xtd 0.2.0
font_box.cpp

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

Windows
font_box_w.png

font_box_wd.png
macOS
font_box_m.png

font_box_md.png
Gnome
font_box_g.png

font_box_gd.png
#include <xtd/xtd>
using namespace xtd;
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(ustring::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 += [] {
auto res = font_box::show(font, color, font_box_options::show_color);
if (res == dialog_result::ok)
message_box::show(ustring::format("Selected font is: {}\ncolor: {}", font, color));
};
}
private:
button button_font;
button button_font_and_color;
};
auto main()->int {
application::run(form1 {});
}