xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
control.h
Go to the documentation of this file.
1 #pragma once
5 #include <any>
6 #include <condition_variable>
7 #include <cstdint>
8 #include <functional>
9 #include <map>
10 #include <memory>
11 #include <optional>
12 #include <string>
13 #include <thread>
14 #include <vector>
15 #include <xtd/iasync_result.h>
16 #include <xtd/drawing/color.h>
17 #include <xtd/drawing/font.h>
18 #include <xtd/drawing/point.h>
19 #include <xtd/drawing/rectangle.h>
20 #include <xtd/drawing/size.h>
21 #include <xtd/forms/create_params.h>
22 
23 #include "../forms_export.h"
25 #include "anchor_styles.h"
26 #include "auto_size_mode.h"
27 #include "bounds_specified.h"
28 #include "component.h"
29 #include "context_menu.h"
30 #include "control_appearance.h"
31 #include "control_event_handler.h"
32 #include "control_ref.h"
33 #include "control_styles.h"
34 #include "cursors.h"
35 #include "dock_style.h"
36 #include "help_event_handler.h"
37 #include "image_layout.h"
38 #include "iwin32_window.h"
39 #include "key_event_handler.h"
41 #include "mouse_event_handler.h"
42 #include "padding.h"
43 #include "paint_event_handler.h"
44 #include "message.h"
45 #include "theme_colors.h"
46 #include "timer.h"
49 
51 namespace xtd {
53  namespace forms {
55  class application;
56  class context_menu;
57  class screen;
59 
73  class forms_export_ control : public component, public iwin32_window {
74  protected:
76  enum class state {
77  empty = 0,
78  creating = 0b1,
79  created = 0b10,
80  destroying = 0b100,
81  destroyed = 0b1000,
82  creating_handle = 0b10000,
83  recreate = 0b100000,
84  parent_recreating = 0b1000000,
85 
86  client_size_setted = 0b10000000,
87  modal = 0b100000000,
88  top_level = 0b1000000000,
89  visible = 0b10000000000,
90  enabled = 0b100000000000,
91  auto_size = 0b1000000000000,
92  tab_stop = 0b10000000000000,
93  allow_drop = 0b100000000000000,
94  drop_target = 0b1000000000000000,
95 
96  layout_deferred = 0b10000000000000000,
97  docked = 0b100000000000000000,
98 
99  double_click_fired = 0b1000000000000000000,
100  double_buffered = 0b10000000000000000000,
101  /*
102  mouse_enter_pending = 0,
103  tracking_mouse_event = 0,
104  mouse_pressed = 0,
105  use_wait_cursor = 0,
106  */
107 
108  /*
109  is_accessible = 0,
110  no_zorder = 0,
111  size_locked_by_os = 0,
112  causes_validation = 0,
113  own_ctl_brush = 0,
114  exception_while_painting = 0,
115  layout_sis_dirty = 0,
116  checked_host = 0,
117  hosted_in_dialog = 0,
118  validation_cancelled = 0,
119  mirrored = 0,
120  */
121  };
122 
123  class async_result_invoke : public xtd::iasync_result {
124  public:
125  explicit async_result_invoke(std::any async_state) : async_state_(async_state) {}
126  std::any async_state() const noexcept override {return async_state_;}
127  std::shared_mutex& async_mutex() override {return *async_mutex_;}
128  bool completed_synchronously() const noexcept override {return false;}
129  bool is_completed() const noexcept override {return *is_completed_;};
130 
131  std::any async_state_;
132  std::shared_ptr<bool> is_completed_ = std::make_shared<bool>(false);
133  std::shared_ptr<std::shared_mutex> async_mutex_ = std::make_shared<std::shared_mutex>();
134  };
136 
137  public:
140  public:
142 
147 
149 
154  explicit control_collection(const allocator_type& allocator = allocator_type());
156 
158  explicit control_collection(const base& collection);
159  control_collection(const control_collection& collection);
160  control_collection& operator=(const control_collection& collection);
163 
165 
167  using base::operator[];
172  std::optional<value_type> operator[](const xtd::ustring& name) const;
177  std::optional<value_type> operator[](const xtd::ustring& name);
179  };
180 
182 
186  control();
191  explicit control(const xtd::ustring& text) : control() {
192  this->text(text);
193  }
199  explicit control(const control& parent, const xtd::ustring& text) : control() {
200  this->parent(parent);
201  this->text(text);
202  }
211  explicit control(const xtd::ustring& text, int32_t left, int32_t top, int32_t width, int32_t height) : control() {
212  this->text(text);
213  this->left(left);
214  this->top(top);
215  this->width(width);
216  this->height(height);
217  }
227  explicit control(const control& parent, const xtd::ustring& text, int32_t left, int32_t top, int32_t width, int32_t height) : control() {
228  this->parent(parent);
229  this->text(text);
230  this->left(left);
231  this->top(top);
232  this->width(width);
233  this->height(height);
234  }
236 
238  control(control&&) = delete;
239  control(const control&) = delete;
240  ~control();
242 
244 
253  virtual anchor_styles anchor() const;
263  virtual control& anchor(anchor_styles anchor);
264 
267  virtual drawing::point auto_scroll_point() const;
268 
272  virtual bool auto_size() const;
277  virtual control& auto_size(bool auto_size);
278 
283  virtual drawing::color back_color() const;
291  virtual control& back_color(const drawing::color& color);
293  virtual control& back_color(std::nullptr_t);
295 
299  virtual const xtd::drawing::image& background_image() const;
304  virtual control& background_image(const xtd::drawing::image& background_image);
305 
310  virtual xtd::forms::image_layout background_image_layout() const;
311 
317  virtual control& background_image_layout(xtd::forms::image_layout background_image_layout);
318 
323  virtual int32_t bottom() const;
324 
328  virtual drawing::rectangle bounds() const;
333  virtual control& bounds(const drawing::rectangle& bounds);
334 
338  virtual bool can_focus() const;
339 
351  virtual bool can_select() const;
352 
355  bool can_raise_events() const override;
356 
361  static bool check_for_illegal_cross_thread_calls();
366  static void check_for_illegal_cross_thread_calls(bool value);
367 
372  virtual const drawing::rectangle& client_rectangle() const;
373 
377  virtual const drawing::size& client_size() const;
382  virtual control& client_size(const drawing::size& client_size);
383 
386  virtual xtd::ustring company_name() const;
387 
390  virtual std::optional<std::reference_wrapper<xtd::forms::context_menu>> context_menu() const;
394  virtual control& context_menu(xtd::forms::context_menu& value);
398  virtual control& context_menu(std::nullptr_t);
399 
412 
419  virtual control_collection& controls();
426  virtual const control_collection& controls() const;
427 
431  virtual bool created();
432 
435  virtual forms::cursor cursor() const;
439  virtual control& cursor(const forms::cursor& cursor);
441  virtual control& cursor(std::nullptr_t);
443 
448 
452 
455  virtual drawing::font default_font() const;
456 
460 
463  virtual drawing::size default_size() const;
464 
467  virtual drawing::rectangle display_rectangle() const;
468 
477  virtual dock_style dock() const;
487  virtual control& dock(dock_style dock);
488 
491  virtual bool double_buffered() const;
495  virtual control& double_buffered(bool double_buffered);
496 
499  virtual bool enabled() const;
503  virtual control& enabled(bool enabled);
504 
507  virtual bool focused() const;
508 
511  virtual drawing::font font() const;
515  virtual control& font(const drawing::font& font);
517  virtual control& font(std::nullptr_t);
519 
522  virtual drawing::color fore_color() const;
526  virtual control& fore_color(const drawing::color& color);
528  virtual control& fore_color(std::nullptr_t);
530 
534  intptr_t handle() const override;
535 
538  virtual int32_t height() const;
542  virtual control& height(int32_t height);
543 
546  bool invoke_required() const;
547 
551  bool is_handle_created() const;
552 
555  virtual int32_t left() const;
559  virtual control& left(int32_t left);
560 
563  virtual drawing::point location() const;
567  virtual control& location(const drawing::point& location);
568 
571  virtual forms::padding margin() const;
575  virtual control& margin(const forms::padding& margin);
576 
582  virtual const drawing::size& maximum_client_size() const;
588  virtual control& maximum_client_size(const drawing::size& size);
589 
595  virtual const drawing::size& maximum_size() const;
601  virtual control& maximum_size(const drawing::size& size);
602 
608  virtual const drawing::size& minimum_client_size() const;
614  virtual control& minimum_client_size(const drawing::size& size);
615 
621  virtual const drawing::size& minimum_size() const;
627  virtual control& minimum_size(const drawing::size& size);
628 
631  static forms::keys modifier_keys();
632 
636 
640  intptr_t native_handle() const;
641 
644  virtual const xtd::ustring& name() const;
648  virtual control& name(const xtd::ustring& name);
649 
652  virtual forms::padding padding() const;
656  virtual control& padding(const forms::padding& padding);
657 
660  virtual std::optional<control_ref> parent() const;
664  virtual control& parent(const control& parent);
668  virtual control& parent(std::nullptr_t);
669 
672  virtual xtd::ustring product_name() const;
673 
676  bool recreating_handle() const;
677 
682  virtual const xtd::drawing::region& region() const;
688  virtual control& region(const xtd::drawing::region& value);
689 
692  virtual int32_t right() const;
693 
696  virtual drawing::size size() const;
700  virtual control& size(const drawing::size& size);
701 
705  virtual style_sheets::style_sheet style_sheet() const;
709  virtual control& style_sheet(const style_sheets::style_sheet& value);
713  virtual control& style_sheet(const xtd::ustring& value);
714 
719  virtual bool tab_stop() const;
725  virtual control& tab_stop(bool value);
726 
731  virtual std::any tag() const;
732 
738  virtual control& tag(std::any tag);
739 
742  virtual const xtd::ustring& text() const;
746  virtual control& text(const xtd::ustring& text);
747 
751  intptr_t toolkit_handle() const;
752 
755  virtual int32_t top() const;
759  virtual control& top(int32_t top);
760 
763  virtual std::optional<control_ref> top_level_control() const;
764 
767  virtual bool visible() const;
771  virtual control& visible(bool visible);
772 
775  virtual int32_t width() const;
779  virtual control& width(int32_t width);
781 
783 
788  std::shared_ptr<xtd::iasync_result> begin_invoke(delegate<void()> value);
789 
794  std::shared_ptr<xtd::iasync_result> begin_invoke(delegate<void(std::vector<std::any>)> value, const std::vector<std::any>& args);
795 
797  template<typename delegate_t>
798  std::shared_ptr<xtd::iasync_result> begin_invoke(delegate_t value, const std::vector<std::any>& args) {return begin_invoke(delegate<void(std::vector<std::any>)>(value), args);}
799 
800  template<typename delegate_t>
801  std::shared_ptr<xtd::iasync_result> begin_invoke(delegate_t value) {return begin_invoke(delegate<void(std::vector<std::any>)>(value), {});}
803 
806  virtual void bring_to_front();
807 
814  template<typename control_t>
815  static std::unique_ptr<control_t> create(const drawing::point& location = {-1, -1}, const drawing::size& size = {-1, -1}, const drawing::color& back_color = drawing::color::empty, const drawing::color& fore_color = drawing::color::empty) {
816  std::unique_ptr<control_t> item = std::make_unique<control_t>();
817  if (location != drawing::point {-1, -1}) item->location(location);
818  if (size != drawing::size {-1, -1}) item->size(size);
819  if (back_color != drawing::color::empty) item->back_color(back_color);
820  if (fore_color != drawing::color::empty) item->fore_color(fore_color);
821  return item;
822  }
823 
831  template<typename control_t>
832  static std::unique_ptr<control_t> create(const control& parent, const drawing::point& location = {-1, -1}, const drawing::size& size = {-1, -1}, const drawing::color& back_color = drawing::color::empty, const drawing::color& fore_color = drawing::color::empty) {
833  std::unique_ptr<control_t> item = std::make_unique<control_t>();
834  item->parent(parent);
835  if (location != drawing::point {-1, -1}) item->location(location);
836  if (size != drawing::size {-1, -1}) item->size(size);
837  if (back_color != drawing::color::empty) item->back_color(back_color);
838  if (fore_color != drawing::color::empty) item->fore_color(fore_color);
839  return item;
840  }
841 
849  template<typename control_t>
850  static std::unique_ptr<control_t> create(const xtd::ustring& text, const drawing::point& location = {-1, -1}, const drawing::size& size = {-1, -1}, const drawing::color& back_color = drawing::color::empty, const drawing::color& fore_color = drawing::color::empty) {
851  std::unique_ptr<control_t> item = std::make_unique<control_t>();
852  item->text(text);
853  if (location != drawing::point {-1, -1}) item->location(location);
854  if (size != drawing::size {-1, -1}) item->size(size);
855  if (back_color != drawing::color::empty) item->back_color(back_color);
856  if (fore_color != drawing::color::empty) item->fore_color(fore_color);
857  return item;
858  }
859 
868  template<typename control_t>
869  static std::unique_ptr<control_t> create(const control& parent, const xtd::ustring& text, const drawing::point& location = {-1, -1}, const drawing::size& size = {-1, -1}, const drawing::color& back_color = drawing::color::empty, const drawing::color& fore_color = drawing::color::empty) {
870  std::unique_ptr<control_t> item = std::make_unique<control_t>();
871  item->parent(parent);
872  item->text(text);
873  if (location != drawing::point {-1, -1}) item->location(location);
874  if (size != drawing::size {-1, -1}) item->size(size);
875  if (back_color != drawing::color::empty) item->back_color(back_color);
876  if (fore_color != drawing::color::empty) item->fore_color(fore_color);
877  return item;
878  }
879 
883  void create_control();
884 
889  drawing::graphics create_graphics() const;
890 
895  virtual void create_handle();
896 
901  virtual void destroy_control();
902 
906  virtual void destroy_handle();
907 
910  void end_invoke(std::shared_ptr<xtd::iasync_result> async);
911 
915  bool focus();
916 
921  static std::optional<control_ref> from_child_handle(intptr_t handle);
922 
926  static std::optional<control_ref> from_handle(intptr_t handle);
927 
930  auto_size_mode get_auto_size_mode() const;
931 
934  std::optional<xtd::drawing::color> get_back_color() const {return data_->back_color;}
936 
939  std::optional<xtd::drawing::font> get_font() const {return data_->font;}
941 
944  std::optional<xtd::drawing::color> get_fore_color() const {return data_->fore_color;}
946 
951  size_t get_child_index(intptr_t child) const;
952 
956  size_t get_child_index(intptr_t child, bool& throw_exception) const;
957 
960  virtual void hide();
961 
964  virtual void invalidate() const;
965 
969  virtual void invalidate(bool invalidate_children) const;
970 
974  virtual void invalidate(const drawing::rectangle& rect) const;
975 
980  virtual void invalidate(const drawing::rectangle& rect, bool invalidate_children) const;
981 
984  void invoke(delegate<void()> value);
985 
989  void invoke(delegate<void(std::vector<std::any>)> value, const std::vector<std::any>& args);
990 
994  void invoke(delegate<void(std::vector<std::any>)> value, std::any arg);
995 
997  template<typename delegate_t>
998  void invoke(delegate_t value, const std::vector<std::any>& args) {invoke(delegate<void(std::vector<std::any>)>(value), args);}
999 
1000  template<typename delegate_t, typename args_t>
1001  void invoke(delegate_t value, args_t args) {invoke(delegate<void(std::vector<std::any>)>(value), std::any(args));}
1002 
1003  template<typename delegate_t>
1004  void invoke(delegate_t value) {invoke(delegate<void(std::vector<std::any>)>(value), std::vector<std::any> {});}
1006 
1009  void perform_layout();
1010 
1014  xtd::drawing::point point_to_client(const xtd::drawing::point& p) const;
1015 
1019  xtd::drawing::point point_to_screen(const xtd::drawing::point& p) const;
1020 
1025  virtual bool pre_process_message(xtd::forms::message& message);
1026 
1030  virtual void refresh() const;
1031 
1036  void resume_layout();
1037 
1044  void resume_layout(bool perform_layout);
1045 
1052  intptr_t send_message(intptr_t hwnd, int32_t msg, intptr_t wparam, intptr_t lparam) const;
1053 
1056  void set_auto_size_mode(auto_size_mode auto_size_mode);
1057 
1063  void set_bounds(int32_t x, int32_t y, int32_t width, int32_t height);
1064 
1071  void set_bounds(int32_t x, int32_t y, int32_t width, int32_t height, bounds_specified specified);
1072 
1075  virtual void show();
1076 
1082  void suspend_layout();
1083 
1086  xtd::ustring to_string() const noexcept override;
1087 
1094  virtual void update() const;
1096 
1098 
1105  child.parent(*this);
1106  return *this;
1107  }
1108 
1114  if (child.parent().has_value() && &child.parent().value().get() == this)
1115  child.parent(nullptr);
1116  return *this;
1117  }
1119 
1121  friend std::ostream& operator<<(std::ostream& os, const xtd::forms::control& control) noexcept {
1122  return os << control.to_string();
1123  }
1124 
1125  bool operator==(const control& value) const {return this == &value;}
1126  bool operator!=(const control& value) const {return !operator==(value);}
1127  bool operator<(const control& value) const {return this < &value;}
1129 
1131 
1138 
1144 
1150 
1156 
1182 
1188 
1194 
1199 
1204 
1210 
1235 
1257 
1263 
1269 
1275 
1281 
1287 
1293 
1306 
1321 
1334 
1340 
1346 
1369 
1386 
1407 
1422 
1437 
1453 
1468 
1483 
1498 
1514 
1524 
1530 
1534 
1544 
1550 
1556 
1562 
1569 
1570  protected:
1571  friend class application;
1572  friend class context_menu;
1573  friend class paint_event_args;
1574  friend class screen;
1575 
1577 
1579 
1582  xtd::forms::visual_styles::control_state control_state() const noexcept {return data_->control_state;}
1583 
1589  virtual forms::create_params create_params() const;
1590 
1593  virtual void def_wnd_proc(message& message);
1594 
1599  bool get_style(control_styles flag) const;
1600 
1603  virtual drawing::size measure_control() const;
1604 
1607  drawing::size measure_text() const;
1608 
1612  virtual void on_auto_size_changed(const event_args& e);
1613 
1617  virtual void on_back_color_changed(const event_args& e);
1618 
1622  virtual void on_background_image_changed(const event_args& e);
1623 
1627  virtual void on_background_image_layout_changed(const event_args& e);
1628 
1632  virtual void on_click(const event_args& e);
1633 
1637  virtual void on_client_size_changed(const event_args& e);
1638 
1642  virtual void on_control_added(const control_event_args& e);
1643 
1647  virtual void on_control_removed(const control_event_args& e);
1648 
1652  virtual void on_create_control();
1653 
1657  virtual void on_cursor_changed(const event_args& e);
1658 
1662  virtual void on_dock_changed(const event_args& e);
1663 
1667  virtual void on_double_click(const event_args& e);
1668 
1672  virtual void on_enabled_changed(const event_args& e);
1673 
1677  virtual void on_fore_color_changed(const event_args& e);
1678 
1682  virtual void on_font_changed(const event_args& e);
1683 
1687  virtual void on_got_focus(const event_args& e);
1688 
1692  virtual void on_handle_created(const event_args& e);
1693 
1697  virtual void on_handle_destroyed(const event_args& e);
1698 
1702  virtual void on_help_requested(help_event_args& e);
1703 
1707  virtual void on_key_down(key_event_args& e);
1708 
1712  virtual void on_key_press(key_press_event_args& e);
1713 
1717  virtual void on_key_up(key_event_args& e);
1718 
1722  virtual void on_layout(const event_args& e);
1723 
1727  virtual void on_location_changed(const event_args& e);
1728 
1732  virtual void on_lost_focus(const event_args& e);
1733 
1737  virtual void on_mouse_click(const mouse_event_args& e);
1738 
1742  virtual void on_mouse_double_click(const mouse_event_args& e);
1743 
1747  virtual void on_mouse_down(const mouse_event_args& e);
1748 
1752  virtual void on_mouse_enter(const event_args& e);
1753 
1757  virtual void on_mouse_horizontal_wheel(const mouse_event_args& e);
1758 
1762  virtual void on_mouse_leave(const event_args& e);
1763 
1767  virtual void on_mouse_move(const mouse_event_args& e);
1768 
1772  virtual void on_mouse_up(const mouse_event_args& e);
1773 
1777  virtual void on_mouse_wheel(const mouse_event_args& e);
1778 
1782  virtual void on_paint(paint_event_args& e);
1783 
1788  virtual void on_paint_background(paint_event_args& e);
1789 
1793  virtual void on_parent_back_color_changed(const event_args& e);
1794 
1798  virtual void on_parent_cursor_changed(const event_args& e);
1799 
1803  virtual void on_parent_changed(const event_args& e);
1804 
1808  virtual void on_parent_enabled_changed(const event_args& e);
1809 
1813  virtual void on_parent_fore_color_changed(const event_args& e);
1814 
1818  virtual void on_parent_font_changed(const event_args& e);
1819 
1823  virtual void on_resize(const event_args& e);
1824 
1828  virtual void on_region_changed(const event_args& e);
1829 
1833  virtual void on_size_changed(const event_args& e);
1834 
1838  virtual void on_tab_stop_changed(const event_args& e);
1839 
1843  virtual void on_text_changed(const event_args& e);
1844 
1848  virtual void on_visible_changed(const event_args& e);
1849 
1850  void post_recreate_handle();
1851 
1854  virtual void recreate_handle();
1855 
1866  virtual void set_bounds_core(int32_t x, int32_t y, int32_t width, int32_t height, bounds_specified specified);
1867 
1871  void set_can_focus(bool value);
1872 
1876  virtual void set_text(const xtd::ustring& text);
1877 
1885  virtual void set_client_size_core(int32_t width, int32_t height);
1886 
1889  static void set_mouse_buttons(forms::mouse_buttons value);
1890 
1893  void set_parent(intptr_t handle);
1894 
1900  void set_style(control_styles flag, bool value);
1901 
1907  virtual void wnd_proc(message& m);
1909 
1911  bool get_state(control::state flag) const;
1912  void set_state(control::state flag, bool value);
1913  bool on_context_menu_item_click(xtd::forms::context_menu& menu, int32_t menu_id) const;
1915 
1916  private:
1917  void on_parent_size_changed(object& sender, const event_args& e);
1918  void do_layout_children_with_dock_style();
1919  void do_layout_with_auto_size_mode();
1920  void do_layout_with_anchor_styles();
1921  control(const xtd::ustring& name, bool);
1922  void show_context_menu(xtd::forms::context_menu& menu, const xtd::drawing::point& pos) const;
1923  intptr_t wnd_proc_(intptr_t hwnd, int32_t msg, intptr_t wparam, intptr_t lparam, intptr_t handle);
1924  void wm_child_activate(message& message);
1925  void wm_create(message& message);
1926  void wm_command(message& message);
1927  void wm_enter_idle(message& message);
1928  void wm_key_char(message& message);
1929  void wm_kill_focus(message& message);
1930  void wm_menu_command(message& message);
1931  void wm_mouse_down(message& message);
1932  void wm_mouse_double_click(message& message);
1933  void wm_mouse_enter(message& message);
1934  void wm_mouse_leave(message& message);
1935  void wm_mouse_up(message& message);
1936  void wm_mouse_move(message& message);
1937  void wm_move(message& message);
1938  void wm_mouse_wheel(message& message);
1939  void wm_notify(message& message);
1940  void wm_paint(const message& message);
1941  void wm_erase_background(const message& message);
1942  void wm_help(message& message);
1943  void wm_scroll(message& message);
1944  void wm_set_focus(message& message);
1945  void wm_set_text(message& message);
1946  void wm_show(message& message);
1947  void wm_size(message& message);
1948  void wm_sizing(message& message);
1949 
1950  struct data {
1952  forms::padding anchoring;
1953  drawing::point auto_scroll_point;
1955  std::optional<drawing::color> back_color;
1957  xtd::forms::image_layout background_image_layout = xtd::forms::image_layout::tile;
1958  bool can_focus = true;
1959  bool can_raise_events = true;
1960  drawing::rectangle client_rectangle;
1961  drawing::size client_size;
1964  control_collection controls;
1965  std::optional<std::reference_wrapper<xtd::forms::context_menu>> context_menu;
1966  std::optional<forms::cursor> cursor;
1968  bool focused = false;
1969  std::optional<drawing::color> fore_color;
1970  std::optional<drawing::font> font;
1971  intptr_t handle = 0;
1973  drawing::region region;
1974  forms::padding margin {3};
1975  drawing::size maximum_client_size;
1976  drawing::size maximum_size;
1977  drawing::size minimum_client_size;
1978  drawing::size minimum_size;
1980  bool mouse_in = false;
1981  xtd::ustring name;
1982  intptr_t parent = 0;
1983  bool recreate_handle_posted = false;
1984  std::optional<drawing::size> size;
1985  control::state state = control::state::empty;
1987  style_sheets::style_sheet style_sheet;
1988  std::any tag;
1989  xtd::ustring text;
1990  };
1991 
1992  static bool check_for_illegal_cross_thread_calls_;
1993  static std::thread::id handle_created_on_thread_id_;
1994  static forms::keys modifier_keys_;
1995  static forms::mouse_buttons mouse_buttons_;
1996  static std::map<intptr_t, control*> handles_;
1997  static control_collection top_level_controls_;
1998 
1999  std::shared_ptr<data> data_ = std::make_shared<data>();
2000  };
2001  }
2002 }
event< control, control_event_handler > control_removed
Occurs when a new control is removed to the control::control_collection.
Definition: control.h:1203
virtual forms::cursor default_cursor() const
Gets the default cursor for the control.
Definition: control.h:451
event< control, event_handler > resize
Occurs when the control is resized.
Definition: control.h:1543
Represents a display device or multiple display devices on a single system.
Definition: screen.h:29
Contains xtd::forms::cursors factory.
Represents a display device or multiple display devices on a single system.
Definition: padding.h:20
Contains xtd::forms::theme_colors class.
Defines a particular format for text, including font face, size, and style attributes. This class cannot be inherited.
Definition: font.h:44
control & operator>>(control &child)
Remove child control.
Definition: control.h:1113
event< control, event_handler > layout
Occurs when a control should reposition its child controls.
Definition: control.h:1339
The image is tiled across the control&#39;s client rectangle.
event< control, event_handler > enabled_changed
Occurs when the value of the enabled property changes.
Definition: control.h:1274
Bind control edges to the top of its container.
event< control, event_handler > background_image_changed
Occurs when the value of the background_image property changes.
Definition: control.h:1149
Represents the status of an asynchronous operation.
Definition: iasync_result.h:21
event< control, mouse_event_handler > mouse_horizontal_wheel
Occurs when the mouse horizontal wheel moves while the control has focus.
Definition: control.h:1452
mouse_buttons
Specifies constants that define which mouse button was pressed. This enumeration has a flag attribute...
Definition: mouse_buttons.h:18
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
event< control, event_handler > client_size_changed
Occurs when the value of the client_size property changes.
Definition: control.h:1187
Contains xtd::forms::key_event_handler event handler.
Contains xtd::forms::arranged_element_collection collection.
Contains xtd::forms::style_sheets::style_sheet class.
xtd::forms::style_sheets::lengths padding
Padding is used to create space around an element&#39;s content, inside of any defined borders...
Definition: padding.h:22
static std::unique_ptr< control_t > create(const control &parent, const xtd::ustring &text, const drawing::point &location={-1, -1}, const drawing::size &size={-1, -1}, const drawing::color &back_color=drawing::color::empty, const drawing::color &fore_color=drawing::color::empty)
A factory to create a specified control with specified parent, text, location ,size back_color and fo...
Definition: control.h:869
const xtd::drawing::color & control_text() const noexcept
Gets the control text system color;.
The picture_box is sized equal to the size of the image that it contains.
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition: point.h:53
Contains xtd::forms::paint_event_handler event handler.
xtd::forms::visual_styles::control_state control_state() const noexcept
Gets state.
Definition: control.h:1582
Represents a collection of controls.
Definition: control.h:139
Contains xtd::drawing::point class.
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:30
Specifies that the top edge of the control is defined.
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
static const xtd::drawing::color empty
Represents a color that is null.
Definition: color.h:50
event< control, event_handler > mouse_enter
Occurs when the mouse pointer enters the control.
Definition: control.h:1436
xtd::forms::style_sheets::lengths margin
Margins are used to create space around elements, outside of any defined borders. ...
Definition: margin.h:22
static std::unique_ptr< control_t > create(const drawing::point &location={-1, -1}, const drawing::size &size={-1, -1}, const drawing::color &back_color=drawing::color::empty, const drawing::color &fore_color=drawing::color::empty)
A factory to create a specified control with specified location ,size back_color and fore_color...
Definition: control.h:815
event< control, key_event_handler > key_down
Occurs when a key is pressed while the control has focus.
Definition: control.h:1305
The appearance of the control is determined by current theme of xtd.
event< control, event_handler > visible_changed
Occurs when the value of the visible property changes.
Definition: control.h:1567
event< control, event_handler > lost_focus
Occurs when the control loses focus.
Definition: control.h:1368
Contains xtd::forms::anchor_styles enum class.
event< control, event_handler > auto_size_changed
Occurs when the value of the auto_size property changes.
Definition: control.h:1137
auto_size_mode
Specifies how a control will behave when its auto_size property is enabled.
Definition: auto_size_mode.h:18
event< control, event_handler > fore_color_changed
Occurs when the value of the fore_color property changes.
Definition: control.h:1280
Contains xtd::forms::message class.
The control grows or shrinks to fit its contents. The control cannot be resized manually.
Contains xtd::iasync_result interface.
control_appearance
Specifies the appearance of a control.
Definition: control_appearance.h:17
event< control, control_event_handler > control_added
Occurs when a new control is added to the control::control_collection.
Definition: control.h:1198
Contains xtd::forms::timer component.
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:50
Specifies that the left edge of the control is defined.
The control has the normal appearance.
Represents the image used to paint the mouse pointer.
Definition: cursor.h:35
Describes the interior of a graphics shape composed of rectangles and paths. This class cannot be inh...
Definition: region.h:31
Represents a collection of objects.
Definition: arranged_element_collection.h:28
std::string to_string(const date_time &value, const std::string &fmt, const std::locale &loc)
Convert a specified value into a string with specified format and locale.
Definition: date_time.h:1110
Bind control edges to the bottom of its container.
Contains xtd::forms::control_appearance enum class.
Contains xtd::forms::control_styles enum class.
event< control, mouse_event_handler > mouse_click
Occurs when the control is clicked by the mouse.
Definition: control.h:1385
control_state
Specifies the visual state of a control that is drawn with visual styles.
Definition: control_state.h:20
Contains xtd::forms::iwin32_window interface.
const xtd::drawing::color & control() const noexcept
Gets the control system color;.
Contains xtd::forms::control_ref typedef.
Contains xtd::forms::padding class.
xtd::ustring to_string() const noexcept override
Returns a string containing the name of the control, if any.
Provides an interface to expose Win32 HWND handles.
Definition: iwin32_window.h:19
Contains xtd::forms::key_press_event_handler event handler.
event< control, event_handler > double_click
Occurs when the control is double-clicked.
Definition: control.h:1234
static std::unique_ptr< control_t > create(const control &parent, const drawing::point &location={-1, -1}, const drawing::size &size={-1, -1}, const drawing::color &back_color=drawing::color::empty, const drawing::color &fore_color=drawing::color::empty)
A factory to create a specified control with specified parent, location ,size back_color and fore_col...
Definition: control.h:832
static cursor default_cursor()
Gets the default cursor, which is usually an arrow cursor.
virtual drawing::color default_fore_color() const
Gets the default foreground color of the control.
Definition: control.h:459
virtual drawing::color default_back_color() const
Gets the default background color of the control.
Definition: control.h:447
Contains xtd::forms::image_layout enum class.
event< control, paint_event_handler > paint
Occurs when the control is redrawn.
Definition: control.h:1523
event< control, event_handler > tab_stop_changed
Occurs when the xtd::forms::control::tab_stop property value changes.
Definition: control.h:1555
event< control, mouse_event_handler > mouse_down
Occurs when the mouse pointer is over the control and a mouse button is pressed.
Definition: control.h:1421
Specifies that the height of the control is defined.
Contains xtd::drawing::rectangle class.
Represents an ARGB (alpha, red, green, blue) color.
Definition: color.h:44
const xtd::forms::style_sheets::system_colors & system_colors() const noexcept
Gets The style sheet system colors of this instance.
The CTRL modifier key.
event< control, event_handler > handle_destroyed
Occurs when the control&#39;s handle is in the process of being destroyed.
Definition: control.h:1268
Represents an event.
Definition: event.h:21
Bind control edges to the right of its container.
Provides data for the paint event.
Definition: paint_event_args.h:27
Specifies that both the width and height property values of the control are defined.
control(const xtd::ustring &text, int32_t left, int32_t top, int32_t width, int32_t height)
Initializes a new instance of the control class with specific text, size, and location.
Definition: control.h:211
Provides static methods and properties to manage an application, such as methods to start and stop an...
Definition: application.h:54
event< control, mouse_event_handler > mouse_move
Occurs when the mouse pointer is moved over the control.
Definition: control.h:1482
event< control, event_handler > font_changed
Occurs when the value of the font property changes.
Definition: control.h:1286
control_styles
Specifies the style and behavior of a control.
Definition: control_styles.h:29
Contains xtd::forms::help_event_handler event handler.
event< control, event_handler > background_image_layout_changed
Occurs when the value of the background_image_layout property changes.
Definition: control.h:1155
Contains xtd::forms::control_event_handler event handler.
static const style_sheet & current_style_sheet() noexcept
Gets current xtd::forms::style_sheets::style_sheet style sheet.
Hides minimized windows by moving them off the visible area of the screen.
Contains xtd::drawing::size class.
event< control, event_handler > back_color_changed
Occurs when the value of the back_color property changes.
Definition: control.h:1143
event< control, event_handler > location_changed
Occurs when the value of the location property changes.
Definition: control.h:1345
Specifies that the width of the control is defined.
Stores a set of four integers that represent the location and size of a rectangle.
Definition: rectangle.h:44
event< control, event_handler > size_changed
Occurs when the value of the size property changes.
Definition: control.h:1549
Contains xtd::forms::visual_styles::control_state enum class.
event< control, mouse_event_handler > mouse_double_click
Occurs when the control is double clicked by the mouse.
Definition: control.h:1406
Indicates that all styles except allow_binary_specifier, allow_octal_specifier and allow_hex_specifie...
Contains xtd::forms::context_menu menu.
Contains xtd::drawing::color class.
An abstract base class that provides functionality for the bitmap and metafile descended classes...
Definition: image.h:47
Implements a Windows message.
Definition: message.h:25
event< control, event_handler > dock_changed
Occurs when the value of the dock property changes.
Definition: control.h:1209
event< control, key_press_event_handler > key_press
Occurs when a character. space or backspace key is pressed while the control has focus.
Definition: control.h:1320
The control is not docked.
Represents the base functionality for all menus. Although tool_strip_drop_down and tool_strip_drop_do...
Definition: menu.h:49
Defines the base class for controls, which are components with visual representation.
Definition: control.h:73
control & operator<<(control &child)
Add child control.
Definition: control.h:1104
event< control, event_handler > parent_changed
Occurs when the value of the parent property changes.
Definition: control.h:1529
dock_style
Specifies the position and manner in which a control is docked.
Definition: dock_style.h:19
event< control, event_handler > mouse_leave
Occurs when the mouse pointer leaves the control.
Definition: control.h:1467
Contains xtd::forms::mouse_event_handler event handler.
keys
Specifies key codes and modifiers.
Definition: keys.h:73
control(const xtd::ustring &text)
Initializes a new instance of the control class with specific text.
Definition: control.h:191
Provides data for the control_added and control_removed events.
Definition: help_event_args.h:22
event< control, event_handler > cursor_changed
Occurs when the value of the cursor property changes.
Definition: control.h:1193
Provides data for the key_press event.
Definition: key_press_event_args.h:23
std::allocator< value_type > allocator_type
Represents the allocator type of the collection.
Definition: arranged_element_collection.h:65
Contains xtd::forms::dock_style enum class.
Provides data for the xtd::forms::control::mouse_up, xtd::forms::control::mouse_down, and xtd::forms::control::mouse_move events.
Definition: mouse_event_args.h:30
event< control, help_event_handler > help_requested
Occurs when the user requests help for a control.
Definition: control.h:1292
event< control, event_handler > text_changed
Occurs when the value of the text property changes.
Definition: control.h:1561
Represents a shortcut menu.
Definition: context_menu.h:22
Contains xtd::forms::auto_size_mode enum class.
Provides data for the control_added and control_removed events.
Definition: control_event_args.h:23
virtual std::optional< control_ref > parent() const
Gets the parent container of the control.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
Contains xtd::forms::component class.
control(const control &parent, const xtd::ustring &text, int32_t left, int32_t top, int32_t width, int32_t height)
Initializes a new instance of the control class as a child control, with specific text...
Definition: control.h:227
event< control, event_handler > region_changed
Occurs when the value of the xtd::forms::control::region property changes.
Definition: control.h:1533
Specifies that both the x and y coordinates of the control are defined.
bounds_specified
Specifies the bounds of the control to use when defining a control&#39;s size and position. This enumeration has a flags attribute that allows a bitwise combination of its member values.
Definition: bounds_specified.h:18
event< control, key_event_handler > key_up
Occurs when a key is released while the control has focus.
Definition: control.h:1333
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition: graphics.h:69
event< control, mouse_event_handler > mouse_up
Occurs when the mouse pointer is over the control and a mouse button is released. ...
Definition: control.h:1497
Contains xtd::forms::bounds_specified enum class.
Provides data for the key_down or key_up event.
Definition: key_event_args.h:22
image_layout
Specifies the position of the image on the control.
Definition: image_layout.h:17
Bind control edges to the left of its container.
event< control, mouse_event_handler > mouse_wheel
Occurs when the mouse wheel moves while the control has focus.
Definition: control.h:1513
anchor_styles
Specifies how a control anchors to the edges of its container.
Definition: anchor_styles.h:19
static image empty
Represent an empty xtd::drawing::image.
Definition: image.h:62
event< control, event_handler > got_focus
Occurs when the control receives focus.
Definition: control.h:1256
The xtd::forms::style_sheets::style_sheet allows you to specify an xtd style sheet.
Definition: style_sheet.h:57
Contains xtd::drawing::font class.
static std::unique_ptr< control_t > create(const xtd::ustring &text, const drawing::point &location={-1, -1}, const drawing::size &size={-1, -1}, const drawing::color &back_color=drawing::color::empty, const drawing::color &fore_color=drawing::color::empty)
A factory to create a specified control with specified text, location ,size back_color and fore_color...
Definition: control.h:850
event< control, event_handler > handle_created
Occurs when a handle is created for the control.
Definition: control.h:1262
Provides the base implementation and enables object sharing between applications. ...
Definition: component.h:21
event< control, event_handler > click
Occurs when the control is clicked.
Definition: control.h:1181
control(const control &parent, const xtd::ustring &text)
Initializes a new instance of the control class as a child control, with specific text...
Definition: control.h:199