xtd 1.0.0
Loading...
Searching...
No Matches
xtd::forms::font_dialog Class Reference
Inheritance diagram for xtd::forms::font_dialog:
xtd::forms::common_dialog xtd::forms::component xtd::object

Definition

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

Header
#include <xtd/forms/font_dialog>
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.
Appearance
Windows macOS Gnome
Light
Dark
Examples
The following code example demonstrates the use of font_dialog dialog.
#include <xtd/xtd>
class form1 : public form {
public:
form1() {
text("Font dialog example");
client_size({400, 400});
controls().add_range({button1, label1});
auto_scroll(true);
button1.location({10, 10});
button1.text("Font...");
button1.click += delegate_ {
auto dialog = font_dialog {};
dialog.color(label1.fore_color());
dialog.font(label1.font());
if (dialog.show_dialog(*this) == xtd::forms::dialog_result::ok) {
label1.fore_color(dialog.color());
label1.font(dialog.font());
}
};
label1.location({10, 50});
label1.auto_size(true);
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;
};
auto main() -> int {
application::run(form1 {});
}
virtual auto text() const noexcept -> const xtd::string &
Gets the text associated with this control.
virtual auto client_size() const noexcept -> const xtd::drawing::size &
Gets the height and width of the client area of the control.
virtual auto controls() noexcept -> control_collection &
Gets the collection of controls contained within the control.
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
virtual auto auto_scroll() const noexcept -> bool
Gets a value indicating whether the container enables the user to scroll to any controls placed outsi...
#define delegate_
The declaration of a delegate type is similar to a method signature. It has a return value and any nu...
Definition delegate.hpp:1018
xtd::forms::style_sheets::control label
The label data allows you to specify the box of a label control.
Definition label.hpp:25
xtd::forms::style_sheets::control button
The buttton data allows you to specify the box of a button control.
Definition button.hpp:25
@ ok
The dialog box return value is OK (usually sent from a button labeled OK).
Definition dialog_result.hpp:47
@ button1
The first button on the message box is the default button.
Definition message_dialog_default_button.hpp:24

Public Events

xtd::event< font_dialog, xtd::event_handlerapply
 Occurs when the user clicks the Apply button in the font dialog box.

Public Constructors

