]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/window.h
typo in style definition fixed
[wxWidgets.git] / include / wx / os2 / window.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: window.h
3 // Purpose: wxWindow class
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/12/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_WINDOW_H_
13 #define _WX_WINDOW_H_
14
15 #define wxUSE_MOUSEEVENT_HACK 0
16
17 // ---------------------------------------------------------------------------
18 // headers
19 // ---------------------------------------------------------------------------
20 #define INCL_DOS
21 #define INCL_PM
22 #define INCL_GPI
23 #include <os2.h>
24
25
26 // ---------------------------------------------------------------------------
27 // forward declarations
28 // ---------------------------------------------------------------------------
29 #ifndef CW_USEDEFAULT
30 # define CW_USEDEFAULT ((int)0x80000000)
31 #endif
32
33 // ---------------------------------------------------------------------------
34 // forward declarations
35 // ---------------------------------------------------------------------------
36
37 class WXDLLEXPORT wxButton;
38
39 // ---------------------------------------------------------------------------
40 // constants
41 // ---------------------------------------------------------------------------
42
43 // FIXME does anybody use those? they're unused by wxWindows...
44 enum
45 {
46 wxKEY_SHIFT = 1,
47 wxKEY_CTRL = 2
48 };
49
50 // ---------------------------------------------------------------------------
51 // wxWindow declaration for OS/2 PM
52 // ---------------------------------------------------------------------------
53
54 class WXDLLEXPORT wxWindowOS2 : public wxWindowBase
55 {
56 public:
57 wxWindowOS2()
58 {
59 Init();
60 }
61
62 wxWindowOS2( wxWindow* pParent
63 ,wxWindowID vId
64 ,const wxPoint& rPos = wxDefaultPosition
65 ,const wxSize& rSize = wxDefaultSize
66 ,long lStyle = 0
67 ,const wxString& rName = wxPanelNameStr
68 )
69 {
70 Init();
71 Create( pParent
72 ,vId
73 ,rPos
74 ,rSize
75 ,lStyle
76 ,rName
77 );
78 }
79
80 virtual ~wxWindowOS2();
81
82 bool Create( wxWindow* pParent
83 ,wxWindowID vId
84 ,const wxPoint& rPos = wxDefaultPosition
85 ,const wxSize& rSize = wxDefaultSize
86 ,long lStyle = 0
87 ,const wxString& rName = wxPanelNameStr
88 );
89
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
100 ,int y
101 );
102 virtual void Refresh( bool bEraseBackground = TRUE
103 ,const wxRect* pRect = (const wxRect *)NULL
104 );
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
114 ,int* pX
115 ,int* pY
116 ,int* pDescent = (int *)NULL
117 ,int* pExternalLeading = (int *)NULL
118 ,const wxFont* pTheFont = (const wxFont *)NULL
119 ) const;
120 #if wxUSE_MENUS_NATIVE
121 virtual bool DoPopupMenu( wxMenu* pMenu
122 ,int nX
123 ,int nY
124 );
125 #endif // wxUSE_MENUS_NATIVE
126
127 virtual void SetScrollbar( int nOrient
128 ,int nPos
129 ,int nThumbVisible
130 ,int nRange
131 ,bool bRefresh = TRUE
132 );
133 virtual void SetScrollPos( int nOrient
134 ,int nPos
135 ,bool bRefresh = TRUE
136 );
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
141 ,int nDy
142 ,const wxRect* pRect = (wxRect *)NULL
143 );
144
145 inline HWND GetScrollBarHorz(void) const {return m_hWndScrollBarHorz;}
146 inline HWND GetScrollBarVert(void) const {return m_hWndScrollBarVert;};
147 #if wxUSE_DRAG_AND_DROP
148 virtual void SetDropTarget(wxDropTarget* pDropTarget);
149 #endif // wxUSE_DRAG_AND_DROP
150
151 // Accept files for dragging
152 virtual void DragAcceptFiles(bool bAccept);
153
154 #if WXWIN_COMPATIBILITY
155 // Set/get scroll attributes
156 virtual void SetScrollRange( int nOrient
157 ,int nRange
158 ,bool bRefresh = TRUE
159 );
160 virtual void SetScrollPage( int nOrient
161 ,int nPage
162 ,bool bRefresh = TRUE
163 );
164 virtual int OldGetScrollRange(int nOrient) const;
165 virtual int GetScrollPage(int nOrient) const;
166
167 //
168 // event handlers
169 //
170 // Handle a control command
171 virtual void OnCommand( wxWindow& rWin
172 ,wxCommandEvent& rEvent
173 );
174
175 // Override to define new behaviour for default action (e.g. double
176 // clicking on a listbox)
177 virtual void OnDefaultAction(wxControl* WXUNUSED(pInitiatingItem)) { }
178 #endif // WXWIN_COMPATIBILITY
179
180 #if wxUSE_CARET && WXWIN_COMPATIBILITY
181 void CreateCaret( int nWidth
182 ,int nHeight
183 );
184 void CreateCaret(const wxBitmap* pBitmap);
185 void DestroyCaret(void);
186 void ShowCaret(bool bShow);
187 void SetCaretPos( int nX
188 ,int nY
189 );
190 void GetCaretPos( int* pX
191 ,int* pY
192 ) const;
193 #endif // wxUSE_CARET
194
195 #ifndef __WXUNIVERSAL__
196 // Native resource loading (implemented in src/os2/nativdlg.cpp)
197 // FIXME: should they really be all virtual?
198 virtual bool LoadNativeDialog( wxWindow* pParent
199 ,wxWindowID& vId
200 );
201 virtual bool LoadNativeDialog( wxWindow* pParent
202 ,const wxString& rName
203 );
204 wxWindow* GetWindowChild1(wxWindowID vId);
205 wxWindow* GetWindowChild(wxWindowID vId);
206 #endif //__WXUNIVERSAL__
207
208 // implementation from now on
209 // --------------------------
210
211 // simple accessors
212 // ----------------
213
214 WXHWND GetHWND(void) const { return m_hWnd; }
215 void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
216 virtual WXWidget GetHandle(void) const { return GetHWND(); }
217 bool GetUseCtl3D(void) const { return m_bUseCtl3D; }
218 bool GetTransparentBackground(void) const { return m_bBackgroundTransparent; }
219 void SetTransparent(bool bT = TRUE) { m_bBackgroundTransparent = bT; }
220
221 // event handlers
222 // --------------
223 void OnSetFocus(wxFocusEvent& rEvent);
224 void OnEraseBackground(wxEraseEvent& rEvent);
225 void OnIdle(wxIdleEvent& rEvent);
226
227 public:
228 // For implementation purposes - sometimes decorations make the client area
229 // smaller
230 virtual wxPoint GetClientAreaOrigin(void) const;
231
232 // Windows subclassing
233 void SubclassWin(WXHWND hWnd);
234 void UnsubclassWin(void);
235
236 WXFARPROC OS2GetOldWndProc(void) const { return m_fnOldWndProc; }
237 void OS2SetOldWndProc(WXFARPROC fnProc) { m_fnOldWndProc = fnProc; }
238
239 wxWindow* FindItem(long lId) const;
240 wxWindow* FindItemByHWND( WXHWND hWnd
241 ,bool bControlOnly = FALSE
242 ) const;
243
244 // Make a Windows extended style from the given wxWindows window style ?? applicable to OS/2??
245 static WXDWORD MakeExtendedStyle( long lStyle
246 ,bool bEliminateBorders = TRUE
247 );
248 // Determine whether 3D effects are wanted
249 WXDWORD Determine3DEffects( WXDWORD dwDefaultBorderStyle
250 ,bool* pbWant3D
251 ) const;
252
253 // PM only: TRUE if this control is part of the main control
254 virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; };
255
256 // returns TRUE if the window has been created
257 bool OS2Create( PSZ zClass
258 ,const char* zTitle
259 ,WXDWORD dwStyle
260 ,const wxPoint& rPos
261 ,const wxSize& rSize
262 ,void* pCtlData
263 ,WXDWORD dwExStyle
264 ,bool bIsChild
265 );
266 virtual bool OS2Command( WXUINT uParam
267 ,WXWORD nId
268 );
269
270 #if WXWIN_COMPATIBILITY
271 wxObject* GetChild(int nNumber) const;
272 virtual void OS2DeviceToLogical( float* pfX
273 ,float* pfY
274 ) const;
275 #endif // WXWIN_COMPATIBILITY
276
277 #ifndef __WXUNIVERSAL__
278 // Create an appropriate wxWindow from a HWND
279 virtual wxWindow* CreateWindowFromHWND( wxWindow* pParent
280 ,WXHWND hWnd
281 );
282
283 // Make sure the window style reflects the HWND style (roughly)
284 virtual void AdoptAttributesFromHWND(void);
285 #endif
286
287 // Setup background and foreground colours correctly
288 virtual void SetupColours(void);
289
290 // ------------------------------------------------------------------------
291 // helpers for message handlers: these perform the same function as the
292 // message crackers from <windowsx.h> - they unpack WPARAM and LPARAM into
293 // the correct parameters
294 // ------------------------------------------------------------------------
295
296 void UnpackCommand( WXWPARAM wParam
297 ,WXLPARAM lParam,
298 WXWORD* pId
299 ,WXHWND* pHwnd
300 ,WXWORD* pCmd
301 );
302 void UnpackActivate( WXWPARAM wParam
303 ,WXLPARAM lParam
304 ,WXWORD* pState
305 ,WXHWND* pHwnd
306 );
307 void UnpackScroll( WXWPARAM wParam
308 ,WXLPARAM lParam
309 ,WXWORD* pCode
310 ,WXWORD* pPos
311 ,WXHWND* pHwnd
312 );
313 void UnpackMenuSelect( WXWPARAM wParam
314 ,WXLPARAM lParam
315 ,WXWORD* pTtem
316 ,WXWORD* pFlags
317 ,WXHMENU* pHmenu
318 );
319
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 // ------------------------------------------------------------------------
324
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.
331
332 // scroll event (both horizontal and vertical)
333 virtual bool OS2OnScroll( int nOrientation
334 ,WXWORD nSBCode
335 ,WXWORD pos
336 ,WXHWND control
337 );
338
339 // owner-drawn controls need to process these messages
340 virtual bool OS2OnDrawItem( int nId
341 ,WXDRAWITEMSTRUCT* pItem
342 );
343 virtual bool OS2OnMeasureItem( int nId
344 ,WXMEASUREITEMSTRUCT* pItem
345 );
346
347 // the rest are not virtual
348 bool HandleCreate( WXLPCREATESTRUCT vCs
349 ,bool* pMayCreate
350 );
351 bool HandleInitDialog(WXHWND hWndFocus);
352 bool HandleDestroy(void);
353 bool HandlePaint(void);
354 bool HandleEraseBkgnd(WXHDC vDC);
355 bool HandleMinimize(void);
356 bool HandleMaximize(void);
357 bool HandleSize( int nX
358 ,int nY
359 ,WXUINT uFlag
360 );
361 bool HandleGetMinMaxInfo(PSWP pMmInfo);
362 bool HandleShow( bool bShow
363 ,int nStatus
364 );
365 bool HandleActivate( int nFlag
366 ,WXHWND hActivate
367 );
368 bool HandleCommand( WXWORD nId
369 ,WXWORD nCmd
370 ,WXHWND hControl
371 );
372 bool HandleSysCommand( WXWPARAM wParam
373 ,WXLPARAM lParam
374 );
375 bool HandlePaletteChanged();
376 bool HandleSysColorChange(void);
377 bool HandleCtlColor(WXHBRUSH* hBrush);
378 bool HandleSetFocus(WXHWND hWnd);
379 bool HandleKillFocus(WXHWND hWnd);
380 bool HandleEndDrag(WXWPARAM wParam);
381 bool HandleMouseEvent( WXUINT uMsg
382 ,int nX
383 ,int nY
384 ,WXUINT uFlags
385 );
386 bool HandleMouseMove( int nX
387 ,int nY
388 ,WXUINT uFlags
389 );
390 bool HandleChar( WXDWORD wParam
391 ,WXLPARAM lParam
392 ,bool bIsASCII = FALSE
393 );
394 bool HandleKeyDown( WXWORD wParam
395 ,WXLPARAM lParam
396 );
397 bool HandleKeyUp( WXDWORD wParam
398 ,WXLPARAM lParam
399 );
400 bool HandleQueryDragIcon(WXHICON* phIcon);
401 bool HandleSetCursor( USHORT vId
402 ,WXHWND hWnd
403 );
404
405 bool IsMouseInWindow(void) const;
406 bool OS2GetCreateWindowCoords( const wxPoint& rPos
407 ,const wxSize& rSize
408 ,int& rnX
409 ,int& rnY
410 ,int& rnWidth
411 ,int& rnHeight
412 ) const;
413
414 // Window procedure
415 virtual MRESULT OS2WindowProc( WXUINT uMsg
416 ,WXWPARAM wParam
417 ,WXLPARAM lParam
418 );
419
420 // Calls an appropriate default window procedure
421 virtual MRESULT OS2DefWindowProc( WXUINT uMsg
422 ,WXWPARAM wParam
423 ,WXLPARAM lParam
424 );
425 virtual bool OS2ProcessMessage(WXMSG* pMsg);
426 virtual bool OS2ShouldPreProcessMessage(WXMSG* pMsg);
427 virtual bool OS2TranslateMessage(WXMSG* pMsg);
428 virtual void OS2DestroyWindow(void);
429
430 // this function should return the brush to paint the window background
431 // with or 0 for the default brush
432 virtual WXHBRUSH OnCtlColor( WXHDC hDC
433 ,WXHWND hWnd
434 ,WXUINT uCtlColor
435 ,WXUINT uMessage
436 ,WXWPARAM wParam
437 ,WXLPARAM lParam
438 );
439
440 #if WXWIN_COMPATIBILITY
441 void SetShowing(bool bShow) { (void)Show(show); }
442 bool IsUserEnabled(void) const { return IsEnabled(); }
443 #endif // WXWIN_COMPATIBILITY
444
445 // Responds to colour changes: passes event on to children.
446 void OnSysColourChanged(wxSysColourChangedEvent& rEvent);
447
448 // initialize various fields of wxMouseEvent (common part of OS2OnMouseXXX)
449 void InitMouseEvent( wxMouseEvent& rEvent
450 ,int nX
451 ,int nY
452 ,WXUINT uFlags
453 );
454
455 void MoveChildren(int nDiff);
456 PSWP GetSwp(void) {return &m_vWinSwp;}
457
458 protected:
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
464 } EExtraFlags;
465 // Some internal sizeing id's to make it easy for event handlers
466 typedef enum size_types { kSizeNormal
467 ,kSizeMax
468 ,kSizeMin
469 } ESizeTypes;
470 // the window handle
471 WXHWND m_hWnd;
472
473 // the old window proc (we subclass all windows)
474 WXFARPROC m_fnOldWndProc;
475
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;
482 WXDWORD m_dwExStyle;
483
484 // the size of one page for scrolling
485 int m_nXThumbSize;
486 int m_nYThumbSize;
487
488 #if wxUSE_MOUSEEVENT_HACK
489 // the coordinates of the last mouse event and the type of it
490 long m_lLastMouseX,
491 long m_lLastMouseY;
492 int m_nLastMouseEvent;
493 #endif // wxUSE_MOUSEEVENT_HACK
494
495 WXHMENU m_hMenu; // Menu, if any
496 unsigned long m_ulMenubarId; // it's Id, if any
497
498 // the return value of WM_GETDLGCODE handler
499 long m_lDlgCode;
500
501 // implement the base class pure virtuals
502 virtual void DoClientToScreen( int* pX
503 ,int* pY
504 ) const;
505 virtual void DoScreenToClient( int* pX
506 ,int* pY
507 ) const;
508 virtual void DoGetPosition( int* pX
509 ,int* pY
510 ) const;
511 virtual void DoGetSize( int* pWidth
512 ,int* pHeight
513 ) const;
514 virtual void DoGetClientSize( int* pWidth
515 ,int* pHeight
516 ) const;
517 virtual void DoSetSize( int nX
518 ,int nY
519 ,int nWidth
520 ,int nHeight
521 ,int nSizeFlags = wxSIZE_AUTO
522 );
523 virtual void DoSetClientSize( int nWidth
524 ,int nHeight
525 );
526
527 virtual void DoCaptureMouse(void);
528 virtual void DoReleaseMouse(void);
529
530 // move the window to the specified location and resize it: this is called
531 // from both DoSetSize() and DoSetClientSize() and would usually just call
532 // ::WinSetWindowPos() except for composite controls which will want to arrange
533 // themselves inside the given rectangle
534 virtual void DoMoveWindow( int nX
535 ,int nY
536 ,int nWidth
537 ,int nHeight
538 );
539
540 #if wxUSE_TOOLTIPS
541 virtual void DoSetToolTip(wxToolTip* pTip);
542 #endif // wxUSE_TOOLTIPS
543
544 int GetOS2ParentHeight(wxWindowOS2* pParent);
545
546 private:
547 // common part of all ctors
548 void Init(void);
549
550 // the (non-virtual) handlers for the events
551 bool HandleMove( int nX
552 ,int nY
553 );
554 bool HandleJoystickEvent( WXUINT uMsg
555 ,int pX
556 ,int pY
557 ,WXUINT uFlags
558 );
559
560 bool HandleNotify( int nIdCtrl
561 ,WXLPARAM lParam
562 ,WXLPARAM* pResult
563 );
564 // the helper functions used by HandleChar/KeyXXX methods
565 wxKeyEvent CreateKeyEvent(wxEventType evType, int id, WXLPARAM lp) const;
566
567
568 DECLARE_DYNAMIC_CLASS(wxWindowOS2);
569 DECLARE_NO_COPY_CLASS(wxWindowOS2)
570 DECLARE_EVENT_TABLE()
571
572 private:
573 HWND m_hWndScrollBarHorz;
574 HWND m_hWndScrollBarVert;
575 SWP m_vWinSwp;
576
577 // Virtual function hiding supression
578 inline virtual bool Reparent(wxWindowBase* pNewParent)
579 { return(wxWindowBase::Reparent(pNewParent));};
580 }; // end of wxWindow
581
582 class wxWindowCreationHook
583 {
584 public:
585 wxWindowCreationHook(wxWindow* pWinBeingCreated);
586 ~wxWindowCreationHook();
587 }; // end of CLASS wxWindowCreationHook
588
589 // ---------------------------------------------------------------------------
590 // global functions
591 // ---------------------------------------------------------------------------
592
593 // kbd code translation
594 WXDLLEXPORT int wxCharCodeOS2ToWX(int nKeySym);
595 WXDLLEXPORT int wxCharCodeWXToOS2( int nId
596 ,bool* pbIsVirtual
597 );
598 #endif
599 // _WX_WINDOW_H_