xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
color_dialog.h
Go to the documentation of this file.
1 #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 
11 namespace xtd {
13  namespace forms {
25  class forms_export_ color_dialog : public common_dialog {
26  public:
28 
43  color_dialog() = default;
45 
47 
51  bool alpha_color() const {return get_option(CC_ALPHACOLOR);}
55  set_option(CC_ALPHACOLOR, alpha_color);
56  return *this;
57  }
58 
61  bool allow_full_open() const {return get_option(CC_PREVENTFULLOPEN);}
65  set_option(CC_PREVENTFULLOPEN, allow_full_open);
66  return *this;
67  }
68 
71  bool any_color() const {return get_option(CC_ANYCOLOR);}
75  set_option(CC_ANYCOLOR, any_color);
76  return *this;
77  }
78 
82  drawing::color color() const {return color_;}
87  color_ = color;
88  return *this;
89  }
90 
95  const std::vector<xtd::drawing::color>& custom_colors() const {return custom_colors_;}
100  color_dialog& custom_colors(const std::vector<xtd::drawing::color>& custom_colors) {
101  for (size_t index = 0; index < custom_colors.size(); index++)
102  custom_colors_[index] = custom_colors[index];
103  for (size_t index = custom_colors.size(); index < custom_colors_.size(); index++)
104  custom_colors_[index] = xtd::drawing::color::white;
105  return *this;
106  }
107 
112  bool full_open() const {return get_option(CC_FULLOPEN);}
118  set_option(CC_FULLOPEN, full_open);
119  return *this;
120  }
121 
125  size_t options() const {return options_;}
126 
129  bool show_help() const {return get_option(CC_SHOWHELP);}
133  set_option(CC_SHOWHELP, show_help);
134  return *this;
135  }
136 
140  bool solid_color_only() const {return get_option(CC_SOLIDCOLOR);}
145  set_option(CC_SOLIDCOLOR, solid_color_only);
146  return *this;
147  }
149 
151 
154  void reset() override;
156 
157  protected:
159 
164  bool run_dialog(intptr_t owner) override;
165 
168  void run_sheet(intptr_t owner) override;
170 
171  private:
172  bool get_option(size_t flag) const {return (options_ & flag) == flag;}
173  void set_option(size_t flag, bool value) {options_ = value ? options_ | flag : options_ & ~flag;}
174 
176  std::vector<xtd::drawing::color> custom_colors_ {16, xtd::drawing::color::white};
177  size_t options_ = CC_ALPHACOLOR | CC_PREVENTFULLOPEN;
178  };
179  }
180 }
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:74
A Help button appears in the color dialog box.
Represents a common dialog box that displays available colors along with controls that enable the use...
Definition: color_dialog.h:25
size_t options() const
Gets values to initialize the color_dialog.
Definition: color_dialog.h:125
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:100
bool alpha_color() const
Gets a value indicating whether the dialog box shows alpha values and an opacity selector (slider)...
Definition: color_dialog.h:51
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:132
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:61
The controls used to create custom colors are visible when the dialog box is opened.
Contains xtd::forms::common_dialog class.
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
The color box shows alpha values and an opacity selector (slider).
const std::vector< xtd::drawing::color > & custom_colors() const
Gets the set of custom colors shown in the dialog box.
Definition: color_dialog.h:95
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:64
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:112
Represents an ARGB (alpha, red, green, blue) color.
Definition: color.h:39
bool show_help() const
Gets a value indicating whether a Help button appears in the color dialog box.
Definition: color_dialog.h:129
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:54
color_dialog & color(const drawing::color &color)
Sets the color selected by the user.
Definition: color_dialog.h:86
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:144
The dialog box will restrict users to selecting solid colors only.
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:140
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:71
The dialog box displays all available colors in the set of basic colors.
Contains xtd::drawing::color class.
drawing::color color() const
Gets the color selected by the user.
Definition: color_dialog.h:82
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:462
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
The user can use the dialog box to define custom colors.
Specifies the base class used for displaying dialog boxes on the screen.
Definition: common_dialog.h:31
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:117
static const xtd::drawing::color black
Gets a system-defined color that has an ARGB value of 0xFF000000. This field is constant.
Definition: color.h:72