 font_dialog ()
 Initializes a new instance of the font_dialog class.

Public Properties

auto allow_script_change () const noexcept -> bool
 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.
auto allow_script_change (bool value) -> font_dialog &
 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.
auto allow_simulation () const noexcept -> bool
 Gets a value indicating whether the dialog box allows graphics device interface (GDI) font simulations.
auto allow_simulation (bool value) -> font_dialog &
 Sets a value indicating whether the dialog box allows graphics device interface (GDI) font simulations.
auto allow_vector_fonts () const noexcept -> bool
 Gets a value indicating whether the dialog box allows vector font selections.
auto allow_vector_fonts (bool value) -> font_dialog &
 Sets a value indicating whether the dialog box allows vector font selections.
auto allow_vertical_fonts () const noexcept -> bool
 Gets a value indicating whether the dialog box displays both vertical and horizontal fonts or only horizontal fonts.
auto allow_vertical_fonts (bool value) -> font_dialog &
 Sets a value indicating whether the dialog box displays both vertical and horizontal fonts or only horizontal fonts.
auto color () const noexcept -> xtd::drawing::color
 Gets the selected font color.
auto color (const xtd::drawing::color &value) -> font_dialog &
 Sets the selected font color.
auto fixed_pitch_only () const noexcept -> bool
 Gets a value indicating whether the dialog box allows only the selection of fixed-pitch fonts.
auto fixed_pitch_only (bool value) -> font_dialog &
 Sets a value indicating whether the dialog box allows only the selection of fixed-pitch fonts.
auto font () const noexcept -> xtd::drawing::font
 Gets the selected font.
auto font (const xtd::drawing::font &value) -> font_dialog &
 Sets the selected font.
auto font_must_exist () const noexcept -> bool
 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.
auto font_must_exist (bool value) -> font_dialog &
 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.
auto max_size () const noexcept -> xtd::usize
 Gets the maximum point size a user can select.
auto max_size (xtd::usize value) -> font_dialog &
 Sets the maximum point size a user can select.
auto min_size () const noexcept -> xtd::usize
 Gets the minimum point size a user can select.
auto min_size (xtd::usize value) -> font_dialog &
 Sets the minimum point size a user can select.
auto options () const noexcept -> xtd::usize
 Gets values to initialize the font_dialog.
auto script_only () const noexcept -> bool
 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.
auto script_only (bool value) -> font_dialog &
 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.
auto show_apply () const noexcept -> bool
 Gets a value indicating whether the dialog box contains an Apply button.
auto show_apply (bool value) -> font_dialog &
 Sets a value indicating whether the dialog box contains an Apply button.
auto show_color () const noexcept -> bool
 Gets a value indicating whether the dialog box displays the color choice.
auto show_color (bool value) -> font_dialog &
 Sets a value indicating whether the dialog box displays the color choice.
auto show_effect () const noexcept -> bool
 Gets a value indicating whether the dialog box contains controls that allow the user to specify strikethrough, underline, and text color options.
auto show_effect (bool value) -> font_dialog &
 Sets a value indicating whether the dialog box contains controls that allow the user to specify strikethrough, underline, and text color options.
auto show_help () const noexcept -> bool
 Gets a value indicating whether the dialog box displays a Help button.
auto show_help (bool value) -> font_dialog &
 Sets a value indicating whether the dialog box displays a Help button.

Public Methods

auto reset () noexcept -> void override
 Resets all dialog box options to their default values.

Protected Methods

virtual auto on_apply (const xtd::event_args &e) -> void
 Raises the font_dialog::apply event.
auto run_dialog (xtd::intptr owner) -> bool override
auto run_sheet (xtd::intptr owner) -> void override
 When overridden in a derived class, specifies a common dialog box.

Additional Inherited Members

xtd::event< common_dialog, xtd::forms::help_event_handlerhelp_request
 Occurs when the user clicks the Help button on a common dialog box.
xtd::event< common_dialog, xtd::forms::dialog_closed_event_handlerdialog_closed
 Occurs when the user close a common dialog box with dialog close button or other dialog buttons.
 common_dialog ()
 Initializes a new instance of the common_dialog class.
auto dialog_result () const noexcept -> xtd::forms::dialog_result
 Gets async dialog_result result after dialog box is closing.
auto tag () const noexcept -> const xtd::any_object &
 Gets an object that contains data about the control.
auto tag (const xtd::any_object &value) -> common_dialog &
 Sets an object that contains data about the control.
auto show_dialog () -> xtd::forms::dialog_result
 Runs a common dialog box with a default owner.
auto show_dialog (const iwin32_window &owner) -> xtd::forms::dialog_result
 Runs a common dialog box with the specified owner.
auto show_sheet (const iwin32_window &owner) -> void
 Runs a common dialog box with the specified owner.
auto show_sheet_dialog (const iwin32_window &owner) -> xtd::forms::dialog_result
 Runs a common dialog box with the specified owner.
 object ()=default
 Create a new instance of the ultimate base class object.
virtual auto equals (const object &obj) const noexcept -> bool
 Determines whether the specified object is equal to the current object.
virtual auto get_hash_code () const noexcept -> xtd::usize
 Serves as a hash function for a particular type.
virtual auto get_type () const noexcept -> type_object
 Gets the type of the current instance.
template<typename object_t>
auto memberwise_clone () const -> xtd::unique_ptr_object< object_t >
 Creates a shallow copy of the current object.
virtual auto to_string () const -> xtd::string
 Returns a xtd::string that represents the current object.
template<typename object_a_t, typename object_b_t>
static auto equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool
 Determines whether the specified object instances are considered equal.
template<typename object_a_t, typename object_b_t>
static auto reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool
 Determines whether the specified object instances are the same instance.
virtual auto on_dialog_closed (const xtd::forms::dialog_closed_event_args &e) -> void
 Raises the common_dialog::dialog_close event.
virtual auto on_help_request (xtd::forms::help_event_args &e) -> void
 Raises the common_dialog::help_request event.
auto set_dialog_result (xtd::forms::dialog_result value) -> void
 Sets async dialog_result result after dialog box is closing.
 component ()
 Initialises a new instance of the component class.
virtual auto can_raise_events () const noexcept -> bool
 Gets a value indicating whether the component can raise an event.
auto design_mode () const noexcept -> bool
 Gets a value that indicates whether the component is currently in design mode.

Constructor & Destructor Documentation

◆ font_dialog()

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

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]

auto xtd::forms::font_dialog::allow_script_change ( ) const -> bool
nodiscardnoexcept

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]

auto xtd::forms::font_dialog::allow_script_change ( bool value) -> font_dialog &

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
valuetrue 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]

auto xtd::forms::font_dialog::allow_simulation ( ) const -> bool
nodiscardnoexcept

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]

