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
font_dialog.cpp

The following code example demonstrate the use of font_dialog dialog.

Windows

macOS

Gnome

#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:
button button1;
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.
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
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