]>
Commit | Line | Data |
---|---|---|
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 | #include <os2.h> | |
24 | ||
25 | #if defined(__WATCOMC__) && defined(__WXMOTIF__) | |
26 | #include <os2def.h> | |
27 | #define I_NEED_OS2_H | |
28 | #include <X11/Xmd.h> | |
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 | } | |
35 | #endif | |
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; | |
47 | } | |
48 | #endif | |
49 | ||
50 | #if defined (__EMX__) && !defined(USE_OS2_TOOLKIT_HEADERS) && !defined(HAVE_SPBCDATA) | |
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 | ||
63 | #endif | |
64 | ||
65 | #include "wx/dlimpexp.h" | |
66 | #include "wx/fontenc.h" | |
67 | ||
68 | class WXDLLEXPORT wxFont; | |
69 | class WXDLLEXPORT wxWindow; | |
70 | class WXDLLEXPORT wxString; | |
71 | class WXDLLEXPORT wxBitmap; | |
72 | ||
73 | // --------------------------------------------------------------------------- | |
74 | // private constants | |
75 | // --------------------------------------------------------------------------- | |
76 | ||
77 | // | |
78 | // Constant strings for control names and classes | |
79 | // | |
80 | ||
81 | // | |
82 | // Controls | |
83 | // | |
84 | WXDLLEXPORT_DATA(extern const wxChar*) wxButtonNameStr; | |
85 | WXDLLEXPORT_DATA(extern const wxChar*) wxCanvasNameStr; | |
86 | WXDLLEXPORT_DATA(extern const wxChar*) wxCheckBoxNameStr; | |
87 | WXDLLEXPORT_DATA(extern const wxChar*) wxChoiceNameStr; | |
88 | WXDLLEXPORT_DATA(extern const wxChar*) wxComboBoxNameStr; | |
89 | WXDLLEXPORT_DATA(extern const wxChar*) wxDialogNameStr; | |
90 | WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr; | |
91 | WXDLLEXPORT_DATA(extern const wxChar*) wxGaugeNameStr; | |
92 | WXDLLEXPORT_DATA(extern const wxChar*) wxStaticBoxNameStr; | |
93 | WXDLLEXPORT_DATA(extern const wxChar*) wxListBoxNameStr; | |
94 | WXDLLEXPORT_DATA(extern const wxChar*) wxStaticTextNameStr; | |
95 | WXDLLEXPORT_DATA(extern const wxChar*) wxStaticBitmapNameStr; | |
96 | WXDLLEXPORT_DATA(extern const wxChar*) wxMultiTextNameStr; | |
97 | WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr; | |
98 | WXDLLEXPORT_DATA(extern const wxChar*) wxRadioBoxNameStr; | |
99 | WXDLLEXPORT_DATA(extern const wxChar*) wxRadioButtonNameStr; | |
100 | WXDLLEXPORT_DATA(extern const wxChar*) wxBitmapRadioButtonNameStr; | |
101 | WXDLLEXPORT_DATA(extern const wxChar*) wxScrollBarNameStr; | |
102 | WXDLLEXPORT_DATA(extern const wxChar*) wxSliderNameStr; | |
103 | WXDLLEXPORT_DATA(extern const wxChar*) wxStaticNameStr; | |
104 | WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlWindowNameStr; | |
105 | WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlNameStr; | |
106 | WXDLLEXPORT_DATA(extern const wxChar*) wxVirtListBoxNameStr; | |
107 | WXDLLEXPORT_DATA(extern const wxChar*) wxButtonBarNameStr; | |
108 | WXDLLEXPORT_DATA(extern const wxChar*) wxEnhDialogNameStr; | |
109 | WXDLLEXPORT_DATA(extern const wxChar*) wxToolBarNameStr; | |
110 | WXDLLEXPORT_DATA(extern const wxChar*) wxStatusLineNameStr; | |
111 | WXDLLEXPORT_DATA(extern const wxChar*) wxGetTextFromUserPromptStr; | |
112 | WXDLLEXPORT_DATA(extern const wxChar*) wxMessageBoxCaptionStr; | |
113 | WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorPromptStr; | |
114 | WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorDefaultWildcardStr; | |
115 | WXDLLEXPORT_DATA(extern const wxChar*) wxInternalErrorStr; | |
116 | WXDLLEXPORT_DATA(extern const wxChar*) wxFatalErrorStr; | |
117 | WXDLLEXPORT_DATA(extern const wxChar*) wxTreeCtrlNameStr; | |
118 | WXDLLEXPORT_DATA(extern const wxChar*) wxDirDialogNameStr; | |
119 | WXDLLEXPORT_DATA(extern const wxChar*) wxDirDialogDefaultFolderStr; | |
120 | ||
121 | // | |
122 | // Class names | |
123 | // | |
124 | WXDLLEXPORT_DATA(extern const wxChar*) wxFrameClassName; | |
125 | WXDLLEXPORT_DATA(extern const wxChar*) wxFrameClassNameNoRedraw; | |
126 | WXDLLEXPORT_DATA(extern const wxChar*) wxMDIFrameClassName; | |
127 | WXDLLEXPORT_DATA(extern const wxChar*) wxMDIFrameClassNameNoRedraw; | |
128 | WXDLLEXPORT_DATA(extern const wxChar*) wxMDIChildFrameClassName; | |
129 | WXDLLEXPORT_DATA(extern const wxChar*) wxMDIChildFrameClassNameNoRedraw; | |
130 | WXDLLEXPORT_DATA(extern const wxChar*) wxPanelClassName; | |
131 | WXDLLEXPORT_DATA(extern const wxChar*) wxPanelClassNameNR; | |
132 | WXDLLEXPORT_DATA(extern const wxChar*) wxCanvasClassName; | |
133 | WXDLLEXPORT_DATA(extern const wxChar*) wxCanvasClassNameNR; | |
134 | ||
135 | // --------------------------------------------------------------------------- | |
136 | // standard icons from the resources | |
137 | // --------------------------------------------------------------------------- | |
138 | ||
139 | #ifdef __WXPM__ | |
140 | ||
141 | WXDLLEXPORT_DATA(extern HICON) wxSTD_FRAME_ICON; | |
142 | WXDLLEXPORT_DATA(extern HICON) wxSTD_MDIPARENTFRAME_ICON; | |
143 | WXDLLEXPORT_DATA(extern HICON) wxSTD_MDICHILDFRAME_ICON; | |
144 | WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_FRAME_ICON; | |
145 | WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_MDIPARENTFRAME_ICON; | |
146 | WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_MDICHILDFRAME_ICON; | |
147 | WXDLLEXPORT_DATA(extern HFONT) wxSTATUS_LINE_FONT; | |
148 | ||
149 | #endif | |
150 | ||
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 | ||
157 | typedef MRESULT (APIENTRY * WndProcCast) (HWND, ULONG, MPARAM, MPARAM); | |
158 | #define CASTWNDPROC (WndProcCast) | |
159 | ||
160 | /* | |
161 | * Decide what window classes we're going to use | |
162 | * for this combination of CTl3D/FAFA settings | |
163 | */ | |
164 | ||
165 | #define STATIC_CLASS _T("STATIC") | |
166 | #define STATIC_FLAGS (SS_TEXT|DT_LEFT|SS_LEFT|WS_VISIBLE) | |
167 | #define CHECK_CLASS _T("BUTTON") | |
168 | #define CHECK_FLAGS (BS_AUTOCHECKBOX|WS_TABSTOP) | |
169 | #define CHECK_IS_FAFA FALSE | |
170 | #define RADIO_CLASS _T("BUTTON" ) | |
171 | #define RADIO_FLAGS (BS_AUTORADIOBUTTON|WS_VISIBLE) | |
172 | #define RADIO_SIZE 20 | |
173 | #define RADIO_IS_FAFA FALSE | |
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 | ||
196 | #ifdef __WXPM__ | |
197 | ||
198 | // Generic subclass proc, for panel item moving/sizing and intercept | |
199 | // EDIT control VK_RETURN messages | |
200 | extern LONG APIENTRY wxSubclassedGenericControlProc(WXHWND hWnd, WXDWORD message, WXWPARAM wParam, WXLPARAM lParam); | |
201 | ||
202 | #endif | |
203 | ||
204 | // --------------------------------------------------------------------------- | |
205 | // constants which might miss from some compilers' headers | |
206 | // --------------------------------------------------------------------------- | |
207 | ||
208 | #if !defined(WS_EX_CLIENTEDGE) | |
209 | #define WS_EX_CLIENTEDGE 0x00000200L | |
210 | #endif | |
211 | ||
212 | #ifndef ENDSESSION_LOGOFF | |
213 | #define ENDSESSION_LOGOFF 0x80000000 | |
214 | #endif | |
215 | ||
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 | ||
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 | ||
263 | #define GetHbitmap() ((HBITMAP)GetHBITMAP()) | |
264 | #define GetHbitmapOf(bmp) ((HBITMAP)(bmp).GetHBITMAP()) | |
265 | ||
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 | ||
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 | ||
281 | // OS/2 convention of the mask is opposed to the wxWidgets one, so we need | |
282 | // to invert the mask each time we pass one/get one to/from Windows | |
283 | extern HBITMAP wxInvertMask(HBITMAP hbmpMask, int w = 0, int h = 0); | |
284 | ||
285 | // --------------------------------------------------------------------------- | |
286 | // global data | |
287 | // --------------------------------------------------------------------------- | |
288 | ||
289 | #ifdef __WXOS2__ | |
290 | // The MakeProcInstance version of the function wxSubclassedGenericControlProc | |
291 | WXDLLEXPORT_DATA(extern int) wxGenericControlSubClassProc; | |
292 | WXDLLEXPORT_DATA(extern wxChar*) wxBuffer; | |
293 | WXDLLEXPORT_DATA(extern HINSTANCE) wxhInstance; | |
294 | #endif | |
295 | ||
296 | // --------------------------------------------------------------------------- | |
297 | // global functions | |
298 | // --------------------------------------------------------------------------- | |
299 | ||
300 | #ifdef __WXOS2__ | |
301 | extern "C" | |
302 | { | |
303 | WXDLLEXPORT HINSTANCE wxGetInstance(); | |
304 | } | |
305 | ||
306 | WXDLLEXPORT void wxSetInstance(HINSTANCE hInst); | |
307 | #endif | |
308 | ||
309 | #include "wx/thread.h" | |
310 | static 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 | ||
323 | #ifdef __WXPM__ | |
324 | ||
325 | WXDLLEXPORT void wxDrawBorder( HPS hPS | |
326 | ,RECTL& rRect | |
327 | ,WXDWORD dwStyle | |
328 | ); | |
329 | ||
330 | WXDLLEXPORT wxWindow* wxFindWinFromHandle(WXHWND hWnd); | |
331 | ||
332 | WXDLLEXPORT void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font); | |
333 | ||
334 | WXDLLEXPORT void wxConvertVectorFontSize( FIXED fxPointSize | |
335 | ,PFATTRS pFattrs | |
336 | ); | |
337 | WXDLLEXPORT void wxFillLogFont( LOGFONT* pLogFont | |
338 | ,PFACENAMEDESC pFaceName | |
339 | ,HPS* phPS | |
340 | ,bool* pbInternalPS | |
341 | ,long* pflId | |
342 | ,wxString& sFaceName | |
343 | ,wxFont* pFont | |
344 | ); | |
345 | WXDLLEXPORT wxFontEncoding wxGetFontEncFromCharSet(int nCharSet); | |
346 | WXDLLEXPORT void wxOS2SelectMatchingFontByName( PFATTRS vFattrs | |
347 | ,PFACENAMEDESC pFaceName | |
348 | ,PFONTMETRICS pFM | |
349 | ,int nNumFonts | |
350 | ,const wxFont* pFont | |
351 | ); | |
352 | WXDLLEXPORT wxFont wxCreateFontFromLogFont( LOGFONT* pLogFont | |
353 | ,PFONTMETRICS pFM | |
354 | ,PFACENAMEDESC pFace | |
355 | ); | |
356 | WXDLLEXPORT int wxGpiStrcmp(wxChar* s0, wxChar* s1); | |
357 | ||
358 | WXDLLEXPORT void wxSliderEvent(WXHWND control, WXWORD wParam, WXWORD pos); | |
359 | WXDLLEXPORT void wxScrollBarEvent(WXHWND hbar, WXWORD wParam, WXWORD pos); | |
360 | ||
361 | // Find maximum size of window/rectangle | |
362 | WXDLLEXPORT extern void wxFindMaxSize(WXHWND hwnd, RECT *rect); | |
363 | ||
364 | WXDLLEXPORT wxWindow* wxFindControlFromHandle(WXHWND hWnd); | |
365 | WXDLLEXPORT void wxAddControlHandle(WXHWND hWnd, wxWindow *item); | |
366 | ||
367 | // Safely get the window text (i.e. without using fixed size buffer) | |
368 | WXDLLEXPORT extern wxString wxGetWindowText(WXHWND hWnd); | |
369 | ||
370 | // get the window class name | |
371 | WXDLLEXPORT 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) | |
375 | WXDLLEXPORT extern WXWORD wxGetWindowId(WXHWND hWnd); | |
376 | ||
377 | // Convert a PM Error code to a string | |
378 | WXDLLEXPORT extern wxString wxPMErrorToStr(ERRORID vError); | |
379 | ||
380 | // Does this window style specify any border? | |
381 | inline bool wxStyleHasBorder(long style) | |
382 | { | |
383 | return (style & (wxSIMPLE_BORDER | wxRAISED_BORDER | | |
384 | wxSUNKEN_BORDER | wxDOUBLE_BORDER)) != 0; | |
385 | } | |
386 | ||
387 | inline RECTL wxGetWindowRect(HWND hWnd) | |
388 | { | |
389 | RECTL vRect; | |
390 | ||
391 | ::WinQueryWindowRect(hWnd, &vRect); | |
392 | return vRect; | |
393 | } // end of wxGetWindowRect | |
394 | ||
395 | WXDLLEXPORT extern void wxOS2SetFont( HWND hWnd | |
396 | ,const wxFont& rFont | |
397 | ); | |
398 | ||
399 | ||
400 | WXDLLEXPORT extern bool wxCheckWindowWndProc( WXHWND hWnd | |
401 | ,WXFARPROC fnWndProc | |
402 | ); | |
403 | WXDLLEXPORT extern wxBitmap wxDisableBitmap( const wxBitmap& rBmp | |
404 | ,long lColor | |
405 | ); | |
406 | ||
407 | #include "wx/colour.h" | |
408 | ||
409 | WXDLLEXPORT extern COLORREF wxColourToRGB(const wxColour& rColor); | |
410 | ||
411 | #endif // __WXPM__ | |
412 | ||
413 | #endif // _WX_PRIVATE_H_ |