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 {
31  class forms_export_ radio_button : public xtd::forms::button_base {
32  public:
34 
38  radio_button();
40 
42 
47  virtual forms::appearance appearance() const {return appearance_;}
53 
58  virtual bool auto_check() const {return auto_check_;}
64  virtual radio_button& auto_check(bool auto_check);
65 
68  virtual bool checked() const {return checked_;}
72  virtual radio_button& checked(bool checked);
73 
76  virtual content_alignment check_align() const {return check_align_;}
80  virtual radio_button& check_align(content_alignment check_align);
82 
84 
87  void perform_click();
88 
92  xtd::ustring to_string() const noexcept override {return ustring::format("{}, checked: {}", ustring::full_class_name(*this), checked_);}
94 
96 
102 
108 
109  protected:
111 
115  xtd::forms::visual_styles::radio_button_state state() const noexcept {return state_;}
117 
119 
123  forms::create_params create_params() const override;
124 
128  drawing::size measure_control() const override;
129 
136  virtual void on_appearance_changed(const event_args& e) {
137  if (flat_style() != xtd::forms::flat_style::system) invalidate();
138  appearance_changed(*this, e);
139  }
140 
147  virtual void on_checked_changed(const event_args& e) {
151  invalidate();
152  }
153  checked_changed(*this, e);
154  }
155 
156  void on_enabled_changed(const event_args& e) override {
160  }
162  }
163 
164  void on_got_focus(const event_args& e) override {
169  }
170  }
171 
174  void on_handle_created(const event_args& e) override;
175 
176  void on_lost_focus(const event_args& e) override {
181  }
182  }
183 
184  void on_mouse_down(const mouse_event_args& e) override {
188  }
190  }
191 
192  void on_mouse_enter(const event_args& e) override {
196  }
198  }
199 
200  void on_mouse_leave(const event_args& e) override {
204  }
206  }
207 
208  void on_mouse_move(const mouse_event_args& e) override {
212  }
214  }
215 
216  void on_mouse_up(const mouse_event_args& e) override {
220  }
222  }
223 
224  void on_paint(paint_event_args& e) override;
225 
226  void wnd_proc(message& message) override;
228 
230  void wm_mouse_double_click(message& message);
231  void wm_mouse_down(const message& message);
232  void wm_mouse_up(const message& message);
234 
235  private:
237  bool auto_check_ = true;
238  bool checked_ = false;
241  };
242  }
243 }
virtual forms::appearance appearance() const
Gets a value determining the appearance of the radio_button.
Definition: radio_button.h:47
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:136
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:177
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:30
Implements the basic functionality common to button controls.
Definition: button_base.h:33
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
Gets state.
Definition: radio_button.h:115
Enables the user to select a single option from a group of choices when paired with other xtd::forms:...
Definition: radio_button.h:31
void on_lost_focus(const event_args &e) override
Raises the control::lost_focus event.
Definition: radio_button.h:176
void on_enabled_changed(const event_args &e) override
Raises the control::enabled_changed event.
Definition: radio_button.h:156
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:50
void on_mouse_enter(const event_args &e) override
Raises the control::mouse_enter event.
Definition: radio_button.h:192
void on_got_focus(const event_args &e) override
Raises the control::got_focus event.
Definition: radio_button.h:164
event< radio_button, event_handler > appearance_changed
Occurs when the appearance property value changes.
Definition: radio_button.h:101
void on_mouse_move(const mouse_event_args &e) override
Raises the control::mouse_move event.
Definition: radio_button.h:208
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:58
void on_mouse_up(const mouse_event_args &e) override
Raises the control::mouse_up event.
Definition: radio_button.h:216
const drawing::point & location() const
Gets the location of the mouse during the generating mouse event.
Definition: mouse_event_args.h:74
void on_mouse_down(const mouse_event_args &e) override
Raises the control::mouse_down event.
Definition: radio_button.h:184
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:150
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:76
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:200
virtual void on_checked_changed(const event_args &e)
Raises the radio_button::radio_button::checked_changed event.
Definition: radio_button.h:147
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:444
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:30
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:708
mouse_buttons button() const
Gets which mouse button was pressed.
Definition: mouse_event_args.h:62
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:187
virtual bool checked() const
Gets a value indicating whether the control is checked.
Definition: radio_button.h:68
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:106
void on_mouse_leave(const event_args &e) override
Raises the control::mouse_leave event.
Definition: button_base.h:182
xtd::ustring to_string() const noexcept override
Returns a string that represents the progress_bar control.
Definition: radio_button.h:92
void on_mouse_down(const mouse_event_args &e) override
Raises the control::mouse_down event.
Definition: button_base.h:172