1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Private declarations: as this header is only included by
4 // wxWindows itself, it may contain identifiers which don't start
6 // Author: Julian Smart
10 // Copyright: (c) Julian Smart
11 // Licence: wxWindows licence
12 /////////////////////////////////////////////////////////////////////////////
14 #ifndef _WX_PRIVATE_H_
15 #define _WX_PRIVATE_H_
19 // undefine conflicting symbols which were defined in windows.h
20 #include "wx/msw/winundef.h"
22 class WXDLLEXPORT wxFont
;
23 class WXDLLEXPORT wxWindow
;
25 // ---------------------------------------------------------------------------
27 // ---------------------------------------------------------------------------
30 static const double METRIC_CONVERSION_CONSTANT
= 0.0393700787;
32 // Scaling factors for various unit conversions
33 static const double mm2inches
= (METRIC_CONVERSION_CONSTANT
);
34 static const double inches2mm
= (1/METRIC_CONVERSION_CONSTANT
);
36 static const double mm2twips
= (METRIC_CONVERSION_CONSTANT
*1440);
37 static const double twips2mm
= (1/(METRIC_CONVERSION_CONSTANT
*1440));
39 static const double mm2pt
= (METRIC_CONVERSION_CONSTANT
*72);
40 static const double pt2mm
= (1/(METRIC_CONVERSION_CONSTANT
*72));
42 // ---------------------------------------------------------------------------
43 // standard icons from the resources
44 // ---------------------------------------------------------------------------
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
;
58 // ---------------------------------------------------------------------------
59 // define things missing from some compilers' headers
60 // ---------------------------------------------------------------------------
62 #if defined(__GNUWIN32__) && !wxUSE_NORLANDER_HEADERS
64 inline void ZeroMemory(void *buf
, size_t len
) { memset(buf
, 0, len
); }
68 // this defines a CASTWNDPROC macro which casts a pointer to the type of a
71 #ifdef __GNUWIN32_OLD__
72 #define CASTWNDPROC (long unsigned)
74 #if defined(STRICT) || defined(__GNUC__)
75 typedef WNDPROC WndProcCast
;
77 typedef FARPROC WndProcCast
;
79 #define CASTWNDPROC (WndProcCast)
80 #endif // __GNUWIN32_OLD__
82 // ---------------------------------------------------------------------------
83 // some stuff for old Windows versions (FIXME: what does it do here??)
84 // ---------------------------------------------------------------------------
86 #if !defined(APIENTRY) // NT defines APIENTRY, 3.x not
87 #define APIENTRY FAR PASCAL
93 #define _EXPORT _export
97 typedef signed short int SHORT
;
100 #if !defined(__WIN32__) // 3.x uses FARPROC for dialogs
102 #define DLGPROC FARPROC
107 WXDLLEXPORT
void wxRegisterPenWin();
108 WXDLLEXPORT
void wxCleanUpPenWin();
109 WXDLLEXPORT
void wxEnablePenAppHooks (bool hook
);
110 #endif // wxUSE_PENWIN
113 #define IBS_HORZCAPTION 0x4000L
114 #define IBS_VERTCAPTION 0x8000L
116 UINT WINAPI
ibGetCaptionSize( HWND hWnd
) ;
117 UINT WINAPI
ibSetCaptionSize( HWND hWnd
, UINT nSize
) ;
118 LRESULT WINAPI
ibDefWindowProc( HWND hWnd
, UINT uiMsg
, WPARAM wParam
, LPARAM lParam
) ;
119 VOID WINAPI
ibAdjustWindowRect( HWND hWnd
, LPRECT lprc
) ;
120 #endif // wxUSE_ITSY_BITSY
123 #include "wx/msw/ctl3d/ctl3d.h"
124 #endif // wxUSE_CTL3D
127 * Decide what window classes we're going to use
128 * for this combination of CTl3D/FAFA settings
131 #define STATIC_CLASS wxT("STATIC")
132 #define STATIC_FLAGS (SS_LEFT|WS_CHILD|WS_VISIBLE)
133 #define CHECK_CLASS wxT("BUTTON")
134 #define CHECK_FLAGS (BS_AUTOCHECKBOX|WS_TABSTOP|WS_CHILD)
135 #define CHECK_IS_FAFA FALSE
136 #define RADIO_CLASS wxT("BUTTON")
137 #define RADIO_FLAGS (BS_AUTORADIOBUTTON|WS_CHILD|WS_VISIBLE)
138 #define RADIO_SIZE 20
139 #define RADIO_IS_FAFA FALSE
141 #define GROUP_CLASS wxT("BUTTON")
142 #define GROUP_FLAGS (BS_GROUPBOX|WS_CHILD|WS_VISIBLE)
145 #define BITCHECK_FLAGS (FB_BITMAP|FC_BUTTONDRAW|FC_DEFAULT|WS_VISIBLE)
146 #define BITRADIO_FLAGS (FC_BUTTONDRAW|FB_BITMAP|FC_RADIO|WS_CHILD|WS_VISIBLE)
149 // ---------------------------------------------------------------------------
151 // ---------------------------------------------------------------------------
153 #define MEANING_CHARACTER '0'
154 #define DEFAULT_ITEM_WIDTH 100
155 #define DEFAULT_ITEM_HEIGHT 80
157 // Scale font to get edit control height
158 //#define EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy) (3*(cy)/2)
159 #define EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy) (cy+8)
161 // Generic subclass proc, for panel item moving/sizing and intercept
162 // EDIT control VK_RETURN messages
163 extern LONG APIENTRY _EXPORT
164 wxSubclassedGenericControlProc(WXHWND hWnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
166 // ---------------------------------------------------------------------------
167 // constants which might miss from some compilers' headers
168 // ---------------------------------------------------------------------------
170 #if !defined(__WIN32__) && !defined(WS_EX_CLIENTEDGE)
171 #define WS_EX_CLIENTEDGE 0
174 #if defined(__WIN32__) && !defined(WS_EX_CLIENTEDGE)
175 #define WS_EX_CLIENTEDGE 0x00000200L
178 #ifndef ENDSESSION_LOGOFF
179 #define ENDSESSION_LOGOFF 0x80000000
182 // ---------------------------------------------------------------------------
183 // useful macros and functions
184 // ---------------------------------------------------------------------------
186 // a wrapper macro for ZeroMemory()
188 #define wxZeroMemory(obj) ::ZeroMemory(&obj, sizeof(obj))
190 #define wxZeroMemory(obj) memset((void*) & obj, 0, sizeof(obj))
195 #include <wx/gdicmn.h>
197 // make conversion from wxColour and COLORREF a bit less painful
198 inline COLORREF
wxColourToRGB(const wxColour
& c
)
200 return RGB(c
.Red(), c
.Green(), c
.Blue());
203 inline void wxRGBToColour(wxColour
& c
, COLORREF rgb
)
205 c
.Set(GetRValue(rgb
), GetGValue(rgb
), GetBValue(rgb
));
208 // copy Windows RECT to our wxRect
209 inline void wxCopyRECTToRect(const RECT
& r
, wxRect
& rect
)
213 rect
.width
= r
.right
- r
.left
;
214 rect
.height
= r
.bottom
- r
.top
;
217 // translations between HIMETRIC units (which OLE likes) and pixels (which are
218 // liked by all the others) - implemented in msw/utilsexc.cpp
219 extern void HIMETRICToPixel(LONG
*x
, LONG
*y
);
220 extern void PixelToHIMETRIC(LONG
*x
, LONG
*y
);
222 // Windows convention of the mask is opposed to the wxWindows one, so we need
223 // to invert the mask each time we pass one/get one to/from Windows
224 extern HBITMAP
wxInvertMask(HBITMAP hbmpMask
, int w
= 0, int h
= 0);
226 // get (x, y) from DWORD - notice that HI/LOWORD can *not* be used because they
227 // will fail on system with multiple monitors where the coords may be negative
229 // these macros are standard now (Win98) but some older headers don't have them
231 #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
232 #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
233 #endif // GET_X_LPARAM
235 // get the current state of SHIFT/CTRL keys
236 inline bool wxIsShiftDown()
238 return (::GetKeyState(VK_SHIFT
) & 0x100) != 0;
241 inline bool wxIsCtrlDown()
243 return (::GetKeyState(VK_CONTROL
) & 0x100) != 0;
246 // ---------------------------------------------------------------------------
247 // small helper classes
248 // ---------------------------------------------------------------------------
250 // create an instance of this class and use it as the HDC for screen, will
251 // automatically release the DC going out of scope
255 ScreenHDC() { m_hdc
= GetDC(NULL
); }
256 ~ScreenHDC() { ReleaseDC(NULL
, m_hdc
); }
257 operator HDC() const { return m_hdc
; }
263 // ---------------------------------------------------------------------------
264 // macros to make casting between WXFOO and FOO a bit easier: the GetFoo()
265 // returns Foo cast to the Windows type for oruselves, while GetFooOf() takes
266 // an argument which should be a pointer or reference to the object of the
267 // corresponding class (this depends on the macro)
268 // ---------------------------------------------------------------------------
270 #define GetHwnd() ((HWND)GetHWND())
271 #define GetHwndOf(win) ((HWND)((win)->GetHWND()))
273 #define GetWinHwnd GetHwndOf
275 #define GetHdc() ((HDC)GetHDC())
276 #define GetHdcOf(dc) ((HDC)(dc).GetHDC())
278 #define GetHbitmap() ((HBITMAP)GetHBITMAP())
279 #define GetHbitmapOf(bmp) ((HBITMAP)(bmp).GetHBITMAP())
281 #define GetHicon() ((HICON)GetHICON())
282 #define GetHiconOf(icon) ((HICON)(icon).GetHICON())
284 #define GetHaccel() ((HACCEL)GetHACCEL())
285 #define GetHaccelOf(table) ((HACCEL)((table).GetHACCEL()))
287 #define GetHmenu() ((HMENU)GetHMenu())
288 #define GetHmenuOf(menu) ((HMENU)menu->GetHMenu())
290 #define GetHcursor() ((HCURSOR)GetHCURSOR())
291 #define GetHcursorOf(cursor) ((HCURSOR)(cursor).GetHCURSOR())
293 #define GetHfont() ((HFONT)GetHFONT())
294 #define GetHfontOf(font) ((HFONT)(font).GetHFONT())
298 // ---------------------------------------------------------------------------
300 // ---------------------------------------------------------------------------
302 WXDLLEXPORT_DATA(extern wxChar
*) wxBuffer
;
304 WXDLLEXPORT_DATA(extern HINSTANCE
) wxhInstance
;
306 // ---------------------------------------------------------------------------
308 // ---------------------------------------------------------------------------
312 WXDLLEXPORT HINSTANCE
wxGetInstance();
315 WXDLLEXPORT
void wxSetInstance(HINSTANCE hInst
);
320 extern HCURSOR
wxGetCurrentBusyCursor(); // from msw/utils.cpp
321 extern const wxCursor
*wxGetGlobalCursor(); // from msw/cursor.cpp
323 WXDLLEXPORT wxWindow
* wxFindWinFromHandle(WXHWND hWnd
);
325 WXDLLEXPORT
void wxGetCharSize(WXHWND wnd
, int *x
, int *y
, const wxFont
*the_font
);
326 WXDLLEXPORT
void wxFillLogFont(LOGFONT
*logFont
, const wxFont
*font
);
327 WXDLLEXPORT wxFont
wxCreateFontFromLogFont(const LOGFONT
*logFont
);
328 WXDLLEXPORT wxFontEncoding
wxGetFontEncFromCharSet(int charset
);
330 WXDLLEXPORT
void wxSliderEvent(WXHWND control
, WXWORD wParam
, WXWORD pos
);
331 WXDLLEXPORT
void wxScrollBarEvent(WXHWND hbar
, WXWORD wParam
, WXWORD pos
);
333 // Find maximum size of window/rectangle
334 WXDLLEXPORT
extern void wxFindMaxSize(WXHWND hwnd
, RECT
*rect
);
336 WXDLLEXPORT wxWindow
* wxFindControlFromHandle(WXHWND hWnd
);
337 WXDLLEXPORT
void wxAddControlHandle(WXHWND hWnd
, wxWindow
*item
);
339 // Safely get the window text (i.e. without using fixed size buffer)
340 WXDLLEXPORT
extern wxString
wxGetWindowText(WXHWND hWnd
);
342 // get the window class name
343 WXDLLEXPORT
extern wxString
wxGetWindowClass(WXHWND hWnd
);
345 // get the window id (should be unsigned, hence this is not wxWindowID which
346 // is, for mainly historical reasons, signed)
347 WXDLLEXPORT
extern WXWORD
wxGetWindowId(WXHWND hWnd
);
349 // Does this window style specify any border?
350 inline bool wxStyleHasBorder(long style
)
352 return (style
& (wxSIMPLE_BORDER
| wxRAISED_BORDER
|
353 wxSUNKEN_BORDER
| wxDOUBLE_BORDER
)) != 0;
356 // find the window for HWND which is part of some wxWindow, returns just the
357 // corresponding wxWindow for HWND which just is one
360 extern wxWindow
*wxGetWindowFromHWND(WXHWND hwnd
);