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