]> git.saurik.com Git - wxWidgets.git/blob - include/wx/app.h
eb507ed17d3f6e14ee64a144c359b266debe5e79
[wxWidgets.git] / include / wx / app.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/app.h
3 // Purpose: wxAppBase class and macros used for declaration of wxApp
4 // derived class in the user code
5 // Author: Julian Smart
6 // Modified by:
7 // Created: 01/02/97
8 // RCS-ID: $Id$
9 // Copyright: (c) Julian Smart
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
12
13 #ifndef _WX_APP_H_BASE_
14 #define _WX_APP_H_BASE_
15
16 // ----------------------------------------------------------------------------
17 // headers we have to include here
18 // ----------------------------------------------------------------------------
19
20 #include "wx/event.h" // for the base class
21
22 #if wxUSE_GUI
23 #include "wx/window.h" // for wxTopLevelWindows
24 #endif // wxUSE_GUI
25
26 #include "wx/build.h"
27 #include "wx/init.h" // we must declare wxEntry()
28
29 class WXDLLIMPEXP_BASE wxAppConsole;
30 class WXDLLIMPEXP_BASE wxAppTraits;
31 class WXDLLIMPEXP_BASE wxCmdLineParser;
32 class WXDLLIMPEXP_BASE wxLog;
33 class WXDLLIMPEXP_BASE wxMessageOutput;
34
35 // wxUSE_EVTLOOP_IN_APP is a temporary hack needed until all ports are updated
36 // to use wxEventLoop, otherwise we get linking errors on wxMac, it's going to
37 // disappear a.s.a.p.
38 #ifdef __WXMAC__
39 #define wxUSE_EVTLOOP_IN_APP 0
40 #else
41 #define wxUSE_EVTLOOP_IN_APP 1
42 class WXDLLEXPORT wxEventLoop;
43 #endif
44
45 // ----------------------------------------------------------------------------
46 // typedefs
47 // ----------------------------------------------------------------------------
48
49 // the type of the function used to create a wxApp object on program start up
50 typedef wxAppConsole* (*wxAppInitializerFunction)();
51
52 // ----------------------------------------------------------------------------
53 // constants
54 // ----------------------------------------------------------------------------
55
56 enum
57 {
58 wxPRINT_WINDOWS = 1,
59 wxPRINT_POSTSCRIPT = 2
60 };
61
62 // ----------------------------------------------------------------------------
63 // support for framebuffer ports
64 // ----------------------------------------------------------------------------
65
66 #if wxUSE_GUI
67 // VS: Fullscreen/framebuffer application needs to choose display mode prior
68 // to wxWindows initialization. This class holds information about display
69 // mode. It is used by wxApp::Set/GetDisplayMode.
70 class WXDLLIMPEXP_CORE wxDisplayModeInfo
71 {
72 public:
73 wxDisplayModeInfo() : m_ok(FALSE) {}
74 wxDisplayModeInfo(unsigned width, unsigned height, unsigned depth)
75 : m_width(width), m_height(height), m_depth(depth), m_ok(TRUE) {}
76
77 unsigned GetWidth() const { return m_width; }
78 unsigned GetHeight() const { return m_height; }
79 unsigned GetDepth() const { return m_depth; }
80 bool IsOk() const { return m_ok; }
81
82 private:
83 unsigned m_width, m_height, m_depth;
84 bool m_ok;
85 };
86 #endif // wxUSE_GUI
87
88
89 // ----------------------------------------------------------------------------
90 // wxAppConsole: wxApp for non-GUI applications
91 // ----------------------------------------------------------------------------
92
93 class WXDLLIMPEXP_BASE wxAppConsole : public wxEvtHandler
94 {
95 public:
96 // ctor and dtor
97 wxAppConsole();
98 virtual ~wxAppConsole();
99
100
101 // the virtual functions which may/must be overridden in the derived class
102 // -----------------------------------------------------------------------
103
104 // This is the very first function called for a newly created wxApp object,
105 // it is used by the library to do the global initialization. If, for some
106 // reason, you must override it (instead of just overriding OnInit(), as
107 // usual, for app-specific initializations), do not forget to call the base
108 // class version!
109 virtual bool Initialize(int& argc, wxChar **argv);
110
111 // This gives wxCocoa a chance to call OnInit() with a memory pool in place
112 virtual bool CallOnInit() { return OnInit(); }
113
114 // Called before OnRun(), this is a good place to do initialization -- if
115 // anything fails, return false from here to prevent the program from
116 // continuing. The command line is normally parsed here, call the base
117 // class OnInit() to do it.
118 virtual bool OnInit();
119
120 // this is here only temproary hopefully (FIXME)
121 virtual bool OnInitGui() { return true; }
122
123 // This is the replacement for the normal main(): all program work should
124 // be done here. When OnRun() returns, the programs starts shutting down.
125 virtual int OnRun() = 0;
126
127 // This is only called if OnInit() returned true so it's a good place to do
128 // any cleanup matching the initializations done there.
129 virtual int OnExit();
130
131 // This is the very last function called on wxApp object before it is
132 // destroyed. If you override it (instead of overriding OnExit() as usual)
133 // do not forget to call the base class version!
134 virtual void CleanUp();
135
136 // Called when a fatal exception occurs, this function should take care not
137 // to do anything which might provoke a nested exception! It may be
138 // overridden if you wish to react somehow in non-default way (core dump
139 // under Unix, application crash under Windows) to fatal program errors,
140 // however extreme care should be taken if you don't want this function to
141 // crash.
142 virtual void OnFatalException() { }
143
144 #if wxUSE_EXCEPTIONS
145 // Called when an unhandled C++ exception occurs inside OnRun(): note that
146 // the exception type is lost by now, so if you really want to handle the
147 // exception you should override OnRun() and put a try/catch around
148 // MainLoop() call there
149 virtual void OnUnhandledException() { }
150 #endif // wxUSE_EXCEPTIONS
151
152 // Called from wxExit() function, should terminate the application a.s.a.p.
153 virtual void Exit();
154
155
156 // application info: name, description, vendor
157 // -------------------------------------------
158
159 // NB: all these should be set by the application itself, there are no
160 // reasonable default except for the application name which is taken to
161 // be argv[0]
162
163 // set/get the application name
164 wxString GetAppName() const
165 {
166 return m_appName.empty() ? m_className : m_appName;
167 }
168 void SetAppName(const wxString& name) { m_appName = name; }
169
170 // set/get the app class name
171 wxString GetClassName() const { return m_className; }
172 void SetClassName(const wxString& name) { m_className = name; }
173
174 // set/get the vendor name
175 const wxString& GetVendorName() const { return m_vendorName; }
176 void SetVendorName(const wxString& name) { m_vendorName = name; }
177
178
179 // cmd line parsing stuff
180 // ----------------------
181
182 // all of these methods may be overridden in the derived class to
183 // customize the command line parsing (by default only a few standard
184 // options are handled)
185 //
186 // you also need to call wxApp::OnInit() from YourApp::OnInit() for all
187 // this to work
188
189 #if wxUSE_CMDLINE_PARSER
190 // this one is called from OnInit() to add all supported options
191 // to the given parser (don't forget to call the base class version if you
192 // override it!)
193 virtual void OnInitCmdLine(wxCmdLineParser& parser);
194
195 // called after successfully parsing the command line, return TRUE
196 // to continue and FALSE to exit (don't forget to call the base class
197 // version if you override it!)
198 virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
199
200 // called if "--help" option was specified, return TRUE to continue
201 // and FALSE to exit
202 virtual bool OnCmdLineHelp(wxCmdLineParser& parser);
203
204 // called if incorrect command line options were given, return
205 // FALSE to abort and TRUE to continue
206 virtual bool OnCmdLineError(wxCmdLineParser& parser);
207 #endif // wxUSE_CMDLINE_PARSER
208
209
210 // miscellaneous customization functions
211 // -------------------------------------
212
213 // create the app traits object to which we delegate for everything which
214 // either should be configurable by the user (then he can change the
215 // default behaviour simply by overriding CreateTraits() and returning his
216 // own traits object) or which is GUI/console dependent as then wxAppTraits
217 // allows us to abstract the differences behind the common façade
218 wxAppTraits *GetTraits();
219
220 // the functions below shouldn't be used now that we have wxAppTraits
221 #if WXWIN_COMPATIBILITY_2_4
222
223 #if wxUSE_LOG
224 // override this function to create default log target of arbitrary
225 // user-defined class (default implementation creates a wxLogGui
226 // object) -- this log object is used by default by all wxLogXXX()
227 // functions.
228 virtual wxLog *CreateLogTarget();
229 #endif // wxUSE_LOG
230
231 // similar to CreateLogTarget() but for the global wxMessageOutput
232 // object
233 virtual wxMessageOutput *CreateMessageOutput();
234
235 #endif // WXWIN_COMPATIBILITY_2_4
236
237
238 // event processing functions
239 // --------------------------
240
241 // this method allows to filter all the events processed by the program, so
242 // you should try to return quickly from it to avoid slowing down the
243 // program to the crawl
244 //
245 // return value should be -1 to continue with the normal event processing,
246 // or TRUE or FALSE to stop further processing and pretend that the event
247 // had been already processed or won't be processed at all, respectively
248 virtual int FilterEvent(wxEvent& event);
249
250 #if wxUSE_EXCEPTIONS
251 // call the specified handler on the given object with the given event
252 //
253 // this method only exists to allow catching the exceptions thrown by any
254 // event handler, it would lead to an extra (useless) virtual function call
255 // if the exceptions were not used, so it doesn't even exist in that case
256 virtual void HandleEvent(wxEvtHandler *handler,
257 wxEventFunction func,
258 wxEvent& event) const;
259 #endif // wxUSE_EXCEPTIONS
260
261 // process all events in the wxPendingEvents list -- it is necessary to
262 // call this function to process posted events. This happens during each
263 // event loop iteration in GUI mode but if there is no main loop, it may be
264 // also called directly.
265 virtual void ProcessPendingEvents();
266
267 // doesn't do anything in this class, just a hook for GUI wxApp
268 virtual bool Yield(bool WXUNUSED(onlyIfNeeded) = false) { return true; }
269
270 // make sure that idle events are sent again
271 virtual void WakeUpIdle() { }
272
273
274 // debugging support
275 // -----------------
276
277 // this function is called when an assert failure occurs, the base class
278 // version does the normal processing (i.e. shows the usual assert failure
279 // dialog box)
280 //
281 // the arguments are the place where the assert occured, the text of the
282 // assert itself and the user-specified message
283 #ifdef __WXDEBUG__
284 virtual void OnAssert(const wxChar *file,
285 int line,
286 const wxChar *cond,
287 const wxChar *msg);
288 #endif // __WXDEBUG__
289
290 // check that the wxBuildOptions object (constructed in the application
291 // itself, usually the one from IMPLEMENT_APP() macro) matches the build
292 // options of the library and abort if it doesn't
293 static bool CheckBuildOptions(const char *optionsSignature,
294 const char *componentName);
295 #if WXWIN_COMPATIBILITY_2_4
296 static bool CheckBuildOptions(const wxBuildOptions& buildOptions)
297 {
298 return CheckBuildOptions(buildOptions.m_signature, "your program");
299 }
300 #endif
301
302 // implementation only from now on
303 // -------------------------------
304
305 // helpers for dynamic wxApp construction
306 static void SetInitializerFunction(wxAppInitializerFunction fn)
307 { ms_appInitFn = fn; }
308 static wxAppInitializerFunction GetInitializerFunction()
309 { return ms_appInitFn; }
310
311 // accessors for ms_appInstance field (external code might wish to modify
312 // it, this is why we provide a setter here as well, but you should really
313 // know what you're doing if you call it), wxTheApp is usually used instead
314 // of GetInstance()
315 static wxAppConsole *GetInstance() { return ms_appInstance; }
316 static void SetInstance(wxAppConsole *app) { ms_appInstance = app; }
317
318
319 // command line arguments (public for backwards compatibility)
320 int argc;
321 wxChar **argv;
322
323 protected:
324 // the function which creates the traits object when GetTraits() needs it
325 // for the first time
326 virtual wxAppTraits *CreateTraits();
327
328
329 // function used for dynamic wxApp creation
330 static wxAppInitializerFunction ms_appInitFn;
331
332 // the one and only global application object
333 static wxAppConsole *ms_appInstance;
334
335
336 // application info (must be set from the user code)
337 wxString m_vendorName, // vendor name (ACME Inc)
338 m_appName, // app name
339 m_className; // class name
340
341 // the class defining the application behaviour, NULL initially and created
342 // by GetTraits() when first needed
343 wxAppTraits *m_traits;
344
345
346 // the application object is a singleton anyhow, there is no sense in
347 // copying it
348 DECLARE_NO_COPY_CLASS(wxAppConsole)
349 };
350
351 // ----------------------------------------------------------------------------
352 // wxAppBase: the common part of wxApp implementations for all platforms
353 // ----------------------------------------------------------------------------
354
355 #if wxUSE_GUI
356
357 class WXDLLIMPEXP_CORE wxAppBase : public wxAppConsole
358 {
359 public:
360 wxAppBase();
361 virtual ~wxAppBase();
362
363 // the virtual functions which may/must be overridden in the derived class
364 // -----------------------------------------------------------------------
365
366 // very first initialization function
367 //
368 // Override: very rarely
369 virtual bool Initialize(int& argc, wxChar **argv);
370
371 // a platform-dependent version of OnInit(): the code here is likely to
372 // depend on the toolkit. default version does nothing.
373 //
374 // Override: rarely.
375 virtual bool OnInitGui();
376
377 // called to start program execution - the default version just enters
378 // the main GUI loop in which events are received and processed until
379 // the last window is not deleted (if GetExitOnFrameDelete) or
380 // ExitMainLoop() is called. In console mode programs, the execution
381 // of the program really starts here
382 //
383 // Override: rarely in GUI applications, always in console ones.
384 virtual int OnRun();
385
386 // a matching function for OnInit()
387 virtual int OnExit();
388
389 // very last clean up function
390 //
391 // Override: very rarely
392 virtual void CleanUp();
393
394
395 // the worker functions - usually not used directly by the user code
396 // -----------------------------------------------------------------
397
398 // execute the main GUI loop, the function returns when the loop ends
399 virtual int MainLoop();
400
401 // exit the main loop thus terminating the application
402 virtual void Exit();
403
404 // exit the main GUI loop during the next iteration (i.e. it does not
405 // stop the program immediately!)
406 virtual void ExitMainLoop();
407
408 // returns true if the program is initialized, i.e. OnInit() has been
409 // completed successfully
410 virtual bool Initialized() = 0;
411
412 // returns TRUE if there are unprocessed events in the event queue
413 virtual bool Pending();
414
415 // process the first event in the event queue (blocks until an event
416 // appears if there are none currently, use Pending() if this is not
417 // wanted), returns false if the event loop should stop and true
418 // otherwise
419 virtual bool Dispatch();
420
421 // process all currently pending events right now
422 //
423 // it is an error to call Yield() recursively unless the value of
424 // onlyIfNeeded is TRUE
425 //
426 // WARNING: this function is dangerous as it can lead to unexpected
427 // reentrancies (i.e. when called from an event handler it
428 // may result in calling the same event handler again), use
429 // with _extreme_ care or, better, don't use at all!
430 virtual bool Yield(bool onlyIfNeeded = FALSE) = 0;
431
432 // this virtual function is called in the GUI mode when the application
433 // becomes idle and normally just sends wxIdleEvent to all interested
434 // parties
435 //
436 // it should return TRUE if more idle events are needed, FALSE if not
437 virtual bool ProcessIdle();
438
439 // Send idle event to window and all subwindows
440 // Returns TRUE if more idle time is requested.
441 virtual bool SendIdleEvents(wxWindow* win, wxIdleEvent& event);
442
443 // Perform standard OnIdle behaviour: call from port's OnIdle
444 void OnIdle(wxIdleEvent& event);
445
446
447 // top level window functions
448 // --------------------------
449
450 // return TRUE if our app has focus
451 virtual bool IsActive() const { return m_isActive; }
452
453 // set the "main" top level window
454 void SetTopWindow(wxWindow *win) { m_topWindow = win; }
455
456 // return the "main" top level window (if it hadn't been set previously
457 // with SetTopWindow(), will return just some top level window and, if
458 // there are none, will return NULL)
459 virtual wxWindow *GetTopWindow() const
460 {
461 if (m_topWindow)
462 return m_topWindow;
463 else if (wxTopLevelWindows.GetCount() > 0)
464 return wxTopLevelWindows.GetFirst()->GetData();
465 else
466 return (wxWindow *)NULL;
467 }
468
469 // control the exit behaviour: by default, the program will exit the
470 // main loop (and so, usually, terminate) when the last top-level
471 // program window is deleted. Beware that if you disable this behaviour
472 // (with SetExitOnFrameDelete(FALSE)), you'll have to call
473 // ExitMainLoop() explicitly from somewhere.
474 void SetExitOnFrameDelete(bool flag)
475 { m_exitOnFrameDelete = flag ? Yes : No; }
476 bool GetExitOnFrameDelete() const
477 { return m_exitOnFrameDelete == Yes; }
478
479
480 // display mode, visual, printing mode, ...
481 // ------------------------------------------------------------------------
482
483 // Get display mode that is used use. This is only used in framebuffer
484 // wxWin ports (such as wxMGL).
485 virtual wxDisplayModeInfo GetDisplayMode() const { return wxDisplayModeInfo(); }
486 // Set display mode to use. This is only used in framebuffer wxWin
487 // ports (such as wxMGL). This method should be called from
488 // wxApp::OnInitGui
489 virtual bool SetDisplayMode(const wxDisplayModeInfo& WXUNUSED(info)) { return TRUE; }
490
491 // set use of best visual flag (see below)
492 void SetUseBestVisual( bool flag ) { m_useBestVisual = flag; }
493 bool GetUseBestVisual() const { return m_useBestVisual; }
494
495 // set/get printing mode: see wxPRINT_XXX constants.
496 //
497 // default behaviour is the normal one for Unix: always use PostScript
498 // printing.
499 virtual void SetPrintMode(int WXUNUSED(mode)) { }
500 int GetPrintMode() const { return wxPRINT_POSTSCRIPT; }
501
502
503 // command line parsing (GUI-specific)
504 // ------------------------------------------------------------------------
505
506 #if wxUSE_CMDLINE_PARSER
507 virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
508 virtual void OnInitCmdLine(wxCmdLineParser& parser);
509 #endif
510
511 // miscellaneous other stuff
512 // ------------------------------------------------------------------------
513
514 // called by toolkit-specific code to set the app status: active (we have
515 // focus) or not and also the last window which had focus before we were
516 // deactivated
517 virtual void SetActive(bool isActive, wxWindow *lastFocus);
518
519
520 protected:
521 // delete all objects in wxPendingDelete list
522 void DeletePendingObjects();
523
524 // override base class method to use GUI traits
525 virtual wxAppTraits *CreateTraits();
526
527
528 #if wxUSE_EVTLOOP_IN_APP
529 // the main event loop of the application (may be NULL if the loop hasn't
530 // been started yet or has already terminated)
531 wxEventLoop *m_mainLoop;
532 #endif // wxUSE_EVTLOOP_IN_APP
533
534 // the main top level window (may be NULL)
535 wxWindow *m_topWindow;
536
537 // if Yes, exit the main loop when the last top level window is deleted, if
538 // No don't do it and if Later -- only do it once we reach our OnRun()
539 //
540 // the explanation for using this strange scheme is given in appcmn.cpp
541 enum
542 {
543 Later = -1,
544 No,
545 Yes
546 } m_exitOnFrameDelete;
547
548 // TRUE if the apps whats to use the best visual on systems where
549 // more than one are available (Sun, SGI, XFree86 4.0 ?)
550 bool m_useBestVisual;
551
552 // does any of our windows has focus?
553 bool m_isActive;
554
555
556 DECLARE_NO_COPY_CLASS(wxAppBase)
557 };
558
559 #endif // wxUSE_GUI
560
561 // ----------------------------------------------------------------------------
562 // now include the declaration of the real class
563 // ----------------------------------------------------------------------------
564
565 #if wxUSE_GUI
566 #if defined(__WXMSW__)
567 #include "wx/msw/app.h"
568 #elif defined(__WXMOTIF__)
569 #include "wx/motif/app.h"
570 #elif defined(__WXMGL__)
571 #include "wx/mgl/app.h"
572 #elif defined(__WXGTK__)
573 #include "wx/gtk/app.h"
574 #elif defined(__WXX11__)
575 #include "wx/x11/app.h"
576 #elif defined(__WXMAC__)
577 #include "wx/mac/app.h"
578 #elif defined(__WXCOCOA__)
579 #include "wx/cocoa/app.h"
580 #elif defined(__WXPM__)
581 #include "wx/os2/app.h"
582 #endif
583 #else // !GUI
584 // allow using just wxApp (instead of wxAppConsole) in console programs
585 typedef wxAppConsole wxApp;
586 #endif // GUI/!GUI
587
588 // ----------------------------------------------------------------------------
589 // the global data
590 // ----------------------------------------------------------------------------
591
592 // for compatibility, we define this macro to access the global application
593 // object of type wxApp
594 //
595 // note that instead of using of wxTheApp in application code you should
596 // consider using DECLARE_APP() after which you may call wxGetApp() which will
597 // return the object of the correct type (i.e. MyApp and not wxApp)
598 //
599 // the cast is safe as in GUI build we only use wxApp, not wxAppConsole, and in
600 // console mode it does nothing at all
601 #define wxTheApp ((wxApp *)wxApp::GetInstance())
602
603 // ----------------------------------------------------------------------------
604 // global functions
605 // ----------------------------------------------------------------------------
606
607 // event loop related functions only work in GUI programs
608 // ------------------------------------------------------
609
610 // Force an exit from main loop
611 extern void WXDLLIMPEXP_BASE wxExit();
612
613 // Yield to other apps/messages
614 extern bool WXDLLIMPEXP_BASE wxYield();
615
616 // Yield to other apps/messages
617 extern void WXDLLIMPEXP_BASE wxWakeUpIdle();
618
619 // ----------------------------------------------------------------------------
620 // macros for dynamic creation of the application object
621 // ----------------------------------------------------------------------------
622
623 // Having a global instance of this class allows wxApp to be aware of the app
624 // creator function. wxApp can then call this function to create a new app
625 // object. Convoluted, but necessary.
626
627 class WXDLLIMPEXP_BASE wxAppInitializer
628 {
629 public:
630 wxAppInitializer(wxAppInitializerFunction fn)
631 { wxApp::SetInitializerFunction(fn); }
632 };
633
634 // Here's a macro you can use if your compiler really, really wants main() to
635 // be in your main program (e.g. hello.cpp). Now IMPLEMENT_APP should add this
636 // code if required.
637
638 #define IMPLEMENT_WXWIN_MAIN_CONSOLE \
639 int main(int argc, char **argv) { return wxEntry(argc, argv); }
640
641 #if !wxUSE_GUI || !defined(__WXMSW__)
642 #define IMPLEMENT_WXWIN_MAIN \
643 IMPLEMENT_WXWIN_MAIN_CONSOLE
644 #elif defined(__WXMSW__)
645 // we need HINSTANCE declaration to define WinMain()
646 #include "wx/msw/wrapwin.h"
647
648 #ifdef SW_SHOWNORMAL
649 #define wxSW_SHOWNORMAL SW_SHOWNORMAL
650 #else
651 #define wxSW_SHOWNORMAL 0
652 #endif
653
654 #define IMPLEMENT_WXWIN_MAIN \
655 extern int wxEntry(HINSTANCE hInstance, \
656 HINSTANCE hPrevInstance = NULL, \
657 char *pCmdLine = NULL, \
658 int nCmdShow = wxSW_SHOWNORMAL); \
659 extern "C" int WINAPI WinMain(HINSTANCE hInstance, \
660 HINSTANCE hPrevInstance, \
661 char *lpCmdLine, \
662 int nCmdShow) \
663 { \
664 return wxEntry(hInstance, hPrevInstance, lpCmdLine, nCmdShow); \
665 }
666 #else
667 #define IMPLEMENT_WXWIN_MAIN
668 #endif
669
670 #ifdef __WXUNIVERSAL__
671 #include "wx/univ/theme.h"
672
673 #define IMPLEMENT_WX_THEME_SUPPORT \
674 WX_USE_THEME(win32); \
675 WX_USE_THEME(gtk);
676 #else
677 #define IMPLEMENT_WX_THEME_SUPPORT
678 #endif
679
680 // Use this macro if you want to define your own main() or WinMain() function
681 // and call wxEntry() from there.
682 #define IMPLEMENT_APP_NO_MAIN(appname) \
683 wxAppConsole *wxCreateApp() \
684 { \
685 wxAppConsole::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, \
686 "your program"); \
687 return new appname; \
688 } \
689 wxAppInitializer \
690 wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp); \
691 appname& wxGetApp() { return *(appname *)wxTheApp; }
692
693 // Same as IMPLEMENT_APP() normally but doesn't include themes support in
694 // wxUniversal builds
695 #define IMPLEMENT_APP_NO_THEMES(appname) \
696 IMPLEMENT_APP_NO_MAIN(appname) \
697 IMPLEMENT_WXWIN_MAIN
698
699 // Use this macro exactly once, the argument is the name of the wxApp-derived
700 // class which is the class of your application.
701 #define IMPLEMENT_APP(appname) \
702 IMPLEMENT_APP_NO_THEMES(appname) \
703 IMPLEMENT_WX_THEME_SUPPORT
704
705 // Same as IMPLEMENT_APP(), but for console applications.
706 #define IMPLEMENT_APP_CONSOLE(appname) \
707 IMPLEMENT_APP_NO_MAIN(appname) \
708 IMPLEMENT_WXWIN_MAIN_CONSOLE
709
710 // this macro can be used multiple times and just allows you to use wxGetApp()
711 // function
712 #define DECLARE_APP(appname) extern appname& wxGetApp();
713
714 #endif // _WX_APP_H_BASE_
715