xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
Public Attributes | Public Member Functions | Protected Member Functions | List of all members
xtd::forms::font_dialog Class Reference

#include <font_dialog.h>

Definition

Prompts the user to choose a font from among those installed on the local computer.

Namespace
xtd::forms
Library
xtd.forms
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.
When you create an instance of font_dialog, some of the read/write properties are set to initial values. For a list of these values, see the font_dialog constructor.
Examples
The following code example demonstrate the use of font_dialog dialog.
#include <xtd/xtd>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Font dialog example");
client_size({400, 400});
controls().push_back_range({button1, label1});
button1.location({10, 10});
button1.text("Font...");
button1.click += [&] {
font_dialog.color(label1.fore_color());
font_dialog.font(label1.font());
if (font_dialog.show_dialog(*this) == forms::dialog_result::ok) {
label1.fore_color(font_dialog.color());
label1.font(font_dialog.font());
}
};
label1.location({10, 50});
label1.size({380, 340});
label1.anchor(anchor_styles::left | anchor_styles::top | anchor_styles::right | anchor_styles::bottom);
label1.text(u8"The quick brown fox jumps over the lazy dog.\n"
u8"THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.\n"
u8"0123456789+-*/%~^&|=<>≤≥±÷≠{{[()]}},;:.?¿!¡\n"
u8"àçéèêëïî@@°_#§$ù£€æœø𵩮∞\\\"'\n"
u8"\u0400\u0401\u0402\u0403\u0404\u0405\u0406\u0407\u0408\u0409\u040a\u040b\u040c\u040d\u040e\u040f\n"
u8"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041a\u041b\u041c\u041d\u041e\u041f\n"
u8"\u4ea0\u4ea1\u4ea2\u4ea3\u4ea4\u4ea5\u4ea6\u4ea7\u4ea8\u4ea9\u4eaa\u4eab\u4eac\u4ead\u4eae\u4eaf\n"
u8"\u4eb0\u4eb1\u4eb2\u4eb3\u4eb4\u4eb5\u4eb6\u4eb7\u4eb8\u4eb9\u4eba\u4ebb\u4ebc\u4ebd\u4ebe\u4ebf\n"
u8"\U0001F428");
}
private:
label label1;
};
int main() {
application::run(form1());
}
font(const font &prototype, float em_size)
IInitializes a new Font that uses the specified existing xtd::drawing::font and size.
static void run()
Begins running a standard application message loop on the current thread, without a form.
Represents a Windows button control.
Definition: button.h:54
xtd::forms::dialog_result show_dialog()
Runs a common dialog box with a default owner.
Definition: common_dialog.h:60
Prompts the user to choose a font from among those installed on the local computer.
Definition: font_dialog.h:27
drawing::color color() const
Gets the selected font color.
Definition: font_dialog.h:97
drawing::font font() const
Gets the selected font.
Definition: font_dialog.h:119
Represents a window or dialog box that makes up an application's user interface.
Definition: form.h:40
Represents a standard Windows label.
Definition: label.h:26
@ button1
The first button on the message box is the default button.
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
Examples
font_dialog.cpp.

Inherits xtd::forms::common_dialog.

Public Attributes

event< font_dialog, event_handlerapply
 Occurs when the user clicks the Apply button in the font dialog box.
 
- Public Attributes inherited from xtd::forms::common_dialog
event< common_dialog, dialog_closed_event_handlerdialog_closed
 Occurs when the user close a common dialog box with dialog close button or other dialog buttons.
 
event< common_dialog, help_event_handlerhelp_request
 Occurs when the user clicks the Help button on a common dialog box.
 

Public Member Functions

 font_dialog ()=default
 Initializes a new instance of the font_dialog class.
 
bool allow_script_change () const
 Gets a value indicating whether the user can change the character set specified in the Script combo box to display a character set other than the one currently displayed.
 
font_dialogallow_script_change (bool allow_script_change)
 Sets a value indicating whether the user can change the character set specified in the Script combo box to display a character set other than the one currently displayed.
 
bool allow_simulation () const
 Gets a value indicating whether the dialog box allows graphics device interface (GDI) font simulations.
 
