1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxApp class
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "app.h"
20 #include "wx/object.h"
22 class WXDLLEXPORT wxFrame
;
23 class WXDLLEXPORT wxWindow
;
24 class WXDLLEXPORT wxApp
;
25 class WXDLLEXPORT wxKeyEvent
;
26 class WXDLLEXPORT wxLog
;
28 #define wxPRINT_WINDOWS 1
29 #define wxPRINT_POSTSCRIPT 2
31 WXDLLEXPORT_DATA(extern wxApp
*) wxTheApp
;
33 void WXDLLEXPORT
wxCleanUp();
34 void WXDLLEXPORT
wxCommonCleanUp(); // Call this from the platform's wxCleanUp()
35 void WXDLLEXPORT
wxCommonInit(); // Call this from the platform's initialization
37 // Force an exit from main loop
38 void WXDLLEXPORT
wxExit();
40 // Yield to other apps/messages
41 bool WXDLLEXPORT
wxYield();
43 // Represents the application. Derive OnInit and declare
44 // a new App object to start application
45 class WXDLLEXPORT wxApp
: public wxEvtHandler
47 DECLARE_DYNAMIC_CLASS(wxApp
)
51 static void SetInitializerFunction(wxAppInitializerFunction fn
) { m_appInitFn
= fn
; }
52 static wxAppInitializerFunction
GetInitializerFunction() { return m_appInitFn
; }
54 virtual int MainLoop();
57 virtual bool Pending() ;
58 virtual void Dispatch() ;
60 virtual void OnIdle(wxIdleEvent
& event
);
63 virtual bool OnInit() { return FALSE
; };
65 // No specific tasks to do here.
66 virtual bool OnInitGui() { return TRUE
; }
68 // Called to set off the main loop
69 virtual int OnRun() { return MainLoop(); };
70 virtual int OnExit() { return 0; }
72 inline void SetPrintMode(int mode
) { m_printMode
= mode
; }
73 inline int GetPrintMode() const { return m_printMode
; }
75 inline void SetExitOnFrameDelete(bool flag
) { m_exitOnFrameDelete
= flag
; }
76 inline bool GetExitOnFrameDelete() const { return m_exitOnFrameDelete
; }
78 inline wxString
GetAppName() const {
81 else return m_className
;
84 inline void SetAppName(const wxString
& name
) { m_appName
= name
; };
85 inline wxString
GetClassName() const { return m_className
; }
86 inline void SetClassName(const wxString
& name
) { m_className
= name
; }
88 void SetVendorName(const wxString
& vendorName
) { m_vendorName
= vendorName
; }
89 const wxString
& GetVendorName() const { return m_vendorName
; }
91 wxWindow
*GetTopWindow() const ;
92 inline void SetTopWindow(wxWindow
*win
) { m_topWindow
= win
; }
94 inline void SetWantDebugOutput(bool flag
) { m_wantDebugOutput
= flag
; }
95 inline bool GetWantDebugOutput() { return m_wantDebugOutput
; }
97 // Send idle event to all top-level windows.
98 // Returns TRUE if more idle time is requested.
99 bool SendIdleEvents();
101 // Send idle event to window and all subwindows
102 // Returns TRUE if more idle time is requested.
103 bool SendIdleEvents(wxWindow
* win
);
105 // Windows only, but for compatibility...
106 inline void SetAuto3D(bool flag
) { m_auto3D
= flag
; }
107 inline bool GetAuto3D() const { return m_auto3D
; }
109 // Creates a log object
110 virtual wxLog
* CreateLogTarget();
113 // Will always be set to the appropriate, main-style values.
118 bool m_wantDebugOutput
;
119 wxString m_className
;
122 wxWindow
* m_topWindow
;
123 bool m_exitOnFrameDelete
;
125 int m_printMode
; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
126 bool m_auto3D
; // Always use 3D controls, except
128 static wxAppInitializerFunction m_appInitFn
;
133 static void CommonInit();
134 static void CleanUp();
135 static void CommonCleanUp();
136 void DeletePendingObjects();
140 static long sm_lastMessageTime
;
146 DECLARE_EVENT_TABLE()
149 // TODO: add platform-specific arguments, e.g. int argc, char* argv[]
150 int WXDLLEXPORT
wxEntry();