xtd 0.2.0
Loading...
Searching...
No Matches
application.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "../forms_export.hpp"
10#include "form_collection.hpp"
11#include "imessage_filter.hpp"
12#include "message.hpp"
14#include <xtd/delegate>
15#include <xtd/event_handler>
16#include <xtd/static>
17#include <cstdint>
18#include <memory>
19#include <vector>
20
22namespace xtd {
24 namespace forms {
26 class input_dialog;
27 class message_box;
29
53 public:
55
60 static bool allow_quit() noexcept;
61
66
71 static bool button_images() noexcept;
72
78 static void button_images(bool value);
79
85 static xtd::string common_app_data_path() noexcept;
86
87 /*
91 static microsoft::win32::registry_key common_app_data_registry();
92 */
93
103 static xtd::string company_name() noexcept;
104
107 static bool dark_mode() noexcept;
108
112 static void dark_mode(bool value);
113
117 [[deprecated("Replaced by xtd::application::dark_mode - Will be removed in version 0.4.0.")]]
118 static bool dark_mode_enabled() noexcept;
119
122 static xtd::string executable_name() noexcept;
123
126 static xtd::string executable_path() noexcept;
127
134 static bool font_size_correction();
135
142 static void font_size_correction(bool value);
143
147 static bool keep_cloned_controls() noexcept;
148
153 static void keep_cloned_controls(bool value);
154
157 static bool light_mode() noexcept;
158
162 static void light_mode(bool value);
163
167 [[deprecated("Replaced by xtd::application::light_mode - Will be removed in version 0.4.0.")]]
168 static bool light_mode_enabled() noexcept;
169
174
179 static bool menu_images() noexcept;
180
186 static void menu_images(bool value);
187
190 static bool message_loop() noexcept;
191
195 static const form_collection open_forms() noexcept;
196
199 static xtd::string product_name() noexcept;
200
203 static xtd::string product_version() noexcept;
204
207 static xtd::string startup_path() noexcept;
208
212 static const xtd::forms::style_sheets::style_sheet& style_sheet() noexcept;
216 static void style_sheet(const xtd::forms::style_sheets::style_sheet& value);
220 static const xtd::forms::style_sheets::style_sheet::style_sheets_t& style_sheets() noexcept;
221
225 static const xtd::forms::style_sheets::style_sheet::style_sheet_names_t& style_sheet_names() noexcept;
226
231 static bool system_controls() noexcept;
232
238 static void system_controls(bool value);
239
246 static bool system_font_size() noexcept;
247
254 static void system_font_size(bool value);
255
261
267 static xtd::string user_app_data_path() noexcept;
268
269 /*
274 static microsoft::win32::registry_key user_app_data_registry();
275 */
276
281 [[deprecated("Replaced by xtd::application::visual_styles - Will be removed in version 0.4.0.")]]
282 static bool use_visual_styles() noexcept;
283
290 static bool use_wait_cursor() noexcept;
298
303 static bool visual_styles() noexcept;
304
310 static void visual_styles(bool value);
312
314
320
324
332
336
345 static event<application, threading::thread_exception_event_handler> thread_exception;
346
352
354
359 static void add_message_filter(const imessage_filter& value);
360
366 static void do_events();
367
372 [[deprecated("Replaced by xtd::application::button_images - Will be removed in version 0.4.0.")]]
373 static void enable_button_images();
374
380 [[deprecated("Replaced by xtd::application::dark_mode - Will be removed in version 0.4.0.")]]
381 static void enable_dark_mode();
382
388 [[deprecated("Replaced by xtd::application::light_mode - Will be removed in version 0.4.0.")]]
389 static void enable_light_mode();
390
395 [[deprecated("Replaced by xtd::application::menu_images - Will be removed in version 0.4.0.")]]
396 static void enable_menu_images();
397
402 static void enable_visual_styles();
403
409 static void exit();
410
417 static void exit(cancel_event_args& e);
418
421 static void exit_thread();
422
429
432 static void raise_idle(const event_args& e);
433
438
442 static void remove_message_filter(const imessage_filter& value);
443
450 static void restart();
451
458 static void run();
459
466 static void run(xtd::forms::application_context& context);
467
475 static void run(const form& main_form);
476
477 /*
483 static void set_unhandled_exception_mode (unhandled_exception_mode mode);
484 */
485
486 /*
495 static void set_unhandled_exception_mode (unhandled_exception_mode mode, bool thread_scope);
496 */
498
500 static auto __opaque_crt_prv_msg__(intptr, int32, intptr, intptr, intptr, intptr) noexcept;
502
503 private:
504 friend class form;
505 friend class input_dialog;
506 friend class message_box;
507
508 static bool close_open_forms();
509 static void on_app_thread_exit(object& sender, const event_args& e);
510 static bool on_app_thread_exception();
511 static bool on_thread_exception(const threading::thread_exception_event_args& e);
512 static void raise_enter_thread_modal(const event_args& e);
513 static void raise_leave_thread_modal(const event_args& e);
514 static intptr wnd_proc_(intptr hwnd, int32 msg, intptr wparam, intptr lparam, intptr handle);
515 static void wnd_proc(message& message);
516 static void wm_activate_app(message& message);
517 static void wm_app_idle(message& message);
518 static void wm_quit(message& message);
519
520 static xtd::forms::application_context internal_context_;
521 static xtd::forms::application_context* context_;
522 static bool button_images_;
523 static bool keep_cloned_controls_;
524 static bool light_mode_;
525 static bool font_size_correction_;
526 static bool menu_images_;
527 static bool message_loop_;
528 static bool raise_idle_;
529 static bool system_controls_;
530 static bool system_font_size_;
531 static bool use_wait_cursor_;
532 static bool visual_styles_;
533 };
534 }
535}
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:52
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:504
static event< application, event_handler > application_exit
Occurs when the application is about to shut down.
Definition application.hpp:319
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, event_handler > enter_thread_modal
Occurs when the application is about to enter a modal state.
Definition application.hpp:323
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, threading::thread_exception_event_handler > thread_exception
Occurs when an untrapped thread exception is thrown.
Definition application.hpp:345
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 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 event< application, event_handler > idle
Occurs when the application finishes processing and is about to enter the idle state.
Definition application.hpp:331
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 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 event< application, event_handler > leave_thread_modal
Occurs when the application is about to leave a modal state.
Definition application.hpp:335
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 event< application, event_handler > 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:350
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 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
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 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
intmax_t intptr
Represent a pointer or a handle.
Definition intptr.hpp:23
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.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::threading namespace provides classes and interfaces that enable multithreaded programming....
Definition abandoned_mutex_exception.hpp:10
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.
Contains xtd::forms::thread_exception_event_handler event handler.