revised other headers

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52463 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Francesco Montorsi
2008-03-12 22:18:27 +00:00
parent 5e4e03e9f9
commit 96d7cc9be3
3 changed files with 407 additions and 377 deletions

View File

@@ -10,27 +10,26 @@
@class wxApp @class wxApp
@wxheader{app.h} @wxheader{app.h}
The @b wxApp class represents the application itself. It is used The wxApp class represents the application itself. It is used to:
to:
set and get application-wide properties; @li set and get application-wide properties;
implement the windowing system message or event loop; @li implement the windowing system message or event loop;
initiate application processing via wxApp::OnInit; @li initiate application processing via wxApp::OnInit;
allow default processing of events not handled by other @li allow default processing of events not handled by other
objects in the application. objects in the application.
You should use the macro IMPLEMENT_APP(appClass) in your application You should use the macro IMPLEMENT_APP(appClass) in your application
implementation implementation file to tell wxWidgets how to create an instance of your
file to tell wxWidgets how to create an instance of your application class. application class.
Use DECLARE_APP(appClass) in a header file if you want the wxGetApp function Use DECLARE_APP(appClass) in a header file if you want the wxGetApp function
(which returns (which returns a reference to your application object) to be visible to other
a reference to your application object) to be visible to other files. files.
@library{wxbase} @library{wxbase}
@category{appmanagement} @category{appmanagement}
@see @ref overview_wxappoverview "wxApp overview" @see @ref overview_app
*/ */
class wxApp : public wxEvtHandler class wxApp : public wxEvtHandler
{ {
@@ -47,16 +46,15 @@ public:
~wxApp(); ~wxApp();
/** /**
Creates a wxLog class for the application to use for logging errors. The default Creates a wxLog class for the application to use for logging errors.
implementation returns a new wxLogGui class. The default implementation returns a new wxLogGui class.
@see wxLog @see wxLog
*/ */
virtual wxLog* CreateLogTarget(); virtual wxLog* CreateLogTarget();
/** /**
Creates the wxAppTraits object when GetTraits() Creates the wxAppTraits object when GetTraits() needs it for the first time.
needs it for the first time.
@see wxAppTraits @see wxAppTraits
*/ */
@@ -65,6 +63,11 @@ public:
/** /**
Dispatches the next event in the windowing system event queue. Dispatches the next event in the windowing system event queue.
This can be used for programming event loops, e.g. This can be used for programming event loops, e.g.
@code
while (app.Pending())
Dispatch();
@endcode
@see Pending() @see Pending()
*/ */
@@ -79,20 +82,22 @@ public:
/** /**
This function is called before processing any event and allows the application This function is called before processing any event and allows the application
to preempt the processing of some events. If this method returns -1 the event to preempt the processing of some events.
is processed normally, otherwise either @true or @false should be
returned and the event processing stops immediately considering that the event If this method returns -1 the event is processed normally, otherwise either
had been already processed (for the former return value) or that it is not @true or @false should be returned and the event processing stops immediately
going to be processed at all (for the latter one). 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).
*/ */
int FilterEvent(wxEvent& event); int FilterEvent(wxEvent& event);
/** /**
Returns the user-readable application name. The difference between this string Returns the user-readable application name.
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, The difference between this string and the one returned by GetAppName() is that
page headers and so on while the other one should be only used internally, e.g. this one is meant to be shown to the user and so should be used for the window
for the file names or configuration file keys. 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 GetAppName(). By default, returns the same string as GetAppName().
@wxsince{2.9.0} @wxsince{2.9.0}
@@ -111,26 +116,23 @@ public:
/** /**
Gets the class name of the application. The class name may be used in a Gets the class name of the application. The class name may be used in a
platform specific platform specific manner to refer to the application.
manner to refer to the application.
@see SetClassName() @see SetClassName()
*/ */
wxString GetClassName() const; wxString GetClassName() const;
/** /**
Returns @true if the application will exit when the top-level window is deleted, Returns @true if the application will exit when the top-level window is
@false deleted, @false otherwise.
otherwise.
@see SetExitOnFrameDelete(), @ref overview_wxappshutdownoverview "wxApp @see SetExitOnFrameDelete(), @ref overview_app_shutdown
shutdown overview"
*/ */
bool GetExitOnFrameDelete() const; bool GetExitOnFrameDelete() const;
/** /**
Returns the one and only global application object. Returns the one and only global application object.
Usually @c wxTheApp is usead instead. Usually ::wxTheApp is usead instead.
@see SetInstance() @see SetInstance()
*/ */
@@ -164,10 +166,11 @@ public:
/** /**
Returns the user-readable vendor name. The difference between this string Returns the user-readable vendor name. The difference between this string
and the one returned by GetVendorName() is that this one and the one returned by GetVendorName() is that this one is meant to be shown
is meant to be shown to the user and so should be used for the window titles, to the user and so should be used for the window titles, page headers and so on
page headers and so on while the other one should be only used internally, e.g. while the other one should be only used internally, e.g. for the file names or
for the file names or configuration file keys. configuration file keys.
By default, returns the same string as GetVendorName(). By default, returns the same string as GetVendorName().
@wxsince{2.9.0} @wxsince{2.9.0}
@@ -183,8 +186,8 @@ public:
This function simply invokes the given method @a func of the specified 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 event handler @a handler with the @a event as parameter. It exists solely
to allow to catch the C++ exceptions which could be thrown by all event 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 handlers in the application in one place: if you want to do this, override
function in your wxApp-derived class and add try/catch clause(s) to it. this function in your wxApp-derived class and add try/catch clause(s) to it.
*/ */
virtual void HandleEvent(wxEvtHandler handler, virtual void HandleEvent(wxEvtHandler handler,
wxEventFunction func, wxEventFunction func,
@@ -192,16 +195,17 @@ public:
/** /**
Returns @true if the application is active, i.e. if one of its windows is Returns @true if the application is active, i.e. if one of its windows is
currently in the foreground. If this function returns @false and you need to currently in the foreground.
attract users attention to the application, you may use
wxTopLevelWindow::RequestUserAttention If this function returns @false and you need to attract users attention to
to do it. the application, you may use wxTopLevelWindow::RequestUserAttention to do it.
*/ */
bool IsActive() const; bool IsActive() const;
/** /**
Returns @true if the main event loop is currently running, i.e. if the Returns @true if the main event loop is currently running, i.e. if the
application is inside OnRun(). application is inside OnRun().
This can be useful to test whether events can be dispatched. For example, 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 if this function returns @false, non-blocking sockets cannot be used because
the events from them would never be processed. the events from them would never be processed.
@@ -215,11 +219,11 @@ public:
void MacNewFile(); void MacNewFile();
/** /**
Mac specific. Called in response of an "open-document" Apple event. You need to Mac specific. Called in response of an "open-document" Apple event.
override this method in order to open a document file after the
user double clicked on it or if the document file was dropped You need to override this method in order to open a document file after the
on either the running application or the application icon in user double clicked on it or if the document file was dropped on either the
Finder. running application or the application icon in Finder.
*/ */
void MacOpenFile(const wxString& fileName); void MacOpenFile(const wxString& fileName);
@@ -250,6 +254,7 @@ public:
/** /**
This function is called when an assert failure occurs, i.e. the condition This function is called when an assert failure occurs, i.e. the condition
specified in wxASSERT() macro evaluated to @false. specified in wxASSERT() macro evaluated to @false.
It is only called in debug mode (when @c __WXDEBUG__ is defined) as It is only called in debug mode (when @c __WXDEBUG__ is defined) as
asserts are not left in the release code at all. asserts are not left in the release code at all.
The base class version shows the default assert failure dialog box proposing to The base class version shows the default assert failure dialog box proposing to
@@ -265,10 +270,8 @@ public:
@param cond @param cond
the condition of the failed assert in text form the condition of the failed assert in text form
@param msg @param msg
the message specified as argument to the message specified as argument to wxASSERT_MSG or wxFAIL_MSG, will
wxASSERT_MSG or wxFAIL_MSG, will be @NULL if just wxASSERT or wxFAIL was used
be @NULL if just wxASSERT or wxFAIL
was used
*/ */
void OnAssertFailure(const wxChar file, int line, void OnAssertFailure(const wxChar file, int line,
const wxChar func, const wxChar func,
@@ -279,6 +282,7 @@ public:
Called when command line parsing fails (i.e. an incorrect command line option 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 was specified by the user). The default behaviour is to show the program usage
text and abort the program. text and abort the program.
Return @true to continue normal execution or @false to return Return @true to continue normal execution or @false to return
@false from OnInit() thus terminating the program. @false from OnInit() thus terminating the program.
@@ -289,6 +293,7 @@ public:
/** /**
Called when the help option (@c --help) was specified on the command line. 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. The default behaviour is to show the program usage text and abort the program.
Return @true to continue normal execution or @false to return Return @true to continue normal execution or @false to return
@false from OnInit() thus terminating the program. @false from OnInit() thus terminating the program.
@@ -300,10 +305,11 @@ public:
Called after the command line had been successfully parsed. You may override 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 this method to test for the values of the various parameters which could be
set from the command line. set from the command line.
Don't forget to call the base class version unless you want to suppress Don't forget to call the base class version unless you want to suppress
processing of the standard command line options. processing of the standard command line options.
Return @true to continue normal execution or @false to return Return @true to continue normal execution or @false to return @false from
@false from OnInit() thus terminating the program. OnInit() thus terminating the program.
@see OnInitCmdLine() @see OnInitCmdLine()
*/ */
@@ -315,10 +321,12 @@ public:
continue running the loop or @false to exit the loop and terminate the 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 program. In the latter case it can also use C++ @c throw keyword to
rethrow the current exception. rethrow the current exception.
The default behaviour of this function is the latter in all ports except under 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 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 the different options. You may override this function in your class to do
something more appropriate. something more appropriate.
Finally note that if the exception is rethrown from here, it can be caught in Finally note that if the exception is rethrown from here, it can be caught in
OnUnhandledException(). OnUnhandledException().
*/ */
@@ -330,8 +338,9 @@ public:
destroying all application windows and controls, but before destroying all application windows and controls, but before
wxWidgets cleanup. Note that it is not called at all if wxWidgets cleanup. Note that it is not called at all if
OnInit() failed. 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. 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 int OnExit(); virtual int OnExit();
@@ -340,6 +349,7 @@ public:
exception under Win32 or a a fatal signal under Unix, for example. However, exception under Win32 or a a fatal signal under Unix, for example. However,
this will not happen by default: you have to explicitly call this will not happen by default: you have to explicitly call
wxHandleFatalExceptions() to enable this. wxHandleFatalExceptions() to enable this.
Generally speaking, this function should only show a message to the user and 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 return. You may attempt to save unsaved data but this is not guaranteed to
work and, in fact, probably won't. work and, in fact, probably won't.
@@ -350,33 +360,34 @@ public:
/** /**
This must be provided by the application, and will usually create the This must be provided by the application, and will usually create the
application's main window, optionally calling application's main window, optionally calling SetTopWindow().
SetTopWindow(). You may use
OnExit() to clean up anything initialized here, provided You may use OnExit() to clean up anything initialized here, provided
that the function returns @true. that the function returns @true.
Notice that if you want to to use the command line processing provided by 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 wxWidgets you have to call the base class version in the derived class
OnInit(). OnInit().
Return @true to continue processing, @false to exit the application Return @true to continue processing, @false to exit the application
immediately. immediately.
*/ */
bool OnInit(); bool OnInit();
/** /**
Called from OnInit() and may be used to initialize the Called from OnInit() and may be used to initialize the parser with the
parser with the command line options for this application. The base class command line options for this application. The base class versions adds
versions adds support for a few standard options only. support for a few standard options only.
*/ */
void OnInitCmdLine(wxCmdLineParser& parser); void OnInitCmdLine(wxCmdLineParser& parser);
/** /**
This virtual function is where the execution of a program written in wxWidgets This virtual function is where the execution of a program written in wxWidgets
starts. The default implementation just enters the main loop and starts starts. The default implementation just enters the main loop and starts
handling the events until it terminates, either because handling the events until it terminates, either because ExitMainLoop() has
ExitMainLoop() has been explicitly called or because been explicitly called or because the last frame has been deleted and
the last frame has been deleted and GetExitOnFrameDelete() flag is @true (this is the default).
GetExitOnFrameDelete() flag is @true (this
is the default).
The return value of this function becomes the exit code of the program, so it The return value of this function becomes the exit code of the program, so it
should return 0 in case of successful termination. should return 0 in case of successful termination.
*/ */
@@ -384,11 +395,12 @@ public:
/** /**
This function is called when an unhandled C++ exception occurs inside This function is called when an unhandled C++ exception occurs inside
OnRun() (the exceptions which occur during the program OnRun() (the exceptions which occur during the program startup and shutdown
startup and shutdown might not be caught at all). Notice that by now the main might not be caught at all). Notice that by now the main event loop has been
event loop has been terminated and the program will exit, if you want to terminated and the program will exit, if you want to prevent this from happening
prevent this from happening (i.e. continue running after catching an exception) (i.e. continue running after catching an exception) you need to override
you need to override OnExceptionInMainLoop(). OnExceptionInMainLoop().
The default implementation shows information about the exception in debug build The default implementation shows information about the exception in debug build
but does nothing in the release build. but does nothing in the release build.
*/ */
@@ -402,14 +414,25 @@ public:
virtual bool Pending(); virtual bool Pending();
/** /**
Windows-only function for processing a message. This function Windows-only function for processing a message. This function is called
is called from the main message loop, checking for windows that from the main message loop, checking for windows that may wish to process it.
may wish to process it. The function returns @true if the message
was processed, @false otherwise. If you use wxWidgets with another class The function returns @true if the message was processed, @false otherwise.
library with its own message loop, you should make sure that this If you use wxWidgets with another class library with its own message loop,
function is called to allow wxWidgets to receive messages. For example, you should make sure that this function is called to allow wxWidgets to
to allow co-existence with the Microsoft Foundation Classes, override receive messages. For example, to allow co-existence with the Microsoft
the PreTranslateMessage function: 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
*/ */
bool ProcessMessage(WXMSG* msg); bool ProcessMessage(WXMSG* msg);
@@ -419,8 +442,8 @@ public:
by user code. by user code.
@remarks These functions poll the top-level windows, and their children, @remarks These functions poll the top-level windows, and their children,
for idle event processing. If @true is returned, more for idle event processing. If @true is returned, more OnIdle
OnIdle processing is requested by one or more window. processing is requested by one or more window.
@see wxIdleEvent @see wxIdleEvent
*/ */
@@ -428,8 +451,8 @@ public:
/** /**
Set the application name to be used in the user-visible places such as window Set the application name to be used in the user-visible places such as window
titles. See GetAppDisplayName() for more about titles. See GetAppDisplayName() for more about the differences between the
the differences between the display name and name. display name and name.
*/ */
void SetAppDisplayName(const wxString& name); void SetAppDisplayName(const wxString& name);
@@ -438,6 +461,7 @@ public:
configuration file entries and other internal strings. For the user-visible configuration file entries and other internal strings. For the user-visible
strings, such as the window titles, the application display name set by strings, such as the window titles, the application display name set by
SetAppDisplayName() is used instead. SetAppDisplayName() is used instead.
By default the application name is set to the name of its executable file. By default the application name is set to the name of its executable file.
@see GetAppName() @see GetAppName()
@@ -457,16 +481,15 @@ public:
top-level frame is deleted. top-level frame is deleted.
@param flag @param flag
If @true (the default), the application will exit when the top-level frame is If @true (the default), the application will exit when the top-level frame
deleted. If @false, the application will continue to run. is deleted. If @false, the application will continue to run.
@see GetExitOnFrameDelete(), @ref overview_wxappshutdownoverview "wxApp @see GetExitOnFrameDelete(), @ref overview_app_shutdown
shutdown overview"
*/ */
void SetExitOnFrameDelete(bool flag); void SetExitOnFrameDelete(bool flag);
/** /**
Allows external code to modify global @c wxTheApp, but you should really Allows external code to modify global ::wxTheApp, but you should really
know what you're doing if you call it. know what you're doing if you call it.
@param app @param app
@@ -477,26 +500,23 @@ public:
static void SetInstance(wxAppConsole* app); static void SetInstance(wxAppConsole* app);
/** /**
Allows runtime switching of the UI environment theme. Currently implemented for Allows runtime switching of the UI environment theme.
wxGTK2-only.
Currently implemented for wxGTK2-only.
Return @true if theme was successfully changed. Return @true if theme was successfully changed.
@param theme @param theme
The name of the new theme or an absolute path to a gtkrc-theme-file The name of the new theme or an absolute path to a gtkrc-theme-file
*/ */
bool SetNativeTheme(const wxStringamp;); bool SetNativeTheme(const wxString& theme);
/** /**
Sets the 'top' window. You can call this from within OnInit() to Sets the 'top' window. You can call this from within OnInit() to let wxWidgets
let wxWidgets know which is the main window. You don't have to set the top know which is the main window. You don't have to set the top window;
window;
it is only a convenience so that (for example) certain dialogs without parents it is only a convenience so that (for example) certain dialogs without parents
can use a can use a specific window as the top window. If no top window is specified by the
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
application, list, when it needs to use the top window.
wxWidgets just uses the first frame or dialog in its top-level window list,
when it
needs to use the top window.
@param window @param window
The new top window. The new top window.
@@ -507,55 +527,56 @@ public:
/** /**
Allows the programmer to specify whether the application will use the best Allows the programmer to specify whether the application will use the best
visual visual on systems that support several visual on the same display. This is typically
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
the certain applications are supposed to run in TrueColour mode.
case under Solaris and IRIX, where the default visual is only 8-bit whereas
certain Note that this function has to be called in the constructor of the wxApp
applications are supposed to run in TrueColour mode.
If @a forceTrueColour is @true then the application will try to force
using a TrueColour visual and abort the app if none is found.
Note that this function has to be called in the constructor of the @c wxApp
instance and won't have any effect when called later on. instance and won't have any effect when called later on.
This function currently only has effect under GTK. This function currently only has effect under GTK.
@param flag @param flag
If @true, the app will use the best visual. If @true, the app will use the best visual.
@param forceTrueColour
If @true then the application will try to force using a TrueColour
visual and abort the app if none is found.
*/ */
void SetUseBestVisual(bool flag, bool forceTrueColour = false); void SetUseBestVisual(bool flag, bool forceTrueColour = false);
/** /**
Set the vendor name to be used in the user-visible places. See Set the vendor name to be used in the user-visible places.
GetVendorDisplayName() for more about See GetVendorDisplayName() for more about the differences between the
the differences between the display name and name. display name and name.
*/ */
void SetVendorDisplayName(const wxString& name); void SetVendorDisplayName(const wxString& name);
/** /**
Sets the name of application's vendor. The name will be used Sets the name of application's vendor. The name will be used
in registry access. A default name is set by in registry access. A default name is set by wxWidgets.
wxWidgets.
@see GetVendorName() @see GetVendorName()
*/ */
void SetVendorName(const wxString& name); void SetVendorName(const wxString& name);
/** /**
Yields control to pending messages in the windowing system. This can be useful, Yields control to pending messages in the windowing system.
for example, when a
time-consuming process writes to a text window. Without an occasional This can be useful, for example, when a time-consuming process writes to a
yield, the text window will not be updated properly, and on systems with text window. Without an occasional yield, the text window will not be updated
cooperative multitasking, such as Windows 3.1 other processes will not respond. properly, and on systems with cooperative multitasking, such as Windows 3.1
other processes will not respond.
Caution should be exercised, however, since yielding may allow the Caution should be exercised, however, since yielding may allow the
user to perform actions which are not compatible with the current task. user to perform actions which are not compatible with the current task.
Disabling menu items or whole menus during processing can avoid unwanted Disabling menu items or whole menus during processing can avoid unwanted
reentrance of code: see ::wxSafeYield for a better reentrance of code: see ::wxSafeYield for a better function.
function.
Note that Yield() will not flush the message logs. This is intentional as Note that Yield() will not flush the message logs. This is intentional as
calling Yield() is usually done to quickly update the screen and popping up a calling Yield() is usually done to quickly update the screen and popping up
message box dialog may be undesirable. If you do wish to flush the log a message box dialog may be undesirable. If you do wish to flush the log
messages immediately (otherwise it will be done during the next idle loop messages immediately (otherwise it will be done during the next idle loop
iteration), call wxLog::FlushActive. iteration), call wxLog::FlushActive.
Calling Yield() recursively is normally an error and an assert failure is Calling Yield() recursively is normally an error and an assert failure is
raised in debug build if such situation is detected. However if the raised in debug build if such situation is detected. However if the
@a onlyIfNeeded parameter is @true, the method will just silently @a onlyIfNeeded parameter is @true, the method will just silently
@@ -564,21 +585,21 @@ public:
bool Yield(bool onlyIfNeeded = false); bool Yield(bool onlyIfNeeded = false);
/** /**
int argc
Number of command line arguments (after environment-specific processing). Number of command line arguments (after environment-specific processing).
*/ */
int argc;
/** /**
wxChar ** argv
Command line arguments (after environment-specific processing). Command line arguments (after environment-specific processing).
Under Windows and Linux/Unix, you should parse the command line Under Windows and Linux/Unix, you should parse the command line
arguments and check for files to be opened when starting your arguments and check for files to be opened when starting your
application. Under OS X, you need to override MacOpenFile() application. Under OS X, you need to override MacOpenFile()
since command line arguments are used differently there. since command line arguments are used differently there.
You may use the wxCmdLineParser to
parse command line arguments. You may use the wxCmdLineParser to parse command line arguments.
*/ */
wxChar** argv;
}; };
@@ -587,93 +608,30 @@ public:
// Global functions/macros // Global functions/macros
// ============================================================================ // ============================================================================
//@{
/** /**
For all normal, informational messages. They also appear in a message box by The global pointer to the singleton wxApp object.
default (but it can be changed).
*/
void wxLogMessage(const char* formatString, ... );
void wxVLogMessage(const char* formatString, va_list argPtr);
//@}
//@{ @see wxApp::GetInstance()
/**
For verbose output. Normally, it is suppressed, but
might be activated if the user wishes to know more details about the program
progress (another, but possibly confusing name for the same function is @b
wxLogInfo).
*/ */
void wxLogVerbose(const char* formatString, ... ); wxApp *wxTheApp;
void wxVLogVerbose(const char* formatString, va_list argPtr);
//@}
/** /**
This is used in headers to create a forward declaration of the This is used in headers to create a forward declaration of the
wxGetApp() function implemented by wxGetApp() function implemented by wxIMPLEMENT_APP().
wxIMPLEMENT_APP(). It creates the declaration
@c className wxGetApp(void). It creates the declaration @a className wxGetApp(void).
Example: Example:
@code @code
wxDECLARE_APP(MyApp) wxDECLARE_APP(MyApp)
@endcode @endcode
*/ */
#define wxDECLARE_APP() /* implementation is private */ #define wxDECLARE_APP(className) /* implementation is private */
/**
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();
//@{
/**
For warnings - they are also normally shown to the user, but don't interrupt
the program work.
*/
void wxLogWarning(const char* formatString, ... );
void wxVLogWarning(const char* formatString, va_list argPtr);
//@}
//@{
/**
Like wxLogError(), but also
terminates the program with the exit code 3. Using @e abort() standard
function also terminates the program with this exit code.
*/
void wxLogFatalError(const char* formatString, ... );
void wxVLogFatalError(const char* formatString,
va_list argPtr);
//@}
/**
If @a doIt is @true, the fatal exceptions (also known as general protection
faults under Windows or segmentation violations in the Unix world) will be
caught and passed to wxApp::OnFatalException.
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.
Calling wxHandleFatalExceptions() with @a doIt equal to @false will restore
this default behaviour.
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.
*/
bool wxHandleFatalExceptions(bool doIt = true);
/** /**
This is used in the application class implementation file to make the This is used in the application class implementation file to make the
application class known to application class known to wxWidgets for dynamic construction.
wxWidgets for dynamic construction. You use this instead of Example:
Old form:
@code
MyApp myApp;
@endcode
New form:
@code @code
IMPLEMENT_APP(MyApp) IMPLEMENT_APP(MyApp)
@@ -681,7 +639,47 @@ bool wxHandleFatalExceptions(bool doIt = true);
See also DECLARE_APP(). See also DECLARE_APP().
*/ */
#define IMPLEMENT_APP() /* implementation is private */ #define IMPLEMENT_APP(className) /* implementation is private */
/**
This function doesn't exist in wxWidgets but it is created by using
the IMPLEMENT_APP() macro.
Thus, before using it anywhere but in the same module where this macro is used,
you must make it available using DECLARE_APP().
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.
*/
wxAppDerivedClass wxGetApp();
/**
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();
/**
If @a doIt is @true, the fatal exceptions (also known as general protection
faults under Windows or segmentation violations in the Unix world) will be
caught and passed to wxApp::OnFatalException.
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.
Calling wxHandleFatalExceptions() with @a doIt equal to @false will restore
this default behaviour.
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.
*/
bool wxHandleFatalExceptions(bool doIt = true);
/** /**
Returns the error code from the last system call. This function uses Returns the error code from the last system call. This function uses
@@ -694,75 +692,12 @@ unsigned long wxSysErrorCode();
/** /**
In a GUI application, this function posts @a event to the specified @e dest In a GUI application, this function posts @a event to the specified @e dest
object using wxEvtHandler::AddPendingEvent. object using wxEvtHandler::AddPendingEvent.
Otherwise, it dispatches @a event immediately using
wxEvtHandler::ProcessEvent. Otherwise, it dispatches @a event immediately using wxEvtHandler::ProcessEvent.
See the respective documentation for details (and caveats). See the respective documentation for details (and caveats).
*/ */
void wxPostEvent(wxEvtHandler* dest, wxEvent& event); void wxPostEvent(wxEvtHandler* dest, wxEvent& event);
//@{
/**
The functions to use for error messages, i.e. the messages that must be shown
to the user. The default processing is to pop up a message box to inform the
user about it.
*/
void wxLogError(const char* formatString, ... );
void wxVLogError(const char* formatString, va_list argPtr);
//@}
//@{
/**
As @b wxLogDebug, trace functions only do something in debug build and
expand to nothing in the release one. The reason for making
it a separate function from it is that usually there are a lot of trace
messages, so it might make sense to separate them from other debug messages.
The trace messages also usually can be separated into different categories and
the second and third versions of this function only log the message if the
@a mask which it has is currently enabled in wxLog. This
allows to selectively trace only some operations and not others by changing
the value of the trace mask (possible during the run-time).
For the second function (taking a string mask), the message is logged only if
the mask has been previously enabled by the call to
wxLog::AddTraceMask or by setting
@ref overview_envvars "@c WXTRACE environment variable".
The predefined string trace masks
used by wxWidgets are:
wxTRACE_MemAlloc: trace memory allocation (new/delete)
wxTRACE_Messages: trace window messages/X callbacks
wxTRACE_ResAlloc: trace GDI resource allocation
wxTRACE_RefCount: trace various ref counting operations
wxTRACE_OleCalls: trace OLE method calls (Win32 only)
@b Caveats: since both the mask and the format string are strings,
this might lead to function signature confusion in some cases:
if you intend to call the format string only version of wxLogTrace,
then add a %s format string parameter and then supply a second string parameter
for that %s, the string mask version of wxLogTrace will erroneously get called instead, since you are supplying two string parameters to the function.
In this case you'll unfortunately have to avoid having two leading
string parameters, e.g. by adding a bogus integer (with its %d format string).
The third version of the function only logs the message if all the bits
corresponding to the @a mask are set in the wxLog trace mask which can be
set by wxLog::SetTraceMask. This version is less
flexible than the previous one because it doesn't allow defining the user
trace masks easily - this is why it is deprecated in favour of using string
trace masks.
wxTraceMemAlloc: trace memory allocation (new/delete)
wxTraceMessages: trace window messages/X callbacks
wxTraceResAlloc: trace GDI resource allocation
wxTraceRefCount: trace various ref counting operations
wxTraceOleCalls: trace OLE method calls (Win32 only)
*/
void wxLogTrace(const char* formatString, ... );
void wxVLogTrace(const char* formatString, va_list argPtr);
void wxLogTrace(const char* mask, const char* formatString,
... );
void wxVLogTrace(const char* mask,
const char* formatString,
va_list argPtr);
void wxLogTrace(wxTraceMask mask, const char* formatString,
... );
void wxVLogTrace(wxTraceMask mask, const char* formatString,
va_list argPtr);
//@}
/** /**
Returns the error message corresponding to the given system error code. If Returns the error message corresponding to the given system error code. If
@@ -773,96 +708,35 @@ void wxVLogTrace(wxTraceMask mask, const char* formatString,
*/ */
const wxChar* wxSysErrorMsg(unsigned long errCode = 0); const wxChar* wxSysErrorMsg(unsigned long errCode = 0);
/**
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.
If the function returns @false the initialization could not be performed,
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.
*/
bool wxInitialize();
/** /**
This function is for use in console (wxBase) programs only. It must be called This function is for use in console (wxBase) programs only. It must be called
once for each previous successful call to wxInitialize(). once for each previous successful call to wxInitialize().
*/ */
void wxUninitialize(); void wxUninitialize();
//@{
/**
The right functions for debug output. They only do something in debug
mode (when the preprocessor symbol __WXDEBUG__ is defined) and expand to
nothing in release mode (otherwise).
*/
void wxLogDebug(const char* formatString, ... );
void wxVLogDebug(const char* formatString, va_list argPtr);
//@}
/**
This function doesn't exist in wxWidgets but it is created by using
the IMPLEMENT_APP() macro. Thus, before using it
anywhere but in the same module where this macro is used, you must make it
available using DECLARE_APP().
The advantage of using this function compared to directly using the global
wxTheApp pointer is that the latter is of type @c 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.
*/
wxAppDerivedClass wxGetApp();
//@{
/**
Messages logged by these functions will appear in the statusbar of the @a frame
or of the top level application window by default (i.e. when using
the second version of the functions).
If the target frame doesn't have a statusbar, the message will be lost.
*/
void wxLogStatus(wxFrame* frame, const char* formatString,
... );
void wxVLogStatus(wxFrame* frame, const char* formatString,
va_list argPtr);
void wxLogStatus(const char* formatString, ... );
void wxVLogStatus(const char* formatString, va_list argPtr);
//@}
/**
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.
If the function returns @false the initialization could not be performed,
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.
*/
bool wxInitialize();
/**
This is used in headers to create a forward declaration of the
wxGetApp() function implemented by
IMPLEMENT_APP(). It creates the declaration
@c className wxGetApp(void).
Example:
@code
DECLARE_APP(MyApp)
@endcode
*/
#define DECLARE_APP() /* implementation is private */
/** /**
Calls wxApp::Yield. Calls wxApp::Yield.
@deprecated
This function is kept only for backwards compatibility. Please use This function is kept only for backwards compatibility. Please use
the wxApp::Yield method instead in any new code. the wxApp::Yield method instead in any new code.
*/ */
bool wxYield(); bool wxYield();
//@{
/**
Mostly used by wxWidgets itself, but might be handy for logging errors after
system call (API function) failure. It logs the specified message text as well
as the last system error code (@e errno or @e ::GetLastError() depending
on the platform) and the corresponding error message. The second form
of this function takes the error code explicitly as the first argument.
@see wxSysErrorCode(), wxSysErrorMsg()
*/
void wxLogSysError(const char* formatString, ... );
void wxVLogSysError(const char* formatString,
va_list argPtr);
//@}
//@{ //@{
/** /**
@@ -870,15 +744,24 @@ void wxVLogSysError(const char* formatString,
using the default wxWidgets entry code (e.g. main or WinMain). For example, you using the default wxWidgets entry code (e.g. main or WinMain). For example, you
can initialize wxWidgets from an Microsoft Foundation Classes application using can initialize wxWidgets from an Microsoft Foundation Classes application using
this function. this function.
The following overload of wxEntry is available under all platforms:
(notice that under Windows CE platform, and only there, the type of The following overload of wxEntry is available under all platforms:
@a pCmdLine is @c wchar_t *, otherwise it is @c char *, even in (notice that under Windows CE platform, and only there, the type of @a pCmdLine
Unicode build). is @c wchar_t *, otherwise it is @c char *, even in Unicode build).
@remarks To clean up wxWidgets, call wxApp::OnExit followed by the static @remarks To clean up wxWidgets, call wxApp::OnExit followed by the static
function wxApp::CleanUp. For example, if exiting from function wxApp::CleanUp. For example, if exiting from an MFC application
an MFC application that also uses wxWidgets: 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
@see wxEntryStart() @see wxEntryStart()
*/ */

View File

@@ -11,33 +11,29 @@
@wxheader{apptrait.h} @wxheader{apptrait.h}
The @b wxAppTraits class defines various configurable aspects of a wxApp. The @b wxAppTraits class defines various configurable aspects of a wxApp.
You can access it using wxApp::GetTraits function and you can You can access it using wxApp::GetTraits function and you can create your
create your own wxAppTraits overriding the own wxAppTraits overriding the wxApp::CreateTraits function.
wxApp::CreateTraits function.
By default, wxWidgets creates a @c wxConsoleAppTraits object for console By default, wxWidgets creates a @c wxConsoleAppTraits object for console
applications applications (i.e. those applications linked against wxBase library only -
(i.e. those applications linked against wxBase library only - see the see the @ref page_libs page) and a @c wxGUIAppTraits object for GUI
@ref overview_librarieslist "Libraries list" page) and a @c wxGUIAppTraits
object for GUI
applications. applications.
@library{wxbase} @library{wxbase}
@category{FIXME} @category{appmanagement}
@see @ref overview_wxappoverview "wxApp overview", wxApp @see @ref overview_app, wxApp
*/ */
class wxAppTraits class wxAppTraits
{ {
public: public:
/** /**
Called by wxWidgets to create the default configuration object for the Called by wxWidgets to create the default configuration object for the
application. The default version creates a registry-based application. The default version creates a registry-based wxRegConfig
wxRegConfig() class under MSW and class under MSW and wxFileConfig under all other platforms.
wxFileConfig under all other platforms. The
wxApp wxApp::GetAppName and The wxApp::GetAppName and wxApp::GetVendorName methods are used to
wxApp::GetVendorName methods are used to determine the determine the registry key or file name.
registry key or file name.
*/ */
virtual wxConfigBase* CreateConfig(); virtual wxConfigBase* CreateConfig();
@@ -57,11 +53,12 @@ public:
virtual wxMessageOutput* CreateMessageOutput(); virtual wxMessageOutput* CreateMessageOutput();
/** /**
Returns the renderer to use for drawing the generic controls (return value may Returns the renderer to use for drawing the generic controls (return
be @NULL value may be @NULL in which case the default renderer for the current
in which case the default renderer for the current platform is used); platform is used); this is used in GUI mode only and always returns @NULL
this is used in GUI mode only and always returns @NULL in console. in console.
NOTE: returned pointer will be deleted by the caller.
@note the returned pointer needs to be deleted by the caller.
*/ */
virtual wxRendererNative* CreateRenderer(); virtual wxRendererNative* CreateRenderer();
@@ -76,8 +73,8 @@ public:
/** /**
Returns the wxStandardPaths object for the application. Returns the wxStandardPaths object for the application.
It's normally the same for wxBase and wxGUI except in the case of wxMac and It's normally the same for wxBase and wxGUI except in the case of wxMac
wxCocoa. and wxCocoa.
*/ */
virtual wxStandardPaths GetStandardPaths(); virtual wxStandardPaths GetStandardPaths();
@@ -85,11 +82,12 @@ public:
Returns the wxWidgets port ID used by the running program and eventually Returns the wxWidgets port ID used by the running program and eventually
fills the given pointers with the values of the major and minor digits fills the given pointers with the values of the major and minor digits
of the native toolkit currently used. of the native toolkit currently used.
The version numbers returned are thus detected at run-time and not compile-time The version numbers returned are thus detected at run-time and not compile-time
(except when this is not possible e.g. wxMotif). (except when this is not possible e.g. wxMotif).
E.g. if your program is using wxGTK port this function will return wxPORT_GTK E.g. if your program is using wxGTK port this function will return wxPORT_GTK
and and put in given pointers the versions of the GTK library in use.
put in given pointers the versions of the GTK library in use.
See wxPlatformInfo for more details. See wxPlatformInfo for more details.
*/ */
virtual wxPortId GetToolkitVersion(int* major = NULL, virtual wxPortId GetToolkitVersion(int* major = NULL,
@@ -101,8 +99,8 @@ public:
virtual bool HasStderr(); virtual bool HasStderr();
/** /**
Returns @true if the library was built as wxUniversal. Always returns Returns @true if the library was built as wxUniversal.
@false for wxBase-only apps. Always returns @false for wxBase-only apps.
*/ */
bool IsUsingUniversalWidgets() const; bool IsUsingUniversalWidgets() const;

View File

@@ -775,3 +775,152 @@ public:
void wxSafeShowMessage(const wxString& title, void wxSafeShowMessage(const wxString& title,
const wxString& text); const wxString& text);
//@{
/**
For all normal, informational messages. They also appear in a message box by
default (but it can be changed).
*/
void wxLogMessage(const char* formatString, ... );
void wxVLogMessage(const char* formatString, va_list argPtr);
//@}
//@{
/**
For verbose output. Normally, it is suppressed, but
might be activated if the user wishes to know more details about the program
progress (another, but possibly confusing name for the same function is @b
wxLogInfo).
*/
void wxLogVerbose(const char* formatString, ... );
void wxVLogVerbose(const char* formatString, va_list argPtr);
//@}
//@{
/**
For warnings - they are also normally shown to the user, but don't interrupt
the program work.
*/
void wxLogWarning(const char* formatString, ... );
void wxVLogWarning(const char* formatString, va_list argPtr);
//@}
//@{
/**
Like wxLogError(), but also
terminates the program with the exit code 3. Using @e abort() standard
function also terminates the program with this exit code.
*/
void wxLogFatalError(const char* formatString, ... );
void wxVLogFatalError(const char* formatString,
va_list argPtr);
//@}
//@{
/**
The functions to use for error messages, i.e. the messages that must be shown
to the user. The default processing is to pop up a message box to inform the
user about it.
*/
void wxLogError(const char* formatString, ... );
void wxVLogError(const char* formatString, va_list argPtr);
//@}
//@{
/**
As @b wxLogDebug, trace functions only do something in debug build and
expand to nothing in the release one. The reason for making
it a separate function from it is that usually there are a lot of trace
messages, so it might make sense to separate them from other debug messages.
The trace messages also usually can be separated into different categories and
the second and third versions of this function only log the message if the
@a mask which it has is currently enabled in wxLog. This
allows to selectively trace only some operations and not others by changing
the value of the trace mask (possible during the run-time).
For the second function (taking a string mask), the message is logged only if
the mask has been previously enabled by the call to
wxLog::AddTraceMask or by setting
@ref overview_envvars "@c WXTRACE environment variable".
The predefined string trace masks
used by wxWidgets are:
wxTRACE_MemAlloc: trace memory allocation (new/delete)
wxTRACE_Messages: trace window messages/X callbacks
wxTRACE_ResAlloc: trace GDI resource allocation
wxTRACE_RefCount: trace various ref counting operations
wxTRACE_OleCalls: trace OLE method calls (Win32 only)
@b Caveats: since both the mask and the format string are strings,
this might lead to function signature confusion in some cases:
if you intend to call the format string only version of wxLogTrace,
then add a %s format string parameter and then supply a second string parameter
for that %s, the string mask version of wxLogTrace will erroneously get called instead, since you are supplying two string parameters to the function.
In this case you'll unfortunately have to avoid having two leading
string parameters, e.g. by adding a bogus integer (with its %d format string).
The third version of the function only logs the message if all the bits
corresponding to the @a mask are set in the wxLog trace mask which can be
set by wxLog::SetTraceMask. This version is less
flexible than the previous one because it doesn't allow defining the user
trace masks easily - this is why it is deprecated in favour of using string
trace masks.
wxTraceMemAlloc: trace memory allocation (new/delete)
wxTraceMessages: trace window messages/X callbacks
wxTraceResAlloc: trace GDI resource allocation
wxTraceRefCount: trace various ref counting operations
wxTraceOleCalls: trace OLE method calls (Win32 only)
*/
void wxLogTrace(const char* formatString, ... );
void wxVLogTrace(const char* formatString, va_list argPtr);
void wxLogTrace(const char* mask, const char* formatString,
... );
void wxVLogTrace(const char* mask,
const char* formatString,
va_list argPtr);
void wxLogTrace(wxTraceMask mask, const char* formatString,
... );
void wxVLogTrace(wxTraceMask mask, const char* formatString,
va_list argPtr);
//@}
//@{
/**
The right functions for debug output. They only do something in debug
mode (when the preprocessor symbol __WXDEBUG__ is defined) and expand to
nothing in release mode (otherwise).
*/
void wxLogDebug(const char* formatString, ... );
void wxVLogDebug(const char* formatString, va_list argPtr);
//@}
//@{
/**
Messages logged by these functions will appear in the statusbar of the @a frame
or of the top level application window by default (i.e. when using
the second version of the functions).
If the target frame doesn't have a statusbar, the message will be lost.
*/
void wxLogStatus(wxFrame* frame, const char* formatString,
... );
void wxVLogStatus(wxFrame* frame, const char* formatString,
va_list argPtr);
void wxLogStatus(const char* formatString, ... );
void wxVLogStatus(const char* formatString, va_list argPtr);
//@}
//@{
/**
Mostly used by wxWidgets itself, but might be handy for logging errors after
system call (API function) failure. It logs the specified message text as well
as the last system error code (@e errno or @e ::GetLastError() depending
on the platform) and the corresponding error message. The second form
of this function takes the error code explicitly as the first argument.
@see wxSysErrorCode(), wxSysErrorMsg()
*/
void wxLogSysError(const char* formatString, ... );
void wxVLogSysError(const char* formatString,
va_list argPtr);
//@}