Version: 3.1.0
wxAppConsole Class Reference

#include <wx/app.h>

+ Inheritance diagram for wxAppConsole:

Detailed Description

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.

Library:  wxBase
Category:  Application and Process Management
See Also
wxApp Overview, wxApp, wxAppTraits, wxEventLoopBase

Public Member Functions

virtual ~wxAppConsole ()
 Destructor.
 
bool Yield (bool onlyIfNeeded=false)
 
void SetCLocale ()
 Sets the C locale to the default locale for the current environment.
 
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.
 
virtual void ExitMainLoop ()
 Call this to explicitly exit the main message (event) loop.
 
virtual int FilterEvent (wxEvent &event)
 Overridden wxEventFilter method.
 
wxEventLoopBaseGetMainLoop () 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).
 
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.
 
virtual bool UsesEventLoop () const
 Returns true if the application is using an event loop.
 
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.
 
void DeletePendingEvents ()
 Deletes the pending events of all wxEvtHandlers of this application.
 
bool HasPendingEvents () const
 Returns true if there are pending events on the internal pending event list.
 
void SuspendProcessingOfPendingEvents ()
 Temporary suspends processing of the pending events.
 
void ResumeProcessingOfPendingEvents ()
 Resume processing of the pending events previously stopped because of a call to SuspendProcessingOfPendingEvents().
 
void ScheduleForDestruction (wxObject *object)
 Delayed objects destruction.
 
bool IsScheduledForDestruction (wxObject *object) const
 Check if the object had been scheduled for destruction with ScheduleForDestruction().
 
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.
 
virtual bool OnCmdLineError (wxCmdLineParser &parser)
 Called when command line parsing fails (i.e. an incorrect command line option was specified by the user).
 
virtual bool OnCmdLineHelp (wxCmdLineParser &parser)
 Called when the help option (–help) was specified on the command line.
 
virtual bool OnCmdLineParsed (wxCmdLineParser &parser)
 Called after the command line had been successfully parsed.
 
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.
 
virtual void OnEventLoopExit (wxEventLoopBase *loop)
 Called by wxEventLoopBase::OnExit() for each event loop which is exited.
 
virtual bool OnExceptionInMainLoop ()
 This function is called if an unhandled exception occurs inside the main application event loop.
 
virtual int OnExit ()
 Override this member function for any processing which needs to be done as the application is about to exit.
 
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.
 
virtual bool OnInit ()
 This must be provided by the application, and will usually create the application's main window, optionally calling SetTopWindow().
 
virtual void OnInitCmdLine (wxCmdLineParser &parser)
 Called from OnInit() and may be used to initialize the parser with the command line options for this application.
 
virtual int OnRun ()
 This virtual function is where the execution of a program written in wxWidgets starts.
 
virtual void OnUnhandledException ()
 This function is called when an unhandled C++ exception occurs in user code called by wxWidgets.
 
Application information
wxString GetAppDisplayName () const
 Returns the user-readable application name.
 
wxString GetAppName () const
 Returns the application name.
 
wxString GetClassName () const
 Gets the class name of the application.
 
wxAppTraitsGetTraits ()
 Returns a pointer to the wxAppTraits object for the application.
 
const wxStringGetVendorDisplayName () const
 Returns the user-readable vendor name.
 
const wxStringGetVendorName () const
 Returns the application's vendor name.
 
void SetAppDisplayName (const wxString &name)
 Set the application name to be used in the user-visible places such as window titles.
 
void SetAppName (const wxString &name)
 Sets the name of the application.
 
void SetClassName (const wxString &name)
 Sets the class name of the application.
 
void SetVendorDisplayName (const wxString &name)
 Set the vendor name to be used in the user-visible places.
 
void SetVendorName (const wxString &name)
 Sets the name of application's vendor.
 
- Public Member Functions inherited from wxEvtHandler
 wxEvtHandler ()
 Constructor.
 
virtual ~wxEvtHandler ()
 Destructor.
 
virtual void QueueEvent (wxEvent *event)
 Queue event for a later processing.
 
virtual void AddPendingEvent (const wxEvent &event)
 Post an event to be processed later.
 
template<typename T , typename T1 , ... >
void CallAfter (void(T::*method)(T1,...), T1 x1,...)
 Asynchronously call the given method.
 
template<typename T >
void CallAfter (const T &functor)
 Asynchronously call the given functor.
 
