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

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

Windows

macOS

Gnome

#include <xtd/xtd>
namespace color_picker_example {
class form1 : public form {
public:
form1() {
text("Color picker example");
color_picker.parent(*this);
color_picker.alpha_color(true);
color_picker.location({10, 10});
color_picker.color_picker_changed += delegate_(object& sender, const color_picker_event_args& e) {
test_zone.invalidate();
color_label.text(color_translator::to_html(e.color()));
};
color_picker.color(color::red);
test_zone.parent(*this);
test_zone.location({10, 50});
test_zone.border_style(border_style::fixed_3d);
test_zone.double_buffered(true);
test_zone.paint += delegate_(object& sender, paint_event_args& e) {
e.graphics().fill_rectangle(drawing_2d::hatch_brush {drawing_2d::hatch_style::wide_checker_board, color::from_argb(0x66, 0x66, 0x66), color::from_argb(0x99, 0x99, 0x99)}, e.clip_rectangle());
e.graphics().fill_rectangle(solid_brush {color_picker.color()}, e.clip_rectangle());
control_paint::draw_border(test_zone, e.graphics(), test_zone.border_style(), test_zone.border_sides(), application::style_sheet().system_colors().control_text(), rectangle::add(e.clip_rectangle(), -1, -1));
};
color_label.parent(*this);
color_label.auto_size(true);
color_label.location({10, 160});
}
private:
forms::color_picker color_picker;
panel test_zone;
label color_label;
};
}
auto main() -> int {
application::run(color_picker_example::form1 {});
}
#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