]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/window.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxWindow class
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #define wxUSE_MOUSEEVENT_HACK 0
17 // ---------------------------------------------------------------------------
19 // ---------------------------------------------------------------------------
26 // ---------------------------------------------------------------------------
27 // forward declarations
28 // ---------------------------------------------------------------------------
30 # define CW_USEDEFAULT ((int)0x80000000)
33 // ---------------------------------------------------------------------------
34 // forward declarations
35 // ---------------------------------------------------------------------------
37 class WXDLLEXPORT wxButton
;
39 // ---------------------------------------------------------------------------
41 // ---------------------------------------------------------------------------
43 #if WXWIN_COMPATIBILITY_2_4
44 // they're unused by wxWidgets...
52 // ---------------------------------------------------------------------------
53 // wxWindow declaration for OS/2 PM
54 // ---------------------------------------------------------------------------
56 class WXDLLEXPORT wxWindowOS2
: public wxWindowBase
64 wxWindowOS2( wxWindow
* pParent
66 ,const wxPoint
& rPos
= wxDefaultPosition
67 ,const wxSize
& rSize
= wxDefaultSize
69 ,const wxString
& rName
= wxPanelNameStr
82 virtual ~wxWindowOS2();
84 bool Create( wxWindow
* pParent
86 ,const wxPoint
& rPos
= wxDefaultPosition
87 ,const wxSize
& rSize
= wxDefaultSize
89 ,const wxString
& rName
= wxPanelNameStr
92 // implement base class pure virtuals
93 virtual void SetTitle(const wxString
& rTitle
);
94 virtual wxString
GetTitle(void) const;
95 virtual void Raise(void);
96 virtual void Lower(void);
97 virtual bool Show(bool bShow
= true);
98 virtual bool Enable(bool bEnable
= true);
99 virtual void SetFocus(void);
100 virtual void SetFocusFromKbd(void);
101 virtual bool Reparent(wxWindow
* pNewParent
);
102 virtual void WarpPointer( int x
105 virtual void Refresh( bool bEraseBackground
= true
106 ,const wxRect
* pRect
= (const wxRect
*)NULL
108 virtual void Freeze(void);
109 virtual void Update(void);
110 virtual void Thaw(void);
111 virtual void SetWindowStyleFlag(long lStyle
);
112 virtual bool SetCursor(const wxCursor
& rCursor
);
113 virtual bool SetFont(const wxFont
& rFont
);
114 virtual int GetCharHeight(void) const;
115 virtual int GetCharWidth(void) const;
116 virtual void GetTextExtent( const wxString
& rString
119 ,int* pDescent
= (int *)NULL
120 ,int* pExternalLeading
= (int *)NULL
121 ,const wxFont
* pTheFont
= (const wxFont
*)NULL
123 #if wxUSE_MENUS_NATIVE
124 virtual bool DoPopupMenu( wxMenu
* pMenu
128 #endif // wxUSE_MENUS_NATIVE
130 virtual void SetScrollbar( int nOrient
134 ,bool bRefresh
= true
136 virtual void SetScrollPos( int nOrient
138 ,bool bRefresh
= true
140 virtual int GetScrollPos(int nOrient
) const;
141 virtual int GetScrollThumb(int nOrient
) const;
142 virtual int GetScrollRange(int nOrient
) const;
143 virtual void ScrollWindow( int nDx
145 ,const wxRect
* pRect
= (wxRect
*)NULL
148 inline HWND
GetScrollBarHorz(void) const {return m_hWndScrollBarHorz
;}
149 inline HWND
GetScrollBarVert(void) const {return m_hWndScrollBarVert
;};
150 #if wxUSE_DRAG_AND_DROP
151 virtual void SetDropTarget(wxDropTarget
* pDropTarget
);
152 #endif // wxUSE_DRAG_AND_DROP
154 // Accept files for dragging
155 virtual void DragAcceptFiles(bool bAccept
);
157 #ifndef __WXUNIVERSAL__
158 // Native resource loading (implemented in src/os2/nativdlg.cpp)
159 // FIXME: should they really be all virtual?
160 virtual bool LoadNativeDialog( wxWindow
* pParent
163 virtual bool LoadNativeDialog( wxWindow
* pParent
164 ,const wxString
& rName
166 wxWindow
* GetWindowChild1(wxWindowID vId
);
167 wxWindow
* GetWindowChild(wxWindowID vId
);
168 #endif //__WXUNIVERSAL__
170 // implementation from now on
171 // --------------------------
176 WXHWND
GetHWND(void) const { return m_hWnd
; }
177 void SetHWND(WXHWND hWnd
) { m_hWnd
= hWnd
; }
178 virtual WXWidget
GetHandle(void) const { return GetHWND(); }
179 bool GetUseCtl3D(void) const { return m_bUseCtl3D
; }
180 bool GetTransparentBackground(void) const { return m_bBackgroundTransparent
; }
181 void SetTransparent(bool bT
= true) { m_bBackgroundTransparent
= bT
; }
185 void OnSetFocus(wxFocusEvent
& rEvent
);
186 void OnEraseBackground(wxEraseEvent
& rEvent
);
187 void OnIdle(wxIdleEvent
& rEvent
);
191 // For implementation purposes - sometimes decorations make the client area
193 virtual wxPoint
GetClientAreaOrigin(void) const;
195 // Windows subclassing
196 void SubclassWin(WXHWND hWnd
);
197 void UnsubclassWin(void);
199 WXFARPROC
OS2GetOldWndProc(void) const { return m_fnOldWndProc
; }
200 void OS2SetOldWndProc(WXFARPROC fnProc
) { m_fnOldWndProc
= fnProc
; }
202 // Return true if the window is of a standard (i.e. not wxWidgets') class
204 bool IsOfStandardClass(void) const { return m_fnOldWndProc
!= NULL
; }
206 wxWindow
* FindItem(long lId
) const;
207 wxWindow
* FindItemByHWND( WXHWND hWnd
208 ,bool bControlOnly
= false
211 // Make a Windows extended style from the given wxWidgets window style ?? applicable to OS/2??
212 static WXDWORD
MakeExtendedStyle( long lStyle
213 ,bool bEliminateBorders
= true
216 // PM only: true if this control is part of the main control
217 virtual bool ContainsHWND(WXHWND
WXUNUSED(hWnd
)) const { return false; };
219 // translate wxWidgets style flags for this control into the PM style
220 // and optional extended style for the corresponding native control
222 // this is the function that should be overridden in the derived classes,
223 // but you will mostly use OS2GetCreateWindowFlags() below
224 virtual WXDWORD
OS2GetStyle( long lFlags
225 ,WXDWORD
* pdwExstyle
= NULL
228 // get the MSW window flags corresponding to wxWidgets ones
230 // the functions returns the flags (WS_XXX) directly and puts the ext
231 // (WS_EX_XXX) flags into the provided pointer if not NULL
232 WXDWORD
OS2GetCreateWindowFlags(WXDWORD
* pdwExflags
= NULL
) const
233 { return OS2GetStyle(GetWindowStyle(), pdwExflags
); }
236 // get the HWND to be used as parent of this window with CreateWindow()
237 virtual WXHWND
OS2GetParent(void) const;
239 // returns true if the window has been created
240 bool OS2Create( PSZ zClass
249 virtual bool OS2Command( WXUINT uParam
253 #ifndef __WXUNIVERSAL__
254 // Create an appropriate wxWindow from a HWND
255 virtual wxWindow
* CreateWindowFromHWND( wxWindow
* pParent
259 // Make sure the window style reflects the HWND style (roughly)
260 virtual void AdoptAttributesFromHWND(void);
263 // Setup background and foreground colours correctly
264 virtual void SetupColours(void);
266 // ------------------------------------------------------------------------
267 // helpers for message handlers: these perform the same function as the
268 // message crackers from <windowsx.h> - they unpack WPARAM and LPARAM into
269 // the correct parameters
270 // ------------------------------------------------------------------------
272 void UnpackCommand( WXWPARAM wParam
278 void UnpackActivate( WXWPARAM wParam
283 void UnpackScroll( WXWPARAM wParam
289 void UnpackMenuSelect( WXWPARAM wParam
296 // ------------------------------------------------------------------------
297 // internal handlers for OS2 messages: all handlers return a boolen value:
298 // true means that the handler processed the event and false that it didn't
299 // ------------------------------------------------------------------------
301 // there are several cases where we have virtual functions for PM
302 // message processing: this is because these messages often require to be
303 // processed in a different manner in the derived classes. For all other
304 // messages, however, we do *not* have corresponding OS2OnXXX() function
305 // and if the derived class wants to process them, it should override
306 // OS2WindowProc() directly.
308 // scroll event (both horizontal and vertical)
309 virtual bool OS2OnScroll( int nOrientation
315 // owner-drawn controls need to process these messages
316 virtual bool OS2OnDrawItem( int nId
317 ,WXDRAWITEMSTRUCT
* pItem
319 virtual long OS2OnMeasureItem( int nId
320 ,WXMEASUREITEMSTRUCT
* pItem
323 virtual void OnPaint(wxPaintEvent
& rEvent
);
325 // the rest are not virtual
326 bool HandleCreate( WXLPCREATESTRUCT vCs
329 bool HandleInitDialog(WXHWND hWndFocus
);
330 bool HandleDestroy(void);
331 bool HandlePaint(void);
332 bool HandleEraseBkgnd(WXHDC vDC
);
333 bool HandleMinimize(void);
334 bool HandleMaximize(void);
335 bool HandleSize( int nX
339 bool HandleGetMinMaxInfo(PSWP pMmInfo
);
340 bool HandleShow( bool bShow
343 bool HandleActivate( int nFlag
346 bool HandleCommand( WXWORD nId
350 bool HandleSysCommand( WXWPARAM wParam
353 bool HandlePaletteChanged(void);
354 bool HandleQueryNewPalette(void);
355 bool HandleSysColorChange(void);
356 bool HandleDisplayChange(void);
357 bool HandleCaptureChanged(WXHWND hBainedCapture
);
359 bool HandleCtlColor(WXHBRUSH
* hBrush
);
360 bool HandleSetFocus(WXHWND hWnd
);
361 bool HandleKillFocus(WXHWND hWnd
);
362 bool HandleEndDrag(WXWPARAM wParam
);
363 bool HandleMouseEvent( WXUINT uMsg
368 bool HandleMouseMove( int nX
372 bool HandleChar( WXWPARAM wParam
374 ,bool bIsASCII
= false
376 bool HandleKeyDown( WXWPARAM wParam
379 bool HandleKeyUp( WXWPARAM wParam
382 bool HandleQueryDragIcon(WXHICON
* phIcon
);
383 bool HandleSetCursor( USHORT vId
387 bool IsMouseInWindow(void) const;
388 bool OS2GetCreateWindowCoords( const wxPoint
& rPos
397 virtual MRESULT
OS2WindowProc( WXUINT uMsg
402 // Calls an appropriate default window procedure
403 virtual MRESULT
OS2DefWindowProc( WXUINT uMsg
407 virtual bool OS2ProcessMessage(WXMSG
* pMsg
);
408 virtual bool OS2ShouldPreProcessMessage(WXMSG
* pMsg
);
409 virtual bool OS2TranslateMessage(WXMSG
* pMsg
);
410 virtual void OS2DestroyWindow(void);
412 // this function should return the brush to paint the window background
413 // with or 0 for the default brush
414 virtual WXHBRUSH
OnCtlColor( WXHDC hDC
422 // Responds to colour changes: passes event on to children.
423 void OnSysColourChanged(wxSysColourChangedEvent
& rEvent
);
425 // initialize various fields of wxMouseEvent (common part of OS2OnMouseXXX)
426 void InitMouseEvent( wxMouseEvent
& rEvent
432 void MoveChildren(int nDiff
);
433 PSWP
GetSwp(void) {return &m_vWinSwp
;}
436 // PM can't create some MSW styles natively but can perform these after
437 // creation by sending messages
438 typedef enum extra_flags
{ kFrameToolWindow
= 0x0001
439 ,kVertCaption
= 0x0002
440 ,kHorzCaption
= 0x0004
442 // Some internal sizeing id's to make it easy for event handlers
443 typedef enum size_types
{ kSizeNormal
450 // the old window proc (we subclass all windows)
451 WXFARPROC m_fnOldWndProc
;
453 // additional (OS2 specific) flags
454 bool m_bUseCtl3D
:1; // Using CTL3D for this control
455 bool m_bBackgroundTransparent
:1;
456 bool m_bMouseInWindow
:1;
457 bool m_bLastKeydownProcessed
:1;
458 bool m_bWinCaptured
:1;
461 // the size of one page for scrolling
465 #if wxUSE_MOUSEEVENT_HACK
466 // the coordinates of the last mouse event and the type of it
469 int m_nLastMouseEvent
;
470 #endif // wxUSE_MOUSEEVENT_HACK
472 WXHMENU m_hMenu
; // Menu, if any
473 unsigned long m_ulMenubarId
; // it's Id, if any
475 // the return value of WM_GETDLGCODE handler
478 // implement the base class pure virtuals
479 virtual void DoClientToScreen( int* pX
482 virtual void DoScreenToClient( int* pX
485 virtual void DoGetPosition( int* pX
488 virtual void DoGetSize( int* pWidth
491 virtual void DoGetClientSize( int* pWidth
494 virtual void DoSetSize( int nX
498 ,int nSizeFlags
= wxSIZE_AUTO
500 virtual void DoSetClientSize( int nWidth
504 virtual void DoCaptureMouse(void);
505 virtual void DoReleaseMouse(void);
507 // move the window to the specified location and resize it: this is called
508 // from both DoSetSize() and DoSetClientSize() and would usually just call
509 // ::WinSetWindowPos() except for composite controls which will want to arrange
510 // themselves inside the given rectangle
511 virtual void DoMoveWindow( int nX
518 virtual void DoSetToolTip(wxToolTip
* pTip
);
519 #endif // wxUSE_TOOLTIPS
521 int GetOS2ParentHeight(wxWindowOS2
* pParent
);
524 // common part of all ctors
527 // the (non-virtual) handlers for the events
528 bool HandleMove( int nX
531 bool HandleJoystickEvent( WXUINT uMsg
537 bool HandleNotify( int nIdCtrl
541 // the helper functions used by HandleChar/KeyXXX methods
542 wxKeyEvent
CreateKeyEvent( wxEventType evType
548 wxWindowList
* m_pChildrenDisabled
;
549 HWND m_hWndScrollBarHorz
;
550 HWND m_hWndScrollBarVert
;
553 DECLARE_DYNAMIC_CLASS(wxWindowOS2
);
554 DECLARE_NO_COPY_CLASS(wxWindowOS2
)
555 DECLARE_EVENT_TABLE()
558 // Virtual function hiding supression
560 inline virtual bool Reparent(wxWindowBase
* pNewParent
)
561 { return(wxWindowBase::Reparent(pNewParent
));}
562 }; // end of wxWindow
564 class wxWindowCreationHook
567 wxWindowCreationHook(wxWindow
* pWinBeingCreated
);
568 ~wxWindowCreationHook();
569 }; // end of CLASS wxWindowCreationHook
571 // ---------------------------------------------------------------------------
573 // ---------------------------------------------------------------------------
575 // kbd code translation
576 WXDLLEXPORT
int wxCharCodeOS2ToWX(int nKeySym
);
577 WXDLLEXPORT
int wxCharCodeWXToOS2( int nId
581 // ----------------------------------------------------------------------------
583 // ----------------------------------------------------------------------------
585 // notice that this hash must be defined after wxWindow declaration as it
586 // needs to "see" its dtor and not just forward declaration
589 // pseudo-template HWND <-> wxWindow hash table
590 WX_DECLARE_HASH(wxWindowOS2
, wxWindowList
, wxWinHashTable
);
592 extern wxWinHashTable
*wxWinHandleHash
;