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.
radio_button.h
Go to the documentation of this file.
1 #pragma once
5 #include "appearance.h"
6 #include "button_base.h"
8 
10 namespace xtd {
12  namespace forms {
26  class forms_export_ radio_button : public button_base {
27  public:
29 
33  radio_button();
35 
37 
42  virtual forms::appearance appearance() const {return appearance_;}
48 
53  virtual bool auto_check() const {return auto_check_;}
59  virtual radio_button& auto_check(bool auto_check);
60 
63  virtual bool checked() const {return checked_;}
67  virtual radio_button& checked(bool checked);
68 
71  virtual content_alignment check_align() const {return check_align_;}
75  virtual radio_button& check_align(content_alignment check_align);
76 
79  drawing::size default_size() const override {return {104, 25};}
81 
83 
86  void perform_click();
87 
91  xtd::ustring to_string() const noexcept override {return ustring::format("{}, checked: {}", ustring::full_class_name(*this), checked_);}
93 
95 
101 
107 
108  protected:
110 
114  xtd::forms::visual_styles::radio_button_state state() const noexcept {return state_;}
116 
118 
122  forms::create_params create_params() const override;
123 
127  drawing::size measure_control() const override;
128 
135  virtual void on_appearance_changed(const event_args& e) {
136  if (flat_style() != xtd::forms::flat_style::system) invalidate();
137  appearance_changed(*this, e);
138  }
139 
146  virtual void on_checked_changed(const event_args& e) {
150  invalidate();
151  }
152  checked_changed(*this, e);
153  }
154 
155  void on_enabled_changed(const event_args& e) override {
159  }
161  }
162 
163  void on_got_focus(const event_args& e) override {
168  }
169  }
170 
173  void on_handle_created(const event_args& e) override;
174 
175  void on_lost_focus(const event_args& e) override {
180  }
181  }
182 
183  void on_mouse_down(const mouse_event_args& e) override {
187  }
189  }
190 
191  void on_mouse_enter(const event_args& e) override {
195  }
197  }
198 
199  void on_mouse_leave(const event_args& e) override {
203  }
205  }
206 
207  void on_mouse_move(const mouse_event_args& e) override {
211  }
213  }
214 
215  void on_mouse_up(const mouse_event_args& e) override {
219  }
221  }
222 
223  void on_paint(paint_event_args& e) override;
224 
225  void wnd_proc(message& message) override;
227 
229  void wm_mouse_double_click(message& message);
230  void wm_mouse_down(message& message);
231  void wm_mouse_up(message& message);
233 
234  private:
236  bool auto_check_ = true;
237  bool checked_ = false;
240  };
241  }
242 }
virtual forms::appearance appearance() const
Gets a value determining the appearance of the radio_button.
Definition: radio_button.h:42
Contains xtd::forms::appearance enum class.
flat_style
Specifies the appearance of a control.
Definition: flat_style.h:20
radio_button_state
Specifies the visual state of a radio button that is drawn with visual styles.
Definition: radio_button_state.h:20
The default appearance defined by the control class.
Contains xtd::forms::button_base class.
virtual void on_appearance_changed(const event_args &e)
Raises the radio_button::appearance_changed event.
Definition: radio_button.h:135
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
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::visual_styles::radio_button_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
xtd::forms::visual_styles::radio_button_state state() const noexcept
Get state.
Definition: radio_button.h:114
Enables the user to select a single option from a group of choices when paired with other xtd::forms:...
Definition: radio_button.h:26
void on_lost_focus(const event_args &e) override
Raises the control::lost_focus event.
Definition: radio_button.h:175
void on_enabled_changed(const event_args &e) override
Raises the control::enabled_changed event.
Definition: radio_button.h:155
drawing::size default_size() const override
Gets the default size of the control.
Definition: radio_button.h:79
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
void on_mouse_enter(const event_args &e) override
Raises the control::mouse_enter event.
Definition: radio_button.h:191
void on_got_focus(const event_args &e) override
Raises the control::got_focus event.
Definition: radio_button.h:163
event< radio_button, event_handler > appearance_changed
Occurs when the appearance property value changes.
Definition: radio_button.h:100
void on_mouse_move(const mouse_event_args &e) override
Raises the control::mouse_move event.
Definition: radio_button.h:207
The appearance of the control is determined by the user&#39;s operating system.
virtual bool auto_check() const
Gets a value indicating whether the checked value and the appearance of the control automatically cha...
Definition: radio_button.h:53
void on_mouse_up(const mouse_event_args &e) override
Raises the control::mouse_up event.
Definition: radio_button.h:215
const drawing::point & location() const
Gets the location of the mouse during the generating mouse event.
Definition: mouse_event_args.h:73
void on_mouse_down(const mouse_event_args &e) override
Raises the control::mouse_down event.
Definition: radio_button.h:183
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
Implements a Windows message.
Definition: message.h:25
virtual content_alignment check_align() const
Gets the horizontal and vertical alignment of the check mark on a check_box control.
Definition: radio_button.h:71
Content is vertically aligned in the middle, and horizontally aligned on the left.
void on_mouse_leave(const event_args &e) override
Raises the control::mouse_leave event.
Definition: radio_button.h:199
virtual void on_checked_changed(const event_args &e)
Raises the radio_button::radio_button::checked_changed event.
Definition: radio_button.h:146
static ustring full_class_name()
Gets the fully qualified class name of the objec_t, including the namespace of the objec_t...
Definition: ustring.h:442
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
static ustring format(const ustring &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition: ustring.h:700
mouse_buttons button() const
Gets which mouse button was pressed.
Definition: mouse_event_args.h:61
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
virtual void on_mouse_move(const mouse_event_args &e)
Raises the control::mouse_move event.
virtual void on_got_focus(const event_args &e)
Raises the control::got_focus event.
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
virtual bool checked() const
Gets a value indicating whether the control is checked.
Definition: radio_button.h:63
virtual void on_lost_focus(const event_args &e)
Raises the control::lost_focus event.
event< radio_button, event_handler > checked_changed
Occurs when the value of the checked property changes.
Definition: radio_button.h:105
void on_mouse_leave(const event_args &e) override
Raises the control::mouse_leave event.
Definition: button_base.h:180
xtd::ustring to_string() const noexcept override
Returns a string that represents the progress_bar control.
Definition: radio_button.h:91
void on_mouse_down(const mouse_event_args &e) override
Raises the control::mouse_down event.
Definition: button_base.h:170