]>
Commit | Line | Data |
---|---|---|
2bda0e17 KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: private.h | |
a23fd0e1 VZ |
3 | // Purpose: Private declarations: as this header is only included by |
4 | // wxWindows itself, it may contain identifiers which don't start | |
5 | // with "wx". | |
2bda0e17 KB |
6 | // Author: Julian Smart |
7 | // Modified by: | |
8 | // Created: 01/02/97 | |
9 | // RCS-ID: $Id$ | |
bbcdf8bc | 10 | // Copyright: (c) Julian Smart |
c085e333 | 11 | // Licence: wxWindows licence |
2bda0e17 KB |
12 | ///////////////////////////////////////////////////////////////////////////// |
13 | ||
bbcdf8bc JS |
14 | #ifndef _WX_PRIVATE_H_ |
15 | #define _WX_PRIVATE_H_ | |
2bda0e17 | 16 | |
2bda0e17 KB |
17 | #include <windows.h> |
18 | ||
04ef50df JS |
19 | #ifdef __WXMICROWIN__ |
20 | /* Extra prototypes and symbols not defined by MicroWindows */ | |
21 | #include "wx/msw/microwin.h" | |
22 | #endif | |
23 | ||
42e69d6b VZ |
24 | // undefine conflicting symbols which were defined in windows.h |
25 | #include "wx/msw/winundef.h" | |
26 | ||
a23fd0e1 | 27 | class WXDLLEXPORT wxFont; |
d427503c | 28 | class WXDLLEXPORT wxWindow; |
2bda0e17 | 29 | |
42e69d6b VZ |
30 | // --------------------------------------------------------------------------- |
31 | // private constants | |
32 | // --------------------------------------------------------------------------- | |
33 | ||
34 | // Conversion | |
35 | static const double METRIC_CONVERSION_CONSTANT = 0.0393700787; | |
36 | ||
37 | // Scaling factors for various unit conversions | |
38 | static const double mm2inches = (METRIC_CONVERSION_CONSTANT); | |
39 | static const double inches2mm = (1/METRIC_CONVERSION_CONSTANT); | |
40 | ||
41 | static const double mm2twips = (METRIC_CONVERSION_CONSTANT*1440); | |
42 | static const double twips2mm = (1/(METRIC_CONVERSION_CONSTANT*1440)); | |
43 | ||
44 | static const double mm2pt = (METRIC_CONVERSION_CONSTANT*72); | |
45 | static const double pt2mm = (1/(METRIC_CONVERSION_CONSTANT*72)); | |
46 | ||
a23fd0e1 VZ |
47 | // --------------------------------------------------------------------------- |
48 | // standard icons from the resources | |
49 | // --------------------------------------------------------------------------- | |
2bda0e17 | 50 | |
b568d04f VZ |
51 | #if wxUSE_GUI |
52 | ||
2bda0e17 KB |
53 | WXDLLEXPORT_DATA(extern HICON) wxSTD_FRAME_ICON; |
54 | WXDLLEXPORT_DATA(extern HICON) wxSTD_MDIPARENTFRAME_ICON; | |
55 | WXDLLEXPORT_DATA(extern HICON) wxSTD_MDICHILDFRAME_ICON; | |
56 | WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_FRAME_ICON; | |
57 | WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_MDIPARENTFRAME_ICON; | |
58 | WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_MDICHILDFRAME_ICON; | |
59 | WXDLLEXPORT_DATA(extern HFONT) wxSTATUS_LINE_FONT; | |
60 | ||
b568d04f VZ |
61 | #endif // wxUSE_GUI |
62 | ||
a23fd0e1 | 63 | // --------------------------------------------------------------------------- |
11c7d5b6 | 64 | // define things missing from some compilers' headers |
a23fd0e1 | 65 | // --------------------------------------------------------------------------- |
c455ab93 | 66 | |
b64f0a5f | 67 | #if defined(__GNUWIN32__) && !wxUSE_NORLANDER_HEADERS |
01dba85a | 68 | #ifndef ZeroMemory |
11c7d5b6 | 69 | inline void ZeroMemory(void *buf, size_t len) { memset(buf, 0, len); } |
01dba85a | 70 | #endif |
11c7d5b6 VZ |
71 | #endif // old mingw32 |
72 | ||
73 | // this defines a CASTWNDPROC macro which casts a pointer to the type of a | |
74 | // window proc | |
62448488 | 75 | |
ae090fdb | 76 | #if defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__) |
f6bcfd97 | 77 | #define CASTWNDPROC (long unsigned) |
c3b177ae | 78 | #else |
f6bcfd97 BP |
79 | #if defined(STRICT) || defined(__GNUC__) |
80 | typedef WNDPROC WndProcCast; | |
81 | #else | |
82 | typedef FARPROC WndProcCast; | |
83 | #endif | |
84 | #define CASTWNDPROC (WndProcCast) | |
85 | #endif // __GNUWIN32_OLD__ | |
2bda0e17 | 86 | |
a23fd0e1 VZ |
87 | // --------------------------------------------------------------------------- |
88 | // some stuff for old Windows versions (FIXME: what does it do here??) | |
89 | // --------------------------------------------------------------------------- | |
90 | ||
c085e333 | 91 | #if !defined(APIENTRY) // NT defines APIENTRY, 3.x not |
a23fd0e1 | 92 | #define APIENTRY FAR PASCAL |
2bda0e17 | 93 | #endif |
c085e333 | 94 | |
2bda0e17 | 95 | #ifdef __WIN32__ |
a23fd0e1 | 96 | #define _EXPORT |
2bda0e17 | 97 | #else |
a23fd0e1 VZ |
98 | #define _EXPORT _export |
99 | #endif | |
100 | ||
101 | #ifndef __WIN32__ | |
102 | typedef signed short int SHORT; | |
2bda0e17 | 103 | #endif |
c085e333 VZ |
104 | |
105 | #if !defined(__WIN32__) // 3.x uses FARPROC for dialogs | |
27a9bd48 | 106 | #ifndef STRICT |
a23fd0e1 | 107 | #define DLGPROC FARPROC |
2bda0e17 | 108 | #endif |
27a9bd48 | 109 | #endif |
2bda0e17 | 110 | |
47d67540 | 111 | #if wxUSE_PENWIN |
cc2b7472 VZ |
112 | WXDLLEXPORT void wxRegisterPenWin(); |
113 | WXDLLEXPORT void wxCleanUpPenWin(); | |
114 | WXDLLEXPORT void wxEnablePenAppHooks (bool hook); | |
115 | #endif // wxUSE_PENWIN | |
2bda0e17 | 116 | |
47d67540 | 117 | #if wxUSE_ITSY_BITSY |
a23fd0e1 VZ |
118 | #define IBS_HORZCAPTION 0x4000L |
119 | #define IBS_VERTCAPTION 0x8000L | |
2bda0e17 | 120 | |
a23fd0e1 VZ |
121 | UINT WINAPI ibGetCaptionSize( HWND hWnd ) ; |
122 | UINT WINAPI ibSetCaptionSize( HWND hWnd, UINT nSize ) ; | |
123 | LRESULT WINAPI ibDefWindowProc( HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam ) ; | |
124 | VOID WINAPI ibAdjustWindowRect( HWND hWnd, LPRECT lprc ) ; | |
125 | #endif // wxUSE_ITSY_BITSY | |
2bda0e17 | 126 | |
1f112209 | 127 | #if wxUSE_CTL3D |
a23fd0e1 VZ |
128 | #include "wx/msw/ctl3d/ctl3d.h" |
129 | #endif // wxUSE_CTL3D | |
2bda0e17 KB |
130 | |
131 | /* | |
132 | * Decide what window classes we're going to use | |
133 | * for this combination of CTl3D/FAFA settings | |
134 | */ | |
c085e333 | 135 | |
223d09f6 | 136 | #define STATIC_CLASS wxT("STATIC") |
2bda0e17 | 137 | #define STATIC_FLAGS (SS_LEFT|WS_CHILD|WS_VISIBLE) |
223d09f6 | 138 | #define CHECK_CLASS wxT("BUTTON") |
2bda0e17 KB |
139 | #define CHECK_FLAGS (BS_AUTOCHECKBOX|WS_TABSTOP|WS_CHILD) |
140 | #define CHECK_IS_FAFA FALSE | |
223d09f6 | 141 | #define RADIO_CLASS wxT("BUTTON") |
2bda0e17 KB |
142 | #define RADIO_FLAGS (BS_AUTORADIOBUTTON|WS_CHILD|WS_VISIBLE) |
143 | #define RADIO_SIZE 20 | |
144 | #define RADIO_IS_FAFA FALSE | |
145 | #define PURE_WINDOWS | |
223d09f6 | 146 | #define GROUP_CLASS wxT("BUTTON") |
2bda0e17 KB |
147 | #define GROUP_FLAGS (BS_GROUPBOX|WS_CHILD|WS_VISIBLE) |
148 | ||
149 | /* | |
150 | #define BITCHECK_FLAGS (FB_BITMAP|FC_BUTTONDRAW|FC_DEFAULT|WS_VISIBLE) | |
151 | #define BITRADIO_FLAGS (FC_BUTTONDRAW|FB_BITMAP|FC_RADIO|WS_CHILD|WS_VISIBLE) | |
152 | */ | |
153 | ||
a23fd0e1 VZ |
154 | // --------------------------------------------------------------------------- |
155 | // misc macros | |
156 | // --------------------------------------------------------------------------- | |
157 | ||
2bda0e17 | 158 | #define MEANING_CHARACTER '0' |
5d368213 | 159 | #define DEFAULT_ITEM_WIDTH 100 |
2bda0e17 | 160 | #define DEFAULT_ITEM_HEIGHT 80 |
1c4a764c VZ |
161 | |
162 | // Scale font to get edit control height | |
f6bcfd97 BP |
163 | //#define EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy) (3*(cy)/2) |
164 | #define EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy) (cy+8) | |
2bda0e17 KB |
165 | |
166 | // Generic subclass proc, for panel item moving/sizing and intercept | |
167 | // EDIT control VK_RETURN messages | |
168 | extern LONG APIENTRY _EXPORT | |
169 | wxSubclassedGenericControlProc(WXHWND hWnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
170 | ||
a23fd0e1 VZ |
171 | // --------------------------------------------------------------------------- |
172 | // constants which might miss from some compilers' headers | |
173 | // --------------------------------------------------------------------------- | |
174 | ||
175 | #if !defined(__WIN32__) && !defined(WS_EX_CLIENTEDGE) | |
176 | #define WS_EX_CLIENTEDGE 0 | |
177 | #endif | |
178 | ||
179 | #if defined(__WIN32__) && !defined(WS_EX_CLIENTEDGE) | |
180 | #define WS_EX_CLIENTEDGE 0x00000200L | |
181 | #endif | |
182 | ||
183 | #ifndef ENDSESSION_LOGOFF | |
184 | #define ENDSESSION_LOGOFF 0x80000000 | |
185 | #endif | |
186 | ||
11c7d5b6 VZ |
187 | // --------------------------------------------------------------------------- |
188 | // useful macros and functions | |
189 | // --------------------------------------------------------------------------- | |
190 | ||
191 | // a wrapper macro for ZeroMemory() | |
04ef50df | 192 | #if defined(__WIN32__) && !defined(__WXMICROWIN__) |
11c7d5b6 | 193 | #define wxZeroMemory(obj) ::ZeroMemory(&obj, sizeof(obj)) |
0e528b99 JS |
194 | #else |
195 | #define wxZeroMemory(obj) memset((void*) & obj, 0, sizeof(obj)) | |
196 | #endif | |
11c7d5b6 | 197 | |
f6bcfd97 BP |
198 | #if wxUSE_GUI |
199 | ||
01dba85a JS |
200 | #include <wx/gdicmn.h> |
201 | ||
11c7d5b6 VZ |
202 | // make conversion from wxColour and COLORREF a bit less painful |
203 | inline COLORREF wxColourToRGB(const wxColour& c) | |
204 | { | |
205 | return RGB(c.Red(), c.Green(), c.Blue()); | |
206 | } | |
207 | ||
208 | inline void wxRGBToColour(wxColour& c, COLORREF rgb) | |
209 | { | |
210 | c.Set(GetRValue(rgb), GetGValue(rgb), GetBValue(rgb)); | |
211 | } | |
212 | ||
ed791986 VZ |
213 | // copy Windows RECT to our wxRect |
214 | inline void wxCopyRECTToRect(const RECT& r, wxRect& rect) | |
215 | { | |
216 | rect.y = r.top; | |
217 | rect.x = r.left; | |
218 | rect.width = r.right - r.left; | |
219 | rect.height = r.bottom - r.top; | |
220 | } | |
221 | ||
d9317fd4 VZ |
222 | // translations between HIMETRIC units (which OLE likes) and pixels (which are |
223 | // liked by all the others) - implemented in msw/utilsexc.cpp | |
224 | extern void HIMETRICToPixel(LONG *x, LONG *y); | |
225 | extern void PixelToHIMETRIC(LONG *x, LONG *y); | |
226 | ||
4b7f2165 VZ |
227 | // Windows convention of the mask is opposed to the wxWindows one, so we need |
228 | // to invert the mask each time we pass one/get one to/from Windows | |
229 | extern HBITMAP wxInvertMask(HBITMAP hbmpMask, int w = 0, int h = 0); | |
230 | ||
8614c467 VZ |
231 | // get (x, y) from DWORD - notice that HI/LOWORD can *not* be used because they |
232 | // will fail on system with multiple monitors where the coords may be negative | |
233 | // | |
234 | // these macros are standard now (Win98) but some older headers don't have them | |
235 | #ifndef GET_X_LPARAM | |
236 | #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp)) | |
237 | #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp)) | |
238 | #endif // GET_X_LPARAM | |
239 | ||
a95e38c0 | 240 | // get the current state of SHIFT/CTRL keys |
1f80a703 | 241 | inline bool wxIsShiftDown() |
a95e38c0 VZ |
242 | { |
243 | return (::GetKeyState(VK_SHIFT) & 0x100) != 0; | |
244 | } | |
245 | ||
1f80a703 | 246 | inline bool wxIsCtrlDown() |
a95e38c0 VZ |
247 | { |
248 | return (::GetKeyState(VK_CONTROL) & 0x100) != 0; | |
249 | } | |
250 | ||
6d167489 VZ |
251 | // --------------------------------------------------------------------------- |
252 | // small helper classes | |
253 | // --------------------------------------------------------------------------- | |
254 | ||
255 | // create an instance of this class and use it as the HDC for screen, will | |
256 | // automatically release the DC going out of scope | |
257 | class ScreenHDC | |
258 | { | |
259 | public: | |
260 | ScreenHDC() { m_hdc = GetDC(NULL); } | |
261 | ~ScreenHDC() { ReleaseDC(NULL, m_hdc); } | |
262 | operator HDC() const { return m_hdc; } | |
263 | ||
264 | private: | |
265 | HDC m_hdc; | |
266 | }; | |
267 | ||
a23fd0e1 | 268 | // --------------------------------------------------------------------------- |
42e69d6b | 269 | // macros to make casting between WXFOO and FOO a bit easier: the GetFoo() |
c50f1fb9 VZ |
270 | // returns Foo cast to the Windows type for oruselves, while GetFooOf() takes |
271 | // an argument which should be a pointer or reference to the object of the | |
272 | // corresponding class (this depends on the macro) | |
a23fd0e1 VZ |
273 | // --------------------------------------------------------------------------- |
274 | ||
275 | #define GetHwnd() ((HWND)GetHWND()) | |
c50f1fb9 VZ |
276 | #define GetHwndOf(win) ((HWND)((win)->GetHWND())) |
277 | // old name | |
278 | #define GetWinHwnd GetHwndOf | |
a23fd0e1 VZ |
279 | |
280 | #define GetHdc() ((HDC)GetHDC()) | |
c50f1fb9 | 281 | #define GetHdcOf(dc) ((HDC)(dc).GetHDC()) |
a23fd0e1 | 282 | |
11c7d5b6 VZ |
283 | #define GetHbitmap() ((HBITMAP)GetHBITMAP()) |
284 | #define GetHbitmapOf(bmp) ((HBITMAP)(bmp).GetHBITMAP()) | |
285 | ||
42e69d6b | 286 | #define GetHicon() ((HICON)GetHICON()) |
c50f1fb9 | 287 | #define GetHiconOf(icon) ((HICON)(icon).GetHICON()) |
42e69d6b | 288 | |
a23fd0e1 | 289 | #define GetHaccel() ((HACCEL)GetHACCEL()) |
c50f1fb9 VZ |
290 | #define GetHaccelOf(table) ((HACCEL)((table).GetHACCEL())) |
291 | ||
292 | #define GetHmenu() ((HMENU)GetHMenu()) | |
293 | #define GetHmenuOf(menu) ((HMENU)menu->GetHMenu()) | |
a23fd0e1 | 294 | |
bfbd6dc1 VZ |
295 | #define GetHcursor() ((HCURSOR)GetHCURSOR()) |
296 | #define GetHcursorOf(cursor) ((HCURSOR)(cursor).GetHCURSOR()) | |
297 | ||
f6bcfd97 BP |
298 | #define GetHfont() ((HFONT)GetHFONT()) |
299 | #define GetHfontOf(font) ((HFONT)(font).GetHFONT()) | |
300 | ||
1e6feb95 VZ |
301 | #define GetHrgn() ((HRGN)GetHRGN()) |
302 | #define GetHrgnOf(rgn) ((HRGN)(rgn).GetHRGN()) | |
303 | ||
f6bcfd97 BP |
304 | #endif // wxUSE_GUI |
305 | ||
a23fd0e1 VZ |
306 | // --------------------------------------------------------------------------- |
307 | // global data | |
308 | // --------------------------------------------------------------------------- | |
2bda0e17 | 309 | |
621ae68a | 310 | WXDLLEXPORT_DATA(extern wxChar*) wxBuffer; |
b568d04f | 311 | |
2bda0e17 KB |
312 | WXDLLEXPORT_DATA(extern HINSTANCE) wxhInstance; |
313 | ||
a23fd0e1 VZ |
314 | // --------------------------------------------------------------------------- |
315 | // global functions | |
316 | // --------------------------------------------------------------------------- | |
317 | ||
18600546 GRG |
318 | extern "C" |
319 | { | |
b568d04f | 320 | WXDLLEXPORT HINSTANCE wxGetInstance(); |
18600546 GRG |
321 | } |
322 | ||
a23fd0e1 VZ |
323 | WXDLLEXPORT void wxSetInstance(HINSTANCE hInst); |
324 | ||
b568d04f VZ |
325 | #if wxUSE_GUI |
326 | ||
bfbd6dc1 VZ |
327 | // cursor stuff |
328 | extern HCURSOR wxGetCurrentBusyCursor(); // from msw/utils.cpp | |
329 | extern const wxCursor *wxGetGlobalCursor(); // from msw/cursor.cpp | |
330 | ||
a23fd0e1 VZ |
331 | WXDLLEXPORT wxWindow* wxFindWinFromHandle(WXHWND hWnd); |
332 | ||
f68586e5 | 333 | WXDLLEXPORT void wxGetCharSize(WXHWND wnd, int *x, int *y, const wxFont *the_font); |
11c7d5b6 VZ |
334 | WXDLLEXPORT void wxFillLogFont(LOGFONT *logFont, const wxFont *font); |
335 | WXDLLEXPORT wxFont wxCreateFontFromLogFont(const LOGFONT *logFont); | |
f6bcfd97 | 336 | WXDLLEXPORT wxFontEncoding wxGetFontEncFromCharSet(int charset); |
a23fd0e1 VZ |
337 | |
338 | WXDLLEXPORT void wxSliderEvent(WXHWND control, WXWORD wParam, WXWORD pos); | |
339 | WXDLLEXPORT void wxScrollBarEvent(WXHWND hbar, WXWORD wParam, WXWORD pos); | |
340 | ||
341 | // Find maximum size of window/rectangle | |
342 | WXDLLEXPORT extern void wxFindMaxSize(WXHWND hwnd, RECT *rect); | |
343 | ||
184b5d99 JS |
344 | WXDLLEXPORT wxWindow* wxFindControlFromHandle(WXHWND hWnd); |
345 | WXDLLEXPORT void wxAddControlHandle(WXHWND hWnd, wxWindow *item); | |
2bda0e17 | 346 | |
1c4a764c | 347 | // Safely get the window text (i.e. without using fixed size buffer) |
184b5d99 | 348 | WXDLLEXPORT extern wxString wxGetWindowText(WXHWND hWnd); |
1c4a764c | 349 | |
cc2b7472 VZ |
350 | // get the window class name |
351 | WXDLLEXPORT extern wxString wxGetWindowClass(WXHWND hWnd); | |
352 | ||
42e69d6b VZ |
353 | // get the window id (should be unsigned, hence this is not wxWindowID which |
354 | // is, for mainly historical reasons, signed) | |
355 | WXDLLEXPORT extern WXWORD wxGetWindowId(WXHWND hWnd); | |
cc2b7472 | 356 | |
c085e333 | 357 | // Does this window style specify any border? |
184b5d99 | 358 | inline bool wxStyleHasBorder(long style) |
c085e333 VZ |
359 | { |
360 | return (style & (wxSIMPLE_BORDER | wxRAISED_BORDER | | |
361 | wxSUNKEN_BORDER | wxDOUBLE_BORDER)) != 0; | |
362 | } | |
363 | ||
8614c467 VZ |
364 | // find the window for HWND which is part of some wxWindow, returns just the |
365 | // corresponding wxWindow for HWND which just is one | |
366 | // | |
367 | // may return NULL | |
368 | extern wxWindow *wxGetWindowFromHWND(WXHWND hwnd); | |
369 | ||
b568d04f VZ |
370 | #endif // wxUSE_GUI |
371 | ||
2bda0e17 | 372 | #endif |
bbcdf8bc | 373 | // _WX_PRIVATE_H_ |