xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
toggle_button.h
Go to the documentation of this file.
1
4#pragma once
5#include "button_base.h"
6#include "check_state.h"
8
10namespace xtd {
12 namespace forms {
31 public:
35
39 virtual bool auto_check() const {return auto_check_;}
43 virtual toggle_button& auto_check(bool auto_check);
44
47 virtual content_alignment check_align() const {return check_align_;}
51
55 virtual bool checked() const {return checked_;}
59 virtual toggle_button& checked(bool checked);
60
70 virtual forms::check_state check_state() const {return check_state_;}
80
83 drawing::size default_size() const override {return {104, 25};}
84
88 virtual bool three_state() const {return three_state_;}
92 virtual toggle_button& three_state(bool three_state);
93
97
101
102 protected:
105 forms::create_params create_params() const override;
106
111
116 virtual void on_checked_changed(const event_args& e) {
117 if (flat_style_ != xtd::forms::flat_style::system && enabled()) {
121 }
122 checked_changed(*this, e);
123 if (flat_style_ != xtd::forms::flat_style::system) invalidate();
124 }
125
130 virtual void on_check_state_changed(const event_args& e) {
131 if (flat_style_ != xtd::forms::flat_style::system && enabled()) {
135 }
136 check_state_changed(*this, e);
137 if (flat_style_ != xtd::forms::flat_style::system) invalidate();
138 }
139
140 void on_enabled_changed(const event_args& e) override {
141 if (flat_style_ != xtd::forms::flat_style::system) {
145 }
146 button_base::on_enabled_changed(e);
147 }
148
151 void on_handle_created(const event_args& e) override;
152
153 void on_mouse_down(const mouse_event_args& e) override {
154 if (flat_style_ != xtd::forms::flat_style::system && enabled()) {
158 }
159 button_base::on_mouse_down(e);
160 }
161
162 void on_mouse_enter(const event_args& e) override {
163 if (flat_style_ != xtd::forms::flat_style::system && enabled()) {
165 else if (check_state_ == xtd::forms::check_state::checked) state_ = (mouse_buttons_ & mouse_buttons::left) == mouse_buttons::left ? xtd::forms::visual_styles::toggle_button_state::checked_pressed : xtd::forms::visual_styles::toggle_button_state::checked_hot;
166 else if (check_state_ == xtd::forms::check_state::indeterminate) state_ = (mouse_buttons_ & mouse_buttons::left) == mouse_buttons::left ? xtd::forms::visual_styles::toggle_button_state::mixed_pressed : xtd::forms::visual_styles::toggle_button_state::mixed_hot;
167 }
168 button_base::on_mouse_enter(e);
169 }
170
171 void on_mouse_leave(const event_args& e) override {
172 if (flat_style_ != xtd::forms::flat_style::system && enabled()) {
176 }
177 button_base::on_mouse_leave(e);
178 }
179
180 void on_mouse_up(const mouse_event_args& e) override {
185 }
186 button_base::on_mouse_up(e);
187 }
188
189 void on_paint(paint_event_args& e) override;
190
192 void wnd_proc(message& message) override;
193 virtual void wm_mouse_double_click(message& message);
194 virtual void wm_mouse_down(message& message);
195 virtual void wm_mouse_up(message& message);
196
197 bool auto_check_ = true;
198 bool three_state_ = 0;
199 bool checked_ = false;
200 content_alignment check_align_ = content_alignment::middle_left;
201 forms::check_state check_state_ = forms::check_state::unchecked;
204 };
205 }
206}
Contains xtd::forms::button_base class.
Contains xtd::forms::check_state enum class.
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:25
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
Represents an event.
Definition: event.h:21
Implements the basic functionality common to button controls.
Definition: button_base.h:26
Implements a Windows message.
Definition: message.h:25
Provides data for the xtd::forms::control::mouse_up, xtd::forms::control::mouse_down,...
Definition: mouse_event_args.h:29
Provides data for the paint event.
Definition: paint_event_args.h:26
Represents a Windows toggle_button.
Definition: toggle_button.h:30
void on_enabled_changed(const event_args &e) override
Raises the control::enabled_changed event.
Definition: toggle_button.h:140
void on_handle_created(const event_args &e) override
Raises the handle_created event.
virtual forms::check_state check_state() const
Gets the state of the toggle_button.
Definition: toggle_button.h:70
virtual toggle_button & auto_check(bool auto_check)
Sets a value indicating whether the checked or check_state values and the toggle_button's appearance ...
virtual bool three_state() const
Gets a value indicating whether the toggle_button will allow three check states rather than two.
Definition: toggle_button.h:88
virtual void on_check_state_changed(const event_args &e)
Raises the toggle_button::check_state_changed event.
Definition: toggle_button.h:130
void on_mouse_up(const mouse_event_args &e) override
Raises the control::mouse_up event.
Definition: toggle_button.h:180
drawing::size default_size() const override
Gets the default size of the control.
Definition: toggle_button.h:83
void on_mouse_down(const mouse_event_args &e) override
Raises the control::mouse_down event.
Definition: toggle_button.h:153
virtual toggle_button & check_state(forms::check_state check_state)
Sets the state of the toggle_button.
virtual bool auto_check() const
Gets a value indicating whether the checked or check_state values and the toggle_button's appearance ...
Definition: toggle_button.h:39
virtual void on_checked_changed(const event_args &e)
Raises the toggle_button::checked_changed event.
Definition: toggle_button.h:116
virtual toggle_button & check_align(content_alignment check_align)
Sets the horizontal and vertical alignment of the check mark on a toggle_button control.
void on_paint(paint_event_args &e) override
Raises the control::paint event.
toggle_button()
Initializes a new instance of the CheckBox class.
forms::create_params create_params() const override
Gets the required creation parameters when the control handle is created.
virtual bool checked() const
Gets a value indicating whether the toggle_button is in the checked state.
Definition: toggle_button.h:55
virtual content_alignment check_align() const
Gets the horizontal and vertical alignment of the check mark on a toggle_button control.
Definition: toggle_button.h:47
virtual toggle_button & three_state(bool three_state)
Gets a value indicating whether the toggle_button will allow three check states rather than two.
drawing::size measure_control() const override
Measure this control.
virtual toggle_button & checked(bool checked)
Sets a value indicating whether the toggle_button is in the checked state.
void on_mouse_enter(const event_args &e) override
Raises the control::mouse_enter event.
Definition: toggle_button.h:162
void on_mouse_leave(const event_args &e) override
Raises the control::mouse_leave event.
Definition: toggle_button.h:171
event< toggle_button, event_handler > checked_changed
Occurs when the value of the checked property changes.
Definition: toggle_button.h:96
event< toggle_button, event_handler > check_state_changed
Occurs when the value of the check_state property changes.
Definition: toggle_button.h:100
#define forms_export_
Define shared library export.
Definition: forms_export.h:13
@ e
The E key.
check_state
Specifies the state of a control, such as a check box, that can be checked, unchecked,...
Definition: check_state.h:19
toggle_button_state
Specifies the visual state of a check box that is drawn with visual styles.
Definition: toggle_button_state.h:20
content_alignment
Specifies alignment of content on the drawing surface.
Definition: content_alignment.h:17
@ checked
The control is checked.
@ indeterminate
The control is indeterminate. An indeterminate control generally has a shaded appearance.
@ unchecked
The control is unchecked.
@ mixed_normal
The check box is three-state.
@ mixed_pressed
The check box is three-state and pressed.
@ unchecked_normal
The check box is unchecked.
@ checked_disabled
The check box is checked and disabled.
@ unchecked_pressed
The check box is unchecked and pressed.
@ mixed_hot
The check box is three-state and hot.
@ checked_hot
The check box is checked and hot.
@ unchecked_hot
The check box is unchecked and hot.
@ unchecked_disabled
The check box is unchecked and disabled.
@ checked_pressed
The check box is checked and pressed.
@ mixed_disabled
The check box is three-state and disabled.
@ system
The appearance of the control is determined by the user's operating system.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17
Contains xtd::forms::visual_styles::toggle_button_state enum class.