font_dialogallow_simulation (bool allow_simulation)
 Sets a value indicating whether the dialog box allows graphics device interface (GDI) font simulations.
 
bool allow_vector_fonts () const
 Gets a value indicating whether the dialog box allows vector font selections.
 
font_dialogallow_vector_fonts (bool allow_vector_fonts)
 Sets a value indicating whether the dialog box allows vector font selections.
 
bool allow_vertical_fonts () const
 Gets a value indicating whether the dialog box displays both vertical and horizontal fonts or only horizontal fonts.
 
font_dialogallow_vertical_fonts (bool allow_vertical_fonts)
 Sets a value indicating whether the dialog box displays both vertical and horizontal fonts or only horizontal fonts.
 
drawing::color color () const
 Gets the selected font color.
 
font_dialogcolor (const drawing::color &color)
 Sets the selected font color.
 
bool fixed_pitch_only () const
 Gets a value indicating whether the dialog box allows only the selection of fixed-pitch fonts.
 
font_dialogfixed_pitch_only (bool fixed_pitch_only)
 Sets a value indicating whether the dialog box allows only the selection of fixed-pitch fonts.
 
drawing::font font () const
 Gets the selected font.
 
font_dialogfont (const drawing::font &font)
 Sets the selected font.
 
bool font_must_exist () const
 Gets a value indicating whether the dialog box specifies an error condition if the user attempts to select a font or style that does not exist.
 
font_dialogfont_must_exist (bool font_must_exist)
 Sets a value indicating whether the dialog box specifies an error condition if the user attempts to select a font or style that does not exist.
 
size_t max_size () const
 Gets the maximum point size a user can select.
 
font_dialogmax_size (size_t max_size)
 Sets the maximum point size a user can select.
 
size_t min_size () const
 Gets the minimum point size a user can select.
 
font_dialogmin_size (size_t min_size)
 Sets the minimum point size a user can select.
 
size_t options () const
 Gets values to initialize the font_dialog.
 
void reset () override
 Resets all dialog box options to their default values.
 
bool script_only () const
 Gets a value indicating whether the dialog box allows selection of fonts for all non-OEM and Symbol character sets, as well as the ANSI character set.
 
font_dialogscript_only (bool script_only)
 Sets a value indicating whether the dialog box allows selection of fonts for all non-OEM and Symbol character sets, as well as the ANSI character set.
 
bool show_apply () const
 Gets a value indicating whether the dialog box contains an Apply button.
 
font_dialogshow_apply (bool show_apply)
 Sets a value indicating whether the dialog box contains an Apply button.
 
bool show_color () const
 Gets a value indicating whether the dialog box displays the color choice.
 
font_dialogshow_color (bool show_color)
 Sets a value indicating whether the dialog box displays the color choice.
 
bool show_effect () const
 Gets a value indicating whether the dialog box contains controls that allow the user to specify strikethrough, underline, and text color options.
 
font_dialogshow_effect (bool show_effect)
 Sets a value indicating whether the dialog box contains controls that allow the user to specify strikethrough, underline, and text color options.
 
bool show_help () const
 Gets a value indicating whether the dialog box displays a Help button.
 
font_dialogshow_help (bool show_help)
 Sets a value indicating whether the dialog box displays a Help button.
 
- Public Member Functions inherited from xtd::forms::common_dialog
 common_dialog ()=default
 Initializes a new instance of the common_dialog class.
 
xtd::forms::dialog_result dialog_result () const
 Get async dialog_result result after dialog box is closing.
 
virtual void reset ()=0
 When overridden in a derived class, resets the properties of a common dialog box to their default values.
 
xtd::forms::dialog_result show_dialog ()
 Runs a common dialog box with a default owner.
 
xtd::forms::dialog_result show_dialog (const iwin32_window &owner)
 Runs a common dialog box with the specified owner.
 
void show_sheet (const iwin32_window &owner)
 Runs a common dialog box with the specified owner.
 
xtd::forms::dialog_result show_sheet_dialog (const iwin32_window &owner)
 Runs a common dialog box with the specified owner.
 
std::any tag () const
 Gets an object that contains data about the control.
 
common_dialogtag (const std::any &tag)
 Sets an object that contains data about the control.
 
- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object.
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object.
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type.
 
template<typename object_t >
std::unique_ptr< object_t > memberwise_clone () const
 Gets the type of the current instance.
 
virtual xtd::ustring to_string () const noexcept
 Returns a std::string that represents the current object.
 

Protected Member Functions

virtual void on_apply (const event_args &e)
 Raises the font_dialog::apply event.
 
bool run_dialog (intptr_t owner) override
 
void run_sheet (intptr_t owner) override
 When overridden in a derived class, specifies a common dialog box.
 
- Protected Member Functions inherited from xtd::forms::common_dialog
virtual void on_dialog_closed (const dialog_closed_event_args &e)
 Raises the common_dialog::dialog_close event.
 
virtual void on_help_request (help_event_args &e)
 Raises the common_dialog::help_request event.
 
virtual bool run_dialog (intptr_t hwnd_owner)=0
 When overridden in a derived class, specifies a common dialog box.
 
virtual void run_sheet (intptr_t hwnd_owner)=0
 When overridden in a derived class, specifies a common dialog box.
 
- Protected Member Functions inherited from xtd::forms::component
 component ()=default
 Initialises a new instance of the component class.
 
virtual bool can_raise_events () const
 Gets a value indicating whether the component can raise an event.
 
bool design_mode () const
 Gets a value that indicates whether the component is currently in design mode.
 

Additional Inherited Members

- Static Public Member Functions inherited from xtd::object
static bool equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
static bool reference_equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 

Constructor & Destructor Documentation

◆ font_dialog()

xtd::forms::font_dialog::font_dialog ( )
default

Initializes a new instance of the font_dialog class.

Remarks
When you create an instance of font_dialog, the following read/write properties are initialized.
Property Initial value
allow_simulations true
allow_vector_fonts true
allow_vertical_fonts  true
allow_script_change true
color color::black
fixed_pitch_only  false
max_size 0
min_size 0
scripts_only false
show_apply false
show_color false
show_effects true
show_help false
You can change the value for any of these properties through a separate call to the property.

Member Function Documentation

◆ allow_script_change() [1/2]

bool xtd::forms::font_dialog::allow_script_change ( ) const
inline

Gets a value indicating whether the user can change the character set specified in the Script combo box to display a character set other than the one currently displayed.

Returns
true if the user can change the character set specified in the Script combo box; otherwise, false. The default value is true.
Remarks
The Script combo box found on the Font dialog box contains character sets associated with the selected font.

◆ allow_script_change() [2/2]

font_dialog & xtd::forms::font_dialog::allow_script_change ( bool  allow_script_change)
inline

Sets a value indicating whether the user can change the character set specified in the Script combo box to display a character set other than the one currently displayed.

Parameters
allow_script_changetrue if the user can change the character set specified in the Script combo box; otherwise, false. The default value is true.
Returns
Current font_dialog.
Remarks
The Script combo box found on the Font dialog box contains character sets associated with the selected font.

◆ allow_simulation() [1/2]

bool xtd::forms::font_dialog::allow_simulation ( ) const
inline

Gets a value indicating whether the dialog box allows graphics device interface (GDI) font simulations.

Returns
true if font simulations are allowed; otherwise, false. The default value is true.

◆ allow_simulation() [2/2]

font_dialog & xtd::forms::font_dialog::allow_simulation ( bool  allow_simulation)
inline

Sets a value indicating whether the dialog box allows graphics device interface (GDI) font simulations.

Parameters
allow_simulationtrue if font simulations are allowed; otherwise, false. The default value is true.
Returns
Current font_dialog.

◆ allow_vector_fonts() [1/2]

bool xtd::forms::font_dialog::allow_vector_fonts ( ) const
inline

Gets a value indicating whether the dialog box allows vector font selections.

Returns
true if vector fonts are allowed; otherwise, false. The default value is true.

◆ allow_vector_fonts() [2/2]

font_dialog & xtd::forms::font_dialog::allow_vector_fonts ( bool  allow_vector_fonts)
inline

Sets a value indicating whether the dialog box allows vector font selections.

Parameters
allow_vector_fontstrue if vector fonts are allowed; otherwise, false. The default value is true.
Returns
Current font_dialog.

