]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/msw/private.h
Undoing my last checkin so wxGTK compiles correctly under unix.
[wxWidgets.git] / include / wx / msw / private.h
... / ...
CommitLineData
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
22class WXDLLEXPORT wxFont;
23class WXDLLEXPORT wxWindow;
24
25// ---------------------------------------------------------------------------
26// private constants
27// ---------------------------------------------------------------------------
28
29// Conversion
30static const double METRIC_CONVERSION_CONSTANT = 0.0393700787;
31
32// Scaling factors for various unit conversions
33static const double mm2inches = (METRIC_CONVERSION_CONSTANT);
34static const double inches2mm = (1/METRIC_CONVERSION_CONSTANT);
35
36static const double mm2twips = (METRIC_CONVERSION_CONSTANT*1440);
37static const double twips2mm = (1/(METRIC_CONVERSION_CONSTANT*1440));
38
39static const double mm2pt = (METRIC_CONVERSION_CONSTANT*72);
40static const double pt2mm = (1/(METRIC_CONVERSION_CONSTANT*72));
41
42// ---------------------------------------------------------------------------
43// standard icons from the resources
44// ---------------------------------------------------------------------------
45
46WXDLLEXPORT_DATA(extern HICON) wxSTD_FRAME_ICON;
47WXDLLEXPORT_DATA(extern HICON) wxSTD_MDIPARENTFRAME_ICON;
48WXDLLEXPORT_DATA(extern HICON) wxSTD_MDICHILDFRAME_ICON;
49WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_FRAME_ICON;
50WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_MDIPARENTFRAME_ICON;
51WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_MDICHILDFRAME_ICON;
52WXDLLEXPORT_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 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
64#if defined(__GNUWIN32__) && !defined(wxUSE_NORLANDER_HEADERS)
65# define CASTWNDPROC (long unsigned)
66#else
67# ifdef __BORLANDC__
68
69# ifdef __WIN32__
70# define CASTWNDPROC
71# else
72 typedef int (pascal * WndProcCast) ();
73# define CASTWNDPROC (WndProcCast)
74# endif
75
76# else
77# if defined (__WIN32__) && defined(STRICT)
78 typedef long (_stdcall * WndProcCast) (HWND, unsigned int, unsigned int, long);
79# define CASTWNDPROC (WndProcCast)
80# elif defined(__WIN16__)
81# ifdef __BORLANDC__
82 typedef int (pascal * WndProcCast) ();
83# define CASTWNDPROC (WndProcCast)
84# else
85# if defined(__VISUALC__) && defined(STRICT)
86# define CASTWNDPROC (WNDPROC)
87# else
88 typedef int (PASCAL * WndProcCast) ();
89# define CASTWNDPROC (WndProcCast)
90# endif
91# endif
92# else
93# define CASTWNDPROC
94# endif
95# endif
96#endif
97
98// ---------------------------------------------------------------------------
99// some stuff for old Windows versions (FIXME: what does it do here??)
100// ---------------------------------------------------------------------------
101
102#if !defined(APIENTRY) // NT defines APIENTRY, 3.x not
103 #define APIENTRY FAR PASCAL
104#endif
105
106#ifdef __WIN32__
107 #define _EXPORT
108#else
109 #define _EXPORT _export
110#endif
111
112#ifndef __WIN32__
113 typedef signed short int SHORT;
114#endif
115
116#if !defined(__WIN32__) // 3.x uses FARPROC for dialogs
117#ifndef STRICT
118 #define DLGPROC FARPROC
119#endif
120#endif
121
122#if wxUSE_PENWIN
123 WXDLLEXPORT void wxRegisterPenWin();
124 WXDLLEXPORT void wxCleanUpPenWin();
125 WXDLLEXPORT void wxEnablePenAppHooks (bool hook);
126#endif // wxUSE_PENWIN
127
128#if wxUSE_ITSY_BITSY
129 #define IBS_HORZCAPTION 0x4000L
130 #define IBS_VERTCAPTION 0x8000L
131
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
137
138#if wxUSE_CTL3D
139 #include "wx/msw/ctl3d/ctl3d.h"
140#endif // wxUSE_CTL3D
141
142/*
143 * Decide what window classes we're going to use
144 * for this combination of CTl3D/FAFA settings
145 */
146
147#define STATIC_CLASS wxT("STATIC")
148#define STATIC_FLAGS (SS_LEFT|WS_CHILD|WS_VISIBLE)
149#define CHECK_CLASS wxT("BUTTON")
150#define CHECK_FLAGS (BS_AUTOCHECKBOX|WS_TABSTOP|WS_CHILD)
151#define CHECK_IS_FAFA FALSE
152#define RADIO_CLASS wxT("BUTTON")
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
157#define GROUP_CLASS wxT("BUTTON")
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
165// ---------------------------------------------------------------------------
166// misc macros
167// ---------------------------------------------------------------------------
168
169#define MEANING_CHARACTER '0'
170#define DEFAULT_ITEM_WIDTH 200
171#define DEFAULT_ITEM_HEIGHT 80
172
173// Scale font to get edit control height
174#define EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy) (3*(cy)/2)
175
176// Generic subclass proc, for panel item moving/sizing and intercept
177// EDIT control VK_RETURN messages
178extern LONG APIENTRY _EXPORT
179 wxSubclassedGenericControlProc(WXHWND hWnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
180
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
213// ---------------------------------------------------------------------------
214// useful macros and functions
215// ---------------------------------------------------------------------------
216
217// a wrapper macro for ZeroMemory()
218#ifdef __WIN32__
219#define wxZeroMemory(obj) ::ZeroMemory(&obj, sizeof(obj))
220#else
221#define wxZeroMemory(obj) memset((void*) & obj, 0, sizeof(obj))
222#endif
223
224// make conversion from wxColour and COLORREF a bit less painful
225inline COLORREF wxColourToRGB(const wxColour& c)
226{
227 return RGB(c.Red(), c.Green(), c.Blue());
228}
229
230inline void wxRGBToColour(wxColour& c, COLORREF rgb)
231{
232 c.Set(GetRValue(rgb), GetGValue(rgb), GetBValue(rgb));
233}
234
235// ---------------------------------------------------------------------------
236// macros to make casting between WXFOO and FOO a bit easier: the GetFoo()
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)
240// ---------------------------------------------------------------------------
241
242#define GetHwnd() ((HWND)GetHWND())
243#define GetHwndOf(win) ((HWND)((win)->GetHWND()))
244// old name
245#define GetWinHwnd GetHwndOf
246
247#define GetHdc() ((HDC)GetHDC())
248#define GetHdcOf(dc) ((HDC)(dc).GetHDC())
249
250#define GetHbitmap() ((HBITMAP)GetHBITMAP())
251#define GetHbitmapOf(bmp) ((HBITMAP)(bmp).GetHBITMAP())
252
253#define GetHicon() ((HICON)GetHICON())
254#define GetHiconOf(icon) ((HICON)(icon).GetHICON())
255
256#define GetHaccel() ((HACCEL)GetHACCEL())
257#define GetHaccelOf(table) ((HACCEL)((table).GetHACCEL()))
258
259#define GetHmenu() ((HMENU)GetHMenu())
260#define GetHmenuOf(menu) ((HMENU)menu->GetHMenu())
261
262// ---------------------------------------------------------------------------
263// global data
264// ---------------------------------------------------------------------------
265
266// The MakeProcInstance version of the function wxSubclassedGenericControlProc
267WXDLLEXPORT_DATA(extern FARPROC) wxGenericControlSubClassProc;
268WXDLLEXPORT_DATA(extern wxChar*) wxBuffer;
269WXDLLEXPORT_DATA(extern HINSTANCE) wxhInstance;
270
271// ---------------------------------------------------------------------------
272// global functions
273// ---------------------------------------------------------------------------
274
275extern "C"
276{
277WXDLLEXPORT HINSTANCE wxGetInstance();
278}
279
280WXDLLEXPORT void wxSetInstance(HINSTANCE hInst);
281
282WXDLLEXPORT wxWindow* wxFindWinFromHandle(WXHWND hWnd);
283
284WXDLLEXPORT void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font);
285WXDLLEXPORT void wxFillLogFont(LOGFONT *logFont, const wxFont *font);
286WXDLLEXPORT wxFont wxCreateFontFromLogFont(const LOGFONT *logFont);
287
288WXDLLEXPORT void wxSliderEvent(WXHWND control, WXWORD wParam, WXWORD pos);
289WXDLLEXPORT void wxScrollBarEvent(WXHWND hbar, WXWORD wParam, WXWORD pos);
290
291// Find maximum size of window/rectangle
292WXDLLEXPORT extern void wxFindMaxSize(WXHWND hwnd, RECT *rect);
293
294WXDLLEXPORT wxWindow* wxFindControlFromHandle(WXHWND hWnd);
295WXDLLEXPORT void wxAddControlHandle(WXHWND hWnd, wxWindow *item);
296
297// Safely get the window text (i.e. without using fixed size buffer)
298WXDLLEXPORT extern wxString wxGetWindowText(WXHWND hWnd);
299
300// get the window class name
301WXDLLEXPORT extern wxString wxGetWindowClass(WXHWND hWnd);
302
303// get the window id (should be unsigned, hence this is not wxWindowID which
304// is, for mainly historical reasons, signed)
305WXDLLEXPORT extern WXWORD wxGetWindowId(WXHWND hWnd);
306
307// Does this window style specify any border?
308inline bool wxStyleHasBorder(long style)
309{
310 return (style & (wxSIMPLE_BORDER | wxRAISED_BORDER |
311 wxSUNKEN_BORDER | wxDOUBLE_BORDER)) != 0;
312}
313
314#endif
315 // _WX_PRIVATE_H_