xtd.forms - Reference Guide  0.1.0
Modern c++17 library containing classes for creating Windows-based applications that take full advantage of the rich user interface features available in the Microsoft Windows, Apple macOS and Linux like Ubuntu operating system.
xtd::forms::color_dialog Class Reference

Represents a common dialog box that displays available colors along with controls that enable the user to define custom colors. More...

#include <color_dialog.hpp>

Inheritance diagram for xtd::forms::color_dialog:
xtd::forms::common_dialog xtd::forms::component

Public Member Functions

 color_dialog ()=default
 Initializes a new instance of the color_dialog class. More...
 
bool allow_full_open () const
 Gets a value indicating whether the user can use the dialog box to define custom colors. More...
 
color_dialogallow_full_open (bool allow_full_open)
 Sets a value indicating whether the user can use the dialog box to define custom colors. More...
 
bool alpha_color () const
 Gets a value indicating whether the dialog box shows alpha values and an opacity selector (slider). More...
 
color_dialogalpha_color (bool alpha_color)
 Sets a value indicating whether the user can use the dialog box to define custom colors. More...
 
bool any_color () const
 Gets a value indicating whether the dialog box displays all available colors in the set of basic colors. More...
 
color_dialogany_color (bool any_color)
 Sets a value indicating whether the dialog box displays all available colors in the set of basic colors. More...
 
drawing::color color () const
 Gets the color selected by the user. More...
 
color_dialogcolor (const drawing::color &color)
 Sets the color selected by the user. More...
 
const std::optional< std::vector< int32_t > > & custom_colors () const
 Gets the set of custom colors shown in the dialog box. More...
 
color_dialogcustom_colors (const std::vector< int32_t > &custom_colors)
 Sets the set of custom colors shown in the dialog box. More...
 
bool full_open () const
 Gets a value indicating whether the controls used to create custom colors are visible when the dialog box is opened. More...
 
color_dialogfull_open (bool full_open)
 Sets a value indicating whether the controls used to create custom colors are visible when the dialog box is opened. More...
 
size_t options () const
 
void reset () override
 Resets all options to their default values, the last selected color to black, and the custom colors to their default values. More...
 
bool show_help () const
 Gets a value indicating whether a Help button appears in the color dialog box. More...
 
color_dialogshow_help (bool show_help)
 Sets a value indicating whether a Help button appears in the color dialog box. More...
 
bool solid_color_only () const
 Gets a value indicating whether the dialog box will restrict users to selecting solid colors only. More...
 
color_dialogsolid_color_only (bool solid_color_only)
 Sets a value indicating whether the dialog box will restrict users to selecting solid colors only. More...
 
- Public Member Functions inherited from xtd::forms::common_dialog
 common_dialog ()=default
 Initializes a new instance of the common_dialog class. More...
 
xtd::forms::dialog_result show_dialog ()
 Runs a common dialog box with a default owner. More...
 
xtd::forms::dialog_result show_dialog (const iwin32_window &owner)
 Runs a common dialog box with the specified owner. More...
 
std::any tag () const
 Gets an object that contains data about the control. More...
 
common_dialogtag (const std::any &tag)
 Sets an object that contains data about the control. More...
 

Protected Member Functions

bool run_dialog (intptr_t owner) override
 When overridden in a derived class, specifies a common dialog box. More...
 
- Protected Member Functions inherited from xtd::forms::common_dialog
virtual void on_help_request (help_event_args &e)
 Raises the help_request event. More...
 
- Protected Member Functions inherited from xtd::forms::component
virtual bool can_raise_events () const
 Gets a value indicating whether the component can raise an event. More...
 
bool design_mode () const
 Gets a value that indicates whether the component is currently in design mode. More...
 

Additional Inherited Members

- Public Attributes inherited from xtd::forms::common_dialog
event< common_dialog, help_event_handler< component & > > help_request
 Occurs when the user clicks the Help button on a common dialog box. More...
 