◆ allow_vertical_fonts() [1/2]

bool xtd::forms::font_dialog::allow_vertical_fonts ( ) const
inline

Gets a value indicating whether the dialog box displays both vertical and horizontal fonts or only horizontal fonts.

Returns
true if both vertical and horizontal fonts are allowed; otherwise, false. The default value is true.

◆ allow_vertical_fonts() [2/2]

font_dialog & xtd::forms::font_dialog::allow_vertical_fonts ( bool  allow_vertical_fonts)
inline

Sets a value indicating whether the dialog box displays both vertical and horizontal fonts or only horizontal fonts.

Parameters
allow_vertical_fontstrue if both vertical and horizontal fonts are allowed; otherwise, false. The default value is true.
Returns
Current font_dialog.

◆ color() [1/2]

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

Gets the selected font color.

Returns
The color of the selected font. The default value is Black.
Examples
font_dialog.cpp.

◆ color() [2/2]

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

Sets the selected font color.

Parameters
colorThe color of the selected font. The default value is Black.
Returns
Current font_dialog.

◆ fixed_pitch_only() [1/2]

bool xtd::forms::font_dialog::fixed_pitch_only ( ) const
inline

Gets a value indicating whether the dialog box allows only the selection of fixed-pitch fonts.

Returns
true if only fixed-pitch fonts can be selected; otherwise, false. The default value is false.

◆ fixed_pitch_only() [2/2]

font_dialog & xtd::forms::font_dialog::fixed_pitch_only ( bool  fixed_pitch_only)
inline

Sets a value indicating whether the dialog box allows only the selection of fixed-pitch fonts.

Parameters
fixed_pitch_onlytrue if only fixed-pitch fonts can be selected; otherwise, false. The default value is false.
Returns
Current font_dialog.

◆ font() [1/2]

drawing::font xtd::forms::font_dialog::font ( ) const
inline

Gets the selected font.

Returns
The selected font.
Examples
font_dialog.cpp.

◆ font() [2/2]

font_dialog & xtd::forms::font_dialog::font ( const drawing::font font)
inline

Sets the selected font.

Parameters
fontThe selected font.
Returns
Current font_dialog.

◆ font_must_exist() [1/2]

bool xtd::forms::font_dialog::font_must_exist ( ) const
inline

Gets a value indicating whether the dialog box specifies an error condition if the user attempts to select a font or style that does not exist.

Returns
true if the dialog box specifies an error condition when the user tries to select a font or style that does not exist; otherwise, false. The default is false.

◆ font_must_exist() [2/2]

font_dialog & xtd::forms::font_dialog::font_must_exist ( bool  font_must_exist)
inline

Sets a value indicating whether the dialog box specifies an error condition if the user attempts to select a font or style that does not exist.

Parameters
font_must_existtrue if the dialog box specifies an error condition when the user tries to select a font or style that does not exist; otherwise, false. The default is false.
Returns
Current font_dialog.

◆ max_size() [1/2]

size_t xtd::forms::font_dialog::max_size ( ) const
inline

Gets the maximum point size a user can select.

Returns
The maximum point size a user can select. The default is 0.

◆ max_size() [2/2]

font_dialog & xtd::forms::font_dialog::max_size ( size_t  max_size)
inline

Sets the maximum point size a user can select.

Parameters
max_sizeThe maximum point size a user can select. The default is 0.
Returns
Current font_dialog.

◆ min_size() [1/2]

size_t xtd::forms::font_dialog::min_size ( ) const
inline

Gets the minimum point size a user can select.

Returns
The minimum point size a user can select. The default is 0.

◆ min_size() [2/2]

font_dialog & xtd::forms::font_dialog::min_size ( size_t  min_size)
inline

Sets the minimum point size a user can select.

Parameters
min_sizeThe minimum point size a user can select. The default is 0.
Returns
Current font_dialog.

◆ on_apply()

virtual void xtd::forms::font_dialog::on_apply ( const event_args e)
protectedvirtual

Raises the font_dialog::apply event.

Parameters
eAn event_args that contains the data.
Remarks
Raising an event invokes the event handler through a delegate.
Notes to Inheritors
When overriding on_apply(const event_args&) in a derived class, be sure to call the base class's on_apply(const event_args&) method.

