xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
color_dialog.h
Go to the documentation of this file.
1
4#pragma once
5#include <xtd/drawing/color.h>
6#include <xtd/forms/choose_color_flags.h>
7#include "../forms_export.h"
8#include "common_dialog.h"
9
11namespace xtd {
13 namespace forms {
26 public:
40 color_dialog() = default;
41
44 bool alpha_color() const {return get_option(CC_ALPHACOLOR);}
47 color_dialog& alpha_color(bool alpha_color) {
48 set_option(CC_ALPHACOLOR, alpha_color);
49 return *this;
50 }
51
54 bool allow_full_open() const {return get_option(CC_PREVENTFULLOPEN);}
57 color_dialog& allow_full_open(bool allow_full_open) {
58 set_option(CC_PREVENTFULLOPEN, allow_full_open);
59 return *this;
60 }
61
64 bool any_color() const {return get_option(CC_ANYCOLOR);}
67 color_dialog& any_color(bool any_color) {
68 set_option(CC_ANYCOLOR, any_color);
69 return *this;
70 }
71
75 drawing::color color() const {return color_;}
80 color_ = color;
81 return *this;
82 }
83
88 const std::vector<xtd::drawing::color>& custom_colors() const {return custom_colors_;}
93 color_dialog& custom_colors(const std::vector<xtd::drawing::color>& custom_colors) {
94 for (size_t index = 0; index < custom_colors.size(); index++)
95 custom_colors_[index] = custom_colors[index];
96 for (size_t index = custom_colors.size(); index < custom_colors_.size(); index++)
97 custom_colors_[index] = xtd::drawing::color::white;
98 return *this;
99 }
100
105 bool full_open() const {return get_option(CC_FULLOPEN);}
110 color_dialog& full_open(bool full_open) {
111 set_option(CC_FULLOPEN, full_open);
112 return *this;
113 }
114
118 size_t options() const {return options_;}
119
122 bool show_help() const {return get_option(CC_SHOWHELP);}
125 color_dialog& show_help(bool show_help) {
126 set_option(CC_SHOWHELP, show_help);
127 return *this;
128 }
129
133 bool solid_color_only() const {return get_option(CC_SOLIDCOLOR);}
137 color_dialog& solid_color_only(bool solid_color_only) {
138 set_option(CC_SOLIDCOLOR, solid_color_only);
139 return *this;
140 }
141
143 void reset() override;
144
145 protected:
149 bool run_dialog(intptr_t owner) override;
150
153 void run_sheet(intptr_t owner) override;
154
155 private:
156 bool get_option(size_t flag) const {return (options_ & flag) == flag;}
157 void set_option(size_t flag, bool value) {options_ = value ? options_ | flag : options_ & ~flag;}
158
159 drawing::color color_ = drawing::color::black;
160 std::vector<xtd::drawing::color> custom_colors_ {16, xtd::drawing::color::white};
161 size_t options_ = CC_ALPHACOLOR | CC_PREVENTFULLOPEN;
162 };
163 }
164}
Represents an ARGB (alpha, red, green, blue) color.
Definition: color.h:39
static const xtd::drawing::color white
Gets a system-defined color that has an ARGB value of 0xFFFFFFFF. This field is constant.
Definition: color.h:459
Represents a common dialog box that displays available colors along with controls that enable the use...
Definition: color_dialog.h:25
color_dialog()=default
Initializes a new instance of the color_dialog class.
bool allow_full_open() const
Gets a value indicating whether the user can use the dialog box to define custom colors.
Definition: color_dialog.h:54
color_dialog & color(const drawing::color &color)
Sets the color selected by the user.
Definition: color_dialog.h:79
bool show_help() const
Gets a value indicating whether a Help button appears in the color dialog box.
Definition: color_dialog.h:122
bool full_open() const
Gets a value indicating whether the controls used to create custom colors are visible when the dialog...
Definition: color_dialog.h:105
color_dialog & show_help(bool show_help)
Sets a value indicating whether a Help button appears in the color dialog box.
Definition: color_dialog.h:125
color_dialog & solid_color_only(bool solid_color_only)
Sets a value indicating whether the dialog box will restrict users to selecting solid colors only.
Definition: color_dialog.h:137
bool any_color() const
Gets a value indicating whether the dialog box displays all available colors in the set of basic colo...
Definition: color_dialog.h:64
bool alpha_color() const
Gets a value indicating whether the dialog box shows alpha values and an opacity selector (slider).
Definition: color_dialog.h:44
color_dialog & full_open(bool full_open)
Sets a value indicating whether the controls used to create custom colors are visible when the dialog...
Definition: color_dialog.h:110
color_dialog & allow_full_open(bool allow_full_open)
Sets a value indicating whether the user can use the dialog box to define custom colors.
Definition: color_dialog.h:57
color_dialog & alpha_color(bool alpha_color)
Sets a value indicating whether the user can use the dialog box to define custom colors.
Definition: color_dialog.h:47
color_dialog & any_color(bool any_color)
Sets a value indicating whether the dialog box displays all available colors in the set of basic colo...
Definition: color_dialog.h:67
void run_sheet(intptr_t owner) override
When overridden in a derived class, specifies a common dialog box.
bool solid_color_only() const
Gets a value indicating whether the dialog box will restrict users to selecting solid colors only.
Definition: color_dialog.h:133
bool run_dialog(intptr_t owner) override
When overridden in a derived class, specifies a common dialog box.
void reset() override
Resets all options to their default values, the last selected color to black, and the custom colors t...
color_dialog & custom_colors(const std::vector< xtd::drawing::color > &custom_colors)
Sets the set of custom colors shown in the dialog box.
Definition: color_dialog.h:93
size_t options() const
Gets values to initialize the color_dialog.
Definition: color_dialog.h:118
drawing::color color() const
Gets the color selected by the user.
Definition: color_dialog.h:75
const std::vector< xtd::drawing::color > & custom_colors() const
Gets the set of custom colors shown in the dialog box.
Definition: color_dialog.h:88
Specifies the base class used for displaying dialog boxes on the screen.
Definition: common_dialog.h:31
Contains xtd::drawing::color class.
Contains xtd::forms::common_dialog class.
#define forms_export_
Define shared library export.
Definition: forms_export.h:13
@ alpha_color
The color box shows alpha values and an opacity selector (slider).
@ allow_full_open
The user can use the dialog box to define custom colors.
@ solid_color_only
The dialog box will restrict users to selecting solid colors only.
@ full_open
The controls used to create custom colors are visible when the dialog box is opened.
@ any_color
The dialog box displays all available colors in the set of basic colors.
@ show_help
A Help button appears in the color dialog box.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17