]> git.saurik.com Git - wxWidgets.git/blame - include/wx/os2/window.h
preemptive fix for wxPython compilation. It will break otherwise when
[wxWidgets.git] / include / wx / os2 / window.h
CommitLineData
0e320a79
DW
1/////////////////////////////////////////////////////////////////////////////
2// Name: window.h
3// Purpose: wxWindow class
54da4255 4// Author: David Webster
0e320a79 5// Modified by:
cdf1e714 6// Created: 10/12/99
0e320a79 7// RCS-ID: $Id$
cdf1e714
DW
8// Copyright: (c) David Webster
9// Licence: wxWindows licence
0e320a79
DW
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_WINDOW_H_
13#define _WX_WINDOW_H_
14
cdf1e714 15#define wxUSE_MOUSEEVENT_HACK 0
0e320a79 16
cdf1e714
DW
17// ---------------------------------------------------------------------------
18// headers
19// ---------------------------------------------------------------------------
63415778
DW
20#define INCL_DOS
21#define INCL_PM
22#define INCL_GPI
23#include <os2.h>
24
0e320a79
DW
25
26// ---------------------------------------------------------------------------
27// forward declarations
28// ---------------------------------------------------------------------------
29
30class WXDLLEXPORT wxButton;
31
cdf1e714
DW
32// ---------------------------------------------------------------------------
33// constants
34// ---------------------------------------------------------------------------
0e320a79 35
cdf1e714
DW
36// FIXME does anybody use those? they're unused by wxWindows...
37enum
38{
39 wxKEY_SHIFT = 1,
40 wxKEY_CTRL = 2
41};
54da4255 42
cdf1e714
DW
43// ---------------------------------------------------------------------------
44// wxWindow declaration for OS/2 PM
45// ---------------------------------------------------------------------------
54da4255 46
210a651b 47class WXDLLEXPORT wxWindowOS2 : public wxWindowBase
0e320a79 48{
0e320a79 49public:
210a651b 50 wxWindowOS2()
3e282d33
DW
51 {
52 Init();
53 }
cdf1e714 54
210a651b
DW
55 wxWindowOS2( wxWindow* pParent
56 ,wxWindowID vId
57 ,const wxPoint& rPos = wxDefaultPosition
58 ,const wxSize& rSize = wxDefaultSize
59 ,long lStyle = 0
60 ,const wxString& rName = wxPanelNameStr
61 )
0e320a79
DW
62 {
63 Init();
776d87d5
DW
64 Create( pParent
65 ,vId
66 ,rPos
67 ,rSize
68 ,lStyle
69 ,rName
70 );
0e320a79
DW
71 }
72
210a651b 73 virtual ~wxWindowOS2();
0e320a79 74
776d87d5
DW
75 bool Create( wxWindow* pParent
76 ,wxWindowID vId
77 ,const wxPoint& rPos = wxDefaultPosition
78 ,const wxSize& rSize = wxDefaultSize
79 ,long lStyle = 0
80 ,const wxString& rName = wxPanelNameStr
81 );
0e320a79 82
cdf1e714 83 // implement base class pure virtuals
776d87d5
DW
84 virtual void SetTitle(const wxString& rTitle);
85 virtual wxString GetTitle(void) const;
86 virtual void Raise(void);
87 virtual void Lower(void);
88 virtual bool Show(bool bShow = TRUE);
89 virtual bool Enable(bool bEnable = TRUE);
90 virtual void SetFocus(void);
91 virtual bool Reparent(wxWindow* pNewParent);
92 virtual void WarpPointer( int x
93 ,int y
94 );
95 virtual void CaptureMouse(void);
96 virtual void ReleaseMouse(void);
97 virtual void Refresh( bool bEraseBackground = TRUE
98 ,const wxRect* pRect = (const wxRect *)NULL
99 );
100 virtual void Clear(void);
101 virtual bool SetCursor(const wxCursor& rCursor);
102 virtual bool SetFont(const wxFont& rFont);
103 virtual int GetCharHeight(void) const;
104 virtual int GetCharWidth(void) const;
105 virtual void GetTextExtent( const wxString& rString
106 ,int* pX
107 ,int* pY
108 ,int* pDescent = (int *)NULL
109 ,int* pExternalLeading = (int *)NULL
110 ,const wxFont* pTheFont = (const wxFont *)NULL
111 ) const;
19193a2c 112#if wxUSE_MENUS_NATIVE
776d87d5
DW
113 virtual bool DoPopupMenu( wxMenu* pMenu
114 ,int nX
115 ,int nY
116 );
19193a2c 117#endif // wxUSE_MENUS_NATIVE
776d87d5
DW
118
119 virtual void SetScrollbar( int nOrient
120 ,int nPos
121 ,int nThumbVisible
122 ,int nRange
123 ,bool bRefresh = TRUE
124 );
125 virtual void SetScrollPos( int nOrient
126 ,int nPos
127 ,bool bRefresh = TRUE
128 );
129 virtual int GetScrollPos(int nOrient) const;
130 virtual int GetScrollThumb(int nOrient) const;
131 virtual int GetScrollRange(int nOrient) const;
132 virtual void ScrollWindow( int nDx
133 ,int nDy
134 ,const wxRect* pRect = (wxRect *)NULL
135 );
0e320a79 136
cdf1e714 137#if wxUSE_DRAG_AND_DROP
776d87d5 138 virtual void SetDropTarget(wxDropTarget* pDropTarget);
cdf1e714 139#endif // wxUSE_DRAG_AND_DROP
0e320a79
DW
140
141 // Accept files for dragging
776d87d5 142 virtual void DragAcceptFiles(bool bAccept);
0e320a79 143
cdf1e714
DW
144#if WXWIN_COMPATIBILITY
145 // Set/get scroll attributes
776d87d5
DW
146 virtual void SetScrollRange( int nOrient
147 ,int nRange
148 ,bool bRefresh = TRUE
149 );
150 virtual void SetScrollPage( int nOrient
151 ,int nPage
152 ,bool bRefresh = TRUE
153 );
154 virtual int OldGetScrollRange(int nOrient) const;
155 virtual int GetScrollPage(int nOrient) const;
156
157 //
cdf1e714 158 // event handlers
776d87d5 159 //
cdf1e714 160 // Handle a control command
776d87d5
DW
161 virtual void OnCommand( wxWindow& rWin
162 ,wxCommandEvent& rEvent
163 );
0e320a79 164
cdf1e714
DW
165 // Override to define new behaviour for default action (e.g. double
166 // clicking on a listbox)
776d87d5 167 virtual void OnDefaultAction(wxControl* WXUNUSED(pInitiatingItem)) { }
cdf1e714 168#endif // WXWIN_COMPATIBILITY
0e320a79 169
cdf1e714 170#if wxUSE_CARET && WXWIN_COMPATIBILITY
776d87d5
DW
171 void CreateCaret( int nWidth
172 ,int nHeight
173 );
174 void CreateCaret(const wxBitmap* pBitmap);
175 void DestroyCaret(void);
176 void ShowCaret(bool bShow);
177 void SetCaretPos( int nX
178 ,int nY
179 );
180 void GetCaretPos( int* pX
181 ,int* pY
182 ) const;
cdf1e714
DW
183#endif // wxUSE_CARET
184
19193a2c 185#ifndef __WXUNIVERSAL__
776d87d5 186 // Native resource loading (implemented in src/os2/nativdlg.cpp)
cdf1e714 187 // FIXME: should they really be all virtual?
776d87d5
DW
188 virtual bool LoadNativeDialog( wxWindow* pParent
189 ,wxWindowID& vId
190 );
191 virtual bool LoadNativeDialog( wxWindow* pParent
192 ,const wxString& rName
193 );
194 wxWindow* GetWindowChild1(wxWindowID vId);
195 wxWindow* GetWindowChild(wxWindowID vId);
19193a2c 196#endif //__WXUNIVERSAL__
cdf1e714
DW
197
198 // implementation from now on
199 // --------------------------
200
201 // simple accessors
202 // ----------------
86de7616 203
776d87d5
DW
204 WXHWND GetHWND(void) const { return m_hWnd; }
205 void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
206 virtual WXWidget GetHandle(void) const { return GetHWND(); }
207 bool GetUseCtl3D(void) const { return m_bUseCtl3D; }
208 bool GetTransparentBackground(void) const { return m_bBackgroundTransparent; }
209 void SetTransparent(bool bT = TRUE) { m_bBackgroundTransparent = bT; }
54da4255 210
cdf1e714
DW
211 // event handlers
212 // --------------
a885d89a 213 void OnSetFocus(wxFocusEvent& rEvent);
776d87d5
DW
214 void OnEraseBackground(wxEraseEvent& rEvent);
215 void OnIdle(wxIdleEvent& rEvent);
cdf1e714
DW
216
217public:
0e320a79
DW
218 // For implementation purposes - sometimes decorations make the client area
219 // smaller
776d87d5 220 virtual wxPoint GetClientAreaOrigin(void) const;
0e320a79 221
86de7616
DW
222 // Windows subclassing
223 void SubclassWin(WXHWND hWnd);
776d87d5 224 void UnsubclassWin(void);
86de7616 225
776d87d5
DW
226 WXFARPROC OS2GetOldWndProc(void) const { return m_fnOldWndProc; }
227 void OS2SetOldWndProc(WXFARPROC fnProc) { m_fnOldWndProc = fnProc; }
86de7616 228
776d87d5
DW
229 wxWindow* FindItem(long lId) const;
230 wxWindow* FindItemByHWND( WXHWND hWnd
231 ,bool bControlOnly = FALSE
232 ) const;
86de7616 233
776d87d5
DW
234 // Make a Windows extended style from the given wxWindows window style ?? applicable to OS/2??
235 static WXDWORD MakeExtendedStyle( long lStyle
236 ,bool bEliminateBorders = TRUE
237 );
86de7616 238 // Determine whether 3D effects are wanted
776d87d5
DW
239 WXDWORD Determine3DEffects( WXDWORD dwDefaultBorderStyle
240 ,bool* pbWant3D
241 ) const;
86de7616 242
776d87d5 243 // PM only: TRUE if this control is part of the main control
86de7616
DW
244 virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; };
245
cdf1e714 246 // returns TRUE if the window has been created
3e282d33
DW
247 bool OS2Create( WXHWND hParent
248 ,PSZ zClass
776d87d5 249 ,const wxChar* zTitle
776d87d5 250 ,WXDWORD dwStyle
3e282d33
DW
251 ,long lX
252 ,long lY
253 ,long lWidth
254 ,long lHeight
255 ,WXHWND hOwner
256 ,WXHWND hZOrder
257 ,unsigned long lId
258 ,void* pCtlData = NULL
259 ,void* pPresParams = NULL
008089f6 260 ,WXDWORD dwExStyle = 0L
776d87d5
DW
261 );
262 virtual bool OS2Command( WXUINT uParam
263 ,WXWORD nId
264 );
cdf1e714
DW
265
266#if WXWIN_COMPATIBILITY
776d87d5
DW
267 wxObject* GetChild(int nNumber) const;
268 virtual void OS2DeviceToLogical( float* pfX
269 ,float* pfY
270 ) const;
cdf1e714
DW
271#endif // WXWIN_COMPATIBILITY
272
19193a2c 273#ifndef __WXUNIVERSAL__
cdf1e714 274 // Create an appropriate wxWindow from a HWND
776d87d5
DW
275 virtual wxWindow* CreateWindowFromHWND( wxWindow* pParent
276 ,WXHWND hWnd
277 );
cdf1e714
DW
278
279 // Make sure the window style reflects the HWND style (roughly)
776d87d5 280 virtual void AdoptAttributesFromHWND(void);
19193a2c 281#endif
cdf1e714
DW
282
283 // Setup background and foreground colours correctly
776d87d5 284 virtual void SetupColours(void);
cdf1e714
DW
285
286 // ------------------------------------------------------------------------
287 // helpers for message handlers: these perform the same function as the
288 // message crackers from <windowsx.h> - they unpack WPARAM and LPARAM into
289 // the correct parameters
290 // ------------------------------------------------------------------------
291
776d87d5
DW
292 void UnpackCommand( WXWPARAM wParam
293 ,WXLPARAM lParam,
294 WXWORD* pId
295 ,WXHWND* pHwnd
296 ,WXWORD* pCmd
297 );
298 void UnpackActivate( WXWPARAM wParam
299 ,WXLPARAM lParam
300 ,WXWORD* pState
776d87d5
DW
301 ,WXHWND* pHwnd
302 );
303 void UnpackScroll( WXWPARAM wParam
304 ,WXLPARAM lParam
305 ,WXWORD* pCode
306 ,WXWORD* pPos
307 ,WXHWND* pHwnd
308 );
776d87d5
DW
309 void UnpackMenuSelect( WXWPARAM wParam
310 ,WXLPARAM lParam
311 ,WXWORD* pTtem
312 ,WXWORD* pFlags
313 ,WXHMENU* pHmenu
314 );
cdf1e714
DW
315
316 // ------------------------------------------------------------------------
776d87d5 317 // internal handlers for OS2 messages: all handlers return a boolen value:
cdf1e714
DW
318 // TRUE means that the handler processed the event and FALSE that it didn't
319 // ------------------------------------------------------------------------
320
776d87d5 321 // there are several cases where we have virtual functions for PM
cdf1e714
DW
322 // message processing: this is because these messages often require to be
323 // processed in a different manner in the derived classes. For all other
776d87d5 324 // messages, however, we do *not* have corresponding OS2OnXXX() function
cdf1e714 325 // and if the derived class wants to process them, it should override
776d87d5 326 // OS2WindowProc() directly.
cdf1e714
DW
327
328 // scroll event (both horizontal and vertical)
776d87d5
DW
329 virtual bool OS2OnScroll( int nOrientation
330 ,WXWORD nSBCode
331 ,WXWORD pos
332 ,WXHWND control
333 );
cdf1e714 334
cdf1e714 335 // owner-drawn controls need to process these messages
776d87d5
DW
336 virtual bool OS2OnDrawItem( int nId
337 ,WXDRAWITEMSTRUCT* pItem
338 );
339 virtual bool OS2OnMeasureItem( int nId
340 ,WXMEASUREITEMSTRUCT* pItem
341 );
cdf1e714
DW
342
343 // the rest are not virtual
776d87d5
DW
344 bool HandleCreate( WXLPCREATESTRUCT vCs
345 ,bool* pMayCreate
346 );
cdf1e714 347 bool HandleInitDialog(WXHWND hWndFocus);
776d87d5
DW
348 bool HandleDestroy(void);
349 bool HandlePaint(void);
350 bool HandleEraseBkgnd(WXHDC vDC);
351 bool HandleMinimize(void);
352 bool HandleMaximize(void);
353 bool HandleSize( int nX
354 ,int nY
355 ,WXUINT uFlag
356 );
61243a51 357 bool HandleGetMinMaxInfo(PSWP pMmInfo);
776d87d5
DW
358 bool HandleShow( bool bShow
359 ,int nStatus
360 );
361 bool HandleActivate( int nFlag
776d87d5
DW
362 ,WXHWND hActivate
363 );
364 bool HandleCommand( WXWORD nId
365 ,WXWORD nCmd
366 ,WXHWND hControl
367 );
368 bool HandleSysCommand( WXWPARAM wParam
369 ,WXLPARAM lParam
370 );
61243a51 371 bool HandlePaletteChanged();
776d87d5 372 bool HandleSysColorChange(void);
61243a51 373 bool HandleCtlColor(WXHBRUSH* hBrush);
776d87d5
DW
374 bool HandleSetFocus(WXHWND hWnd);
375 bool HandleKillFocus(WXHWND hWnd);
61243a51 376 bool HandleEndDrag(WXWPARAM wParam);
776d87d5
DW
377 bool HandleMouseEvent( WXUINT uMsg
378 ,int nX
379 ,int nY
380 ,WXUINT uFlags
381 );
382 bool HandleMouseMove( int nX
383 ,int nY
384 ,WXUINT uFlags
385 );
afa59b4e 386 bool HandleChar( WXDWORD wParam
776d87d5
DW
387 ,WXLPARAM lParam
388 ,bool bIsASCII = FALSE
389 );
390 bool HandleKeyDown( WXWORD wParam
391 ,WXLPARAM lParam
392 );
afa59b4e 393 bool HandleKeyUp( WXDWORD wParam
776d87d5
DW
394 ,WXLPARAM lParam
395 );
396 bool HandleQueryDragIcon(WXHICON* phIcon);
61243a51
DW
397 bool HandleSetCursor( USHORT vId
398 ,WXHWND hWnd
776d87d5 399 );
0e320a79 400
cdf1e714 401 // Window procedure
a885d89a 402 virtual MRESULT OS2WindowProc( WXUINT uMsg
776d87d5
DW
403 ,WXWPARAM wParam
404 ,WXLPARAM lParam
405 );
0e320a79 406
cdf1e714 407 // Calls an appropriate default window procedure
a885d89a 408 virtual MRESULT OS2DefWindowProc( WXUINT uMsg
776d87d5
DW
409 ,WXWPARAM wParam
410 ,WXLPARAM lParam
411 );
412 virtual bool OS2ProcessMessage(WXMSG* pMsg);
413 virtual bool OS2TranslateMessage(WXMSG* pMsg);
414 virtual void OS2DestroyWindow(void);
0e320a79 415
cdf1e714 416 // Detach "Window" menu from menu bar so it doesn't get deleted
776d87d5 417 void OS2DetachWindowMenu(void);
27476f73 418
cdf1e714
DW
419 // this function should return the brush to paint the window background
420 // with or 0 for the default brush
776d87d5
DW
421 virtual WXHBRUSH OnCtlColor( WXHDC hDC
422 ,WXHWND hWnd
423 ,WXUINT uCtlColor
424 ,WXUINT uMessage
425 ,WXWPARAM wParam
426 ,WXLPARAM lParam
427 );
27476f73 428
cdf1e714 429#if WXWIN_COMPATIBILITY
776d87d5
DW
430 void SetShowing(bool bShow) { (void)Show(show); }
431 bool IsUserEnabled(void) const { return IsEnabled(); }
cdf1e714 432#endif // WXWIN_COMPATIBILITY
0e320a79 433
cdf1e714 434 // Responds to colour changes: passes event on to children.
776d87d5 435 void OnSysColourChanged(wxSysColourChangedEvent& rEvent);
0e320a79 436
776d87d5
DW
437 // initialize various fields of wxMouseEvent (common part of OS2OnMouseXXX)
438 void InitMouseEvent( wxMouseEvent& rEvent
439 ,int nX
440 ,int nY
441 ,WXUINT uFlags
442 );
0e320a79 443
cdf1e714 444protected:
a885d89a
DW
445 // PM can't create some MSW styles natively but can perform these after
446 // creation by sending messages
447 typedef enum extra_flags { kFrameToolWindow = 0x0001
448 ,kVertCaption = 0x0002
449 ,kHorzCaption = 0x0004
450 } EExtraFlags;
451 // Some internal sizeing id's to make it easy for event handlers
452 typedef enum size_types { kSizeNormal
453 ,kSizeMax
454 ,kSizeMin
455 } ESizeTypes;
cdf1e714 456 // the window handle
776d87d5 457 WXHWND m_hWnd;
cdf1e714
DW
458
459 // the old window proc (we subclass all windows)
776d87d5 460 WXFARPROC m_fnOldWndProc;
cdf1e714 461
008089f6 462 // additional (OS2 specific) flags
776d87d5
DW
463 bool m_bUseCtl3D:1; // Using CTL3D for this control
464 bool m_bBackgroundTransparent:1;
465 bool m_bMouseInWindow:1;
466 bool m_bDoubleClickAllowed:1;
467 bool m_bWinCaptured:1;
008089f6 468 WXDWORD m_dwExStyle;
849949b1
DW
469
470 // the size of one page for scrolling
776d87d5
DW
471 int m_nXThumbSize;
472 int m_nYThumbSize;
0e320a79 473
cdf1e714
DW
474#if wxUSE_MOUSEEVENT_HACK
475 // the coordinates of the last mouse event and the type of it
776d87d5
DW
476 long m_lLastMouseX,
477 long m_lLastMouseY;
478 int m_nLastMouseEvent;
cdf1e714
DW
479#endif // wxUSE_MOUSEEVENT_HACK
480
776d87d5 481 WXHMENU m_hMenu; // Menu, if any
0fe536e3 482 unsigned long m_ulMenubarId; // it's Id, if any
cdf1e714
DW
483
484 // the return value of WM_GETDLGCODE handler
776d87d5 485 long m_lDlgCode;
cdf1e714
DW
486
487 // implement the base class pure virtuals
776d87d5
DW
488 virtual void DoClientToScreen( int* pX
489 ,int* pY
490 ) const;
491 virtual void DoScreenToClient( int* pX
492 ,int* pY
493 ) const;
494 virtual void DoGetPosition( int* pX
495 ,int* pY
496 ) const;
497 virtual void DoGetSize( int* pWidth
498 ,int* pHeight
499 ) const;
500 virtual void DoGetClientSize( int* pWidth
501 ,int* pHeight
502 ) const;
503 virtual void DoSetSize( int nX
504 ,int nY
505 ,int nWidth
506 ,int nHeight
507 ,int nSizeFlags = wxSIZE_AUTO
508 );
509 virtual void DoSetClientSize( int nWidth
510 ,int nHeight
511 );
cdf1e714 512
cdf1e714
DW
513 // move the window to the specified location and resize it: this is called
514 // from both DoSetSize() and DoSetClientSize() and would usually just call
3e282d33 515 // ::WinSetWindowPos() except for composite controls which will want to arrange
cdf1e714 516 // themselves inside the given rectangle
776d87d5
DW
517 virtual void DoMoveWindow( int nX
518 ,int nY
519 ,int nWidth
520 ,int nHeight
521 );
cdf1e714
DW
522
523#if wxUSE_TOOLTIPS
776d87d5 524 virtual void DoSetToolTip(wxToolTip* pTip);
cdf1e714
DW
525#endif // wxUSE_TOOLTIPS
526
0e320a79 527private:
cdf1e714 528 // common part of all ctors
776d87d5 529 void Init(void);
0e320a79 530
cdf1e714 531 // the (non-virtual) handlers for the events
776d87d5
DW
532 bool HandleMove( int nX
533 ,int nY
534 );
535 bool HandleJoystickEvent( WXUINT uMsg
536 ,int pX
537 ,int pY
538 ,WXUINT uFlags
539 );
540
541 bool HandleNotify( int nIdCtrl
542 ,WXLPARAM lParam
543 ,WXLPARAM* pResult
544 );
a885d89a
DW
545 // the helper functions used by HandleChar/KeyXXX methods
546 wxKeyEvent CreateKeyEvent(wxEventType evType, int id, WXLPARAM lp) const;
547
210a651b
DW
548 DECLARE_DYNAMIC_CLASS(wxWindowOS2);
549 DECLARE_NO_COPY_CLASS(wxWindowOS2)
cdf1e714 550 DECLARE_EVENT_TABLE()
63415778 551private:
c8b5f745
DW
552 HWND m_hWndScrollBarHorz;
553 HWND m_hWndScrollBarVert;
1c84ee88 554
63415778 555 // Virtual function hiding supression
776d87d5
DW
556 inline virtual bool Reparent(wxWindowBase* pNewParent)
557 { return(wxWindowBase::Reparent(pNewParent));};
a885d89a 558}; // end of wxWindow
0e320a79 559
cdf1e714
DW
560// ---------------------------------------------------------------------------
561// global functions
562// ---------------------------------------------------------------------------
0e320a79 563
cdf1e714 564// kbd code translation
776d87d5
DW
565WXDLLEXPORT int wxCharCodeOS2ToWX(int nKeySym);
566WXDLLEXPORT int wxCharCodeWXToOS2( int nId
567 ,bool* pbIsVirtual
568 );
0e320a79
DW
569#endif
570 // _WX_WINDOW_H_