]> git.saurik.com Git - wxWidgets.git/blame - interface/app.h
some more comments about wxSortedArrayString::Sort
[wxWidgets.git] / interface / app.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: app.h
e54c96f1 3// Purpose: interface of wxApp
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
8064223b 9
23324ae1 10/**
8064223b 11 @class wxAppConsole
23324ae1 12 @wxheader{app.h}
7c913512 13
8064223b
FM
14 This class is essential for writing console-only or hybrid apps without
15 having to define wxUSE_GUI=0.
7c913512 16
8064223b 17 @todo MORE INFO
7c913512 18
23324ae1
FM
19 @library{wxbase}
20 @category{appmanagement}
7c913512 21
96d7cc9b 22 @see @ref overview_app
23324ae1 23*/
8064223b 24class wxAppConsole : public wxEvtHandler
23324ae1 25{
8064223b 26protected:
23324ae1 27 /**
8064223b 28 Creates the wxAppTraits object when GetTraits() needs it for the first time.
23324ae1 29
8064223b 30 @see wxAppTraits
23324ae1 31 */
8064223b 32 virtual wxAppTraits* CreateTraits();
23324ae1 33
8064223b 34public:
3c4f71cc 35
8064223b
FM
36 /**
37 Constructor.
23324ae1 38 */
8064223b 39 wxAppConsole();
23324ae1
FM
40
41 /**
8064223b 42 Destructor.
23324ae1 43 */
8064223b 44 virtual ~wxAppConsole();
23324ae1
FM
45
46 /**
47 Dispatches the next event in the windowing system event queue.
8064223b
FM
48 Blocks until an event appears if there are none currently
49 (use Pending() if this is not wanted).
50
23324ae1 51 This can be used for programming event loops, e.g.
96d7cc9b
FM
52
53 @code
54 while (app.Pending())
55 Dispatch();
56 @endcode
3c4f71cc 57
8064223b
FM
58 @return @false if the event loop should stop and @true otherwise.
59
4cc4bfaf 60 @see Pending()
23324ae1 61 */
8064223b 62 virtual bool Dispatch();
23324ae1
FM
63
64 /**
65 Call this to explicitly exit the main message (event) loop.
66 You should normally exit the main loop (and the application) by deleting
67 the top window.
68 */
69 virtual void ExitMainLoop();
70
71 /**
72 This function is called before processing any event and allows the application
96d7cc9b
FM
73 to preempt the processing of some events.
74
75 If this method returns -1 the event is processed normally, otherwise either
76 @true or @false should be returned and the event processing stops immediately
77 considering that the event had been already processed (for the former return
78 value) or that it is not going to be processed at all (for the latter one).
23324ae1 79 */
8064223b 80 virtual int FilterEvent(wxEvent& event);
23324ae1
FM
81
82 /**
3c4f71cc
VS
83 Returns the user-readable application name.
84
96d7cc9b
FM
85 The difference between this string and the one returned by GetAppName() is that
86 this one is meant to be shown to the user and so should be used for the window
87 titles, page headers and so on while the other one should be only used internally,
88 e.g. for the file names or configuration file keys.
23324ae1 89 By default, returns the same string as GetAppName().
3c4f71cc 90
e54c96f1 91 @wxsince{2.9.0}
23324ae1 92 */
328f5751 93 wxString GetAppDisplayName() const;
23324ae1
FM
94
95 /**
96 Returns the application name.
3c4f71cc 97
23324ae1 98 @remarks wxWidgets sets this to a reasonable default before calling
4cc4bfaf 99 OnInit(), but the application can reset it at will.
3c4f71cc 100
4cc4bfaf 101 @see GetAppDisplayName()
23324ae1 102 */
328f5751 103 wxString GetAppName() const;
23324ae1
FM
104
105 /**
106 Gets the class name of the application. The class name may be used in a
96d7cc9b 107 platform specific manner to refer to the application.
3c4f71cc 108
4cc4bfaf 109 @see SetClassName()
23324ae1 110 */
328f5751 111 wxString GetClassName() const;
23324ae1 112
23324ae1
FM
113 /**
114 Returns the one and only global application object.
96d7cc9b 115 Usually ::wxTheApp is usead instead.
3c4f71cc 116
4cc4bfaf 117 @see SetInstance()
23324ae1 118 */
4cc4bfaf 119 static wxAppConsole* GetInstance();
23324ae1 120
23324ae1
FM
121 /**
122 Returns a pointer to the wxAppTraits object for the application.
123 If you want to customize the wxAppTraits object, you must override the
124 CreateTraits() function.
125 */
4cc4bfaf 126 wxAppTraits* GetTraits();
23324ae1 127
23324ae1
FM
128 /**
129 Returns the user-readable vendor name. The difference between this string
96d7cc9b
FM
130 and the one returned by GetVendorName() is that this one is meant to be shown
131 to the user and so should be used for the window titles, page headers and so on
132 while the other one should be only used internally, e.g. for the file names or
133 configuration file keys.
134
23324ae1 135 By default, returns the same string as GetVendorName().
3c4f71cc 136
e54c96f1 137 @wxsince{2.9.0}
23324ae1 138 */
8064223b 139 const wxString& GetVendorDisplayName() const;
23324ae1
FM
140
141 /**
142 Returns the application's vendor name.
143 */
8064223b 144 const wxString& GetVendorName() const;
23324ae1
FM
145
146 /**
4cc4bfaf
FM
147 This function simply invokes the given method @a func of the specified
148 event handler @a handler with the @a event as parameter. It exists solely
23324ae1 149 to allow to catch the C++ exceptions which could be thrown by all event
96d7cc9b
FM
150 handlers in the application in one place: if you want to do this, override
151 this function in your wxApp-derived class and add try/catch clause(s) to it.
23324ae1 152 */
8064223b 153 virtual void HandleEvent(wxEvtHandler* handler,
23324ae1 154 wxEventFunction func,
328f5751 155 wxEvent& event) const;
23324ae1 156
23324ae1
FM
157 /**
158 Returns @true if the main event loop is currently running, i.e. if the
159 application is inside OnRun().
96d7cc9b 160
23324ae1
FM
161 This can be useful to test whether events can be dispatched. For example,
162 if this function returns @false, non-blocking sockets cannot be used because
163 the events from them would never be processed.
164 */
165 static bool IsMainLoopRunning();
166
167 /**
168 Mac specific. Called in response of an "open-application" Apple event.
169 Override this to create a new document in your app.
170 */
8064223b 171 virtual void MacNewFile();
23324ae1
FM
172
173 /**
96d7cc9b
FM
174 Mac specific. Called in response of an "open-document" Apple event.
175
176 You need to override this method in order to open a document file after the
177 user double clicked on it or if the document file was dropped on either the
178 running application or the application icon in Finder.
23324ae1 179 */
8064223b 180 virtual void MacOpenFile(const wxString& fileName);
23324ae1
FM
181
182 /**
183 Mac specific. Called in response of a "get-url" Apple event.
184 */
8064223b 185 virtual void MacOpenURL(const wxString& url);
23324ae1
FM
186
187 /**
188 Mac specific. Called in response of a "print-document" Apple event.
189 */
8064223b 190 virtual void MacPrintFile(const wxString& fileName);
23324ae1
FM
191
192 /**
193 Mac specific. Called in response of a "reopen-application" Apple event.
194 */
8064223b 195 virtual void MacReopenApp();
23324ae1
FM
196
197 /**
198 Called by wxWidgets on creation of the application. Override this if you wish
199 to provide your own (environment-dependent) main loop.
3c4f71cc 200
23324ae1 201 @returns Returns 0 under X, and the wParam of the WM_QUIT message under
4cc4bfaf 202 Windows.
23324ae1
FM
203 */
204 virtual int MainLoop();
205
206 /**
207 This function is called when an assert failure occurs, i.e. the condition
e54c96f1 208 specified in wxASSERT() macro evaluated to @false.
96d7cc9b 209
23324ae1
FM
210 It is only called in debug mode (when @c __WXDEBUG__ is defined) as
211 asserts are not left in the release code at all.
23324ae1
FM
212 The base class version shows the default assert failure dialog box proposing to
213 the user to stop the program, continue or ignore all subsequent asserts.
3c4f71cc 214
7c913512 215 @param file
4cc4bfaf 216 the name of the source file where the assert occurred
7c913512 217 @param line
4cc4bfaf 218 the line number in this file where the assert occurred
7c913512 219 @param func
4cc4bfaf
FM
220 the name of the function where the assert occurred, may be
221 empty if the compiler doesn't support C99 __FUNCTION__
7c913512 222 @param cond
4cc4bfaf 223 the condition of the failed assert in text form
7c913512 224 @param msg
96d7cc9b
FM
225 the message specified as argument to wxASSERT_MSG or wxFAIL_MSG, will
226 be @NULL if just wxASSERT or wxFAIL was used
23324ae1 227 */
8064223b
FM
228 virtual void OnAssertFailure(const wxChar file, int line,
229 const wxChar func,
230 const wxChar cond,
231 const wxChar msg);
23324ae1
FM
232
233 /**
234 Called when command line parsing fails (i.e. an incorrect command line option
235 was specified by the user). The default behaviour is to show the program usage
236 text and abort the program.
96d7cc9b 237
7c913512 238 Return @true to continue normal execution or @false to return
23324ae1 239 @false from OnInit() thus terminating the program.
3c4f71cc 240
4cc4bfaf 241 @see OnInitCmdLine()
23324ae1 242 */
8064223b 243 virtual bool OnCmdLineError(wxCmdLineParser& parser);
23324ae1
FM
244
245 /**
246 Called when the help option (@c --help) was specified on the command line.
247 The default behaviour is to show the program usage text and abort the program.
96d7cc9b 248
7c913512 249 Return @true to continue normal execution or @false to return
23324ae1 250 @false from OnInit() thus terminating the program.
3c4f71cc 251
4cc4bfaf 252 @see OnInitCmdLine()
23324ae1 253 */
8064223b 254 virtual bool OnCmdLineHelp(wxCmdLineParser& parser);
23324ae1
FM
255
256 /**
257 Called after the command line had been successfully parsed. You may override
258 this method to test for the values of the various parameters which could be
259 set from the command line.
96d7cc9b 260
23324ae1
FM
261 Don't forget to call the base class version unless you want to suppress
262 processing of the standard command line options.
96d7cc9b
FM
263 Return @true to continue normal execution or @false to return @false from
264 OnInit() thus terminating the program.
3c4f71cc 265
4cc4bfaf 266 @see OnInitCmdLine()
23324ae1 267 */
8064223b 268 virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
23324ae1
FM
269
270 /**
271 This function is called if an unhandled exception occurs inside the main
272 application event loop. It can return @true to ignore the exception and to
273 continue running the loop or @false to exit the loop and terminate the
274 program. In the latter case it can also use C++ @c throw keyword to
275 rethrow the current exception.
96d7cc9b 276
23324ae1
FM
277 The default behaviour of this function is the latter in all ports except under
278 Windows where a dialog is shown to the user which allows him to choose between
279 the different options. You may override this function in your class to do
280 something more appropriate.
96d7cc9b 281
7c913512 282 Finally note that if the exception is rethrown from here, it can be caught in
23324ae1
FM
283 OnUnhandledException().
284 */
285 virtual bool OnExceptionInMainLoop();
286
287 /**
288 Override this member function for any processing which needs to be
289 done as the application is about to exit. OnExit is called after
290 destroying all application windows and controls, but before
7c913512 291 wxWidgets cleanup. Note that it is not called at all if
23324ae1 292 OnInit() failed.
96d7cc9b
FM
293
294 The return value of this function is currently ignored, return the same
295 value as returned by the base class method if you override it.
23324ae1
FM
296 */
297 virtual int OnExit();
298
299 /**
300 This function may be called if something fatal happens: an unhandled
301 exception under Win32 or a a fatal signal under Unix, for example. However,
7c913512 302 this will not happen by default: you have to explicitly call
e54c96f1 303 wxHandleFatalExceptions() to enable this.
96d7cc9b 304
23324ae1
FM
305 Generally speaking, this function should only show a message to the user and
306 return. You may attempt to save unsaved data but this is not guaranteed to
307 work and, in fact, probably won't.
3c4f71cc 308
e54c96f1 309 @see wxHandleFatalExceptions()
23324ae1 310 */
8064223b 311 virtual void OnFatalException();
23324ae1
FM
312
313 /**
314 This must be provided by the application, and will usually create the
96d7cc9b
FM
315 application's main window, optionally calling SetTopWindow().
316
317 You may use OnExit() to clean up anything initialized here, provided
23324ae1 318 that the function returns @true.
96d7cc9b 319
23324ae1
FM
320 Notice that if you want to to use the command line processing provided by
321 wxWidgets you have to call the base class version in the derived class
322 OnInit().
96d7cc9b 323
23324ae1
FM
324 Return @true to continue processing, @false to exit the application
325 immediately.
326 */
8064223b 327 virtual bool OnInit();
23324ae1
FM
328
329 /**
96d7cc9b
FM
330 Called from OnInit() and may be used to initialize the parser with the
331 command line options for this application. The base class versions adds
332 support for a few standard options only.
23324ae1 333 */
8064223b 334 virtual void OnInitCmdLine(wxCmdLineParser& parser);
23324ae1
FM
335
336 /**
337 This virtual function is where the execution of a program written in wxWidgets
338 starts. The default implementation just enters the main loop and starts
96d7cc9b
FM
339 handling the events until it terminates, either because ExitMainLoop() has
340 been explicitly called or because the last frame has been deleted and
341 GetExitOnFrameDelete() flag is @true (this is the default).
342
23324ae1
FM
343 The return value of this function becomes the exit code of the program, so it
344 should return 0 in case of successful termination.
345 */
346 virtual int OnRun();
347
348 /**
7c913512 349 This function is called when an unhandled C++ exception occurs inside
96d7cc9b
FM
350 OnRun() (the exceptions which occur during the program startup and shutdown
351 might not be caught at all). Notice that by now the main event loop has been
352 terminated and the program will exit, if you want to prevent this from happening
353 (i.e. continue running after catching an exception) you need to override
354 OnExceptionInMainLoop().
355
23324ae1
FM
356 The default implementation shows information about the exception in debug build
357 but does nothing in the release build.
358 */
359 virtual void OnUnhandledException();
360
361 /**
362 Returns @true if unprocessed events are in the window system event queue.
3c4f71cc 363
4cc4bfaf 364 @see Dispatch()
23324ae1
FM
365 */
366 virtual bool Pending();
367
8064223b
FM
368 /**
369 Set the application name to be used in the user-visible places such as window
370 titles. See GetAppDisplayName() for more about the differences between the
371 display name and name.
372 */
373 void SetAppDisplayName(const wxString& name);
374
375 /**
376 Sets the name of the application. This name should be used for file names,
377 configuration file entries and other internal strings. For the user-visible
378 strings, such as the window titles, the application display name set by
379 SetAppDisplayName() is used instead.
380
381 By default the application name is set to the name of its executable file.
382
383 @see GetAppName()
384 */
385 void SetAppName(const wxString& name);
386
387 /**
388 Sets the class name of the application. This may be used in a platform specific
389 manner to refer to the application.
390
391 @see GetClassName()
392 */
393 void SetClassName(const wxString& name);
394
395 /**
396 Allows external code to modify global ::wxTheApp, but you should really
397 know what you're doing if you call it.
398
399 @param app
400 Replacement for the global application object.
401
402 @see GetInstance()
403 */
404 static void SetInstance(wxAppConsole* app);
405
406 /**
407 Set the vendor name to be used in the user-visible places.
408 See GetVendorDisplayName() for more about the differences between the
409 display name and name.
410 */
411 void SetVendorDisplayName(const wxString& name);
412
413 /**
414 Sets the name of application's vendor. The name will be used
415 in registry access. A default name is set by wxWidgets.
416
417 @see GetVendorName()
418 */
419 void SetVendorName(const wxString& name);
420
421 /**
422 Yields control to pending messages in the windowing system.
423
424 This can be useful, for example, when a time-consuming process writes to a
425 text window. Without an occasional yield, the text window will not be updated
426 properly, and on systems with cooperative multitasking, such as Windows 3.1
427 other processes will not respond.
428
429 Caution should be exercised, however, since yielding may allow the
430 user to perform actions which are not compatible with the current task.
431 Disabling menu items or whole menus during processing can avoid unwanted
432 reentrance of code: see ::wxSafeYield for a better function.
433
434 Note that Yield() will not flush the message logs. This is intentional as
435 calling Yield() is usually done to quickly update the screen and popping up
436 a message box dialog may be undesirable. If you do wish to flush the log
437 messages immediately (otherwise it will be done during the next idle loop
438 iteration), call wxLog::FlushActive.
439
440 Calling Yield() recursively is normally an error and an assert failure is
441 raised in debug build if such situation is detected. However if the
442 @a onlyIfNeeded parameter is @true, the method will just silently
443 return @false instead.
444 */
445 virtual bool Yield(bool onlyIfNeeded = false);
446
447 /**
448 Number of command line arguments (after environment-specific processing).
449 */
450 int argc;
451
452 /**
453 Command line arguments (after environment-specific processing).
454
455 Under Windows and Linux/Unix, you should parse the command line
456 arguments and check for files to be opened when starting your
457 application. Under OS X, you need to override MacOpenFile()
458 since command line arguments are used differently there.
459
460 You may use the wxCmdLineParser to parse command line arguments.
461 */
462 wxChar** argv;
463};
464
465
466
467
468/**
469 @class wxApp
470 @wxheader{app.h}
471
472 The wxApp class represents the application itself. It is used to:
473
474 @li set and get application-wide properties;
475 @li implement the windowing system message or event loop;
476 @li initiate application processing via wxApp::OnInit;
477 @li allow default processing of events not handled by other
478 objects in the application.
479
480 You should use the macro IMPLEMENT_APP(appClass) in your application
481 implementation file to tell wxWidgets how to create an instance of your
482 application class.
483
484 Use DECLARE_APP(appClass) in a header file if you want the wxGetApp function
485 (which returns a reference to your application object) to be visible to other
486 files.
487
488 @library{wxbase}
489 @category{appmanagement}
490
491 @see @ref overview_app
492*/
493class wxApp : public wxAppConsole
494{
495public:
496 /**
497 Constructor. Called implicitly with a definition of a wxApp object.
498 */
499 wxApp();
500
501 /**
502 Destructor. Will be called implicitly on program exit if the wxApp
503 object is created on the stack.
504 */
505 virtual ~wxApp();
506
507 /**
508 Returns @true if the application will exit when the top-level frame is deleted.
509
510 @see SetExitOnFrameDelete()
511 */
512 bool GetExitOnFrameDelete() const;
513
514 /**
515 Returns @true if the application will use the best visual on systems that support
516 different visuals, @false otherwise.
517
518 @see SetUseBestVisual()
519 */
520 bool GetUseBestVisual() const;
521
522 /**
523 Returns a pointer to the top window.
524
525 @remarks If the top window hasn't been set using SetTopWindow(),
526 this function will find the first top-level window
527 (frame or dialog) and return that.
528
529 @see SetTopWindow()
530 */
531 virtual wxWindow* GetTopWindow() const;
532
533 /**
534 Returns @true if the application is active, i.e. if one of its windows is
535 currently in the foreground.
536
537 If this function returns @false and you need to attract users attention to
538 the application, you may use wxTopLevelWindow::RequestUserAttention to do it.
539 */
540 bool IsActive() const;
541
23324ae1 542 /**
96d7cc9b
FM
543 Windows-only function for processing a message. This function is called
544 from the main message loop, checking for windows that may wish to process it.
545
546 The function returns @true if the message was processed, @false otherwise.
547 If you use wxWidgets with another class library with its own message loop,
548 you should make sure that this function is called to allow wxWidgets to
3c4f71cc 549 receive messages. For example, to allow co-existence with the Microsoft
96d7cc9b 550 Foundation Classes, override the PreTranslateMessage function:
3c4f71cc 551
96d7cc9b
FM
552 @code
553 // Provide wxWidgets message loop compatibility
554 BOOL CTheApp::PreTranslateMessage(MSG *msg)
555 {
556 if (wxTheApp && wxTheApp->ProcessMessage((WXMSW *)msg))
557 return true;
558 else
559 return CWinApp::PreTranslateMessage(msg);
560 }
561 @endcode
23324ae1 562 */
4cc4bfaf 563 bool ProcessMessage(WXMSG* msg);
23324ae1
FM
564
565 /**
566 Sends idle events to a window and its children.
23324ae1
FM
567 Please note that this function is internal to wxWidgets and shouldn't be used
568 by user code.
3c4f71cc 569
23324ae1 570 @remarks These functions poll the top-level windows, and their children,
96d7cc9b
FM
571 for idle event processing. If @true is returned, more OnIdle
572 processing is requested by one or more window.
3c4f71cc 573
4cc4bfaf 574 @see wxIdleEvent
23324ae1
FM
575 */
576 bool SendIdleEvents(wxWindow* win, wxIdleEvent& event);
577
23324ae1
FM
578 /**
579 Allows the programmer to specify whether the application will exit when the
580 top-level frame is deleted.
3c4f71cc 581
7c913512 582 @param flag
96d7cc9b
FM
583 If @true (the default), the application will exit when the top-level frame
584 is deleted. If @false, the application will continue to run.
3c4f71cc 585
96d7cc9b 586 @see GetExitOnFrameDelete(), @ref overview_app_shutdown
23324ae1
FM
587 */
588 void SetExitOnFrameDelete(bool flag);
589
590 /**
96d7cc9b 591 Allows external code to modify global ::wxTheApp, but you should really
23324ae1 592 know what you're doing if you call it.
3c4f71cc 593
7c913512 594 @param app
4cc4bfaf 595 Replacement for the global application object.
3c4f71cc 596
4cc4bfaf 597 @see GetInstance()
23324ae1
FM
598 */
599 static void SetInstance(wxAppConsole* app);
600
601 /**
96d7cc9b
FM
602 Allows runtime switching of the UI environment theme.
603
604 Currently implemented for wxGTK2-only.
23324ae1 605 Return @true if theme was successfully changed.
3c4f71cc 606
7c913512 607 @param theme
4cc4bfaf 608 The name of the new theme or an absolute path to a gtkrc-theme-file
23324ae1 609 */
8064223b 610 virtual bool SetNativeTheme(const wxString& theme);
23324ae1
FM
611
612 /**
96d7cc9b
FM
613 Sets the 'top' window. You can call this from within OnInit() to let wxWidgets
614 know which is the main window. You don't have to set the top window;
23324ae1 615 it is only a convenience so that (for example) certain dialogs without parents
96d7cc9b
FM
616 can use a specific window as the top window. If no top window is specified by the
617 application, wxWidgets just uses the first frame or dialog in its top-level window
618 list, when it needs to use the top window.
3c4f71cc 619
7c913512 620 @param window
4cc4bfaf 621 The new top window.
3c4f71cc 622
4cc4bfaf 623 @see GetTopWindow(), OnInit()
23324ae1
FM
624 */
625 void SetTopWindow(wxWindow* window);
626
627 /**
628 Allows the programmer to specify whether the application will use the best
96d7cc9b
FM
629 visual on systems that support several visual on the same display. This is typically
630 the case under Solaris and IRIX, where the default visual is only 8-bit whereas
631 certain applications are supposed to run in TrueColour mode.
632
633 Note that this function has to be called in the constructor of the wxApp
23324ae1 634 instance and won't have any effect when called later on.
23324ae1 635 This function currently only has effect under GTK.
3c4f71cc 636
7c913512 637 @param flag
4cc4bfaf 638 If @true, the app will use the best visual.
96d7cc9b
FM
639 @param forceTrueColour
640 If @true then the application will try to force using a TrueColour
641 visual and abort the app if none is found.
23324ae1 642 */
4cc4bfaf 643 void SetUseBestVisual(bool flag, bool forceTrueColour = false);
23324ae1
FM
644};
645
646
e54c96f1 647
23324ae1
FM
648// ============================================================================
649// Global functions/macros
650// ============================================================================
651
23324ae1 652
8af7f7c1
BP
653/** @ingroup group_funcmacro_rtti */
654//@{
23324ae1
FM
655
656/**
8af7f7c1
BP
657 This is used in headers to create a forward declaration of the wxGetApp()
658 function implemented by IMPLEMENT_APP().
96d7cc9b
FM
659
660 It creates the declaration @a className wxGetApp(void).
8af7f7c1
BP
661
662 @header{wx/app.h}
663
23324ae1 664 Example:
4cc4bfaf 665
23324ae1 666 @code
8af7f7c1 667 DECLARE_APP(MyApp)
23324ae1
FM
668 @endcode
669*/
7baebf86 670#define DECLARE_APP( className )
23324ae1
FM
671
672/**
96d7cc9b
FM
673 This is used in the application class implementation file to make the
674 application class known to wxWidgets for dynamic construction.
8af7f7c1
BP
675
676 @header{wx/app.h}
677
96d7cc9b
FM
678 Example:
679
680 @code
681 IMPLEMENT_APP(MyApp)
682 @endcode
683
8af7f7c1
BP
684 @see DECLARE_APP().
685*/
7baebf86 686#define IMPLEMENT_APP( className )
8af7f7c1
BP
687
688//@}
689
690
691
8cd06fb5
BP
692/**
693 The global pointer to the singleton wxApp object.
694
695 @see wxApp::GetInstance()
696*/
697wxApp *wxTheApp;
698
699
700
39fb8056
FM
701/** @ingroup group_funcmacro_appinitterm */
702//@{
23324ae1 703
23324ae1 704/**
8cd06fb5
BP
705 This function doesn't exist in wxWidgets but it is created by using the
706 IMPLEMENT_APP() macro.
96d7cc9b 707
39fb8056
FM
708 Thus, before using it anywhere but in the same module where this macro is
709 used, you must make it available using DECLARE_APP().
96d7cc9b
FM
710
711 The advantage of using this function compared to directly using the global
8cd06fb5
BP
712 ::wxTheApp pointer is that the latter is of type wxApp* and so wouldn't
713 allow you to access the functions specific to your application class but
714 not present in wxApp while wxGetApp() returns the object of the right type.
027c1c27
BP
715
716 @header{wx/app.h}
23324ae1 717*/
8cd06fb5 718wxAppDerivedClass& wxGetApp();
23324ae1 719
23324ae1 720/**
4cc4bfaf 721 If @a doIt is @true, the fatal exceptions (also known as general protection
23324ae1
FM
722 faults under Windows or segmentation violations in the Unix world) will be
723 caught and passed to wxApp::OnFatalException.
96d7cc9b 724
8cd06fb5
BP
725 By default, i.e. before this function is called, they will be handled in
726 the normal way which usually just means that the application will be
727 terminated. Calling wxHandleFatalExceptions() with @a doIt equal to @false
728 will restore this default behaviour.
4cc4bfaf 729
8cd06fb5
BP
730 Notice that this function is only available if @c wxUSE_ON_FATAL_EXCEPTION
731 is 1 and under Windows platform this requires a compiler with support for
732 SEH (structured exception handling) which currently means only Microsoft
733 Visual C++ or a recent Borland C++ version.
027c1c27
BP
734
735 @header{wx/app.h}
23324ae1 736*/
96d7cc9b 737bool wxHandleFatalExceptions(bool doIt = true);
23324ae1 738
23324ae1
FM
739/**
740 This function is used in wxBase only and only if you don't create
741 wxApp object at all. In this case you must call it from your
742 @c main() function before calling any other wxWidgets functions.
96d7cc9b 743
23324ae1 744 If the function returns @false the initialization could not be performed,
96d7cc9b
FM
745 in this case the library cannot be used and wxUninitialize() shouldn't be
746 called neither.
747
748 This function may be called several times but wxUninitialize() must be
749 called for each successful call to this function.
027c1c27
BP
750
751 @header{wx/app.h}
23324ae1
FM
752*/
753bool wxInitialize();
754
755/**
96d7cc9b
FM
756 This function is for use in console (wxBase) programs only. It must be called
757 once for each previous successful call to wxInitialize().
027c1c27
BP
758
759 @header{wx/app.h}
23324ae1 760*/
96d7cc9b 761void wxUninitialize();
23324ae1 762
8cd06fb5
BP
763/**
764 This function wakes up the (internal and platform dependent) idle system,
765 i.e. it will force the system to send an idle event even if the system
766 currently @e is idle and thus would not send any idle event until after
767 some other event would get sent. This is also useful for sending events
768 between two threads and is used by the corresponding functions
769 wxPostEvent() and wxEvtHandler::AddPendingEvent().
027c1c27
BP
770
771 @header{wx/app.h}
8cd06fb5
BP
772*/
773void wxWakeUpIdle();
774
23324ae1
FM
775/**
776 Calls wxApp::Yield.
96d7cc9b
FM
777
778 @deprecated
23324ae1
FM
779 This function is kept only for backwards compatibility. Please use
780 the wxApp::Yield method instead in any new code.
027c1c27
BP
781
782 @header{wx/app.h}
23324ae1
FM
783*/
784bool wxYield();
785
39fb8056
FM
786/**
787 This function is similar to wxYield, except that it disables the user input to
788 all program windows before calling wxYield and re-enables it again
789 afterwards. If @a win is not @NULL, this window will remain enabled,
790 allowing the implementation of some limited user interaction.
791 Returns the result of the call to ::wxYield.
027c1c27
BP
792
793 @header{wx/app.h}
39fb8056
FM
794*/
795bool wxSafeYield(wxWindow* win = NULL, bool onlyIfNeeded = false);
23324ae1 796
23324ae1 797/**
39fb8056
FM
798 This function initializes wxWidgets in a platform-dependent way. Use this if you
799 are not using the default wxWidgets entry code (e.g. main or WinMain).
7c913512 800
39fb8056
FM
801 For example, you can initialize wxWidgets from an Microsoft Foundation Classes
802 (MFC) application using this function.
803
804 @note This overload of wxEntry is available under all platforms.
805
806 @see wxEntryStart()
027c1c27
BP
807
808 @header{wx/app.h}
39fb8056
FM
809*/
810int wxEntry(int& argc, wxChar** argv);
811
812/**
813 See wxEntry(int&,wxChar**) for more info about this function.
814
815 Notice that under Windows CE platform, and only there, the type of @a pCmdLine
816 is @c wchar_t *, otherwise it is @c char *, even in Unicode build.
7c913512 817
23324ae1 818 @remarks To clean up wxWidgets, call wxApp::OnExit followed by the static
96d7cc9b
FM
819 function wxApp::CleanUp. For example, if exiting from an MFC application
820 that also uses wxWidgets:
821 @code
822 int CTheApp::ExitInstance()
823 {
824 // OnExit isn't called by CleanUp so must be called explicitly.
825 wxTheApp->OnExit();
826 wxApp::CleanUp();
3c4f71cc 827
96d7cc9b
FM
828 return CWinApp::ExitInstance();
829 }
830 @endcode
7c913512 831
027c1c27 832 @header{wx/app.h}
23324ae1 833*/
7c913512 834int wxEntry(HINSTANCE hInstance,
4cc4bfaf
FM
835 HINSTANCE hPrevInstance = NULL,
836 char* pCmdLine = NULL,
7c913512 837 int nCmdShow = SW_SHOWNORMAL);
39fb8056
FM
838
839//@}
840
841
842
843/** @ingroup group_funcmacro_procctrl */
844//@{
845
846/**
847 Exits application after calling wxApp::OnExit.
848
849 Should only be used in an emergency: normally the top-level frame
850 should be deleted (after deleting all other frames) to terminate the
851 application. See wxCloseEvent and wxApp.
027c1c27
BP
852
853 @header{wx/app.h}
39fb8056
FM
854*/
855void wxExit();
856
23324ae1
FM
857//@}
858