]>
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 | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_APP_H_ | |
13 | #define _WX_APP_H_ | |
14 | ||
15 | #include "wx/event.h" | |
16 | #include "wx/icon.h" | |
17 | ||
18 | class WXDLLIMPEXP_FWD_CORE wxFrame; | |
19 | class WXDLLIMPEXP_FWD_CORE wxWindow; | |
20 | class WXDLLIMPEXP_FWD_CORE wxApp; | |
21 | class WXDLLIMPEXP_FWD_CORE wxKeyEvent; | |
22 | class WXDLLIMPEXP_FWD_BASE wxLog; | |
23 | ||
24 | // Represents the application. Derive OnInit and declare | |
25 | // a new App object to start application | |
26 | class WXDLLIMPEXP_CORE wxApp : public wxAppBase | |
27 | { | |
28 | DECLARE_DYNAMIC_CLASS(wxApp) | |
29 | ||
30 | public: | |
31 | wxApp(); | |
32 | virtual ~wxApp(); | |
33 | ||
34 | // override base class (pure) virtuals | |
35 | virtual bool Initialize(int& argc, wxChar **argv); | |
36 | virtual void CleanUp(); | |
37 | ||
38 | virtual bool Yield(bool onlyIfNeeded = false); | |
39 | virtual void WakeUpIdle(); | |
40 | ||
41 | virtual void SetPrintMode(int mode) { m_printMode = mode; } | |
42 | virtual int GetPrintMode() const { return m_printMode; } | |
43 | ||
44 | // implementation only | |
45 | void OnIdle(wxIdleEvent& event); | |
46 | void OnEndSession(wxCloseEvent& event); | |
47 | void OnQueryEndSession(wxCloseEvent& event); | |
48 | ||
49 | #if wxUSE_EXCEPTIONS | |
50 | virtual bool OnExceptionInMainLoop(); | |
51 | #endif // wxUSE_EXCEPTIONS | |
52 | ||
53 | protected: | |
54 | int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT | |
55 | ||
56 | public: | |
57 | // Implementation | |
58 | static bool RegisterWindowClasses(); | |
59 | static bool UnregisterWindowClasses(); | |
60 | ||
61 | #if wxUSE_RICHEDIT | |
62 | // initialize the richedit DLL of (at least) given version, return true if | |
63 | // ok (Win95 has version 1, Win98/NT4 has 1 and 2, W2K has 3) | |
64 | static bool InitRichEdit(int version = 2); | |
65 | #endif // wxUSE_RICHEDIT | |
66 | ||
67 | // returns 400, 470, 471 for comctl32.dll 4.00, 4.70, 4.71 or 0 if it | |
68 | // wasn't found at all | |
69 | static int GetComCtl32Version(); | |
70 | ||
71 | // the same for shell32.dll: returns 400, 471, 500, 600, ... (4.70 not | |
72 | // currently detected) | |
73 | static int GetShell32Version(); | |
74 | ||
75 | // the SW_XXX value to be used for the frames opened by the application | |
76 | // (currently seems unused which is a bug -- TODO) | |
77 | static int m_nCmdShow; | |
78 | ||
79 | protected: | |
80 | DECLARE_EVENT_TABLE() | |
81 | DECLARE_NO_COPY_CLASS(wxApp) | |
82 | }; | |
83 | ||
84 | #ifdef __WXWINCE__ | |
85 | ||
86 | // under CE provide a dummy implementation of GetComCtl32Version() returning | |
87 | // the value passing all ">= 470" tests (which are the only ones used in our | |
88 | // code currently) as commctrl.dll under CE 2.0 and later support comctl32.dll | |
89 | // functionality | |
90 | inline int wxApp::GetComCtl32Version() | |
91 | { | |
92 | return 471; | |
93 | } | |
94 | ||
95 | // this is not currently used at all under CE so it's not really clear what do | |
96 | // we need to return from here | |
97 | inline int wxApp::GetShell32Version() | |
98 | { | |
99 | return 0; | |
100 | } | |
101 | ||
102 | #endif // __WXWINCE__ | |
103 | ||
104 | // ---------------------------------------------------------------------------- | |
105 | // MSW-specific wxEntry() overload and IMPLEMENT_WXWIN_MAIN definition | |
106 | // ---------------------------------------------------------------------------- | |
107 | ||
108 | // we need HINSTANCE declaration to define WinMain() | |
109 | #include "wx/msw/wrapwin.h" | |
110 | ||
111 | #ifndef SW_SHOWNORMAL | |
112 | #define SW_SHOWNORMAL 1 | |
113 | #endif | |
114 | ||
115 | // WinMain() is always ANSI, even in Unicode build, under normal Windows | |
116 | // but is always Unicode under CE | |
117 | #ifdef __WXWINCE__ | |
118 | typedef wchar_t *wxCmdLineArgType; | |
119 | #else | |
120 | typedef char *wxCmdLineArgType; | |
121 | #endif | |
122 | ||
123 | // wxMSW-only overloads of wxEntry() and wxEntryStart() which take the | |
124 | // parameters passed to WinMain() instead of those passed to main() | |
125 | extern WXDLLIMPEXP_CORE bool | |
126 | wxEntryStart(HINSTANCE hInstance, | |
127 | HINSTANCE hPrevInstance = NULL, | |
128 | wxCmdLineArgType pCmdLine = NULL, | |
129 | int nCmdShow = SW_SHOWNORMAL); | |
130 | ||
131 | extern WXDLLIMPEXP_CORE int | |
132 | wxEntry(HINSTANCE hInstance, | |
133 | HINSTANCE hPrevInstance = NULL, | |
134 | wxCmdLineArgType pCmdLine = NULL, | |
135 | int nCmdShow = SW_SHOWNORMAL); | |
136 | ||
137 | #if defined(__BORLANDC__) && wxUSE_UNICODE | |
138 | // Borland C++ has the following nonstandard behaviour: when the -WU | |
139 | // command line flag is used, the linker expects to find wWinMain instead | |
140 | // of WinMain. This flag causes the compiler to define _UNICODE and | |
141 | // UNICODE symbols and there's no way to detect its use, so we have to | |
142 | // define both WinMain and wWinMain so that IMPLEMENT_WXWIN_MAIN works | |
143 | // for both code compiled with and without -WU. | |
144 | // See http://sourceforge.net/tracker/?func=detail&atid=309863&aid=1935997&group_id=9863 | |
145 | // for more details. | |
146 | #define IMPLEMENT_WXWIN_MAIN_BORLAND_NONSTANDARD \ | |
147 | extern "C" int WINAPI wWinMain(HINSTANCE hInstance, \ | |
148 | HINSTANCE hPrevInstance, \ | |
149 | wchar_t * WXUNUSED(lpCmdLine), \ | |
150 | int nCmdShow) \ | |
151 | { \ | |
152 | /* NB: wxEntry expects lpCmdLine argument to be char*, not */ \ | |
153 | /* wchar_t*, but fortunately it's not used anywhere */ \ | |
154 | /* and we can simply pass NULL in: */ \ | |
155 | return wxEntry(hInstance, hPrevInstance, NULL, nCmdShow); \ | |
156 | } | |
157 | #else | |
158 | #define IMPLEMENT_WXWIN_MAIN_BORLAND_NONSTANDARD | |
159 | #endif // defined(__BORLANDC__) && wxUSE_UNICODE | |
160 | ||
161 | #define IMPLEMENT_WXWIN_MAIN \ | |
162 | extern "C" int WINAPI WinMain(HINSTANCE hInstance, \ | |
163 | HINSTANCE hPrevInstance, \ | |
164 | wxCmdLineArgType WXUNUSED(lpCmdLine), \ | |
165 | int nCmdShow) \ | |
166 | { \ | |
167 | /* NB: We pass NULL in place of lpCmdLine to behave the same as */ \ | |
168 | /* Borland-specific wWinMain() above. If it becomes needed */ \ | |
169 | /* to pass lpCmdLine to wxEntry() here, you'll have to fix */ \ | |
170 | /* wWinMain() above too. */ \ | |
171 | return wxEntry(hInstance, hPrevInstance, NULL, nCmdShow); \ | |
172 | } \ | |
173 | IMPLEMENT_WXWIN_MAIN_BORLAND_NONSTANDARD | |
174 | ||
175 | ||
176 | #endif // _WX_APP_H_ | |
177 |