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
116 static xtd::string executable_name() noexcept;
117
120 static xtd::string executable_path() noexcept;
121
128 static bool font_size_correction();
129
136 static void font_size_correction(bool value);
137
140 static bool light_mode() noexcept;
141
145 static void light_mode(bool value);
146
151
156 static bool menu_images() noexcept;
157
163 static void menu_images(bool value);
164
167 static bool message_loop() noexcept;
168
172 static const form_collection open_forms() noexcept;
173
176 static xtd::string product_name() noexcept;
177
180 static xtd::string product_version() noexcept;
181
184 static xtd::string startup_path() noexcept;
185
189 static const xtd::forms::style_sheets::style_sheet& style_sheet() noexcept;
193 static void style_sheet(const xtd::forms::style_sheets::style_sheet& value);
197 static const xtd::forms::style_sheets::style_sheet::style_sheets_t& style_sheets() noexcept;
198
202 static const xtd::forms::style_sheets::style_sheet::style_sheet_names_t& style_sheet_names() noexcept;
203
208 static bool system_controls() noexcept;
209
215 static void system_controls(bool value);
216
223 static bool system_font_size() noexcept;
224
231 static void system_font_size(bool value);
232
238
244 static xtd::string user_app_data_path() noexcept;
245
246 /*
251 static microsoft::win32::registry_key user_app_data_registry();
252 */
253
260 static bool use_wait_cursor() noexcept;
268
273 static bool visual_styles() noexcept;
274
280 static void visual_styles(bool value);
282
284
290
294
302
306
315 static event<application, threading::thread_exception_event_handler> thread_exception;
316
322
324
329 static void add_message_filter(const imessage_filter& value);
330
336 static void do_events();
337
342 static void enable_visual_styles();
343
349 static void exit();
350
357 static void exit(cancel_event_args& e);
358
361 static void exit_thread();
362
369
372 static void raise_idle(const event_args& e);
373
378
382 static void remove_message_filter(const imessage_filter& value);
383
390 static void restart();
391
398 static void run();
399
406 static void run(xtd::forms::application_context& context);
407
415 static void run(const form& main_form);
416
417 /*
423 static void set_unhandled_exception_mode (unhandled_exception_mode mode);
424 */
425
426 /*
435 static void set_unhandled_exception_mode (unhandled_exception_mode mode, bool thread_scope);
436 */
438
440 static auto __opaque_crt_prv_msg__(intptr, int32, intptr, intptr, intptr, intptr) noexcept;
442
444
449 [[deprecated("Replaced by xtd::application::dark_mode - Will be removed in version 0.4.0.")]]
450 static bool dark_mode_enabled() noexcept;
451
455 [[deprecated("Replaced by xtd::application::light_mode - Will be removed in version 0.4.0.")]]
456 static bool light_mode_enabled() noexcept;
457
462 [[deprecated("Replaced by xtd::application::visual_styles - Will be removed in version 0.4.0.")]]
463 static bool use_visual_styles() noexcept;
465
467
473 [[deprecated("Replaced by xtd::application::button_images - Will be removed in version 0.4.0.")]]
474 static void enable_button_images();
475
481 [[deprecated("Replaced by xtd::application::dark_mode - Will be removed in version 0.4.0.")]]
482 static void enable_dark_mode();
483
489 [[deprecated("Replaced by xtd::application::light_mode - Will be removed in version 0.4.0.")]]
490 static void enable_light_mode();
491
496 [[deprecated("Replaced by xtd::application::menu_images - Will be removed in version 0.4.0.")]]
497 static void enable_menu_images();
499
500 private:
501 friend class control;
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 bool on_thread_exception(const threading::thread_exception_event_args& e);
510 static void raise_enter_thread_modal(const event_args& e);
511 static void raise_leave_thread_modal(const event_args& e);
512 static intptr wnd_proc_(intptr hwnd, int32 msg, intptr wparam, intptr lparam, intptr handle);
513 static void wnd_proc(message& message);
514 static void wm_activate_app(message& message);
515 static void wm_app_idle(message& message);
516 static void wm_quit(message& message);
517
518 static xtd::forms::application_context internal_context_;
519 static xtd::forms::application_context* context_;
520 static bool button_images_;
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 static xtd::collections::generic::list<xtd::sptr<xtd::forms::control>> top_level_forms_;
531 };
532 }
533}
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:502
static event< application, event_handler > application_exit
Occurs when the application is about to shut down.
Definition application.hpp:289
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:293
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:315
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:301
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 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:305
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:320
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
Represents a collection of form objects.
Definition form_collection.hpp:24
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:38
#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::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:25
std::optional< type_t > optional
Represents the optional alias on std::optional.
Definition optional.hpp:26
xtd::ref< form > form_ref
Represent an xtd::forms::form reference.
Definition form_ref.hpp:25
Contains xtd::forms::imessage_filter interface.
Contains xtd::forms::message class.
Contains xtd::forms::message_loop_callback delegate.
The xtd::collections namespace contains interfaces and classes that define various collections of obj...
Definition any_pair.hpp:10
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.