xtd 0.2.0
switch_button.h
Go to the documentation of this file.
1 #include "button_base.h"
5 #include <xtd/optional>
6 
7 namespace xtd {
8  namespace forms {
31  struct data;
32 
33  public:
35 
38  switch_button();
40 
42 
47  virtual bool auto_check() const noexcept;
52  virtual switch_button& auto_check(bool auto_check);
53 
56  virtual xtd::drawing::color checked_back_color() const noexcept;
61  virtual switch_button& checked_back_color(std::nullptr_t);
63 
66  virtual xtd::drawing::color slider_color() const noexcept;
69  virtual switch_button& slider_color(const xtd::drawing::color& color);
71  virtual switch_button& slider_color(std::nullptr_t);
73 
76  virtual bool rounded() const noexcept;
80  virtual switch_button& rounded(bool value);
81 
84  virtual bool checked() const noexcept;
88  virtual switch_button& checked(bool checked);
89 
92  virtual bool show_text() const noexcept;
96  virtual switch_button& show_text(bool value);
98 
100 
102  using control::create;
110  static switch_button create(bool checked, const drawing::point& location = {-1, -1}, const drawing::size& size = {-1, -1}, const xtd::ustring& name = xtd::ustring::empty_string);
119  static switch_button create(const control& parent, bool checked, const drawing::point& location = {-1, -1}, const drawing::size& size = {-1, -1}, const xtd::ustring& name = xtd::ustring::empty_string);
121 
123 
129 
130  protected:
132 
136  drawing::size default_size() const noexcept override;
138 
140 
146  virtual void on_checked_changed(const event_args& e);
147 
148  void on_mouse_down(const mouse_event_args& e) override;
149  void on_handle_created(const event_args& e) override;
150  void on_paint(paint_event_args& e) override;
151  void on_resize(const event_args& e) override;
153 
154  private:
155  std::shared_ptr<data> data_;
156  };
157  }
158 }
virtual void on_checked_changed(const event_args &e)
Raises the switch_button::checked_changed event.
void on_paint(paint_event_args &e) override
Raises the xtd::forms::control::paint event.
virtual xtd::drawing::color slider_color() const noexcept
Gets the slider color for the control.
Contains xtd::forms::button_base class.
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
Represents a standard Windows switch button.
Definition: switch_button.h:30
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition: point.h:54
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:31
Implements the basic functionality common to button controls.
Definition: button_base.h:35
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
virtual bool auto_check() const noexcept
Gets a value indicating whether the checked and the switch_button&#39;s appearance are automatically chan...
virtual bool rounded() const noexcept
Gets a value indicating whether the switch_button is rounded appearance.
virtual const xtd::ustring & name() const noexcept
Gets the name of the control.
virtual xtd::drawing::color checked_back_color() const noexcept
Gets the checked background color for the control.
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
drawing::size default_size() const noexcept override
Gets the default size of the control.
static control create(const drawing::point &location={-1, -1}, const drawing::size &size={-1, -1}, const xtd::ustring &name=xtd::ustring::empty_string)
A factory to create a specified control with specified location, size, and name.
Represents an ARGB (alpha, red, green, blue) color.
Definition: color.h:45
Represents an event.
Definition: event.h:21
Provides data for the xtd::forms::control::paint event.
Definition: paint_event_args.h:28
void on_mouse_down(const mouse_event_args &e) override
Raises the xtd::forms::control::mouse_down event.
virtual drawing::point location() const noexcept
Gets the coordinates of the upper-left corner of the control relative to the upper-left corner of its...
virtual bool checked() const noexcept
Gets a value indicating whether the switch_button is in the checked state.
event< switch_button, event_handler > checked_changed
Occurs when the value of the checked property changes.
Definition: switch_button.h:127
void on_resize(const event_args &e) override
Raises the xtd::forms::control::region event.
Defines the base class for controls, which are components with visual representation.
Definition: control.h:78
virtual std::optional< control_ref > parent() const noexcept
Gets the parent container of the control.
void on_handle_created(const event_args &e) override
Raises the xtd::forms::control::handle_created event.
Provides data for the xtd::forms::control::mouse_up, xtd::forms::control::mouse_down, and xtd::forms::control::mouse_move events.
Definition: mouse_event_args.h:32
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
static const ustring empty_string
Represents the empty string.
Definition: ustring.h:53
virtual bool show_text() const noexcept
Gets a value indicating whether the switch_button text is shown.
static switch_button create(bool checked, const drawing::point &location={-1, -1}, const drawing::size &size={-1, -1}, const xtd::ustring &name=xtd::ustring::empty_string)
A factory to create an xtd::forms::switch_button with specified text, three_state, check_state, location ,size, and name.
size_t size
Represents a size of any object in bytes.
Definition: types.h:195