2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: app.h
|
2008-03-10 15:24:38 +00:00
|
|
|
// Purpose: interface of wxApp
|
2008-03-08 13:52:38 +00:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxApp
|
|
|
|
@wxheader{app.h}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-12 22:18:27 +00:00
|
|
|
The wxApp class represents the application itself. It is used to:
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-12 22:18:27 +00:00
|
|
|
@li set and get application-wide properties;
|
|
|
|
@li implement the windowing system message or event loop;
|
|
|
|
@li initiate application processing via wxApp::OnInit;
|
|
|
|
@li allow default processing of events not handled by other
|
|
|
|
objects in the application.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
You should use the macro IMPLEMENT_APP(appClass) in your application
|
2008-03-12 22:18:27 +00:00
|
|
|
implementation file to tell wxWidgets how to create an instance of your
|
|
|
|
application class.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Use DECLARE_APP(appClass) in a header file if you want the wxGetApp function
|
2008-03-12 22:18:27 +00:00
|
|
|
(which returns a reference to your application object) to be visible to other
|
|
|
|
files.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxbase}
|
|
|
|
@category{appmanagement}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-12 22:18:27 +00:00
|
|
|
@see @ref overview_app
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
class wxApp : public wxEvtHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor. Called implicitly with a definition of a wxApp object.
|
|
|
|
*/
|
|
|
|
wxApp();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor. Will be called implicitly on program exit if the wxApp
|
|
|
|
object is created on the stack.
|
|
|
|
*/
|
|
|
|
~wxApp();
|
|
|
|
|
|
|
|
/**
|
2008-03-12 22:18:27 +00:00
|
|
|
Creates a wxLog class for the application to use for logging errors.
|
|
|
|
The default implementation returns a new wxLogGui class.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see wxLog
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
virtual wxLog* CreateLogTarget();
|
|
|
|
|
|
|
|
/**
|
2008-03-12 22:18:27 +00:00
|
|
|
Creates the wxAppTraits object when GetTraits() needs it for the first time.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see wxAppTraits
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
virtual wxAppTraits* CreateTraits();
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Dispatches the next event in the windowing system event queue.
|
|
|
|
This can be used for programming event loops, e.g.
|
2008-03-12 22:18:27 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
while (app.Pending())
|
|
|
|
Dispatch();
|
|
|
|
@endcode
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see Pending()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
virtual void Dispatch();
|
|
|
|
|
|
|
|
/**
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
virtual void ExitMainLoop();
|
|
|
|
|
|
|
|
/**
|
|
|
|
This function is called before processing any event and allows the application
|
2008-03-12 22:18:27 +00:00
|
|
|
to preempt the processing of some events.
|
|
|
|
|
|
|
|
If this method returns -1 the event is processed normally, otherwise either
|
|
|
|
@true or @false should be returned and the event processing stops immediately
|
|
|
|
considering that the event had been already processed (for the former return
|
|
|
|
value) or that it is not going to be processed at all (for the latter one).
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
int FilterEvent(wxEvent& event);
|
|
|
|
|
|
|
|
/**
|
2008-03-12 22:18:27 +00:00
|
|
|
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.
|
2008-03-08 13:52:38 +00:00
|
|
|
By default, returns the same string as GetAppName().
|
2008-03-10 15:24:38 +00:00
|
|
|
|
|
|
|
@wxsince{2.9.0}
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString GetAppDisplayName() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the application name.
|
|
|
|
|
|
|
|
@remarks wxWidgets sets this to a reasonable default before calling
|
2008-03-09 12:33:59 +00:00
|
|
|
OnInit(), but the application can reset it at will.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see GetAppDisplayName()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString GetAppName() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the class name of the application. The class name may be used in a
|
2008-03-12 22:18:27 +00:00
|
|
|
platform specific manner to refer to the application.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see SetClassName()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString GetClassName() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-12 22:18:27 +00:00
|
|
|
Returns @true if the application will exit when the top-level window is
|
|
|
|
deleted, @false otherwise.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-03-12 22:18:27 +00:00
|
|
|
@see SetExitOnFrameDelete(), @ref overview_app_shutdown
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool GetExitOnFrameDelete() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the one and only global application object.
|
2008-03-12 22:18:27 +00:00
|
|
|
Usually ::wxTheApp is usead instead.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see SetInstance()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
static wxAppConsole* GetInstance();
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a pointer to the top window.
|
|
|
|
|
|
|
|
@remarks If the top window hasn't been set using SetTopWindow(),
|
2008-03-09 12:33:59 +00:00
|
|
|
this function will find the first top-level window
|
|
|
|
(frame or dialog) and return that.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see SetTopWindow()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
virtual wxWindow* GetTopWindow() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a pointer to the wxAppTraits object for the application.
|
|
|
|
If you want to customize the wxAppTraits object, you must override the
|
|
|
|
CreateTraits() function.
|
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
wxAppTraits* GetTraits();
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the application will use the best visual on systems that support
|
|
|
|
different visuals, @false otherwise.
|
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see SetUseBestVisual()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool GetUseBestVisual() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the user-readable vendor name. The difference between this string
|
2008-03-12 22:18:27 +00:00
|
|
|
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.
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
By default, returns the same string as GetVendorName().
|
2008-03-10 15:24:38 +00:00
|
|
|
|
|
|
|
@wxsince{2.9.0}
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString GetVendorDisplayName() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the application's vendor name.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString GetVendorName() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
This function simply invokes the given method @a func of the specified
|
|
|
|
event handler @a handler with the @a event as parameter. It exists solely
|
2008-03-08 13:52:38 +00:00
|
|
|
to allow to catch the C++ exceptions which could be thrown by all event
|
2008-03-12 22:18:27 +00:00
|
|
|
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.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
virtual void HandleEvent(wxEvtHandler handler,
|
|
|
|
wxEventFunction func,
|
2008-03-09 16:24:26 +00:00
|
|
|
wxEvent& event) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the application is active, i.e. if one of its windows is
|
2008-03-12 22:18:27 +00:00
|
|
|
currently in the foreground.
|
|
|
|
|
|
|
|
If this function returns @false and you need to attract users attention to
|
|
|
|
the application, you may use wxTopLevelWindow::RequestUserAttention to do it.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool IsActive() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the main event loop is currently running, i.e. if the
|
|
|
|
application is inside OnRun().
|
2008-03-12 22:18:27 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
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.
|
|
|
|
*/
|
|
|
|
static bool IsMainLoopRunning();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Mac specific. Called in response of an "open-application" Apple event.
|
|
|
|
Override this to create a new document in your app.
|
|
|
|
*/
|
|
|
|
void MacNewFile();
|
|
|
|
|
|
|
|
/**
|
2008-03-12 22:18:27 +00:00
|
|
|
Mac specific. Called in response of an "open-document" Apple event.
|
|
|
|
|
|
|
|
You need to override this method in order to open a document file after the
|
|
|
|
user double clicked on it or if the document file was dropped on either the
|
|
|
|
running application or the application icon in Finder.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void MacOpenFile(const wxString& fileName);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Mac specific. Called in response of a "get-url" Apple event.
|
|
|
|
*/
|
|
|
|
void MacOpenURL(const wxString& url);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Mac specific. Called in response of a "print-document" Apple event.
|
|
|
|
*/
|
|
|
|
void MacPrintFile(const wxString& fileName);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Mac specific. Called in response of a "reopen-application" Apple event.
|
|
|
|
*/
|
|
|
|
void MacReopenApp();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Called by wxWidgets on creation of the application. Override this if you wish
|
|
|
|
to provide your own (environment-dependent) main loop.
|
|
|
|
|
|
|
|
@returns Returns 0 under X, and the wParam of the WM_QUIT message under
|
2008-03-09 12:33:59 +00:00
|
|
|
Windows.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
virtual int MainLoop();
|
|
|
|
|
|
|
|
/**
|
|
|
|
This function is called when an assert failure occurs, i.e. the condition
|
2008-03-10 15:24:38 +00:00
|
|
|
specified in wxASSERT() macro evaluated to @false.
|
2008-03-12 22:18:27 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
It is only called in debug mode (when @c __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.
|
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param file
|
2008-03-09 12:33:59 +00:00
|
|
|
the name of the source file where the assert occurred
|
2008-03-08 14:43:31 +00:00
|
|
|
@param line
|
2008-03-09 12:33:59 +00:00
|
|
|
the line number in this file where the assert occurred
|
2008-03-08 14:43:31 +00:00
|
|
|
@param func
|
2008-03-09 12:33:59 +00:00
|
|
|
the name of the function where the assert occurred, may be
|
|
|
|
empty if the compiler doesn't support C99 __FUNCTION__
|
2008-03-08 14:43:31 +00:00
|
|
|
@param cond
|
2008-03-09 12:33:59 +00:00
|
|
|
the condition of the failed assert in text form
|
2008-03-08 14:43:31 +00:00
|
|
|
@param msg
|
2008-03-12 22:18:27 +00:00
|
|
|
the message specified as argument to wxASSERT_MSG or wxFAIL_MSG, will
|
|
|
|
be @NULL if just wxASSERT or wxFAIL was used
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void OnAssertFailure(const wxChar file, int line,
|
|
|
|
const wxChar func,
|
|
|
|
const wxChar cond,
|
|
|
|
const wxChar msg);
|
|
|
|
|
|
|
|
/**
|
|
|
|
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.
|
2008-03-12 22:18:27 +00:00
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
Return @true to continue normal execution or @false to return
|
2008-03-08 13:52:38 +00:00
|
|
|
@false from OnInit() thus terminating the program.
|
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see OnInitCmdLine()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool OnCmdLineError(wxCmdLineParser& parser);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Called when the help option (@c --help) was specified on the command line.
|
|
|
|
The default behaviour is to show the program usage text and abort the program.
|
2008-03-12 22:18:27 +00:00
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
Return @true to continue normal execution or @false to return
|
2008-03-08 13:52:38 +00:00
|
|
|
@false from OnInit() thus terminating the program.
|
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see OnInitCmdLine()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool OnCmdLineHelp(wxCmdLineParser& parser);
|
|
|
|
|
|
|
|
/**
|
|
|
|
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.
|
2008-03-12 22:18:27 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Don't forget to call the base class version unless you want to suppress
|
|
|
|
processing of the standard command line options.
|
2008-03-12 22:18:27 +00:00
|
|
|
Return @true to continue normal execution or @false to return @false from
|
|
|
|
OnInit() thus terminating the program.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see OnInitCmdLine()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool OnCmdLineParsed(wxCmdLineParser& parser);
|
|
|
|
|
|
|
|
/**
|
|
|
|
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++ @c throw keyword to
|
|
|
|
rethrow the current exception.
|
2008-03-12 22:18:27 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
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.
|
2008-03-12 22:18:27 +00:00
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
Finally note that if the exception is rethrown from here, it can be caught in
|
2008-03-08 13:52:38 +00:00
|
|
|
OnUnhandledException().
|
|
|
|
*/
|
|
|
|
virtual bool OnExceptionInMainLoop();
|
|
|
|
|
|
|
|
/**
|
|
|
|
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
|
2008-03-08 14:43:31 +00:00
|
|
|
wxWidgets cleanup. Note that it is not called at all if
|
2008-03-08 13:52:38 +00:00
|
|
|
OnInit() failed.
|
2008-03-12 22:18:27 +00:00
|
|
|
|
|
|
|
The return value of this function is currently ignored, return the same
|
|
|
|
value as returned by the base class method if you override it.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
virtual int OnExit();
|
|
|
|
|
|
|
|
/**
|
|
|
|
This function may be called if something fatal happens: an unhandled
|
|
|
|
exception under Win32 or a a fatal signal under Unix, for example. However,
|
2008-03-08 14:43:31 +00:00
|
|
|
this will not happen by default: you have to explicitly call
|
2008-03-10 15:24:38 +00:00
|
|
|
wxHandleFatalExceptions() to enable this.
|
2008-03-12 22:18:27 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
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.
|
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
@see wxHandleFatalExceptions()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void OnFatalException();
|
|
|
|
|
|
|
|
/**
|
|
|
|
This must be provided by the application, and will usually create the
|
2008-03-12 22:18:27 +00:00
|
|
|
application's main window, optionally calling SetTopWindow().
|
|
|
|
|
|
|
|
You may use OnExit() to clean up anything initialized here, provided
|
2008-03-08 13:52:38 +00:00
|
|
|
that the function returns @true.
|
2008-03-12 22:18:27 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Notice that if you want to to use the command line processing provided by
|
|
|
|
wxWidgets you have to call the base class version in the derived class
|
|
|
|
OnInit().
|
2008-03-12 22:18:27 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Return @true to continue processing, @false to exit the application
|
|
|
|
immediately.
|
|
|
|
*/
|
|
|
|
bool OnInit();
|
|
|
|
|
|
|
|
/**
|
2008-03-12 22:18:27 +00:00
|
|
|
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.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void OnInitCmdLine(wxCmdLineParser& parser);
|
|
|
|
|
|
|
|
/**
|
|
|
|
This virtual function is where the execution of a program written in wxWidgets
|
|
|
|
starts. The default implementation just enters the main loop and starts
|
2008-03-12 22:18:27 +00:00
|
|
|
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).
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
The return value of this function becomes the exit code of the program, so it
|
|
|
|
should return 0 in case of successful termination.
|
|
|
|
*/
|
|
|
|
virtual int OnRun();
|
|
|
|
|
|
|
|
/**
|
2008-03-08 14:43:31 +00:00
|
|
|
This function is called when an unhandled C++ exception occurs inside
|
2008-03-12 22:18:27 +00:00
|
|
|
OnRun() (the exceptions which occur during the program startup and shutdown
|
|
|
|
might not be caught at all). Notice that by now the main event loop has been
|
|
|
|
terminated and the program will exit, if you want to prevent this from happening
|
|
|
|
(i.e. continue running after catching an exception) you need to override
|
|
|
|
OnExceptionInMainLoop().
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
The default implementation shows information about the exception in debug build
|
|
|
|
but does nothing in the release build.
|
|
|
|
*/
|
|
|
|
virtual void OnUnhandledException();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if unprocessed events are in the window system event queue.
|
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see Dispatch()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
virtual bool Pending();
|
|
|
|
|
|
|
|
/**
|
2008-03-12 22:18:27 +00:00
|
|
|
Windows-only function for processing a message. This function is called
|
|
|
|
from the main message loop, checking for windows that may wish to process it.
|
|
|
|
|
|
|
|
The function returns @true if the message was processed, @false otherwise.
|
|
|
|
If you use wxWidgets with another class library with its own message loop,
|
|
|
|
you should make sure that this function is called to allow wxWidgets to
|
|
|
|
receive messages. For example, to allow co-existence with the Microsoft
|
|
|
|
Foundation Classes, override the PreTranslateMessage function:
|
|
|
|
|
|
|
|
@code
|
|
|
|
// Provide wxWidgets message loop compatibility
|
|
|
|
BOOL CTheApp::PreTranslateMessage(MSG *msg)
|
|
|
|
{
|
|
|
|
if (wxTheApp && wxTheApp->ProcessMessage((WXMSW *)msg))
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return CWinApp::PreTranslateMessage(msg);
|
|
|
|
}
|
|
|
|
@endcode
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
bool ProcessMessage(WXMSG* msg);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sends idle events to a window and its children.
|
|
|
|
Please note that this function is internal to wxWidgets and shouldn't be used
|
|
|
|
by user code.
|
|
|
|
|
|
|
|
@remarks These functions poll the top-level windows, and their children,
|
2008-03-12 22:18:27 +00:00
|
|
|
for idle event processing. If @true is returned, more OnIdle
|
|
|
|
processing is requested by one or more window.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see wxIdleEvent
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool SendIdleEvents(wxWindow* win, wxIdleEvent& event);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Set the application name to be used in the user-visible places such as window
|
2008-03-12 22:18:27 +00:00
|
|
|
titles. See GetAppDisplayName() for more about the differences between the
|
|
|
|
display name and name.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void SetAppDisplayName(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
|
2008-03-08 14:43:31 +00:00
|
|
|
strings, such as the window titles, the application display name set by
|
2008-03-08 13:52:38 +00:00
|
|
|
SetAppDisplayName() is used instead.
|
2008-03-12 22:18:27 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
By default the application name is set to the name of its executable file.
|
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see GetAppName()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void SetAppName(const wxString& name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the class name of the application. This may be used in a platform specific
|
|
|
|
manner to refer to the application.
|
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see GetClassName()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void SetClassName(const wxString& name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Allows the programmer to specify whether the application will exit when the
|
|
|
|
top-level frame is deleted.
|
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param flag
|
2008-03-12 22:18:27 +00:00
|
|
|
If @true (the default), the application will exit when the top-level frame
|
|
|
|
is deleted. If @false, the application will continue to run.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-03-12 22:18:27 +00:00
|
|
|
@see GetExitOnFrameDelete(), @ref overview_app_shutdown
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void SetExitOnFrameDelete(bool flag);
|
|
|
|
|
|
|
|
/**
|
2008-03-12 22:18:27 +00:00
|
|
|
Allows external code to modify global ::wxTheApp, but you should really
|
2008-03-08 13:52:38 +00:00
|
|
|
know what you're doing if you call it.
|
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param app
|
2008-03-09 12:33:59 +00:00
|
|
|
Replacement for the global application object.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see GetInstance()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
static void SetInstance(wxAppConsole* app);
|
|
|
|
|
|
|
|
/**
|
2008-03-12 22:18:27 +00:00
|
|
|
Allows runtime switching of the UI environment theme.
|
|
|
|
|
|
|
|
Currently implemented for wxGTK2-only.
|
2008-03-08 13:52:38 +00:00
|
|
|
Return @true if theme was successfully changed.
|
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param theme
|
2008-03-09 12:33:59 +00:00
|
|
|
The name of the new theme or an absolute path to a gtkrc-theme-file
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-12 22:18:27 +00:00
|
|
|
bool SetNativeTheme(const wxString& theme);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-12 22:18:27 +00:00
|
|
|
Sets the 'top' window. You can call this from within OnInit() to let wxWidgets
|
|
|
|
know which is the main window. You don't have to set the top window;
|
2008-03-08 13:52:38 +00:00
|
|
|
it is only a convenience so that (for example) certain dialogs without parents
|
2008-03-12 22:18:27 +00:00
|
|
|
can use a specific window as the top window. If no top window is specified by the
|
|
|
|
application, wxWidgets just uses the first frame or dialog in its top-level window
|
|
|
|
list, when it needs to use the top window.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param window
|
2008-03-09 12:33:59 +00:00
|
|
|
The new top window.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see GetTopWindow(), OnInit()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void SetTopWindow(wxWindow* window);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Allows the programmer to specify whether the application will use the best
|
2008-03-12 22:18:27 +00:00
|
|
|
visual on systems that support several visual on the same display. This is typically
|
|
|
|
the case under Solaris and IRIX, where the default visual is only 8-bit whereas
|
|
|
|
certain applications are supposed to run in TrueColour mode.
|
|
|
|
|
|
|
|
Note that this function has to be called in the constructor of the wxApp
|
2008-03-08 13:52:38 +00:00
|
|
|
instance and won't have any effect when called later on.
|
|
|
|
This function currently only has effect under GTK.
|
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param flag
|
2008-03-09 12:33:59 +00:00
|
|
|
If @true, the app will use the best visual.
|
2008-03-12 22:18:27 +00:00
|
|
|
@param forceTrueColour
|
|
|
|
If @true then the application will try to force using a TrueColour
|
|
|
|
visual and abort the app if none is found.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
void SetUseBestVisual(bool flag, bool forceTrueColour = false);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-12 22:18:27 +00:00
|
|
|
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.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void SetVendorDisplayName(const wxString& name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the name of application's vendor. The name will be used
|
2008-03-12 22:18:27 +00:00
|
|
|
in registry access. A default name is set by wxWidgets.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see GetVendorName()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void SetVendorName(const wxString& name);
|
|
|
|
|
|
|
|
/**
|
2008-03-12 22:18:27 +00:00
|
|
|
Yields control to pending messages in the windowing system.
|
|
|
|
|
|
|
|
This can be useful, for example, when a time-consuming process writes to a
|
|
|
|
text window. Without an occasional yield, the text window will not be updated
|
|
|
|
properly, and on systems with cooperative multitasking, such as Windows 3.1
|
|
|
|
other processes will not respond.
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Caution should be exercised, however, since yielding may allow the
|
|
|
|
user to perform actions which are not compatible with the current task.
|
|
|
|
Disabling menu items or whole menus during processing can avoid unwanted
|
2008-03-12 22:18:27 +00:00
|
|
|
reentrance of code: see ::wxSafeYield for a better function.
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Note that Yield() will not flush the message logs. This is intentional as
|
2008-03-12 22:18:27 +00:00
|
|
|
calling Yield() is usually done to quickly update the screen and popping up
|
|
|
|
a message box dialog may be undesirable. If you do wish to flush the log
|
2008-03-08 13:52:38 +00:00
|
|
|
messages immediately (otherwise it will be done during the next idle loop
|
|
|
|
iteration), call wxLog::FlushActive.
|
2008-03-12 22:18:27 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Calling Yield() recursively is normally an error and an assert failure is
|
2008-03-08 14:43:31 +00:00
|
|
|
raised in debug build if such situation is detected. However if the
|
2008-03-09 12:33:59 +00:00
|
|
|
@a onlyIfNeeded parameter is @true, the method will just silently
|
2008-03-08 13:52:38 +00:00
|
|
|
return @false instead.
|
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
bool Yield(bool onlyIfNeeded = false);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Number of command line arguments (after environment-specific processing).
|
|
|
|
*/
|
2008-03-12 22:18:27 +00:00
|
|
|
int argc;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Command line arguments (after environment-specific processing).
|
2008-03-12 22:18:27 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
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 MacOpenFile()
|
|
|
|
since command line arguments are used differently there.
|
2008-03-12 22:18:27 +00:00
|
|
|
|
|
|
|
You may use the wxCmdLineParser to parse command line arguments.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-12 22:18:27 +00:00
|
|
|
wxChar** argv;
|
2008-03-08 13:52:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
// ============================================================================
|
|
|
|
// Global functions/macros
|
|
|
|
// ============================================================================
|
|
|
|
|
2008-03-14 15:35:10 +00:00
|
|
|
/**
|
|
|
|
The global pointer to the singleton wxApp object.
|
|
|
|
|
|
|
|
@see wxApp::GetInstance()
|
|
|
|
*/
|
|
|
|
wxApp *wxTheApp;
|
|
|
|
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-03-14 07:44:48 +00:00
|
|
|
/** @ingroup group_funcmacro_rtti */
|
|
|
|
//@{
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-14 07:44:48 +00:00
|
|
|
This is used in headers to create a forward declaration of the wxGetApp()
|
|
|
|
function implemented by IMPLEMENT_APP().
|
2008-03-12 22:18:27 +00:00
|
|
|
|
|
|
|
It creates the declaration @a className wxGetApp(void).
|
2008-03-14 07:44:48 +00:00
|
|
|
|
|
|
|
@header{wx/app.h}
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Example:
|
2008-03-09 12:33:59 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@code
|
2008-03-14 07:44:48 +00:00
|
|
|
DECLARE_APP(MyApp)
|
2008-03-08 13:52:38 +00:00
|
|
|
@endcode
|
|
|
|
*/
|
2008-03-14 08:05:31 +00:00
|
|
|
#define DECLARE_APP( className )
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-12 22:18:27 +00:00
|
|
|
This is used in the application class implementation file to make the
|
|
|
|
application class known to wxWidgets for dynamic construction.
|
2008-03-14 07:44:48 +00:00
|
|
|
|
|
|
|
@header{wx/app.h}
|
|
|
|
|
2008-03-12 22:18:27 +00:00
|
|
|
Example:
|
|
|
|
|
|
|
|
@code
|
|
|
|
IMPLEMENT_APP(MyApp)
|
|
|
|
@endcode
|
|
|
|
|
2008-03-14 07:44:48 +00:00
|
|
|
@see DECLARE_APP().
|
|
|
|
*/
|
2008-03-14 08:05:31 +00:00
|
|
|
#define IMPLEMENT_APP( className )
|
2008-03-14 07:44:48 +00:00
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-14 15:35:10 +00:00
|
|
|
/** @ingroup group_funcmacro_appinitterm */
|
|
|
|
//@{
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-12 22:18:27 +00:00
|
|
|
This function doesn't exist in wxWidgets but it is created by using
|
|
|
|
the IMPLEMENT_APP() macro.
|
|
|
|
|
2008-03-14 15:35:10 +00:00
|
|
|
Thus, before using it anywhere but in the same module where this macro is
|
|
|
|
used, you must make it available using DECLARE_APP().
|
2008-03-12 22:18:27 +00:00
|
|
|
|
|
|
|
The advantage of using this function compared to directly using the global
|
|
|
|
wxTheApp pointer is that the latter is of type wxApp* and so wouldn't
|
|
|
|
allow you to access the functions specific to your application class but not
|
|
|
|
present in wxApp while wxGetApp() returns the object of the right type.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-12 22:18:27 +00:00
|
|
|
wxAppDerivedClass wxGetApp();
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
If @a doIt is @true, the fatal exceptions (also known as general protection
|
2008-03-08 13:52:38 +00:00
|
|
|
faults under Windows or segmentation violations in the Unix world) will be
|
|
|
|
caught and passed to wxApp::OnFatalException.
|
2008-03-12 22:18:27 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
By default, i.e. before this function is called, they will be handled in the
|
|
|
|
normal way which usually just means that the application will be terminated.
|
2008-03-09 12:33:59 +00:00
|
|
|
Calling wxHandleFatalExceptions() with @a doIt equal to @false will restore
|
2008-03-08 13:52:38 +00:00
|
|
|
this default behaviour.
|
2008-03-09 12:33:59 +00:00
|
|
|
|
2008-03-12 22:18:27 +00:00
|
|
|
Notice that this function is only available if @c wxUSE_ON_FATAL_EXCEPTION is 1
|
|
|
|
and under Windows platform this requires a compiler with support for SEH
|
|
|
|
(structured exception handling) which currently means only Microsoft Visual C++
|
|
|
|
or a recent Borland C++ version.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-12 22:18:27 +00:00
|
|
|
bool wxHandleFatalExceptions(bool doIt = true);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
This function is used in wxBase only and only if you don't create
|
|
|
|
wxApp object at all. In this case you must call it from your
|
|
|
|
@c main() function before calling any other wxWidgets functions.
|
2008-03-12 22:18:27 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
If the function returns @false the initialization could not be performed,
|
2008-03-12 22:18:27 +00:00
|
|
|
in this case the library cannot be used and wxUninitialize() shouldn't be
|
|
|
|
called neither.
|
|
|
|
|
|
|
|
This function may be called several times but wxUninitialize() must be
|
|
|
|
called for each successful call to this function.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool wxInitialize();
|
|
|
|
|
|
|
|
/**
|
2008-03-12 22:18:27 +00:00
|
|
|
This function is for use in console (wxBase) programs only. It must be called
|
|
|
|
once for each previous successful call to wxInitialize().
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-12 22:18:27 +00:00
|
|
|
void wxUninitialize();
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Calls wxApp::Yield.
|
2008-03-12 22:18:27 +00:00
|
|
|
|
|
|
|
@deprecated
|
2008-03-08 13:52:38 +00:00
|
|
|
This function is kept only for backwards compatibility. Please use
|
|
|
|
the wxApp::Yield method instead in any new code.
|
|
|
|
*/
|
|
|
|
bool wxYield();
|
|
|
|
|
2008-03-14 15:35:10 +00:00
|
|
|
/**
|
|
|
|
This function is similar to wxYield, except that it disables the user input to
|
|
|
|
all program windows before calling wxYield and re-enables it again
|
|
|
|
afterwards. If @a win is not @NULL, this window will remain enabled,
|
|
|
|
allowing the implementation of some limited user interaction.
|
|
|
|
Returns the result of the call to ::wxYield.
|
|
|
|
*/
|
|
|
|
bool wxSafeYield(wxWindow* win = NULL, bool onlyIfNeeded = false);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-14 15:35:10 +00:00
|
|
|
This function initializes wxWidgets in a platform-dependent way. Use this if you
|
|
|
|
are not using the default wxWidgets entry code (e.g. main or WinMain).
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-14 15:35:10 +00:00
|
|
|
For example, you can initialize wxWidgets from an Microsoft Foundation Classes
|
|
|
|
(MFC) application using this function.
|
|
|
|
|
|
|
|
@note This overload of wxEntry is available under all platforms.
|
|
|
|
|
|
|
|
@see wxEntryStart()
|
|
|
|
*/
|
|
|
|
int wxEntry(int& argc, wxChar** argv);
|
|
|
|
|
|
|
|
/**
|
|
|
|
See wxEntry(int&,wxChar**) for more info about this function.
|
|
|
|
|
|
|
|
Notice that under Windows CE platform, and only there, the type of @a pCmdLine
|
|
|
|
is @c wchar_t *, otherwise it is @c char *, even in Unicode build.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@remarks To clean up wxWidgets, call wxApp::OnExit followed by the static
|
2008-03-12 22:18:27 +00:00
|
|
|
function wxApp::CleanUp. For example, if exiting from an MFC application
|
|
|
|
that also uses wxWidgets:
|
|
|
|
@code
|
|
|
|
int CTheApp::ExitInstance()
|
|
|
|
{
|
|
|
|
// OnExit isn't called by CleanUp so must be called explicitly.
|
|
|
|
wxTheApp->OnExit();
|
|
|
|
wxApp::CleanUp();
|
|
|
|
|
|
|
|
return CWinApp::ExitInstance();
|
|
|
|
}
|
|
|
|
@endcode
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
int wxEntry(HINSTANCE hInstance,
|
2008-03-09 12:33:59 +00:00
|
|
|
HINSTANCE hPrevInstance = NULL,
|
|
|
|
char* pCmdLine = NULL,
|
2008-03-08 14:43:31 +00:00
|
|
|
int nCmdShow = SW_SHOWNORMAL);
|
2008-03-14 15:35:10 +00:00
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @ingroup group_funcmacro_procctrl */
|
|
|
|
//@{
|
|
|
|
|
|
|
|
/**
|
|
|
|
Exits application after calling wxApp::OnExit.
|
|
|
|
|
|
|
|
Should only be used in an emergency: normally the top-level frame
|
|
|
|
should be deleted (after deleting all other frames) to terminate the
|
|
|
|
application. See wxCloseEvent and wxApp.
|
|
|
|
*/
|
|
|
|
void wxExit();
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|