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