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