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 wxWindow
: public wxWindowBase
49 DECLARE_DYNAMIC_CLASS(wxWindow
);
52 wxWindow() { Init(); }
54 wxWindow( wxWindow
* pParent
56 ,const wxPoint
& rPos
= wxDefaultPosition
57 ,const wxSize
& rSize
= wxDefaultSize
59 ,const wxString
& rName
= wxPanelNameStr
74 bool Create( wxWindow
* pParent
76 ,const wxPoint
& rPos
= wxDefaultPosition
77 ,const wxSize
& rSize
= wxDefaultSize
79 ,const wxString
& rName
= wxPanelNameStr
82 // implement base class pure virtuals
83 virtual void SetTitle(const wxString
& rTitle
);
84 virtual wxString
GetTitle(void) const;
85 virtual void Raise(void);
86 virtual void Lower(void);
87 virtual bool Show(bool bShow
= TRUE
);
88 virtual bool Enable(bool bEnable
= TRUE
);
89 virtual void SetFocus(void);
90 virtual bool Reparent(wxWindow
* pNewParent
);
91 virtual void WarpPointer( int x
94 virtual void CaptureMouse(void);
95 virtual void ReleaseMouse(void);
96 virtual void Refresh( bool bEraseBackground
= TRUE
97 ,const wxRect
* pRect
= (const wxRect
*)NULL
99 virtual void Clear(void);
100 virtual bool SetCursor(const wxCursor
& rCursor
);
101 virtual bool SetFont(const wxFont
& rFont
);
102 virtual int GetCharHeight(void) const;
103 virtual int GetCharWidth(void) const;
104 virtual void GetTextExtent( const wxString
& rString
107 ,int* pDescent
= (int *)NULL
108 ,int* pExternalLeading
= (int *)NULL
109 ,const wxFont
* pTheFont
= (const wxFont
*)NULL
111 virtual bool DoPopupMenu( wxMenu
* pMenu
116 virtual void SetScrollbar( int nOrient
120 ,bool bRefresh
= TRUE
122 virtual void SetScrollPos( int nOrient
124 ,bool bRefresh
= TRUE
126 virtual int GetScrollPos(int nOrient
) const;
127 virtual int GetScrollThumb(int nOrient
) const;
128 virtual int GetScrollRange(int nOrient
) const;
129 virtual void ScrollWindow( int nDx
131 ,const wxRect
* pRect
= (wxRect
*)NULL
134 #if wxUSE_DRAG_AND_DROP
135 virtual void SetDropTarget(wxDropTarget
* pDropTarget
);
136 #endif // wxUSE_DRAG_AND_DROP
138 // Accept files for dragging
139 virtual void DragAcceptFiles(bool bAccept
);
141 #if WXWIN_COMPATIBILITY
142 // Set/get scroll attributes
143 virtual void SetScrollRange( int nOrient
145 ,bool bRefresh
= TRUE
147 virtual void SetScrollPage( int nOrient
149 ,bool bRefresh
= TRUE
151 virtual int OldGetScrollRange(int nOrient
) const;
152 virtual int GetScrollPage(int nOrient
) const;
157 // Handle a control command
158 virtual void OnCommand( wxWindow
& rWin
159 ,wxCommandEvent
& rEvent
162 // Override to define new behaviour for default action (e.g. double
163 // clicking on a listbox)
164 virtual void OnDefaultAction(wxControl
* WXUNUSED(pInitiatingItem
)) { }
165 #endif // WXWIN_COMPATIBILITY
167 #if wxUSE_CARET && WXWIN_COMPATIBILITY
168 void CreateCaret( int nWidth
171 void CreateCaret(const wxBitmap
* pBitmap
);
172 void DestroyCaret(void);
173 void ShowCaret(bool bShow
);
174 void SetCaretPos( int nX
177 void GetCaretPos( int* pX
180 #endif // wxUSE_CARET
182 // Native resource loading (implemented in src/os2/nativdlg.cpp)
183 // FIXME: should they really be all virtual?
184 virtual bool LoadNativeDialog( wxWindow
* pParent
187 virtual bool LoadNativeDialog( wxWindow
* pParent
188 ,const wxString
& rName
190 wxWindow
* GetWindowChild1(wxWindowID vId
);
191 wxWindow
* GetWindowChild(wxWindowID vId
);
193 // implementation from now on
194 // --------------------------
199 WXHWND
GetHWND(void) const { return m_hWnd
; }
200 void SetHWND(WXHWND hWnd
) { m_hWnd
= hWnd
; }
201 virtual WXWidget
GetHandle(void) const { return GetHWND(); }
202 bool GetUseCtl3D(void) const { return m_bUseCtl3D
; }
203 bool GetTransparentBackground(void) const { return m_bBackgroundTransparent
; }
204 void SetTransparent(bool bT
= TRUE
) { m_bBackgroundTransparent
= bT
; }
208 void OnEraseBackground(wxEraseEvent
& rEvent
);
209 void OnIdle(wxIdleEvent
& rEvent
);
212 // For implementation purposes - sometimes decorations make the client area
214 virtual wxPoint
GetClientAreaOrigin(void) const;
216 // Makes an adjustment to the window position (for example, a frame that has
217 // a toolbar that it manages itself).
218 virtual void AdjustForParentClientOrigin( int& rX
223 // Windows subclassing
224 void SubclassWin(WXHWND hWnd
);
225 void UnsubclassWin(void);
227 WXFARPROC
OS2GetOldWndProc(void) const { return m_fnOldWndProc
; }
228 void OS2SetOldWndProc(WXFARPROC fnProc
) { m_fnOldWndProc
= fnProc
; }
230 wxWindow
* FindItem(long lId
) const;
231 wxWindow
* FindItemByHWND( WXHWND hWnd
232 ,bool bControlOnly
= FALSE
235 // Make a Windows extended style from the given wxWindows window style ?? applicable to OS/2??
236 static WXDWORD
MakeExtendedStyle( long lStyle
237 ,bool bEliminateBorders
= TRUE
239 // Determine whether 3D effects are wanted
240 WXDWORD
Determine3DEffects( WXDWORD dwDefaultBorderStyle
244 // PM only: TRUE if this control is part of the main control
245 virtual bool ContainsHWND(WXHWND
WXUNUSED(hWnd
)) const { return FALSE
; };
247 // returns TRUE if the window has been created
248 bool OS2Create( int nId
250 ,const wxChar
* zWclass
252 ,const wxChar
* zTitle
258 ,const wxChar
* zDialogTemplate
= NULL
259 ,WXDWORD dwExendedStyle
= 0
261 virtual bool OS2Command( WXUINT uParam
265 #if WXWIN_COMPATIBILITY
266 wxObject
* GetChild(int nNumber
) const;
267 virtual void OS2DeviceToLogical( float* pfX
270 #endif // WXWIN_COMPATIBILITY
272 // Create an appropriate wxWindow from a HWND
273 virtual wxWindow
* CreateWindowFromHWND( wxWindow
* pParent
277 // Make sure the window style reflects the HWND style (roughly)
278 virtual void AdoptAttributesFromHWND(void);
280 // Setup background and foreground colours correctly
281 virtual void SetupColours(void);
283 // ------------------------------------------------------------------------
284 // helpers for message handlers: these perform the same function as the
285 // message crackers from <windowsx.h> - they unpack WPARAM and LPARAM into
286 // the correct parameters
287 // ------------------------------------------------------------------------
289 void UnpackCommand( WXWPARAM wParam
295 void UnpackActivate( WXWPARAM wParam
301 void UnpackScroll( WXWPARAM wParam
307 void UnpackCtlColor( WXWPARAM wParam
313 void UnpackMenuSelect( WXWPARAM wParam
320 // ------------------------------------------------------------------------
321 // internal handlers for OS2 messages: all handlers return a boolen value:
322 // TRUE means that the handler processed the event and FALSE that it didn't
323 // ------------------------------------------------------------------------
325 // there are several cases where we have virtual functions for PM
326 // message processing: this is because these messages often require to be
327 // processed in a different manner in the derived classes. For all other
328 // messages, however, we do *not* have corresponding OS2OnXXX() function
329 // and if the derived class wants to process them, it should override
330 // OS2WindowProc() directly.
332 // scroll event (both horizontal and vertical)
333 virtual bool OS2OnScroll( int nOrientation
339 virtual bool OS2OnNotify( int nIdCtrl
344 // owner-drawn controls need to process these messages
345 virtual bool OS2OnDrawItem( int nId
346 ,WXDRAWITEMSTRUCT
* pItem
348 virtual bool OS2OnMeasureItem( int nId
349 ,WXMEASUREITEMSTRUCT
* pItem
352 // the rest are not virtual
353 bool HandleCreate( WXLPCREATESTRUCT vCs
356 bool HandleInitDialog(WXHWND hWndFocus
);
357 bool HandleDestroy(void);
358 bool HandlePaint(void);
359 bool HandleEraseBkgnd(WXHDC vDC
);
360 bool HandleMinimize(void);
361 bool HandleMaximize(void);
362 bool HandleSize( int nX
366 bool HandleGetMinMaxInfo(void* pMmInfo
);
367 bool HandleShow( bool bShow
370 bool HandleActivate( int nFlag
374 bool HandleCommand( WXWORD nId
378 bool HandleSysCommand( WXWPARAM wParam
381 bool HandleCtlColor( WXHBRUSH
* phBrush
389 bool HandlePaletteChanged(WXHWND hWndPalChange
);
390 bool HandleQueryNewPalette(void);
391 bool HandleSysColorChange(void);
392 bool HandleQueryEndSession( long lLogOff
395 bool HandleEndSession( bool bEndSession
398 bool HandleSetFocus(WXHWND hWnd
);
399 bool HandleKillFocus(WXHWND hWnd
);
400 bool HandleDropFiles(WXWPARAM wParam
);
401 bool HandleMouseEvent( WXUINT uMsg
406 bool HandleMouseMove( int nX
410 bool HandleChar( WXWORD wParam
412 ,bool bIsASCII
= FALSE
414 bool HandleKeyDown( WXWORD wParam
417 bool HandleKeyUp( WXWORD wParam
420 bool HandleQueryDragIcon(WXHICON
* phIcon
);
421 bool HandleSetCursor( WXHWND hWnd
427 virtual MRESULT
OS2WindowProc( HWND hwnd
433 // Calls an appropriate default window procedure
434 virtual MRESULT
OS2DefWindowProc( HWND hwnd
439 virtual bool OS2ProcessMessage(WXMSG
* pMsg
);
440 virtual bool OS2TranslateMessage(WXMSG
* pMsg
);
441 virtual void OS2DestroyWindow(void);
443 // Detach "Window" menu from menu bar so it doesn't get deleted
444 void OS2DetachWindowMenu(void);
446 // this function should return the brush to paint the window background
447 // with or 0 for the default brush
448 virtual WXHBRUSH
OnCtlColor( WXHDC hDC
456 #if WXWIN_COMPATIBILITY
457 void SetShowing(bool bShow
) { (void)Show(show
); }
458 bool IsUserEnabled(void) const { return IsEnabled(); }
459 #endif // WXWIN_COMPATIBILITY
461 // Responds to colour changes: passes event on to children.
462 void OnSysColourChanged(wxSysColourChangedEvent
& rEvent
);
464 // initialize various fields of wxMouseEvent (common part of OS2OnMouseXXX)
465 void InitMouseEvent( wxMouseEvent
& rEvent
475 // the old window proc (we subclass all windows)
476 WXFARPROC m_fnOldWndProc
;
478 // additional (MSW specific) flags
479 bool m_bUseCtl3D
:1; // Using CTL3D for this control
480 bool m_bBackgroundTransparent
:1;
481 bool m_bMouseInWindow
:1;
482 bool m_bDoubleClickAllowed
:1;
483 bool m_bWinCaptured
:1;
485 // the size of one page for scrolling
489 #if wxUSE_MOUSEEVENT_HACK
490 // the coordinates of the last mouse event and the type of it
493 int m_nLastMouseEvent
;
494 #endif // wxUSE_MOUSEEVENT_HACK
496 WXHMENU m_hMenu
; // Menu, if any
497 unsigned long m_ulMenubarId
; // it's Id, if any
499 // the return value of WM_GETDLGCODE handler
502 // implement the base class pure virtuals
503 virtual void DoClientToScreen( int* pX
506 virtual void DoScreenToClient( int* pX
509 virtual void DoGetPosition( int* pX
512 virtual void DoGetSize( int* pWidth
515 virtual void DoGetClientSize( int* pWidth
518 virtual void DoSetSize( int nX
522 ,int nSizeFlags
= wxSIZE_AUTO
524 virtual void DoSetClientSize( int nWidth
528 // move the window to the specified location and resize it: this is called
529 // from both DoSetSize() and DoSetClientSize() and would usually just call
530 // ::MoveWindow() except for composite controls which will want to arrange
531 // themselves inside the given rectangle
532 virtual void DoMoveWindow( int nX
539 virtual void DoSetToolTip(wxToolTip
* pTip
);
540 #endif // wxUSE_TOOLTIPS
543 // common part of all ctors
546 // the (non-virtual) handlers for the events
547 bool HandleMove( int nX
550 bool HandleJoystickEvent( WXUINT uMsg
556 bool HandleNotify( int nIdCtrl
560 DECLARE_NO_COPY_CLASS(wxWindow
);
561 DECLARE_EVENT_TABLE()
563 // Virtual function hiding supression
564 inline virtual bool Reparent(wxWindowBase
* pNewParent
)
565 { return(wxWindowBase::Reparent(pNewParent
));};
568 // ---------------------------------------------------------------------------
570 // ---------------------------------------------------------------------------
572 // kbd code translation
573 WXDLLEXPORT
int wxCharCodeOS2ToWX(int nKeySym
);
574 WXDLLEXPORT
int wxCharCodeWXToOS2( int nId