]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/private.h
native font dialog implementation for mac os x 10.2+
[wxWidgets.git] / include / wx / os2 / private.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: private.h
3 // Purpose: Private declarations: as this header is only included by
4 // wxWidgets 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 #define INCL_BASE
18 #define INCL_PM
19 #define INCL_GPI
20 #define INCL_WINSYS
21 #define INCL_SHLERRORS
22 #include <os2.h>
23 #if defined (__EMX__) && !defined(USE_OS2_TOOLKIT_HEADERS) && !defined(FCF_CLOSEBUTTON)
24 /* struct missing in "os2emx.h" - luckily FCF_CLOSEBUTTON was added in the
25 same version of os2emx.h as SPBCDATA type, so we can do the test above. */
26 typedef struct _SPBCDATA {
27 ULONG cbSize; /* Size of control block. */
28 ULONG ulTextLimit; /* Entryfield text limit. */
29 LONG lLowerLimit; /* Spin lower limit (numeric only). */
30 LONG lUpperLimit; /* Spin upper limit (numeric only). */
31 ULONG idMasterSpb; /* ID of the servant's master spinbutton. */
32 PVOID pHWXCtlData; /* Handwriting control data structure flag. */
33 } SPBCDATA;
34
35 typedef SPBCDATA *PSPBCDATA;
36 #endif
37
38 #include "wx/fontenc.h"
39
40 class WXDLLEXPORT wxFont;
41 class WXDLLEXPORT wxWindow;
42 class WXDLLEXPORT wxString;
43 class WXDLLEXPORT wxBitmap;
44
45 // ---------------------------------------------------------------------------
46 // private constants
47 // ---------------------------------------------------------------------------
48
49 // Conversion
50 static const double METRIC_CONVERSION_CONSTANT = 0.0393700787;
51
52 // Scaling factors for various unit conversions
53 static const double mm2inches = (METRIC_CONVERSION_CONSTANT);
54 static const double inches2mm = (1/METRIC_CONVERSION_CONSTANT);
55
56 static const double mm2twips = (METRIC_CONVERSION_CONSTANT*1440);
57 static const double twips2mm = (1/(METRIC_CONVERSION_CONSTANT*1440));
58
59 static const double mm2pt = (METRIC_CONVERSION_CONSTANT*72);
60 static const double pt2mm = (1/(METRIC_CONVERSION_CONSTANT*72));
61
62 //
63 // Constant strings for control names and classes
64 //
65
66 //
67 // Controls
68 //
69 WXDLLEXPORT_DATA(extern const wxChar*) wxButtonNameStr;
70 WXDLLEXPORT_DATA(extern const wxChar*) wxCanvasNameStr;
71 WXDLLEXPORT_DATA(extern const wxChar*) wxCheckBoxNameStr;
72 WXDLLEXPORT_DATA(extern const wxChar*) wxChoiceNameStr;
73 WXDLLEXPORT_DATA(extern const wxChar*) wxComboBoxNameStr;
74 WXDLLEXPORT_DATA(extern const wxChar*) wxDialogNameStr;
75 WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr;
76 WXDLLEXPORT_DATA(extern const wxChar*) wxGaugeNameStr;
77 WXDLLEXPORT_DATA(extern const wxChar*) wxStaticBoxNameStr;
78 WXDLLEXPORT_DATA(extern const wxChar*) wxListBoxNameStr;
79 WXDLLEXPORT_DATA(extern const wxChar*) wxStaticTextNameStr;
80 WXDLLEXPORT_DATA(extern const wxChar*) wxStaticBitmapNameStr;
81 WXDLLEXPORT_DATA(extern const wxChar*) wxMultiTextNameStr;
82 WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr;
83 WXDLLEXPORT_DATA(extern const wxChar*) wxRadioBoxNameStr;
84 WXDLLEXPORT_DATA(extern const wxChar*) wxRadioButtonNameStr;
85 WXDLLEXPORT_DATA(extern const wxChar*) wxBitmapRadioButtonNameStr;
86 WXDLLEXPORT_DATA(extern const wxChar*) wxScrollBarNameStr;
87 WXDLLEXPORT_DATA(extern const wxChar*) wxSliderNameStr;
88 WXDLLEXPORT_DATA(extern const wxChar*) wxStaticNameStr;
89 WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlWindowNameStr;
90 WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlNameStr;
91 WXDLLEXPORT_DATA(extern const wxChar*) wxVirtListBoxNameStr;
92 WXDLLEXPORT_DATA(extern const wxChar*) wxButtonBarNameStr;
93 WXDLLEXPORT_DATA(extern const wxChar*) wxEnhDialogNameStr;
94 WXDLLEXPORT_DATA(extern const wxChar*) wxToolBarNameStr;
95 WXDLLEXPORT_DATA(extern const wxChar*) wxStatusLineNameStr;
96 WXDLLEXPORT_DATA(extern const wxChar*) wxGetTextFromUserPromptStr;
97 WXDLLEXPORT_DATA(extern const wxChar*) wxMessageBoxCaptionStr;
98 WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorPromptStr;
99 WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorDefaultWildcardStr;
100 WXDLLEXPORT_DATA(extern const wxChar*) wxInternalErrorStr;
101 WXDLLEXPORT_DATA(extern const wxChar*) wxFatalErrorStr;
102 WXDLLEXPORT_DATA(extern const wxChar*) wxTreeCtrlNameStr;
103 WXDLLEXPORT_DATA(extern const wxChar*) wxDirDialogNameStr;
104 WXDLLEXPORT_DATA(extern const wxChar*) wxDirDialogDefaultFolderStr;
105
106 //
107 // Class names
108 //
109 WXDLLEXPORT_DATA(extern const wxChar*) wxFrameClassName;
110 WXDLLEXPORT_DATA(extern const wxChar*) wxFrameClassNameNoRedraw;
111 WXDLLEXPORT_DATA(extern const wxChar*) wxMDIFrameClassName;
112 WXDLLEXPORT_DATA(extern const wxChar*) wxMDIFrameClassNameNoRedraw;
113 WXDLLEXPORT_DATA(extern const wxChar*) wxMDIChildFrameClassName;
114 WXDLLEXPORT_DATA(extern const wxChar*) wxMDIChildFrameClassNameNoRedraw;
115 WXDLLEXPORT_DATA(extern const wxChar*) wxPanelClassName;
116 WXDLLEXPORT_DATA(extern const wxChar*) wxPanelClassNameNR;
117 WXDLLEXPORT_DATA(extern const wxChar*) wxCanvasClassName;
118 WXDLLEXPORT_DATA(extern const wxChar*) wxCanvasClassNameNR;
119
120 // ---------------------------------------------------------------------------
121 // standard icons from the resources
122 // ---------------------------------------------------------------------------
123
124 #ifdef __WXPM__
125
126 WXDLLEXPORT_DATA(extern HICON) wxSTD_FRAME_ICON;
127 WXDLLEXPORT_DATA(extern HICON) wxSTD_MDIPARENTFRAME_ICON;
128 WXDLLEXPORT_DATA(extern HICON) wxSTD_MDICHILDFRAME_ICON;
129 WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_FRAME_ICON;
130 WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_MDIPARENTFRAME_ICON;
131 WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_MDICHILDFRAME_ICON;
132 WXDLLEXPORT_DATA(extern HFONT) wxSTATUS_LINE_FONT;
133
134 #endif
135
136 // ---------------------------------------------------------------------------
137 // this defines a CASTWNDPROC macro which casts a pointer to the type of a
138 // window proc for PM.
139 // MPARAM is a void * but is really a 32-bit value
140 // ---------------------------------------------------------------------------
141
142 typedef MRESULT (APIENTRY * WndProcCast) (HWND, ULONG, MPARAM, MPARAM);
143 #define CASTWNDPROC (WndProcCast)
144
145 #if wxUSE_ITSY_BITSY
146 #define IBS_HORZCAPTION 0x4000L
147 #define IBS_VERTCAPTION 0x8000L
148
149 UINT APIENTRY ibGetCaptionSize( HWND hWnd ) ;
150 UINT APIENTRY ibSetCaptionSize( HWND hWnd, UINT nSize ) ;
151 MRESULT APIENTRY ibDefWindowProc( HWND hWnd, ULONG ulMsg, MPARAM wParam, MPARAM lParam ) ;
152 VOID APIENTRY ibAdjustWindowRect( HWND hWnd, LPRECT lprc ) ;
153 #endif // wxUSE_ITSY_BITSY
154
155 /*
156 * Decide what window classes we're going to use
157 * for this combination of CTl3D/FAFA settings
158 */
159
160 #define STATIC_CLASS _T("STATIC")
161 #define STATIC_FLAGS (SS_TEXT|DT_LEFT|SS_LEFT|WS_VISIBLE)
162 #define CHECK_CLASS _T("BUTTON")
163 #define CHECK_FLAGS (BS_AUTOCHECKBOX|WS_TABSTOP)
164 #define CHECK_IS_FAFA FALSE
165 #define RADIO_CLASS _T("BUTTON" )
166 #define RADIO_FLAGS (BS_AUTORADIOBUTTON|WS_VISIBLE)
167 #define RADIO_SIZE 20
168 #define RADIO_IS_FAFA FALSE
169 #define PURE_WINDOWS
170 /* PM has no group box button style
171 #define GROUP_CLASS "BUTTON"
172 #define GROUP_FLAGS (BS_GROUPBOX|WS_CHILD|WS_VISIBLE)
173 */
174
175 /*
176 #define BITCHECK_FLAGS (FB_BITMAP|FC_BUTTONDRAW|FC_DEFAULT|WS_VISIBLE)
177 #define BITRADIO_FLAGS (FC_BUTTONDRAW|FB_BITMAP|FC_RADIO|WS_CHILD|WS_VISIBLE)
178 */
179
180 // ---------------------------------------------------------------------------
181 // misc macros
182 // ---------------------------------------------------------------------------
183
184 #define MEANING_CHARACTER '0'
185 #define DEFAULT_ITEM_WIDTH 200
186 #define DEFAULT_ITEM_HEIGHT 80
187
188 // Scale font to get edit control height
189 #define EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy) (3*(cy)/2)
190
191 #ifdef __WXPM__
192
193 // Generic subclass proc, for panel item moving/sizing and intercept
194 // EDIT control VK_RETURN messages
195 extern LONG APIENTRY wxSubclassedGenericControlProc(WXHWND hWnd, WXDWORD message, WXWPARAM wParam, WXLPARAM lParam);
196
197 #endif
198
199 // ---------------------------------------------------------------------------
200 // constants which might miss from some compilers' headers
201 // ---------------------------------------------------------------------------
202
203 #if !defined(WS_EX_CLIENTEDGE)
204 #define WS_EX_CLIENTEDGE 0x00000200L
205 #endif
206
207 #ifndef ENDSESSION_LOGOFF
208 #define ENDSESSION_LOGOFF 0x80000000
209 #endif
210
211 // ---------------------------------------------------------------------------
212 // debug messages -- OS/2 has no native debug output system
213 // ---------------------------------------------------------------------------
214
215 // ---------------------------------------------------------------------------
216 // macros to make casting between WXFOO and FOO a bit easier: the GetFoo()
217 // returns Foo cast to the Windows type for oruselves, while GetFooOf() takes
218 // an argument which should be a pointer or reference to the object of the
219 // corresponding class (this depends on the macro)
220 // ---------------------------------------------------------------------------
221
222 #define GetHwnd() ((HWND)GetHWND())
223 #define GetHwndOf(win) ((HWND)((win)->GetHWND()))
224 // old name
225 #define GetWinHwnd GetHwndOf
226
227 #define GetHdc() ((HDC)GetHDC())
228 #define GetHdcOf(dc) ((HDC)(dc).GetHDC())
229
230 #define GetHbitmap() ((HBITMAP)GetHBITMAP())
231 #define GetHbitmapOf(bmp) ((HBITMAP)(bmp).GetHBITMAP())
232
233 #define GetHicon() ((HICON)GetHICON())
234 #define GetHiconOf(icon) ((HICON)(icon).GetHICON())
235
236 #define GetHaccel() ((HACCEL)GetHACCEL())
237 #define GetHaccelOf(table) ((HACCEL)((table).GetHACCEL()))
238
239 #define GetHmenu() ((HMENU)GetHMenu())
240 #define GetHmenuOf(menu) ((HMENU)menu->GetHMenu())
241
242 #define GetHcursor() ((HCURSOR)GetHCURSOR())
243 #define GetHcursorOf(cursor) ((HCURSOR)(cursor).GetHCURSOR())
244
245 #define GetHfont() ((HFONT)GetHFONT())
246 #define GetHfontOf(font) ((HFONT)(font).GetHFONT())
247
248 // OS/2 convention of the mask is opposed to the wxWidgets one, so we need
249 // to invert the mask each time we pass one/get one to/from Windows
250 extern HBITMAP wxInvertMask(HBITMAP hbmpMask, int w = 0, int h = 0);
251
252 // ---------------------------------------------------------------------------
253 // global data
254 // ---------------------------------------------------------------------------
255
256 // The MakeProcInstance version of the function wxSubclassedGenericControlProc
257 WXDLLEXPORT_DATA(extern int) wxGenericControlSubClassProc;
258 WXDLLEXPORT_DATA(extern wxChar*) wxBuffer;
259 WXDLLEXPORT_DATA(extern HINSTANCE) wxhInstance;
260
261 // ---------------------------------------------------------------------------
262 // global functions
263 // ---------------------------------------------------------------------------
264
265 extern "C"
266 {
267 WXDLLEXPORT HINSTANCE wxGetInstance();
268 }
269
270 WXDLLEXPORT void wxSetInstance(HINSTANCE hInst);
271
272 #include "wx/thread.h"
273 static inline MRESULT MySendMsg(HWND hwnd, ULONG ulMsgid,
274 MPARAM mpParam1, MPARAM mpParam2)
275 {
276 MRESULT vRes;
277 vRes = ::WinSendMsg(hwnd, ulMsgid, mpParam1, mpParam2);
278 #if wxUSE_THREADS
279 if (!wxThread::IsMain())
280 ::WinPostMsg(hwnd, ulMsgid, mpParam1, mpParam2);
281 #endif
282 return vRes;
283 }
284 #define WinSendMsg MySendMsg
285
286 #ifdef __WXPM__
287
288 WXDLLEXPORT void wxDrawBorder( HPS hPS
289 ,RECTL& rRect
290 ,WXDWORD dwStyle
291 );
292
293 WXDLLEXPORT wxWindow* wxFindWinFromHandle(WXHWND hWnd);
294
295 WXDLLEXPORT void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font);
296
297 WXDLLEXPORT void wxConvertVectorFontSize( FIXED fxPointSize
298 ,PFATTRS pFattrs
299 );
300 WXDLLEXPORT void wxFillLogFont( LOGFONT* pLogFont
301 ,PFACENAMEDESC pFaceName
302 ,HPS* phPS
303 ,bool* pbInternalPS
304 ,long* pflId
305 ,wxString& sFaceName
306 ,wxFont* pFont
307 );
308 WXDLLEXPORT wxFontEncoding wxGetFontEncFromCharSet(int nCharSet);
309 WXDLLEXPORT void wxOS2SelectMatchingFontByName( PFATTRS vFattrs
310 ,PFACENAMEDESC pFaceName
311 ,PFONTMETRICS pFM
312 ,int nNumFonts
313 ,const wxFont* pFont
314 );
315 WXDLLEXPORT wxFont wxCreateFontFromLogFont( LOGFONT* pLogFont
316 ,PFONTMETRICS pFM
317 ,PFACENAMEDESC pFace
318 );
319 WXDLLEXPORT int wxGpiStrcmp(char* s0, char* s1);
320
321 WXDLLEXPORT void wxSliderEvent(WXHWND control, WXWORD wParam, WXWORD pos);
322 WXDLLEXPORT void wxScrollBarEvent(WXHWND hbar, WXWORD wParam, WXWORD pos);
323
324 // Find maximum size of window/rectangle
325 WXDLLEXPORT extern void wxFindMaxSize(WXHWND hwnd, RECT *rect);
326
327 WXDLLEXPORT wxWindow* wxFindControlFromHandle(WXHWND hWnd);
328 WXDLLEXPORT void wxAddControlHandle(WXHWND hWnd, wxWindow *item);
329
330 // Safely get the window text (i.e. without using fixed size buffer)
331 WXDLLEXPORT extern wxString wxGetWindowText(WXHWND hWnd);
332
333 // get the window class name
334 WXDLLEXPORT extern wxString wxGetWindowClass(WXHWND hWnd);
335
336 // get the window id (should be unsigned, hence this is not wxWindowID which
337 // is, for mainly historical reasons, signed)
338 WXDLLEXPORT extern WXWORD wxGetWindowId(WXHWND hWnd);
339
340 // Convert a PM Error code to a string
341 WXDLLEXPORT extern wxString wxPMErrorToStr(ERRORID vError);
342
343 // Does this window style specify any border?
344 inline bool wxStyleHasBorder(long style)
345 {
346 return (style & (wxSIMPLE_BORDER | wxRAISED_BORDER |
347 wxSUNKEN_BORDER | wxDOUBLE_BORDER)) != 0;
348 }
349
350 inline RECTL wxGetWindowRect(HWND hWnd)
351 {
352 RECTL vRect;
353
354 ::WinQueryWindowRect(hWnd, &vRect);
355 return vRect;
356 } // end of wxGetWindowRect
357
358 WXDLLEXPORT extern void wxOS2SetFont( HWND hWnd
359 ,const wxFont& rFont
360 );
361
362
363 WXDLLEXPORT extern bool wxCheckWindowWndProc( WXHWND hWnd
364 ,WXFARPROC fnWndProc
365 );
366 WXDLLEXPORT extern wxBitmap wxDisableBitmap( const wxBitmap& rBmp
367 ,long lColor
368 );
369
370 #include "wx/colour.h"
371
372 WXDLLEXPORT extern COLORREF wxColourToRGB(const wxColour& rColor);
373
374 #endif // __WXPM__
375
376 #endif // _WX_PRIVATE_H_