]>
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$ | |
bbcdf8bc | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
bbcdf8bc JS |
12 | #ifndef _WX_APP_H_ |
13 | #define _WX_APP_H_ | |
2bda0e17 | 14 | |
a3ef5bf5 | 15 | #include "wx/event.h" |
ebea0891 | 16 | #include "wx/icon.h" |
2bda0e17 | 17 | |
b5dbe15d VS |
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; | |
2bda0e17 | 23 | |
2bda0e17 KB |
24 | // Represents the application. Derive OnInit and declare |
25 | // a new App object to start application | |
53a2db12 | 26 | class WXDLLIMPEXP_CORE wxApp : public wxAppBase |
2bda0e17 | 27 | { |
094637f6 VZ |
28 | public: |
29 | wxApp(); | |
30 | virtual ~wxApp(); | |
580c10e3 | 31 | |
094637f6 | 32 | // override base class (pure) virtuals |
05e2b077 | 33 | virtual bool Initialize(int& argc, wxChar **argv); |
94826170 VZ |
34 | virtual void CleanUp(); |
35 | ||
77c46f00 | 36 | virtual bool Yield(bool onlyIfNeeded = false); |
e2478fde | 37 | virtual void WakeUpIdle(); |
2bda0e17 | 38 | |
094637f6 VZ |
39 | virtual void SetPrintMode(int mode) { m_printMode = mode; } |
40 | virtual int GetPrintMode() const { return m_printMode; } | |
2bda0e17 | 41 | |
094637f6 VZ |
42 | // implementation only |
43 | void OnIdle(wxIdleEvent& event); | |
44 | void OnEndSession(wxCloseEvent& event); | |
45 | void OnQueryEndSession(wxCloseEvent& event); | |
2bda0e17 | 46 | |
6046e57a VZ |
47 | #if wxUSE_EXCEPTIONS |
48 | virtual bool OnExceptionInMainLoop(); | |
49 | #endif // wxUSE_EXCEPTIONS | |
50 | ||
d9698bd4 VZ |
51 | // MSW-specific from now on |
52 | // ------------------------ | |
53 | ||
54 | // this suffix should be appended to all our Win32 class names to obtain a | |
55 | // variant registered without CS_[HV]REDRAW styles | |
56 | static const wxChar *GetNoRedrawClassSuffix() { return _T("NR"); } | |
57 | ||
58 | // get the name of the registered Win32 class with the given (unique) base | |
59 | // name: this function constructs the unique class name using this name as | |
60 | // prefix, checks if the class is already registered and registers it if it | |
61 | // isn't and returns the name it was registered under (or NULL if it failed) | |
62 | // | |
63 | // the registered class will always have CS_[HV]REDRAW and CS_DBLCLKS | |
64 | // styles as well as any additional styles specified as arguments here; and | |
65 | // there will be also a companion registered class identical to this one | |
66 | // but without CS_[HV]REDRAW whose name will be the same one but with | |
67 | // GetNoRedrawClassSuffix() | |
68 | // | |
69 | // the background brush argument must be either a COLOR_XXX standard value | |
70 | // or (default) -1 meaning that the class paints its background itself | |
71 | static const wxChar *GetRegisteredClassName(const wxChar *name, | |
72 | int bgBrushCol = -1, | |
73 | int extraStyles = 0); | |
74 | ||
75 | // return true if this name corresponds to one of the classes we registered | |
76 | // in the previous GetRegisteredClassName() calls | |
77 | static bool IsRegisteredClassName(const wxString& name); | |
78 | ||
2bda0e17 | 79 | protected: |
1e6feb95 | 80 | int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT |
094637f6 | 81 | |
2bda0e17 | 82 | public: |
d9698bd4 VZ |
83 | // unregister any window classes registered by GetRegisteredClassName() |
84 | static void UnregisterWindowClasses(); | |
ed45e263 | 85 | |
6d167489 | 86 | #if wxUSE_RICHEDIT |
77c46f00 | 87 | // initialize the richedit DLL of (at least) given version, return true if |
6d167489 VZ |
88 | // ok (Win95 has version 1, Win98/NT4 has 1 and 2, W2K has 3) |
89 | static bool InitRichEdit(int version = 2); | |
90 | #endif // wxUSE_RICHEDIT | |
91 | ||
92 | // returns 400, 470, 471 for comctl32.dll 4.00, 4.70, 4.71 or 0 if it | |
93 | // wasn't found at all | |
94 | static int GetComCtl32Version(); | |
2bda0e17 | 95 | |
5e9b921d VZ |
96 | // the same for shell32.dll: returns 400, 471, 500, 600, ... (4.70 not |
97 | // currently detected) | |
98 | static int GetShell32Version(); | |
99 | ||
94826170 VZ |
100 | // the SW_XXX value to be used for the frames opened by the application |
101 | // (currently seems unused which is a bug -- TODO) | |
102 | static int m_nCmdShow; | |
2bda0e17 KB |
103 | |
104 | protected: | |
094637f6 | 105 | DECLARE_EVENT_TABLE() |
fc7a2a60 | 106 | DECLARE_NO_COPY_CLASS(wxApp) |
d9698bd4 | 107 | DECLARE_DYNAMIC_CLASS(wxApp) |
2bda0e17 KB |
108 | }; |
109 | ||
6b4296f7 VZ |
110 | #ifdef __WXWINCE__ |
111 | ||
112 | // under CE provide a dummy implementation of GetComCtl32Version() returning | |
113 | // the value passing all ">= 470" tests (which are the only ones used in our | |
114 | // code currently) as commctrl.dll under CE 2.0 and later support comctl32.dll | |
115 | // functionality | |
116 | inline int wxApp::GetComCtl32Version() | |
117 | { | |
118 | return 471; | |
119 | } | |
120 | ||
121 | // this is not currently used at all under CE so it's not really clear what do | |
122 | // we need to return from here | |
123 | inline int wxApp::GetShell32Version() | |
124 | { | |
125 | return 0; | |
126 | } | |
127 | ||
128 | #endif // __WXWINCE__ | |
129 | ||
956495ca VZ |
130 | // ---------------------------------------------------------------------------- |
131 | // MSW-specific wxEntry() overload and IMPLEMENT_WXWIN_MAIN definition | |
132 | // ---------------------------------------------------------------------------- | |
133 | ||
134 | // we need HINSTANCE declaration to define WinMain() | |
135 | #include "wx/msw/wrapwin.h" | |
136 | ||
137 | #ifndef SW_SHOWNORMAL | |
138 | #define SW_SHOWNORMAL 1 | |
139 | #endif | |
140 | ||
141 | // WinMain() is always ANSI, even in Unicode build, under normal Windows | |
142 | // but is always Unicode under CE | |
143 | #ifdef __WXWINCE__ | |
144 | typedef wchar_t *wxCmdLineArgType; | |
145 | #else | |
146 | typedef char *wxCmdLineArgType; | |
147 | #endif | |
148 | ||
d76a558d VZ |
149 | // wxMSW-only overloads of wxEntry() and wxEntryStart() which take the |
150 | // parameters passed to WinMain() instead of those passed to main() | |
53a2db12 FM |
151 | extern WXDLLIMPEXP_CORE bool |
152 | wxEntryStart(HINSTANCE hInstance, | |
153 | HINSTANCE hPrevInstance = NULL, | |
154 | wxCmdLineArgType pCmdLine = NULL, | |
155 | int nCmdShow = SW_SHOWNORMAL); | |
156 | ||
157 | extern WXDLLIMPEXP_CORE int | |
158 | wxEntry(HINSTANCE hInstance, | |
159 | HINSTANCE hPrevInstance = NULL, | |
160 | wxCmdLineArgType pCmdLine = NULL, | |
161 | int nCmdShow = SW_SHOWNORMAL); | |
956495ca | 162 | |
1b1c490c VS |
163 | #if defined(__BORLANDC__) && wxUSE_UNICODE |
164 | // Borland C++ has the following nonstandard behaviour: when the -WU | |
165 | // command line flag is used, the linker expects to find wWinMain instead | |
166 | // of WinMain. This flag causes the compiler to define _UNICODE and | |
167 | // UNICODE symbols and there's no way to detect its use, so we have to | |
168 | // define both WinMain and wWinMain so that IMPLEMENT_WXWIN_MAIN works | |
169 | // for both code compiled with and without -WU. | |
170 | // See http://sourceforge.net/tracker/?func=detail&atid=309863&aid=1935997&group_id=9863 | |
171 | // for more details. | |
172 | #define IMPLEMENT_WXWIN_MAIN_BORLAND_NONSTANDARD \ | |
173 | extern "C" int WINAPI wWinMain(HINSTANCE hInstance, \ | |
174 | HINSTANCE hPrevInstance, \ | |
175 | wchar_t * WXUNUSED(lpCmdLine), \ | |
176 | int nCmdShow) \ | |
177 | { \ | |
178 | /* NB: wxEntry expects lpCmdLine argument to be char*, not */ \ | |
179 | /* wchar_t*, but fortunately it's not used anywhere */ \ | |
180 | /* and we can simply pass NULL in: */ \ | |
181 | return wxEntry(hInstance, hPrevInstance, NULL, nCmdShow); \ | |
182 | } | |
183 | #else | |
184 | #define IMPLEMENT_WXWIN_MAIN_BORLAND_NONSTANDARD | |
185 | #endif // defined(__BORLANDC__) && wxUSE_UNICODE | |
186 | ||
956495ca | 187 | #define IMPLEMENT_WXWIN_MAIN \ |
1b1c490c VS |
188 | extern "C" int WINAPI WinMain(HINSTANCE hInstance, \ |
189 | HINSTANCE hPrevInstance, \ | |
190 | wxCmdLineArgType WXUNUSED(lpCmdLine), \ | |
191 | int nCmdShow) \ | |
192 | { \ | |
193 | /* NB: We pass NULL in place of lpCmdLine to behave the same as */ \ | |
194 | /* Borland-specific wWinMain() above. If it becomes needed */ \ | |
195 | /* to pass lpCmdLine to wxEntry() here, you'll have to fix */ \ | |
196 | /* wWinMain() above too. */ \ | |
197 | return wxEntry(hInstance, hPrevInstance, NULL, nCmdShow); \ | |
198 | } \ | |
199 | IMPLEMENT_WXWIN_MAIN_BORLAND_NONSTANDARD | |
200 | ||
2bda0e17 | 201 | |
94826170 | 202 | #endif // _WX_APP_H_ |
2bda0e17 | 203 |