#include <xtd/drawing/pens>
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/label>
#include <xtd/forms/toggle_button>
class form1 :
public form {
public:
form1() {
client_size({280, 180});
controls().push_back_range({button_red, button_green, button_blue, panel_color});
text(
"Toggle button example");
button_red.location({20, 20});
button_red.text("Red");
button_red.three_state(true);
button_red.check_state_changed += event_handler(*this, &form1::update_color);
button_green.location({20, 70});
button_green.text("Green");
button_green.three_state(true);
button_green.check_state_changed += event_handler(*this, &form1::update_color);
button_blue.location({20, 120});
button_blue.text("Blue");
button_blue.three_state(true);
button_blue.check_state_changed += event_handler(*this, &form1::update_color);
panel_color.location({150, 20});
panel_color.size({110, 110});
}
private:
void update_color(
object& sender,
const event_args&
e) {
panel_color.back_color(
color::from_argb(color_levels[button_red.check_state()], color_levels[button_green.check_state()], color_levels[button_blue.check_state()]));
}
auto colored_bitmap =
bitmap {16, 16};
g.fill_ellipse(
solid_brush(
color), 0, 0, colored_bitmap.width(), colored_bitmap.height());
g.draw_ellipse(
pens::black(), 0, 0, colored_bitmap.width() - 1, colored_bitmap.height() - 1);
return colored_bitmap;
}
};
auto main() -> int {
}
Encapsulates a GDI+ bitmap, which consists of the pixel data for a graphics image and its attributes....
Definition bitmap.hpp:26
Represents an ARGB (alpha, red, green, blue) color.
Definition color.hpp:46
static const xtd::drawing::color lime
Gets a system-defined color that has an ARGB value of 0xFF00FF00. This field is constant.
Definition color.hpp:287
static const xtd::drawing::color red
Gets a system-defined color that has an ARGB value of 0xFFFF0000. This field is constant.
Definition color.hpp:401
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
static xtd::drawing::color from_argb(uint32 argb) noexcept
Creates a xtd::drawing::color class from a 32-bit ARGB value.
static graphics from_image(const xtd::drawing::image &image)
Creates a new xtd::drawing::graphics from the specified xtd::drawing::image.
An abstract base class that provides functionality for the bitmap and metafile descended classes.
Definition image.hpp:49
static xtd::drawing::pen black()
A system-defined pen object with a width of 1.
Defines a xtd::drawing::brush of a single color. Brushes are used to fill graphics shapes,...
Definition solid_brush.hpp:29
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.hpp:18
static const event_args empty
Provides a value to use with events that do not have event data.
Definition event_args.hpp:25
@ g
The G key.
Definition console_key.hpp:100
@ 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