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 // FIXME does anybody use those? they're unused by wxWindows...
50 // ---------------------------------------------------------------------------
51 // wxWindow declaration for OS/2 PM
52 // ---------------------------------------------------------------------------
54 class WXDLLEXPORT wxWindowOS2
: public wxWindowBase
62 wxWindowOS2( wxWindow
* pParent
64 ,const wxPoint
& rPos
= wxDefaultPosition
65 ,const wxSize
& rSize
= wxDefaultSize
67 ,const wxString
& rName
= wxPanelNameStr
80 virtual ~wxWindowOS2();
82 bool Create( wxWindow
* pParent
84 ,const wxPoint
& rPos
= wxDefaultPosition
85 ,const wxSize
& rSize
= wxDefaultSize
87 ,const wxString
& rName
= wxPanelNameStr
90 // implement base class pure virtuals
91 virtual void SetTitle(const wxString
& rTitle
);
92 virtual wxString
GetTitle(void) const;
93 virtual void Raise(void);
94 virtual void Lower(void);
95 virtual bool Show(bool bShow
= TRUE
);
96 virtual bool Enable(bool bEnable
= TRUE
);
97 virtual void SetFocus(void);
98 virtual bool Reparent(wxWindow
* pNewParent
);
99 virtual void WarpPointer( int x
102 virtual void Refresh( bool bEraseBackground
= TRUE
103 ,const wxRect
* pRect
= (const wxRect
*)NULL
105 virtual void Clear(void);
106 virtual void Freeze(void);
107 virtual void Update(void);
108 virtual void Thaw(void);
109 virtual bool SetCursor(const wxCursor
& rCursor
);
110 virtual bool SetFont(const wxFont
& rFont
);
111 virtual int GetCharHeight(void) const;
112 virtual int GetCharWidth(void) const;
113 virtual void GetTextExtent( const wxString
& rString
116 ,int* pDescent
= (int *)NULL
117 ,int* pExternalLeading
= (int *)NULL
118 ,const wxFont
* pTheFont
= (const wxFont
*)NULL
120 #if wxUSE_MENUS_NATIVE
121 virtual bool DoPopupMenu( wxMenu
* pMenu
125 #endif // wxUSE_MENUS_NATIVE
127 virtual void SetScrollbar( int nOrient
131 ,bool bRefresh
= TRUE
133 virtual void SetScrollPos( int nOrient
135 ,bool bRefresh
= TRUE
137 virtual int GetScrollPos(int nOrient
) const;
138 virtual int GetScrollThumb(int nOrient
) const;
139 virtual int GetScrollRange(int nOrient
) const;
140 virtual void ScrollWindow( int nDx
142 ,const wxRect
* pRect
= (wxRect
*)NULL
145 #if wxUSE_DRAG_AND_DROP
146 virtual void SetDropTarget(wxDropTarget
* pDropTarget
);
147 #endif // wxUSE_DRAG_AND_DROP
149 // Accept files for dragging
150 virtual void DragAcceptFiles(bool bAccept
);
152 #if WXWIN_COMPATIBILITY
153 // Set/get scroll attributes
154 virtual void SetScrollRange( int nOrient
156 ,bool bRefresh
= TRUE
158 virtual void SetScrollPage( int nOrient
160 ,bool bRefresh
= TRUE
162 virtual int OldGetScrollRange(int nOrient
) const;
163 virtual int GetScrollPage(int nOrient
) const;
168 // Handle a control command
169 virtual void OnCommand( wxWindow
& rWin
170 ,wxCommandEvent
& rEvent
173 // Override to define new behaviour for default action (e.g. double
174 // clicking on a listbox)
175 virtual void OnDefaultAction(wxControl
* WXUNUSED(pInitiatingItem
)) { }
176 #endif // WXWIN_COMPATIBILITY
178 #if wxUSE_CARET && WXWIN_COMPATIBILITY
179 void CreateCaret( int nWidth
182 void CreateCaret(const wxBitmap
* pBitmap
);
183 void DestroyCaret(void);
184 void ShowCaret(bool bShow
);
185 void SetCaretPos( int nX
188 void GetCaretPos( int* pX
191 #endif // wxUSE_CARET
193 #ifndef __WXUNIVERSAL__
194 // Native resource loading (implemented in src/os2/nativdlg.cpp)
195 // FIXME: should they really be all virtual?
196 virtual bool LoadNativeDialog( wxWindow
* pParent
199 virtual bool LoadNativeDialog( wxWindow
* pParent
200 ,const wxString
& rName
202 wxWindow
* GetWindowChild1(wxWindowID vId
);
203 wxWindow
* GetWindowChild(wxWindowID vId
);
204 #endif //__WXUNIVERSAL__
206 // implementation from now on
207 // --------------------------
212 WXHWND
GetHWND(void) const { return m_hWnd
; }
213 void SetHWND(WXHWND hWnd
) { m_hWnd
= hWnd
; }
214 virtual WXWidget
GetHandle(void) const { return GetHWND(); }
215 bool GetUseCtl3D(void) const { return m_bUseCtl3D
; }
216 bool GetTransparentBackground(void) const { return m_bBackgroundTransparent
; }
217 void SetTransparent(bool bT
= TRUE
) { m_bBackgroundTransparent
= bT
; }
221 void OnSetFocus(wxFocusEvent
& rEvent
);
222 void OnEraseBackground(wxEraseEvent
& rEvent
);
223 void OnIdle(wxIdleEvent
& rEvent
);
226 // For implementation purposes - sometimes decorations make the client area
228 virtual wxPoint
GetClientAreaOrigin(void) const;
230 // Windows subclassing
231 void SubclassWin(WXHWND hWnd
);
232 void UnsubclassWin(void);
234 WXFARPROC
OS2GetOldWndProc(void) const { return m_fnOldWndProc
; }
235 void OS2SetOldWndProc(WXFARPROC fnProc
) { m_fnOldWndProc
= fnProc
; }
237 wxWindow
* FindItem(long lId
) const;
238 wxWindow
* FindItemByHWND( WXHWND hWnd
239 ,bool bControlOnly
= FALSE
242 // Make a Windows extended style from the given wxWindows window style ?? applicable to OS/2??
243 static WXDWORD
MakeExtendedStyle( long lStyle
244 ,bool bEliminateBorders
= TRUE
246 // Determine whether 3D effects are wanted
247 WXDWORD
Determine3DEffects( WXDWORD dwDefaultBorderStyle
251 // PM only: TRUE if this control is part of the main control
252 virtual bool ContainsHWND(WXHWND
WXUNUSED(hWnd
)) const { return FALSE
; };
254 // returns TRUE if the window has been created
255 bool OS2Create( PSZ zClass
264 virtual bool OS2Command( WXUINT uParam
268 #if WXWIN_COMPATIBILITY
269 wxObject
* GetChild(int nNumber
) const;
270 virtual void OS2DeviceToLogical( float* pfX
273 #endif // WXWIN_COMPATIBILITY
275 #ifndef __WXUNIVERSAL__
276 // Create an appropriate wxWindow from a HWND
277 virtual wxWindow
* CreateWindowFromHWND( wxWindow
* pParent
281 // Make sure the window style reflects the HWND style (roughly)
282 virtual void AdoptAttributesFromHWND(void);
285 // Setup background and foreground colours correctly
286 virtual void SetupColours(void);
288 // ------------------------------------------------------------------------
289 // helpers for message handlers: these perform the same function as the
290 // message crackers from <windowsx.h> - they unpack WPARAM and LPARAM into
291 // the correct parameters
292 // ------------------------------------------------------------------------
294 void UnpackCommand( WXWPARAM wParam
300 void UnpackActivate( WXWPARAM wParam
305 void UnpackScroll( WXWPARAM wParam
311 void UnpackMenuSelect( WXWPARAM wParam
318 // ------------------------------------------------------------------------
319 // internal handlers for OS2 messages: all handlers return a boolen value:
320 // TRUE means that the handler processed the event and FALSE that it didn't
321 // ------------------------------------------------------------------------
323 // there are several cases where we have virtual functions for PM
324 // message processing: this is because these messages often require to be
325 // processed in a different manner in the derived classes. For all other
326 // messages, however, we do *not* have corresponding OS2OnXXX() function
327 // and if the derived class wants to process them, it should override
328 // OS2WindowProc() directly.
330 // scroll event (both horizontal and vertical)
331 virtual bool OS2OnScroll( int nOrientation
337 // owner-drawn controls need to process these messages
338 virtual bool OS2OnDrawItem( int nId
339 ,WXDRAWITEMSTRUCT
* pItem
341 virtual bool OS2OnMeasureItem( int nId
342 ,WXMEASUREITEMSTRUCT
* pItem
345 // the rest are not virtual
346 bool HandleCreate( WXLPCREATESTRUCT vCs
349 bool HandleInitDialog(WXHWND hWndFocus
);
350 bool HandleDestroy(void);
351 bool HandlePaint(void);
352 bool HandleEraseBkgnd(WXHDC vDC
);
353 bool HandleMinimize(void);
354 bool HandleMaximize(void);
355 bool HandleSize( int nX
359 bool HandleGetMinMaxInfo(PSWP pMmInfo
);
360 bool HandleShow( bool bShow
363 bool HandleActivate( int nFlag
366 bool HandleCommand( WXWORD nId
370 bool HandleSysCommand( WXWPARAM wParam
373 bool HandlePaletteChanged();
374 bool HandleSysColorChange(void);
375 bool HandleCtlColor(WXHBRUSH
* hBrush
);
376 bool HandleSetFocus(WXHWND hWnd
);
377 bool HandleKillFocus(WXHWND hWnd
);
378 bool HandleEndDrag(WXWPARAM wParam
);
379 bool HandleMouseEvent( WXUINT uMsg
384 bool HandleMouseMove( int nX
388 bool HandleChar( WXDWORD wParam
390 ,bool bIsASCII
= FALSE
392 bool HandleKeyDown( WXWORD wParam
395 bool HandleKeyUp( WXDWORD wParam
398 bool HandleQueryDragIcon(WXHICON
* phIcon
);
399 bool HandleSetCursor( USHORT vId
403 bool IsMouseInWindow(void) const;
404 bool OS2GetCreateWindowCoords( const wxPoint
& rPos
413 virtual MRESULT
OS2WindowProc( WXUINT uMsg
418 // Calls an appropriate default window procedure
419 virtual MRESULT
OS2DefWindowProc( WXUINT uMsg
423 virtual bool OS2ProcessMessage(WXMSG
* pMsg
);
424 virtual bool OS2ShouldPreProcessMessage(WXMSG
* pMsg
);
425 virtual bool OS2TranslateMessage(WXMSG
* pMsg
);
426 virtual void OS2DestroyWindow(void);
428 // this function should return the brush to paint the window background
429 // with or 0 for the default brush
430 virtual WXHBRUSH
OnCtlColor( WXHDC hDC
438 #if WXWIN_COMPATIBILITY
439 void SetShowing(bool bShow
) { (void)Show(show
); }
440 bool IsUserEnabled(void) const { return IsEnabled(); }
441 #endif // WXWIN_COMPATIBILITY
443 // Responds to colour changes: passes event on to children.
444 void OnSysColourChanged(wxSysColourChangedEvent
& rEvent
);
446 // initialize various fields of wxMouseEvent (common part of OS2OnMouseXXX)
447 void InitMouseEvent( wxMouseEvent
& rEvent
453 void MoveChildren(int nDiff
);
456 // PM can't create some MSW styles natively but can perform these after
457 // creation by sending messages
458 typedef enum extra_flags
{ kFrameToolWindow
= 0x0001
459 ,kVertCaption
= 0x0002
460 ,kHorzCaption
= 0x0004
462 // Some internal sizeing id's to make it easy for event handlers
463 typedef enum size_types
{ kSizeNormal
470 // the old window proc (we subclass all windows)
471 WXFARPROC m_fnOldWndProc
;
473 // additional (OS2 specific) flags
474 bool m_bUseCtl3D
:1; // Using CTL3D for this control
475 bool m_bBackgroundTransparent
:1;
476 bool m_bMouseInWindow
:1;
477 bool m_bDoubleClickAllowed
:1;
478 bool m_bWinCaptured
:1;
481 // the size of one page for scrolling
485 #if wxUSE_MOUSEEVENT_HACK
486 // the coordinates of the last mouse event and the type of it
489 int m_nLastMouseEvent
;
490 #endif // wxUSE_MOUSEEVENT_HACK
492 WXHMENU m_hMenu
; // Menu, if any
493 unsigned long m_ulMenubarId
; // it's Id, if any
495 // the return value of WM_GETDLGCODE handler
498 // implement the base class pure virtuals
499 virtual void DoClientToScreen( int* pX
502 virtual void DoScreenToClient( int* pX
505 virtual void DoGetPosition( int* pX
508 virtual void DoGetSize( int* pWidth
511 virtual void DoGetClientSize( int* pWidth
514 virtual void DoSetSize( int nX
518 ,int nSizeFlags
= wxSIZE_AUTO
520 virtual void DoSetClientSize( int nWidth
524 virtual void DoCaptureMouse(void);
525 virtual void DoReleaseMouse(void);
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