]>
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 KB |
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 | ||
a23fd0e1 | 54 | // --------------------------------------------------------------------------- |
11c7d5b6 | 55 | // define things missing from some compilers' headers |
a23fd0e1 | 56 | // --------------------------------------------------------------------------- |
c455ab93 | 57 | |
11c7d5b6 VZ |
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 | |
65fd5cb0 | 64 | #if defined(__GNUWIN32__) && !defined(wxUSE_NORLANDER_HEADERS) |
d6a1743b | 65 | # define CASTWNDPROC (long unsigned) |
2bda0e17 | 66 | #else |
d6a1743b | 67 | # ifdef __BORLANDC__ |
62448488 JS |
68 | |
69 | # ifdef __WIN32__ | |
d6a1743b | 70 | # define CASTWNDPROC |
62448488 JS |
71 | # else |
72 | typedef int (pascal * WndProcCast) (); | |
73 | # define CASTWNDPROC (WndProcCast) | |
74 | # endif | |
75 | ||
d6a1743b | 76 | # else |
65fd5cb0 | 77 | # if defined (__WIN32__) && defined(STRICT) |
81d66cf3 JS |
78 | typedef long (_stdcall * WndProcCast) (HWND, unsigned int, unsigned int, long); |
79 | # define CASTWNDPROC (WndProcCast) | |
1e6d9499 | 80 | # elif defined(__WIN16__) |
62448488 JS |
81 | # ifdef __BORLANDC__ |
82 | typedef int (pascal * WndProcCast) (); | |
83 | # define CASTWNDPROC (WndProcCast) | |
84 | # else | |
27a9bd48 PA |
85 | # if defined(__VISUALC__) && defined(STRICT) |
86 | # define CASTWNDPROC (WNDPROC) | |
87 | # else | |
88 | typedef int (PASCAL * WndProcCast) (); | |
89 | # define CASTWNDPROC (WndProcCast) | |
90 | # endif | |
62448488 | 91 | # endif |
81d66cf3 JS |
92 | # else |
93 | # define CASTWNDPROC | |
94 | # endif | |
d6a1743b | 95 | # endif |
2bda0e17 KB |
96 | #endif |
97 | ||
a23fd0e1 VZ |
98 | // --------------------------------------------------------------------------- |
99 | // some stuff for old Windows versions (FIXME: what does it do here??) | |
100 | // --------------------------------------------------------------------------- | |
101 | ||
c085e333 | 102 | #if !defined(APIENTRY) // NT defines APIENTRY, 3.x not |
a23fd0e1 | 103 | #define APIENTRY FAR PASCAL |
2bda0e17 | 104 | #endif |
c085e333 | 105 | |
2bda0e17 | 106 | #ifdef __WIN32__ |
a23fd0e1 | 107 | #define _EXPORT |
2bda0e17 | 108 | #else |
a23fd0e1 VZ |
109 | #define _EXPORT _export |
110 | #endif | |
111 | ||
112 | #ifndef __WIN32__ | |
113 | typedef signed short int SHORT; | |
2bda0e17 | 114 | #endif |
c085e333 VZ |
115 | |
116 | #if !defined(__WIN32__) // 3.x uses FARPROC for dialogs | |
27a9bd48 | 117 | #ifndef STRICT |
a23fd0e1 | 118 | #define DLGPROC FARPROC |
2bda0e17 | 119 | #endif |
27a9bd48 | 120 | #endif |
2bda0e17 | 121 | |
47d67540 | 122 | #if wxUSE_PENWIN |
cc2b7472 VZ |
123 | WXDLLEXPORT void wxRegisterPenWin(); |
124 | WXDLLEXPORT void wxCleanUpPenWin(); | |
125 | WXDLLEXPORT void wxEnablePenAppHooks (bool hook); | |
126 | #endif // wxUSE_PENWIN | |
2bda0e17 | 127 | |
47d67540 | 128 | #if wxUSE_ITSY_BITSY |
a23fd0e1 VZ |
129 | #define IBS_HORZCAPTION 0x4000L |
130 | #define IBS_VERTCAPTION 0x8000L | |
2bda0e17 | 131 | |
a23fd0e1 VZ |
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 | |
2bda0e17 | 137 | |
1f112209 | 138 | #if wxUSE_CTL3D |
a23fd0e1 VZ |
139 | #include "wx/msw/ctl3d/ctl3d.h" |
140 | #endif // wxUSE_CTL3D | |
2bda0e17 KB |
141 | |
142 | /* | |
143 | * Decide what window classes we're going to use | |
144 | * for this combination of CTl3D/FAFA settings | |
145 | */ | |
c085e333 | 146 | |
223d09f6 | 147 | #define STATIC_CLASS wxT("STATIC") |
2bda0e17 | 148 | #define STATIC_FLAGS (SS_LEFT|WS_CHILD|WS_VISIBLE) |
223d09f6 | 149 | #define CHECK_CLASS wxT("BUTTON") |
2bda0e17 KB |
150 | #define CHECK_FLAGS (BS_AUTOCHECKBOX|WS_TABSTOP|WS_CHILD) |
151 | #define CHECK_IS_FAFA FALSE | |
223d09f6 | 152 | #define RADIO_CLASS wxT("BUTTON") |
2bda0e17 KB |
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 | |
223d09f6 | 157 | #define GROUP_CLASS wxT("BUTTON") |
2bda0e17 KB |
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 | ||
a23fd0e1 VZ |
165 | // --------------------------------------------------------------------------- |
166 | // misc macros | |
167 | // --------------------------------------------------------------------------- | |
168 | ||
2bda0e17 KB |
169 | #define MEANING_CHARACTER '0' |
170 | #define DEFAULT_ITEM_WIDTH 200 | |
171 | #define DEFAULT_ITEM_HEIGHT 80 | |
1c4a764c VZ |
172 | |
173 | // Scale font to get edit control height | |
174 | #define EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy) (3*(cy)/2) | |
2bda0e17 KB |
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 | ||
a23fd0e1 VZ |
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 | ||
11c7d5b6 VZ |
213 | // --------------------------------------------------------------------------- |
214 | // useful macros and functions | |
215 | // --------------------------------------------------------------------------- | |
216 | ||
217 | // a wrapper macro for ZeroMemory() | |
0e528b99 | 218 | #ifdef __WIN32__ |
11c7d5b6 | 219 | #define wxZeroMemory(obj) ::ZeroMemory(&obj, sizeof(obj)) |
0e528b99 JS |
220 | #else |
221 | #define wxZeroMemory(obj) memset((void*) & obj, 0, sizeof(obj)) | |
222 | #endif | |
11c7d5b6 VZ |
223 | |
224 | // make conversion from wxColour and COLORREF a bit less painful | |
225 | inline COLORREF wxColourToRGB(const wxColour& c) | |
226 | { | |
227 | return RGB(c.Red(), c.Green(), c.Blue()); | |
228 | } | |
229 | ||
230 | inline void wxRGBToColour(wxColour& c, COLORREF rgb) | |
231 | { | |
232 | c.Set(GetRValue(rgb), GetGValue(rgb), GetBValue(rgb)); | |
233 | } | |
234 | ||
a23fd0e1 | 235 | // --------------------------------------------------------------------------- |
42e69d6b | 236 | // macros to make casting between WXFOO and FOO a bit easier: the GetFoo() |
c50f1fb9 VZ |
237 | // returns Foo cast to the Windows type for oruselves, while GetFooOf() takes |
238 | // an argument which should be a pointer or reference to the object of the | |
239 | // corresponding class (this depends on the macro) | |
a23fd0e1 VZ |
240 | // --------------------------------------------------------------------------- |
241 | ||
242 | #define GetHwnd() ((HWND)GetHWND()) | |
c50f1fb9 VZ |
243 | #define GetHwndOf(win) ((HWND)((win)->GetHWND())) |
244 | // old name | |
245 | #define GetWinHwnd GetHwndOf | |
a23fd0e1 VZ |
246 | |
247 | #define GetHdc() ((HDC)GetHDC()) | |
c50f1fb9 | 248 | #define GetHdcOf(dc) ((HDC)(dc).GetHDC()) |
a23fd0e1 | 249 | |
11c7d5b6 VZ |
250 | #define GetHbitmap() ((HBITMAP)GetHBITMAP()) |
251 | #define GetHbitmapOf(bmp) ((HBITMAP)(bmp).GetHBITMAP()) | |
252 | ||
42e69d6b | 253 | #define GetHicon() ((HICON)GetHICON()) |
c50f1fb9 | 254 | #define GetHiconOf(icon) ((HICON)(icon).GetHICON()) |
42e69d6b | 255 | |
a23fd0e1 | 256 | #define GetHaccel() ((HACCEL)GetHACCEL()) |
c50f1fb9 VZ |
257 | #define GetHaccelOf(table) ((HACCEL)((table).GetHACCEL())) |
258 | ||
259 | #define GetHmenu() ((HMENU)GetHMenu()) | |
260 | #define GetHmenuOf(menu) ((HMENU)menu->GetHMenu()) | |
a23fd0e1 VZ |
261 | |
262 | // --------------------------------------------------------------------------- | |
263 | // global data | |
264 | // --------------------------------------------------------------------------- | |
2bda0e17 | 265 | |
2bda0e17 KB |
266 | // The MakeProcInstance version of the function wxSubclassedGenericControlProc |
267 | WXDLLEXPORT_DATA(extern FARPROC) wxGenericControlSubClassProc; | |
621ae68a | 268 | WXDLLEXPORT_DATA(extern wxChar*) wxBuffer; |
2bda0e17 KB |
269 | WXDLLEXPORT_DATA(extern HINSTANCE) wxhInstance; |
270 | ||
a23fd0e1 VZ |
271 | // --------------------------------------------------------------------------- |
272 | // global functions | |
273 | // --------------------------------------------------------------------------- | |
274 | ||
18600546 GRG |
275 | extern "C" |
276 | { | |
a23fd0e1 | 277 | WXDLLEXPORT HINSTANCE wxGetInstance(); |
18600546 GRG |
278 | } |
279 | ||
a23fd0e1 VZ |
280 | WXDLLEXPORT void wxSetInstance(HINSTANCE hInst); |
281 | ||
282 | WXDLLEXPORT wxWindow* wxFindWinFromHandle(WXHWND hWnd); | |
283 | ||
284 | WXDLLEXPORT void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font); | |
11c7d5b6 VZ |
285 | WXDLLEXPORT void wxFillLogFont(LOGFONT *logFont, const wxFont *font); |
286 | WXDLLEXPORT wxFont wxCreateFontFromLogFont(const LOGFONT *logFont); | |
a23fd0e1 VZ |
287 | |
288 | WXDLLEXPORT void wxSliderEvent(WXHWND control, WXWORD wParam, WXWORD pos); | |
289 | WXDLLEXPORT void wxScrollBarEvent(WXHWND hbar, WXWORD wParam, WXWORD pos); | |
290 | ||
291 | // Find maximum size of window/rectangle | |
292 | WXDLLEXPORT extern void wxFindMaxSize(WXHWND hwnd, RECT *rect); | |
293 | ||
184b5d99 JS |
294 | WXDLLEXPORT wxWindow* wxFindControlFromHandle(WXHWND hWnd); |
295 | WXDLLEXPORT void wxAddControlHandle(WXHWND hWnd, wxWindow *item); | |
2bda0e17 | 296 | |
1c4a764c | 297 | // Safely get the window text (i.e. without using fixed size buffer) |
184b5d99 | 298 | WXDLLEXPORT extern wxString wxGetWindowText(WXHWND hWnd); |
1c4a764c | 299 | |
cc2b7472 VZ |
300 | // get the window class name |
301 | WXDLLEXPORT extern wxString wxGetWindowClass(WXHWND hWnd); | |
302 | ||
42e69d6b VZ |
303 | // get the window id (should be unsigned, hence this is not wxWindowID which |
304 | // is, for mainly historical reasons, signed) | |
305 | WXDLLEXPORT extern WXWORD wxGetWindowId(WXHWND hWnd); | |
cc2b7472 | 306 | |
c085e333 | 307 | // Does this window style specify any border? |
184b5d99 | 308 | inline bool wxStyleHasBorder(long style) |
c085e333 VZ |
309 | { |
310 | return (style & (wxSIMPLE_BORDER | wxRAISED_BORDER | | |
311 | wxSUNKEN_BORDER | wxDOUBLE_BORDER)) != 0; | |
312 | } | |
313 | ||
2bda0e17 | 314 | #endif |
bbcdf8bc | 315 | // _WX_PRIVATE_H_ |