xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
check_box.h
Go to the documentation of this file.
1 #pragma once
5 #include "appearance.h"
6 #include "button_base.h"
7 #include "check_state.h"
9 
11 namespace xtd {
13  namespace forms {
52  class forms_export_ check_box : public button_base {
53  public:
55 
62  check_box();
64 
66 
74  virtual forms::appearance appearance() const {return data_->appearance;}
79 
86  virtual bool auto_check() const {return data_->auto_check;}
90  virtual check_box& auto_check(bool auto_check);
91 
94  virtual content_alignment check_align() const {return data_->check_align;}
97  virtual check_box& check_align(content_alignment check_align);
98 
105  virtual bool checked() const {return data_->checked;}
109  virtual check_box& checked(bool checked);
110 
123  virtual forms::check_state check_state() const {return data_->check_state;}
136 
139  drawing::size default_size() const override {return {104, 25};}
140 
147  virtual bool three_state() const {return data_->three_state;}
151  virtual check_box& three_state(bool three_state);
153 
155 
161 
166 
172 
173  protected:
175 
179  xtd::forms::visual_styles::check_box_state state() const noexcept {return data_->state;}
181 
183 
187  forms::create_params create_params() const override;
188 
192  drawing::size measure_control() const override;
193 
198  virtual void on_appearance_changed(const event_args& e) {
199  appearance_changed(*this, e);
200  if (flat_style() != xtd::forms::flat_style::system) invalidate();
201  }
202 
207  virtual void on_checked_changed(const event_args& e) {
208  if (flat_style() != xtd::forms::flat_style::system && enabled()) {
212  }
213  checked_changed(*this, e);
214  if (flat_style() != xtd::forms::flat_style::system) invalidate();
215  }
216 
221  virtual void on_check_state_changed(const event_args& e) {
222  if (flat_style() != xtd::forms::flat_style::system && enabled()) {
226  }
227  check_state_changed(*this, e);
228  if (flat_style() != xtd::forms::flat_style::system) invalidate();
229  }
230 
231  void on_enabled_changed(const event_args& e) override {
236  }
238  }
239 
240  void on_handle_created(const event_args& e) override;
241 
242  void on_mouse_down(const mouse_event_args& e) override {
243  if (flat_style() != xtd::forms::flat_style::system && enabled()) {
247  }
249  }
250 
251  void on_mouse_enter(const event_args& e) override {
252  if (flat_style() != xtd::forms::flat_style::system && enabled()) {
256  }
258  }
259 
260  void on_mouse_leave(const event_args& e) override {
261  if (flat_style() != xtd::forms::flat_style::system && enabled()) {
265  }
267  }
268 
269  void on_mouse_up(const mouse_event_args& e) override {
274  }
276  }
277 
278  void on_paint(paint_event_args& e) override;
280 
282  void wnd_proc(message& message) override;
283  virtual void wm_mouse_double_click(message& message);
284  virtual void wm_mouse_down(message& message);
285  virtual void wm_mouse_up(message& message);
287 
288  private:
289  struct data {
291  bool auto_check = true;
292  bool three_state = 0;
293  bool checked = false;
297  };
298  std::shared_ptr<data> data_ = std::make_shared<data>();
299  };
300  }
301 }
virtual forms::check_state check_state() const
Gets the state of the check_box.
Definition: check_box.h:123
check_state
Specifies the state of a control, such as a check box, that can be checked, unchecked, or set to an indeterminate state.
Definition: check_state.h:19
The control is unchecked.
Contains xtd::forms::appearance enum class.
flat_style
Specifies the appearance of a control.
Definition: flat_style.h:20
The default appearance defined by the control class.
Contains xtd::forms::button_base class.
mouse_buttons
Specifies constants that define which mouse button was pressed. This enumeration has a flag attribute...
Definition: mouse_buttons.h:18
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
virtual content_alignment check_align() const
Gets the horizontal and vertical alignment of the check mark on a check_box control.
Definition: check_box.h:94
void on_mouse_enter(const event_args &e) override
Raises the control::mouse_enter event.
Definition: button_base.h:175
The button has a checked or latched appearance. Use this appearance to show that a toggle button has ...
appearance
Specifies the appearance of a control.
Definition: appearance.h:18
Contains xtd::forms::check_state enum class.
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:25
Implements the basic functionality common to button controls.
Definition: button_base.h:26
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
The control is checked.
void on_mouse_enter(const event_args &e) override
Raises the control::mouse_enter event.
Definition: check_box.h:251
virtual void on_check_state_changed(const event_args &e)
Raises the check_box::check_state_changed event.
Definition: check_box.h:221
The check box is three-state and disabled.
check_box_state
Specifies the visual state of a check box that is drawn with visual styles.
Definition: check_box_state.h:20
void on_mouse_up(const mouse_event_args &e) override
Raises the control::mouse_up event.
Definition: check_box.h:269
The appearance of the control is determined by the user&#39;s operating system.
virtual bool three_state() const
Gets a value indicating whether the check_box will allow three check states rather than two...
Definition: check_box.h:147
void on_mouse_down(const mouse_event_args &e) override
Raises the control::mouse_down event.
Definition: check_box.h:242
Represents an event.
Definition: event.h:21
Provides data for the paint event.
Definition: paint_event_args.h:27
content_alignment
Specifies alignment of content on the drawing surface.
Definition: content_alignment.h:17
void on_enabled_changed(const event_args &e) override
Raises the control::enabled_changed event.
Definition: button_base.h:148
void on_mouse_leave(const event_args &e) override
Raises the control::mouse_leave event.
Definition: check_box.h:260
event< check_box, event_handler > check_state_changed
Occurs when the value of the check_state property changes.
Definition: check_box.h:170
The control is indeterminate. An indeterminate control generally has a shaded appearance.
The check box is three-state and pressed.
Implements a Windows message.
Definition: message.h:25
xtd::forms::visual_styles::check_box_state state() const noexcept
Get state.
Definition: check_box.h:179
Contains xtd::forms::visual_styles::check_box_state enum class.
Represents a Windows check_box.
Definition: check_box.h:52
void on_enabled_changed(const event_args &e) override
Raises the control::enabled_changed event.
Definition: check_box.h:231
Content is vertically aligned in the middle, and horizontally aligned on the left.
event< check_box, event_handler > checked_changed
Occurs when the value of the checked property changes.
Definition: check_box.h:165
virtual forms::appearance appearance() const
Gets the value that determines the appearance of a check_box control.
Definition: check_box.h:74
virtual void on_checked_changed(const event_args &e)
Raises the check_box::checked_changed event.
Definition: check_box.h:207
virtual bool checked() const
Gets a value indicating whether the check_box is in the checked state.
Definition: check_box.h:105
virtual bool auto_check() const
Gets a value indicating whether the checked or check_state values and the check_box&#39;s appearance are ...
Definition: check_box.h:86
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:29
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
event< check_box, event_handler > appearance_changed
Occurs when the value of the appearance property changes.
Definition: check_box.h:160
drawing::size default_size() const override
Gets the default size of the control.
Definition: check_box.h:139
virtual void on_appearance_changed(const event_args &e)
Raises the check_box::appearance_changed event.
Definition: check_box.h:198
The left mouse button was pressed.
void on_mouse_up(const mouse_event_args &e) override
Raises the control::mouse_up event.
Definition: button_base.h:185
void on_mouse_leave(const event_args &e) override
Raises the control::mouse_leave event.
Definition: button_base.h:180
The check box is three-state and hot.
void on_mouse_down(const mouse_event_args &e) override
Raises the control::mouse_down event.
Definition: button_base.h:170