xtd 1.0.0
Loading...
Searching...
No Matches
form.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "const_form_ref.hpp"
9#include "form_ref.hpp"
11#include "form_window_state.hpp"
12#include "container_control.hpp"
13#include "dialog_result.hpp"
14#include "ibutton_control.hpp"
15#include "main_menu.hpp"
16#include "screen.hpp"
17#include "status_bar.hpp"
18#include "tool_bar.hpp"
19#include <xtd/drawing/icon>
20#include <xtd/io/path>
21#include <cstddef>
22
24namespace xtd {
26 namespace forms {
28 class application;
30 class form;
32
55 struct data;
56
57 public:
59
63
66
69
73
75
81
83
87 [[nodiscard]] auto accept_button() const noexcept -> std::optional<ibutton_control_ref>;
91 auto accept_button(const xtd::forms::ibutton_control& value) -> form&;
96
99 [[nodiscard]] virtual auto auto_size_mode() const noexcept -> xtd::forms::auto_size_mode;
103 virtual auto auto_size_mode(xtd::forms::auto_size_mode value) -> form&;
104
107 [[nodiscard]] auto cancel_button() const noexcept -> std::optional<ibutton_control_ref>;
111 auto cancel_button(const xtd::forms::ibutton_control& value) -> form&;
116
119 [[nodiscard]] virtual auto close_box() const noexcept -> bool;
123 virtual auto close_box(bool value) -> form&;
124
127 [[nodiscard]] virtual auto control_box() const noexcept -> bool;
131 virtual auto control_box(bool value) -> form&;
132
135 [[nodiscard]] virtual auto dialog_result() const noexcept -> xtd::forms::dialog_result;
139 virtual auto dialog_result(xtd::forms::dialog_result value) -> form&;
140
145 auto font(xtd::null_ptr) -> control& override;
146
149 [[nodiscard]] virtual auto form_border_style() const noexcept -> xtd::forms::form_border_style;
154
157 [[nodiscard]] virtual auto help_button() const -> bool;
161 virtual auto help_button(bool value) -> form&;
162
165 [[nodiscard]] virtual auto icon() const noexcept -> const xtd::drawing::icon&;
169 virtual auto icon(const xtd::drawing::icon& value) -> form&;
170
173 [[nodiscard]] virtual auto maximize_box() const noexcept -> bool;
177 virtual auto maximize_box(bool value) -> form&;
178
181 [[nodiscard]] virtual auto menu() const noexcept -> std::optional<main_menu_ref>;
185 virtual auto menu(const xtd::forms::main_menu& value) -> form&;
189 virtual auto menu(xtd::null_ptr) -> form&;
190
193 [[nodiscard]] virtual auto minimize_box() const noexcept -> bool;
197 virtual auto minimize_box(bool value) -> form&;
198
201 [[nodiscard]] auto modal() const noexcept -> bool;
202
205 [[nodiscard]] virtual auto opacity() const noexcept -> double;
208 virtual auto opacity(double opacity) -> form&;
209
212 [[nodiscard]] virtual auto owner() const noexcept -> std::optional<xtd::forms::control_ref>;
216 virtual auto owner(const xtd::forms::control& value) -> form&;
220 virtual auto owner(xtd::null_ptr) -> form&;
221
225 auto parent(const xtd::forms::control& value) -> xtd::forms::control& override;
226
229 [[nodiscard]] virtual auto show_icon() const noexcept -> bool;
233 virtual auto show_icon(bool value) -> form&;
234
240 [[nodiscard]] virtual auto show_in_taskbar() const noexcept -> bool;
247 virtual auto show_in_taskbar(bool value) -> form&;
248
251 [[nodiscard]] virtual auto start_position() const noexcept -> xtd::forms::form_start_position;
256
259 [[nodiscard]] virtual auto status_bar() const noexcept -> std::optional<status_bar_ref>;
263 virtual auto status_bar(const xtd::forms::status_bar& value) -> form&;
267 virtual auto status_bar(xtd::null_ptr) -> form&;
268
271 [[nodiscard]] virtual auto tool_bar() const noexcept -> std::optional<tool_bar_ref>;
275 virtual auto tool_bar(const xtd::forms::tool_bar& value) -> form&;
279 virtual auto tool_bar(xtd::null_ptr) -> form&;
280
285 [[nodiscard]] virtual auto top_level() const noexcept -> bool;
290 virtual auto top_level(bool top_level) -> form&;
291
294 [[nodiscard]] virtual auto top_most() const noexcept -> bool;
298 virtual auto top_most(bool value) -> form&;
299
304 auto visible(bool visible) -> xtd::forms::control& override;
305
308 [[nodiscard]] virtual auto window_state() const noexcept -> xtd::forms::form_window_state;
312 virtual auto window_state(xtd::forms::form_window_state value) -> form&;
314
316
320 [[nodiscard]] static auto active_form() noexcept -> std::optional<xtd::forms::form_ref>;
322
324
328 auto activate() -> void;
329
330 auto bring_to_front() -> void override;
331
335 auto center_to_screen() -> void;
336
339 auto close() -> void;
340
341 auto pre_process_message(const xtd::forms::message& message) -> bool override;
342
345 virtual auto show_dialog() -> xtd::forms::dialog_result;
350
354 virtual auto show_sheet(const xtd::forms::iwin32_window& owner) -> void;
355
361
363
367 [[nodiscard]] static auto create() -> form;
371 [[nodiscard]] static auto create(const xtd::string& text) -> form;
376 [[nodiscard]] static auto create(const xtd::string& text, const xtd::drawing::point& location) -> form;
382 [[nodiscard]] static auto create(const xtd::string& text, const xtd::drawing::point& location, const xtd::drawing::size& size) -> form;
389 [[nodiscard]] static auto create(const xtd::string& text, const xtd::drawing::point& location, const xtd::drawing::size& size, const xtd::string& name) -> form;
394 [[nodiscard]] static auto create(const xtd::string& text, const xtd::drawing::size& size) -> form;
400 [[nodiscard]] static auto create(const xtd::string& text, const xtd::drawing::size& size, const xtd::string& name) -> form;
405 [[nodiscard]] static auto create(const xtd::string& text, xtd::forms::form_start_position start_position) -> form;
411 [[nodiscard]] static auto create(const xtd::string& text, xtd::forms::form_start_position start_position, const xtd::drawing::point& location) -> form;
418 [[nodiscard]] static auto create(const xtd::string& text, xtd::forms::form_start_position start_position, const xtd::drawing::point& location, const xtd::drawing::size& size) -> form;
426 [[nodiscard]] static auto create(const xtd::string& text, xtd::forms::form_start_position start_position, const xtd::drawing::point& location, const xtd::drawing::size& size, const xtd::string& name) -> form;
432 [[nodiscard]] static auto create(const xtd::string& text, xtd::forms::form_start_position start_position, const xtd::drawing::size& size) -> form;
439 [[nodiscard]] static auto create(const xtd::string& text, xtd::forms::form_start_position start_position, const xtd::drawing::size& size, const xtd::string& name) -> form;
441
443
448
452
456
461
462 protected:
463 friend class application;
464
466
468 auto create_params() const noexcept -> xtd::forms::create_params override;
469 auto default_size() const noexcept -> xtd::drawing::size override;
471
473
477 virtual auto on_activated(const xtd::event_args& e) -> void;
478
481 virtual auto on_deactivate(const xtd::event_args& e) -> void;
482
483 auto on_handle_created(const xtd::event_args& e) -> void override;
484 auto on_handle_destroyed(const xtd::event_args& e) -> void override;
485
488 virtual auto on_form_closed(const xtd::forms::form_closed_event_args& e) -> void;
489
493
494 auto on_layout(const xtd::event_args& e) -> void override;
495 auto on_location_changed(const xtd::event_args& e) -> void override;
496 auto on_paint(xtd::forms::paint_event_args& e) -> void override;
497 auto on_region_changed(const xtd::event_args& e) -> void override;
498
499 auto on_resize(const xtd::event_args& e) -> void override;
500 auto wnd_proc(xtd::forms::message& message) -> void override;
502
503 private:
504 friend class xtd::forms::application_context;
505 [[nodiscard]] auto closed_() const noexcept -> bool;
506 auto internal_set_window_state() -> void;
507
508 auto create_system_menu() -> void;
509 auto destroy_system_menu() -> void;
510
511 auto fill_in_create_params_border_icons(xtd::forms::create_params& cp) const -> void;
512 auto fill_in_create_params_border_styles(xtd::forms::create_params& cp) const -> void;
513 auto fill_in_create_params_start_position(xtd::forms::create_params& cp) const -> void;
514 auto fill_in_create_params_window_state(xtd::forms::create_params& cp) const -> void;
515
516 auto wm_activate(xtd::forms::message& message) -> void;
517 auto wm_close(xtd::forms::message& message) -> void;
518 auto wm_recreate(xtd::forms::message& message) -> void;
519 auto wm_syscolor_change(xtd::forms::message& message) -> void;
520
521 xtd::sptr<data> data_;
522 static std::optional<xtd::forms::form_ref> active_form_;
523 };
524 }
525}
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:23
Specifies the contextual information about an application thread.
Definition application_context.hpp:27
Provides static methods and properties to manage an application, such as methods to start and stop an...
Definition application.hpp:52
Provides focus-management functionality for controls that can function as a container for other contr...
Definition container_control.hpp:25
container_control()
Initializes a new instance of the container_control class.
Defines the base class for controls, which are components with visual representation.
Definition control.hpp:81
virtual auto size() const noexcept -> xtd::drawing::size
Gets the height and width of the control.
virtual auto text() const noexcept -> const xtd::string &
Gets the text associated with this control.
virtual auto name() const noexcept -> const xtd::string &
Gets the name of the control.
virtual auto location() const noexcept -> xtd::drawing::point
Gets the coordinates of the upper-left corner of the control relative to the upper-left corner of its...
Provides data for the form_closed event.
Definition form_closed_event_args.hpp:22
Provides data for the form_closing event.
Definition form_closing_event_args.hpp:22
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
auto on_paint(xtd::forms::paint_event_args &e) -> void override
Raises the xtd::forms::control::paint event.
auto on_handle_created(const xtd::event_args &e) -> void override
Raises the xtd::forms::control::handle_created event.
xtd::event< form, xtd::event_handler > activated
Occurs when the form is activated in code or by the user.
Definition form.hpp:447
auto accept_button() const noexcept -> std::optional< ibutton_control_ref >
Gets the button on the form that is clicked when the user presses the ENTER key.
virtual auto window_state() const noexcept -> xtd::forms::form_window_state
Gets a value that indicates whether form is minimized, maximized, or normal.
xtd::event< form, xtd::event_handler > deactivate
Occurs when the form loses focus and is no longer the active form.
Definition form.hpp:451
virtual auto dialog_result() const noexcept -> xtd::forms::dialog_result
Gets the dialog result for the form.
virtual auto on_deactivate(const xtd::event_args &e) -> void
Raises the form::deactivate event.
virtual auto show_in_taskbar() const noexcept -> bool
Gets a value indicating whether the form is displayed in the Windows taskbar.
auto bring_to_front() -> void override
Brings the control to the front of the z-order.
form()
Initializes a new instance of the Form class.
static auto create() -> form
A factory to create an xtd::forms::form.
virtual auto on_activated(const xtd::event_args &e) -> void
Raises the form::activated event.
static auto active_form() noexcept -> std::optional< xtd::forms::form_ref >
Gets the currently active form for this application.
virtual auto top_most() const noexcept -> bool
Gets a value indicating whether the form should be displayed as a topmost form.
auto on_handle_destroyed(const xtd::event_args &e) -> void override
Raises the xtd::forms::control::handle_destroyed event.
xtd::ref< xtd::forms::tool_bar > tool_bar_ref
Represent an xtd::forms::tool_bar reference.
Definition form.hpp:71
virtual auto icon() const noexcept -> const xtd::drawing::icon &
Gets the icon for the form.
auto parent(const xtd::forms::control &value) -> xtd::forms::control &override
Sets the parent container of the control.
auto on_layout(const xtd::event_args &e) -> void override
Raises the xtd::forms::control::layout event.
virtual auto show_dialog() -> xtd::forms::dialog_result
Shows the form as a modal dialog box.
virtual auto show_sheet_dialog(const xtd::forms::iwin32_window &owner) -> xtd::forms::dialog_result
Shows the form as a modal sheet dialog box.
auto close() -> void
Closes the form.
xtd::ref< xtd::forms::main_menu > main_menu_ref
Represent an xtd::forms::main_menu reference.
Definition form.hpp:65
virtual auto start_position() const noexcept -> xtd::forms::form_start_position
Gets the starting position of the form at run time.
auto on_region_changed(const xtd::event_args &e) -> void override
Raises the xtd::forms::control::region_changed event.
auto on_resize(const xtd::event_args &e) -> void override
Raises the xtd::forms::control::region event.
auto modal() const noexcept -> bool
Gets a value indicating whether this form is displayed modally.
virtual auto opacity() const noexcept -> double
Gets form opacity.
virtual auto show_sheet(const xtd::forms::iwin32_window &owner) -> void
Shows the form as a sheet dialog box.
virtual auto form_border_style() const noexcept -> xtd::forms::form_border_style
Gets the border style of the form.
xtd::ref< xtd::forms::ibutton_control > ibutton_control_ref
Represent an xtd::forms::ibutton_control reference.
Definition form.hpp:62
virtual auto show_icon() const noexcept -> bool
Gets a value indicating whether an icon is displayed in the caption bar of the form.
auto default_size() const noexcept -> xtd::drawing::size override
Gets the default size of the control.
xtd::event< form, xtd::forms::form_closed_event_handler > form_closed
Occurs after the form is closed.
Definition form.hpp:455
virtual auto auto_size_mode() const noexcept -> xtd::forms::auto_size_mode
Gets the mode by which the form automatically resizes itself.
auto on_location_changed(const xtd::event_args &e) -> void override
Raises the xtd::forms::control::location_changed event.
virtual auto menu() const noexcept -> std::optional< main_menu_ref >
Gets the main_menu that is displayed in the form.
virtual auto owner() const noexcept -> std::optional< xtd::forms::control_ref >
Gets the form that owns this form.
auto create_params() const noexcept -> xtd::forms::create_params override
Gets the required creation parameters when the control handle is created.
auto center_to_screen() -> void
Centers the position of the form within the bounds of the parent form.
xtd::event< form, xtd::forms::form_closing_event_handler > form_closing
Occurs before the form is closed.
Definition form.hpp:459
auto pre_process_message(const xtd::forms::message &message) -> bool override
Preprocesses keyboard or input messages within the message loop before they are dispatched.
virtual auto top_level() const noexcept -> bool
Gets a value indicating whether to display the form as a top-level window.
xtd::ref< xtd::forms::status_bar > status_bar_ref
Represent an xtd::forms::status_bar reference.
Definition form.hpp:68
auto font(xtd::null_ptr) -> control &override
Resets the font of the text displayed by the control.
virtual auto maximize_box() const noexcept -> bool
Gets a value indicating whether the Maximize button is displayed in the caption bar of the form.
virtual auto on_form_closed(const xtd::forms::form_closed_event_args &e) -> void
Raises the form::form_closed event.
virtual auto minimize_box() const noexcept -> bool
Gets a value indicating whether the Minimize button is displayed in the caption bar of the form.
auto wnd_proc(xtd::forms::message &message) -> void override
Processes Windows messages.
auto visible(bool visible) -> xtd::forms::control &override
Sets a value indicating whether the control and all its child controls are displayed.
auto cancel_button() const noexcept -> std::optional< ibutton_control_ref >
Gets the button control that is clicked when the user presses the ESC key.
virtual auto close_box() const noexcept -> bool
Gets a value indicating whether a close box is displayed in the caption bar of the form.
auto activate() -> void
Activates the form and gives it focus.
virtual auto on_form_closing(xtd::forms::form_closing_event_args &e) -> void
Raises the form::form_closing event.
virtual auto tool_bar() const noexcept -> std::optional< tool_bar_ref >
Gets the tool_bar that is displayed in the form.
virtual auto help_button() const -> bool
Gets a value indicating whether a Help button should be displayed in the caption box of the form.
virtual auto control_box() const noexcept -> bool
Gets a value indicating whether a control box is displayed in the caption bar of the form.
virtual auto status_bar() const noexcept -> std::optional< status_bar_ref >
Gets the status_bar that is displayed in the form.
Allows a control to act like a button on a form.
Definition ibutton_control.hpp:26
Provides an interface to expose Win32 HWND handles.
Definition iwin32_window.hpp:23
Represents the menu structure of a form.
Definition main_menu.hpp:41
Provides data for the xtd::forms::control::paint event.
Definition paint_event_args.hpp:26
Contains xtd::forms::form_ref alias.
Contains xtd::forms::container_control class.
Contains xtd::forms::dialog_result enum class.
Contains xtd::forms::form_border_style enum class.
Contains xtd::forms::form_closed_event_args event handler.
Contains xtd::forms::form_closing_event_handler event handler.
Contains xtd::forms::form_ref alias.
Contains xtd::forms::form_start_position enum class.
Contains xtd::forms::form_window_state enum class.
generic_event_handler< const xtd::event_args & > event_handler
Represents the method that will handle an event that has no event data.
Definition event_handler.hpp:24
xtd::delegate< void(xtd::object &sender, xtd::forms::form_closing_event_args &e)> form_closing_event_handler
Represents the method that handles a form_closing event.
Definition form_closing_event_handler.hpp:27
xtd::delegate< void(xtd::object &sender, const xtd::forms::form_closed_event_args &e)> form_closed_event_handler
Represents the method that handles a form_closed event.
Definition form_closed_event_handler.hpp:27
#define forms_export_
Define shared library export.
Definition forms_export.hpp:13
xtd::shared_ptr_object< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
std::nullptr_t null_ptr
Represents the null_opt alias on std::nullptr_t.
Definition null_ptr.hpp:19
xtd::reference_wrapper_object< type_t > ref
The xtd::ref object is a reference wrapper.
Definition ref.hpp:25
std::optional< type_t > optional
Represents the optional alias on std::optional.
Definition optional.hpp:26
form_window_state
Specifies how a form window is displayed.
Definition form_window_state.hpp:22
xtd::ref< xtd::forms::control > control_ref
Represents a control reference.
Definition control_ref.hpp:25
form_start_position
Specifies the initial position of a form.
Definition form_start_position.hpp:22
xtd::ref< xtd::forms::form > form_ref
Represent an xtd::forms::form reference.
Definition form_ref.hpp:25
Contains xtd::forms::ibutton_control interface.
Contains xtd::forms::main_menu menu.
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition texts.hpp:219
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
constexpr auto data() const noexcept -> const_pointer
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:197
Contains xtd::forms::screen component.
Contains xtd::forms::status_bar container.
Implements a Windows message.
Definition message.hpp:33
Contains xtd::forms::tool_bar container.