📄 app.tex
字号:
\section{\class{wxApp}}\label{wxapp}The {\bf wxApp} class represents the application itself. It is usedto:\begin{itemize}\itemsep=0pt\item set and get application-wide properties;\item implement the windowing system message or event loop;\item initiate application processing via \helpref{wxApp::OnInit}{wxapponinit};\item allow default processing of events not handled by otherobjects in the application.\end{itemize}You should use the macro IMPLEMENT\_APP(appClass) in your application implementationfile to tell wxWidgets how to create an instance of your application class.Use DECLARE\_APP(appClass) in a header file if you want the wxGetApp function (which returnsa reference to your application object) to be visible to other files.\wxheading{Derived from}\helpref{wxEvtHandler}{wxevthandler}\\\helpref{wxObject}{wxobject}\wxheading{Include files}<wx/app.h>\wxheading{See also}\helpref{wxApp overview}{wxappoverview}\latexignore{\rtfignore{\wxheading{Members}}}\membersection{wxApp::wxApp}\label{wxappctor}\func{}{wxApp}{\void}Constructor. Called implicitly with a definition of a wxApp object.\membersection{wxApp::\destruct{wxApp}}\label{wxappdtor}\func{virtual}{\destruct{wxApp}}{\void}Destructor. Will be called implicitly on program exit if the wxAppobject is created on the stack.\membersection{wxApp::argc}\label{wxappargc}\member{int}{argc}Number of command line arguments (after environment-specific processing).\membersection{wxApp::argv}\label{wxappargv}\member{wxChar **}{argv}Command line arguments (after environment-specific processing).\membersection{wxApp::CreateLogTarget}\label{wxappcreatelogtarget}\func{virtual wxLog*}{CreateLogTarget}{\void}Creates a wxLog class for the application to use for logging errors. The defaultimplementation returns a new wxLogGui class.\wxheading{See also}\helpref{wxLog}{wxlog}\membersection{wxApp::CreateTraits}\label{wxappcreatetraits}\func{virtual wxAppTraits *}{CreateTraits}{\void}Creates the \helpref{wxAppTraits}{wxapptraits} object when \helpref{GetTraits}{wxappgettraits}needs it for the first time.\wxheading{See also}\helpref{wxAppTraits}{wxapptraits}\membersection{wxApp::Dispatch}\label{wxappdispatch}\func{virtual void}{Dispatch}{\void}Dispatches the next event in the windowing system event queue.This can be used for programming event loops, e.g.\begin{verbatim} while (app.Pending()) Dispatch();\end{verbatim}\wxheading{See also}\helpref{wxApp::Pending}{wxapppending}\membersection{wxApp::ExitMainLoop}\label{wxappexitmainloop}\func{virtual void}{ExitMainLoop}{\void}Call this to explicitly exit the main message (event) loop.You should normally exit the main loop (and the application) by deletingthe top window.\membersection{wxApp::FilterEvent}\label{wxappfilterevent}\func{int}{FilterEvent}{\param{wxEvent\& }{event}}This function is called before processing any event and allows the applicationto preempt the processing of some events. If this method returns $-1$ the eventis processed normally, otherwise either {\tt true} or {\tt false} should bereturned and the event processing stops immediately considering that the eventhad been already processed (for the former return value) or that it is notgoing to be processed at all (for the latter one).\membersection{wxApp::GetAppName}\label{wxappgetappname}\constfunc{wxString}{GetAppName}{\void}Returns the application name.\wxheading{Remarks}wxWidgets sets this to a reasonable default beforecalling \helpref{wxApp::OnInit}{wxapponinit}, but the application can reset it at will.\membersection{wxApp::GetClassName}\label{wxappgetclassname}\constfunc{wxString}{GetClassName}{\void}Gets the class name of the application. The class name may be used in a platform specificmanner to refer to the application.\wxheading{See also}\helpref{wxApp::SetClassName}{wxappsetclassname}\membersection{wxApp::GetExitOnFrameDelete}\label{wxappgetexitonframedelete}\constfunc{bool}{GetExitOnFrameDelete}{\void}Returns true if the application will exit when the top-level window is deleted, falseotherwise.\wxheading{See also}\helpref{wxApp::SetExitOnFrameDelete}{wxappsetexitonframedelete},\\\helpref{wxApp shutdown overview}{wxappshutdownoverview}\membersection{wxApp::GetInstance}\label{wxappgetinstance}\func{static wxAppConsole *}{GetInstance}{\void}Returns the one and only global application object.Usually \texttt{wxTheApp} is usead instead.\wxheading{See also}\helpref{wxApp::SetInstance}{wxappsetinstance}\membersection{wxApp::GetTopWindow}\label{wxappgettopwindow}\constfunc{virtual wxWindow *}{GetTopWindow}{\void}Returns a pointer to the top window.\wxheading{Remarks}If the top window hasn't been set using \helpref{wxApp::SetTopWindow}{wxappsettopwindow}, thisfunction will find the first top-level window (frame or dialog) and return that.\wxheading{See also}\helpref{SetTopWindow}{wxappsettopwindow}\membersection{wxApp::GetTraits}\label{wxappgettraits}\func{wxAppTraits *}{GetTraits}{\void}Returns a pointer to the \helpref{wxAppTraits}{wxapptraits} object for the application.If you want to customize the \helpref{wxAppTraits}{wxapptraits} object, you must override the\helpref{CreateTraits}{wxappcreatetraits} function.\membersection{wxApp::GetUseBestVisual}\label{wxappgetusebestvisual}\constfunc{bool}{GetUseBestVisual}{\void}Returns true if the application will use the best visual on systems that supportdifferent visuals, false otherwise.\wxheading{See also}\helpref{SetUseBestVisual}{wxappsetusebestvisual}\membersection{wxApp::GetVendorName}\label{wxappgetvendorname}\constfunc{wxString}{GetVendorName}{\void}Returns the application's vendor name.\membersection{wxApp::IsActive}\label{wxappisactive}\constfunc{bool}{IsActive}{\void}Returns \true if the application is active, i.e. if one of its windows iscurrently in the foreground. If this function returns \false and you need toattract users attention to the application, you may use \helpref{wxTopLevelWindow::RequestUserAttention}{wxtoplevelwindowrequestuserattention} to do it.\membersection{wxApp::IsMainLoopRunning}\label{wxappismainlooprunning}\func{static bool}{IsMainLoopRunning}{\void}Returns \true if the main event loop is currently running, i.e. if theapplication is inside \helpref{OnRun}{wxapponrun}.This can be useful to test whether the events can be dispatched. For example,if this function returns \false, non-blocking sockets cannot be used becausethe events from them would never be processed.\membersection{wxApp::MainLoop}\label{wxappmainloop}\func{virtual int}{MainLoop}{\void}Called by wxWidgets on creation of the application. Override this if you wishto provide your own (environment-dependent) main loop.\wxheading{Return value}Returns 0 under X, and the wParam of the WM\_QUIT message under Windows.%% VZ: OnXXX() functions should *not* be documented%%%%\membersection{wxApp::OnActivate}\label{wxapponactivate}%%%%\func{void}{OnActivate}{\param{wxActivateEvent\& }{event}}%%%%Provide this member function to know whether the application is being%%activated or deactivated (Windows only).%%%%\wxheading{See also}%%%%\helpref{wxWindow::OnActivate}{wxwindowonactivate}, \helpref{wxActivateEvent}{wxactivateevent}%%%%\membersection{wxApp::OnCharHook}\label{wxapponcharhook}%%%%\func{void}{OnCharHook}{\param{wxKeyEvent\&}{ event}}%%%%This event handler function is called (under Windows only) to allow the window to intercept keyboard events%%before they are processed by child windows.%%%%\wxheading{Parameters}%%%%\docparam{event}{The keypress event.}%%%%\wxheading{Remarks}%%%%Use the wxEVT\_CHAR\_HOOK macro in your event table.%%%%If you use this member, you can selectively consume keypress events by calling\rtfsp%%\helpref{wxEvent::Skip}{wxeventskip} for characters the application is not interested in.%%%%\wxheading{See also}%%%%\helpref{wxKeyEvent}{wxkeyevent}, \helpref{wxWindow::OnChar}{wxwindowonchar},\rtfsp%%\helpref{wxWindow::OnCharHook}{wxwindowoncharhook}, \helpref{wxDialog::OnCharHook}{wxdialogoncharhook}\membersection{wxApp::OnAssertFailure}\label{wxapponassertfailure}\func{void}{OnAssertFailure}{\param{const wxChar }{*file}, \param{int }{line}, \param{const wxChar }{*func}, \param{const wxChar }{*cond}, \param{const wxChar }{*msg}}This function is called when an assert failure occurs, i.e. the conditionspecified in \helpref{wxASSERT}{wxassert} macro evaluated to {\tt false}.It is only called in debug mode (when {\tt \_\_WXDEBUG\_\_} is defined) asasserts are not left in the release code at all.The base class version shows the default assert failure dialog box proposing tothe user to stop the program, continue or ignore all subsequent asserts.\wxheading{Parameters}\docparam{file}{the name of the source file where the assert occurred}\docparam{line}{the line number in this file where the assert occurred}\docparam{func}{the name of the function where the assert occurred, may beempty if the compiler doesn't support C99 \texttt{\_\_FUNCTION\_\_}}\docparam{cond}{the condition of the failed assert in text form}\docparam{msg}{the message specified as argument to \helpref{wxASSERT\_MSG}{wxassertmsg} or \helpref{wxFAIL\_MSG}{wxfailmsg}, willbe {\tt NULL} if just \helpref{wxASSERT}{wxassert} or \helpref{wxFAIL}{wxfail} was used}\membersection{wxApp::OnCmdLineError}\label{wxapponcmdlineerror}\func{bool}{OnCmdLineError}{\param{wxCmdLineParser\& }{parser}}Called when command line parsing fails (i.e. an incorrect command line optionwas specified by the user). The default behaviour is to show the program usagetext and abort the program.Return {\tt true} to continue normal execution or {\tt false} to return {\tt false} from \helpref{OnInit}{wxapponinit} thus terminating the program.\wxheading{See also}\helpref{OnInitCmdLine}{wxapponinitcmdline}\membersection{wxApp::OnCmdLineHelp}\label{wxapponcmdlinehelp}\func{bool}{OnCmdLineHelp}{\param{wxCmdLineParser\& }{parser}}Called when the help option ({\tt --help}) was specified on the command line.The default behaviour is to show the program usage text and abort the program.Return {\tt true} to continue normal execution or {\tt false} to return {\tt false} from \helpref{OnInit}{wxapponinit} thus terminating the program.\wxheading{See also}\helpref{OnInitCmdLine}{wxapponinitcmdline}\membersection{wxApp::OnCmdLineParsed}\label{wxapponcmdlineparsed}\func{bool}{OnCmdLineParsed}{\param{wxCmdLineParser\& }{parser}}Called after the command line had been successfully parsed. You may overridethis method to test for the values of the various parameters which could beset from the command line.Don't forget to call the base class version unless you want to suppressprocessing of the standard command line options.Return {\tt true} to continue normal execution or {\tt false} to return {\tt false} from \helpref{OnInit}{wxapponinit} thus terminating the program.\wxheading{See also}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -