xtd 0.2.0
font_box.cpp

demonstrates the use of xtd::forms::font_box font dialog.

Windows

macOS

Gnome

#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/font_box>
#include <xtd/forms/form>
#include <xtd/forms/message_box>
#include <xtd/forms/label>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Font box example");
client_size({220, 160});
controls().push_back_range({button_font, button_font_and_color});
button_font.parent(*this)
.location({10, 10})
.text("Select a font")
.size({200, 45})
.click += [this] {
auto res = font_box::show(font, *this);
if (res == dialog_result::ok)
message_box::show(string::format("Selected font is: {}", font));
};
button_font_and_color.parent(*this)
.location({10, 60})
.text("Select a font and a font color")
.size({200, 45})
.click += [] {
if (res == dialog_result::ok)
message_box::show(string::format("Selected font is: {}\ncolor: {}", font, color));
};
}
private:
button button_font;
button button_font_and_color;
};
auto main() -> int {
application::run(form1 {});
}
Represents an ARGB (alpha, red, green, blue) color.
Definition color.hpp:46
static const xtd::drawing::color blue
Gets a system-defined color that has an ARGB value of 0xFF0000FF. This field is constant.
Definition color.hpp:86
static font_family generic_sans_serif() noexcept
Gets a generic sans serif font_family.
Defines a particular format for text, including font face, size, and style attributes....
Definition font.hpp:45
static xtd::drawing::font default_font()
Gets the default font that applications can use for dialog boxes and forms.
static void run()
Begins running a standard application message loop on the current thread, without a form.
Represents a Windows button control.
Definition button.hpp:49
static dialog_result show(xtd::drawing::font &font)
Displays a font dialog box.
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
static dialog_result show(const iwin32_window &owner)
Displays a message box in front of the specified window.
@ show_color
Whether the dialog box displays the color choice.
Definition font_box_options.hpp:40
@ ok
The dialog box return value is OK (usually sent from a button labeled OK).
Definition dialog_result.hpp:47
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition texts.hpp:217
Contains classes that represent ASCII and Unicode character encodings; abstract base classes for conv...
Definition basic_string_builder.hpp:16
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8