xtd 0.2.0
Loading...
Searching...
No Matches
control.h
Go to the documentation of this file.
1
4#pragma once
5#include "../forms_export.h"
7#include "anchor_styles.h"
8#include "auto_size_mode.h"
9#include "bounds_specified.h"
10#include "component.h"
11#include "const_control_ref.h"
12#include "context_menu.h"
13#include "control_appearance.h"
15#include "control_ref.h"
16#include "control_styles.h"
17#include "create_params.h"
18#include "cursors.h"
19#include "dock_style.h"
20#include "help_event_handler.h"
21#include "image_layout.h"
22#include "iwin32_window.h"
23#include "key_event_handler.h"
25#include "message.h"
26#include "mouse_event_handler.h"
27#include "padding.h"
28#include "paint_event_handler.h"
29#include "right_to_left.h"
30#include "timer.h"
33#include <xtd/drawing/color>
34#include <xtd/drawing/font>
35#include <xtd/drawing/point>
36#include <xtd/drawing/rectangle>
37#include <xtd/drawing/size>
38#include <xtd/any>
39#include <xtd/async_result>
40#include <xtd/optional>
41#include <xtd/iclonable>
42#include <xtd/iequatable>
43#include <xtd/isynchronize_invoke>
44#include <cstdint>
45#include <functional>
46#include <map>
47#include <memory>
48#include <string>
49#include <vector>
50
52namespace xtd {
54 namespace forms {
56 class application;
57 class context_menu;
58 class horizontal_layout_panel;
59 class screen;
60 class vertical_layout_panel;
61
63
79 class forms_export_ control : public component, public iwin32_window, public iclonable, public icomparable<control>, public xtd::iequatable<control>, public xtd::isynchronize_invoke {
80 struct data;
81
82 protected:
84 enum class state : int64 {
85 empty = 0,
86 creating = 0b1,
87 created = 0b10,
88 destroying = 0b100,
89 destroyed = 0b1000,
90 creating_handle = 0b10000,
91 recreate = 0b100000,
92 parent_recreating = 0b1000000,
93
94 client_size_setted = 0b10000000,
95 modal = 0b100000000,
96 top_level = 0b1000000000,
97 visible = 0b10000000000,
98 enabled = 0b100000000000,
99 auto_size = 0b1000000000000,
100 tab_stop = 0b10000000000000,
101 allow_drop = 0b100000000000000,
102 drop_target = 0b1000000000000000,
103
104 layout_deferred = 0b10000000000000000,
105 docked = 0b100000000000000000,
106
107 double_click_fired = 0b1000000000000000000,
108 double_buffered = 0b10000000000000000000,
109
110 mouse_enter_pending = 0b100000000000000000000,
111 tracking_mouse_event = 0b1000000000000000000000,
112 mouse_pressed = 0b10000000000000000000000,
113 use_wait_cursor = 0b100000000000000000000000,
114
115 is_accessible = 0b1000000000000000000000000,
116 no_zorder = 0b10000000000000000000000000,
117 size_locked_by_os = 0b10000000000000000000000000,
118 causes_validation = 0b100000000000000000000000000,
119 own_ctl_brush = 0b1000000000000000000000000000,
120 exception_while_painting = 0b10000000000000000000000000000,
121 layout_sis_dirty = 0b100000000000000000000000000000,
122 checked_host = 0b1000000000000000000000000000000,
123 hosted_in_dialog = 0b10000000000000000000000000000000,
124 validation_cancelled = 0b100000000000000000000000000000000,
125 mirrored = 0b1000000000000000000000000000000000,
126 };
127
128 class async_result_invoke : public xtd::iasync_result {
129 struct data;
130 public:
131 explicit async_result_invoke(std::any async_state);
132 std::any async_state() const noexcept override;
133 xtd::threading::wait_handle& async_wait_handle() noexcept override;
134 bool completed_synchronously() const noexcept override;
135 bool is_completed() const noexcept override;
136
137 std::shared_ptr<data> data_;
138 };
140
141 public:
143
146 using context_menu_ref = std::reference_wrapper<xtd::forms::context_menu>;
148
151 public:
153
158
160
165 explicit control_collection(const allocator_type& allocator = allocator_type());
171 explicit control_collection(bool clone_and_keep_controls, const allocator_type& allocator = allocator_type());
173
175 explicit control_collection(const base& collection);
176 control_collection(const control_collection& collection);
177 control_collection& operator =(const control_collection& collection);
180
182
184 using base::operator [];
189 std::optional<value_type> operator [](const xtd::ustring& name) const;
194 std::optional<value_type> operator [](const xtd::ustring& name);
196
198
209 template<typename control_t, typename ... args_t>
210 control_t& emplace(const_iterator pos, args_t&& ...args) {
211 auto control_ptr = std::make_unique<control_t>(control_t::create(std::forward<args_t>(args)...));
212 auto& control_ref = *control_ptr;
213 controls_.push_back(std::move(control_ptr));
214 base::insert(pos, control_ref);
215 return control_ref;
216 }
217
227 template<typename control_t, typename ... args_t>
228 control_t& emplace_at(size_t index, args_t&& ...args) {
229 auto control_ptr = std::make_unique<control_t>(control_t::create(std::forward<args_t>(args)...));
230 auto& control_ref = *control_ptr;
231 controls_.push_back(std::move(control_ptr));
232 base::insert_at(index, control_ref);
233 return control_ref;
234 }
235
244 template<typename control_t, typename ... args_t>
245 control_t& emplace_back(args_t&& ...args) {
246 auto control_ptr = std::make_unique<control_t>(control_t::create(std::forward<args_t>(args)...));
247 auto& control_ref = *control_ptr;
248 controls_.push_back(std::move(control_ptr));
249 base::push_back(control_ref);
250 return control_ref;
251 }
252
253 iterator insert(const_iterator pos, const value_type& value) override;
254
255 void insert_at(size_t index, const value_type& value) override;
256
257 void push_back(const value_type& value) override;
258
259 template<typename control_t>
260 iterator insert(const_iterator pos, control_t& value) {
261 for (auto it = begin(); it != end(); ++it)
262 if (it->get() == value) return it;
263 if (!clone_and_keep_controls_) return base::insert(pos, value);
264 auto control_ptr = as<control>(as<iclonable>(value).clone());
265 auto& control_ref = *control_ptr;
266 controls_.push_back(std::move(control_ptr));
267 return base::insert(pos, control_ref);
268 }
269
270 template<typename control_t>
271 void insert_at(size_t index, control_t& value) {
272 for (auto it = begin(); it != end(); ++it)
273 if (it->get() == value) return;
274 if (!clone_and_keep_controls_) base::insert_at(index, value);
275 else {
276 auto control_ptr = as<control>(as<iclonable>(value).clone());
277 auto& control_ref = *control_ptr;
278 controls_.push_back(std::move(control_ptr));
279 base::insert_at(index, control_ref);
280 }
281 }
282
283 template<typename control_t>
284 void push_back(control_t& value) {
285 for (auto it = begin(); it != end(); ++it)
286 if (it->get() == value) return;
287 if (!clone_and_keep_controls_) base::push_back(value);
288 else {
289 auto control_ptr = as<control>(as<iclonable>(value).clone());
290 auto& control_ref = *control_ptr;
291 controls_.push_back(std::move(control_ptr));
292 base::push_back(control_ref);
293 }
294 }
295
297
298 protected:
300
302 void on_item_removed(size_t index, control_ref& item) override {
304 for (auto iterator = controls_.begin(); iterator != controls_.end(); ++iterator) {
305 if (iterator->get() != &item.get()) continue;
306 controls_.erase(iterator);
307 break;
308 }
309 }
311
312 private:
313 bool clone_and_keep_controls_ = false;
314 static std::vector<std::unique_ptr<xtd::forms::control>> controls_;
315 };
316
318
327 explicit control(const xtd::ustring& text);
333 control(const control& parent, const xtd::ustring& text);
342 control(const xtd::ustring& text, int32 left, int32 top, int32 width, int32 height);
352 control(const control& parent, const xtd::ustring& text, int32 left, int32 top, int32 width, int32 height);
354
356 control(control&& rhs);
357 control(const control&) = default;
358 control& operator =(const control&) = default;
359 ~control();
361
363
372 virtual anchor_styles anchor() const noexcept;
382 virtual control& anchor(xtd::forms::anchor_styles anchor);
383
386 virtual drawing::point auto_scroll_point() const noexcept;
387
391 virtual bool auto_size() const noexcept;
396 virtual control& auto_size(bool auto_size);
397
402 virtual drawing::color back_color() const noexcept;
410 virtual control& back_color(const xtd::drawing::color& color);
412 virtual control& back_color(std::nullptr_t);
414
418 virtual const xtd::drawing::image& background_image() const noexcept;
423 virtual control& background_image(const xtd::drawing::image& background_image);
424
429 virtual xtd::forms::image_layout background_image_layout() const noexcept;
430
436 virtual control& background_image_layout(xtd::forms::image_layout background_image_layout);
437
442 virtual int32 bottom() const noexcept;
443
447 virtual drawing::rectangle bounds() const noexcept;
452 virtual control& bounds(const xtd::drawing::rectangle& bounds);
453
457 virtual bool can_focus() const noexcept;
458
470 virtual bool can_select() const noexcept;
471
474 bool can_raise_events() const noexcept override;
475
480 virtual const drawing::rectangle& client_rectangle() const noexcept;
481
485 virtual const drawing::size& client_size() const noexcept;
490 virtual control& client_size(const xtd::drawing::size& client_size);
491
494 virtual xtd::ustring company_name() const noexcept;
495
498 virtual std::optional<context_menu_ref> context_menu() const noexcept;
506 virtual control& context_menu(std::nullptr_t);
507
513 virtual forms::control_appearance control_appearance() const noexcept;
520
527 virtual control_collection& controls() noexcept;
534 virtual const control_collection& controls() const noexcept;
535
539 virtual bool created() const noexcept;
540
544 virtual forms::cursor cursor() const noexcept;
549 virtual control& cursor(const xtd::forms::cursor& cursor);
551 virtual control& cursor(std::nullptr_t);
553
556 virtual drawing::rectangle display_rectangle() const noexcept;
557
566 virtual dock_style dock() const noexcept;
576 virtual control& dock(xtd::forms::dock_style dock);
577
580 virtual bool double_buffered() const noexcept;
584 virtual control& double_buffered(bool double_buffered);
585
588 virtual bool enabled() const noexcept;
592 virtual control& enabled(bool enabled);
593
596 virtual bool focused() const noexcept;
597
601 virtual drawing::font font() const noexcept;
606 virtual control& font(const xtd::drawing::font& font);
608 virtual control& font(std::nullptr_t);
610
614 virtual drawing::color fore_color() const noexcept;
619 virtual control& fore_color(const xtd::drawing::color& color);
621 virtual control& fore_color(std::nullptr_t);
623
627 intptr handle() const override;
628
631 virtual int32 height() const noexcept;
635 virtual control& height(int32 height);
636
639 bool invoke_required() const noexcept override;
640
644 bool is_handle_created() const noexcept;
645
648 virtual int32 left() const noexcept;
652 virtual control& left(int32 left);
653
656 virtual drawing::point location() const noexcept;
660 virtual control& location(const xtd::drawing::point& location);
661
664 virtual forms::padding margin() const noexcept;
668 virtual control& margin(const xtd::forms::padding& margin);
669
675 virtual const drawing::size& maximum_client_size() const noexcept;
681 virtual control& maximum_client_size(const xtd::drawing::size& size);
682
688 virtual const drawing::size& maximum_size() const noexcept;
694 virtual control& maximum_size(const xtd::drawing::size& size);
695
701 virtual const drawing::size& minimum_client_size() const noexcept;
707 virtual control& minimum_client_size(const xtd::drawing::size& size);
708
714 virtual const drawing::size& minimum_size() const noexcept;
720 virtual control& minimum_size(const xtd::drawing::size& size);
721
725 intptr native_handle() const noexcept;
726
729 virtual const xtd::ustring& name() const noexcept;
733 virtual control& name(const xtd::ustring& name);
734
737 virtual forms::padding padding() const noexcept;
742
745 virtual std::optional<control_ref> parent() const noexcept;
749 virtual control& parent(const control& parent);
753 virtual control& parent(std::nullptr_t);
754
757 virtual xtd::ustring product_name() const noexcept;
758
761 bool recreating_handle() const noexcept;
762
767 virtual const xtd::drawing::region& region() const noexcept;
773 virtual control& region(const xtd::drawing::region& value);
774
777 virtual int32 right() const noexcept;
778
794 virtual xtd::forms::right_to_left right_to_left() const noexcept;
813 virtual control& right_to_left(std::nullptr_t);
815
818 virtual drawing::size size() const noexcept;
822 virtual control& size(const drawing::size& size);
823
827 virtual style_sheets::style_sheet style_sheet() const noexcept;
831 virtual control& style_sheet(const style_sheets::style_sheet& value);
836 virtual control& style_sheet(const xtd::ustring& value);
841 virtual control& style_sheet(std::nullptr_t);
842
847 virtual bool tab_stop() const noexcept;
853 virtual control& tab_stop(bool value);
854
859 virtual std::any tag() const noexcept;
865 virtual control& tag(std::any tag);
866
869 virtual const xtd::ustring& text() const noexcept;
873 virtual control& text(const xtd::ustring& text);
874
878 intptr toolkit_handle() const noexcept;
879
882 virtual int32 top() const noexcept;
886 virtual control& top(int32 top);
887
890 virtual std::optional<control_ref> top_level_control() const noexcept;
891
894 virtual bool visible() const noexcept;
898 virtual control& visible(bool visible);
899
902 virtual int32 width() const noexcept;
906 virtual control& width(int32 width);
908
910
916 static bool check_for_illegal_cross_thread_calls() noexcept;
921 static void check_for_illegal_cross_thread_calls(bool value);
922
925 static forms::keys modifier_keys() noexcept;
926
930
935 static xtd::drawing::point mouse_position() noexcept;
937
939
941 using isynchronize_invoke::begin_invoke;
945 xtd::async_result begin_invoke(delegate<void()> method) override;
946
951 xtd::async_result begin_invoke(delegate<void(std::vector<std::any>)> method, const std::vector<std::any>& args) override;
952
955 virtual void bring_to_front();
956
957 int32 compare_to(const control& value) const noexcept override;
958
962 void create_control();
963
967 drawing::graphics create_graphics() const;
968
973 virtual void destroy_control();
974
977 std::optional<object_ref> end_invoke(xtd::async_result async) override;
978
979 bool equals(const control& value) const noexcept override;
980
984 bool focus();
985
988 auto_size_mode get_auto_size_mode() const;
989
992 std::optional<xtd::drawing::color> get_back_color() const noexcept;
994
997 std::optional<xtd::drawing::font> get_font() const noexcept;
999
1002 std::optional<xtd::drawing::color> get_fore_color() const noexcept;
1004
1009 size_t get_child_index(intptr child) const;
1010
1014 size_t get_child_index(intptr child, bool& throw_exception) const;
1015
1018 virtual void hide();
1019
1022 virtual void invalidate() const;
1023
1027 virtual void invalidate(bool invalidate_children) const;
1028
1032 virtual void invalidate(const drawing::rectangle& rect) const;
1033
1038 virtual void invalidate(const drawing::rectangle& rect, bool invalidate_children) const;
1039
1043 virtual void invalidate(const drawing::region& region) const;
1044
1049 virtual void invalidate(const drawing::region& region, bool invalidate_children) const;
1050
1051 using isynchronize_invoke::invoke;
1054 std::optional<object_ref> invoke(delegate<void()> method) override;
1058 std::optional<object_ref> invoke(delegate<void(std::vector<std::any>)> method, const std::vector<std::any>& args) override;
1062 std::optional<object_ref> invoke(delegate<void(std::vector<std::any>)> method, std::any arg) override;
1063
1066 void perform_layout();
1067
1071 xtd::drawing::point point_to_client(const xtd::drawing::point& p) const;
1072
1076 xtd::drawing::point point_to_screen(const xtd::drawing::point& p) const;
1077
1082 virtual bool pre_process_message(const xtd::forms::message& message);
1083
1087 virtual void refresh() const;
1088
1093 void resume_layout();
1094
1101 void resume_layout(bool perform_layout);
1102
1109 intptr send_message(intptr hwnd, int32 msg, intptr wparam, intptr lparam) const;
1110
1113 void set_auto_size_mode(auto_size_mode auto_size_mode);
1114
1120 void set_bounds(int32 x, int32 y, int32 width, int32 height);
1121
1128 void set_bounds(int32 x, int32 y, int32 width, int32 height, bounds_specified specified);
1129
1132 virtual void show();
1133
1139 void suspend_layout();
1140
1143 xtd::ustring to_string() const noexcept override;
1144
1151 virtual void update() const;
1153
1155
1161 control& operator <<(control& child);
1162
1167 control& operator >>(control& child);
1169
1171
1175 static control create();
1179 static control create(const drawing::point& location);
1184 static control create(const drawing::point& location, const drawing::size& size);
1190 static control create(const drawing::point& location, const drawing::size& size, const xtd::ustring& name);
1194 static control create(const control& paren);
1201 static control create(const control& parent, const drawing::point& location);
1207 static control create(const control& parent, const drawing::point& location, const drawing::size& size);
1214 static control create(const control& parent, const drawing::point& location, const drawing::size& size, const xtd::ustring& name);
1217 template<typename control_t>
1218 static control_t create() {
1219 auto result = control_t {};
1220 return result;
1221 }
1225 template<typename control_t>
1226 static control_t create(const drawing::point& location) {
1227 auto result = control_t {};
1228 result.location(location);
1229 return result;
1230 }
1235 template<typename control_t>
1236 static control_t create(const drawing::point& location, const drawing::size& size) {
1237 auto result = control_t {};
1238 result.location(location);
1239 result.size(size);
1240 return result;
1241 }
1247 template<typename control_t>
1248 static control_t create(const drawing::point& location, const drawing::size& size, const xtd::ustring& name) {
1249 auto result = control_t {};
1250 result.location(location);
1251 result.size(size);
1252 result.name(name);
1253 return result;
1254 }
1258 template<typename control_t>
1259 static control_t create(const control& parent) {
1260 auto result = control_t {};
1261 result.parent(parent);
1262 return result;
1263 }
1268 template<typename control_t>
1269 static control_t create(const control& parent, const drawing::point& location) {
1270 auto result = control_t {};
1271 result.parent(parent);
1272 result.location(location);
1273 return result;
1274 }
1280 template<typename control_t>
1281 static control_t create(const control& parent, const drawing::point& location, const drawing::size& size) {
1282 auto result = control_t {};
1283 result.parent(parent);
1284 result.location(location);
1285 result.size(size);
1286 return result;
1287 }
1294 template<typename control_t>
1295 static control_t create(const control& parent, const drawing::point& location, const drawing::size& size, const xtd::ustring& name) {
1296 auto result = control_t {};
1297 result.parent(parent);
1298 result.location(location);
1299 result.size(size);
1300 result.name(name);
1301 return result;
1302 }
1306 template<typename control_t>
1307 static control_t create(const xtd::ustring& text) {
1308 auto result = control_t {};
1309 result.text(text);
1310 return result;
1311 }
1316 template<typename control_t>
1317 static control_t create(const xtd::ustring& text, const drawing::point& location) {
1318 auto result = control_t {};
1319 result.text(text);
1320 result.location(location);
1321 return result;
1322 }
1328 template<typename control_t>
1329 static control_t create(const xtd::ustring& text, const drawing::point& location, const drawing::size& size) {
1330 auto result = control_t {};
1331 result.text(text);
1332 result.location(location);
1333 result.size(size);
1334 return result;
1335 }
1342 template<typename control_t>
1343 static control_t create(const xtd::ustring& text, const drawing::point& location, const drawing::size& size, const xtd::ustring& name) {
1344 auto result = control_t {};
1345 result.text(text);
1346 result.location(location);
1347 result.size(size);
1348 result.name(name);
1349 return result;
1350 }
1355 template<typename control_t>
1356 static control_t create(const control& parent, const xtd::ustring& text) {
1357 auto result = control_t {};
1358 result.parent(parent);
1359 result.text(text);
1360 return result;
1361 }
1367 template<typename control_t>
1368 static control_t create(const control& parent, const xtd::ustring& text, const drawing::point& location) {
1369 auto result = control_t {};
1370 result.parent(parent);
1371 result.text(text);
1372 result.location(location);
1373 return result;
1374 }
1381 template<typename control_t>
1382 static control_t create(const control& parent, const xtd::ustring& text, const drawing::point& location, const drawing::size& size) {
1383 auto result = control_t {};
1384 result.parent(parent);
1385 result.text(text);
1386 result.location(location);
1387 result.size(size);
1388 return result;
1389 }
1397 template<typename control_t>
1398 static control_t create(const control& parent, const xtd::ustring& text, const drawing::point& location, const drawing::size& size, const xtd::ustring& name) {
1399 auto result = control_t {};
1400 result.parent(parent);
1401 result.text(text);
1402 result.location(location);
1403 result.size(size);
1404 result.name(name);
1405 return result;
1406 }
1407
1412 static std::optional<control_ref> from_child_handle(intptr handle);
1413
1417 static std::optional<control_ref> from_handle(intptr handle);
1419
1421
1427
1432
1437
1442
1447
1472
1477
1482
1486
1490
1495
1519
1540
1545
1550
1555
1560
1565
1570
1582
1596
1608
1613
1618
1640
1656
1676
1690
1704
1719
1733
1747
1761
1776
1780
1789
1794
1799
1808
1813
1818
1823
1828
1833
1838
1844
1845 protected:
1846 friend class application;
1847 friend class context_menu;
1848 friend class horizontal_layout_panel;
1849 friend class paint_event_args;
1850 friend class screen;
1851 friend class vertical_layout_panel;
1852 friend class style_sheets::style_sheet;
1853
1855
1860
1866 virtual forms::create_params create_params() const noexcept;
1867
1871 virtual drawing::color default_back_color() const noexcept;
1872
1875 virtual forms::cursor default_cursor() const noexcept;
1876
1879 virtual drawing::font default_font() const noexcept;
1880
1883 virtual drawing::color default_fore_color() const noexcept;
1884
1887 virtual drawing::size default_size() const noexcept;
1889
1891
1897 std::unique_ptr<xtd::object> clone() const override;
1898
1903 virtual void create_handle();
1904
1908 virtual void destroy_handle();
1909
1912 virtual void def_wnd_proc(message& message);
1913
1918 bool get_style(control_styles flag) const noexcept;
1919
1922 virtual drawing::size measure_control() const noexcept;
1923
1926 drawing::size measure_text() const noexcept;
1927
1930 virtual void on_auto_size_changed(const event_args& e);
1931
1934 virtual void on_back_color_changed(const event_args& e);
1935
1938 virtual void on_background_image_changed(const event_args& e);
1939
1942 virtual void on_background_image_layout_changed(const event_args& e);
1943
1946 virtual void on_control_appearance_changed(const event_args& e);
1947
1950 virtual void on_click(const event_args& e);
1951
1954 virtual void on_client_size_changed(const event_args& e);
1955
1958 virtual void on_control_added(const control_event_args& e);
1959
1962 virtual void on_control_removed(const control_event_args& e);
1963
1966 virtual void on_create_control();
1967
1970 virtual void on_cursor_changed(const event_args& e);
1971
1974 virtual void on_destroy_control();
1975
1978 virtual void on_dock_changed(const event_args& e);
1979
1982 virtual void on_double_click(const event_args& e);
1983
1986 virtual void on_enabled_changed(const event_args& e);
1987
1990 virtual void on_fore_color_changed(const event_args& e);
1991
1994 virtual void on_font_changed(const event_args& e);
1995
1998 virtual void on_got_focus(const event_args& e);
1999
2002 virtual void on_handle_created(const event_args& e);
2003
2006 virtual void on_handle_destroyed(const event_args& e);
2007
2010 virtual void on_help_requested(help_event_args& e);
2011
2014 virtual void on_key_down(key_event_args& e);
2015
2018 virtual void on_key_press(key_press_event_args& e);
2019
2022 virtual void on_key_up(key_event_args& e);
2023
2026 virtual void on_layout(const event_args& e);
2027
2030 virtual void on_location_changed(const event_args& e);
2031
2034 virtual void on_lost_focus(const event_args& e);
2035
2038 virtual void on_mouse_click(const mouse_event_args& e);
2039
2042 virtual void on_mouse_double_click(const mouse_event_args& e);
2043
2046 virtual void on_mouse_down(const mouse_event_args& e);
2047
2050 virtual void on_mouse_enter(const event_args& e);
2051
2054 virtual void on_mouse_horizontal_wheel(const mouse_event_args& e);
2055
2058 virtual void on_mouse_leave(const event_args& e);
2059
2062 virtual void on_mouse_move(const mouse_event_args& e);
2063
2066 virtual void on_mouse_up(const mouse_event_args& e);
2067
2070 virtual void on_mouse_wheel(const mouse_event_args& e);
2071
2074 virtual void on_move(const event_args& e);
2075
2078 virtual void on_paint(paint_event_args& e);
2079
2083 virtual void on_paint_background(paint_event_args& e);
2084
2087 virtual void on_parent_back_color_changed(const event_args& e);
2088
2091 virtual void on_parent_cursor_changed(const event_args& e);
2092
2095 virtual void on_parent_changed(const event_args& e);
2096
2099 virtual void on_parent_enabled_changed(const event_args& e);
2100
2103 virtual void on_parent_fore_color_changed(const event_args& e);
2104
2107 virtual void on_parent_font_changed(const event_args& e);
2108
2111 virtual void on_resize(const event_args& e);
2112
2115 virtual void on_region_changed(const event_args& e);
2116
2119 virtual void on_right_to_left_changed(const event_args& e);
2120
2123 virtual void on_size_changed(const event_args& e);
2124
2127 virtual void on_style_sheet_changed(const event_args& e);
2128
2131 virtual void on_system_colors_changed(const event_args& e);
2132
2135 virtual void on_tab_stop_changed(const event_args& e);
2136
2139 virtual void on_text_changed(const event_args& e);
2140
2143 virtual void on_visible_changed(const event_args& e);
2144
2145 void post_recreate_handle() noexcept;
2146
2149 virtual void recreate_handle();
2150
2161 virtual void set_bounds_core(int32 x, int32 y, int32 width, int32 height, bounds_specified specified);
2162
2166 void set_can_focus(bool value);
2167
2171 virtual void set_text(const xtd::ustring& text);
2172
2180 virtual void set_client_size_core(int32 width, int32 height);
2181
2184 void set_parent(intptr handle);
2185
2191 void set_style(control_styles flag, bool value);
2192
2198 virtual void wnd_proc(message& m);
2200
2202
2206 static void set_mouse_buttons(forms::mouse_buttons value);
2208
2210 bool get_state(control::state flag) const noexcept;
2211 void set_state(control::state flag, bool value);
2212 bool on_context_menu_item_click(xtd::forms::context_menu& menu, intptr menu_id) const;
2214
2215 private:
2216 void do_layout_children_with_dock_style();
2217 void do_layout_with_auto_size_mode();
2218 void do_layout_with_anchor_styles();
2219 static bool is_trace_form_or_control(const ustring& name);
2220 void on_controls_item_added(size_t, control_ref item);
2221 void on_controls_item_removed(size_t, control_ref item);
2222 void on_parent_size_changed(object& sender, const event_args& e);
2223 void show_context_menu(xtd::forms::context_menu& menu, const xtd::drawing::point& pos) const;
2224 void reflect_message(intptr handle, message& message);
2225 intptr wnd_proc_(intptr hwnd, int32 msg, intptr wparam, intptr lparam, intptr handle);
2226 void wm_app_idle(message& message);
2227 void wm_child_activate(message& message);
2228 void wm_command(message& message);
2229 void wm_command_control(message& message);
2230 void wm_ctlcolor(message& message);
2231 void wm_ctlcolor_control(message& message);
2232 void wm_create(message& message);
2233 void wm_destroy(message& message);
2234 void wm_key_char(message& message);
2235 void wm_kill_focus(message& message);
2236 void wm_menu_command(message& message);
2237 void wm_mouse_down(message& message);
2238 void wm_mouse_double_click(message& message);
2239 void wm_mouse_enter(message& message);
2240 void wm_mouse_leave(message& message);
2241 void wm_mouse_up(message& message);
2242 void wm_mouse_move(message& message);
2243 void wm_move(message& message);
2244 void wm_mouse_wheel(message& message);
2245 void wm_notify(message& message);
2246 void wm_notify_control(message& message);
2247 void wm_paint(message& message);
2248 void wm_erase_background(message& message);
2249 void wm_help(message& message);
2250 void wm_scroll(message& message);
2251 void wm_scroll_control(message& message);
2252 void wm_set_focus(message& message);
2253 void wm_set_text(message& message);
2254 void wm_show(message& message);
2255 void wm_size(message& message);
2256 void wm_sizing(message& message);
2257 void wm_style_sheet_changed(message& message);
2258
2259 static bool check_for_illegal_cross_thread_calls_;
2260 static forms::keys modifier_keys_;
2261 static forms::mouse_buttons mouse_buttons_;
2262 static std::map<intptr, control*> handles_;
2263 static control_collection top_level_controls_;
2264
2265 std::shared_ptr<data> data_;
2266 };
2267 }
2268}
Contains xtd::forms::anchor_styles enum class.
Contains xtd::forms::layout::arranged_element_collection collection.
Contains xtd::forms::auto_size_mode enum class.
Contains xtd::forms::bounds_specified enum class.
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition point.h:54
Stores an ordered pair of integers, which specify a height and width.
Definition size.h:31
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
Provides static methods and properties to manage an application, such as methods to start and stop an...
Definition application.h:49
Provides the base implementation and enables object sharing between applications.
Definition component.h:23
Represents a shortcut menu.
Definition context_menu.h:34
Represents a collection of controls.
Definition control.h:150
control_collection(const allocator_type &allocator=allocator_type())
Creates a new object xtd::forms::control::control_collection with specified allocator (optional).
control_t & emplace_at(size_t index, args_t &&...args)
Creates and inserts specified control at specified position.
Definition control.h:228
control_t & emplace(const_iterator pos, args_t &&...args)
Creates and inserts specified control at specified position.
Definition control.h:210
iterator insert(const_iterator pos, const value_type &value) override
Inserts specified element at specified position.
void push_back(const value_type &value) override
Adds an element to the end.
control_t & emplace_back(args_t &&...args)
Creates and adds a control to the end.
Definition control.h:245
void on_item_removed(size_t index, control_ref &item) override
Raises the xtd::forms::layout::arranged_element_collection::item_removed event.
Definition control.h:302
control_collection(bool clone_and_keep_controls, const allocator_type &allocator=allocator_type())
Creates a new object xtd::forms::control::control_collection with specified clone_and_keep_controls,...
void insert_at(size_t index, const value_type &value) override
Inserts specified element at specified index.
Provides data for the xtd::forms::control::control_added and xtd::forms::control::control_removed eve...
Definition control_event_args.h:25
Defines the base class for controls, which are components with visual representation.
Definition control.h:79
event< control, event_handler > parent_changed
Occurs when the value of the xtd::forms::control::parent property changes.
Definition control.h:1793
event< control, help_event_handler > help_requested
Occurs when the user requests help for a xtd::forms::control.
Definition control.h:1569
static control_t create(const control &parent, const drawing::point &location, const drawing::size &size)
A factory to create a specified control with specified parent, location, and size.
Definition control.h:1281
event< control, event_handler > dock_changed
Occurs when the value of the xtd::forms::control::dock property changes.
Definition control.h:1494
event< control, event_handler > move
Occurs when the control is moved.
Definition control.h:1779
event< control, event_handler > style_sheet_changed
Occurs when the value of the xtd::forms::control::style_sheet property changes or when xtd::applicati...
Definition control.h:1822
control(const xtd::ustring &text)
Initializes a new instance of the xtd::forms::control class with specific text.
event< control, event_handler > background_image_changed
Occurs when the value of the xtd::forms::control::background_image property changes.
Definition control.h:1436
event< control, event_handler > client_size_changed
Occurs when the value of the xtd::forms::control::client_size property changes.
Definition control.h:1476
event< control, event_handler > system_colors_changed
Occurs when the xtd::drwing::system_colors changes.
Definition control.h:1827
event< control, event_handler > tab_stop_changed
Occurs when the xtd::forms::control::tab_stop property value changes.
Definition control.h:1832
event< control, key_event_handler > key_up
Occurs when a key is released while the xtd::forms::control has focus.
Definition control.h:1607
static control_t create(const control &parent, const xtd::ustring &text)
A factory to create a specified control with specified parent, and text.
Definition control.h:1356
std::reference_wrapper< xtd::forms::context_menu > context_menu_ref
Represent an xtd::forms::context_menu reference.
Definition control.h:146
event< control, event_handler > enabled_changed
Occurs when the value of the xtd::forms::control::enabled property changes.
Definition control.h:1554
control(const control &parent, const xtd::ustring &text, int32 left, int32 top, int32 width, int32 height)
Initializes a new instance of the xtd::forms::control class as a child control, with specific text,...
event< control, event_handler > visible_changed
Occurs when the value of the xtd::forms::control::visible property changes.
Definition control.h:1842
static std::optional< control_ref > from_child_handle(intptr handle)
Retrieves the control that contains the specified handle.
static control_t create(const xtd::ustring &text, const drawing::point &location)
A factory to create a specified control with specified text, and location.
Definition control.h:1317
control(const xtd::ustring &text, int32 left, int32 top, int32 width, int32 height)
Initializes a new instance of the control class with specific text, size, and location.
static control_t create(const control &parent, const drawing::point &location, const drawing::size &size, const xtd::ustring &name)
A factory to create a specified control with specified parent, location, size, and name.
Definition control.h:1295
static control_t create(const drawing::point &location, const drawing::size &size, const xtd::ustring &name)
A factory to create a specified control with specified location, size, and name.
Definition control.h:1248
event< control, event_handler > text_changed
Occurs when the value of the xtd::forms::control::text property changes.
Definition control.h:1837
event< control, event_handler > layout
Occurs when a xtd::forms::control should reposition its child controls.
Definition control.h:1612
event< control, event_handler > font_changed
Occurs when the value of the xtd::forms::control::font property changes.
Definition control.h:1564
static control_t create(const control &parent, const xtd::ustring &text, const drawing::point &location, const drawing::size &size, const xtd::ustring &name)
A factory to create a specified control with specified parent, text, location, size,...
Definition control.h:1398
event< control, event_handler > double_click
Occurs when the xtd::forms::control is double-clicked.
Definition control.h:1518
event< control, event_handler > click
Occurs when the xtd::forms::control is clicked.
Definition control.h:1471
event< control, key_press_event_handler > key_press
Occurs when a character. space or backspace key is pressed while the xtd::forms::control has focus.
Definition control.h:1595
static control_t create(const xtd::ustring &text, const drawing::point &location, const drawing::size &size)
A factory to create a specified control with specified text, location, and size.
Definition control.h:1329
event< control, event_handler > handle_created
Occurs when a handle is created for the xtd::forms::control.
Definition control.h:1544
event< control, event_handler > handle_destroyed
Occurs when the control's handle is in the process of being destroyed.
Definition control.h:1549
event< control, control_event_handler > control_removed
Occurs when a new xtd::forms::control:: is removed to the xtd::forms::control::control_collection.
Definition control.h:1489
event< control, mouse_event_handler > mouse_down
Occurs when the mouse pointer is over the xtd::forms::control and a mouse button is pressed.
Definition control.h:1689
static control_t create(const xtd::ustring &text)
A factory to create a specified control with specified text.
Definition control.h:1307
control()
Initializes a new instance of the xtd::forms::control class with default settings.
event< control, event_handler > mouse_enter
Occurs when the mouse pointer enters the xtd::forms::control.
Definition control.h:1703
event< control, event_handler > auto_size_changed
Occurs when the value of the xtd::forms::control::auto_size property changes.
Definition control.h:1426
event< control, mouse_event_handler > mouse_double_click
Occurs when the xtd::forms::control is double clicked by the mouse.
Definition control.h:1675
event< control, paint_event_handler > paint
Occurs when the xtd::forms::control is redrawn.
Definition control.h:1788
static control_t create(const drawing::point &location, const drawing::size &size)
A factory to create a specified control with specified location, and size.
Definition control.h:1236
event< control, event_handler > lost_focus
Occurs when the xtd::forms::control loses focus.
Definition control.h:1639
static control_t create(const control &parent, const xtd::ustring &text, const drawing::point &location, const drawing::size &size)
A factory to create a specified control with specified parent, text, location, and size.
Definition control.h:1382
event< control, event_handler > background_image_layout_changed
Occurs when the value of the xtd::forms::control::background_image_layout property changes.
Definition control.h:1441
xtd::forms::visual_styles::control_state control_state() const noexcept
Gets state.
static control_t create(const control &parent, const drawing::point &location)
A factory to create a specified control with specified parent, and location.
Definition control.h:1269
event< control, event_handler > region_changed
Occurs when the value of the xtd::forms::control::region property changes.
Definition control.h:1798
event< control, event_handler > mouse_leave
Occurs when the mouse pointer leaves the xtd::forms::control.
Definition control.h:1732
event< control, mouse_event_handler > mouse_move
Occurs when the mouse pointer is moved over the xtd::forms::control.
Definition control.h:1746
static control_t create(const control &parent, const xtd::ustring &text, const drawing::point &location)
A factory to create a specified control with specified parent, text, and location.
Definition control.h:1368
event< control, event_handler > right_to_left_changed
Occurs when the value of the xtd::forms::control::right_to_left property changes.
Definition control.h:1812
virtual anchor_styles anchor() const noexcept
Gets the edges of the container to which a control is bound and determines how a control is resized w...
event< control, event_handler > control_appearance_changed
Occurs when the value of the xtd::forms::control::control_appearance property changes.
Definition control.h:1446
event< control, key_event_handler > key_down
Occurs when a key is pressed while the xtd::forms::control has focus.
Definition control.h:1581
event< control, event_handler > got_focus
Occurs when the xtd::forms::control receives focus.
Definition control.h:1539
event< control, event_handler > location_changed
Occurs when the value of the xtd::forms::control::location property changes.
Definition control.h:1617
event< control, mouse_event_handler > mouse_up
Occurs when the mouse pointer is over the xtd::forms::control and a mouse button is released.
Definition control.h:1760
event< control, mouse_event_handler > mouse_horizontal_wheel
Occurs when the mouse horizontal wheel moves while the xtd::forms::control has focus.
Definition control.h:1718
static control_t create(const control &parent)
A factory to create a specified control with specified parent.
Definition control.h:1259
event< control, mouse_event_handler > mouse_wheel
Occurs when the mouse wheel moves while the xtd::forms::control has focus.
Definition control.h:1775
static control_t create(const xtd::ustring &text, const drawing::point &location, const drawing::size &size, const xtd::ustring &name)
A factory to create a specified control with specified text, location,size, and name.
Definition control.h:1343
static control_t create(const drawing::point &location)
A factory to create a specified control with specified location.
Definition control.h:1226
event< control, event_handler > back_color_changed
Occurs when the value of the xtd::forms::control::back_color property changes.
Definition control.h:1431
event< control, control_event_handler > control_added
Occurs when a new xtd::forms::control::control is added to the xtd::forms::control::control_collectio...
Definition control.h:1485
event< control, event_handler > fore_color_changed
Occurs when the value of the xtd::forms::control::fore_color property changes.
Definition control.h:1559
event< control, event_handler > resize
Occurs when the xtd::forms::control is resized.
Definition control.h:1807
event< control, event_handler > cursor_changed
Occurs when the value of the xtd::forms::control::cursor property changes.
Definition control.h:1481
static std::optional< control_ref > from_handle(intptr handle)
Returns the control that is currently associated with the specified handle.
control(const control &parent, const xtd::ustring &text)
Initializes a new instance of the xtd::forms::control class as a child control, with specific text.
event< control, mouse_event_handler > mouse_click
Occurs when the xtd::forms::control is clicked by the mouse.
Definition control.h:1655
event< control, event_handler > size_changed
Occurs when the value of the xtd::forms::control::size property changes.
Definition control.h:1817
Encapsulates the information needed when creating a control.
Definition create_params.h:27
Represents the image used to paint the mouse pointer.
Definition cursor.h:38
Provides data for the xtd::forms::control::control_added and xtd::forms::control::control_removed eve...
Definition help_event_args.h:24
Used to group collections of horizontally aligned controls.
Definition horizontal_layout_panel.h:28
Provides an interface to expose Win32 HWND handles.
Definition iwin32_window.h:21
Provides data for the xtd::forms::control::key_down or xtd::forms::control::key_up event.
Definition key_event_args.h:23
Provides data for the xtd::forms::control::key_press event.
Definition key_press_event_args.h:24
Represents a collection of objects.
Definition arranged_element_collection.h:32
virtual void on_item_removed(size_t index, type_t &item)
Raises the xtd::forms::layout::arranged_element_collection::item_removed event.
Definition arranged_element_collection.h:495
typename std::vector< value_type >::iterator iterator
Represents the iterator type of the collection.
Definition arranged_element_collection.h:83
std::allocator< value_type > allocator_type
Represents the allocator type of the collection.
Definition arranged_element_collection.h:69
typename std::vector< value_type >::const_iterator const_iterator
Represents the const iterator type of the collection.
Definition arranged_element_collection.h:85
Represents the base functionality for all menus. Although tool_strip_drop_down and tool_strip_drop_do...
Definition menu.h:35
Implements a Windows message.
Definition message.h:26
Provides data for the xtd::forms::control::mouse_up, xtd::forms::control::mouse_down,...
Definition mouse_event_args.h:32
Represents a display device or multiple display devices on a single system.
Definition padding.h:23
Provides data for the xtd::forms::control::paint event.
Definition paint_event_args.h:28
Represents a display device or multiple display devices on a single system.
Definition screen.h:30
The xtd::forms::style_sheets::style_sheet allows you to specify an xtd style sheet.
Definition style_sheet.h:62
Creates a use wait cursor class.
Definition use_wait_cursor.h:23
Used to group collections of vertically aligned controls.
Definition vertical_layout_panel.h:29
Represents the status of an asynchronous operation.
Definition iasync_result.h:22
Supports cloning, which creates a new instance of a class with the same value as an existing instance...
Definition iclonable.h:19
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.h:17
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.h:18
Provides a way to synchronously or asynchronously execute a delegate.
Definition isynchronize_invoke.h:26
Encapsulates operating system specific objects that wait for exclusive access to shared resources.
Definition wait_handle.h:50
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
Contains xtd::forms::component class.
Contains xtd::forms::const_control_ref typedef.
Contains xtd::forms::context_menu menu.
Contains xtd::forms::control_appearance enum class.
Contains xtd::forms::control_event_handler event handler.
Contains xtd::forms::control_ref typedef.
Contains xtd::forms::visual_styles::control_state enum class.
Contains xtd::forms::control_styles enum class.
Contains xtd::forms::create_params class.
Contains xtd::forms::cursors factory.
Contains xtd::forms::dock_style enum class.
#define forms_export_
Define shared library export.
Definition forms_export.h:13
int_least64_t int64
Represents a 64-bit signed integer.
Definition types.h:142
int_least32_t int32
Represents a 32-bit signed integer.
Definition types.h:131
size_t size
Represents a size of any object in bytes.
Definition types.h:197
intmax_t intptr
Represent a pointer or a handle.
Definition types.h:153
std::shared_ptr< xtd::iasync_result > async_result
Represents the status of an asynchronous operation.
Definition async_result.h:16
std::reference_wrapper< object > object_ref
Represents an object reference.
Definition object_ref.h:18
@ end
The END key.
@ insert
The INS (INSERT) key.
keys
Specifies key codes and modifiers.
Definition keys.h:74
bounds_specified
Specifies the bounds of the control to use when defining a control's size and position....
Definition bounds_specified.h:20
image_layout
Specifies the position of the image on the control.
Definition image_layout.h:19
control_appearance
Specifies the appearance of a control.
Definition control_appearance.h:19
control_state
Specifies the visual state of a control that is drawn with visual styles.
Definition control_state.h:22
control_styles
Specifies the style and behavior of a control.
Definition control_styles.h:31
auto_size_mode
Specifies how a control will behave when its auto_size property is enabled.
Definition auto_size_mode.h:20
dock_style
Specifies the position and manner in which a control is docked.
Definition dock_style.h:21
anchor_styles
Specifies how a control anchors to the edges of its container.
Definition anchor_styles.h:19
right_to_left
Specifies a value indicating whether the text appears from right to left, such as when using Hebrew o...
Definition right_to_left.h:22
mouse_buttons
Specifies constants that define which mouse button was pressed. This enumeration has a flag attribute...
Definition mouse_buttons.h:20
std::reference_wrapper< control > control_ref
Represents a control reference.
Definition control_ref.h:23
@ auto_size
The picture_box is sized equal to the size of the image that it contains.
@ location
Specifies that both the x and y coordinates of the control are defined.
@ text
The xtd::forms::status_bar_panel displays text in the standard font.
Contains xtd::forms::help_event_handler event handler.
Contains xtd::forms::image_layout enum class.
Contains xtd::forms::iwin32_window interface.
Contains xtd::forms::key_event_handler event handler.
Contains xtd::forms::key_press_event_handler event handler.
Contains xtd::forms::message class.
Contains xtd::forms::mouse_event_handler event handler.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.h:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd::forms::paint_event_handler event handler.
Contains xtd::forms::right_to_left enum class.
Contains xtd::forms::style_sheets::style_sheet class.
Contains xtd::forms::style_sheets::padding alias.
Contains xtd::forms::timer component.