1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxApp class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
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
;
29 class WXDLLEXPORT wxConfig
;
32 #define wxPRINT_WINDOWS 1
33 #define wxPRINT_POSTSCRIPT 2
35 WXDLLEXPORT_DATA(extern wxApp
*) wxTheApp
;
37 void WXDLLEXPORT
wxCleanUp();
38 void WXDLLEXPORT
wxCommonCleanUp(); // Call this from the platform's wxCleanUp()
39 void WXDLLEXPORT
wxCommonInit(); // Call this from the platform's initialization
41 // Force an exit from main loop
42 void WXDLLEXPORT
wxExit();
44 // Yield to other apps/messages
45 bool WXDLLEXPORT
wxYield();
47 // Represents the application. Derive OnInit and declare
48 // a new App object to start application
49 class WXDLLEXPORT wxApp
: public wxEvtHandler
51 DECLARE_DYNAMIC_CLASS(wxApp
)
55 static void SetInitializerFunction(wxAppInitializerFunction fn
) { m_appInitFn
= fn
; }
56 static wxAppInitializerFunction
GetInitializerFunction() { return m_appInitFn
; }
58 virtual int MainLoop();
61 virtual bool Pending() ;
62 virtual void Dispatch() ;
64 virtual void OnIdle(wxIdleEvent
& event
);
67 virtual bool OnInit() { return FALSE
; };
69 // No specific tasks to do here.
70 virtual bool OnInitGui() { return TRUE
; }
72 // Called to set off the main loop
73 virtual int OnRun() { return MainLoop(); };
74 virtual int OnExit() { return 0; };
75 inline void SetPrintMode(int mode
) { m_printMode
= mode
; }
76 inline int GetPrintMode() const { return m_printMode
; }
78 inline void SetExitOnFrameDelete(bool flag
) { m_exitOnFrameDelete
= flag
; }
79 inline bool GetExitOnFrameDelete() const { return m_exitOnFrameDelete
; }
81 inline wxString
GetAppName() const {
84 else return m_className
;
87 inline void SetAppName(const wxString
& name
) { m_appName
= name
; };
88 inline wxString
GetClassName() const { return m_className
; }
89 inline void SetClassName(const wxString
& name
) { m_className
= name
; }
90 wxWindow
*GetTopWindow() const ;
91 inline void SetTopWindow(wxWindow
*win
) { m_topWindow
= win
; }
93 inline void SetWantDebugOutput(bool flag
) { m_wantDebugOutput
= flag
; }
94 inline bool GetWantDebugOutput() { return m_wantDebugOutput
; }
96 // Send idle event to all top-level windows.
97 // Returns TRUE if more idle time is requested.
98 bool SendIdleEvents();
100 // Send idle event to window and all subwindows
101 // Returns TRUE if more idle time is requested.
102 bool SendIdleEvents(wxWindow
* win
);
104 inline void SetAuto3D(bool flag
) { m_auto3D
= flag
; }
105 inline bool GetAuto3D() const { return m_auto3D
; }
107 // Creates a log object
108 virtual wxLog
* CreateLogTarget();
111 // override this function to create a global wxConfig object of different
112 // than default type (right now the default implementation returns NULL)
113 virtual wxConfig
* CreateConfig() { return NULL
; }
114 #endif //USE_WXCONFIG
117 // void (*work_proc)(wxApp*app); // work procedure;
122 bool m_wantDebugOutput
;
123 wxString m_className
;
125 wxWindow
* m_topWindow
;
126 bool m_exitOnFrameDelete
;
128 int m_printMode
; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
129 bool m_auto3D
; // Always use 3D controls, except
131 static wxAppInitializerFunction m_appInitFn
;
133 /* Windows-specific wxApp definitions */
138 static bool Initialize(WXHINSTANCE instance
);
139 static void CommonInit();
140 static bool RegisterWindowClasses();
141 static void CleanUp();
142 static void CommonCleanUp();
143 virtual bool DoMessage();
144 virtual bool ProcessMessage(WXMSG
* pMsg
);
145 void DeletePendingObjects();
147 int GetComCtl32Version() const;
150 static long sm_lastMessageTime
;
155 // bool m_resourceCollection;
156 // bool m_pendingCleanup; // TRUE if we need to check the GDI object lists for cleanup
158 DECLARE_EVENT_TABLE()
161 #if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
162 int WXDLLEXPORT
wxEntry(WXHINSTANCE hInstance
, WXHINSTANCE hPrevInstance
, char *lpszCmdLine
,
163 int nCmdShow
, bool enterLoop
= TRUE
);
165 int WXDLLEXPORT
wxEntry(WXHINSTANCE hInstance
);