xtd 0.2.0
Loading...
Searching...
No Matches
check_box_renderer.cpp

demonstrates the use of xtd::forms::check_box_renderer control.

Windows

macOS

Gnome

#include <xtd/xtd>
namespace check_box_renderer_example {
class form1 : public form {
public:
form1() {
text("Check box renderer example");
client_size({500, 300});
set_color(color::blue);
set_color(nullptr);
choice_theme.parent(*this);
choice_theme.location({10, 10});
choice_theme.items().push_back("default theme");
auto names = application::style_sheet_names();
names.sort();
choice_theme.items().push_back_range(names);
choice_theme.selected_index(0);
choice_theme.selected_index_changed += delegate_ {
application::style_sheet(choice_theme.selected_index() == 0 ? application::system_style_sheet() : application::get_style_sheet_from_name(choice_theme.selected_item().value()));
color_picker_background.color(back_color());
color_picker_foreground.color(fore_color());
bcolor.reset();
fcolor.reset();
check_box_system.back_color(nullptr);
check_box_system.fore_color(nullptr);
check_box_standard.back_color(nullptr);
check_box_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 += delegate_ {
bcolor = color_picker_background.color();
check_box_system.back_color(bcolor.value());
check_box_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 += delegate_ {
fcolor = color_picker_foreground.color();
check_box_system.fore_color(fcolor.value());
check_box_standard.fore_color(fcolor.value());
};
check_box_system.parent(*this);
check_box_system.flat_style(xtd::forms::flat_style::system);
check_box_system.location({10, 210});
check_box_system.text("System");
check_box_system.three_state(true);
check_box_standard.parent(*this);
check_box_standard.location({100, 210});
check_box_standard.text("Standard");
check_box_standard.three_state(true);
}
protected:
void on_paint(paint_event_args& e) override {
form::on_paint(e);
check_box_renderer::draw_check_box(e.graphics(), {10, 70, 104, 25}, "Normal", font(), xtd::forms::text_format_flags::vertical_center | xtd::forms::text_format_flags::left, xtd::drawing::image::empty, {0, 0, 0, 0}, false, xtd::forms::visual_styles::check_box_state::unchecked_normal, bcolor, fcolor);
check_box_renderer::draw_check_box(e.graphics(), {124, 70, 104, 25}, "Hot", font(), xtd::forms::text_format_flags::vertical_center | xtd::forms::text_format_flags::left, xtd::drawing::image::empty, {0, 0, 0, 0}, false, xtd::forms::visual_styles::check_box_state::unchecked_hot, bcolor, fcolor);
check_box_renderer::draw_check_box(e.graphics(), {238, 70, 104, 25}, "Pressed", font(), xtd::forms::text_format_flags::vertical_center | xtd::forms::text_format_flags::left, xtd::drawing::image::empty, {0, 0, 0, 0}, false, xtd::forms::visual_styles::check_box_state::unchecked_pressed, bcolor, fcolor);
check_box_renderer::draw_check_box(e.graphics(), {352, 70, 104, 25}, "Disabled", font(), xtd::forms::text_format_flags::vertical_center | xtd::forms::text_format_flags::left, xtd::drawing::image::empty, {0, 0, 0, 0}, false, xtd::forms::visual_styles::check_box_state::unchecked_disabled, bcolor, fcolor);
check_box_renderer::draw_check_box(e.graphics(), {10, 110, 104, 25}, "Normal", font(), xtd::forms::text_format_flags::vertical_center | xtd::forms::text_format_flags::left, xtd::drawing::image::empty, {0, 0, 0, 0}, false, xtd::forms::visual_styles::check_box_state::checked_normal, bcolor, fcolor);
check_box_renderer::draw_check_box(e.graphics(), {124, 110, 104, 25}, "Hot", font(), xtd::forms::text_format_flags::vertical_center | xtd::forms::text_format_flags::left, xtd::drawing::image::empty, {0, 0, 0, 0}, false, xtd::forms::visual_styles::check_box_state::checked_hot, bcolor, fcolor);
check_box_renderer::draw_check_box(e.graphics(), {238, 110, 104, 25}, "Pressed", font(), xtd::forms::text_format_flags::vertical_center | xtd::forms::text_format_flags::left, xtd::drawing::image::empty, {0, 0, 0, 0}, false, xtd::forms::visual_styles::check_box_state::checked_pressed, bcolor, fcolor);
check_box_renderer::draw_check_box(e.graphics(), {352, 110, 104, 25}, "Disabled", font(), xtd::forms::text_format_flags::vertical_center | xtd::forms::text_format_flags::left, xtd::drawing::image::empty, {0, 0, 0, 0}, false, xtd::forms::visual_styles::check_box_state::checked_disabled, bcolor, fcolor);
check_box_renderer::draw_check_box(e.graphics(), {10, 150, 104, 25}, "Normal", font(), xtd::forms::text_format_flags::vertical_center | xtd::forms::text_format_flags::left, xtd::drawing::image::empty, {0, 0, 0, 0}, false, xtd::forms::visual_styles::check_box_state::mixed_normal, bcolor, fcolor);
check_box_renderer::draw_check_box(e.graphics(), {124, 150, 104, 25}, "Hot", font(), xtd::forms::text_format_flags::vertical_center | xtd::forms::text_format_flags::left, xtd::drawing::image::empty, {0, 0, 0, 0}, false, xtd::forms::visual_styles::check_box_state::mixed_hot, bcolor, fcolor);
check_box_renderer::draw_check_box(e.graphics(), {238, 150, 104, 25}, "Pressed", font(), xtd::forms::text_format_flags::vertical_center | xtd::forms::text_format_flags::left, xtd::drawing::image::empty, {0, 0, 0, 0}, false, xtd::forms::visual_styles::check_box_state::mixed_pressed, bcolor, fcolor);
check_box_renderer::draw_check_box(e.graphics(), {352, 150, 104, 25}, "Disabled", font(), xtd::forms::text_format_flags::vertical_center | xtd::forms::text_format_flags::left, xtd::drawing::image::empty, {0, 0, 0, 0}, false, xtd::forms::visual_styles::check_box_state::mixed_disabled, bcolor, fcolor);
}
private:
void set_color(const color& color) {
cdebug << string::format("color = {}", color.to_string()) << environment::new_line;
}
void set_color(nullptr_t) {
cdebug << "color = (nullptr)" << environment::new_line;
}
std::optional<color> bcolor;
std::optional<color> fcolor;
choice choice_theme;
color_picker color_picker_background;
color_picker color_picker_foreground;
check_box check_box_system;
check_box check_box_standard;
};
}
auto main() -> int {
application::run(check_box_renderer_example::form1 {});
}
static image empty
Represent an empty xtd::drawing::image.
Definition image.hpp:65
#define delegate_
The declaration of a delegate type is similar to a method signature. It has a return value and any nu...
Definition delegate.hpp:900
@ vertical_center
Centers the text vertically, within the bounding rectangle.
Definition text_format_flags.hpp:36
@ left
Aligns the text on the left side of the clipping area. This is the default.
Definition text_format_flags.hpp:28
@ mixed_normal
The check box is three-state.
Definition check_box_state.hpp:42
@ mixed_pressed
The check box is three-state and pressed.
Definition check_box_state.hpp:46
@ unchecked_normal
The check box is unchecked.
Definition check_box_state.hpp:26
@ checked_normal
The check box is checked.
Definition check_box_state.hpp:34
@ checked_disabled
The check box is checked and disabled.
Definition check_box_state.hpp:40
@ unchecked_pressed
The check box is unchecked and pressed.
Definition check_box_state.hpp:30
@ mixed_hot
The check box is three-state and hot.
Definition check_box_state.hpp:44
@ checked_hot
The check box is checked and hot.
Definition check_box_state.hpp:36
@ unchecked_hot
The check box is unchecked and hot.
Definition check_box_state.hpp:28
@ unchecked_disabled
The check box is unchecked and disabled.
Definition check_box_state.hpp:32
@ checked_pressed
The check box is checked and pressed.
Definition check_box_state.hpp:38
@ mixed_disabled
The check box is three-state and disabled.
Definition check_box_state.hpp:48
@ system
The appearance of the control is determined by the user's operating system.
Definition flat_style.hpp:32