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