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