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_box.h
Go to the documentation of this file.
1 #pragma once
5 #include "color_dialog.h"
6 #include "color_box_styles.h"
7 #include <xtd/static.h>
8 
10 namespace xtd {
12  namespace forms {
22  class color_box final static_ {
23  public:
29  static xtd::forms::dialog_result show(xtd::drawing::color& color, const xtd::forms::iwin32_window& owner) {return show_color_box(color, &owner);}
36  static xtd::forms::dialog_result show(xtd::drawing::color& color, const xtd::forms::iwin32_window& owner, color_box_styles styles) {return show_color_box(color, &owner, styles);}
44  static xtd::forms::dialog_result show(xtd::drawing::color& color, const xtd::forms::iwin32_window& owner, color_box_styles styles, const std::vector<xtd::drawing::color>& custom_colors) {return show_color_box(color, &owner, styles, custom_colors);}
45 
50  static xtd::forms::dialog_result show(xtd::drawing::color& color) {return show_color_box(color, nullptr);}
56  static xtd::forms::dialog_result show(xtd::drawing::color& color, color_box_styles styles) {return show_color_box(color, nullptr, styles);}
63  static xtd::forms::dialog_result show(xtd::drawing::color& color, color_box_styles styles, const std::vector<xtd::drawing::color>& custom_colors) {return show_color_box(color, nullptr, styles, custom_colors);}
64 
65  private:
66  static xtd::forms::dialog_result show_color_box(xtd::drawing::color& color, const xtd::forms::iwin32_window* owner = nullptr, color_box_styles styles = color_box_styles::alpha_color|color_box_styles::allow_full_open, const std::optional<std::vector<xtd::drawing::color>>& custom_colors = std::optional<std::vector<xtd::drawing::color>> {}) {
68  dialog.color(color);
69  dialog.alpha_color((styles & color_box_styles::alpha_color) == color_box_styles::alpha_color);
70  dialog.allow_full_open((styles & color_box_styles::allow_full_open) == color_box_styles::allow_full_open);
71  dialog.any_color((styles & color_box_styles::any_color) == color_box_styles::any_color);
72  dialog.full_open((styles & color_box_styles::full_open) == color_box_styles::full_open);
73  dialog.show_help((styles & color_box_styles::show_help) == color_box_styles::show_help);
74  if (custom_colors.has_value()) dialog.custom_colors(custom_colors.value());
75  dialog.solid_color_only((styles & color_box_styles::solid_color_only) == color_box_styles::solid_color_only);
76  xtd::forms::dialog_result result = owner ? dialog.show_sheet_dialog(*owner) : dialog.show_dialog();
77  if (result == xtd::forms::dialog_result::ok) color = dialog.color();
78  return result;
79  }
80  };
81  }
82 }
A Help button appears in the color dialog box.
Contains xtd::static_object class.
Represents a common dialog box that displays available colors along with controls that enable the use...
Definition: color_dialog.h:25
xtd::forms::dialog_result show_dialog()
Runs a common dialog box with a default owner.
Definition: common_dialog.h:60
dialog_result
Specifies identifiers to indicate the return value of a dialog box.
Definition: dialog_result.h:39
#define static_
This keyword is use to represent a static object. A static object can&#39;t be instantiated (constructors...
Definition: static.h:38
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
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
The controls used to create custom colors are visible when the dialog box is opened.
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).
static xtd::forms::dialog_result show(xtd::drawing::color &color, color_box_styles styles)
Displays a color box. The color box displays a color with styles.
Definition: color_box.h:56
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
Represents a common dialog box that displays available colors along with controls that enable the use...
Definition: color_box.h:22
static xtd::forms::dialog_result show(xtd::drawing::color &color, const xtd::forms::iwin32_window &owner, color_box_styles styles)
Displays a color box in front of the specified window. The color box displays a color with styles...
Definition: color_box.h:36
Provides an interface to expose Win32 HWND handles.
Definition: iwin32_window.h:19
Contains xtd::forms::color_dialog dialog.
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
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:122
static xtd::forms::dialog_result show(xtd::drawing::color &color, const xtd::forms::iwin32_window &owner)
Displays a color box in front of the specified window. The color box displays a color.
Definition: color_box.h:29
xtd::forms::dialog_result show_sheet_dialog(const iwin32_window &owner)
Runs a common dialog box with the specified owner.
Definition: common_dialog.h:91
static xtd::forms::dialog_result show(xtd::drawing::color &color, const xtd::forms::iwin32_window &owner, color_box_styles styles, const std::vector< xtd::drawing::color > &custom_colors)
Displays a color box in front of the specified window. The color box displays a color with styles...
Definition: color_box.h:44
The dialog box will restrict users to selecting solid colors only.
static xtd::forms::dialog_result show(xtd::drawing::color &color)
Displays a color box. The color box displays a color.
Definition: color_box.h:50
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 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
The dialog box displays all available colors in the set of basic colors.
drawing::color color() const
Gets the color selected by the user.
Definition: color_dialog.h:75
static xtd::forms::dialog_result show(xtd::drawing::color &color, color_box_styles styles, const std::vector< xtd::drawing::color > &custom_colors)
Displays a color box. The color box displays a color with styles, and custom colors.
Definition: color_box.h:63
color_box_styles
Specifies constants defining which color_box styles is used.
Definition: color_box_styles.h:18
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.
The dialog box return value is OK (usually sent from a button labeled OK).
Contains xtd::forms::color_box_styles enum class.