Detailed Description

Represents a common dialog box that displays available colors along with controls that enable the user to define custom colors.

Remarks
The inherited member show_dialog must be invoked to create this specific common dialog box. hook_proc can be overridden to implement specific dialog box hook functionality. Use color to retrieve the color selected by the user.
When you create an instance of color_dialog, some of the read/write properties are set to initial values. For a list of these values, see the color_dialog constructor.
Example
The following code example demonstrate the use of color_dialog dialog.
#include <xtd/xtd.forms>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Color dialog example");
controls().push_back(button1);
button1.location({10, 10});
button1.text("Color...");
button1.click += [this] {
color_dialog.color(this->back_color());
if (color_dialog.show_dialog() == forms::dialog_result::ok)
this->back_color(color_dialog.color());
};
}
private:
};
int main() {
application::run(form1());
}

Constructor & Destructor Documentation

§ color_dialog()

xtd::forms::color_dialog::color_dialog ( )
default

Initializes a new instance of the color_dialog class.

Remarks
When you create an instance of ColorDialog, the following read/write properties are set to initial values.
Property Initial Value
alpha_color true
allow_full_open true
any_color false
color drawing::color::black
custom_colors has no value
full_open false
show_help false
solid_color_only false
You can change the value for any of these properties through a separate call to the property.

Member Function Documentation

§ allow_full_open() [1/2]

bool xtd::forms::color_dialog::allow_full_open ( ) const
inline

Gets a value indicating whether the user can use the dialog box to define custom colors.

Returns
true if the user can define custom colors; otherwise, false. The default is true.

§ allow_full_open() [2/2]

color_dialog& xtd::forms::color_dialog::allow_full_open ( bool  allow_full_open)
inline

Sets a value indicating whether the user can use the dialog box to define custom colors.

Parameters
allow_full_opentrue if the user can define custom colors; otherwise, false. The default is true.

§ alpha_color() [1/2]

bool xtd::forms::color_dialog::alpha_color ( ) const
inline

Gets a value indicating whether the dialog box shows alpha values and an opacity selector (slider).

Returns
true if the dialog box shows alpha values and an opacity selector (slider); otherwise, false. The default is true.

§ alpha_color() [2/2]

color_dialog& xtd::forms::color_dialog::alpha_color ( bool  alpha_color)
inline

Sets a value indicating whether the user can use the dialog box to define custom colors.

Parameters
alpha_colortrue if the dialog box shows alpha values and an opacity selector (slider); otherwise, false.

§ any_color() [1/2]

bool xtd::forms::color_dialog::any_color ( ) const
inline

Gets a value indicating whether the dialog box displays all available colors in the set of basic colors.

Returns
true if the dialog box displays all available colors in the set of basic colors; otherwise, false. The default value is false.

§ any_color() [2/2]

color_dialog& xtd::forms::color_dialog::any_color ( bool  any_color)
inline

Sets a value indicating whether the dialog box displays all available colors in the set of basic colors.

Parameters
any_colortrue if the dialog box displays all available colors in the set of basic colors; otherwise, false. The default value is false.

§ color() [1/2]

drawing::color xtd::forms::color_dialog::color ( ) const
inline

Gets the color selected by the user.

Returns
The color selected by the user. If a color is not selected, the default value is black.
Remarks
The color selected by the user in the dialog box at run time, as defined in color structure.

§ color() [2/2]

color_dialog& xtd::forms::color_dialog::color ( const drawing::color color)
inline

Sets the color selected by the user.

Parameters
colorThe color selected by the user. If a color is not selected.
Remarks
The color selected by the user in the dialog box at run time, as defined in color structure.

§ custom_colors() [1/2]

const std::optional<std::vector<int32_t> >& xtd::forms::color_dialog::custom_colors ( ) const
inline

Gets the set of custom colors shown in the dialog box.

