#include <wx/app.h>
This class is essential for writing console-only or hybrid apps without having to define wxUSE_GUI=0
.
It is used to:
You should use the macro wxIMPLEMENT_APP(appClass) in your application implementation file to tell wxWidgets how to create an instance of your application class.
Use wxDECLARE_APP(appClass) in a header file if you want the wxGetApp() function (which returns a reference to your application object) to be visible to other files.
Public Member Functions | |
virtual | ~wxAppConsole () |
Destructor. More... | |
bool | Yield (bool onlyIfNeeded=false) |
Yields control to pending messages in the event loop. More... | |
void | SetCLocale () |
Sets the C locale to the default locale for the current environment. More... | |
Event-handling | |
Note that you should look at wxEvtLoopBase for more event-processing documentation. | |
virtual int | MainLoop () |
Called by wxWidgets on creation of the application. More... | |
virtual void | ExitMainLoop () |
Call this to explicitly exit the main message (event) loop. More... | |
virtual int | FilterEvent (wxEvent &event) |
Overridden wxEventFilter method. More... | |
wxEventLoopBase * | GetMainLoop () const |
Returns the main event loop instance, i.e. the event loop which is started by OnRun() and which dispatches all events sent from the native toolkit to the application (except when new event loops are temporarily set-up). More... | |
virtual void | HandleEvent (wxEvtHandler *handler, wxEventFunction func, wxEvent &event) const |
This function simply invokes the given method func of the specified event handler handler with the event as parameter. More... | |
virtual bool | UsesEventLoop () const |
Returns true if the application is using an event loop. More... | |
Pending events | |
Pending events are handled by wxAppConsole rather than wxEventLoopBase to allow queuing of events even when there's no event loop (e.g. in wxAppConsole::OnInit). | |
virtual void | ProcessPendingEvents () |
Process all pending events; it is necessary to call this function to process events posted with wxEvtHandler::QueueEvent or wxEvtHandler::AddPendingEvent. More... | |
void | DeletePendingEvents () |
Deletes the pending events of all wxEvtHandlers of this application. More... | |
bool | HasPendingEvents () const |
Returns true if there are pending events on the internal pending event list. More... | |
void | SuspendProcessingOfPendingEvents () |
Temporary suspends processing of the pending events. More... | |
void | ResumeProcessingOfPendingEvents () |
Resume processing of the pending events previously stopped because of a call to SuspendProcessingOfPendingEvents(). More... | |
void | ScheduleForDestruction (wxObject *object) |
Delayed objects destruction. More... | |
bool | IsScheduledForDestruction (wxObject *object) const |
Check if the object had been scheduled for destruction with ScheduleForDestruction(). More... | |
Callbacks for application-wide "events" | |
virtual void | OnAssertFailure (const wxChar *file, int line, const wxChar *func, const wxChar *cond, const wxChar *msg) |
This function is called when an assert failure occurs, i.e. the condition specified in wxASSERT() macro evaluated to false. More... | |
virtual bool | OnCmdLineError (wxCmdLineParser &parser) |
Called when command line parsing fails (i.e. an incorrect command line option was specified by the user). More... | |
virtual bool | OnCmdLineHelp (wxCmdLineParser &parser) |
Called when the help option (--help ) was specified on the command line. More... | |
virtual bool | OnCmdLineParsed (wxCmdLineParser &parser) |
Called after the command line had been successfully parsed. More... | |
virtual void | OnEventLoopEnter (wxEventLoopBase *loop) |
Called by wxEventLoopBase::SetActive(): you can override this function and put here the code which needs an active event loop. More... | |
virtual void | OnEventLoopExit (wxEventLoopBase *loop) |
Called by wxEventLoopBase::OnExit() for each event loop which is exited. More... | |
virtual int | OnExit () |
Override this member function for any processing which needs to be done as the application is about to exit. More... | |
virtual void | OnFatalException () |
This function may be called if something fatal happens: an unhandled exception under Win32 or a fatal signal under Unix, for example. More... | |
virtual bool | OnInit () |
This must be provided by the application, and will usually create the application's main window, optionally calling SetTopWindow(). More... | |
virtual void | OnInitCmdLine (wxCmdLineParser &parser) |
Called from OnInit() and may be used to initialize the parser with the command line options for this application. More... | |
virtual int | OnRun () |
This virtual function is where the execution of a program written in wxWidgets starts. More... | |
Exceptions support | |
Methods related to C++ exceptions handling.
| |
virtual bool | OnExceptionInMainLoop () |
This function is called if an unhandled exception occurs inside the main application event loop. More... | |
virtual void | OnUnhandledException () |
This function is called when an unhandled C++ exception occurs in user code called by wxWidgets. More... | |
virtual bool | StoreCurrentException () |
Method to store exceptions not handled by OnExceptionInMainLoop(). More... | |
virtual void | RethrowStoredException () |
Method to rethrow exceptions stored by StoreCurrentException(). More... | |
Application information | |
wxString | GetAppDisplayName () const |
Returns the user-readable application name. More... | |
wxString | GetAppName () const |
Returns the application name. More... | |
wxString | GetClassName () const |
Gets the class name of the application. More... | |
wxAppTraits * | GetTraits () |
Returns a pointer to the wxAppTraits object for the application. More... | |
const wxString & | GetVendorDisplayName () const |
Returns the user-readable vendor name. More... | |
const wxString & | GetVendorName () const |
Returns the application's vendor name. More... | |
void | SetAppDisplayName (const wxString &name) |
Set the application name to be used in the user-visible places such as window titles. More... | |
void | SetAppName (const wxString &name) |
Sets the name of the application. More... | |
void | SetClassName (const wxString &name) |
Sets the class name of the application. More... | |
void | SetVendorDisplayName (const wxString &name) |
Set the vendor name to be used in the user-visible places. More... | |
void | SetVendorName (const wxString &name) |
Sets the name of application's vendor. More... | |
Public Member Functions inherited from wxEvtHandler | |
wxEvtHandler () | |
Constructor. More... | |
virtual | ~wxEvtHandler () |
Destructor. More... | |
virtual void | QueueEvent (wxEvent *event) |
Queue event for a later processing. More... | |
virtual void | AddPendingEvent (const wxEvent &event) |
Post an event to be processed later. More... | |
template<typename T , typename T1 , ... > | |
void | CallAfter (void(T::*method)(T1,...), T1 x1,...) |
Asynchronously call the given method. More... | |
template<typename T > | |
void | CallAfter (const T &functor) |
Asynchronously call the given functor. More... | |
virtual bool | ProcessEvent (wxEvent &event) |
Processes an event, searching event tables and calling zero or more suitable event handler function(s). More... | |
bool | ProcessEventLocally (wxEvent &event) |
Try to process the event in this handler and all those chained to it. More... | |
bool | SafelyProcessEvent (wxEvent &event) |
Processes an event by calling ProcessEvent() and handles any exceptions that occur in the process. More... | |
void | ProcessPendingEvents () |
Processes the pending events previously queued using QueueEvent() or AddPendingEvent(); you must call this function only if you are sure there are pending events for this handler, otherwise a wxCHECK will fail. More... | |
void | DeletePendingEvents () |
Deletes all events queued on this event handler using QueueEvent() or AddPendingEvent(). More... | |
void | Connect (int id, int lastId, wxEventType eventType, wxObjectEventFunction function, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL) |
Connects the given function dynamically with the event handler, id and event type. More... | |
void | Connect (int id, wxEventType eventType, wxObjectEventFunction function, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL) |
See the Connect(int, int, wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*) overload for more info. More... | |
void | Connect (wxEventType eventType, wxObjectEventFunction function, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL) |
See the Connect(int, int, wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*) overload for more info. More... | |
bool | Disconnect (wxEventType eventType, wxObjectEventFunction function, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL) |
Disconnects the given function dynamically from the event handler, using the specified parameters as search criteria and returning true if a matching function has been found and removed. More... | |
bool | Disconnect (int id=wxID_ANY, wxEventType eventType=wxEVT_NULL, wxObjectEventFunction function=NULL, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL) |
See the Disconnect(wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*) overload for more info. More... | |
bool | Disconnect (int id, int lastId, wxEventType eventType, wxObjectEventFunction function=NULL, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL) |
See the Disconnect(wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*) overload for more info. More... | |
template<typename EventTag , typename Functor > | |
void | Bind (const EventTag &eventType, Functor functor, int id=wxID_ANY, int lastId=wxID_ANY, wxObject *userData=NULL) |
Binds the given function, functor or method dynamically with the event. More... | |
template<typename EventTag , typename Class , typename EventArg , typename EventHandler > | |
void | Bind (const EventTag &eventType, void(Class::*method)(EventArg &), EventHandler *handler, int id=wxID_ANY, int lastId=wxID_ANY, wxObject *userData=NULL) |
See the Bind<>(const EventTag&, Functor, int, int, wxObject*) overload for more info. More... | |
template<typename EventTag , typename Functor > | |
bool | Unbind (const EventTag &eventType, Functor functor, int id=wxID_ANY, int lastId=wxID_ANY, wxObject *userData=NULL) |
Unbinds the given function, functor or method dynamically from the event handler, using the specified parameters as search criteria and returning true if a matching function has been found and removed. More... | |
template<typename EventTag , typename Class , typename EventArg , typename EventHandler > | |
bool | Unbind (const EventTag &eventType, void(Class::*method)(EventArg &), EventHandler *handler, int id=wxID_ANY, int lastId=wxID_ANY, wxObject *userData=NULL) |
See the Unbind<>(const EventTag&, Functor, int, int, wxObject*) overload for more info. More... | |
void * | GetClientData () const |
Returns user-supplied client data. More... | |
wxClientData * | GetClientObject () const |
Returns a pointer to the user-supplied client data object. More... | |
void | SetClientData (void *data) |
Sets user-supplied client data. More... | |
void | SetClientObject (wxClientData *data) |
Set the client data object. More... | |
bool | GetEvtHandlerEnabled () const |
Returns true if the event handler is enabled, false otherwise. More... | |
wxEvtHandler * | GetNextHandler () const |
Returns the pointer to the next handler in the chain. More... | |
wxEvtHandler * | GetPreviousHandler () const |
Returns the pointer to the previous handler in the chain. More... | |
void | SetEvtHandlerEnabled (bool enabled) |
Enables or disables the event handler. More... | |
virtual void | SetNextHandler (wxEvtHandler *handler) |
Sets the pointer to the next handler. More... | |
virtual void | SetPreviousHandler (wxEvtHandler *handler) |
Sets the pointer to the previous handler. More... | |
void | Unlink () |
Unlinks this event handler from the chain it's part of (if any); then links the "previous" event handler to the "next" one (so that the chain won't be interrupted). More... | |
bool | IsUnlinked () const |
Returns true if the next and the previous handler pointers of this event handler instance are NULL. More... | |
Public Member Functions inherited from wxObject | |
wxObject () | |
Default ctor; initializes to NULL the internal reference data. More... | |
wxObject (const wxObject &other) | |
Copy ctor. More... | |
virtual | ~wxObject () |
Destructor. More... | |
virtual wxClassInfo * | GetClassInfo () const |
This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar). More... | |
wxObjectRefData * | GetRefData () const |
Returns the wxObject::m_refData pointer, i.e. the data referenced by this object. More... | |
bool | IsKindOf (const wxClassInfo *info) const |
Determines whether this class is a subclass of (or the same class as) the given class. More... | |
bool | IsSameAs (const wxObject &obj) const |
Returns true if this object has the same data pointer as obj. More... | |
void | Ref (const wxObject &clone) |
Makes this object refer to the data in clone. More... | |
void | SetRefData (wxObjectRefData *data) |
Sets the wxObject::m_refData pointer. More... | |
void | UnRef () |
Decrements the reference count in the associated data, and if it is zero, deletes the data. More... | |
void | UnShare () |
This is the same of AllocExclusive() but this method is public. More... | |
void | operator delete (void *buf) |
The delete operator is defined for debugging versions of the library only, when the identifier __WXDEBUG__ is defined. More... | |
void * | operator new (size_t size, const wxString &filename=NULL, int lineNum=0) |
The new operator is defined for debugging versions of the library only, when the identifier __WXDEBUG__ is defined. More... | |
Public Member Functions inherited from wxEventFilter | |
wxEventFilter () | |
Default constructor. More... | |
virtual | ~wxEventFilter () |
Destructor. More... | |
Static Public Member Functions | |
static void | SetInstance (wxAppConsole *app) |
Allows external code to modify global wxTheApp, but you should really know what you're doing if you call it. More... | |
static wxAppConsole * | GetInstance () |
Returns the one and only global application object. More... | |
static bool | IsMainLoopRunning () |
Returns true if the main event loop is currently running, i.e. if the application is inside OnRun(). More... | |
Static Public Member Functions inherited from wxEvtHandler | |
static void | AddFilter (wxEventFilter *filter) |
Add an event filter whose FilterEvent() method will be called for each and every event processed by wxWidgets. More... | |
static void | RemoveFilter (wxEventFilter *filter) |
Remove a filter previously installed with AddFilter(). More... | |
Public Attributes | |
int | argc |
Number of command line arguments (after environment-specific processing). More... | |
wxChar ** | argv |
Command line arguments (after environment-specific processing). More... | |
Protected Member Functions | |
virtual wxAppTraits * | CreateTraits () |
Creates the wxAppTraits object when GetTraits() needs it for the first time. More... | |
Protected Member Functions inherited from wxEvtHandler | |
virtual bool | TryBefore (wxEvent &event) |
Method called by ProcessEvent() before examining this object event tables. More... | |
virtual bool | TryAfter (wxEvent &event) |
Method called by ProcessEvent() as last resort. More... | |
Protected Member Functions inherited from wxObject | |
void | AllocExclusive () |
Ensure that this object's data is not shared with any other object. More... | |
virtual wxObjectRefData * | CreateRefData () const |
Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it. More... | |
virtual wxObjectRefData * | CloneRefData (const wxObjectRefData *data) const |
Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data. More... | |
Additional Inherited Members | |
Public Types inherited from wxEventFilter | |
enum | { Event_Skip = -1 , Event_Ignore = 0 , Event_Processed = 1 } |
Possible return values for FilterEvent(). More... | |
Protected Attributes inherited from wxObject | |
wxObjectRefData * | m_refData |
Pointer to an object which is the object's reference-counted data. More... | |
|
virtual |
Destructor.
|
protectedvirtual |
Creates the wxAppTraits object when GetTraits() needs it for the first time.
void wxAppConsole::DeletePendingEvents | ( | ) |
Deletes the pending events of all wxEvtHandlers of this application.
See wxEvtHandler::DeletePendingEvents() for warnings about deleting the pending events.
|
virtual |
Call this to explicitly exit the main message (event) loop.
You should normally exit the main loop (and the application) by deleting the top window.
This function simply calls wxEvtLoopBase::Exit() on the active loop.
|
virtual |
Overridden wxEventFilter method.
This function is called before processing any event and allows the application to preempt the processing of some events, see wxEventFilter documentation for more information.
wxApp implementation of this method always return -1 indicating that the event should be processed normally.
Implements wxEventFilter.
wxString wxAppConsole::GetAppDisplayName | ( | ) | const |
Returns the user-readable application name.
The difference between this string and the one returned by GetAppName() is that this one is meant to be shown to the user and so should be used for the window titles, page headers and so on while the other one should be only used internally, e.g. for the file names or configuration file keys.
If the application name for display had been previously set by SetAppDisplayName(), it will be returned by this function. Otherwise, if SetAppName() had been called its value will be returned; also as is. Finally if none was called, this function returns the program name capitalized using wxString::Capitalize().
wxString wxAppConsole::GetAppName | ( | ) | const |
Returns the application name.
If SetAppName() had been called, returns the string passed to it. Otherwise returns the program name, i.e. the value of argv
[0] passed to the main()
function.
wxString wxAppConsole::GetClassName | ( | ) | const |
Gets the class name of the application.
The class name may be used in a platform specific manner to refer to the application.
|
static |
Returns the one and only global application object.
Usually wxTheApp is used instead.
wxEventLoopBase* wxAppConsole::GetMainLoop | ( | ) | const |
Returns the main event loop instance, i.e. the event loop which is started by OnRun() and which dispatches all events sent from the native toolkit to the application (except when new event loops are temporarily set-up).
The returned value maybe NULL. Put initialization code which needs a non-NULL main event loop into OnEventLoopEnter().
wxAppTraits* wxAppConsole::GetTraits | ( | ) |
Returns a pointer to the wxAppTraits object for the application.
If you want to customize the wxAppTraits object, you must override the CreateTraits() function.
const wxString& wxAppConsole::GetVendorDisplayName | ( | ) | const |
Returns the user-readable vendor name.
The difference between this string and the one returned by GetVendorName() is that this one is meant to be shown to the user and so should be used for the window titles, page headers and so on while the other one should be only used internally, e.g. for the file names or configuration file keys.
By default, returns the same string as GetVendorName().
const wxString& wxAppConsole::GetVendorName | ( | ) | const |
Returns the application's vendor name.
|
virtual |
This function simply invokes the given method func of the specified event handler handler with the event as parameter.
It exists solely to allow to catch the C++ exceptions which could be thrown by all event handlers in the application in one place: if you want to do this, override this function in your wxApp-derived class and add try/catch clause(s) to it.
bool wxAppConsole::HasPendingEvents | ( | ) | const |
Returns true if there are pending events on the internal pending event list.
Whenever wxEvtHandler::QueueEvent or wxEvtHandler::AddPendingEvent() are called (not only for wxApp itself, but for any event handler of the application!), the internal wxApp's list of handlers with pending events is updated and this function will return true.
|
static |
Returns true if the main event loop is currently running, i.e. if the application is inside OnRun().
This can be useful to test whether events can be dispatched. For example, if this function returns false, non-blocking sockets cannot be used because the events from them would never be processed.
bool wxAppConsole::IsScheduledForDestruction | ( | wxObject * | object | ) | const |
Check if the object had been scheduled for destruction with ScheduleForDestruction().
This function may be useful as an optimization to avoid doing something with an object which will be soon destroyed in any case.
|
virtual |
Called by wxWidgets on creation of the application.
Override this if you wish to provide your own (environment-dependent) main loop.
|
virtual |
This function is called when an assert failure occurs, i.e. the condition specified in wxASSERT() macro evaluated to false.
It is only called in debug mode (when __WXDEBUG__
is defined) as asserts are not left in the release code at all. The base class version shows the default assert failure dialog box proposing to the user to stop the program, continue or ignore all subsequent asserts.
file | the name of the source file where the assert occurred |
line | the line number in this file where the assert occurred |
func | the name of the function where the assert occurred, may be empty if the compiler doesn't support C99 __FUNCTION__ |
cond | the condition of the failed assert in text form |
msg | the message specified as argument to wxASSERT_MSG or wxFAIL_MSG, will be NULL if just wxASSERT or wxFAIL was used |
|
virtual |
Called when command line parsing fails (i.e. an incorrect command line option was specified by the user).
The default behaviour is to show the program usage text and abort the program.
Return true to continue normal execution or false to return false from OnInit() thus terminating the program.
|
virtual |
Called when the help option (--help
) was specified on the command line.
The default behaviour is to show the program usage text and abort the program.
Return true to continue normal execution or false to return false from OnInit() thus terminating the program.
|
virtual |
Called after the command line had been successfully parsed.
You may override this method to test for the values of the various parameters which could be set from the command line.
Don't forget to call the base class version unless you want to suppress processing of the standard command line options. Return true to continue normal execution or false to return false from OnInit() thus terminating the program.
|
virtual |
Called by wxEventLoopBase::SetActive(): you can override this function and put here the code which needs an active event loop.
Note that this function is called whenever an event loop is activated; you may want to use wxEventLoopBase::IsMain() to perform initialization specific for the app's main event loop.
|
virtual |
Called by wxEventLoopBase::OnExit() for each event loop which is exited.
|
virtual |
This function is called if an unhandled exception occurs inside the main application event loop.
It can return true to ignore the exception and to continue running the loop or false to exit the loop and terminate the program.
The default behaviour of this function is the latter in all ports except under Windows where a dialog is shown to the user which allows him to choose between the different options. You may override this function in your class to do something more appropriate.
If this method rethrows the exception and if the exception can't be stored for later processing using StoreCurrentException(), the program will terminate after calling OnUnhandledException().
You should consider overriding this method to perform whichever last resort exception handling that would be done in a typical C++ program in a try/catch
block around the entire main()
function. As this method is called during exception handling, you may use the C++ throw
keyword to rethrow the current exception to catch it again and analyze it. For example:
|
virtual |
Override this member function for any processing which needs to be done as the application is about to exit.
OnExit is called after destroying all application windows and controls, but before wxWidgets cleanup. Note that it is not called at all if OnInit() failed.
The return value of this function is currently ignored, return the same value as returned by the base class method if you override it.
|
virtual |
This function may be called if something fatal happens: an unhandled exception under Win32 or a fatal signal under Unix, for example.
However, this will not happen by default: you have to explicitly call wxHandleFatalExceptions() to enable this.
Generally speaking, this function should only show a message to the user and return. You may attempt to save unsaved data but this is not guaranteed to work and, in fact, probably won't.
|
virtual |
This must be provided by the application, and will usually create the application's main window, optionally calling SetTopWindow().
You may use OnExit() to clean up anything initialized here, provided that the function returns true.
Notice that if you want to use the command line processing provided by wxWidgets you have to call the base class version in the derived class OnInit().
Return true to continue processing, false to exit the application immediately.
|
virtual |
Called from OnInit() and may be used to initialize the parser with the command line options for this application.
The base class versions adds support for a few standard options only.
Note that this method should just configure parser to accept the desired command line options by calling wxCmdLineParser::AddOption(), wxCmdLineParser::AddSwitch() and similar methods, but should not call wxCmdLineParser::Parse() as this will be done by wxWidgets itself slightly later.
|
virtual |
This virtual function is where the execution of a program written in wxWidgets starts.
The default implementation just enters the main loop and starts handling the events until it terminates, either because ExitMainLoop() has been explicitly called or because the last frame has been deleted and GetExitOnFrameDelete() flag is true (this is the default).
The return value of this function becomes the exit code of the program, so it should return 0 in case of successful termination.
|
virtual |
This function is called when an unhandled C++ exception occurs in user code called by wxWidgets.
Any unhandled exceptions thrown from (overridden versions of) OnInit() and OnExit() methods as well as any exceptions thrown from inside the main loop and re-thrown by OnUnhandledException() will result in a call to this function.
By the time this function is called, the program is already about to exit and the exception can't be handled nor ignored any more, override OnUnhandledException() or use explicit try/catch
blocks around OnInit() body to be able to handle the exception earlier.
The default implementation dumps information about the exception using wxMessageOutputBest.
|
virtual |
Process all pending events; it is necessary to call this function to process events posted with wxEvtHandler::QueueEvent or wxEvtHandler::AddPendingEvent.
This happens during each event loop iteration (see wxEventLoopBase) in GUI mode but it may be also called directly.
Note that this function does not only process the pending events for the wxApp object itself (which derives from wxEvtHandler) but also the pending events for any event handler of this application.
This function will immediately return and do nothing if SuspendProcessingOfPendingEvents() was called.
void wxAppConsole::ResumeProcessingOfPendingEvents | ( | ) |
Resume processing of the pending events previously stopped because of a call to SuspendProcessingOfPendingEvents().
|
virtual |
Method to rethrow exceptions stored by StoreCurrentException().
If StoreCurrentException() is overridden, this function should be overridden as well to rethrow the exceptions stored by it when the control gets back to our code, i.e. when it's safe to do it.
See StoreCurrentException() for an example of implementing this method.
The default version does nothing when using C++98 and uses std::rethrow_exception() in C++11.
void wxAppConsole::ScheduleForDestruction | ( | wxObject * | object | ) |
Delayed objects destruction.
In applications using events it may be unsafe for an event handler to delete the object which generated the event because more events may be still pending for the same object. In this case the handler may call ScheduleForDestruction() instead. Schedule the object for destruction in the near future.
Notice that if the application is not using an event loop, i.e. if UsesEventLoop() returns false, this method will simply delete the object immediately.
Examples of using this function inside wxWidgets itself include deleting the top level windows when they are closed and sockets when they are disconnected.
void wxAppConsole::SetAppDisplayName | ( | const wxString & | name | ) |
Set the application name to be used in the user-visible places such as window titles.
See GetAppDisplayName() for more about the differences between the display name and name.
Notice that if this function is called, the name is used as is, without any capitalization as done by default by GetAppDisplayName().
void wxAppConsole::SetAppName | ( | const wxString & | name | ) |
Sets the name of the application.
This name should be used for file names, configuration file entries and other internal strings. For the user-visible strings, such as the window titles, the application display name set by SetAppDisplayName() is used instead.
By default the application name is set to the name of its executable file.
void wxAppConsole::SetClassName | ( | const wxString & | name | ) |
Sets the class name of the application.
This may be used in a platform specific manner to refer to the application.
void wxAppConsole::SetCLocale | ( | ) |
Sets the C locale to the default locale for the current environment.
It is advised to call this to ensure that the underlying toolkit uses the locale in which the numbers and monetary amounts are shown in the format expected by user and so on.
Calling this function is roughly equivalent to calling
but performs additional toolkit-specific tasks under some platforms and so should be used instead of setlocale()
itself. Alternatively, you can use wxLocale to change the locale with more control.
Notice that this does not change the global C++ locale, you need to do it explicitly if you want, e.g.
but be warned that locale support in C++ standard library can be poor or worse under some platforms.
|
static |
Allows external code to modify global wxTheApp, but you should really know what you're doing if you call it.
app | Replacement for the global application object. |
void wxAppConsole::SetVendorDisplayName | ( | const wxString & | name | ) |
Set the vendor name to be used in the user-visible places.
See GetVendorDisplayName() for more about the differences between the display name and name.
void wxAppConsole::SetVendorName | ( | const wxString & | name | ) |
Sets the name of application's vendor.
The name will be used in registry access. A default name is set by wxWidgets.
|
virtual |
Method to store exceptions not handled by OnExceptionInMainLoop().
This function can be overridden to store the current exception, in view of rethrowing it later when RethrowStoredException() is called. If the exception was stored, return true. If the exception can't be stored, i.e. if this function returns false, the program will abort after calling OnUnhandledException().
It is necessary to override this function if OnExceptionInMainLoop() doesn't catch all exceptions, but you still want to handle them using explicit try/catch
statements. Typical use could be to allow code like the following to work:
By default, throwing an exception from an event handler called from the dialog modal event loop would terminate the application as the exception can't be safely propagated to the code in the catch clause because of the presence of the native system functions (through which C++ exceptions can't, generally speaking, propagate) in the call stack between them.
Overriding this method allows the exception to be stored when it is detected and rethrown using RethrowStoredException() when the native system function dispatching the dialog events terminates, with the result that the code above works as expected.
An example of implementing this method:
void wxAppConsole::SuspendProcessingOfPendingEvents | ( | ) |
Temporary suspends processing of the pending events.
|
virtual |
Returns true if the application is using an event loop.
This function always returns true for the GUI applications which must use an event loop but by default only returns true for the console programs if an event loop is already running as it can't know whether one will be created in the future.
Thus, it only makes sense to override it in console applications which do use an event loop, to return true instead of checking if there is a currently active event loop.
bool wxAppConsole::Yield | ( | bool | onlyIfNeeded = false | ) |
Yields control to pending messages in the event loop.
This method is a convenient wrapper for wxEvtLoopBase::Yield(). If the main loop is currently running, it calls this method on it. Otherwise it creates a temporary event loop and uses it instead, which can be useful to process pending messages during the program startup, before the main loop is created.
Use extreme caution when calling this function as, just as wxEvtLoopBase::Yield(), it can result in unexpected reentrances.
int wxAppConsole::argc |
Number of command line arguments (after environment-specific processing).
wxChar** wxAppConsole::argv |
Command line arguments (after environment-specific processing).
Under Windows and Linux/Unix, you should parse the command line arguments and check for files to be opened when starting your application. Under macOS, you need to override MacOpenFiles() since command line arguments are used differently there.
You may use the wxCmdLineParser to parse command line arguments.