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