auto xtd::forms::font_dialog::allow_simulation ( bool value) -> font_dialog &

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

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

◆ allow_vector_fonts() [1/2]

auto xtd::forms::font_dialog::allow_vector_fonts ( ) const -> bool
nodiscardnoexcept

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]

auto xtd::forms::font_dialog::allow_vector_fonts ( bool value) -> font_dialog &

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

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

◆ allow_vertical_fonts() [1/2]

auto xtd::forms::font_dialog::allow_vertical_fonts ( ) const -> bool
nodiscardnoexcept

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]

auto xtd::forms::font_dialog::allow_vertical_fonts ( bool value) -> font_dialog &

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

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

◆ color() [1/2]

auto xtd::forms::font_dialog::color ( ) const -> xtd::drawing::color
nodiscardnoexcept

Gets the selected font color.

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

◆ color() [2/2]

auto xtd::forms::font_dialog::color ( const xtd::drawing::color & value) -> font_dialog &

Sets the selected font color.

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

◆ fixed_pitch_only() [1/2]

auto xtd::forms::font_dialog::fixed_pitch_only ( ) const -> bool
nodiscardnoexcept

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]

auto xtd::forms::font_dialog::fixed_pitch_only ( bool value) -> font_dialog &

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

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

◆ font() [1/2]

auto xtd::forms::font_dialog::font ( ) const -> xtd::drawing::font
nodiscardnoexcept

Gets the selected font.

Returns
The selected font.

◆ font() [2/2]

auto xtd::forms::font_dialog::font ( const xtd::drawing::font & value) -> font_dialog &

Sets the selected font.

Parameters
valueThe selected font.
Returns
Current font_dialog.

◆ font_must_exist() [1/2]

auto xtd::forms::font_dialog::font_must_exist ( ) const -> bool
nodiscardnoexcept

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]

auto xtd::forms::font_dialog::font_must_exist ( bool value) -> font_dialog &

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
valuetrue 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]

auto xtd::forms::font_dialog::max_size ( ) const -> xtd::usize
nodiscardnoexcept

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]

auto xtd::forms::font_dialog::max_size ( xtd::usize value) -> font_dialog &

Sets the maximum point size a user can select.

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

◆ min_size() [1/2]

auto xtd::forms::font_dialog::min_size ( ) const -> xtd::usize
nodiscardnoexcept

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]

auto xtd::forms::font_dialog::min_size ( xtd::usize value) -> font_dialog &

Sets the minimum point size a user can select.

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

◆ options()

auto xtd::forms::font_dialog::options ( ) const -> xtd::usize
nodiscardnoexcept

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.

◆ script_only() [1/2]

auto xtd::forms::font_dialog::script_only ( ) const -> bool
nodiscardnoexcept

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]

auto xtd::forms::font_dialog::script_only ( bool value) -> font_dialog &

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
value= 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]

auto xtd::forms::font_dialog::show_apply ( ) const -> bool
nodiscardnoexcept

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]

auto xtd::forms::font_dialog::show_apply ( bool value) -> font_dialog &

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

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

◆ show_color() [1/2]

auto xtd::forms::font_dialog::show_color ( ) const -> bool
nodiscardnoexcept

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]

auto xtd::forms::font_dialog::show_color ( bool value) -> font_dialog &

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

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

◆ show_effect() [1/2]

auto xtd::forms::font_dialog::show_effect ( ) const -> bool
nodiscardnoexcept

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]

auto xtd::forms::font_dialog::show_effect ( bool value) -> font_dialog &

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

Parameters
valuetrue 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]

auto xtd::forms::font_dialog::show_help ( ) const -> bool
nodiscardnoexcept

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]

auto xtd::forms::font_dialog::show_help ( bool value) -> font_dialog &

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

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

◆ reset()

auto xtd::forms::font_dialog::reset ( ) -> void
overridevirtualnoexcept

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.

◆ on_apply()

virtual auto xtd::forms::font_dialog::on_apply ( const xtd::event_args & e) -> void
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.

◆ run_dialog()

auto xtd::forms::font_dialog::run_dialog ( xtd::intptr owner) -> bool
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()

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

Member Data Documentation

◆ apply

xtd::event<font_dialog, xtd::event_handler> xtd::forms::font_dialog::apply

Occurs when the user clicks the Apply button in the font dialog box.

Remarks
Every time the Apply button is clicked, another apply event is raised.
For more information about handling events, see Handling and Raising Events.

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