]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/private.h
9729793909e71dfb7ce878edd50631d30d8c67ef
[wxWidgets.git] / include / wx / os2 / private.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/os2/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 // Copyright: (c) Julian Smart
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
12
13 #ifndef _WX_OS2_PRIVATE_H_
14 #define _WX_OS2_PRIVATE_H_
15
16 #define INCL_BASE
17 #define INCL_PM
18 #define INCL_GPI
19 #define INCL_WINSYS
20 #define INCL_GPIERRORS
21 #define INCL_DOS
22 #define INCL_DOSPROCESS
23 #define INCL_DOSERRORS
24 #define INCL_WIN
25 #define INCL_WINATOM
26 #define INCL_SHLERRORS
27
28 #include <os2.h>
29
30 #if wxONLY_WATCOM_EARLIER_THAN(1,4)
31 inline HATOMTBL APIENTRY WinQuerySystemAtomTable(VOID){return NULL;}
32 inline ULONG APIENTRY WinQueryAtomName(HATOMTBL,ATOM,PCSZ,ULONG){return 0;}
33 inline LONG APIENTRY GpiPointArc(HPS,PPOINTL){return GPI_ERROR;}
34 inline BOOL APIENTRY WinDrawPointer(HPS,LONG,LONG,HPOINTER,ULONG){return FALSE;}
35 inline HPOINTER APIENTRY WinCreatePointerIndirect(HWND,PPOINTERINFO){return NULLHANDLE;}
36 inline BOOL APIENTRY WinGetMaxPosition(HWND,PSWP){return FALSE;}
37 inline BOOL APIENTRY WinGetMinPosition(HWND,PSWP,PPOINTL){return FALSE;}
38 #endif
39
40 #if defined(__WATCOMC__) && defined(__WXMOTIF__)
41 #include <os2def.h>
42 #define I_NEED_OS2_H
43 #include <X11/Xmd.h>
44
45 // include this header from here for many of the GUI related code
46 #if wxUSE_GUI
47 extern "C" {
48 #include <Xm/VendorSP.h>
49 }
50 #endif
51
52 // provide Unix-like pipe()
53 #include <types.h>
54 #include <tcpustd.h>
55 #include <sys/time.h>
56 // Use ::DosCreatePipe or ::DosCreateNPipe under OS/2
57 // for more see http://posix2.sourceforge.net/guide.html
58 inline int pipe( int WXUNUSED(filedes)[2] )
59 {
60 wxFAIL_MSG(wxT("Implement first"));
61 return -1;
62 }
63 #endif
64
65 #if defined (__EMX__) && !defined(USE_OS2_TOOLKIT_HEADERS) && !defined(HAVE_SPBCDATA)
66
67 typedef struct _SPBCDATA {
68 ULONG cbSize; /* Size of control block. */
69 ULONG ulTextLimit; /* Entryfield text limit. */
70 LONG lLowerLimit; /* Spin lower limit (numeric only). */
71 LONG lUpperLimit; /* Spin upper limit (numeric only). */
72 ULONG idMasterSpb; /* ID of the servant's master spinbutton. */
73 PVOID pHWXCtlData; /* Handwriting control data structure flag. */
74 } SPBCDATA;
75
76 typedef SPBCDATA *PSPBCDATA;
77
78 #endif
79
80 #include "wx/dlimpexp.h"
81 #include "wx/fontenc.h"
82
83 class WXDLLIMPEXP_FWD_CORE wxFont;
84 class WXDLLIMPEXP_FWD_CORE wxWindow;
85 class WXDLLIMPEXP_FWD_BASE wxString;
86 class WXDLLIMPEXP_FWD_CORE wxBitmap;
87
88 // ---------------------------------------------------------------------------
89 // private constants
90 // ---------------------------------------------------------------------------
91
92 //
93 // Constant strings for control names and classes
94 //
95
96 //
97 // Controls
98 //
99 WXDLLIMPEXP_DATA_CORE(extern const char) wxButtonNameStr[];
100 WXDLLIMPEXP_DATA_CORE(extern const char) wxCheckBoxNameStr[];
101 WXDLLIMPEXP_DATA_CORE(extern const char) wxChoiceNameStr[];
102 WXDLLIMPEXP_DATA_CORE(extern const char) wxComboBoxNameStr[];
103 WXDLLIMPEXP_DATA_CORE(extern const char) wxDialogNameStr[];
104 WXDLLIMPEXP_DATA_CORE(extern const char) wxFrameNameStr[];
105 WXDLLIMPEXP_DATA_CORE(extern const char) wxGaugeNameStr[];
106 WXDLLIMPEXP_DATA_CORE(extern const char) wxStaticBoxNameStr[];
107 WXDLLIMPEXP_DATA_CORE(extern const char) wxListBoxNameStr[];
108 WXDLLIMPEXP_DATA_CORE(extern const char) wxStaticLineNameStr[];
109 WXDLLIMPEXP_DATA_CORE(extern const char) wxStaticTextNameStr[];
110 WXDLLIMPEXP_DATA_CORE(extern const char) wxStaticBitmapNameStr[];
111 WXDLLIMPEXP_DATA_CORE(extern const char) wxPanelNameStr[];
112 WXDLLIMPEXP_DATA_CORE(extern const char) wxRadioBoxNameStr[];
113 WXDLLIMPEXP_DATA_CORE(extern const char) wxRadioButtonNameStr[];
114 WXDLLIMPEXP_DATA_CORE(extern const char) wxBitmapRadioButtonNameStr[];
115 WXDLLIMPEXP_DATA_CORE(extern const char) wxScrollBarNameStr[];
116 WXDLLIMPEXP_DATA_CORE(extern const char) wxSliderNameStr[];
117 WXDLLIMPEXP_DATA_CORE(extern const char) wxTextCtrlNameStr[];
118 WXDLLIMPEXP_DATA_CORE(extern const char) wxToolBarNameStr[];
119 WXDLLIMPEXP_DATA_CORE(extern const char) wxStatusLineNameStr[];
120 WXDLLIMPEXP_DATA_CORE(extern const char) wxGetTextFromUserPromptStr[];
121 WXDLLIMPEXP_DATA_CORE(extern const char) wxMessageBoxCaptionStr[];
122 WXDLLIMPEXP_DATA_CORE(extern const char) wxFileSelectorPromptStr[];
123 WXDLLIMPEXP_DATA_CORE(extern const char) wxFileSelectorDefaultWildcardStr[];
124 WXDLLIMPEXP_DATA_CORE(extern const wxChar*) wxInternalErrorStr;
125 WXDLLIMPEXP_DATA_CORE(extern const wxChar*) wxFatalErrorStr;
126 WXDLLIMPEXP_DATA_CORE(extern const char) wxTreeCtrlNameStr[];
127 WXDLLIMPEXP_DATA_CORE(extern const char) wxDirDialogNameStr[];
128 WXDLLIMPEXP_DATA_CORE(extern const char) wxDirDialogDefaultFolderStr[];
129
130 //
131 // Class names
132 //
133 WXDLLIMPEXP_DATA_CORE(extern const wxChar*) wxFrameClassName;
134 WXDLLIMPEXP_DATA_CORE(extern const wxChar*) wxFrameClassNameNoRedraw;
135 WXDLLIMPEXP_DATA_CORE(extern const wxChar*) wxMDIFrameClassName;
136 WXDLLIMPEXP_DATA_CORE(extern const wxChar*) wxMDIFrameClassNameNoRedraw;
137 WXDLLIMPEXP_DATA_CORE(extern const wxChar*) wxMDIChildFrameClassName;
138 WXDLLIMPEXP_DATA_CORE(extern const wxChar*) wxMDIChildFrameClassNameNoRedraw;
139 WXDLLIMPEXP_DATA_CORE(extern const wxChar*) wxPanelClassName;
140 WXDLLIMPEXP_DATA_CORE(extern const wxChar*) wxPanelClassNameNR;
141 WXDLLIMPEXP_DATA_CORE(extern const wxChar*) wxCanvasClassName;
142 WXDLLIMPEXP_DATA_CORE(extern const wxChar*) wxCanvasClassNameNR;
143
144 // ---------------------------------------------------------------------------
145 // standard icons from the resources
146 // ---------------------------------------------------------------------------
147
148 #ifdef __WXPM__
149
150 WXDLLIMPEXP_DATA_CORE(extern HICON) wxSTD_FRAME_ICON;
151 WXDLLIMPEXP_DATA_CORE(extern HICON) wxSTD_MDIPARENTFRAME_ICON;
152 WXDLLIMPEXP_DATA_CORE(extern HICON) wxSTD_MDICHILDFRAME_ICON;
153 WXDLLIMPEXP_DATA_CORE(extern HICON) wxDEFAULT_FRAME_ICON;
154 WXDLLIMPEXP_DATA_CORE(extern HICON) wxDEFAULT_MDIPARENTFRAME_ICON;
155 WXDLLIMPEXP_DATA_CORE(extern HICON) wxDEFAULT_MDICHILDFRAME_ICON;
156 WXDLLIMPEXP_DATA_CORE(extern HFONT) wxSTATUS_LINE_FONT;
157
158 #endif
159
160 // ---------------------------------------------------------------------------
161 // this defines a CASTWNDPROC macro which casts a pointer to the type of a
162 // window proc for PM.
163 // MPARAM is a void * but is really a 32-bit value
164 // ---------------------------------------------------------------------------
165
166 typedef MRESULT (APIENTRY * WndProcCast) (HWND, ULONG, MPARAM, MPARAM);
167 #define CASTWNDPROC (WndProcCast)
168
169 /*
170 * Decide what window classes we're going to use
171 * for this combination of CTl3D/FAFA settings
172 */
173
174 #define STATIC_CLASS wxT("STATIC")
175 #define STATIC_FLAGS (SS_TEXT|DT_LEFT|SS_LEFT|WS_VISIBLE)
176 #define CHECK_CLASS wxT("BUTTON")
177 #define CHECK_FLAGS (BS_AUTOCHECKBOX|WS_TABSTOP)
178 #define CHECK_IS_FAFA FALSE
179 #define RADIO_CLASS wxT("BUTTON" )
180 #define RADIO_FLAGS (BS_AUTORADIOBUTTON|WS_VISIBLE)
181 #define RADIO_SIZE 20
182 #define RADIO_IS_FAFA FALSE
183 #define PURE_WINDOWS
184 /* PM has no group box button style
185 #define GROUP_CLASS "BUTTON"
186 #define GROUP_FLAGS (BS_GROUPBOX|WS_CHILD|WS_VISIBLE)
187 */
188
189 /*
190 #define BITCHECK_FLAGS (FB_BITMAP|FC_BUTTONDRAW|FC_DEFAULT|WS_VISIBLE)
191 #define BITRADIO_FLAGS (FC_BUTTONDRAW|FB_BITMAP|FC_RADIO|WS_CHILD|WS_VISIBLE)
192 */
193
194 // ---------------------------------------------------------------------------
195 // misc macros
196 // ---------------------------------------------------------------------------
197
198 #define MEANING_CHARACTER '0'
199 #define DEFAULT_ITEM_WIDTH 200
200 #define DEFAULT_ITEM_HEIGHT 80
201
202 // Scale font to get edit control height
203 #define EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy) (3*(cy)/2)
204
205 #ifdef __WXPM__
206
207 // Generic subclass proc, for panel item moving/sizing and intercept
208 // EDIT control VK_RETURN messages
209 extern LONG APIENTRY wxSubclassedGenericControlProc(WXHWND hWnd, WXDWORD message, WXWPARAM wParam, WXLPARAM lParam);
210
211 #endif
212
213 // ---------------------------------------------------------------------------
214 // constants which might miss from some compilers' headers
215 // ---------------------------------------------------------------------------
216
217 #if !defined(WS_EX_CLIENTEDGE)
218 #define WS_EX_CLIENTEDGE 0x00000200L
219 #endif
220
221 #ifndef ENDSESSION_LOGOFF
222 #define ENDSESSION_LOGOFF 0x80000000
223 #endif
224
225 #ifndef PMERR_INVALID_PARM
226 #define PMERR_INVALID_PARM 0x1303
227 #endif
228
229 #ifndef PMERR_INVALID_PARAMETERS
230 #define PMERR_INVALID_PARAMETERS 0x1208
231 #endif
232
233 #ifndef BOOKERR_INVALID_PARAMETERS
234 #define BOOKERR_INVALID_PARAMETERS -1
235 #endif
236
237 #ifndef DLGC_ENTRYFIELD
238 #define DLGC_ENTRYFIELD 0x0001
239 #endif
240
241 #ifndef DLGC_BUTTON
242 #define DLGC_BUTTON 0x0002
243 #endif
244
245 #ifndef DLGC_MLE
246 #define DLGC_MLE 0x0400
247 #endif
248
249 #ifndef DP_NORMAL
250 #define DP_NORMAL 0
251 #endif
252
253 // ---------------------------------------------------------------------------
254 // debug messages -- OS/2 has no native debug output system
255 // ---------------------------------------------------------------------------
256
257 // ---------------------------------------------------------------------------
258 // macros to make casting between WXFOO and FOO a bit easier: the GetFoo()
259 // returns Foo cast to the Windows type for oruselves, while GetFooOf() takes
260 // an argument which should be a pointer or reference to the object of the
261 // corresponding class (this depends on the macro)
262 // ---------------------------------------------------------------------------
263
264 #define GetHwnd() ((HWND)GetHWND())
265 #define GetHwndOf(win) ((HWND)((win)->GetHWND()))
266 // old name
267 #define GetWinHwnd GetHwndOf
268
269 #define GetHdc() ((HDC)GetHDC())
270 #define GetHdcOf(dc) ((HDC)(dc).GetHDC())
271
272 #define GetHbitmap() ((HBITMAP)GetHBITMAP())
273 #define GetHbitmapOf(bmp) ((HBITMAP)(bmp).GetHBITMAP())
274
275 #define GetHicon() ((HICON)GetHICON())
276 #define GetHiconOf(icon) ((HICON)(icon).GetHICON())
277
278 #define GetHaccel() ((HACCEL)GetHACCEL())
279 #define GetHaccelOf(table) ((HACCEL)((table).GetHACCEL()))
280
281 #define GetHmenu() ((HMENU)GetHMenu())
282 #define GetHmenuOf(menu) ((HMENU)menu->GetHMenu())
283
284 #define GetHcursor() ((HCURSOR)GetHCURSOR())
285 #define GetHcursorOf(cursor) ((HCURSOR)(cursor).GetHCURSOR())
286
287 #define GetHfont() ((HFONT)GetHFONT())
288 #define GetHfontOf(font) ((HFONT)(font).GetHFONT())
289
290 // OS/2 convention of the mask is opposed to the wxWidgets one, so we need
291 // to invert the mask each time we pass one/get one to/from Windows
292 extern HBITMAP wxInvertMask(HBITMAP hbmpMask, int w = 0, int h = 0);
293 extern HBITMAP wxCopyBmp(HBITMAP hbmp, bool flip=false, int w=0, int h=0);
294
295 // ---------------------------------------------------------------------------
296 // global data
297 // ---------------------------------------------------------------------------
298
299 #ifdef __WXPM__
300 // The MakeProcInstance version of the function wxSubclassedGenericControlProc
301 WXDLLIMPEXP_DATA_CORE(extern int) wxGenericControlSubClassProc;
302 WXDLLIMPEXP_DATA_CORE(extern wxChar*) wxBuffer;
303 WXDLLIMPEXP_DATA_CORE(extern HINSTANCE) wxhInstance;
304 #endif
305
306 // ---------------------------------------------------------------------------
307 // global functions
308 // ---------------------------------------------------------------------------
309
310 #ifdef __WXPM__
311 extern "C"
312 {
313 WXDLLIMPEXP_CORE HINSTANCE wxGetInstance();
314 }
315
316 WXDLLIMPEXP_CORE void wxSetInstance(HINSTANCE hInst);
317 #endif
318
319 #include "wx/thread.h"
320 static inline MRESULT MySendMsg(HWND hwnd, ULONG ulMsgid,
321 MPARAM mpParam1, MPARAM mpParam2)
322 {
323 MRESULT vRes;
324 vRes = ::WinSendMsg(hwnd, ulMsgid, mpParam1, mpParam2);
325 #if wxUSE_THREADS
326 if (!wxThread::IsMain())
327 ::WinPostMsg(hwnd, ulMsgid, mpParam1, mpParam2);
328 #endif
329 return vRes;
330 }
331 #define WinSendMsg MySendMsg
332
333 #ifdef __WXPM__
334
335 WXDLLIMPEXP_CORE void wxDrawBorder( HPS hPS
336 ,RECTL& rRect
337 ,WXDWORD dwStyle
338 );
339
340 WXDLLIMPEXP_CORE wxWindow* wxFindWinFromHandle(WXHWND hWnd);
341
342 WXDLLIMPEXP_CORE void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font);
343
344 WXDLLIMPEXP_CORE void wxConvertVectorFontSize( FIXED fxPointSize
345 ,PFATTRS pFattrs
346 );
347 WXDLLIMPEXP_CORE void wxFillLogFont( LOGFONT* pLogFont
348 ,PFACENAMEDESC pFaceName
349 ,HPS* phPS
350 ,bool* pbInternalPS
351 ,long* pflId
352 ,wxString& sFaceName
353 ,wxFont* pFont
354 );
355 WXDLLIMPEXP_CORE wxFontEncoding wxGetFontEncFromCharSet(int nCharSet);
356 WXDLLIMPEXP_CORE void wxOS2SelectMatchingFontByName( PFATTRS vFattrs
357 ,PFACENAMEDESC pFaceName
358 ,PFONTMETRICS pFM
359 ,int nNumFonts
360 ,const wxFont* pFont
361 );
362 WXDLLIMPEXP_CORE wxFont wxCreateFontFromLogFont( LOGFONT* pLogFont
363 ,PFONTMETRICS pFM
364 ,PFACENAMEDESC pFace
365 );
366 WXDLLIMPEXP_CORE int wxGpiStrcmp(wxChar* s0, wxChar* s1);
367
368 WXDLLIMPEXP_CORE void wxSliderEvent(WXHWND control, WXWORD wParam, WXWORD pos);
369 WXDLLIMPEXP_CORE void wxScrollBarEvent(WXHWND hbar, WXWORD wParam, WXWORD pos);
370
371 // Find maximum size of window/rectangle
372 WXDLLIMPEXP_CORE extern void wxFindMaxSize(WXHWND hwnd, RECT *rect);
373
374 WXDLLIMPEXP_CORE wxWindow* wxFindControlFromHandle(WXHWND hWnd);
375 WXDLLIMPEXP_CORE void wxAddControlHandle(WXHWND hWnd, wxWindow *item);
376
377 // Safely get the window text (i.e. without using fixed size buffer)
378 WXDLLIMPEXP_CORE extern wxString wxGetWindowText(WXHWND hWnd);
379
380 // get the window class name
381 WXDLLIMPEXP_CORE extern wxString wxGetWindowClass(WXHWND hWnd);
382
383 // get the window id (should be unsigned, hence this is not wxWindowID which
384 // is, for mainly historical reasons, signed)
385 WXDLLIMPEXP_CORE extern WXWORD wxGetWindowId(WXHWND hWnd);
386
387 // Convert a PM Error code to a string
388 WXDLLIMPEXP_BASE extern wxString wxPMErrorToStr(ERRORID vError);
389
390 // Does this window style specify any border?
391 inline bool wxStyleHasBorder(long style)
392 {
393 return (style & (wxSIMPLE_BORDER | wxRAISED_BORDER |
394 wxSUNKEN_BORDER | wxDOUBLE_BORDER)) != 0;
395 }
396
397 inline RECTL wxGetWindowRect(HWND hWnd)
398 {
399 RECTL vRect;
400
401 ::WinQueryWindowRect(hWnd, &vRect);
402 return vRect;
403 } // end of wxGetWindowRect
404
405 WXDLLIMPEXP_CORE extern void wxOS2SetFont( HWND hWnd
406 ,const wxFont& rFont
407 );
408
409
410 WXDLLIMPEXP_CORE extern bool wxCheckWindowWndProc( WXHWND hWnd
411 ,WXFARPROC fnWndProc
412 );
413 WXDLLIMPEXP_CORE extern wxBitmap wxDisableBitmap( const wxBitmap& rBmp
414 ,long lColor
415 );
416 #if wxUSE_GUI
417 class wxColour;
418 WXDLLIMPEXP_CORE extern COLORREF wxColourToRGB(const wxColour& rColor);
419 #endif
420
421 #endif // __WXPM__
422
423 #endif // _WX_OS2_PRIVATE_H_