xtd 0.2.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;
29 class application_context;
30 class form;
32
55 struct data;
56
57 public:
59
62 using ibutton_control_ref = std::reference_wrapper<xtd::forms::ibutton_control>;
63
65 using main_menu_ref = std::reference_wrapper<xtd::forms::main_menu>;
66
68 using status_bar_ref = std::reference_wrapper<xtd::forms::status_bar>;
69
71 using tool_bar_ref = std::reference_wrapper<xtd::forms::tool_bar>;
73
75
81
83
87 std::optional<ibutton_control_ref> accept_button() const noexcept;
91 form& accept_button(const ibutton_control& value);
95 form& accept_button(std::nullptr_t);
96
99 virtual forms::auto_size_mode auto_size_mode() const noexcept;
104
107 std::optional<ibutton_control_ref> cancel_button() const noexcept;
111 form& cancel_button(const ibutton_control& value);
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
221 using container_control::parent;
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;
254 virtual form& start_position(form_start_position value);
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
299 using container_control::visible;
303 control& visible(bool visible) override;
304
307 virtual form_window_state window_state() const noexcept;
311 virtual form& window_state(form_window_state value);
313
315
319 static std::optional<form_ref> active_form() noexcept;
321
323
327 void activate();
328
329 void bring_to_front() override;
330
334 void center_to_screen();
335
338 void close();
339
340 bool pre_process_message(const xtd::forms::message& message) override;
341
344 virtual forms::dialog_result show_dialog();
348 virtual forms::dialog_result show_dialog(const iwin32_window& owner);
349
353 virtual void show_sheet(const iwin32_window& owner);
354
358 virtual forms::dialog_result show_sheet_dialog(const iwin32_window& owner);
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);
404 static form create(const xtd::string& text, form_start_position start_position);
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);
431 static form create(const xtd::string& text, form_start_position start_position, const drawing::size& size);
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
493 virtual void on_form_closed(const form_closed_event_args& e);
494
497 virtual void on_form_closing(form_closing_event_args& e);
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:26
Provides static methods and properties to manage an application, such as methods to start and stop an...
Definition application.hpp:51
Provides focus-management functionality for controls that can function as a container for other contr...
Definition container_control.hpp:25
Defines the base class for controls, which are components with visual representation.
Definition control.hpp:81
Encapsulates the information needed when creating a control.
Definition create_params.hpp:29
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
std::reference_wrapper< xtd::forms::main_menu > main_menu_ref
Represent an xtd::forms::main_menu reference.
Definition form.hpp:65
form()
Initializes a new instance of the Form class.
std::reference_wrapper< xtd::forms::ibutton_control > ibutton_control_ref
Represent an xtd::forms::ibutton_control reference.
Definition form.hpp:62
std::reference_wrapper< xtd::forms::tool_bar > tool_bar_ref
Represent an xtd::forms::tool_bar reference.
Definition form.hpp:71
std::reference_wrapper< xtd::forms::status_bar > status_bar_ref
Represent an xtd::forms::status_bar reference.
Definition form.hpp:68
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.
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
Represents the base functionality for all menus. Although tool_strip_drop_down and tool_strip_drop_do...
Definition menu.hpp:37
Implements a Windows message.
Definition message.hpp:28
Provides data for the xtd::forms::control::paint event.
Definition paint_event_args.hpp:30
Represents a Windows status bar control.
Definition status_bar.hpp:48
Represents a Windows toolbar.
Definition tool_bar.hpp:52
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<> event_handler
Represents the method that will handle an event that has no event data.
Definition event_handler.hpp:32
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:24
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:25
#define forms_export_
Define shared library export.
Definition forms_export.hpp:13
xtd::forms::style_sheets::control form
The form data allows you to specify the box of a form control.
Definition form.hpp:23
std::optional< type_t > optional
Represents the null_opt alias on std::nullopt_t.
Definition optional.hpp:181
std::unique_ptr< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.hpp:25
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
std::shared_ptr< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
std::reference_wrapper< form > form_ref
Represent an xtd::forms::form reference.
Definition form_ref.hpp:25
dialog_result
Specifies identifiers to indicate the return value of a dialog box.
Definition dialog_result.hpp:43
form_window_state
Specifies how a form window is displayed.
Definition form_window_state.hpp:22
auto_size_mode
Specifies how a control will behave when its auto_size property is enabled.
Definition auto_size_mode.hpp:22
form_start_position
Specifies the initial position of a form.
Definition form_start_position.hpp:22
form_border_style
Specifies the border styles for a form.
Definition form_border_style.hpp:22
std::reference_wrapper< control > control_ref
Represents a control reference.
Definition control_ref.hpp:25
Contains xtd::forms::ibutton_control interface.
Contains xtd::forms::main_menu menu.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.hpp:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Contains xtd::forms::screen component.
Contains xtd::forms::style_sheets::status_bar class.
Contains xtd::forms::tool_bar container.