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