6 #include <condition_variable> 21 #include <xtd/forms/create_params.h> 23 #include "../forms_export.h" 82 creating_handle = 0b10000,
84 parent_recreating = 0b1000000,
86 client_size_setted = 0b10000000,
88 top_level = 0b1000000000,
89 visible = 0b10000000000,
90 enabled = 0b100000000000,
92 tab_stop = 0b10000000000000,
93 allow_drop = 0b100000000000000,
94 drop_target = 0b1000000000000000,
96 layout_deferred = 0b10000000000000000,
97 docked = 0b100000000000000000,
99 double_click_fired = 0b1000000000000000000,
100 double_buffered = 0b10000000000000000000,
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_;};
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>();
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);
200 this->parent(parent);
228 this->parent(parent);
293 virtual control& back_color(std::nullptr_t);
323 virtual int32_t
bottom()
const;
338 virtual bool can_focus()
const;
351 virtual bool can_select()
const;
355 bool can_raise_events()
const override;
361 static bool check_for_illegal_cross_thread_calls();
366 static void check_for_illegal_cross_thread_calls(
bool value);
390 virtual std::optional<std::reference_wrapper<xtd::forms::context_menu>>
context_menu()
const;
398 virtual control& context_menu(std::nullptr_t);
431 virtual bool created();
441 virtual control& cursor(std::nullptr_t);
491 virtual bool double_buffered()
const;
495 virtual control& double_buffered(
bool double_buffered);
499 virtual bool enabled()
const;
503 virtual control& enabled(
bool enabled);
507 virtual bool focused()
const;
517 virtual control& font(std::nullptr_t);
528 virtual control& fore_color(std::nullptr_t);
534 intptr_t handle()
const override;
538 virtual int32_t
height()
const;
546 bool invoke_required()
const;
551 bool is_handle_created()
const;
555 virtual int32_t
left()
const;
640 intptr_t native_handle()
const;
660 virtual std::optional<control_ref> parent()
const;
668 virtual control& parent(std::nullptr_t);
676 bool recreating_handle()
const;
692 virtual int32_t
right()
const;
719 virtual bool tab_stop()
const;
725 virtual control& tab_stop(
bool value);
751 intptr_t toolkit_handle()
const;
755 virtual int32_t
top()
const;
763 virtual std::optional<control_ref> top_level_control()
const;
767 virtual bool visible()
const;
771 virtual control& visible(
bool visible);
775 virtual int32_t
width()
const;
788 std::shared_ptr<xtd::iasync_result> begin_invoke(delegate<
void()> value);
794 std::shared_ptr<xtd::iasync_result> begin_invoke(delegate<
void(std::vector<std::any>)> value,
const std::vector<std::any>& args);
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);}
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), {});}
806 virtual void bring_to_front();
814 template<
typename control_t>
816 std::unique_ptr<control_t> item = std::make_unique<control_t>();
817 if (location !=
drawing::point {-1, -1}) item->location(location);
831 template<
typename control_t>
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);
849 template<
typename control_t>
851 std::unique_ptr<control_t> item = std::make_unique<control_t>();
853 if (location !=
drawing::point {-1, -1}) item->location(location);
868 template<
typename control_t>
870 std::unique_ptr<control_t> item = std::make_unique<control_t>();
871 item->parent(parent);
873 if (location !=
drawing::point {-1, -1}) item->location(location);
883 void create_control();
895 virtual void create_handle();
901 virtual void destroy_control();
906 virtual void destroy_handle();
910 void end_invoke(std::shared_ptr<xtd::iasync_result> async);
921 static std::optional<control_ref> from_child_handle(intptr_t handle);
926 static std::optional<control_ref> from_handle(intptr_t handle);
934 std::optional<xtd::drawing::color> get_back_color()
const {
return data_->back_color;}
939 std::optional<xtd::drawing::font> get_font()
const {
return data_->font;}
944 std::optional<xtd::drawing::color> get_fore_color()
const {
return data_->fore_color;}
951 size_t get_child_index(intptr_t child)
const;
956 size_t get_child_index(intptr_t child,
bool& throw_exception)
const;
964 virtual void invalidate()
const;
969 virtual void invalidate(
bool invalidate_children)
const;
980 virtual void invalidate(
const drawing::rectangle& rect,
bool invalidate_children)
const;
984 void invoke(delegate<
void()> value);
989 void invoke(delegate<
void(std::vector<std::any>)> value,
const std::vector<std::any>& args);
994 void invoke(delegate<
void(std::vector<std::any>)> value,
std::any arg);
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);}
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));}
1003 template<
typename delegate_t>
1004 void invoke(delegate_t value) {invoke(delegate<
void(std::vector<std::any>)>(value), std::vector<std::any> {});}
1009 void perform_layout();
1030 virtual void refresh()
const;
1036 void resume_layout();
1044 void resume_layout(
bool perform_layout);
1052 intptr_t send_message(intptr_t hwnd, int32_t msg, intptr_t wparam, intptr_t lparam)
const;
1063 void set_bounds(int32_t
x, int32_t
y, int32_t width, int32_t height);
1071 void set_bounds(int32_t x, int32_t y, int32_t width, int32_t height,
bounds_specified specified);
1075 virtual void show();
1082 void suspend_layout();
1094 virtual void update()
const;
1114 if (child.
parent().has_value() && &child.
parent().value().get() ==
this)
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;}
1572 friend class context_menu;
1589 virtual forms::create_params create_params()
const;
1593 virtual void def_wnd_proc(message& message);
1612 virtual void on_auto_size_changed(
const event_args&
e);
1617 virtual void on_back_color_changed(
const event_args& e);
1622 virtual void on_background_image_changed(
const event_args& e);
1627 virtual void on_background_image_layout_changed(
const event_args& e);
1637 virtual void on_client_size_changed(
const event_args& e);
1652 virtual void on_create_control();
1657 virtual void on_cursor_changed(
const event_args& e);
1662 virtual void on_dock_changed(
const event_args& e);
1667 virtual void on_double_click(
const event_args& e);
1672 virtual void on_enabled_changed(
const event_args& e);
1677 virtual void on_fore_color_changed(
const event_args& e);
1682 virtual void on_font_changed(
const event_args& e);
1687 virtual void on_got_focus(
const event_args& e);
1692 virtual void on_handle_created(
const event_args& e);
1697 virtual void on_handle_destroyed(
const event_args& e);
1727 virtual void on_location_changed(
const event_args& e);
1732 virtual void on_lost_focus(
const event_args& e);
1752 virtual void on_mouse_enter(
const event_args& e);
1762 virtual void on_mouse_leave(
const event_args& e);
1793 virtual void on_parent_back_color_changed(
const event_args& e);
1798 virtual void on_parent_cursor_changed(
const event_args& e);
1803 virtual void on_parent_changed(
const event_args& e);
1808 virtual void on_parent_enabled_changed(
const event_args& e);
1813 virtual void on_parent_fore_color_changed(
const event_args& e);
1818 virtual void on_parent_font_changed(
const event_args& e);
1828 virtual void on_region_changed(
const event_args& e);
1833 virtual void on_size_changed(
const event_args& e);
1838 virtual void on_tab_stop_changed(
const event_args& e);
1843 virtual void on_text_changed(
const event_args& e);
1848 virtual void on_visible_changed(
const event_args& e);
1850 void post_recreate_handle();
1854 virtual void recreate_handle();
1866 virtual void set_bounds_core(int32_t x, int32_t y, int32_t width, int32_t height,
bounds_specified specified);
1871 void set_can_focus(
bool value);
1885 virtual void set_client_size_core(int32_t width, int32_t height);
1893 void set_parent(intptr_t handle);
1907 virtual void wnd_proc(message&
m);
1911 bool get_state(control::state flag)
const;
1912 void set_state(control::state flag,
bool value);
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();
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);
1955 std::optional<drawing::color> back_color;
1958 bool can_focus =
true;
1959 bool can_raise_events =
true;
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;
1980 bool mouse_in =
false;
1982 intptr_t parent = 0;
1983 bool recreate_handle_posted =
false;
1984 std::optional<drawing::size>
size;
1985 control::state state = control::state::empty;
1992 static bool check_for_illegal_cross_thread_calls_;
1993 static std::thread::id handle_created_on_thread_id_;
1996 static std::map<intptr_t, control*> handles_;
1999 std::shared_ptr<data> data_ = std::make_shared<data>();
event< control, control_event_handler > control_removed
Occurs when a new control is removed to the control::control_collection.
Definition: control.h:1203
event< control, event_handler > resize
Occurs when the control is resized.
Definition: control.h:1543
Contains xtd::forms::cursors factory.
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
event< control, event_handler > layout
Occurs when a control should reposition its child controls.
Definition: control.h:1339
event< control, event_handler > enabled_changed
Occurs when the value of the enabled property changes.
Definition: control.h:1274
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
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's content, inside of any defined borders...
Definition: padding.h:22
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.
Contains xtd::drawing::point class.
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:30
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
event< control, key_event_handler > key_down
Occurs when a key is pressed while the control has focus.
Definition: control.h:1305
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
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.
Contains xtd::iasync_result interface.
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
Describes the interior of a graphics shape composed of rectangles and paths. This class cannot be inh...
Definition: region.h:31
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
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
Contains xtd::forms::iwin32_window interface.
Contains xtd::forms::control_ref typedef.
Contains xtd::forms::padding class.
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
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
Contains xtd::drawing::rectangle class.
Represents an ARGB (alpha, red, green, blue) color.
Definition: color.h:44
event< control, event_handler > handle_destroyed
Occurs when the control's handle is in the process of being destroyed.
Definition: control.h:1268
Represents an event.
Definition: event.h:21
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
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.
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
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::drawing::color class.
An abstract base class that provides functionality for the bitmap and metafile descended classes...
Definition: image.h:47
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
event< control, event_handler > parent_changed
Occurs when the value of the parent property changes.
Definition: control.h:1529
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.
event< control, event_handler > cursor_changed
Occurs when the value of the cursor property changes.
Definition: control.h:1193
Contains xtd::forms::dock_style enum class.
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
Contains xtd::forms::auto_size_mode enum class.
Contains xtd::forms::component class.
event< control, event_handler > region_changed
Occurs when the value of the xtd::forms::control::region property changes.
Definition: control.h:1533
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.
event< control, mouse_event_handler > mouse_wheel
Occurs when the mouse wheel moves while the control has focus.
Definition: control.h:1513
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
Contains xtd::drawing::font class.
event< control, event_handler > handle_created
Occurs when a handle is created for the control.
Definition: control.h:1262
event< control, event_handler > click
Occurs when the control is clicked.
Definition: control.h:1181