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