]>
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 // 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 void SetFocusFromKbd(void);
99 virtual bool Reparent(wxWindow
* pNewParent
);
100 virtual void WarpPointer( int x
103 virtual void Refresh( bool bEraseBackground
= TRUE
104 ,const wxRect
* pRect
= (const wxRect
*)NULL
106 virtual void Freeze(void);
107 virtual void Update(void);
108 virtual void Thaw(void);
109 virtual void SetWindowStyleFlag(long lStyle
);
110 virtual bool SetCursor(const wxCursor
& rCursor
);
111 virtual bool SetFont(const wxFont
& rFont
);
112 virtual int GetCharHeight(void) const;
113 virtual int GetCharWidth(void) const;
114 virtual void GetTextExtent( const wxString
& rString
117 ,int* pDescent
= (int *)NULL
118 ,int* pExternalLeading
= (int *)NULL
119 ,const wxFont
* pTheFont
= (const wxFont
*)NULL
121 #if wxUSE_MENUS_NATIVE
122 virtual bool DoPopupMenu( wxMenu
* pMenu
126 #endif // wxUSE_MENUS_NATIVE
128 virtual void SetScrollbar( int nOrient
132 ,bool bRefresh
= TRUE
134 virtual void SetScrollPos( int nOrient
136 ,bool bRefresh
= TRUE
138 virtual int GetScrollPos(int nOrient
) const;
139 virtual int GetScrollThumb(int nOrient
) const;
140 virtual int GetScrollRange(int nOrient
) const;
141 virtual void ScrollWindow( int nDx
143 ,const wxRect
* pRect
= (wxRect
*)NULL
146 inline HWND
GetScrollBarHorz(void) const {return m_hWndScrollBarHorz
;}
147 inline HWND
GetScrollBarVert(void) const {return m_hWndScrollBarVert
;};
148 #if wxUSE_DRAG_AND_DROP
149 virtual void SetDropTarget(wxDropTarget
* pDropTarget
);
150 #endif // wxUSE_DRAG_AND_DROP
152 // Accept files for dragging
153 virtual void DragAcceptFiles(bool bAccept
);
155 #ifndef __WXUNIVERSAL__
156 // Native resource loading (implemented in src/os2/nativdlg.cpp)
157 // FIXME: should they really be all virtual?
158 virtual bool LoadNativeDialog( wxWindow
* pParent
161 virtual bool LoadNativeDialog( wxWindow
* pParent
162 ,const wxString
& rName
164 wxWindow
* GetWindowChild1(wxWindowID vId
);
165 wxWindow
* GetWindowChild(wxWindowID vId
);
166 #endif //__WXUNIVERSAL__
168 // implementation from now on
169 // --------------------------
174 WXHWND
GetHWND(void) const { return m_hWnd
; }
175 void SetHWND(WXHWND hWnd
) { m_hWnd
= hWnd
; }
176 virtual WXWidget
GetHandle(void) const { return GetHWND(); }
177 bool GetUseCtl3D(void) const { return m_bUseCtl3D
; }
178 bool GetTransparentBackground(void) const { return m_bBackgroundTransparent
; }
179 void SetTransparent(bool bT
= TRUE
) { m_bBackgroundTransparent
= bT
; }
183 void OnSetFocus(wxFocusEvent
& rEvent
);
184 void OnEraseBackground(wxEraseEvent
& rEvent
);
185 void OnIdle(wxIdleEvent
& rEvent
);
189 // For implementation purposes - sometimes decorations make the client area
191 virtual wxPoint
GetClientAreaOrigin(void) const;
193 // Windows subclassing
194 void SubclassWin(WXHWND hWnd
);
195 void UnsubclassWin(void);
197 WXFARPROC
OS2GetOldWndProc(void) const { return m_fnOldWndProc
; }
198 void OS2SetOldWndProc(WXFARPROC fnProc
) { m_fnOldWndProc
= fnProc
; }
200 // Return TRUE if the window is of a standard (i.e. not wxWindows') class
202 bool IsOfStandardClass(void) const { return m_fnOldWndProc
!= NULL
; }
204 wxWindow
* FindItem(long lId
) const;
205 wxWindow
* FindItemByHWND( WXHWND hWnd
206 ,bool bControlOnly
= FALSE
209 // Make a Windows extended style from the given wxWindows window style ?? applicable to OS/2??
210 static WXDWORD
MakeExtendedStyle( long lStyle
211 ,bool bEliminateBorders
= TRUE
214 // PM only: TRUE if this control is part of the main control
215 virtual bool ContainsHWND(WXHWND
WXUNUSED(hWnd
)) const { return FALSE
; };
217 // translate wxWindows style flags for this control into the PM style
218 // and optional extended style for the corresponding native control
220 // this is the function that should be overridden in the derived classes,
221 // but you will mostly use OS2GetCreateWindowFlags() below
222 virtual WXDWORD
OS2GetStyle( long lFlags
223 ,WXDWORD
* pdwExstyle
= NULL
226 // get the MSW window flags corresponding to wxWindows ones
228 // the functions returns the flags (WS_XXX) directly and puts the ext
229 // (WS_EX_XXX) flags into the provided pointer if not NULL
230 WXDWORD
OS2GetCreateWindowFlags(WXDWORD
* pdwExflags
= NULL
) const
231 { return OS2GetStyle(GetWindowStyle(), pdwExflags
); }
234 // get the HWND to be used as parent of this window with CreateWindow()
235 virtual WXHWND
OS2GetParent(void) const;
237 // returns TRUE if the window has been created
238 bool OS2Create( PSZ zClass
247 virtual bool OS2Command( WXUINT uParam
251 #ifndef __WXUNIVERSAL__
252 // Create an appropriate wxWindow from a HWND
253 virtual wxWindow
* CreateWindowFromHWND( wxWindow
* pParent
257 // Make sure the window style reflects the HWND style (roughly)
258 virtual void AdoptAttributesFromHWND(void);
261 // Setup background and foreground colours correctly
262 virtual void SetupColours(void);
264 // ------------------------------------------------------------------------
265 // helpers for message handlers: these perform the same function as the
266 // message crackers from <windowsx.h> - they unpack WPARAM and LPARAM into
267 // the correct parameters
268 // ------------------------------------------------------------------------
270 void UnpackCommand( WXWPARAM wParam
276 void UnpackActivate( WXWPARAM wParam
281 void UnpackScroll( WXWPARAM wParam
287 void UnpackMenuSelect( WXWPARAM wParam
294 // ------------------------------------------------------------------------
295 // internal handlers for OS2 messages: all handlers return a boolen value:
296 // TRUE means that the handler processed the event and FALSE that it didn't
297 // ------------------------------------------------------------------------
299 // there are several cases where we have virtual functions for PM
300 // message processing: this is because these messages often require to be
301 // processed in a different manner in the derived classes. For all other
302 // messages, however, we do *not* have corresponding OS2OnXXX() function
303 // and if the derived class wants to process them, it should override
304 // OS2WindowProc() directly.
306 // scroll event (both horizontal and vertical)
307 virtual bool OS2OnScroll( int nOrientation
313 // owner-drawn controls need to process these messages
314 virtual bool OS2OnDrawItem( int nId
315 ,WXDRAWITEMSTRUCT
* pItem
317 virtual long OS2OnMeasureItem( int nId
318 ,WXMEASUREITEMSTRUCT
* pItem
321 virtual void OnPaint(wxPaintEvent
& rEvent
);
323 // the rest are not virtual
324 bool HandleCreate( WXLPCREATESTRUCT vCs
327 bool HandleInitDialog(WXHWND hWndFocus
);
328 bool HandleDestroy(void);
329 bool HandlePaint(void);
330 bool HandleEraseBkgnd(WXHDC vDC
);
331 bool HandleMinimize(void);
332 bool HandleMaximize(void);
333 bool HandleSize( int nX
337 bool HandleGetMinMaxInfo(PSWP pMmInfo
);
338 bool HandleShow( bool bShow
341 bool HandleActivate( int nFlag
344 bool HandleCommand( WXWORD nId
348 bool HandleSysCommand( WXWPARAM wParam
351 bool HandlePaletteChanged(void);
352 bool HandleQueryNewPalette(void);
353 bool HandleSysColorChange(void);
354 bool HandleDisplayChange(void);
355 bool HandleCaptureChanged(WXHWND hBainedCapture
);
357 bool HandleCtlColor(WXHBRUSH
* hBrush
);
358 bool HandleSetFocus(WXHWND hWnd
);
359 bool HandleKillFocus(WXHWND hWnd
);
360 bool HandleEndDrag(WXWPARAM wParam
);
361 bool HandleMouseEvent( WXUINT uMsg
366 bool HandleMouseMove( int nX
370 bool HandleChar( WXWPARAM wParam
372 ,bool bIsASCII
= FALSE
374 bool HandleKeyDown( WXWPARAM wParam
377 bool HandleKeyUp( WXWPARAM wParam
380 bool HandleQueryDragIcon(WXHICON
* phIcon
);
381 bool HandleSetCursor( USHORT vId
385 bool IsMouseInWindow(void) const;
386 bool OS2GetCreateWindowCoords( const wxPoint
& rPos
395 virtual MRESULT
OS2WindowProc( WXUINT uMsg
400 // Calls an appropriate default window procedure
401 virtual MRESULT
OS2DefWindowProc( WXUINT uMsg
405 virtual bool OS2ProcessMessage(WXMSG
* pMsg
);
406 virtual bool OS2ShouldPreProcessMessage(WXMSG
* pMsg
);
407 virtual bool OS2TranslateMessage(WXMSG
* pMsg
);
408 virtual void OS2DestroyWindow(void);
410 // this function should return the brush to paint the window background
411 // with or 0 for the default brush
412 virtual WXHBRUSH
OnCtlColor( WXHDC hDC
420 // Responds to colour changes: passes event on to children.
421 void OnSysColourChanged(wxSysColourChangedEvent
& rEvent
);
423 // initialize various fields of wxMouseEvent (common part of OS2OnMouseXXX)
424 void InitMouseEvent( wxMouseEvent
& rEvent
430 void MoveChildren(int nDiff
);
431 PSWP
GetSwp(void) {return &m_vWinSwp
;}
434 // PM can't create some MSW styles natively but can perform these after
435 // creation by sending messages
436 typedef enum extra_flags
{ kFrameToolWindow
= 0x0001
437 ,kVertCaption
= 0x0002
438 ,kHorzCaption
= 0x0004
440 // Some internal sizeing id's to make it easy for event handlers
441 typedef enum size_types
{ kSizeNormal
448 // the old window proc (we subclass all windows)
449 WXFARPROC m_fnOldWndProc
;
451 // additional (OS2 specific) flags
452 bool m_bUseCtl3D
:1; // Using CTL3D for this control
453 bool m_bBackgroundTransparent
:1;
454 bool m_bMouseInWindow
:1;
455 bool m_bLastKeydownProcessed
:1;
456 bool m_bWinCaptured
:1;
459 // the size of one page for scrolling
463 #if wxUSE_MOUSEEVENT_HACK
464 // the coordinates of the last mouse event and the type of it
467 int m_nLastMouseEvent
;
468 #endif // wxUSE_MOUSEEVENT_HACK
470 WXHMENU m_hMenu
; // Menu, if any
471 unsigned long m_ulMenubarId
; // it's Id, if any
473 // the return value of WM_GETDLGCODE handler
476 // implement the base class pure virtuals
477 virtual void DoClientToScreen( int* pX
480 virtual void DoScreenToClient( int* pX
483 virtual void DoGetPosition( int* pX
486 virtual void DoGetSize( int* pWidth
489 virtual void DoGetClientSize( int* pWidth
492 virtual void DoSetSize( int nX
496 ,int nSizeFlags
= wxSIZE_AUTO
498 virtual void DoSetClientSize( int nWidth
502 virtual void DoCaptureMouse(void);
503 virtual void DoReleaseMouse(void);
505 // move the window to the specified location and resize it: this is called
506 // from both DoSetSize() and DoSetClientSize() and would usually just call
507 // ::WinSetWindowPos() except for composite controls which will want to arrange
508 // themselves inside the given rectangle
509 virtual void DoMoveWindow( int nX
516 virtual void DoSetToolTip(wxToolTip
* pTip
);
517 #endif // wxUSE_TOOLTIPS
519 int GetOS2ParentHeight(wxWindowOS2
* pParent
);
522 // common part of all ctors
525 // the (non-virtual) handlers for the events
526 bool HandleMove( int nX
529 bool HandleJoystickEvent( WXUINT uMsg
535 bool HandleNotify( int nIdCtrl
539 // the helper functions used by HandleChar/KeyXXX methods
540 wxKeyEvent
CreateKeyEvent( wxEventType evType
546 wxWindowList
* m_pChildrenDisabled
;
547 HWND m_hWndScrollBarHorz
;
548 HWND m_hWndScrollBarVert
;
551 DECLARE_DYNAMIC_CLASS(wxWindowOS2
);
552 DECLARE_NO_COPY_CLASS(wxWindowOS2
)
553 DECLARE_EVENT_TABLE()
556 // Virtual function hiding supression
558 inline virtual bool Reparent(wxWindowBase
* pNewParent
)
559 { return(wxWindowBase::Reparent(pNewParent
));}
560 }; // end of wxWindow
562 class wxWindowCreationHook
565 wxWindowCreationHook(wxWindow
* pWinBeingCreated
);
566 ~wxWindowCreationHook();
567 }; // end of CLASS wxWindowCreationHook
569 // ---------------------------------------------------------------------------
571 // ---------------------------------------------------------------------------
573 // kbd code translation
574 WXDLLEXPORT
int wxCharCodeOS2ToWX(int nKeySym
);
575 WXDLLEXPORT
int wxCharCodeWXToOS2( int nId