virtual bool ProcessEvent (wxEvent &event)
 Processes an event, searching event tables and calling zero or more suitable event handler function(s).
 
bool ProcessEventLocally (wxEvent &event)
 Try to process the event in this handler and all those chained to it.
 
bool SafelyProcessEvent (wxEvent &event)
 Processes an event by calling ProcessEvent() and handles any exceptions that occur in the process.
 
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.
 
void DeletePendingEvents ()
 Deletes all events queued on this event handler using QueueEvent() or AddPendingEvent().
 
virtual bool SearchEventTable (wxEventTable &table, wxEvent &event)
 Searches the event table, executing an event handler function if an appropriate one is found.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
void * GetClientData () const
 Returns user-supplied client data.
 
wxClientDataGetClientObject () const
 Returns a pointer to the user-supplied client data object.
 
void SetClientData (void *data)
 Sets user-supplied client data.
 
void SetClientObject (wxClientData *data)
 Set the client data object.
 
bool GetEvtHandlerEnabled () const
 Returns true if the event handler is enabled, false otherwise.
 
wxEvtHandlerGetNextHandler () const
 Returns the pointer to the next handler in the chain.
 
wxEvtHandlerGetPreviousHandler () const
 Returns the pointer to the previous handler in the chain.
 
void SetEvtHandlerEnabled (bool enabled)
 Enables or disables the event handler.
 
virtual void SetNextHandler (wxEvtHandler *handler)
 Sets the pointer to the next handler.
 
virtual void SetPreviousHandler (wxEvtHandler *handler)
 Sets the pointer to the previous handler.
 
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).
 
bool IsUnlinked () const
 Returns true if the next and the previous handler pointers of this event handler instance are NULL.
 
- Public Member Functions inherited from wxObject
 wxObject ()
 Default ctor; initializes to NULL the internal reference data.
 
 wxObject (const wxObject &other)
 Copy ctor.
 
virtual ~wxObject ()
 Destructor.
 
virtual wxClassInfoGetClassInfo () const
 This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar).
 
wxObjectRefDataGetRefData () const
 Returns the wxObject::m_refData pointer, i.e. the data referenced by this object.
 
bool IsKindOf (const wxClassInfo *info) const
 Determines whether this class is a subclass of (or the same class as) the given class.
 
bool IsSameAs (const wxObject &obj) const
 Returns true if this object has the same data pointer as obj.
 
void Ref (const wxObject &clone)
 Makes this object refer to the data in clone.
 
void SetRefData (wxObjectRefData *data)
 Sets the wxObject::m_refData pointer.
 
void UnRef ()
 Decrements the reference count in the associated data, and if it is zero, deletes the data.
 
void UnShare ()
 This is the same of AllocExclusive() but this method is public.
 
void operator delete (void *buf)
 The delete operator is defined for debugging versions of the library only, when the identifier WXDEBUG is defined.
 
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.
 
- Public Member Functions inherited from wxEventFilter
 wxEventFilter ()
 Default constructor.
 
virtual ~wxEventFilter ()
 Destructor.
 

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.
 
static wxAppConsoleGetInstance ()
 Returns the one and only global application object.
 
static bool IsMainLoopRunning ()
 Returns true if the main event loop is currently running, i.e. if the application is inside OnRun().
 
- 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.
 
static void RemoveFilter (wxEventFilter *filter)
 Remove a filter previously installed with AddFilter().
 

Public Attributes

int argc
 Number of command line arguments (after environment-specific processing).
 
wxChar ** argv
 Command line arguments (after environment-specific processing).
 

Protected Member Functions

virtual wxAppTraitsCreateTraits ()
 Creates the wxAppTraits object when GetTraits() needs it for the first time.
 
- Protected Member Functions inherited from wxEvtHandler
virtual bool TryBefore (wxEvent &event)
 Method called by ProcessEvent() before examining this object event tables.
 
virtual bool TryAfter (wxEvent &event)
 Method called by ProcessEvent() as last resort.
 
- Protected Member Functions inherited from wxObject
void AllocExclusive ()
 Ensure that this object's data is not shared with any other object.
 
virtual wxObjectRefDataCreateRefData () const
 Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it.
 
virtual wxObjectRefDataCloneRefData (const wxObjectRefData *data) const
 Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data.
 

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
wxObjectRefDatam_refData
 Pointer to an object which is the object's reference-counted data.
 

Constructor & Destructor Documentation

virtual wxAppConsole::~wxAppConsole ( )
virtual

