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