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