Destructor.

Member Function Documentation

virtual wxAppTraits* wxAppConsole::CreateTraits ( )
protectedvirtual

Creates the wxAppTraits object when GetTraits() needs it for the first time.

See Also
wxAppTraits
void wxAppConsole::DeletePendingEvents ( )

Deletes the pending events of all wxEvtHandlers of this application.

See wxEvtHandler::DeletePendingEvents() for warnings about deleting the pending events.

virtual void wxAppConsole::ExitMainLoop ( )
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 int wxAppConsole::FilterEvent ( wxEvent event)
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().

Since
2.9.0
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.

See Also
GetAppDisplayName()
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.

See Also
SetClassName()
static wxAppConsole* wxAppConsole::GetInstance ( )
static

Returns the one and only global application object.

Usually wxTheApp is used instead.

See Also
SetInstance()
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().

Since
2.9.0
const wxString& wxAppConsole::GetVendorName ( ) const

Returns the application's vendor name.

virtual void wxAppConsole::HandleEvent ( wxEvtHandler handler,
wxEventFunction  func,
wxEvent event 
) const
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 bool wxAppConsole::IsMainLoopRunning ( )
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 int wxAppConsole::MainLoop ( )
virtual

Called by wxWidgets on creation of the application.

Override this if you wish to provide your own (environment-dependent) main loop.

Returns
0 under X, and the wParam of the WM_QUIT message under Windows.
virtual void wxAppConsole::OnAssertFailure ( const wxChar file,
int  line,
const wxChar func,
const wxChar cond,
const wxChar msg 
)
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.

Parameters
filethe name of the source file where the assert occurred
linethe line number in this file where the assert occurred
functhe name of the function where the assert occurred, may be empty if the compiler doesn't support C99 FUNCTION
condthe condition of the failed assert in text form
msgthe message specified as argument to wxASSERT_MSG or wxFAIL_MSG, will be NULL if just wxASSERT or wxFAIL was used
virtual bool wxAppConsole::OnCmdLineError ( wxCmdLineParser parser)
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.

See Also
OnInitCmdLine()
virtual bool wxAppConsole::OnCmdLineHelp ( wxCmdLineParser parser)
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.

See Also
OnInitCmdLine()
virtual bool wxAppConsole::OnCmdLineParsed ( wxCmdLineParser parser)
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.

See Also
OnInitCmdLine()
virtual void wxAppConsole::OnEventLoopEnter ( wxEventLoopBase loop)
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.

See Also
OnEventLoopExit()
virtual void wxAppConsole::OnEventLoopExit ( wxEventLoopBase loop)
virtual

Called by wxEventLoopBase::OnExit() for each event loop which is exited.

See Also
OnEventLoopEnter()
virtual bool wxAppConsole::OnExceptionInMainLoop ( )
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. In the latter case it can also use C++ throw keyword to rethrow the current exception.

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.

Finally note that if the exception is rethrown from here, it can be caught in OnUnhandledException().

virtual int wxAppConsole::OnExit ( )
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 void wxAppConsole::OnFatalException ( )
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.

See Also
wxHandleFatalExceptions()
virtual bool wxAppConsole::OnInit ( )
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 void wxAppConsole::OnInitCmdLine ( wxCmdLineParser parser)
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.

virtual int wxAppConsole::OnRun ( )
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 void wxAppConsole::OnUnhandledException ( )
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 void wxAppConsole::ProcessPendingEvents ( )
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().

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.

See Also
GetAppName()
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.

See Also
GetClassName()
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

setlocale(LC_ALL, "");

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.

std::locale::global(std::locale(""));

but be warned that locale support in C++ standard library can be poor or worse under some platforms, e.g. the above line results in an immediate crash under OS X up to the version 10.8.2.

Since
2.9.5
static void wxAppConsole::SetInstance ( wxAppConsole app)
static

Allows external code to modify global wxTheApp, but you should really know what you're doing if you call it.

Parameters
appReplacement for the global application object.
See Also
GetInstance()
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.

See Also
GetVendorName()
void wxAppConsole::SuspendProcessingOfPendingEvents ( )

Temporary suspends processing of the pending events.

See Also
ResumeProcessingOfPendingEvents()
virtual bool wxAppConsole::UsesEventLoop ( ) const
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)

Member Data Documentation

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 OS X, you need to override MacOpenFiles() since command line arguments are used differently there.

You may use the wxCmdLineParser to parse command line arguments.