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