xtd - Reference Guide  0.1.2
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
button_base.h
Go to the documentation of this file.
1
4#pragma once
5#include <xtd/drawing/image.h>
6#include "control.h"
7#include "content_alignment.h"
8#include "image_list.h"
10#include "flat_style.h"
11#include "text_format_flags.h"
12
14namespace xtd {
16 namespace forms {
27 public:
31 bool auto_ellipsis() const {return auto_ellipsis_;}
32
36 virtual button_base& auto_ellipsis(bool auto_ellipsis) {
37 if (auto_ellipsis_ != auto_ellipsis)
38 auto_ellipsis_ = auto_ellipsis;
39 return *this;
40 }
41
42 bool auto_size() const override {return control::auto_size();}
43 control& auto_size(bool auto_size) override {
44 control::auto_size(auto_size);
45 if (get_state(state::auto_size))
46 auto_ellipsis_ = false;
47 return *this;
48 }
49
52 const xtd::forms::flat_button_appearance& flat_appearance() const {return flat_appearance_;}
56
59 virtual xtd::forms::flat_style flat_style() const {return flat_style_;}
63
68 virtual const drawing::image& image() const {return image_;}
73 virtual button_base& image(const drawing::image& value);
74
77 virtual content_alignment image_align() const {return image_align_;}
81
87 virtual int32_t image_index() const {return image_index_;}
93 virtual button_base& image_index(int32_t value);
94
97 virtual const forms::image_list& image_list() const {return image_list_;}
100 virtual forms::image_list& image_list() {return image_list_;}
104
107 virtual content_alignment text_align() const {return text_align_;}
111
116
117 protected:
120
123 forms::create_params create_params() const override;
124
127 drawing::size default_size() const override {return {75, 25};}
128
133
134 void on_back_color_changed(const event_args& e) override {
135 if (flat_style_ != xtd::forms::flat_style::system) invalidate();
136 control::on_parent_back_color_changed(e);
137 }
138
139 void on_enabled_changed(const event_args& e) override {
140 if (flat_style_ != xtd::forms::flat_style::system) invalidate();
141 control::on_enabled_changed(e);
142 }
143
144 void on_font_changed(const xtd::event_args& e) override {
145 if (flat_style_ != xtd::forms::flat_style::system) invalidate();
146 control::on_font_changed(e);
147 }
148
149 void on_fore_color_changed(const event_args& e) override {
150 if (flat_style_ != xtd::forms::flat_style::system) invalidate();
151 control::on_fore_color_changed(e);
152 }
153
156 virtual void on_image_changed(const xtd::event_args& e) {
157 if (flat_style_ != xtd::forms::flat_style::system) invalidate();
158 if (can_raise_events()) image_changed(*this, e);
159 }
160
161 void on_mouse_down(const mouse_event_args& e) override {
162 if (flat_style_ != xtd::forms::flat_style::system) invalidate();
163 control::on_mouse_down(e);
164 }
165
166 void on_mouse_enter(const event_args& e) override {
167 if (flat_style_ != xtd::forms::flat_style::system) invalidate();
168 control::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) invalidate();
173 control::on_mouse_leave(e);
174 }
175
176 void on_mouse_up(const mouse_event_args& e) override {
177 if (flat_style_ != xtd::forms::flat_style::system) invalidate();
178 control::on_mouse_up(e);
179 }
180
181 void on_parent_back_color_changed(const event_args& e) override {
182 if (flat_style_ != xtd::forms::flat_style::system) invalidate();
183 control::on_parent_back_color_changed(e);
184 }
185
186 void on_parent_fore_color_changed(const event_args& e) override {
187 if (flat_style_ != xtd::forms::flat_style::system) invalidate();
188 control::on_parent_fore_color_changed(e);
189 }
190
191 void on_resize(const xtd::event_args& e) override {
192 if (flat_style_ != xtd::forms::flat_style::system) invalidate();
193 control::on_resize(e);
194 }
195
196 void on_text_changed(const xtd::event_args& e) override {
197 if (flat_style_ != xtd::forms::flat_style::system) invalidate();
198 control::on_text_changed(e);
199 }
200
202 text_format_flags to_text_format_flags(content_alignment text_align);
203 xtd::drawing::rectangle compute_image_bounds() {return compute_image_bounds({0, 0, width(), height()});}
204 xtd::drawing::rectangle compute_image_bounds(const xtd::drawing::rectangle& rectangle);
205
206 bool auto_ellipsis_ = false;
207 xtd::forms::flat_button_appearance flat_appearance_;
209 xtd::drawing::image image_ = xtd::drawing::image::empty;
211 int32_t image_index_ = -1;
212 content_alignment image_align_ = content_alignment::middle_center;
213 content_alignment text_align_ = content_alignment::middle_center;
215 };
216 }
217}
An abstract base class that provides functionality for the bitmap and metafile descended classes.
Definition image.h:34
Stores a set of four integers that represent the location and size of a rectangle.
Definition rectangle.h:25
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
virtual const drawing::image & image() const
Gets the image that is displayed on a button control.
Definition button_base.h:68
virtual forms::image_list & image_list()
Gets the image_list that contains the image displayed on a button control.
Definition button_base.h:100
virtual button_base & auto_ellipsis(bool auto_ellipsis)
Sets a value indicating whether the ellipsis character (...) appears at the right edge of the control...
Definition button_base.h:36
drawing::size measure_control() const override
Measure this control.
const xtd::forms::flat_button_appearance & flat_appearance() const
Gets the appearance of the border and the colors used to indicate check state and mouse state.
Definition button_base.h:52
void on_enabled_changed(const event_args &e) override
Raises the control::enabled_changed event.
Definition button_base.h:139
void on_mouse_up(const mouse_event_args &e) override
Raises the control::mouse_up event.
Definition button_base.h:176
void on_mouse_down(const mouse_event_args &e) override
Raises the control::mouse_down event.
Definition button_base.h:161
virtual button_base & image_list(const forms::image_list &value)
Sets the image_list that contains the image displayed on a button control.
virtual xtd::forms::flat_style flat_style() const
Gets the flat style appearance of the button control.
Definition button_base.h:59
void on_fore_color_changed(const event_args &e) override
Raises the control::fore_color_changed event.
Definition button_base.h:149
virtual xtd::forms::button_base & flat_style(xtd::forms::flat_style flat_style)
Sets the flat style appearance of the button control.
void on_parent_fore_color_changed(const event_args &e) override
Raises the control::parent_fore_color_changed event.
Definition button_base.h:186
bool auto_size() const override
Gets a value that indicates whether the control resizes based on its contents.
Definition button_base.h:42
control & auto_size(bool auto_size) override
Sets a value that indicates whether the control resizes based on its contents.
Definition button_base.h:43
drawing::size default_size() const override
Gets the default size of the control.
Definition button_base.h:127
void on_back_color_changed(const event_args &e) override
Raises the control::back_color_changed event.
Definition button_base.h:134
void on_text_changed(const xtd::event_args &e) override
Raises the control::text_changed event.
Definition button_base.h:196
void on_parent_back_color_changed(const event_args &e) override
Raises the control::parent_back_color_changed event.
Definition button_base.h:181
virtual void on_image_changed(const xtd::event_args &e)
Raises the button_base::image_changed event.
Definition button_base.h:156
forms::create_params create_params() const override
Gets the required creation parameters when the control handle is created.
void on_mouse_enter(const event_args &e) override
Raises the control::mouse_enter event.
Definition button_base.h:166
virtual button_base & image(const drawing::image &value)
Sets the image that is displayed on a button control.
void on_resize(const xtd::event_args &e) override
Raises the control::resize event.
Definition button_base.h:191
virtual content_alignment image_align() const
Gets the alignment of the image on the button control.
Definition button_base.h:77
button_base()
Initializes a new instance of the ButtonBase class.
void on_font_changed(const xtd::event_args &e) override
Raises the control::font_changed event.
Definition button_base.h:144
virtual int32_t image_index() const
Gets the image list index value of the image displayed on the button control.
Definition button_base.h:87
bool auto_ellipsis() const
Gets a value indicating whether the ellipsis character (...) appears at the right edge of the control...
Definition button_base.h:31
virtual button_base & text_align(content_alignment value)
Gets the alignment of the text on the button control.
virtual button_base & image_align(content_alignment value)
Gets the alignment of the image on the button control.
void on_mouse_leave(const event_args &e) override
Raises the control::mouse_leave event.
Definition button_base.h:171
xtd::forms::flat_button_appearance & flat_appearance()
Gets the appearance of the border and the colors used to indicate check state and mouse state.
Definition button_base.h:55
virtual content_alignment text_align() const
Gets the alignment of the text on the button control.
Definition button_base.h:107
virtual button_base & image_index(int32_t value)
Sets the image list index value of the image displayed on the button control.
virtual const forms::image_list & image_list() const
Gets the image_list that contains the image displayed on a button control.
Definition button_base.h:97
Defines the base class for controls, which are components with visual representation.
Definition control.h:67
Provides properties that specify the appearance of xtd::forms::button controls whose xtd::forms::flat...
Definition flat_button_appearance.h:20
Provides methods to manage a collection of xtd::drawing::image objects. This class cannot be inherite...
Definition image_list.h:25
static image_list empty
Represents an image_list empty.
Definition image_list.h:78
Provides data for the xtd::forms::control::mouse_up, xtd::forms::control::mouse_down,...
Definition mouse_event_args.h:29
Contains xtd::forms::content_alignment enum class.
Contains xtd::forms::control control.
Contains xtd::forms::flat_button_appearance class.
Contains xtd::forms::flat_style enum class.
event< button_base, event_handler > image_changed
Occurs when the value of the image property changes.
Definition button_base.h:115
#define forms_export_
Define shared library export.
Definition forms_export.h:13
@ e
The E key.
text_format_flags
Specifies the display and layout information for text strings.
Definition text_format_flags.h:18
flat_style
Specifies the appearance of a control.
Definition flat_style.h:20
content_alignment
Specifies alignment of content on the drawing surface.
Definition content_alignment.h:17
@ auto_size
The picture_box is sized equal to the size of the image that it contains.
@ height
Specifies that the height of the control is defined.
@ width
Specifies that the width of the control is defined.
@ system
The appearance of the control is determined by the user's operating system.
@ standard
The control appears three-dimensional.
Contains xtd::drawing::image class.
Contains xtd::forms::image_list component.
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::text_format_flags enum class.