xtd - Reference Guide  0.1.2
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
font_dialog.h
Go to the documentation of this file.
1
4#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
13namespace xtd {
15 namespace forms {
28 public:
47 font_dialog() = default;
48
52 bool allow_script_change() const {return !get_option(CF_SELECTSCRIPT);}
57 font_dialog& allow_script_change(bool allow_script_change) {
58 set_option(CF_SELECTSCRIPT, !allow_script_change);
59 return *this;
60 }
61
64 bool allow_simulation() const {return !get_option(CF_NOSIMULATIONS);}
68 font_dialog& allow_simulation(bool allow_simulation) {
69 set_option(CF_NOSIMULATIONS, !allow_simulation);
70 return *this;
71 }
72
75 bool allow_vector_fonts() const {return !get_option(CF_NOVECTORFONTS);}
79 font_dialog& allow_vector_fonts(bool allow_vector_fonts) {
80 set_option(CF_NOVECTORFONTS, !allow_vector_fonts);
81 return *this;
82 }
83
86 bool allow_vertical_fonts() const {return !get_option(CF_NOVERTFONTS);}
90 font_dialog& allow_vertical_fonts(bool allow_vertical_fonts) {
91 set_option(CF_NOVERTFONTS, !allow_vertical_fonts);
92 return *this;
93 }
94
97 drawing::color color() const {return color_;}
102 color_ = color;
103 return *this;
104 }
105
108 bool fixed_pitch_only() const {return get_option(CF_FIXEDPITCHONLY);}
112 font_dialog& fixed_pitch_only(bool fixed_pitch_only) {
113 set_option(CF_FIXEDPITCHONLY, fixed_pitch_only);
114 return *this;
115 }
116
119 drawing::font font() const {return font_;}
124 font_ = font;
125 return *this;
126 }
127
130 bool font_must_exist() const {return get_option(CF_FORCEFONTEXIST);}
134 font_dialog& font_must_exist(bool font_must_exist) {
135 set_option(CF_FORCEFONTEXIST, font_must_exist);
136 return *this;
137 }
138
141 size_t max_size() const {return max_size_;}
145 font_dialog& max_size(size_t max_size) {
146 max_size_ = max_size;
147 return *this;
148 }
149
152 size_t min_size() const {return min_size_;}
156 font_dialog& min_size(size_t min_size) {
157 min_size_ = min_size;
158 return *this;
159 }
160
164 size_t options() const {return options_;}
165
168 bool script_only() const {return get_option(CF_SCRIPTSONLY);}
172 font_dialog& script_only(bool script_only) {
173 set_option(CF_SCRIPTSONLY, script_only);
174 return *this;
175 }
176
179 bool show_apply() const {return get_option(CF_APPLY);}
183 font_dialog& show_apply(bool show_apply) {
184 set_option(CF_APPLY, show_apply);
185 return *this;
186 }
187
190 bool show_color() const {return show_color_;}
194 font_dialog& show_color(bool show_color) {
195 show_color_ = show_color;
196 return *this;
197 }
198
201 bool show_effect() const {return get_option(CF_EFFECTS);}
205 font_dialog& show_effect(bool show_effect) {
206 set_option(CF_EFFECTS, show_effect);
207 return *this;
208 }
209
212 bool show_help() const {return get_option(CF_SHOWHELP);}
216 font_dialog& show_help(bool show_help) {
217 set_option(CF_SHOWHELP, show_help);
218 return *this;
219 }
220
225
228 void reset() override;
229
230 protected:
236 virtual void on_apply(const event_args& e);
237
242 bool run_dialog(intptr_t owner) override;
243
246 void run_sheet(intptr_t owner) override;
247
248 private:
249 bool get_option(size_t flag) const {return (options_ & flag) == flag;}
250 void set_option(size_t flag, bool value) {options_ = value ? options_ | flag : options_ & ~flag;}
251
252 drawing::color color_ = xtd::forms::theme_colors::current_theme().control_text();
253 drawing::font font_ = drawing::system_fonts::default_font();
254 size_t max_size_ = 0;
255 size_t min_size_ = 0;
256 size_t options_ = CF_TTONLY;
257 bool show_color_ = false;
258 };
259 }
260}
Represents an ARGB (alpha, red, green, blue) color.
Definition color.h:39
Defines a particular format for text, including font face, size, and style attributes....
Definition font.h:39
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.h:18
Represents an event.
Definition event.h:21
Specifies the base class used for displaying dialog boxes on the screen.
Definition common_dialog.h:31
Prompts the user to choose a font from among those installed on the local computer.
Definition font_dialog.h:27
bool show_help() const
Gets a value indicating whether the dialog box displays a Help button.
Definition font_dialog.h:212
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:112
size_t max_size() const
Gets the maximum point size a user can select.
Definition font_dialog.h:141
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:172
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:90
void reset() override
Resets all dialog box options to their default values.
size_t options() const
Gets values to initialize the font_dialog.
Definition font_dialog.h:164
virtual void on_apply(const event_args &e)
Raises the font_dialog::apply event.
font_dialog & max_size(size_t max_size)
Sets the maximum point size a user can select.
Definition font_dialog.h:145
font_dialog & show_help(bool show_help)
Sets a value indicating whether the dialog box displays a Help button.
Definition font_dialog.h:216
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:168
bool run_dialog(intptr_t owner) override
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:134
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:205
drawing::color color() const
Gets the selected font color.
Definition font_dialog.h:97
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:201
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:68
bool show_apply() const
Gets a value indicating whether the dialog box contains an Apply button.
Definition font_dialog.h:179
font_dialog & show_color(bool show_color)
Sets a value indicating whether the dialog box displays the color choice.
Definition font_dialog.h:194
font_dialog()=default
Initializes a new instance of the font_dialog class.
font_dialog & font(const drawing::font &font)
Sets the selected font.
Definition font_dialog.h:123
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:52
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:86
font_dialog & color(const drawing::color &color)
Sets the selected font color.
Definition font_dialog.h:101
size_t min_size() const
Gets the minimum point size a user can select.
Definition font_dialog.h:152
void run_sheet(intptr_t owner) override
When overridden in a derived class, specifies a common dialog box.
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:79
font_dialog & show_apply(bool show_apply)
Sets a value indicating whether the dialog box contains an Apply button.
Definition font_dialog.h:183
bool allow_simulation() const
Gets a value indicating whether the dialog box allows graphics device interface (GDI) font simulation...
Definition font_dialog.h:64
font_dialog & min_size(size_t min_size)
Sets the minimum point size a user can select.
Definition font_dialog.h:156
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:57
bool allow_vector_fonts() const
Gets a value indicating whether the dialog box allows vector font selections.
Definition font_dialog.h:75
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:108
bool show_color() const
Gets a value indicating whether the dialog box displays the color choice.
Definition font_dialog.h:190
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:130
drawing::font font() const
Gets the selected font.
Definition font_dialog.h:119
Contains xtd::drawing::color class.
Contains xtd::forms::common_dialog class.
Contains xtd::drawing::font class.
event< font_dialog, event_handler > apply
Occurs when the user clicks the Apply button in the font dialog box.
Definition font_dialog.h:224
#define forms_export_
Define shared library export.
Definition forms_export.h:13
@ 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
Contains xtd::drawing::system_colors factory.
Contains xtd::drawing::system_fonts factory.