Returns
A set of custom colors shown by the dialog box. The default value is empty.
Remarks
Users can create their own set of custom colors. These colors are contained in an int32_t composed of the BGR (blue, green, red) values necessary to create the color.
Custom colors can only be defined if allow_full_open is set to true.

§ custom_colors() [2/2]

color_dialog& xtd::forms::color_dialog::custom_colors ( const std::vector< int32_t > &  custom_colors)
inline

Sets the set of custom colors shown in the dialog box.

Parameters
custom_colorA set of custom colors shown by the dialog box.
Remarks
Users can create their own set of custom colors. These colors are contained in an int32_t composed of the BGR (blue, green, red) values necessary to create the color.
Custom colors can only be defined if allow_full_open is set to true.

§ full_open() [1/2]

bool xtd::forms::color_dialog::full_open ( ) const
inline

Gets a value indicating whether the controls used to create custom colors are visible when the dialog box is opened.

Returns
true if the custom color controls are available when the dialog box is opened; otherwise, false. The default value is false.
Remarks
By default, the custom color controls are not visible when the dialog box is first opened. You must click the Custom Colors button to display them.
Note
If allow_full_open is false, then full_open has no effect.

§ full_open() [2/2]

color_dialog& xtd::forms::color_dialog::full_open ( bool  full_open)
inline

Sets a value indicating whether the controls used to create custom colors are visible when the dialog box is opened.

Parameters
full_opentrue if the custom color controls are available when the dialog box is opened; otherwise, false. The default value is false.
Remarks
By default, the custom color controls are not visible when the dialog box is first opened. You must click the Custom Colors button to display them.
Note
If allow_full_open is false, then full_open has no effect.

§ options()

size_t xtd::forms::color_dialog::options ( ) const
inline
Returns
Gets values to initialize the color_dialog.
A bitwise combination of internal values that initializes the color_dialog.
The options property corresponds to the flags used to initialize a color dialog box using Win32. Use the properties of the color_dialog class to get and set the options.

§ reset()

void xtd::forms::color_dialog::reset ( )
overridevirtual

Resets all options to their default values, the last selected color to black, and the custom colors to their default values.

Implements xtd::forms::common_dialog.

§ run_dialog()

bool xtd::forms::color_dialog::run_dialog ( intptr_t  owner)
overrideprotectedvirtual

When overridden in a derived class, specifies a common dialog box.

Parameters
ownerA value that represents the window handle of the owner window for the common dialog box.
Returns
true if the dialog box was successfully run; otherwise, false.

Implements xtd::forms::common_dialog.

§ show_help() [1/2]

bool xtd::forms::color_dialog::show_help ( ) const
inline

Gets a value indicating whether a Help button appears in the color dialog box.

Returns
true if the Help button is shown in the dialog box; otherwise, false. The default value is false.

§ show_help() [2/2]

color_dialog& xtd::forms::color_dialog::show_help ( bool  show_help)
inline

Sets a value indicating whether a Help button appears in the color dialog box.

Parameters
show_helptrue if the Help button is shown in the dialog box; otherwise, false.

§ solid_color_only() [1/2]

bool xtd::forms::color_dialog::solid_color_only ( ) const
inline

Gets a value indicating whether the dialog box will restrict users to selecting solid colors only.

Returns
true if users can select only solid colors; otherwise, false. The default value is false.
Remarks
This property is applicable to systems with 256 or fewer colors. On these types of systems, some colors are composites of others.

§ solid_color_only() [2/2]

color_dialog& xtd::forms::color_dialog::solid_color_only ( bool  solid_color_only)
inline

Sets a value indicating whether the dialog box will restrict users to selecting solid colors only.

Parameters
solid_color_onlytrue if users can select only solid colors; otherwise, false.
Remarks
This property is applicable to systems with 256 or fewer colors. On these types of systems, some colors are composites of others.

The documentation for this class was generated from the following file: