]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/app.tex
many wxItemContainer-related changes:
[wxWidgets.git] / docs / latex / wx / app.tex
CommitLineData
a660d684
KB
1\section{\class{wxApp}}\label{wxapp}
2
3The {\bf wxApp} class represents the application itself. It is used
4to:
5
6\begin{itemize}\itemsep=0pt
7\item set and get application-wide properties;
8\item implement the windowing system message or event loop;
9\item initiate application processing via \helpref{wxApp::OnInit}{wxapponinit};
10\item allow default processing of events not handled by other
11objects in the application.
12\end{itemize}
13
14You should use the macro IMPLEMENT\_APP(appClass) in your application implementation
fc2171bd 15file to tell wxWidgets how to create an instance of your application class.
a660d684
KB
16
17Use DECLARE\_APP(appClass) in a header file if you want the wxGetApp function (which returns
18a reference to your application object) to be visible to other files.
19
20\wxheading{Derived from}
21
22\helpref{wxEvtHandler}{wxevthandler}\\
23\helpref{wxObject}{wxobject}
24
954b8ae6
JS
25\wxheading{Include files}
26
27<wx/app.h>
28
a660d684
KB
29\wxheading{See also}
30
31\helpref{wxApp overview}{wxappoverview}
32
33\latexignore{\rtfignore{\wxheading{Members}}}
34
bc37bb43 35
f510b7b2 36\membersection{wxApp::wxApp}\label{wxappctor}
a660d684 37
0e10e38d 38\func{}{wxApp}{\void}
a660d684
KB
39
40Constructor. Called implicitly with a definition of a wxApp object.
41
4c39aa3a 42
f510b7b2 43\membersection{wxApp::\destruct{wxApp}}\label{wxappdtor}
a660d684 44
3f39c254 45\func{virtual}{\destruct{wxApp}}{\void}
a660d684
KB
46
47Destructor. Will be called implicitly on program exit if the wxApp
48object is created on the stack.
49
4c39aa3a 50
a660d684
KB
51\membersection{wxApp::argc}\label{wxappargc}
52
53\member{int}{argc}
54
55Number of command line arguments (after environment-specific processing).
56
4c39aa3a 57
a660d684
KB
58\membersection{wxApp::argv}\label{wxappargv}
59
749a05ee 60\member{wxChar **}{argv}
a660d684
KB
61
62Command line arguments (after environment-specific processing).
63
4c39aa3a 64
a660d684
KB
65\membersection{wxApp::CreateLogTarget}\label{wxappcreatelogtarget}
66
67\func{virtual wxLog*}{CreateLogTarget}{\void}
68
69Creates a wxLog class for the application to use for logging errors. The default
70implementation returns a new wxLogGui class.
71
72\wxheading{See also}
73
74\helpref{wxLog}{wxlog}
75
4c39aa3a 76
afdf936c
VZ
77\membersection{wxApp::CreateTraits}\label{wxappcreatetraits}
78
79\func{virtual wxAppTraits *}{CreateTraits}{\void}
80
81Creates the \helpref{wxAppTraits}{wxapptraits} object when \helpref{GetTraits}{wxappgettraits}
82needs it for the first time.
83
84\wxheading{See also}
85
86\helpref{wxAppTraits}{wxapptraits}
87
88
a660d684
KB
89\membersection{wxApp::Dispatch}\label{wxappdispatch}
90
c805f6c3 91\func{virtual void}{Dispatch}{\void}
a660d684
KB
92
93Dispatches the next event in the windowing system event queue.
94
95This can be used for programming event loops, e.g.
96
97\begin{verbatim}
98 while (app.Pending())
99 Dispatch();
100\end{verbatim}
101
102\wxheading{See also}
103
104\helpref{wxApp::Pending}{wxapppending}
105
4c39aa3a 106
82ce8b17
WS
107\membersection{wxApp::ExitMainLoop}\label{wxappexitmainloop}
108
109\func{virtual void}{ExitMainLoop}{\void}
110
111Call this to explicitly exit the main message (event) loop.
112You should normally exit the main loop (and the application) by deleting
113the top window.
114
115
9154d8cf
VZ
116\membersection{wxApp::FilterEvent}\label{wxappfilterevent}
117
118\func{int}{FilterEvent}{\param{wxEvent\& }{event}}
119
120This function is called before processing any event and allows the application
121to preempt the processing of some events. If this method returns $-1$ the event
cc81d32f 122is processed normally, otherwise either {\tt true} or {\tt false} should be
9154d8cf
VZ
123returned and the event processing stops immediately considering that the event
124had been already processed (for the former return value) or that it is not
125going to be processed at all (for the latter one).
126
4c39aa3a 127
a660d684
KB
128\membersection{wxApp::GetAppName}\label{wxappgetappname}
129
130\constfunc{wxString}{GetAppName}{\void}
131
132Returns the application name.
133
134\wxheading{Remarks}
135
fc2171bd 136wxWidgets sets this to a reasonable default before
a660d684
KB
137calling \helpref{wxApp::OnInit}{wxapponinit}, but the application can reset it at will.
138
4c39aa3a 139
a660d684
KB
140\membersection{wxApp::GetClassName}\label{wxappgetclassname}
141
142\constfunc{wxString}{GetClassName}{\void}
143
144Gets the class name of the application. The class name may be used in a platform specific
145manner to refer to the application.
146
147\wxheading{See also}
148
149\helpref{wxApp::SetClassName}{wxappsetclassname}
150
4c39aa3a 151
f59d80ca 152\membersection{wxApp::GetExitOnFrameDelete}\label{wxappgetexitonframedelete}
a660d684 153
dab73021 154\constfunc{bool}{GetExitOnFrameDelete}{\void}
a660d684 155
cc81d32f 156Returns true if the application will exit when the top-level window is deleted, false
a660d684
KB
157otherwise.
158
159\wxheading{See also}
160
1cbee0b4
VZ
161\helpref{wxApp::SetExitOnFrameDelete}{wxappsetexitonframedelete},\\
162\helpref{wxApp shutdown overview}{wxappshutdownoverview}
a660d684 163
4c39aa3a 164
82ce8b17
WS
165\membersection{wxApp::GetInstance}\label{wxappgetinstance}
166
167\func{static wxAppConsole *}{GetInstance}{\void}
168
169Returns the one and only global application object.
170Usually \texttt{wxTheApp} is usead instead.
171
172\wxheading{See also}
173
174\helpref{wxApp::SetInstance}{wxappsetinstance}
175
176
a660d684
KB
177\membersection{wxApp::GetTopWindow}\label{wxappgettopwindow}
178
83a5b533 179\constfunc{virtual wxWindow *}{GetTopWindow}{\void}
a660d684
KB
180
181Returns a pointer to the top window.
182
2a47d3c1
JS
183\wxheading{Remarks}
184
185If the top window hasn't been set using \helpref{wxApp::SetTopWindow}{wxappsettopwindow}, this
186function will find the first top-level window (frame or dialog) and return that.
187
a660d684
KB
188\wxheading{See also}
189
8480b297
RR
190\helpref{SetTopWindow}{wxappsettopwindow}
191
4c39aa3a 192
afdf936c
VZ
193
194\membersection{wxApp::GetTraits}\label{wxappgettraits}
195
196\func{wxAppTraits *}{GetTraits}{\void}
197
198Returns a pointer to the \helpref{wxAppTraits}{wxapptraits} object for the application.
199If you want to customize the \helpref{wxAppTraits}{wxapptraits} object, you must override the
200\helpref{CreateTraits}{wxappcreatetraits} function.
201
202
203
8480b297
RR
204\membersection{wxApp::GetUseBestVisual}\label{wxappgetusebestvisual}
205
206\constfunc{bool}{GetUseBestVisual}{\void}
207
cc81d32f
VS
208Returns true if the application will use the best visual on systems that support
209different visuals, false otherwise.
8480b297
RR
210
211\wxheading{See also}
212
213\helpref{SetUseBestVisual}{wxappsetusebestvisual}
a660d684 214
4c39aa3a 215
e06b9569 216\membersection{wxApp::GetVendorName}\label{wxappgetvendorname}
2aa59ef4
VS
217
218\constfunc{wxString}{GetVendorName}{\void}
219
220Returns the application's vendor name.
221
4c39aa3a 222
2fd47df6 223\membersection{wxApp::IsActive}\label{wxappisactive}
a660d684 224
2fd47df6 225\constfunc{bool}{IsActive}{\void}
a660d684 226
2fd47df6
VZ
227Returns \true if the application is active, i.e. if one of its windows is
228currently in the foreground. If this function returns \false and you need to
229attract users attention to the application, you may use
230\helpref{wxTopLevelWindow::RequestUserAttention}{wxtoplevelwindowrequestuserattention}
231to do it.
a660d684 232
4c39aa3a 233
5f4f5b58
VZ
234\membersection{wxApp::IsMainLoopRunning}\label{wxappismainlooprunning}
235
9b0db452 236\func{static bool}{IsMainLoopRunning}{\void}
5f4f5b58
VZ
237
238Returns \true if the main event loop is currently running, i.e. if the
239application is inside \helpref{OnRun}{wxapponrun}.
240
fab86f26 241This can be useful to test whether events can be dispatched. For example,
5f4f5b58
VZ
242if this function returns \false, non-blocking sockets cannot be used because
243the events from them would never be processed.
244
245
a660d684
KB
246\membersection{wxApp::MainLoop}\label{wxappmainloop}
247
c805f6c3 248\func{virtual int}{MainLoop}{\void}
a660d684 249
fc2171bd 250Called by wxWidgets on creation of the application. Override this if you wish
a660d684
KB
251to provide your own (environment-dependent) main loop.
252
253\wxheading{Return value}
254
255Returns 0 under X, and the wParam of the WM\_QUIT message under Windows.
256
a5f1fd3e
VZ
257%% VZ: OnXXX() functions should *not* be documented
258%%
259%%\membersection{wxApp::OnActivate}\label{wxapponactivate}
260%%
261%%\func{void}{OnActivate}{\param{wxActivateEvent\& }{event}}
262%%
263%%Provide this member function to know whether the application is being
264%%activated or deactivated (Windows only).
265%%
266%%\wxheading{See also}
267%%
268%%\helpref{wxWindow::OnActivate}{wxwindowonactivate}, \helpref{wxActivateEvent}{wxactivateevent}
269%%
270%%\membersection{wxApp::OnCharHook}\label{wxapponcharhook}
271%%
272%%\func{void}{OnCharHook}{\param{wxKeyEvent\&}{ event}}
273%%
274%%This event handler function is called (under Windows only) to allow the window to intercept keyboard events
275%%before they are processed by child windows.
276%%
277%%\wxheading{Parameters}
278%%
279%%\docparam{event}{The keypress event.}
280%%
281%%\wxheading{Remarks}
282%%
283%%Use the wxEVT\_CHAR\_HOOK macro in your event table.
284%%
285%%If you use this member, you can selectively consume keypress events by calling\rtfsp
286%%\helpref{wxEvent::Skip}{wxeventskip} for characters the application is not interested in.
287%%
288%%\wxheading{See also}
289%%
290%%\helpref{wxKeyEvent}{wxkeyevent}, \helpref{wxWindow::OnChar}{wxwindowonchar},\rtfsp
291%%\helpref{wxWindow::OnCharHook}{wxwindowoncharhook}, \helpref{wxDialog::OnCharHook}{wxdialogoncharhook}
292
4c39aa3a 293
3ec4a23f 294\membersection{wxApp::OnAssertFailure}\label{wxapponassertfailure}
a5f1fd3e 295
3ec4a23f 296\func{void}{OnAssertFailure}{\param{const wxChar }{*file}, \param{int }{line}, \param{const wxChar }{*func}, \param{const wxChar }{*cond}, \param{const wxChar }{*msg}}
a5f1fd3e
VZ
297
298This function is called when an assert failure occurs, i.e. the condition
cc81d32f 299specified in \helpref{wxASSERT}{wxassert} macro evaluated to {\tt false}.
1156efc1 300It is only called in debug mode (when {\tt \_\_WXDEBUG\_\_} is defined) as
a5f1fd3e
VZ
301asserts are not left in the release code at all.
302
3ec4a23f 303The base class version shows the default assert failure dialog box proposing to
a5f1fd3e 304the user to stop the program, continue or ignore all subsequent asserts.
a660d684 305
a5f1fd3e 306\wxheading{Parameters}
a660d684 307
43e8916f 308\docparam{file}{the name of the source file where the assert occurred}
a660d684 309
43e8916f 310\docparam{line}{the line number in this file where the assert occurred}
a660d684 311
3ec4a23f
VZ
312\docparam{func}{the name of the function where the assert occurred, may be
313empty if the compiler doesn't support C99 \texttt{\_\_FUNCTION\_\_}}
314
315\docparam{cond}{the condition of the failed assert in text form}
aad65f13 316
a5f1fd3e
VZ
317\docparam{msg}{the message specified as argument to
318\helpref{wxASSERT\_MSG}{wxassertmsg} or \helpref{wxFAIL\_MSG}{wxfailmsg}, will
319be {\tt NULL} if just \helpref{wxASSERT}{wxassert} or \helpref{wxFAIL}{wxfail}
320was used}
a660d684 321
a660d684 322
bf188f1a 323\membersection{wxApp::OnCmdLineError}\label{wxapponcmdlineerror}
a37a5a73 324
bf188f1a 325\func{bool}{OnCmdLineError}{\param{wxCmdLineParser\& }{parser}}
a37a5a73 326
bf188f1a
VZ
327Called when command line parsing fails (i.e. an incorrect command line option
328was specified by the user). The default behaviour is to show the program usage
329text and abort the program.
a37a5a73 330
cc81d32f
VS
331Return {\tt true} to continue normal execution or {\tt false} to return
332{\tt false} from \helpref{OnInit}{wxapponinit} thus terminating the program.
a37a5a73
VZ
333
334\wxheading{See also}
335
bf188f1a 336\helpref{OnInitCmdLine}{wxapponinitcmdline}
a37a5a73 337
4c39aa3a 338
bf188f1a 339\membersection{wxApp::OnCmdLineHelp}\label{wxapponcmdlinehelp}
a660d684 340
bf188f1a 341\func{bool}{OnCmdLineHelp}{\param{wxCmdLineParser\& }{parser}}
a660d684 342
bf188f1a
VZ
343Called when the help option ({\tt --help}) was specified on the command line.
344The default behaviour is to show the program usage text and abort the program.
a660d684 345
cc81d32f
VS
346Return {\tt true} to continue normal execution or {\tt false} to return
347{\tt false} from \helpref{OnInit}{wxapponinit} thus terminating the program.
a660d684
KB
348
349\wxheading{See also}
350
bf188f1a 351\helpref{OnInitCmdLine}{wxapponinitcmdline}
a660d684 352
4c39aa3a 353
bf188f1a 354\membersection{wxApp::OnCmdLineParsed}\label{wxapponcmdlineparsed}
387a3b02 355
bf188f1a 356\func{bool}{OnCmdLineParsed}{\param{wxCmdLineParser\& }{parser}}
387a3b02 357
bf188f1a
VZ
358Called after the command line had been successfully parsed. You may override
359this method to test for the values of the various parameters which could be
360set from the command line.
387a3b02 361
bf188f1a
VZ
362Don't forget to call the base class version unless you want to suppress
363processing of the standard command line options.
387a3b02 364
cc81d32f
VS
365Return {\tt true} to continue normal execution or {\tt false} to return
366{\tt false} from \helpref{OnInit}{wxapponinit} thus terminating the program.
387a3b02 367
bf188f1a
VZ
368\wxheading{See also}
369
370\helpref{OnInitCmdLine}{wxapponinitcmdline}
371
4c39aa3a 372
f510b7b2 373\membersection{wxApp::OnExceptionInMainLoop}\label{wxapponexceptioninmainloop}
b76f0023
VZ
374
375\func{virtual bool}{OnExceptionInMainLoop}{\void}
376
377This function is called if an unhandled exception occurs inside the main
378application event loop. It can return \true to ignore the exception and to
379continue running the loop or \false to exit the loop and terminate the
380program. In the latter case it can also use C++ \texttt{throw} keyword to
381rethrow the current exception.
382
383The default behaviour of this function is the latter in all ports except under
384Windows where a dialog is shown to the user which allows him to choose between
385the different options. You may override this function in your class to do
386something more appropriate.
387
388Finally note that if the exception is rethrown from here, it can be caught in
389\helpref{OnUnhandledException}{wxapponunhandledexception}.
390
391
4c39aa3a
VZ
392\membersection{wxApp::OnExit}\label{wxapponexit}
393
bc37bb43 394\func{virtual int}{OnExit}{\void}
4c39aa3a 395
bc37bb43 396Override this member function for any processing which needs to be
4c39aa3a
VZ
397done as the application is about to exit. OnExit is called after
398destroying all application windows and controls, but before
fc2171bd 399wxWidgets cleanup. Note that it is not called at all if
bc37bb43
VZ
400\helpref{OnInit}{wxapponinit} failed.
401
402The return value of this function is currently ignored, return the same value
403as returned by the base class method if you override it.
4c39aa3a
VZ
404
405
bf188f1a
VZ
406\membersection{wxApp::OnFatalException}\label{wxapponfatalexception}
407
408\func{void}{OnFatalException}{\void}
387a3b02 409
bf188f1a
VZ
410This function may be called if something fatal happens: an unhandled
411exception under Win32 or a a fatal signal under Unix, for example. However,
412this will not happen by default: you have to explicitly call
413\helpref{wxHandleFatalExceptions}{wxhandlefatalexceptions} to enable this.
387a3b02 414
bf188f1a
VZ
415Generally speaking, this function should only show a message to the user and
416return. You may attempt to save unsaved data but this is not guaranteed to
417work and, in fact, probably won't.
387a3b02
JS
418
419\wxheading{See also}
420
d2c2afc9 421\helpref{wxHandleFatalExceptions}{wxhandlefatalexceptions}
bf188f1a
VZ
422
423%% VZ: the wxApp event handler are private and should not be documented here!
424%%
425%%\membersection{wxApp::OnIdle}\label{wxapponidle}
426%%
427%%\func{void}{OnIdle}{\param{wxIdleEvent\& }{event}}
428%%
429%%Override this member function for any processing which needs to be done
430%%when the application is idle. You should call wxApp::OnIdle from your own function,
431%%since this forwards OnIdle events to windows and also performs garbage collection for
432%%windows whose destruction has been delayed.
433%%
fc2171bd
JS
434%%wxWidgets' strategy for OnIdle processing is as follows. After pending user interface events for an
435%%application have all been processed, wxWidgets sends an OnIdle event to the application object. wxApp::OnIdle itself
bf188f1a
VZ
436%%sends an OnIdle event to each application window, allowing windows to do idle processing such as updating
437%%their appearance. If either wxApp::OnIdle or a window OnIdle function requested more time, by
fc2171bd 438%%calling \helpref{wxIdleEvent::RequestMore}{wxidleeventrequestmore}, wxWidgets will send another OnIdle
bf188f1a
VZ
439%%event to the application object. This will occur in a loop until either a user event is found to be
440%%pending, or OnIdle requests no more time. Then all pending user events are processed until the system
441%%goes idle again, when OnIdle is called, and so on.
442%%
443%%\wxheading{See also}
444%%
445%%\helpref{wxWindow::OnIdle}{wxwindowonidle}, \helpref{wxIdleEvent}{wxidleevent},\rtfsp
446%%\helpref{wxWindow::SendIdleEvents}{wxappsendidleevents}
447%%
448%%\membersection{wxApp::OnEndSession}\label{wxapponendsession}
449%%
450%%\func{void}{OnEndSession}{\param{wxCloseEvent\& }{event}}
451%%
452%%This is an event handler function called when the operating system or GUI session is
453%%about to close down. The application has a chance to silently save information,
454%%and can optionally close itself.
455%%
456%%Use the EVT\_END\_SESSION event table macro to handle query end session events.
457%%
cc81d32f 458%%The default handler calls \helpref{wxWindow::Close}{wxwindowclose} with a true argument
bf188f1a
VZ
459%%(forcing the application to close itself silently).
460%%
461%%\wxheading{Remarks}
462%%
463%%Under X, OnEndSession is called in response to the `die' event.
464%%
465%%Under Windows, OnEndSession is called in response to the WM\_ENDSESSION message.
466%%
467%%\wxheading{See also}
468%%
469%%\helpref{wxWindow::Close}{wxwindowclose},\rtfsp
470%%\helpref{wxWindow::OnCloseWindow}{wxwindowonclosewindow},\rtfsp
471%%\helpref{wxCloseEvent}{wxcloseevent},\rtfsp
387a3b02 472
4c39aa3a 473
a660d684
KB
474\membersection{wxApp::OnInit}\label{wxapponinit}
475
476\func{bool}{OnInit}{\void}
477
478This must be provided by the application, and will usually create the
bf188f1a 479application's main window, optionally calling
bc37bb43
VZ
480\helpref{wxApp::SetTopWindow}{wxappsettopwindow}. You may use
481\helpref{OnExit}{wxapponexit} to clean up anything initialized here, provided
482that the function returns \true.
bf188f1a
VZ
483
484Notice that if you want to to use the command line processing provided by
fc2171bd 485wxWidgets you have to call the base class version in the derived class
bf188f1a 486OnInit().
a660d684 487
bc37bb43
VZ
488Return \true to continue processing, \false to exit the application
489immediately.
a660d684 490
4c39aa3a 491
bf188f1a
VZ
492\membersection{wxApp::OnInitCmdLine}\label{wxapponinitcmdline}
493
494\func{void}{OnInitCmdLine}{\param{wxCmdLineParser\& }{parser}}
495
496Called from \helpref{OnInit}{wxapponinit} and may be used to initialize the
497parser with the command line options for this application. The base class
498versions adds support for a few standard options only.
499
4c39aa3a
VZ
500\membersection{wxApp::OnRun}\label{wxapponrun}
501
502\func{virtual int}{OnRun}{\void}
503
fc2171bd 504This virtual function is where the execution of a program written in wxWidgets
4c39aa3a
VZ
505starts. The default implementation just enters the main loop and starts
506handling the events until it terminates, either because
507\helpref{ExitMainLoop}{wxappexitmainloop} has been explicitly called or because
508the last frame has been deleted and
509\helpref{GetExitOnFrameDelete}{wxappgetexitonframedelete} flag is \true (this
510is the default).
511
bc37bb43
VZ
512The return value of this function becomes the exit code of the program, so it
513should return $0$ in case of successful termination.
514
515
e490e267 516\membersection{wxApp::OnUnhandledException}\label{wxapponunhandledexception}
4c39aa3a
VZ
517
518\func{virtual void}{OnUnhandledException}{\void}
519
520This function is called when an unhandled C++ exception occurs inside
521\helpref{OnRun()}{wxapponrun} (the exceptions which occur during the program
1663c655
VZ
522startup and shutdown might not be caught at all). Notice that by now the main
523event loop has been terminated and the program will exit, if you want to
524prevent this from happening (i.e. continue running after catching an exception)
525you need to override \helpref{OnExceptionInMainLoop}{wxapponexceptioninmainloop}.
526
527The default implementation shows information about the exception in debug build
528but does nothing in the release build.
4c39aa3a 529
bc37bb43 530
a660d684
KB
531\membersection{wxApp::ProcessMessage}\label{wxappprocessmessage}
532
da25d3ab 533\func{bool}{ProcessMessage}{\param{WXMSG *}{msg}}
a660d684
KB
534
535Windows-only function for processing a message. This function
536is called from the main message loop, checking for windows that
cc81d32f 537may wish to process it. The function returns true if the message
fc2171bd 538was processed, false otherwise. If you use wxWidgets with another class
a660d684 539library with its own message loop, you should make sure that this
fc2171bd 540function is called to allow wxWidgets to receive messages. For example,
2edb0bde 541to allow co-existence with the Microsoft Foundation Classes, override
a660d684
KB
542the PreTranslateMessage function:
543
544\begin{verbatim}
fc2171bd 545// Provide wxWidgets message loop compatibility
a660d684
KB
546BOOL CTheApp::PreTranslateMessage(MSG *msg)
547{
da25d3ab 548 if (wxTheApp && wxTheApp->ProcessMessage((WXMSW *)msg))
cc81d32f 549 return true;
a660d684
KB
550 else
551 return CWinApp::PreTranslateMessage(msg);
552}
553\end{verbatim}
554
4c39aa3a 555
387a3b02
JS
556\membersection{wxApp::Pending}\label{wxapppending}
557
c805f6c3 558\func{virtual bool}{Pending}{\void}
387a3b02 559
cc81d32f 560Returns true if unprocessed events are in the window system event queue.
387a3b02
JS
561
562\wxheading{See also}
563
564\helpref{wxApp::Dispatch}{wxappdispatch}
565
4c39aa3a 566
a660d684
KB
567\membersection{wxApp::SendIdleEvents}\label{wxappsendidleevents}
568
dfcb9d7c 569\func{bool}{SendIdleEvents}{\param{wxWindow*}{ win}, \param{wxIdleEvent\& }{event}}
a660d684
KB
570
571Sends idle events to a window and its children.
572
fc2171bd 573Please note that this function is internal to wxWidgets and shouldn't be used
dfcb9d7c
VZ
574by user code.
575
a660d684
KB
576\wxheading{Remarks}
577
578These functions poll the top-level windows, and their children, for idle event processing.
cc81d32f 579If true is returned, more OnIdle processing is requested by one or more window.
a660d684
KB
580
581\wxheading{See also}
582
4d5a0f67 583\helpref{wxIdleEvent}{wxidleevent}
a660d684 584
4c39aa3a 585
a660d684
KB
586\membersection{wxApp::SetAppName}\label{wxappsetappname}
587
588\func{void}{SetAppName}{\param{const wxString\& }{name}}
589
590Sets the name of the application. The name may be used in dialogs
591(for example by the document/view framework). A default name is set by
fc2171bd 592wxWidgets.
a660d684
KB
593
594\wxheading{See also}
595
596\helpref{wxApp::GetAppName}{wxappgetappname}
597
4c39aa3a 598
a660d684
KB
599\membersection{wxApp::SetClassName}\label{wxappsetclassname}
600
601\func{void}{SetClassName}{\param{const wxString\& }{name}}
602
603Sets the class name of the application. This may be used in a platform specific
604manner to refer to the application.
605
606\wxheading{See also}
607
608\helpref{wxApp::GetClassName}{wxappgetclassname}
609
4c39aa3a 610
f59d80ca 611\membersection{wxApp::SetExitOnFrameDelete}\label{wxappsetexitonframedelete}
a660d684 612
f59d80ca 613\func{void}{SetExitOnFrameDelete}{\param{bool}{ flag}}
a660d684
KB
614
615Allows the programmer to specify whether the application will exit when the
616top-level frame is deleted.
617
618\wxheading{Parameters}
619
cc81d32f
VS
620\docparam{flag}{If true (the default), the application will exit when the top-level frame is
621deleted. If false, the application will continue to run.}
a660d684 622
1cbee0b4
VZ
623\wxheading{See also}
624
625\helpref{wxApp::GetExitOnFrameDelete}{wxappgetexitonframedelete},\\
626\helpref{wxApp shutdown overview}{wxappshutdownoverview}
627
4c39aa3a 628
82ce8b17
WS
629\membersection{wxApp::SetInstance}\label{wxappsetinstance}
630
631\func{static void}{SetInstance}{\param{wxAppConsole* }{app}}
632
633Allows external code to modify global \texttt{wxTheApp}, but you should really
634know what you're doing if you call it.
635
636\wxheading{Parameters}
637
638\docparam{app}{Replacement for the global application object.}
639
640\wxheading{See also}
641
642\helpref{wxApp::GetInstance}{wxappgetinstance}
643
644
a660d684
KB
645\membersection{wxApp::SetTopWindow}\label{wxappsettopwindow}
646
647\func{void}{SetTopWindow}{\param{wxWindow* }{window}}
648
2a47d3c1 649Sets the `top' window. You can call this from within \helpref{wxApp::OnInit}{wxapponinit} to
fc2171bd 650let wxWidgets know which is the main window. You don't have to set the top window;
f6bcfd97 651it is only a convenience so that (for example) certain dialogs without parents can use a
2a47d3c1 652specific window as the top window. If no top window is specified by the application,
fc2171bd 653wxWidgets just uses the first frame or dialog in its top-level window list, when it
2a47d3c1 654needs to use the top window.
a660d684
KB
655
656\wxheading{Parameters}
657
658\docparam{window}{The new top window.}
659
660\wxheading{See also}
661
662\helpref{wxApp::GetTopWindow}{wxappgettopwindow}, \helpref{wxApp::OnInit}{wxapponinit}
663
2aa59ef4 664
4c39aa3a 665
2aa59ef4
VS
666\membersection{wxApp::SetVendorName}\label{wxappsetvendorname}
667
668\func{void}{SetVendorName}{\param{const wxString\& }{name}}
669
670Sets the name of application's vendor. The name will be used
671in registry access. A default name is set by
fc2171bd 672wxWidgets.
2aa59ef4
VS
673
674\wxheading{See also}
675
676\helpref{wxApp::GetVendorName}{wxappgetvendorname}
677
4c39aa3a 678
8480b297
RR
679\membersection{wxApp::SetUseBestVisual}\label{wxappsetusebestvisual}
680
515a31bf 681\func{void}{SetUseBestVisual}{\param{bool}{ flag}, \param{bool}{ forceTrueColour = false}}
8480b297
RR
682
683Allows the programmer to specify whether the application will use the best visual
103aab26
RR
684on systems that support several visual on the same display. This is typically the
685case under Solaris and IRIX, where the default visual is only 8-bit whereas certain
2edb0bde 686applications are supposed to run in TrueColour mode.
8480b297 687
515a31bf
RR
688If \arg{forceTrueColour} is true then the application will try to force
689using a TrueColour visual and abort the app if none is found.
690
fa482912 691Note that this function has to be called in the constructor of the {\tt wxApp}
8480b297
RR
692instance and won't have any effect when called later on.
693
694This function currently only has effect under GTK.
695
696\wxheading{Parameters}
697
cc81d32f 698\docparam{flag}{If true, the app will use the best visual.}
e06b9569 699
763b3301
VS
700
701\membersection{wxApp::HandleEvent}\label{wxapphandleevent}
702
703\constfunc{virtual void}{HandleEvent}{\param{wxEvtHandler}{ *handler}, \param{wxEventFunction}{ func}, \param{wxEvent\& }{event}}
704
705This function simply invokes the given method \arg{func} of the specified
706event handler \arg{handler} with the \arg{event} as parameter. It exists solely
707to allow to catch the C++ exceptions which could be thrown by all event
708handlers in the application in one place: if you want to do this, override this
709function in your wxApp-derived class and add try/catch clause(s) to it.
710
711
5638d705 712\membersection{wxApp::Yield}\label{wxappyield}
8461e4c2 713
cc81d32f 714\func{bool}{Yield}{\param{bool}{ onlyIfNeeded = false}}
8461e4c2
VZ
715
716Yields control to pending messages in the windowing system. This can be useful, for example, when a
717time-consuming process writes to a text window. Without an occasional
718yield, the text window will not be updated properly, and on systems with
719cooperative multitasking, such as Windows 3.1 other processes will not respond.
720
721Caution should be exercised, however, since yielding may allow the
722user to perform actions which are not compatible with the current task.
723Disabling menu items or whole menus during processing can avoid unwanted
724reentrance of code: see \helpref{::wxSafeYield}{wxsafeyield} for a better
725function.
726
727Note that Yield() will not flush the message logs. This is intentional as
728calling Yield() is usually done to quickly update the screen and popping up a
729message box dialog may be undesirable. If you do wish to flush the log
730messages immediately (otherwise it will be done during the next idle loop
731iteration), call \helpref{wxLog::FlushActive}{wxlogflushactive}.
732
733Calling Yield() recursively is normally an error and an assert failure is
43e8916f 734raised in debug build if such situation is detected. However if the
cc81d32f
VS
735{\it onlyIfNeeded} parameter is {\tt true}, the method will just silently
736return {\tt false} instead.
f010ad48 737