]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: app.h | |
3 | // Purpose: wxApp class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart and Markus Holzem | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef __APPH__ | |
13 | #define __APPH__ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "app.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/defs.h" | |
20 | #include "wx/object.h" | |
21 | ||
22 | class WXDLLEXPORT wxFrame; | |
23 | class WXDLLEXPORT wxWindow; | |
24 | class WXDLLEXPORT wxApp ; | |
25 | class WXDLLEXPORT wxKeyEvent; | |
26 | class WXDLLEXPORT wxLog; | |
27 | ||
28 | #if USE_WXCONFIG | |
29 | class WXDLLEXPORT wxConfig; | |
30 | #endif //USE_WXCONFIG | |
31 | ||
32 | #define wxPRINT_WINDOWS 1 | |
33 | #define wxPRINT_POSTSCRIPT 2 | |
34 | ||
35 | WXDLLEXPORT_DATA(extern wxApp*) wxTheApp; | |
36 | ||
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 | |
40 | ||
41 | // Force an exit from main loop | |
42 | void WXDLLEXPORT wxExit(); | |
43 | ||
44 | // Yield to other apps/messages | |
45 | bool WXDLLEXPORT wxYield(); | |
46 | ||
47 | // Represents the application. Derive OnInit and declare | |
48 | // a new App object to start application | |
49 | class WXDLLEXPORT wxApp: public wxEvtHandler | |
50 | { | |
51 | DECLARE_DYNAMIC_CLASS(wxApp) | |
52 | wxApp(); | |
53 | inline ~wxApp() {} | |
54 | ||
55 | static void SetInitializerFunction(wxAppInitializerFunction fn) { m_appInitFn = fn; } | |
56 | static wxAppInitializerFunction GetInitializerFunction() { return m_appInitFn; } | |
57 | ||
58 | virtual int MainLoop(); | |
59 | void ExitMainLoop(); | |
60 | bool Initialized(); | |
61 | virtual bool Pending() ; | |
62 | virtual void Dispatch() ; | |
63 | ||
64 | virtual void OnIdle(wxIdleEvent& event); | |
65 | ||
66 | // Generic | |
67 | virtual bool OnInit() { return FALSE; }; | |
68 | ||
69 | // No specific tasks to do here. | |
70 | virtual bool OnInitGui() { return TRUE; } | |
71 | ||
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; } | |
77 | ||
78 | inline void SetExitOnFrameDelete(bool flag) { m_exitOnFrameDelete = flag; } | |
79 | inline bool GetExitOnFrameDelete() const { return m_exitOnFrameDelete; } | |
80 | ||
81 | inline wxString GetAppName() const { | |
82 | if (m_appName != "") | |
83 | return m_appName; | |
84 | else return m_className; | |
85 | } | |
86 | ||
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; } | |
92 | ||
93 | inline void SetWantDebugOutput(bool flag) { m_wantDebugOutput = flag; } | |
94 | inline bool GetWantDebugOutput() { return m_wantDebugOutput; } | |
95 | ||
96 | // Send idle event to all top-level windows. | |
97 | // Returns TRUE if more idle time is requested. | |
98 | bool SendIdleEvents(); | |
99 | ||
100 | // Send idle event to window and all subwindows | |
101 | // Returns TRUE if more idle time is requested. | |
102 | bool SendIdleEvents(wxWindow* win); | |
103 | ||
104 | inline void SetAuto3D(bool flag) { m_auto3D = flag; } | |
105 | inline bool GetAuto3D() const { return m_auto3D; } | |
106 | ||
107 | // Creates a log object | |
108 | virtual wxLog* CreateLogTarget(); | |
109 | ||
110 | #if USE_WXCONFIG | |
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 | |
115 | ||
116 | public: | |
117 | // void (*work_proc)(wxApp*app); // work procedure; | |
118 | int argc; | |
119 | char ** argv; | |
120 | ||
121 | protected: | |
122 | bool m_wantDebugOutput ; | |
123 | wxString m_className; | |
124 | wxString m_appName; | |
125 | wxWindow * m_topWindow; | |
126 | bool m_exitOnFrameDelete; | |
127 | bool m_showOnInit; | |
128 | int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT | |
129 | bool m_auto3D ; // Always use 3D controls, except | |
130 | // where overriden | |
131 | static wxAppInitializerFunction m_appInitFn; | |
132 | ||
133 | /* Windows-specific wxApp definitions */ | |
134 | ||
135 | public: | |
136 | ||
137 | // Implementation | |
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(); | |
146 | bool ProcessIdle(); | |
147 | int GetComCtl32Version() const; | |
148 | ||
149 | public: | |
150 | static long sm_lastMessageTime; | |
151 | int m_nCmdShow; | |
152 | ||
153 | protected: | |
154 | bool m_keepGoing ; | |
155 | // bool m_resourceCollection; | |
156 | // bool m_pendingCleanup; // TRUE if we need to check the GDI object lists for cleanup | |
157 | ||
158 | DECLARE_EVENT_TABLE() | |
159 | }; | |
160 | ||
161 | #if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL)) | |
162 | int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance, WXHINSTANCE hPrevInstance, char *lpszCmdLine, | |
163 | int nCmdShow, bool enterLoop = TRUE); | |
164 | #else | |
165 | int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance); | |
166 | #endif | |
167 | ||
168 | #endif | |
169 | // __APPH__ | |
170 |