◆ options()

size_t xtd::forms::font_dialog::options ( ) const
inline

Gets values to initialize the font_dialog.

Returns
A bitwise combination of internal values that initializes the font_dialog.
Remarks
The options property corresponds to the flags used to initialize a color dialog box using Win32. Use the properties of the font_dialog class to get and set the options.

◆ reset()

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

Resets all dialog box options to their default values.

Remarks
When the options are reset, the strikethrough, underline, and color effects are enabled. The fonts listed include only the screen fonts supported by the system.

Implements xtd::forms::common_dialog.

◆ run_dialog()

bool xtd::forms::font_dialog::run_dialog ( intptr_t  owner)
overrideprotectedvirtual
Returns
Specifies a file dialog box.
Parameters
ownerThe window handle of the owner window for the common dialog box.
Returns
true if the dialog box was successfully run; otherwise, false.
Remarks
The run_dialog method is invoked when the user of a font dialog box calls the show_dialog method.

Implements xtd::forms::common_dialog.

◆ run_sheet()

void xtd::forms::font_dialog::run_sheet ( 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.

Implements xtd::forms::common_dialog.

◆ script_only() [1/2]

bool xtd::forms::font_dialog::script_only ( ) const
inline

Gets a value indicating whether the dialog box allows selection of fonts for all non-OEM and Symbol character sets, as well as the ANSI character set.

Returns
true if selection of fonts for all non-OEM and Symbol character sets, as well as the ANSI character set, is allowed; otherwise, false. The default value is false.

◆ script_only() [2/2]

font_dialog & xtd::forms::font_dialog::script_only ( bool  script_only)
inline

Sets a value indicating whether the dialog box allows selection of fonts for all non-OEM and Symbol character sets, as well as the ANSI character set.

Parameters
script_script= true if selection of fonts for all non-OEM and Symbol character sets, as well as the ANSI character set, is allowed; otherwise, false. The default value is false.
Returns
Current font_dialog.

◆ show_apply() [1/2]

bool xtd::forms::font_dialog::show_apply ( ) const
inline

Gets a value indicating whether the dialog box contains an Apply button.

Returns
true if the dialog box contains an Apply button; otherwise, false. The default value is false.

◆ show_apply() [2/2]

font_dialog & xtd::forms::font_dialog::show_apply ( bool  show_apply)
inline

Sets a value indicating whether the dialog box contains an Apply button.

Parameters
show_applytrue if the dialog box contains an Apply button; otherwise, false. The default value is false.
Returns
Current font_dialog.

◆ show_color() [1/2]

bool xtd::forms::font_dialog::show_color ( ) const
inline

Gets a value indicating whether the dialog box displays the color choice.

Returns
true if the dialog box displays the color choice; otherwise, false. The default value is false.

◆ show_color() [2/2]

font_dialog & xtd::forms::font_dialog::show_color ( bool  show_color)
inline

Sets a value indicating whether the dialog box displays the color choice.

Parameters
show_colortrue if the dialog box displays the color choice; otherwise, false. The default value is false.
Returns
Current font_dialog.

◆ show_effect() [1/2]

bool xtd::forms::font_dialog::show_effect ( ) const
inline

Gets a value indicating whether the dialog box contains controls that allow the user to specify strikethrough, underline, and text color options.

Returns
true if the dialog box contains controls to set strikethrough, underline, and text color options; otherwise, false. The default value is true.

◆ show_effect() [2/2]

font_dialog & xtd::forms::font_dialog::show_effect ( bool  show_effect)
inline

Sets a value indicating whether the dialog box contains controls that allow the user to specify strikethrough, underline, and text color options.

Parameters
show_effecttrue if the dialog box contains controls to set strikethrough, underline, and text color options; otherwise, false. The default value is true.
Returns
Current font_dialog.

◆ show_help() [1/2]

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

Gets a value indicating whether the dialog box displays a Help button.

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

◆ show_help() [2/2]

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

Sets a value indicating whether the dialog box displays a Help button.

Parameters
show_helptrue if the dialog box displays a Help button; otherwise, false. The default value is false.
Returns
Current font_dialog.

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