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.
font_dialog.h
Go to the documentation of this file.
1 #pragma once
5 #include <xtd/drawing/color.h>
6 #include <xtd/drawing/font.h>
9 #include <xtd/forms/choose_font_flags.h>
10 #include "common_dialog.h"
11 
13 namespace xtd {
15  namespace forms {
27  class forms_export_ font_dialog : public common_dialog {
28  public:
30 
50  font_dialog() = default;
52 
54 
59  bool allow_script_change() const {return !get_option(CF_SELECTSCRIPT);}
65  set_option(CF_SELECTSCRIPT, !allow_script_change);
66  return *this;
67  }
68 
71  bool allow_simulation() const {return !get_option(CF_NOSIMULATIONS);}
75  font_dialog& allow_simulation(bool allow_simulation) {
76  set_option(CF_NOSIMULATIONS, !allow_simulation);
77  return *this;
78  }
79 
82  bool allow_vector_fonts() const {return !get_option(CF_NOVECTORFONTS);}
87  set_option(CF_NOVECTORFONTS, !allow_vector_fonts);
88  return *this;
89  }
90 
93  bool allow_vertical_fonts() const {return !get_option(CF_NOVERTFONTS);}
98  set_option(CF_NOVERTFONTS, !allow_vertical_fonts);
99  return *this;
100  }
101 
104  drawing::color color() const {return color_;}
109  color_ = color;
110  return *this;
111  }
112 
115  bool fixed_pitch_only() const {return get_option(CF_FIXEDPITCHONLY);}
120  set_option(CF_FIXEDPITCHONLY, fixed_pitch_only);
121  return *this;
122  }
123 
126  drawing::font font() const {return font_;}
131  font_ = font;
132  return *this;
133  }
134 
137  bool font_must_exist() const {return get_option(CF_FORCEFONTEXIST);}
141  font_dialog& font_must_exist(bool font_must_exist) {
142  set_option(CF_FORCEFONTEXIST, font_must_exist);
143  return *this;
144  }
145 
148  size_t max_size() const {return max_size_;}
152  font_dialog& max_size(size_t max_size) {
153  max_size_ = max_size;
154  return *this;
155  }
156 
159  size_t min_size() const {return min_size_;}
163  font_dialog& min_size(size_t min_size) {
164  min_size_ = min_size;
165  return *this;
166  }
167 
171  size_t options() const {return options_;}
172 
175  bool script_only() const {return get_option(CF_SCRIPTSONLY);}
179  font_dialog& script_only(bool script_only) {
180  set_option(CF_SCRIPTSONLY, script_only);
181  return *this;
182  }
183 
186  bool show_apply() const {return get_option(CF_APPLY);}
191  set_option(CF_APPLY, show_apply);
192  return *this;
193  }
194 
197  bool show_color() const {return show_color_;}
202  show_color_ = show_color;
203  return *this;
204  }
205 
208  bool show_effect() const {return get_option(CF_EFFECTS);}
212  font_dialog& show_effect(bool show_effect) {
213  set_option(CF_EFFECTS, show_effect);
214  return *this;
215  }
216 
219  bool show_help() const {return get_option(CF_SHOWHELP);}
224  set_option(CF_SHOWHELP, show_help);
225  return *this;
226  }
228 
230 
234  void reset() override;
236 
238 
246 
247  protected:
249 
256  virtual void on_apply(const event_args& e);
257 
262  bool run_dialog(intptr_t owner) override;
263 
266  void run_sheet(intptr_t owner) override;
268 
269  private:
270  bool get_option(size_t flag) const {return (options_ & flag) == flag;}
271  void set_option(size_t flag, bool value) {options_ = value ? options_ | flag : options_ & ~flag;}
272 
273  drawing::color color_ = xtd::forms::theme_colors::current_theme().control_text();
275  size_t max_size_ = 0;
276  size_t min_size_ = 0;
277  size_t options_ = CF_TTONLY;
278  bool show_color_ = false;
279  };
280  }
281 }
A Help button appears in the color dialog box.
bool fixed_pitch_only() const
Gets a value indicating whether the dialog box allows only the selection of fixed-pitch fonts...
Definition: font_dialog.h:115
Whether the dialog box allows vector font selections.
Defines a particular format for text, including font face, size, and style attributes. This class cannot be inherited.
Definition: font.h:39
size_t max_size() const
Gets the maximum point size a user can select.
Definition: font_dialog.h:148
font_dialog & show_apply(bool show_apply)
Sets a value indicating whether the dialog box contains an Apply button.
Definition: font_dialog.h:190
font_dialog & show_effect(bool show_effect)
Sets a value indicating whether the dialog box contains controls that allow the user to specify strik...
Definition: font_dialog.h:212
bool script_only() const
Gets a value indicating whether the dialog box allows selection of fonts for all non-OEM and Symbol c...
Definition: font_dialog.h:175
bool allow_vertical_fonts() const
Gets a value indicating whether the dialog box displays both vertical and horizontal fonts or only ho...
Definition: font_dialog.h:93
font_dialog & show_help(bool show_help)
Sets a value indicating whether the dialog box displays a Help button.
Definition: font_dialog.h:223
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
bool font_must_exist() const
Gets a value indicating whether the dialog box specifies an error condition if the user attempts to s...
Definition: font_dialog.h:137
font_dialog & script_only(bool script_only)
Sets a value indicating whether the dialog box allows selection of fonts for all non-OEM and Symbol c...
Definition: font_dialog.h:179
Contains xtd::drawing::system_fonts factory.
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
static xtd::drawing::font default_font()
Gets the default font that applications can use for dialog boxes and forms.
bool show_effect() const
Gets a value indicating whether the dialog box contains controls that allow the user to specify strik...
Definition: font_dialog.h:208
bool show_apply() const
Gets a value indicating whether the dialog box contains an Apply button.
Definition: font_dialog.h:186
drawing::color color() const
Gets the selected font color.
Definition: font_dialog.h:104
bool allow_vector_fonts() const
Gets a value indicating whether the dialog box allows vector font selections.
Definition: font_dialog.h:82
font_dialog & max_size(size_t max_size)
Sets the maximum point size a user can select.
Definition: font_dialog.h:152
font_dialog & allow_script_change(bool allow_script_change)
Sets a value indicating whether the user can change the character set specified in the Script combo b...
Definition: font_dialog.h:64
Represents an ARGB (alpha, red, green, blue) color.
Definition: color.h:39
Represents an event.
Definition: event.h:21
Prompts the user to choose a font from among those installed on the local computer.
Definition: font_dialog.h:27
Whether the dialog box contains an Apply button.
Whether the dialog box allows only the selection of fixed-pitch fonts.
font_dialog & color(const drawing::color &color)
Sets the selected font color.
Definition: font_dialog.h:108
Whether the dialog box displays the color choice.
font_dialog & show_color(bool show_color)
Sets a value indicating whether the dialog box displays the color choice.
Definition: font_dialog.h:201
Contains xtd::drawing::color class.
font_dialog & font(const drawing::font &font)
Sets the selected font.
Definition: font_dialog.h:130
Whether the user can change the character set specified in the Script combo box to display a characte...
bool allow_simulation() const
Gets a value indicating whether the dialog box allows graphics device interface (GDI) font simulation...
Definition: font_dialog.h:71
drawing::font font() const
Gets the selected font.
Definition: font_dialog.h:126
font_dialog & allow_vector_fonts(bool allow_vector_fonts)
Sets a value indicating whether the dialog box allows vector font selections.
Definition: font_dialog.h:86
size_t min_size() const
Gets the minimum point size a user can select.
Definition: font_dialog.h:159
font_dialog & min_size(size_t min_size)
Sets the minimum point size a user can select.
Definition: font_dialog.h:163
font_dialog & allow_simulation(bool allow_simulation)
Sets a value indicating whether the dialog box allows graphics device interface (GDI) font simulation...
Definition: font_dialog.h:75
font_dialog & fixed_pitch_only(bool fixed_pitch_only)
Sets a value indicating whether the dialog box allows only the selection of fixed-pitch fonts...
Definition: font_dialog.h:119
Contains xtd::drawing::system_colors factory.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
bool show_help() const
Gets a value indicating whether the dialog box displays a Help button.
Definition: font_dialog.h:219
Whether the dialog box displays both vertical and horizontal fonts or only horizontal fonts...
bool allow_script_change() const
Gets a value indicating whether the user can change the character set specified in the Script combo b...
Definition: font_dialog.h:59
size_t options() const
Gets values to initialize the font_dialog.
Definition: font_dialog.h:171
font_dialog & allow_vertical_fonts(bool allow_vertical_fonts)
Sets a value indicating whether the dialog box displays both vertical and horizontal fonts or only ho...
Definition: font_dialog.h:97
Specifies the base class used for displaying dialog boxes on the screen.
Definition: common_dialog.h:31
bool show_color() const
Gets a value indicating whether the dialog box displays the color choice.
Definition: font_dialog.h:197
font_dialog & font_must_exist(bool font_must_exist)
Sets a value indicating whether the dialog box specifies an error condition if the user attempts to s...
Definition: font_dialog.h:141
event< font_dialog, event_handler > apply
Occurs when the user clicks the Apply button in the font dialog box.
Definition: font_dialog.h:244
Contains xtd::drawing::font class.