]>
Commit | Line | Data |
---|---|---|
2bda0e17 KB |
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 | #define wxPRINT_WINDOWS 1 | |
29 | #define wxPRINT_POSTSCRIPT 2 | |
30 | ||
31 | WXDLLEXPORT_DATA(extern wxApp*) wxTheApp; | |
32 | ||
33 | void WXDLLEXPORT wxCleanUp(void); | |
34 | void WXDLLEXPORT wxCommonCleanUp(void); // Call this from the platform's wxCleanUp() | |
35 | void WXDLLEXPORT wxCommonInit(void); // Call this from the platform's initialization | |
36 | ||
37 | // Force an exit from main loop | |
38 | void WXDLLEXPORT wxExit(void); | |
39 | ||
40 | // Yield to other apps/messages | |
41 | bool WXDLLEXPORT wxYield(void); | |
42 | ||
43 | // Represents the application. Derive OnInit and declare | |
44 | // a new App object to start application | |
45 | class WXDLLEXPORT wxApp: public wxEvtHandler | |
46 | { | |
47 | DECLARE_DYNAMIC_CLASS(wxApp) | |
48 | wxApp(void); | |
49 | inline ~wxApp(void) {} | |
50 | ||
51 | static void SetInitializerFunction(wxAppInitializerFunction fn) { m_appInitFn = fn; } | |
52 | static wxAppInitializerFunction GetInitializerFunction(void) { return m_appInitFn; } | |
53 | ||
54 | virtual int MainLoop(void); | |
55 | void ExitMainLoop(void); | |
56 | bool Initialized(void); | |
57 | virtual bool Pending(void) ; | |
58 | virtual void Dispatch(void) ; | |
59 | ||
60 | virtual void OnIdle(wxIdleEvent& event); | |
61 | ||
62 | // Windows specific. Intercept keyboard input. | |
63 | #if WXWIN_COMPATIBILITY == 2 | |
64 | virtual bool OldOnCharHook(wxKeyEvent& event); | |
65 | #endif | |
66 | ||
67 | // Generic | |
68 | virtual bool OnInit(void) { return FALSE; }; | |
69 | ||
70 | // No specific tasks to do here. | |
71 | virtual bool OnInitGui(void) { return TRUE; } | |
72 | ||
73 | // Called to set off the main loop | |
74 | virtual int OnRun(void) { return MainLoop(); }; | |
75 | virtual int OnExit(void) { return 0; }; | |
76 | inline void SetPrintMode(int mode) { m_printMode = mode; } | |
77 | inline int GetPrintMode(void) const { return m_printMode; } | |
78 | ||
79 | inline void SetExitOnFrameDelete(bool flag) { m_exitOnFrameDelete = flag; } | |
80 | inline bool GetExitOnFrameDelete(void) const { return m_exitOnFrameDelete; } | |
81 | ||
82 | /* | |
83 | inline void SetShowFrameOnInit(bool flag) { m_showOnInit = flag; } | |
84 | inline bool GetShowFrameOnInit(void) const { return m_showOnInit; } | |
85 | */ | |
86 | ||
87 | inline wxString GetAppName(void) const { | |
88 | if (m_appName != "") | |
89 | return m_appName; | |
90 | else return m_className; | |
91 | } | |
92 | ||
93 | inline void SetAppName(const wxString& name) { m_appName = name; }; | |
94 | inline wxString GetClassName(void) const { return m_className; } | |
95 | inline void SetClassName(const wxString& name) { m_className = name; } | |
96 | wxWindow *GetTopWindow(void) const ; | |
97 | inline void SetTopWindow(wxWindow *win) { m_topWindow = win; } | |
98 | ||
99 | inline void SetWantDebugOutput(bool flag) { m_wantDebugOutput = flag; } | |
100 | inline bool GetWantDebugOutput(void) { return m_wantDebugOutput; } | |
101 | ||
102 | // Send idle event to all top-level windows. | |
103 | // Returns TRUE if more idle time is requested. | |
104 | bool SendIdleEvents(void); | |
105 | ||
106 | // Send idle event to window and all subwindows | |
107 | // Returns TRUE if more idle time is requested. | |
108 | bool SendIdleEvents(wxWindow* win); | |
109 | ||
110 | inline void SetAuto3D(const bool flag) { m_auto3D = flag; } | |
111 | inline bool GetAuto3D(void) const { return m_auto3D; } | |
112 | ||
113 | // Creates a log object | |
114 | virtual wxLog* CreateLogTarget(void); | |
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(void); | |
140 | static bool RegisterWindowClasses(void); | |
141 | static void CleanUp(void); | |
142 | static void CommonCleanUp(void); | |
143 | virtual bool DoMessage(void); | |
144 | virtual bool ProcessMessage(WXMSG* pMsg); | |
145 | void DeletePendingObjects(void); | |
146 | bool ProcessIdle(void); | |
147 | ||
148 | /* | |
149 | inline void SetPendingCleanup(bool flag) { m_pendingCleanup = flag; } | |
150 | inline bool GetPendingCleanup(void) { return m_pendingCleanup; } | |
151 | ||
152 | bool DoResourceCleanup(void); | |
153 | // Set resource collection scheme on or off. | |
154 | inline void SetResourceCollection(bool flag) { m_resourceCollection = flag; } | |
155 | inline bool GetResourceCollection(void) { return m_resourceCollection; } | |
156 | */ | |
157 | ||
158 | public: | |
159 | static long sm_lastMessageTime; | |
160 | int m_nCmdShow; | |
161 | ||
162 | protected: | |
163 | bool m_keepGoing ; | |
164 | // bool m_resourceCollection; | |
165 | // bool m_pendingCleanup; // TRUE if we need to check the GDI object lists for cleanup | |
166 | ||
167 | DECLARE_EVENT_TABLE() | |
168 | }; | |
169 | ||
170 | #if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL)) | |
171 | int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance, WXHINSTANCE hPrevInstance, char *lpszCmdLine, | |
172 | int nCmdShow, bool enterLoop = TRUE); | |
173 | #else | |
174 | int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance); | |
175 | #endif | |
176 | ||
177 | #endif | |
178 | // __APPH__ | |
179 |