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 class WXDLLEXPORT wxButton
;
32 // ---------------------------------------------------------------------------
34 // ---------------------------------------------------------------------------
36 // FIXME does anybody use those? they're unused by wxWindows...
43 // ---------------------------------------------------------------------------
44 // wxWindow declaration for OS/2 PM
45 // ---------------------------------------------------------------------------
47 class WXDLLEXPORT wxWindowOS2
: public wxWindowBase
55 wxWindowOS2( wxWindow
* pParent
57 ,const wxPoint
& rPos
= wxDefaultPosition
58 ,const wxSize
& rSize
= wxDefaultSize
60 ,const wxString
& rName
= wxPanelNameStr
73 virtual ~wxWindowOS2();
75 bool Create( wxWindow
* pParent
77 ,const wxPoint
& rPos
= wxDefaultPosition
78 ,const wxSize
& rSize
= wxDefaultSize
80 ,const wxString
& rName
= wxPanelNameStr
83 // implement base class pure virtuals
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
95 virtual void CaptureMouse(void);
96 virtual void ReleaseMouse(void);
97 virtual void Refresh( bool bEraseBackground
= TRUE
98 ,const wxRect
* pRect
= (const wxRect
*)NULL
100 virtual void Clear(void);
101 virtual void Freeze(void);
102 virtual void Update(void);
103 virtual void Thaw(void);
104 virtual bool SetCursor(const wxCursor
& rCursor
);
105 virtual bool SetFont(const wxFont
& rFont
);
106 virtual int GetCharHeight(void) const;
107 virtual int GetCharWidth(void) const;
108 virtual void GetTextExtent( const wxString
& rString
111 ,int* pDescent
= (int *)NULL
112 ,int* pExternalLeading
= (int *)NULL
113 ,const wxFont
* pTheFont
= (const wxFont
*)NULL
115 #if wxUSE_MENUS_NATIVE
116 virtual bool DoPopupMenu( wxMenu
* pMenu
120 #endif // wxUSE_MENUS_NATIVE
122 virtual void SetScrollbar( int nOrient
126 ,bool bRefresh
= TRUE
128 virtual void SetScrollPos( int nOrient
130 ,bool bRefresh
= TRUE
132 virtual int GetScrollPos(int nOrient
) const;
133 virtual int GetScrollThumb(int nOrient
) const;
134 virtual int GetScrollRange(int nOrient
) const;
135 virtual void ScrollWindow( int nDx
137 ,const wxRect
* pRect
= (wxRect
*)NULL
140 #if wxUSE_DRAG_AND_DROP
141 virtual void SetDropTarget(wxDropTarget
* pDropTarget
);
142 #endif // wxUSE_DRAG_AND_DROP
144 // Accept files for dragging
145 virtual void DragAcceptFiles(bool bAccept
);
147 #if WXWIN_COMPATIBILITY
148 // Set/get scroll attributes
149 virtual void SetScrollRange( int nOrient
151 ,bool bRefresh
= TRUE
153 virtual void SetScrollPage( int nOrient
155 ,bool bRefresh
= TRUE
157 virtual int OldGetScrollRange(int nOrient
) const;
158 virtual int GetScrollPage(int nOrient
) const;
163 // Handle a control command
164 virtual void OnCommand( wxWindow
& rWin
165 ,wxCommandEvent
& rEvent
168 // Override to define new behaviour for default action (e.g. double
169 // clicking on a listbox)
170 virtual void OnDefaultAction(wxControl
* WXUNUSED(pInitiatingItem
)) { }
171 #endif // WXWIN_COMPATIBILITY
173 #if wxUSE_CARET && WXWIN_COMPATIBILITY
174 void CreateCaret( int nWidth
177 void CreateCaret(const wxBitmap
* pBitmap
);
178 void DestroyCaret(void);
179 void ShowCaret(bool bShow
);
180 void SetCaretPos( int nX
183 void GetCaretPos( int* pX
186 #endif // wxUSE_CARET
188 #ifndef __WXUNIVERSAL__
189 // Native resource loading (implemented in src/os2/nativdlg.cpp)
190 // FIXME: should they really be all virtual?
191 virtual bool LoadNativeDialog( wxWindow
* pParent
194 virtual bool LoadNativeDialog( wxWindow
* pParent
195 ,const wxString
& rName
197 wxWindow
* GetWindowChild1(wxWindowID vId
);
198 wxWindow
* GetWindowChild(wxWindowID vId
);
199 #endif //__WXUNIVERSAL__
201 // implementation from now on
202 // --------------------------
207 WXHWND
GetHWND(void) const { return m_hWnd
; }
208 void SetHWND(WXHWND hWnd
) { m_hWnd
= hWnd
; }
209 virtual WXWidget
GetHandle(void) const { return GetHWND(); }
210 bool GetUseCtl3D(void) const { return m_bUseCtl3D
; }
211 bool GetTransparentBackground(void) const { return m_bBackgroundTransparent
; }
212 void SetTransparent(bool bT
= TRUE
) { m_bBackgroundTransparent
= bT
; }
216 void OnSetFocus(wxFocusEvent
& rEvent
);
217 void OnEraseBackground(wxEraseEvent
& rEvent
);
218 void OnIdle(wxIdleEvent
& rEvent
);
221 // For implementation purposes - sometimes decorations make the client area
223 virtual wxPoint
GetClientAreaOrigin(void) const;
225 // Windows subclassing
226 void SubclassWin(WXHWND hWnd
);
227 void UnsubclassWin(void);
229 WXFARPROC
OS2GetOldWndProc(void) const { return m_fnOldWndProc
; }
230 void OS2SetOldWndProc(WXFARPROC fnProc
) { m_fnOldWndProc
= fnProc
; }
232 wxWindow
* FindItem(long lId
) const;
233 wxWindow
* FindItemByHWND( WXHWND hWnd
234 ,bool bControlOnly
= FALSE
237 // Make a Windows extended style from the given wxWindows window style ?? applicable to OS/2??
238 static WXDWORD
MakeExtendedStyle( long lStyle
239 ,bool bEliminateBorders
= TRUE
241 // Determine whether 3D effects are wanted
242 WXDWORD
Determine3DEffects( WXDWORD dwDefaultBorderStyle
246 // PM only: TRUE if this control is part of the main control
247 virtual bool ContainsHWND(WXHWND
WXUNUSED(hWnd
)) const { return FALSE
; };
249 // returns TRUE if the window has been created
250 bool OS2Create( WXHWND hParent
252 ,const wxChar
* zTitle
261 ,void* pCtlData
= NULL
262 ,void* pPresParams
= NULL
263 ,WXDWORD dwExStyle
= 0L
265 virtual bool OS2Command( WXUINT uParam
269 #if WXWIN_COMPATIBILITY
270 wxObject
* GetChild(int nNumber
) const;
271 virtual void OS2DeviceToLogical( float* pfX
274 #endif // WXWIN_COMPATIBILITY
276 #ifndef __WXUNIVERSAL__
277 // Create an appropriate wxWindow from a HWND
278 virtual wxWindow
* CreateWindowFromHWND( wxWindow
* pParent
282 // Make sure the window style reflects the HWND style (roughly)
283 virtual void AdoptAttributesFromHWND(void);
286 // Setup background and foreground colours correctly
287 virtual void SetupColours(void);
289 // ------------------------------------------------------------------------
290 // helpers for message handlers: these perform the same function as the
291 // message crackers from <windowsx.h> - they unpack WPARAM and LPARAM into
292 // the correct parameters
293 // ------------------------------------------------------------------------
295 void UnpackCommand( WXWPARAM wParam
301 void UnpackActivate( WXWPARAM wParam
306 void UnpackScroll( WXWPARAM wParam
312 void UnpackMenuSelect( WXWPARAM wParam
319 // ------------------------------------------------------------------------
320 // internal handlers for OS2 messages: all handlers return a boolen value:
321 // TRUE means that the handler processed the event and FALSE that it didn't
322 // ------------------------------------------------------------------------
324 // there are several cases where we have virtual functions for PM
325 // message processing: this is because these messages often require to be
326 // processed in a different manner in the derived classes. For all other
327 // messages, however, we do *not* have corresponding OS2OnXXX() function
328 // and if the derived class wants to process them, it should override
329 // OS2WindowProc() directly.
331 // scroll event (both horizontal and vertical)
332 virtual bool OS2OnScroll( int nOrientation
338 // owner-drawn controls need to process these messages
339 virtual bool OS2OnDrawItem( int nId
340 ,WXDRAWITEMSTRUCT
* pItem
342 virtual bool OS2OnMeasureItem( int nId
343 ,WXMEASUREITEMSTRUCT
* pItem
346 // the rest are not virtual
347 bool HandleCreate( WXLPCREATESTRUCT vCs
350 bool HandleInitDialog(WXHWND hWndFocus
);
351 bool HandleDestroy(void);
352 bool HandlePaint(void);
353 bool HandleEraseBkgnd(WXHDC vDC
);
354 bool HandleMinimize(void);
355 bool HandleMaximize(void);
356 bool HandleSize( int nX
360 bool HandleGetMinMaxInfo(PSWP pMmInfo
);
361 bool HandleShow( bool bShow
364 bool HandleActivate( int nFlag
367 bool HandleCommand( WXWORD nId
371 bool HandleSysCommand( WXWPARAM wParam
374 bool HandlePaletteChanged();
375 bool HandleSysColorChange(void);
376 bool HandleCtlColor(WXHBRUSH
* hBrush
);
377 bool HandleSetFocus(WXHWND hWnd
);
378 bool HandleKillFocus(WXHWND hWnd
);
379 bool HandleEndDrag(WXWPARAM wParam
);
380 bool HandleMouseEvent( WXUINT uMsg
385 bool HandleMouseMove( int nX
389 bool HandleChar( WXDWORD wParam
391 ,bool bIsASCII
= FALSE
393 bool HandleKeyDown( WXWORD wParam
396 bool HandleKeyUp( WXDWORD wParam
399 bool HandleQueryDragIcon(WXHICON
* phIcon
);
400 bool HandleSetCursor( USHORT vId
404 bool IsMouseInWindow(void) const;
405 bool OS2GetCreateWindowCoords( const wxPoint
& rPos
414 virtual MRESULT
OS2WindowProc( WXUINT uMsg
419 // Calls an appropriate default window procedure
420 virtual MRESULT
OS2DefWindowProc( WXUINT uMsg
424 virtual bool OS2ProcessMessage(WXMSG
* pMsg
);
425 virtual bool OS2TranslateMessage(WXMSG
* pMsg
);
426 virtual void OS2DestroyWindow(void);
428 // Detach "Window" menu from menu bar so it doesn't get deleted
429 void OS2DetachWindowMenu(void);
431 // this function should return the brush to paint the window background
432 // with or 0 for the default brush
433 virtual WXHBRUSH
OnCtlColor( WXHDC hDC
441 #if WXWIN_COMPATIBILITY
442 void SetShowing(bool bShow
) { (void)Show(show
); }
443 bool IsUserEnabled(void) const { return IsEnabled(); }
444 #endif // WXWIN_COMPATIBILITY
446 // Responds to colour changes: passes event on to children.
447 void OnSysColourChanged(wxSysColourChangedEvent
& rEvent
);
449 // initialize various fields of wxMouseEvent (common part of OS2OnMouseXXX)
450 void InitMouseEvent( wxMouseEvent
& rEvent
456 void MoveChildren(int nDiff
);
459 // PM can't create some MSW styles natively but can perform these after
460 // creation by sending messages
461 typedef enum extra_flags
{ kFrameToolWindow
= 0x0001
462 ,kVertCaption
= 0x0002
463 ,kHorzCaption
= 0x0004
465 // Some internal sizeing id's to make it easy for event handlers
466 typedef enum size_types
{ kSizeNormal
473 // the old window proc (we subclass all windows)
474 WXFARPROC m_fnOldWndProc
;
476 // additional (OS2 specific) flags
477 bool m_bUseCtl3D
:1; // Using CTL3D for this control
478 bool m_bBackgroundTransparent
:1;
479 bool m_bMouseInWindow
:1;
480 bool m_bDoubleClickAllowed
:1;
481 bool m_bWinCaptured
:1;
484 // the size of one page for scrolling
488 #if wxUSE_MOUSEEVENT_HACK
489 // the coordinates of the last mouse event and the type of it
492 int m_nLastMouseEvent
;
493 #endif // wxUSE_MOUSEEVENT_HACK
495 WXHMENU m_hMenu
; // Menu, if any
496 unsigned long m_ulMenubarId
; // it's Id, if any
498 // the return value of WM_GETDLGCODE handler
501 // implement the base class pure virtuals
502 virtual void DoClientToScreen( int* pX
505 virtual void DoScreenToClient( int* pX
508 virtual void DoGetPosition( int* pX
511 virtual void DoGetSize( int* pWidth
514 virtual void DoGetClientSize( int* pWidth
517 virtual void DoSetSize( int nX
521 ,int nSizeFlags
= wxSIZE_AUTO
523 virtual void DoSetClientSize( int nWidth
527 // move the window to the specified location and resize it: this is called
528 // from both DoSetSize() and DoSetClientSize() and would usually just call
529 // ::WinSetWindowPos() except for composite controls which will want to arrange
530 // themselves inside the given rectangle
531 virtual void DoMoveWindow( int nX
538 virtual void DoSetToolTip(wxToolTip
* pTip
);
539 #endif // wxUSE_TOOLTIPS
541 int GetOS2ParentHeight(wxWindowOS2
* pParent
);
544 // common part of all ctors
547 // the (non-virtual) handlers for the events
548 bool HandleMove( int nX
551 bool HandleJoystickEvent( WXUINT uMsg
557 bool HandleNotify( int nIdCtrl
561 // the helper functions used by HandleChar/KeyXXX methods
562 wxKeyEvent
CreateKeyEvent(wxEventType evType
, int id
, WXLPARAM lp
) const;
564 DECLARE_DYNAMIC_CLASS(wxWindowOS2
);
565 DECLARE_NO_COPY_CLASS(wxWindowOS2
)
566 DECLARE_EVENT_TABLE()
568 HWND m_hWndScrollBarHorz
;
569 HWND m_hWndScrollBarVert
;
571 // Virtual function hiding supression
572 inline virtual bool Reparent(wxWindowBase
* pNewParent
)
573 { return(wxWindowBase::Reparent(pNewParent
));};
574 }; // end of wxWindow
576 class wxWindowCreationHook
579 wxWindowCreationHook(wxWindow
* pWinBeingCreated
);
580 ~wxWindowCreationHook();
581 }; // end of CLASS wxWindowCreationHook
583 // ---------------------------------------------------------------------------
585 // ---------------------------------------------------------------------------
587 // kbd code translation
588 WXDLLEXPORT
int wxCharCodeOS2ToWX(int nKeySym
);
589 WXDLLEXPORT
int wxCharCodeWXToOS2( int nId