xtd 0.2.0
application.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "../forms_export.hpp"
9#include "form_collection.hpp"
10#include "imessage_filter.hpp"
11#include "message.hpp"
13#include <xtd/delegate>
14#include <xtd/event_args>
15#include <xtd/static>
16#include <cstdint>
17#include <memory>
18#include <vector>
19
21namespace xtd {
23 namespace forms {
25 class input_dialog;
26 class message_box;
28
52 public:
54
59 static bool allow_quit() noexcept;
60
65
70 static bool button_images() noexcept;
71
77 static void button_images(bool value);
78
84 static xtd::string common_app_data_path() noexcept;
85
86 /*
90 static microsoft::win32::registry_key common_app_data_registry();
91 */
92
102 static xtd::string company_name() noexcept;
103
106 static bool dark_mode() noexcept;
107
111 static void dark_mode(bool value);
112
116 [[deprecated("Replaced by xtd::application::dark_mode - Will be removed in version 0.4.0.")]]
117 static bool dark_mode_enabled() noexcept;
118
121 static xtd::string executable_name() noexcept;
122
125 static xtd::string executable_path() noexcept;
126
133 static bool font_size_correction();
134
141 static void font_size_correction(bool value);
142
146 static bool keep_cloned_controls() noexcept;
147
152 static void keep_cloned_controls(bool value);
153
156 static bool light_mode() noexcept;
157
161 static void light_mode(bool value);
162
166 [[deprecated("Replaced by xtd::application::light_mode - Will be removed in version 0.4.0.")]]
167 static bool light_mode_enabled() noexcept;
168
173
178 static bool menu_images() noexcept;
179
185 static void menu_images(bool value);
186
189 static bool message_loop() noexcept;
190
194 static const form_collection open_forms() noexcept;
195
198 static xtd::string product_name() noexcept;
199
202 static xtd::string product_version() noexcept;
203
206 static xtd::string startup_path() noexcept;
207
211 static const xtd::forms::style_sheets::style_sheet& style_sheet() noexcept;
215 static void style_sheet(const xtd::forms::style_sheets::style_sheet& value);
219 static const xtd::forms::style_sheets::style_sheet::style_sheets_t& style_sheets() noexcept;
220
224 static const xtd::forms::style_sheets::style_sheet::style_sheet_names_t& style_sheet_names() noexcept;
225
230 static bool system_controls() noexcept;
231
237 static void system_controls(bool value);
238
245 static bool system_font_size() noexcept;
246
253 static void system_font_size(bool value);
254
260
266 static xtd::string user_app_data_path() noexcept;
267
268 /*
273 static microsoft::win32::registry_key user_app_data_registry();
274 */
275
280 [[deprecated("Replaced by xtd::application::visual_styles - Will be removed in version 0.4.0.")]]
281 static bool use_visual_styles() noexcept;
282
289 static bool use_wait_cursor() noexcept;
297
302 static bool visual_styles() noexcept;
303
309 static void visual_styles(bool value);
311
313
318 static event<application, delegate<void(const event_args&)>> application_exit;
319
322 static event<application, delegate<void(const event_args&)>> enter_thread_modal;
323
330 static event<application, delegate<void(const event_args&)>> idle;
331
334 static event<application, delegate<void(const event_args&)>> leave_thread_modal;
335
336 /*
342 static event<threading::thread_exception_event_handler> thread_exception;
343 */
344
348 static event<application, delegate<void(const event_args&)>> thread_exit;
350
352
357 static void add_message_filter(const imessage_filter& value);
358
364 static void do_events();
365
370 [[deprecated("Replaced by xtd::application::button_images - Will be removed in version 0.4.0.")]]
371 static void enable_button_images();
372
378 [[deprecated("Replaced by xtd::application::dark_mode - Will be removed in version 0.4.0.")]]
379 static void enable_dark_mode();
380
386 [[deprecated("Replaced by xtd::application::light_mode - Will be removed in version 0.4.0.")]]
387 static void enable_light_mode();
388
393 [[deprecated("Replaced by xtd::application::menu_images - Will be removed in version 0.4.0.")]]
394 static void enable_menu_images();
395
400 static void enable_visual_styles();
401
407 static void exit();
408
415 static void exit(cancel_event_args& e);
416
419 static void exit_thread();
420
427
430 static void raise_idle(const event_args& e);
431
436
440 static void remove_message_filter(const imessage_filter& value);
441
448 static void restart();
449
456 static void run();
457
464 static void run(xtd::forms::application_context& context);
465
473 static void run(const form& main_form);
474
475 /*
481 static void set_unhandled_exception_mode (unhandled_exception_mode mode);
482 */
483
484 /*
493 static void set_unhandled_exception_mode (unhandled_exception_mode mode, bool thread_scope);
494 */
496
498 static auto __opaque_crt_prv_msg__(intptr, int32, intptr, intptr, intptr, intptr) noexcept;
500
501 private:
502 friend class form;
503 friend class input_dialog;
504 friend class message_box;
505
506 static bool close_open_forms();
507 static void on_app_thread_exit(object& sender, const event_args& e);
508 static bool on_app_thread_exception();
509 static void raise_enter_thread_modal(const event_args& e);
510 static void raise_leave_thread_modal(const event_args& e);
511 static intptr wnd_proc_(intptr hwnd, int32 msg, intptr wparam, intptr lparam, intptr handle);
512 static void wnd_proc(message& message);
513 static void wm_activate_app(message& message);
514 static void wm_app_idle(message& message);
515 static void wm_quit(message& message);
516
517 static xtd::forms::application_context internal_context_;
518 static xtd::forms::application_context* context_;
519 static bool button_images_;
520 static bool keep_cloned_controls_;
521 static bool light_mode_;
522 static bool font_size_correction_;
523 static bool menu_images_;
524 static bool message_loop_;
525 static bool raise_idle_;
526 static bool system_controls_;
527 static bool system_font_size_;
528 static bool use_wait_cursor_;
529 static bool visual_styles_;
530 };
531 }
532}
Contains xtd::forms::application_context class.
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
Provides static methods and properties to manage an application, such as methods to start and stop an...
Definition application.hpp:51
static void enable_dark_mode()
Enables dark mode for the application.
static bool menu_images() noexcept
Gets menu images are enabled.
friend class form
The form data allows you to specify the box of a form control.
Definition application.hpp:502
static xtd::string executable_name() noexcept
Gets the executable name for the executable file that started the application, including the executab...
static void do_events()
Processes all Windows messages currently in the message queue.
static const xtd::forms::style_sheets::style_sheet & style_sheet() noexcept
Gets current xtd::forms::style_sheets::style_sheet style sheet.
static void exit()
Informs all message pumps that they must terminate, and then closes all application windows after the...
static const xtd::forms::style_sheets::style_sheet::style_sheets_t & style_sheets() noexcept
Gets the installed xtd::forms::style_sheets::style_sheet style sheets.
static xtd::string executable_path() noexcept
Gets the path for the executable file that started the application, including the executable name.
static bool dark_mode_enabled() noexcept
Return true if dark mode is enabled for the application; otherwise return false.
static bool system_font_size() noexcept
Gets a value indicating whether the system font size is enabled.
static std::optional< form_ref > main_form()
Gets the optional main form owned by the application.
static bool light_mode_enabled() noexcept
Return true if dark mode is enabled for the application; otherwise return false.
static xtd::string common_app_data_path() noexcept
Gets the path for the application data that is shared among all users.
static bool system_controls() noexcept
Gets a value indicating whether the system control is enabled.
static event< application, delegate< void(const event_args &)> > enter_thread_modal
Occurs when the application is about to enter a modal state.
Definition application.hpp:322
static bool visual_styles() noexcept
Gets a value that indicates whether visual styles are enabled for the application.
static void enable_menu_images()
Enables menu images for the application.
static xtd::string user_app_data_path() noexcept
Gets the path for the application data of a user.
static void run()
Begins running a standard application message loop on the current thread, without a form.
static void add_message_filter(const imessage_filter &value)
Adds a message filter to monitor Windows messages as they are routed to their destinations.
static xtd::forms::application_context & application_context()
Gets the application context associate to the application.
static event< application, delegate< void(const event_args &)> > thread_exit
Occurs when a thread is about to shut down. When the main thread for an application is about to be sh...
Definition application.hpp:348
static xtd::string product_version() noexcept
Gets the product version associated with this application.
static void raise_idle(const event_args &e)
Raises the Idle event.
static bool use_wait_cursor() noexcept
Gets whether the wait cursor is used for all open forms of the application.
static void enable_visual_styles()
Enables visual styles for the application.
static xtd::string company_name() noexcept
Gets the company name associated with the application.
static xtd::forms::style_sheets::style_sheet get_style_sheet_from_name(const xtd::string &name)
Gets the installed xtd::forms::style_sheets::style_sheet style sheet from specified name.
static bool light_mode() noexcept
Gets a value indicating whether light mode is enabled for the application.
static event< application, delegate< void(const event_args &)> > leave_thread_modal
Occurs when the application is about to leave a modal state.
Definition application.hpp:334
static bool button_images() noexcept
Gets button images are enabled.
static void exit_thread()
Exits the message loop on the current thread and closes all windows on the thread.
static xtd::string startup_path() noexcept
Gets the path for the executable file that started the application, not including the executable name...
static xtd::string product_name() noexcept
Gets the product name associated with this application.
static event< application, delegate< void(const event_args &)> > idle
Occurs when the application finishes processing and is about to enter the idle state.
Definition application.hpp:330
static bool keep_cloned_controls() noexcept
Gets a value indicating whether the xtd framework keep cloned control is enabled.
static void restart()
Shuts down the application and starts a new instance immediately.
static bool allow_quit() noexcept
Gets a value indicating whether the caller can quit this application.
static const xtd::forms::style_sheets::style_sheet & system_style_sheet() noexcept
Gets system xtd::forms::style_sheets::style_sheet style sheet.
static bool use_visual_styles() noexcept
Gets a value that indicates whether visual styles are enabled for the application.
static bool dark_mode() noexcept
Gets a value indicating whether dark mode is enabled for the application.
static const form_collection open_forms() noexcept
Gets a collection of open forms owned by the application.
static void enable_light_mode()
Enables light mode for the application.
static void enable_button_images()
Enables button images for the application.
static bool font_size_correction()
Gets a value indicating whether font size correction is enabled.
static void remove_message_filter(const imessage_filter &value)
Removes a message filter from the message pump of the application.
static bool message_loop() noexcept
Gets a value indicating whether a message loop exists on this thread.
static const xtd::forms::style_sheets::style_sheet::style_sheet_names_t & style_sheet_names() noexcept
Gets the installed xtd::forms::style_sheets::style_sheet style sheet names.
static event< application, delegate< void(const event_args &)> > application_exit
Occurs when the application is about to shut down.
Definition application.hpp:318
static void register_message_loop_callback(message_loop_callback callback)
Registers a callback for checking whether the message loop is running in hosted environments.
Provides data for a cancelable event.
Definition cancel_event_args.hpp:22
Defines a message filter interface.
Definition imessage_filter.hpp:24
Represents a common dialog box that displays input dialog.
Definition input_dialog.hpp:38
Displays a message window, also known as a dialog box, which presents a message to the user....
Definition message_box.hpp:40
Contains xtd::forms::form_collection alias.
Contains forms_export_ keyword.
Contains namespace aliases.
xtd::delegate< bool()> message_loop_callback
Represents a method that will check whether the hosting environment is still sending messages.
Definition message_loop_callback.hpp:26
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition static.hpp:37
#define forms_export_
Define shared library export.
Definition forms_export.hpp:13
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
intmax_t intptr
Represent a pointer or a handle.
Definition intptr.hpp:23
std::optional< type_t > optional
Represents the optional alias on std::optional.
Definition optional.hpp:25
std::vector< std::reference_wrapper< form > > form_collection
Represents a collection of form objects.
Definition form_collection.hpp:24
std::reference_wrapper< form > form_ref
Represent an xtd::forms::form reference.
Definition form_ref.hpp:25
@ e
The E key.
Definition keys.hpp:207
Contains xtd::forms::imessage_filter interface.
Contains xtd::forms::message class.
Contains xtd::forms::message_loop_callback delegate.
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
Implements a Windows message.
Definition message.hpp:33
Contains xtd::forms::style_sheets::style_sheet class.