xtd 0.2.0
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 std::optional<ibutton_control_ref> accept_button() const noexcept;
95 form& accept_button(std::nullptr_t);
96
99 virtual forms::auto_size_mode auto_size_mode() const noexcept;
104
115 form& cancel_button(std::nullptr_t);
116
119 virtual bool close_box() const noexcept;
123 virtual form& close_box(bool value);
124
127 virtual bool control_box() const noexcept;
131 virtual form& control_box(bool value);
132
135 virtual forms::dialog_result dialog_result() const noexcept;
140
142 using container_control::font;
143 control& font(std::nullptr_t) override;
145
148 virtual forms::form_border_style form_border_style() const noexcept;
153
156 virtual bool help_button() const;
160 virtual form& help_button(bool value);
161
164 virtual const xtd::drawing::icon& icon() const noexcept;
168 virtual form& icon(const xtd::drawing::icon& value);
169
172 virtual bool maximize_box() const noexcept;
176 virtual form& maximize_box(bool value);
177
180 virtual std::optional<main_menu_ref> menu() const noexcept;
184 virtual form& menu(const forms::main_menu& value);
188 virtual form& menu(std::nullptr_t);
189
192 virtual bool minimize_box() const noexcept;
196 virtual form& minimize_box(bool value);
197
200 bool modal() const noexcept;
201
204 virtual double opacity() const noexcept;
207 virtual form& opacity(double opacity);
208
211 virtual std::optional<control_ref> owner() const noexcept;
215 virtual form& owner(const control& value);
219 virtual form& owner(std::nullptr_t);
220
224 control& parent(const control& value) override;
225
228 virtual bool show_icon() const noexcept;
232 virtual form& show_icon(bool value);
233
239 virtual bool show_in_taskbar() const noexcept;
246 virtual form& show_in_taskbar(bool value);
247
250 virtual form_start_position start_position() const noexcept;
255
258 virtual std::optional<status_bar_ref> status_bar() const noexcept;
262 virtual form& status_bar(const forms::status_bar& value);
266 virtual form& status_bar(std::nullptr_t);
267
270 virtual std::optional<tool_bar_ref> tool_bar() const noexcept;
274 virtual form& tool_bar(const forms::tool_bar& value);
278 virtual form& tool_bar(std::nullptr_t);
279
284 virtual bool top_level() const noexcept;
289 virtual form& top_level(bool top_level);
290
293 virtual bool top_most() const noexcept;
297 virtual form& top_most(bool value);
298
303 control& visible(bool visible) override;
304
307 virtual form_window_state window_state() const noexcept;
313
315
319 static std::optional<form_ref> active_form() noexcept;
321
323
327 void activate();
328
329 void bring_to_front() override;
330
335
338 void close();
339
340 bool pre_process_message(const xtd::forms::message& message) override;
341
349
353 virtual void show_sheet(const iwin32_window& owner);
354
360
362
366 static form create();
370 static form create(const xtd::string& text);
375 static form create(const xtd::string& text, const drawing::point& location);
381 static form create(const xtd::string& text, const drawing::point& location, const drawing::size& size);
388 static form create(const xtd::string& text, const drawing::point& location, const drawing::size& size, const xtd::string& name);
393 static form create(const xtd::string& text, const drawing::size& size);
399 static form create(const xtd::string& text, const drawing::size& size, const xtd::string& name);
410 static form create(const xtd::string& text, form_start_position start_position, const drawing::point& location);
417 static form create(const xtd::string& text, form_start_position start_position, const drawing::point& location, const drawing::size& size);
425 static form create(const xtd::string& text, form_start_position start_position, const drawing::point& location, const drawing::size& size, const xtd::string& name);
438 static form create(const xtd::string& text, form_start_position start_position, const drawing::size& size, const xtd::string& name);
440
442
447
451
455
460
461 protected:
462 friend class application;
463
465
467 forms::create_params create_params() const noexcept override;
468 drawing::size default_size() const noexcept override;
470
472
478 xtd::uptr<xtd::object> clone() const override;
479
482 virtual void on_activated(const event_args& e);
483
486 virtual void on_deactivate(const event_args& e);
487
488 void on_handle_created(const event_args& e) override;
489 void on_handle_destroyed(const event_args& e) override;
490
494
498
499 void on_layout(const event_args& e) override;
500 void on_location_changed(const event_args& e) override;
501 void on_paint(paint_event_args& e) override;
502 void on_region_changed(const event_args& e) override;
503
504 void on_resize(const event_args& e) override;
505 void wnd_proc(message& message) override;
507
508 private:
509 friend class application_context;
510 bool closed_() const noexcept;
511 void internal_set_window_state();
512
513 void create_system_menu();
514 void destroy_system_menu();
515
516 void fill_in_create_params_border_icons(xtd::forms::create_params& cp) const;
517 void fill_in_create_params_border_styles(xtd::forms::create_params& cp) const;
518 void fill_in_create_params_start_position(xtd::forms::create_params& cp) const;
519 void fill_in_create_params_window_state(xtd::forms::create_params& cp) const;
520
521 void wm_activate(message& message);
522 void wm_close(message& message);
523 void wm_recreate(message& message);
524 void wm_syscolor_change(message& message);
525
526 xtd::sptr<data> data_;
527 static std::optional<form_ref> active_form_;
528 };
529 }
530}
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
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:51
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 drawing::font font() const noexcept
Gets the font of the text displayed by the control.
virtual const xtd::string & name() const noexcept
Gets the name of the control.
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
void center_to_screen()
Centers the position of the form within the bounds of the parent form.
virtual bool show_icon() const noexcept
Gets a value indicating whether an icon is displayed in the caption bar of the form.
virtual std::optional< control_ref > owner() const noexcept
Gets the form that owns this form.
event< form, form_closing_event_handler > form_closing
Occurs before the form is closed.
Definition form.hpp:458
void activate()
Activates the form and gives it focus.
virtual forms::dialog_result show_dialog()
Shows the form as a modal dialog box.
virtual void on_form_closing(form_closing_event_args &e)
Raises the form::form_closing event.
void on_handle_destroyed(const event_args &e) override
Raises the xtd::forms::control::handle_destroyed event.
control & visible(bool visible) override
Sets a value indicating whether the control and all its child controls are displayed.
void bring_to_front() override
Brings the control to the front of the z-order.
virtual void on_activated(const event_args &e)
Raises the form::activated event.
form()
Initializes a new instance of the Form class.
xtd::ref< xtd::forms::tool_bar > tool_bar_ref
Represent an xtd::forms::tool_bar reference.
Definition form.hpp:71
forms::create_params create_params() const noexcept override
Gets the required creation parameters when the control handle is created.
std::optional< ibutton_control_ref > cancel_button() const noexcept
Gets the button control that is clicked when the user presses the ESC key.
virtual bool maximize_box() const noexcept
Gets a value indicating whether the Maximize button is displayed in the caption bar of the form.
bool pre_process_message(const xtd::forms::message &message) override
Preprocesses keyboard or input messages within the message loop before they are dispatched.
bool modal() const noexcept
Gets a value indicating whether this form is displayed modally.
virtual void on_deactivate(const event_args &e)
Raises the form::deactivate event.
drawing::size default_size() const noexcept override
Gets the default size of the control.
virtual bool show_in_taskbar() const noexcept
Gets a value indicating whether the form is displayed in the Windows taskbar.
event< form, form_closed_event_handler > form_closed
Occurs after the form is closed.
Definition form.hpp:454
event< form, event_handler > activated
Occurs when the form is activated in code or by the user.
Definition form.hpp:446
xtd::ref< xtd::forms::main_menu > main_menu_ref
Represent an xtd::forms::main_menu reference.
Definition form.hpp:65
virtual forms::form_border_style form_border_style() const noexcept
Gets the border style of the form.
virtual forms::dialog_result dialog_result() const noexcept
Gets the dialog result for the form.
virtual void show_sheet(const iwin32_window &owner)
Shows the form as a sheet dialog box.
virtual std::optional< status_bar_ref > status_bar() const noexcept
Gets the status_bar that is displayed in the form.
void on_handle_created(const event_args &e) override
Raises the xtd::forms::control::handle_created event.
virtual std::optional< tool_bar_ref > tool_bar() const noexcept
Gets the tool_bar that is displayed in the form.
xtd::ref< xtd::forms::ibutton_control > ibutton_control_ref
Represent an xtd::forms::ibutton_control reference.
Definition form.hpp:62
void on_layout(const event_args &e) override
Raises the xtd::forms::control::layout event.
virtual void on_form_closed(const form_closed_event_args &e)
Raises the form::form_closed event.
void close()
Closes the form.
static std::optional< form_ref > active_form() noexcept
Gets the currently active form for this application.
virtual const xtd::drawing::icon & icon() const noexcept
Gets the icon for the form.
virtual forms::auto_size_mode auto_size_mode() const noexcept
Gets the mode by which the form automatically resizes itself.
virtual bool control_box() const noexcept
Gets a value indicating whether a control box is displayed in the caption bar of the form.
virtual form_start_position start_position() const noexcept
Gets the starting position of the form at run time.
xtd::ref< xtd::forms::status_bar > status_bar_ref
Represent an xtd::forms::status_bar reference.
Definition form.hpp:68
virtual bool close_box() const noexcept
Gets a value indicating whether a close box is displayed in the caption bar of the form.
virtual bool minimize_box() const noexcept
Gets a value indicating whether the Minimize button is displayed in the caption bar of the form.
void wnd_proc(message &message) override
Processes Windows messages.
virtual form_window_state window_state() const noexcept
Gets a value that indicates whether form is minimized, maximized, or normal.
virtual bool help_button() const
Gets a value indicating whether a Help button should be displayed in the caption box of the form.
virtual forms::dialog_result show_sheet_dialog(const iwin32_window &owner)
Shows the form as a modal sheet dialog box.
xtd::uptr< xtd::object > clone() const override
Creates a new object that is a copy of the current instance.
control & parent(const control &value) override
Sets the parent container of the control.
virtual bool top_level() const noexcept
Gets a value indicating whether to display the form as a top-level window.
event< form, event_handler > deactivate
Occurs when the form loses focus and is no longer the active form.
Definition form.hpp:450
virtual bool top_most() const noexcept
Gets a value indicating whether the form should be displayed as a topmost form.
static form create()
A factory to create an xtd::forms::form.
void on_paint(paint_event_args &e) override
Raises the xtd::forms::control::paint event.
std::optional< ibutton_control_ref > accept_button() const noexcept
Gets the button on the form that is clicked when the user presses the ENTER key.
virtual double opacity() const noexcept
Gets form opacity.
virtual std::optional< main_menu_ref > menu() const noexcept
Gets the main_menu that is displayed in the form.
void on_region_changed(const event_args &e) override
Raises the xtd::forms::control::region_changed event.
void on_location_changed(const event_args &e) override
Raises the xtd::forms::control::location_changed event.
void on_resize(const event_args &e) override
Raises the xtd::forms::control::region event.
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:42
Provides data for the xtd::forms::control::paint event.
Definition paint_event_args.hpp:30
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.
xtd::delegate< void(object &sender, 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(object &sender, const 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
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
#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
xtd::unique_ptr_object< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.hpp:25
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 null_opt alias on std::nullopt_t.
Definition optional.hpp:175
xtd::ref< control > control_ref
Represents a control reference.
Definition control_ref.hpp:25
form_window_state
Specifies how a form window is displayed.
Definition form_window_state.hpp:22
xtd::ref< form > form_ref
Represent an xtd::forms::form reference.
Definition form_ref.hpp:25
form_start_position
Specifies the initial position of a form.
Definition form_start_position.hpp:22
@ e
The E key.
Definition keys.hpp:207
@ location
Specifies that both the x and y coordinates of the control are defined.
Definition bounds_specified.hpp:30
@ size
Specifies that both the width and height property values of the control are defined.
Definition bounds_specified.hpp:36
@ text
The xtd::forms::status_bar_panel displays text in the standard font.
Definition status_bar_panel_style.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:217
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
constexpr const_pointer data() const noexcept
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:201
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.