xtd 0.2.0
Loading...
Searching...
No Matches
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 font = system_fonts::default_font();
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 += [] {
drawing::font font(drawing::font_family::generic_sans_serif(), 16);
drawing::color color = drawing::color::blue;
auto res = font_box::show(font, color, font_box_options::show_color);
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:49
Defines a particular format for text, including font face, size, and style attributes....
Definition font.hpp:45
Represents a Windows button control.
Definition button.hpp:49
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:11
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.hpp:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10