xtd 0.2.0
Loading...
Searching...
No Matches
control.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "../forms_export.hpp"
7#include "anchor_styles.hpp"
8#include "auto_size_mode.hpp"
10#include "component.hpp"
11#include "const_control_ref.hpp"
12#include "context_menu.hpp"
15#include "control_ref.hpp"
16#include "control_styles.hpp"
17#include "create_params.hpp"
18#include "cursors.hpp"
19#include "dock_style.hpp"
21#include "image_layout.hpp"
22#include "iwin32_window.hpp"
23#include "key_event_handler.hpp"
25#include "message.hpp"
27#include "padding.hpp"
29#include "right_to_left.hpp"
30#include "timer.hpp"
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
81 class forms_export_ control : public component, public iwin32_window, public iclonable, public icomparable<control>, public xtd::iequatable<control>, public xtd::isynchronize_invoke {
82 struct data;
83
84 protected:
86 enum class state : int64 {
87 empty = 0,
88 creating = 0b1,
89 created = 0b10,
90 destroying = 0b100,
91 destroyed = 0b1000,
92 creating_handle = 0b10000,
93 recreate = 0b100000,
94 parent_recreating = 0b1000000,
95
96 client_size_setted = 0b10000000,
97 modal = 0b100000000,
98 top_level = 0b1000000000,
99 visible = 0b10000000000,
100 enabled = 0b100000000000,
101 auto_size = 0b1000000000000,
102 tab_stop = 0b10000000000000,
103 allow_drop = 0b100000000000000,
104 drop_target = 0b1000000000000000,
105
106 layout_deferred = 0b10000000000000000,
107 docked = 0b100000000000000000,
108
109 double_click_fired = 0b1000000000000000000,
110 double_buffered = 0b10000000000000000000,
111
112 mouse_enter_pending = 0b100000000000000000000,
113 tracking_mouse_event = 0b1000000000000000000000,
114 mouse_pressed = 0b10000000000000000000000,
115 use_wait_cursor = 0b100000000000000000000000,
116
117 is_accessible = 0b1000000000000000000000000,
118 no_zorder = 0b10000000000000000000000000,
119 size_locked_by_os = 0b10000000000000000000000000,
120 causes_validation = 0b100000000000000000000000000,
121 own_ctl_brush = 0b1000000000000000000000000000,
122 exception_while_painting = 0b10000000000000000000000000000,
123 layout_sis_dirty = 0b100000000000000000000000000000,
124 checked_host = 0b1000000000000000000000000000000,
125 hosted_in_dialog = 0b10000000000000000000000000000000,
126 validation_cancelled = 0b100000000000000000000000000000000,
127 mirrored = 0b1000000000000000000000000000000000,
128 };
129
130 class async_result_invoke : public xtd::iasync_result {
131 struct data;
132 public:
133 explicit async_result_invoke(std::any async_state);
134 std::any async_state() const noexcept override;
135 xtd::threading::wait_handle& async_wait_handle() noexcept override;
136 bool completed_synchronously() const noexcept override;
137 bool is_completed() const noexcept override;
138
139 xtd::sptr<data> data_;
140 };
142
143 public:
145
148 using context_menu_ref = std::reference_wrapper<xtd::forms::context_menu>;
150
153 public:
155
160
162
167 explicit control_collection(const allocator_type& allocator = allocator_type());
173 explicit control_collection(bool keep_cloned_controls, const allocator_type& allocator = allocator_type());
175
177 explicit control_collection(const base& collection);
178 control_collection(const control_collection& collection);
179 control_collection& operator =(const control_collection& collection);
182
184
186 using base::operator [];
191 std::optional<value_type> operator [](const xtd::string& name) const;
196 std::optional<value_type> operator [](const xtd::string& name);
198
200
211 template<typename control_t, typename ... args_t>
212 control_t& emplace(const_iterator pos, args_t&& ...args) {
213 auto control_ptr = xtd::new_uptr<control_t>(control_t::create(std::forward<args_t>(args)...));
214 auto& control_ref = *control_ptr;
215 controls_.push_back(std::move(control_ptr));
216 base::insert(pos, control_ref);
217 return control_ref;
218 }
219
229 template<typename control_t, typename ... args_t>
230 control_t& emplace_at(size_t index, args_t&& ...args) {
231 auto control_ptr = xtd::new_uptr<control_t>(control_t::create(std::forward<args_t>(args)...));
232 auto& control_ref = *control_ptr;
233 controls_.push_back(std::move(control_ptr));
234 base::insert_at(index, control_ref);
235 return control_ref;
236 }
237
246 template<typename control_t, typename ... args_t>
247 control_t& emplace_back(args_t&& ...args) {
248 auto control_ptr = xtd::new_uptr<control_t>(control_t::create(std::forward<args_t>(args)...));
249 auto& control_ref = *control_ptr;
250 controls_.push_back(std::move(control_ptr));
251 base::push_back(control_ref);
252 return control_ref;
253 }
254
255 iterator insert(const_iterator pos, const value_type& value) override;
256
257 void insert_at(size_t index, const value_type& value) override;
258
259 void push_back(const value_type& value) override;
260
261 template<typename control_t>
262 iterator insert(const_iterator pos, control_t& value) {
263 for (auto it = begin(); it != end(); ++it)
264 if (it->get() == value) return it;
265 if (!keep_cloned_controls_) return base::insert(pos, value);
266 auto control_ptr = as<control>(as<iclonable>(value).clone());
267 auto& control_ref = *control_ptr;
268 controls_.push_back(std::move(control_ptr));
269 return base::insert(pos, control_ref);
270 }
271
272 template<typename control_t>
273 void insert_at(size_t index, control_t& value) {
274 for (auto it = begin(); it != end(); ++it)
275 if (it->get() == value) return;
276 if (!keep_cloned_controls_) base::insert_at(index, value);
277 else {
278 auto control_ptr = as<control>(as<iclonable>(value).clone());
279 auto& control_ref = *control_ptr;
280 controls_.push_back(std::move(control_ptr));
281 base::insert_at(index, control_ref);
282 }
283 }
284
285 template<typename control_t>
286 void push_back(control_t& value) {
287 for (auto it = begin(); it != end(); ++it)
288 if (it->get() == value) return;
289 if (!keep_cloned_controls_) base::push_back(value);
290 else {
291 auto control_ptr = as<control>(as<iclonable>(value).clone());
292 auto& control_ref = *control_ptr;
293 controls_.push_back(std::move(control_ptr));
294 base::push_back(control_ref);
295 }
296 }
297
299
300 protected:
302
304 void on_item_removed(size_t index, control_ref& item) override {
306 for (auto iterator = controls_.begin(); iterator != controls_.end(); ++iterator) {
307 if (iterator->get() != &item.get()) continue;
308 controls_.erase(iterator);
309 break;
310 }
311 }
313
314 private:
317
318 bool keep_cloned_controls_ = false;
319 static std::vector<xtd::uptr<xtd::forms::control>> controls_;
320 };
321
323
332 explicit control(const xtd::string& text);
338 control(const control& parent, const xtd::string& text);
347 control(const xtd::string& text, int32 left, int32 top, int32 width, int32 height);
357 control(const control& parent, const xtd::string& text, int32 left, int32 top, int32 width, int32 height);
359
361 control(control&& rhs);
362 control(const control&) = default;
363 control& operator =(const control&) = default;
364 ~control();
366
368
377 virtual anchor_styles anchor() const noexcept;
387 virtual control& anchor(xtd::forms::anchor_styles anchor);
388
391 virtual drawing::point auto_scroll_point() const noexcept;
392
396 virtual bool auto_size() const noexcept;
401 virtual control& auto_size(bool auto_size);
402
407 virtual drawing::color back_color() const noexcept;
415 virtual control& back_color(const xtd::drawing::color& color);
417 virtual control& back_color(std::nullptr_t);
419
423 virtual const xtd::drawing::image& background_image() const noexcept;
428 virtual control& background_image(const xtd::drawing::image& background_image);
429
434 virtual xtd::forms::image_layout background_image_layout() const noexcept;
435
441 virtual control& background_image_layout(xtd::forms::image_layout background_image_layout);
442
447 virtual int32 bottom() const noexcept;
448
452 virtual drawing::rectangle bounds() const noexcept;
457 virtual control& bounds(const xtd::drawing::rectangle& bounds);
458
462 virtual bool can_focus() const noexcept;
463
475 virtual bool can_select() const noexcept;
476
479 bool can_raise_events() const noexcept override;
480
485 virtual const drawing::rectangle& client_rectangle() const noexcept;
486
490 virtual const drawing::size& client_size() const noexcept;
495 virtual control& client_size(const xtd::drawing::size& client_size);
496
499 virtual xtd::string company_name() const noexcept;
500
503 virtual std::optional<context_menu_ref> context_menu() const noexcept;
511 virtual control& context_menu(std::nullptr_t);
512
518 virtual forms::control_appearance control_appearance() const noexcept;
525
532 virtual control_collection& controls() noexcept;
539 virtual const control_collection& controls() const noexcept;
540
544 virtual bool created() const noexcept;
545
549 virtual forms::cursor cursor() const noexcept;
554 virtual control& cursor(const xtd::forms::cursor& cursor);
556 virtual control& cursor(std::nullptr_t);
558
561 virtual drawing::rectangle display_rectangle() const noexcept;
562
571 virtual dock_style dock() const noexcept;
581 virtual control& dock(xtd::forms::dock_style dock);
582
585 virtual bool double_buffered() const noexcept;
589 virtual control& double_buffered(bool double_buffered);
590
593 virtual bool enabled() const noexcept;
597 virtual control& enabled(bool enabled);
598
601 virtual bool focused() const noexcept;
602
606 virtual drawing::font font() const noexcept;
611 virtual control& font(const xtd::drawing::font& font);
613 virtual control& font(std::nullptr_t);
615
619 virtual drawing::color fore_color() const noexcept;
624 virtual control& fore_color(const xtd::drawing::color& color);
626 virtual control& fore_color(std::nullptr_t);
628
632 intptr handle() const override;
633
636 virtual int32 height() const noexcept;
640 virtual control& height(int32 height);
641
644 bool invoke_required() const noexcept override;
645
649 bool is_handle_created() const noexcept;
650
653 virtual int32 left() const noexcept;
657 virtual control& left(int32 left);
658
661 virtual drawing::point location() const noexcept;
665 virtual control& location(const xtd::drawing::point& location);
666
669 virtual forms::padding margin() const noexcept;
673 virtual control& margin(const xtd::forms::padding& margin);
674
680 virtual const drawing::size& maximum_client_size() const noexcept;
686 virtual control& maximum_client_size(const xtd::drawing::size& size);
687
693 virtual const drawing::size& maximum_size() const noexcept;
699 virtual control& maximum_size(const xtd::drawing::size& size);
700
706 virtual const drawing::size& minimum_client_size() const noexcept;
712 virtual control& minimum_client_size(const xtd::drawing::size& size);
713
719 virtual const drawing::size& minimum_size() const noexcept;
725 virtual control& minimum_size(const xtd::drawing::size& size);
726
730 intptr native_handle() const noexcept;
731
734 virtual const xtd::string& name() const noexcept;
738 virtual control& name(const xtd::string& name);
739
742 virtual forms::padding padding() const noexcept;
747
750 virtual std::optional<control_ref> parent() const noexcept;
754 virtual control& parent(const control& parent);
758 virtual control& parent(std::nullptr_t);
759
762 virtual xtd::string product_name() const noexcept;
763
766 bool recreating_handle() const noexcept;
767
772 virtual const xtd::drawing::region& region() const noexcept;
778 virtual control& region(const xtd::drawing::region& value);
779
782 virtual int32 right() const noexcept;
783
799 virtual xtd::forms::right_to_left right_to_left() const noexcept;
818 virtual control& right_to_left(std::nullptr_t);
820
823 virtual drawing::size size() const noexcept;
827 virtual control& size(const drawing::size& size);
828
832 virtual style_sheets::style_sheet style_sheet() const noexcept;
836 virtual control& style_sheet(const style_sheets::style_sheet& value);
841 virtual control& style_sheet(const xtd::string& value);
846 virtual control& style_sheet(std::nullptr_t);
847
852 virtual bool tab_stop() const noexcept;
858 virtual control& tab_stop(bool value);
859
864 virtual std::any tag() const noexcept;
870 virtual control& tag(std::any tag);
871
874 virtual const xtd::string& text() const noexcept;
878 virtual control& text(const xtd::string& text);
879
883 intptr toolkit_handle() const noexcept;
884
887 virtual int32 top() const noexcept;
891 virtual control& top(int32 top);
892
895 virtual std::optional<control_ref> top_level_control() const noexcept;
896
899 virtual bool visible() const noexcept;
903 virtual control& visible(bool visible);
904
907 virtual int32 width() const noexcept;
911 virtual control& width(int32 width);
913
915
921 static bool check_for_illegal_cross_thread_calls() noexcept;
926 static void check_for_illegal_cross_thread_calls(bool value);
927
930 static forms::keys modifier_keys() noexcept;
931
935
940 static xtd::drawing::point mouse_position() noexcept;
942
944
946 using isynchronize_invoke::begin_invoke;
950 xtd::async_result begin_invoke(delegate<void()> method) override;
951
956 xtd::async_result begin_invoke(delegate<void(std::vector<std::any>)> method, const std::vector<std::any>& args) override;
957
960 virtual void bring_to_front();
961
962 int32 compare_to(const control& value) const noexcept override;
963
967 void create_control();
968
972 drawing::graphics create_graphics() const;
973
978 virtual void destroy_control();
979
982 std::optional<object_ref> end_invoke(xtd::async_result async) override;
983
984 using object::equals;
985 bool equals(const control& value) const noexcept override;
986
990 bool focus();
991
994 auto_size_mode get_auto_size_mode() const;
995
998 std::optional<xtd::drawing::color> get_back_color() const noexcept;
1000
1003 std::optional<xtd::drawing::font> get_font() const noexcept;
1005
1008 std::optional<xtd::drawing::color> get_fore_color() const noexcept;
1010
1015 size_t get_child_index(intptr child) const;
1016
1020 size_t get_child_index(intptr child, bool& throw_exception) const;
1021
1024 virtual void hide();
1025
1028 virtual void invalidate() const;
1029
1033 virtual void invalidate(bool invalidate_children) const;
1034
1038 virtual void invalidate(const drawing::rectangle& rect) const;
1039
1044 virtual void invalidate(const drawing::rectangle& rect, bool invalidate_children) const;
1045
1049 virtual void invalidate(const drawing::region& region) const;
1050
1055 virtual void invalidate(const drawing::region& region, bool invalidate_children) const;
1056
1057 using isynchronize_invoke::invoke;
1060 std::optional<object_ref> invoke(delegate<void()> method) override;
1064 std::optional<object_ref> invoke(delegate<void(std::vector<std::any>)> method, const std::vector<std::any>& args) override;
1068 std::optional<object_ref> invoke(delegate<void(std::vector<std::any>)> method, std::any arg) override;
1069
1072 void perform_layout();
1073
1077 xtd::drawing::point point_to_client(const xtd::drawing::point& p) const;
1078
1082 xtd::drawing::point point_to_screen(const xtd::drawing::point& p) const;
1083
1090 bool post_message(intptr hwnd, int32 msg, intptr wparam, intptr lparam) const;
1091
1096 virtual bool pre_process_message(const xtd::forms::message& message);
1097
1101 virtual void refresh() const;
1102
1107 void resume_layout();
1108
1115 void resume_layout(bool perform_layout);
1116
1123 intptr send_message(intptr hwnd, int32 msg, intptr wparam, intptr lparam) const;
1124
1127 void set_auto_size_mode(auto_size_mode auto_size_mode);
1128
1134 void set_bounds(int32 x, int32 y, int32 width, int32 height);
1135
1142 void set_bounds(int32 x, int32 y, int32 width, int32 height, bounds_specified specified);
1143
1146 virtual void show();
1147
1153 void suspend_layout();
1154
1157 xtd::string to_string() const noexcept override;
1158
1165 virtual void update() const;
1167
1169
1175 control& operator <<(control& child);
1176
1181 control& operator >>(control& child);
1183
1185
1189 static control create();
1193 static control create(const drawing::point& location);
1198 static control create(const drawing::point& location, const drawing::size& size);
1204 static control create(const drawing::point& location, const drawing::size& size, const xtd::string& name);
1208 static control create(const control& paren);
1215 static control create(const control& parent, const drawing::point& location);
1221 static control create(const control& parent, const drawing::point& location, const drawing::size& size);
1228 static control create(const control& parent, const drawing::point& location, const drawing::size& size, const xtd::string& name);
1231 template<typename control_t>
1232 static control_t create() {
1233 auto result = control_t {};
1234 return result;
1235 }
1239 template<typename control_t>
1240 static control_t create(const drawing::point& location) {
1241 auto result = control_t {};
1242 result.location(location);
1243 return result;
1244 }
1249 template<typename control_t>
1250 static control_t create(const drawing::point& location, const drawing::size& size) {
1251 auto result = control_t {};
1252 result.location(location);
1253 result.size(size);
1254 return result;
1255 }
1261 template<typename control_t>
1262 static control_t create(const drawing::point& location, const drawing::size& size, const xtd::string& name) {
1263 auto result = control_t {};
1264 result.location(location);
1265 result.size(size);
1266 result.name(name);
1267 return result;
1268 }
1272 template<typename control_t>
1273 static control_t create(const control& parent) {
1274 auto result = control_t {};
1275 result.parent(parent);
1276 return result;
1277 }
1282 template<typename control_t>
1283 static control_t create(const control& parent, const drawing::point& location) {
1284 auto result = control_t {};
1285 result.parent(parent);
1286 result.location(location);
1287 return result;
1288 }
1294 template<typename control_t>
1295 static control_t create(const control& parent, const drawing::point& location, const drawing::size& size) {
1296 auto result = control_t {};
1297 result.parent(parent);
1298 result.location(location);
1299 result.size(size);
1300 return result;
1301 }
1308 template<typename control_t>
1309 static control_t create(const control& parent, const drawing::point& location, const drawing::size& size, const xtd::string& name) {
1310 auto result = control_t {};
1311 result.parent(parent);
1312 result.location(location);
1313 result.size(size);
1314 result.name(name);
1315 return result;
1316 }
1320 template<typename control_t>
1321 static control_t create(const xtd::string& text) {
1322 auto result = control_t {};
1323 result.text(text);
1324 return result;
1325 }
1330 template<typename control_t>
1331 static control_t create(const xtd::string& text, const drawing::point& location) {
1332 auto result = control_t {};
1333 result.text(text);
1334 result.location(location);
1335 return result;
1336 }
1342 template<typename control_t>
1343 static control_t create(const xtd::string& text, const drawing::point& location, const drawing::size& size) {
1344 auto result = control_t {};
1345 result.text(text);
1346 result.location(location);
1347 result.size(size);
1348 return result;
1349 }
1356 template<typename control_t>
1357 static control_t create(const xtd::string& text, const drawing::point& location, const drawing::size& size, const xtd::string& name) {
1358 auto result = control_t {};
1359 result.text(text);
1360 result.location(location);
1361 result.size(size);
1362 result.name(name);
1363 return result;
1364 }
1369 template<typename control_t>
1370 static control_t create(const control& parent, const xtd::string& text) {
1371 auto result = control_t {};
1372 result.parent(parent);
1373 result.text(text);
1374 return result;
1375 }
1381 template<typename control_t>
1382 static control_t create(const control& parent, const xtd::string& text, const drawing::point& location) {
1383 auto result = control_t {};
1384 result.parent(parent);
1385 result.text(text);
1386 result.location(location);
1387 return result;
1388 }
1395 template<typename control_t>
1396 static control_t create(const control& parent, const xtd::string& text, const drawing::point& location, const drawing::size& size) {
1397 auto result = control_t {};
1398 result.parent(parent);
1399 result.text(text);
1400 result.location(location);
1401 result.size(size);
1402 return result;
1403 }
1411 template<typename control_t>
1412 static control_t create(const control& parent, const xtd::string& text, const drawing::point& location, const drawing::size& size, const xtd::string& name) {
1413 auto result = control_t {};
1414 result.parent(parent);
1415 result.text(text);
1416 result.location(location);
1417 result.size(size);
1418 result.name(name);
1419 return result;
1420 }
1421
1426 static std::optional<control_ref> from_child_handle(intptr handle);
1427
1431 static std::optional<control_ref> from_handle(intptr handle);
1433
1435
1441
1446
1451
1456
1461
1486
1491
1496
1500
1504
1509
1533
1554
1559
1564
1569
1574
1579
1584
1596
1610
1622
1627
1632
1654
1670
1690
1704
1718
1733
1747
1761
1775
1790
1794
1803
1808
1813
1822
1827
1832
1837
1842
1847
1852
1858
1859 protected:
1860 friend class application;
1861 friend class context_menu;
1862 friend class horizontal_layout_panel;
1863 friend class paint_event_args;
1864 friend class screen;
1865 friend class vertical_layout_panel;
1866 friend class style_sheets::style_sheet;
1867
1869
1874
1880 virtual forms::create_params create_params() const noexcept;
1881
1885 virtual drawing::color default_back_color() const noexcept;
1886
1889 virtual forms::cursor default_cursor() const noexcept;
1890
1893 virtual drawing::font default_font() const noexcept;
1894
1897 virtual drawing::color default_fore_color() const noexcept;
1898
1901 virtual drawing::size default_size() const noexcept;
1903
1905
1911 xtd::uptr<xtd::object> clone() const override;
1912
1917 virtual void create_handle();
1918
1922 virtual void destroy_handle();
1923
1926 virtual void def_wnd_proc(message& message);
1927
1932 bool get_style(control_styles flag) const noexcept;
1933
1936 virtual drawing::size measure_control() const noexcept;
1937
1940 drawing::size measure_text() const noexcept;
1941
1944 virtual void on_auto_size_changed(const event_args& e);
1945
1948 virtual void on_back_color_changed(const event_args& e);
1949
1952 virtual void on_background_image_changed(const event_args& e);
1953
1956 virtual void on_background_image_layout_changed(const event_args& e);
1957
1960 virtual void on_control_appearance_changed(const event_args& e);
1961
1964 virtual void on_click(const event_args& e);
1965
1968 virtual void on_client_size_changed(const event_args& e);
1969
1972 virtual void on_control_added(const control_event_args& e);
1973
1976 virtual void on_control_removed(const control_event_args& e);
1977
1980 virtual void on_create_control();
1981
1984 virtual void on_cursor_changed(const event_args& e);
1985
1988 virtual void on_destroy_control();
1989
1992 virtual void on_dock_changed(const event_args& e);
1993
1996 virtual void on_double_click(const event_args& e);
1997
2000 virtual void on_enabled_changed(const event_args& e);
2001
2004 virtual void on_fore_color_changed(const event_args& e);
2005
2008 virtual void on_font_changed(const event_args& e);
2009
2012 virtual void on_got_focus(const event_args& e);
2013
2016 virtual void on_handle_created(const event_args& e);
2017
2020 virtual void on_handle_destroyed(const event_args& e);
2021
2024 virtual void on_help_requested(help_event_args& e);
2025
2028 virtual void on_key_down(key_event_args& e);
2029
2032 virtual void on_key_press(key_press_event_args& e);
2033
2036 virtual void on_key_up(key_event_args& e);
2037
2040 virtual void on_layout(const event_args& e);
2041
2044 virtual void on_location_changed(const event_args& e);
2045
2048 virtual void on_lost_focus(const event_args& e);
2049
2052 virtual void on_mouse_click(const mouse_event_args& e);
2053
2056 virtual void on_mouse_double_click(const mouse_event_args& e);
2057
2060 virtual void on_mouse_down(const mouse_event_args& e);
2061
2064 virtual void on_mouse_enter(const event_args& e);
2065
2068 virtual void on_mouse_horizontal_wheel(const mouse_event_args& e);
2069
2072 virtual void on_mouse_leave(const event_args& e);
2073
2076 virtual void on_mouse_move(const mouse_event_args& e);
2077
2080 virtual void on_mouse_up(const mouse_event_args& e);
2081
2084 virtual void on_mouse_wheel(const mouse_event_args& e);
2085
2088 virtual void on_move(const event_args& e);
2089
2092 virtual void on_paint(paint_event_args& e);
2093
2097 virtual void on_paint_background(paint_event_args& e);
2098
2101 virtual void on_parent_back_color_changed(const event_args& e);
2102
2105 virtual void on_parent_cursor_changed(const event_args& e);
2106
2109 virtual void on_parent_changed(const event_args& e);
2110
2113 virtual void on_parent_enabled_changed(const event_args& e);
2114
2117 virtual void on_parent_fore_color_changed(const event_args& e);
2118
2121 virtual void on_parent_font_changed(const event_args& e);
2122
2125 virtual void on_resize(const event_args& e);
2126
2129 virtual void on_region_changed(const event_args& e);
2130
2133 virtual void on_right_to_left_changed(const event_args& e);
2134
2137 virtual void on_size_changed(const event_args& e);
2138
2141 virtual void on_style_sheet_changed(const event_args& e);
2142
2145 virtual void on_system_colors_changed(const event_args& e);
2146
2149 virtual void on_tab_stop_changed(const event_args& e);
2150
2153 virtual void on_text_changed(const event_args& e);
2154
2157 virtual void on_visible_changed(const event_args& e);
2158
2159 void post_recreate_handle() noexcept;
2160
2163 virtual void recreate_handle();
2164
2175 virtual void set_bounds_core(int32 x, int32 y, int32 width, int32 height, bounds_specified specified);
2176
2180 void set_can_focus(bool value);
2181
2185 virtual void set_text(const xtd::string& text);
2186
2194 virtual void set_client_size_core(int32 width, int32 height);
2195
2198 void set_parent(intptr handle);
2199
2205 void set_style(control_styles flag, bool value);
2206
2212 virtual void wnd_proc(message& m);
2214
2216
2220 static void set_mouse_buttons(forms::mouse_buttons value);
2222
2224 bool get_state(control::state flag) const noexcept;
2225 void set_state(control::state flag, bool value);
2226 bool on_context_menu_item_click(xtd::forms::context_menu& menu, intptr menu_id) const;
2228
2229 private:
2230 void do_layout_children_with_dock_style();
2231 void do_layout_with_auto_size_mode();
2232 void do_layout_with_anchor_styles();
2233 static bool is_trace_form_or_control(const string& name);
2234 void on_controls_item_added(size_t, control_ref item);
2235 void on_controls_item_removed(size_t, control_ref item);
2236 void on_parent_size_changed(object& sender, const event_args& e);
2237 void show_context_menu(xtd::forms::context_menu& menu, const xtd::drawing::point& pos) const;
2238 void reflect_message(intptr handle, message& message);
2239 intptr wnd_proc_(intptr hwnd, int32 msg, intptr wparam, intptr lparam, intptr handle);
2240 void wm_app_idle(message& message);
2241 void wm_child_activate(message& message);
2242 void wm_command(message& message);
2243 void wm_command_control(message& message);
2244 void wm_ctlcolor(message& message);
2245 void wm_ctlcolor_control(message& message);
2246 void wm_create(message& message);
2247 void wm_destroy(message& message);
2248 void wm_key_char(message& message);
2249 void wm_kill_focus(message& message);
2250 void wm_menu_command(message& message);
2251 void wm_mouse_down(message& message);
2252 void wm_mouse_double_click(message& message);
2253 void wm_mouse_enter(message& message);
2254 void wm_mouse_leave(message& message);
2255 void wm_mouse_up(message& message);
2256 void wm_mouse_move(message& message);
2257 void wm_move(message& message);
2258 void wm_mouse_wheel(message& message);
2259 void wm_notify(message& message);
2260 void wm_notify_control(message& message);
2261 void wm_paint(message& message);
2262 void wm_erase_background(message& message);
2263 void wm_help(message& message);
2264 void wm_scroll(message& message);
2265 void wm_scroll_control(message& message);
2266 void wm_set_focus(message& message);
2267 void wm_set_text(message& message);
2268 void wm_show(message& message);
2269 void wm_size(message& message);
2270 void wm_sizing(message& message);
2271 void wm_style_sheet_changed(message& message);
2272
2273 static bool check_for_illegal_cross_thread_calls_;
2274 static forms::keys modifier_keys_;
2275 static forms::mouse_buttons mouse_buttons_;
2276 static std::map<intptr, control*> handles_;
2277 static control_collection top_level_controls_;
2278
2279 xtd::sptr<data> data_;
2280 };
2281 }
2282}
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 text as a sequence of character units.
Definition basic_string.hpp:79
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition point.hpp:54
Stores an ordered pair of integers, which specify a height and width.
Definition size.hpp:31
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.hpp:18
Represents an event.
Definition event.hpp:21
Provides static methods and properties to manage an application, such as methods to start and stop an...
Definition application.hpp:51
Provides the base implementation and enables object sharing between applications.
Definition component.hpp:25
Represents a shortcut menu.
Definition context_menu.hpp:36
Represents a collection of controls.
Definition control.hpp:152
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.hpp:230
control_t & emplace(const_iterator pos, args_t &&...args)
Creates and inserts specified control at specified position.
Definition control.hpp:212
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.hpp:247
void on_item_removed(size_t index, control_ref &item) override
Raises the xtd::forms::layout::arranged_element_collection::item_removed event.
Definition control.hpp:304
control_collection(bool keep_cloned_controls, const allocator_type &allocator=allocator_type())
Creates a new object xtd::forms::control::control_collection with specified keep_cloned_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.hpp:27
Defines the base class for controls, which are components with visual representation.
Definition control.hpp:81
control(const control &parent, const xtd::string &text)
Initializes a new instance of the xtd::forms::control class as a child control, with specific text.
event< control, event_handler > parent_changed
Occurs when the value of the xtd::forms::control::parent property changes.
Definition control.hpp:1807
event< control, help_event_handler > help_requested
Occurs when the user requests help for a xtd::forms::control.
Definition control.hpp:1583
static control_t create(const xtd::string &text, const drawing::point &location, const drawing::size &size, const xtd::string &name)
A factory to create a specified control with specified text, location,size, and name.
Definition control.hpp:1357
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.hpp:1295
event< control, event_handler > dock_changed
Occurs when the value of the xtd::forms::control::dock property changes.
Definition control.hpp:1508
event< control, event_handler > move
Occurs when the control is moved.
Definition control.hpp:1793
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.hpp:1836
event< control, event_handler > background_image_changed
Occurs when the value of the xtd::forms::control::background_image property changes.
Definition control.hpp:1450
event< control, event_handler > client_size_changed
Occurs when the value of the xtd::forms::control::client_size property changes.
Definition control.hpp:1490
event< control, event_handler > system_colors_changed
Occurs when the xtd::drwing::system_colors changes.
Definition control.hpp:1841
event< control, event_handler > tab_stop_changed
Occurs when the xtd::forms::control::tab_stop property value changes.
Definition control.hpp:1846
event< control, key_event_handler > key_up
Occurs when a key is released while the xtd::forms::control has focus.
Definition control.hpp:1621
static control_t create(const xtd::string &text, const drawing::point &location, const drawing::size &size)
A factory to create a specified control with specified text, location, and size.
Definition control.hpp:1343
std::reference_wrapper< xtd::forms::context_menu > context_menu_ref
Represent an xtd::forms::context_menu reference.
Definition control.hpp:148
event< control, event_handler > enabled_changed
Occurs when the value of the xtd::forms::control::enabled property changes.
Definition control.hpp:1568
event< control, event_handler > visible_changed
Occurs when the value of the xtd::forms::control::visible property changes.
Definition control.hpp:1856
static std::optional< control_ref > from_child_handle(intptr handle)
Retrieves the control that contains the specified handle.
control(const xtd::string &text)
Initializes a new instance of the xtd::forms::control class with specific text.
event< control, event_handler > text_changed
Occurs when the value of the xtd::forms::control::text property changes.
Definition control.hpp:1851
event< control, event_handler > layout
Occurs when a xtd::forms::control should reposition its child controls.
Definition control.hpp:1626
event< control, event_handler > font_changed
Occurs when the value of the xtd::forms::control::font property changes.
Definition control.hpp:1578
event< control, event_handler > double_click
Occurs when the xtd::forms::control is double-clicked.
Definition control.hpp:1532
event< control, event_handler > click
Occurs when the xtd::forms::control is clicked.
Definition control.hpp:1485
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.hpp:1609
static control_t create(const control &parent, const xtd::string &text)
A factory to create a specified control with specified parent, and text.
Definition control.hpp:1370
event< control, event_handler > handle_created
Occurs when a handle is created for the xtd::forms::control.
Definition control.hpp:1558
event< control, event_handler > handle_destroyed
Occurs when the control's handle is in the process of being destroyed.
Definition control.hpp:1563
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.hpp:1503
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.hpp:1703
static control_t create(const control &parent, const xtd::string &text, const drawing::point &location)
A factory to create a specified control with specified parent, text, and location.
Definition control.hpp:1382
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.hpp:1717
event< control, event_handler > auto_size_changed
Occurs when the value of the xtd::forms::control::auto_size property changes.
Definition control.hpp:1440
event< control, mouse_event_handler > mouse_double_click
Occurs when the xtd::forms::control is double clicked by the mouse.
Definition control.hpp:1689
static control_t create(const xtd::string &text)
A factory to create a specified control with specified text.
Definition control.hpp:1321
event< control, paint_event_handler > paint
Occurs when the xtd::forms::control is redrawn.
Definition control.hpp:1802
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.hpp:1250
event< control, event_handler > lost_focus
Occurs when the xtd::forms::control loses focus.
Definition control.hpp:1653
static control_t create(const control &parent, const xtd::string &text, const drawing::point &location, const drawing::size &size, const xtd::string &name)
A factory to create a specified control with specified parent, text, location, size,...
Definition control.hpp:1412
event< control, event_handler > background_image_layout_changed
Occurs when the value of the xtd::forms::control::background_image_layout property changes.
Definition control.hpp:1455
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.hpp:1283
event< control, event_handler > region_changed
Occurs when the value of the xtd::forms::control::region property changes.
Definition control.hpp:1812
event< control, event_handler > mouse_leave
Occurs when the mouse pointer leaves the xtd::forms::control.
Definition control.hpp:1746
event< control, mouse_event_handler > mouse_move
Occurs when the mouse pointer is moved over the xtd::forms::control.
Definition control.hpp:1760
event< control, event_handler > right_to_left_changed
Occurs when the value of the xtd::forms::control::right_to_left property changes.
Definition control.hpp:1826
static control_t create(const control &parent, const xtd::string &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.hpp:1396
static control_t create(const drawing::point &location, const drawing::size &size, const xtd::string &name)
A factory to create a specified control with specified location, size, and name.
Definition control.hpp:1262
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.hpp:1460
control(const control &parent, const xtd::string &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, key_event_handler > key_down
Occurs when a key is pressed while the xtd::forms::control has focus.
Definition control.hpp:1595
event< control, event_handler > got_focus
Occurs when the xtd::forms::control receives focus.
Definition control.hpp:1553
event< control, event_handler > location_changed
Occurs when the value of the xtd::forms::control::location property changes.
Definition control.hpp:1631
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.hpp:1774
event< control, mouse_event_handler > mouse_horizontal_wheel
Occurs when the mouse horizontal wheel moves while the xtd::forms::control has focus.
Definition control.hpp:1732
static control_t create(const control &parent)
A factory to create a specified control with specified parent.
Definition control.hpp:1273
event< control, mouse_event_handler > mouse_wheel
Occurs when the mouse wheel moves while the xtd::forms::control has focus.
Definition control.hpp:1789
control(const xtd::string &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 drawing::point &location)
A factory to create a specified control with specified location.
Definition control.hpp:1240
static control_t create(const control &parent, const drawing::point &location, const drawing::size &size, const xtd::string &name)
A factory to create a specified control with specified parent, location, size, and name.
Definition control.hpp:1309
event< control, event_handler > back_color_changed
Occurs when the value of the xtd::forms::control::back_color property changes.
Definition control.hpp:1445
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.hpp:1499
event< control, event_handler > fore_color_changed
Occurs when the value of the xtd::forms::control::fore_color property changes.
Definition control.hpp:1573
event< control, event_handler > resize
Occurs when the xtd::forms::control is resized.
Definition control.hpp:1821
event< control, event_handler > cursor_changed
Occurs when the value of the xtd::forms::control::cursor property changes.
Definition control.hpp:1495
static std::optional< control_ref > from_handle(intptr handle)
Returns the control that is currently associated with the specified handle.
static control_t create(const xtd::string &text, const drawing::point &location)
A factory to create a specified control with specified text, and location.
Definition control.hpp:1331
event< control, mouse_event_handler > mouse_click
Occurs when the xtd::forms::control is clicked by the mouse.
Definition control.hpp:1669
event< control, event_handler > size_changed
Occurs when the value of the xtd::forms::control::size property changes.
Definition control.hpp:1831
Encapsulates the information needed when creating a control.
Definition create_params.hpp:29
Represents the image used to paint the mouse pointer.
Definition cursor.hpp:40
Provides data for the xtd::forms::control::control_added and xtd::forms::control::control_removed eve...
Definition help_event_args.hpp:26
Used to group collections of horizontally aligned controls.
Definition horizontal_layout_panel.hpp:30
Provides an interface to expose Win32 HWND handles.
Definition iwin32_window.hpp:23
Provides data for the xtd::forms::control::key_down or xtd::forms::control::key_up event.
Definition key_event_args.hpp:25
Provides data for the xtd::forms::control::key_press event.
Definition key_press_event_args.hpp:26
Represents a collection of objects.
Definition arranged_element_collection.hpp:34
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.hpp:497
typename std::vector< value_type >::iterator iterator
Represents the iterator type of the collection.
Definition arranged_element_collection.hpp:85
std::allocator< value_type > allocator_type
Represents the allocator type of the collection.
Definition arranged_element_collection.hpp:71
typename std::vector< value_type >::const_iterator const_iterator
Represents the const iterator type of the collection.
Definition arranged_element_collection.hpp:87
Represents the base functionality for all menus. Although tool_strip_drop_down and tool_strip_drop_do...
Definition menu.hpp:37
Implements a Windows message.
Definition message.hpp:28
Provides data for the xtd::forms::control::mouse_up, xtd::forms::control::mouse_down,...
Definition mouse_event_args.hpp:34
Represents a display device or multiple display devices on a single system.
Definition padding.hpp:25
Provides data for the xtd::forms::control::paint event.
Definition paint_event_args.hpp:30
Represents a display device or multiple display devices on a single system.
Definition screen.hpp:32
The xtd::forms::style_sheets::style_sheet allows you to specify an xtd style sheet.
Definition style_sheet.hpp:64
Creates a use wait cursor class.
Definition use_wait_cursor.hpp:25
Used to group collections of vertically aligned controls.
Definition vertical_layout_panel.hpp:31
Represents the status of an asynchronous operation.
Definition iasync_result.hpp:25
Supports cloning, which creates a new instance of a class with the same value as an existing instance...
Definition iclonable.hpp:21
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.hpp:21
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
Provides a way to synchronously or asynchronously execute a delegate.
Definition isynchronize_invoke.hpp:26
Encapsulates operating system specific objects that wait for exclusive access to shared resources.
Definition wait_handle.hpp:52
Contains xtd::forms::component class.
Contains xtd::forms::const_control_ref typedef.
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::dock_style enum class.
#define forms_export_
Define shared library export.
Definition forms_export.hpp:13
std::optional< type_t > optional
Represents the null_opt alias on std::nullopt_t.
Definition optional.hpp:181
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
int64_t int64
Represents a 64-bit signed integer.
Definition int64.hpp:23
std::unique_ptr< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.hpp:25
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
intmax_t intptr
Represent a pointer or a handle.
Definition intptr.hpp:23
std::shared_ptr< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
xtd::sptr< xtd::iasync_result > async_result
Represents the status of an asynchronous operation.
Definition async_result.hpp:19
std::reference_wrapper< object > object_ref
Represents an object reference.
Definition object_ref.hpp:20
@ end
The END key.
@ insert
The INS (INSERT) key.
keys
Specifies key codes and modifiers.
Definition keys.hpp:77
bounds_specified
Specifies the bounds of the control to use when defining a control's size and position....
Definition bounds_specified.hpp:22
image_layout
Specifies the position of the image on the control.
Definition image_layout.hpp:21
control_appearance
Specifies the appearance of a control.
Definition control_appearance.hpp:21
control_state
Specifies the visual state of a control that is drawn with visual styles.
Definition control_state.hpp:24
control_styles
Specifies the style and behavior of a control.
Definition control_styles.hpp:33
auto_size_mode
Specifies how a control will behave when its auto_size property is enabled.
Definition auto_size_mode.hpp:22
dock_style
Specifies the position and manner in which a control is docked.
Definition dock_style.hpp:23
anchor_styles
Specifies how a control anchors to the edges of its container.
Definition anchor_styles.hpp: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.hpp:24
mouse_buttons
Specifies constants that define which mouse button was pressed. This enumeration has a flag attribute...
Definition mouse_buttons.hpp:22
std::reference_wrapper< control > control_ref
Represents a control reference.
Definition control_ref.hpp:25
@ 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.hpp:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp: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::context_menu menu.
Contains xtd::forms::create_params class.
Contains xtd::forms::cursors factory.
Contains xtd::forms::timer component.