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