#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/button_renderer>
#include <xtd/forms/choice>
#include <xtd/forms/color_picker>
#include <xtd/forms/form>
#include <xtd/cdebug>
namespace button_renderer_example {
class form1 :
public form {
public:
form1() {
text(
"Button renderer example");
client_size({400, 300});
set_color(nullptr);
choice_theme.parent(*this);
choice_theme.location({10, 10});
choice_theme.items().push_back("default theme");
sort(names.begin(), names.end());
choice_theme.items().push_back_range(names);
choice_theme.selected_index(0);
choice_theme.selected_index_changed += [&] {
color_picker_background.color(back_color());
color_picker_foreground.color(fore_color());
bcolor.reset();
fcolor.reset();
button_system.back_color(nullptr);
button_system.fore_color(nullptr);
button_standard.back_color(nullptr);
button_standard.fore_color(nullptr);
};
color_picker_background.parent(*this);
color_picker_background.location({180, 10});
color_picker_background.color(back_color());
color_picker_background.color_picker_changed += [&] {
bcolor = color_picker_background.color();
button_system.back_color(bcolor.value());
button_standard.back_color(bcolor.value());
};
color_picker_foreground.parent(*this);
color_picker_foreground.location({290, 10});
color_picker_foreground.color(fore_color());
color_picker_foreground.color_picker_changed += [&] {
fcolor = color_picker_foreground.color();
button_system.fore_color(fcolor.value());
button_standard.fore_color(fcolor.value());
};
button_system.parent(*this);
button_system.location({10, 170});
button_system.text("System");
button_standard.parent(*this);
button_standard.location({100, 170});
button_standard.text("Standard");
}
protected:
button_renderer::draw_button(
e.graphics(), {10, 70, 75, 25},
"Normal",
font(),
xtd::forms::text_format_flags::vertical_center |
xtd::forms::text_format_flags::horizontal_center,
xtd::drawing::image::empty, {0, 0, 0, 0},
false,
xtd::forms::visual_styles::push_button_state::normal, bcolor, fcolor);
button_renderer::draw_button(
e.graphics(), {100, 70, 75, 25},
"Hot",
font(),
xtd::forms::text_format_flags::vertical_center |
xtd::forms::text_format_flags::horizontal_center,
xtd::drawing::image::empty, {0, 0, 0, 0},
false,
xtd::forms::visual_styles::push_button_state::hot, bcolor, fcolor);
button_renderer::draw_button(
e.graphics(), {190, 70, 75, 25},
"Pressed",
font(),
xtd::forms::text_format_flags::vertical_center |
xtd::forms::text_format_flags::horizontal_center,
xtd::drawing::image::empty, {0, 0, 0, 0},
false,
xtd::forms::visual_styles::push_button_state::pressed, bcolor, fcolor);
button_renderer::draw_button(
e.graphics(), {10, 110, 75, 25},
"Disabled",
font(),
xtd::forms::text_format_flags::vertical_center |
xtd::forms::text_format_flags::horizontal_center,
xtd::drawing::image::empty, {0, 0, 0, 0},
false,
xtd::forms::visual_styles::push_button_state::disabled, bcolor, fcolor);
button_renderer::draw_button(
e.graphics(), {100, 110, 75, 25},
"Default",
font(),
xtd::forms::text_format_flags::vertical_center |
xtd::forms::text_format_flags::horizontal_center,
xtd::drawing::image::empty, {0, 0, 0, 0},
false,
xtd::forms::visual_styles::push_button_state::default_state, bcolor, fcolor);
}
private:
}
void set_color(nullptr_t) {
}
std::optional<color> bcolor;
std::optional<color> fcolor;
};
}
auto main() -> int {
}
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
xtd::string to_string() const noexcept override
Creates a human-readable string that represents this color class.
Defines a particular format for text, including font face, size, and style attributes....
Definition font.hpp:45
static image empty
Represent an empty xtd::drawing::image.
Definition image.hpp:65
static xtd::string new_line() noexcept
Gets the newline string defined for this environment.
@ e
The E key.
Definition console_key.hpp:96
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
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