]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/private.h
1. wxStaticBox doesn't draw over the underlying controls any more
[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
KB
45
46WXDLLEXPORT_DATA(extern HICON) wxSTD_FRAME_ICON;
47WXDLLEXPORT_DATA(extern HICON) wxSTD_MDIPARENTFRAME_ICON;
48WXDLLEXPORT_DATA(extern HICON) wxSTD_MDICHILDFRAME_ICON;
49WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_FRAME_ICON;
50WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_MDIPARENTFRAME_ICON;
51WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_MDICHILDFRAME_ICON;
52WXDLLEXPORT_DATA(extern HFONT) wxSTATUS_LINE_FONT;
53
a23fd0e1 54// ---------------------------------------------------------------------------
11c7d5b6 55// define things missing from some compilers' headers
a23fd0e1 56// ---------------------------------------------------------------------------
c455ab93 57
11c7d5b6 58#if defined(__GNUWIN32__) && !defined(wxUSE_NORLANDER_HEADERS)
01dba85a 59#ifndef ZeroMemory
11c7d5b6 60 inline void ZeroMemory(void *buf, size_t len) { memset(buf, 0, len); }
01dba85a 61#endif
11c7d5b6
VZ
62#endif // old mingw32
63
64// this defines a CASTWNDPROC macro which casts a pointer to the type of a
65// window proc
65fd5cb0 66#if defined(__GNUWIN32__) && !defined(wxUSE_NORLANDER_HEADERS)
d6a1743b 67# define CASTWNDPROC (long unsigned)
2bda0e17 68#else
d6a1743b 69# ifdef __BORLANDC__
62448488
JS
70
71# ifdef __WIN32__
d6a1743b 72# define CASTWNDPROC
62448488
JS
73# else
74 typedef int (pascal * WndProcCast) ();
75# define CASTWNDPROC (WndProcCast)
76# endif
77
d6a1743b 78# else
65fd5cb0 79# if defined (__WIN32__) && defined(STRICT)
81d66cf3
JS
80 typedef long (_stdcall * WndProcCast) (HWND, unsigned int, unsigned int, long);
81# define CASTWNDPROC (WndProcCast)
1e6d9499 82# elif defined(__WIN16__)
62448488
JS
83# ifdef __BORLANDC__
84 typedef int (pascal * WndProcCast) ();
85# define CASTWNDPROC (WndProcCast)
86# else
27a9bd48
PA
87# if defined(__VISUALC__) && defined(STRICT)
88# define CASTWNDPROC (WNDPROC)
89# else
90 typedef int (PASCAL * WndProcCast) ();
91# define CASTWNDPROC (WndProcCast)
92# endif
62448488 93# endif
81d66cf3
JS
94# else
95# define CASTWNDPROC
96# endif
d6a1743b 97# endif
2bda0e17
KB
98#endif
99
a23fd0e1
VZ
100// ---------------------------------------------------------------------------
101// some stuff for old Windows versions (FIXME: what does it do here??)
102// ---------------------------------------------------------------------------
103
c085e333 104#if !defined(APIENTRY) // NT defines APIENTRY, 3.x not
a23fd0e1 105 #define APIENTRY FAR PASCAL
2bda0e17 106#endif
c085e333 107
2bda0e17 108#ifdef __WIN32__
a23fd0e1 109 #define _EXPORT
2bda0e17 110#else
a23fd0e1
VZ
111 #define _EXPORT _export
112#endif
113
114#ifndef __WIN32__
115 typedef signed short int SHORT;
2bda0e17 116#endif
c085e333
VZ
117
118#if !defined(__WIN32__) // 3.x uses FARPROC for dialogs
27a9bd48 119#ifndef STRICT
a23fd0e1 120 #define DLGPROC FARPROC
2bda0e17 121#endif
27a9bd48 122#endif
2bda0e17 123
47d67540 124#if wxUSE_PENWIN
cc2b7472
VZ
125 WXDLLEXPORT void wxRegisterPenWin();
126 WXDLLEXPORT void wxCleanUpPenWin();
127 WXDLLEXPORT void wxEnablePenAppHooks (bool hook);
128#endif // wxUSE_PENWIN
2bda0e17 129
47d67540 130#if wxUSE_ITSY_BITSY
a23fd0e1
VZ
131 #define IBS_HORZCAPTION 0x4000L
132 #define IBS_VERTCAPTION 0x8000L
2bda0e17 133
a23fd0e1
VZ
134 UINT WINAPI ibGetCaptionSize( HWND hWnd ) ;
135 UINT WINAPI ibSetCaptionSize( HWND hWnd, UINT nSize ) ;
136 LRESULT WINAPI ibDefWindowProc( HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam ) ;
137 VOID WINAPI ibAdjustWindowRect( HWND hWnd, LPRECT lprc ) ;
138#endif // wxUSE_ITSY_BITSY
2bda0e17 139
1f112209 140#if wxUSE_CTL3D
a23fd0e1
VZ
141 #include "wx/msw/ctl3d/ctl3d.h"
142#endif // wxUSE_CTL3D
2bda0e17
KB
143
144/*
145 * Decide what window classes we're going to use
146 * for this combination of CTl3D/FAFA settings
147 */
c085e333 148
223d09f6 149#define STATIC_CLASS wxT("STATIC")
2bda0e17 150#define STATIC_FLAGS (SS_LEFT|WS_CHILD|WS_VISIBLE)
223d09f6 151#define CHECK_CLASS wxT("BUTTON")
2bda0e17
KB
152#define CHECK_FLAGS (BS_AUTOCHECKBOX|WS_TABSTOP|WS_CHILD)
153#define CHECK_IS_FAFA FALSE
223d09f6 154#define RADIO_CLASS wxT("BUTTON")
2bda0e17
KB
155#define RADIO_FLAGS (BS_AUTORADIOBUTTON|WS_CHILD|WS_VISIBLE)
156#define RADIO_SIZE 20
157#define RADIO_IS_FAFA FALSE
158#define PURE_WINDOWS
223d09f6 159#define GROUP_CLASS wxT("BUTTON")
2bda0e17
KB
160#define GROUP_FLAGS (BS_GROUPBOX|WS_CHILD|WS_VISIBLE)
161
162/*
163#define BITCHECK_FLAGS (FB_BITMAP|FC_BUTTONDRAW|FC_DEFAULT|WS_VISIBLE)
164#define BITRADIO_FLAGS (FC_BUTTONDRAW|FB_BITMAP|FC_RADIO|WS_CHILD|WS_VISIBLE)
165*/
166
a23fd0e1
VZ
167// ---------------------------------------------------------------------------
168// misc macros
169// ---------------------------------------------------------------------------
170
2bda0e17
KB
171#define MEANING_CHARACTER '0'
172#define DEFAULT_ITEM_WIDTH 200
173#define DEFAULT_ITEM_HEIGHT 80
1c4a764c
VZ
174
175// Scale font to get edit control height
176#define EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy) (3*(cy)/2)
2bda0e17
KB
177
178// Generic subclass proc, for panel item moving/sizing and intercept
179// EDIT control VK_RETURN messages
180extern LONG APIENTRY _EXPORT
181 wxSubclassedGenericControlProc(WXHWND hWnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
182
a23fd0e1
VZ
183// ---------------------------------------------------------------------------
184// constants which might miss from some compilers' headers
185// ---------------------------------------------------------------------------
186
187#if !defined(__WIN32__) && !defined(WS_EX_CLIENTEDGE)
188 #define WS_EX_CLIENTEDGE 0
189#endif
190
191#if defined(__WIN32__) && !defined(WS_EX_CLIENTEDGE)
192 #define WS_EX_CLIENTEDGE 0x00000200L
193#endif
194
195#ifndef ENDSESSION_LOGOFF
196 #define ENDSESSION_LOGOFF 0x80000000
197#endif
198
199// ---------------------------------------------------------------------------
200// debug messages
201// ---------------------------------------------------------------------------
202#if defined(__WIN95__) && defined(__WXDEBUG__) && wxUSE_DBWIN32
203
204 #ifndef __TWIN32__
205 #ifdef OutputDebugString
206 #undef OutputDebugString
207 #endif
208
209 #define OutputDebugString OutputDebugStringW95
210 #endif // __TWIN32__
211
212 extern void OutputDebugStringW95(const wxChar*, ...);
213#endif // USE_DBWIN32
214
11c7d5b6
VZ
215// ---------------------------------------------------------------------------
216// useful macros and functions
217// ---------------------------------------------------------------------------
218
219// a wrapper macro for ZeroMemory()
0e528b99 220#ifdef __WIN32__
11c7d5b6 221#define wxZeroMemory(obj) ::ZeroMemory(&obj, sizeof(obj))
0e528b99
JS
222#else
223#define wxZeroMemory(obj) memset((void*) & obj, 0, sizeof(obj))
224#endif
11c7d5b6 225
01dba85a
JS
226#include <wx/gdicmn.h>
227
11c7d5b6
VZ
228// make conversion from wxColour and COLORREF a bit less painful
229inline COLORREF wxColourToRGB(const wxColour& c)
230{
231 return RGB(c.Red(), c.Green(), c.Blue());
232}
233
234inline void wxRGBToColour(wxColour& c, COLORREF rgb)
235{
236 c.Set(GetRValue(rgb), GetGValue(rgb), GetBValue(rgb));
237}
238
a23fd0e1 239// ---------------------------------------------------------------------------
42e69d6b 240// macros to make casting between WXFOO and FOO a bit easier: the GetFoo()
c50f1fb9
VZ
241// returns Foo cast to the Windows type for oruselves, while GetFooOf() takes
242// an argument which should be a pointer or reference to the object of the
243// corresponding class (this depends on the macro)
a23fd0e1
VZ
244// ---------------------------------------------------------------------------
245
246#define GetHwnd() ((HWND)GetHWND())
c50f1fb9
VZ
247#define GetHwndOf(win) ((HWND)((win)->GetHWND()))
248// old name
249#define GetWinHwnd GetHwndOf
a23fd0e1
VZ
250
251#define GetHdc() ((HDC)GetHDC())
c50f1fb9 252#define GetHdcOf(dc) ((HDC)(dc).GetHDC())
a23fd0e1 253
11c7d5b6
VZ
254#define GetHbitmap() ((HBITMAP)GetHBITMAP())
255#define GetHbitmapOf(bmp) ((HBITMAP)(bmp).GetHBITMAP())
256
42e69d6b 257#define GetHicon() ((HICON)GetHICON())
c50f1fb9 258#define GetHiconOf(icon) ((HICON)(icon).GetHICON())
42e69d6b 259
a23fd0e1 260#define GetHaccel() ((HACCEL)GetHACCEL())
c50f1fb9
VZ
261#define GetHaccelOf(table) ((HACCEL)((table).GetHACCEL()))
262
263#define GetHmenu() ((HMENU)GetHMenu())
264#define GetHmenuOf(menu) ((HMENU)menu->GetHMenu())
a23fd0e1
VZ
265
266// ---------------------------------------------------------------------------
267// global data
268// ---------------------------------------------------------------------------
2bda0e17 269
2bda0e17
KB
270// The MakeProcInstance version of the function wxSubclassedGenericControlProc
271WXDLLEXPORT_DATA(extern FARPROC) wxGenericControlSubClassProc;
621ae68a 272WXDLLEXPORT_DATA(extern wxChar*) wxBuffer;
2bda0e17
KB
273WXDLLEXPORT_DATA(extern HINSTANCE) wxhInstance;
274
a23fd0e1
VZ
275// ---------------------------------------------------------------------------
276// global functions
277// ---------------------------------------------------------------------------
278
18600546
GRG
279extern "C"
280{
a23fd0e1 281WXDLLEXPORT HINSTANCE wxGetInstance();
18600546
GRG
282}
283
a23fd0e1
VZ
284WXDLLEXPORT void wxSetInstance(HINSTANCE hInst);
285
286WXDLLEXPORT wxWindow* wxFindWinFromHandle(WXHWND hWnd);
287
288WXDLLEXPORT void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font);
11c7d5b6
VZ
289WXDLLEXPORT void wxFillLogFont(LOGFONT *logFont, const wxFont *font);
290WXDLLEXPORT wxFont wxCreateFontFromLogFont(const LOGFONT *logFont);
a23fd0e1
VZ
291
292WXDLLEXPORT void wxSliderEvent(WXHWND control, WXWORD wParam, WXWORD pos);
293WXDLLEXPORT void wxScrollBarEvent(WXHWND hbar, WXWORD wParam, WXWORD pos);
294
295// Find maximum size of window/rectangle
296WXDLLEXPORT extern void wxFindMaxSize(WXHWND hwnd, RECT *rect);
297
184b5d99
JS
298WXDLLEXPORT wxWindow* wxFindControlFromHandle(WXHWND hWnd);
299WXDLLEXPORT void wxAddControlHandle(WXHWND hWnd, wxWindow *item);
2bda0e17 300
1c4a764c 301// Safely get the window text (i.e. without using fixed size buffer)
184b5d99 302WXDLLEXPORT extern wxString wxGetWindowText(WXHWND hWnd);
1c4a764c 303
cc2b7472
VZ
304// get the window class name
305WXDLLEXPORT extern wxString wxGetWindowClass(WXHWND hWnd);
306
42e69d6b
VZ
307// get the window id (should be unsigned, hence this is not wxWindowID which
308// is, for mainly historical reasons, signed)
309WXDLLEXPORT extern WXWORD wxGetWindowId(WXHWND hWnd);
cc2b7472 310
c085e333 311// Does this window style specify any border?
184b5d99 312inline bool wxStyleHasBorder(long style)
c085e333
VZ
313{
314 return (style & (wxSIMPLE_BORDER | wxRAISED_BORDER |
315 wxSUNKEN_BORDER | wxDOUBLE_BORDER)) != 0;
316}
317
2bda0e17 318#endif
bbcdf8bc 319 // _WX_PRIVATE_H_