]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/window.h
compilation fix for recent commit
[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
30 class WXDLLEXPORT wxButton;
31
32 // ---------------------------------------------------------------------------
33 // constants
34 // ---------------------------------------------------------------------------
35
36 // FIXME does anybody use those? they're unused by wxWindows...
37 enum
38 {
39 wxKEY_SHIFT = 1,
40 wxKEY_CTRL = 2
41 };
42
43 // ---------------------------------------------------------------------------
44 // wxWindow declaration for OS/2 PM
45 // ---------------------------------------------------------------------------
46
47 class WXDLLEXPORT wxWindowOS2 : public wxWindowBase
48 {
49 public:
50 wxWindowOS2()
51 {
52 Init();
53 }
54
55 wxWindowOS2( wxWindow* pParent
56 ,wxWindowID vId
57 ,const wxPoint& rPos = wxDefaultPosition
58 ,const wxSize& rSize = wxDefaultSize
59 ,long lStyle = 0
60 ,const wxString& rName = wxPanelNameStr
61 )
62 {
63 Init();
64 Create( pParent
65 ,vId
66 ,rPos
67 ,rSize
68 ,lStyle
69 ,rName
70 );
71 }
72
73 virtual ~wxWindowOS2();
74
75 bool Create( wxWindow* pParent
76 ,wxWindowID vId
77 ,const wxPoint& rPos = wxDefaultPosition
78 ,const wxSize& rSize = wxDefaultSize
79 ,long lStyle = 0
80 ,const wxString& rName = wxPanelNameStr
81 );
82
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
93 ,int y
94 );
95 virtual void CaptureMouse(void);
96 virtual void ReleaseMouse(void);
97 virtual void Refresh( bool bEraseBackground = TRUE
98 ,const wxRect* pRect = (const wxRect *)NULL
99 );
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
109 ,int* pX
110 ,int* pY
111 ,int* pDescent = (int *)NULL
112 ,int* pExternalLeading = (int *)NULL
113 ,const wxFont* pTheFont = (const wxFont *)NULL
114 ) const;
115 #if wxUSE_MENUS_NATIVE
116 virtual bool DoPopupMenu( wxMenu* pMenu
117 ,int nX
118 ,int nY
119 );
120 #endif // wxUSE_MENUS_NATIVE
121
122 virtual void SetScrollbar( int nOrient
123 ,int nPos
124 ,int nThumbVisible
125 ,int nRange
126 ,bool bRefresh = TRUE
127 );
128 virtual void SetScrollPos( int nOrient
129 ,int nPos
130 ,bool bRefresh = TRUE
131 );
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
136 ,int nDy
137 ,const wxRect* pRect = (wxRect *)NULL
138 );
139
140 #if wxUSE_DRAG_AND_DROP
141 virtual void SetDropTarget(wxDropTarget* pDropTarget);
142 #endif // wxUSE_DRAG_AND_DROP
143
144 // Accept files for dragging
145 virtual void DragAcceptFiles(bool bAccept);
146
147 #if WXWIN_COMPATIBILITY
148 // Set/get scroll attributes
149 virtual void SetScrollRange( int nOrient
150 ,int nRange
151 ,bool bRefresh = TRUE
152 );
153 virtual void SetScrollPage( int nOrient
154 ,int nPage
155 ,bool bRefresh = TRUE
156 );
157 virtual int OldGetScrollRange(int nOrient) const;
158 virtual int GetScrollPage(int nOrient) const;
159
160 //
161 // event handlers
162 //
163 // Handle a control command
164 virtual void OnCommand( wxWindow& rWin
165 ,wxCommandEvent& rEvent
166 );
167
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
172
173 #if wxUSE_CARET && WXWIN_COMPATIBILITY
174 void CreateCaret( int nWidth
175 ,int nHeight
176 );
177 void CreateCaret(const wxBitmap* pBitmap);
178 void DestroyCaret(void);
179 void ShowCaret(bool bShow);
180 void SetCaretPos( int nX
181 ,int nY
182 );
183 void GetCaretPos( int* pX
184 ,int* pY
185 ) const;
186 #endif // wxUSE_CARET
187
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
192 ,wxWindowID& vId
193 );
194 virtual bool LoadNativeDialog( wxWindow* pParent
195 ,const wxString& rName
196 );
197 wxWindow* GetWindowChild1(wxWindowID vId);
198 wxWindow* GetWindowChild(wxWindowID vId);
199 #endif //__WXUNIVERSAL__
200
201 // implementation from now on
202 // --------------------------
203
204 // simple accessors
205 // ----------------
206
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; }
213
214 // event handlers
215 // --------------
216 void OnSetFocus(wxFocusEvent& rEvent);
217 void OnEraseBackground(wxEraseEvent& rEvent);
218 void OnIdle(wxIdleEvent& rEvent);
219
220 public:
221 // For implementation purposes - sometimes decorations make the client area
222 // smaller
223 virtual wxPoint GetClientAreaOrigin(void) const;
224
225 // Windows subclassing
226 void SubclassWin(WXHWND hWnd);
227 void UnsubclassWin(void);
228
229 WXFARPROC OS2GetOldWndProc(void) const { return m_fnOldWndProc; }
230 void OS2SetOldWndProc(WXFARPROC fnProc) { m_fnOldWndProc = fnProc; }
231
232 wxWindow* FindItem(long lId) const;
233 wxWindow* FindItemByHWND( WXHWND hWnd
234 ,bool bControlOnly = FALSE
235 ) const;
236
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
240 );
241 // Determine whether 3D effects are wanted
242 WXDWORD Determine3DEffects( WXDWORD dwDefaultBorderStyle
243 ,bool* pbWant3D
244 ) const;
245
246 // PM only: TRUE if this control is part of the main control
247 virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; };
248
249 // returns TRUE if the window has been created
250 bool OS2Create( WXHWND hParent
251 ,PSZ zClass
252 ,const wxChar* zTitle
253 ,WXDWORD dwStyle
254 ,long lX
255 ,long lY
256 ,long lWidth
257 ,long lHeight
258 ,WXHWND hOwner
259 ,WXHWND hZOrder
260 ,unsigned long lId
261 ,void* pCtlData = NULL
262 ,void* pPresParams = NULL
263 ,WXDWORD dwExStyle = 0L
264 );
265 virtual bool OS2Command( WXUINT uParam
266 ,WXWORD nId
267 );
268
269 #if WXWIN_COMPATIBILITY
270 wxObject* GetChild(int nNumber) const;
271 virtual void OS2DeviceToLogical( float* pfX
272 ,float* pfY
273 ) const;
274 #endif // WXWIN_COMPATIBILITY
275
276 #ifndef __WXUNIVERSAL__
277 // Create an appropriate wxWindow from a HWND
278 virtual wxWindow* CreateWindowFromHWND( wxWindow* pParent
279 ,WXHWND hWnd
280 );
281
282 // Make sure the window style reflects the HWND style (roughly)
283 virtual void AdoptAttributesFromHWND(void);
284 #endif
285
286 // Setup background and foreground colours correctly
287 virtual void SetupColours(void);
288
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 // ------------------------------------------------------------------------
294
295 void UnpackCommand( WXWPARAM wParam
296 ,WXLPARAM lParam,
297 WXWORD* pId
298 ,WXHWND* pHwnd
299 ,WXWORD* pCmd
300 );
301 void UnpackActivate( WXWPARAM wParam
302 ,WXLPARAM lParam
303 ,WXWORD* pState
304 ,WXHWND* pHwnd
305 );
306 void UnpackScroll( WXWPARAM wParam
307 ,WXLPARAM lParam
308 ,WXWORD* pCode
309 ,WXWORD* pPos
310 ,WXHWND* pHwnd
311 );
312 void UnpackMenuSelect( WXWPARAM wParam
313 ,WXLPARAM lParam
314 ,WXWORD* pTtem
315 ,WXWORD* pFlags
316 ,WXHMENU* pHmenu
317 );
318
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 // ------------------------------------------------------------------------
323
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.
330
331 // scroll event (both horizontal and vertical)
332 virtual bool OS2OnScroll( int nOrientation
333 ,WXWORD nSBCode
334 ,WXWORD pos
335 ,WXHWND control
336 );
337
338 // owner-drawn controls need to process these messages
339 virtual bool OS2OnDrawItem( int nId
340 ,WXDRAWITEMSTRUCT* pItem
341 );
342 virtual bool OS2OnMeasureItem( int nId
343 ,WXMEASUREITEMSTRUCT* pItem
344 );
345
346 // the rest are not virtual
347 bool HandleCreate( WXLPCREATESTRUCT vCs
348 ,bool* pMayCreate
349 );
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
357 ,int nY
358 ,WXUINT uFlag
359 );
360 bool HandleGetMinMaxInfo(PSWP pMmInfo);
361 bool HandleShow( bool bShow
362 ,int nStatus
363 );
364 bool HandleActivate( int nFlag
365 ,WXHWND hActivate
366 );
367 bool HandleCommand( WXWORD nId
368 ,WXWORD nCmd
369 ,WXHWND hControl
370 );
371 bool HandleSysCommand( WXWPARAM wParam
372 ,WXLPARAM lParam
373 );
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
381 ,int nX
382 ,int nY
383 ,WXUINT uFlags
384 );
385 bool HandleMouseMove( int nX
386 ,int nY
387 ,WXUINT uFlags
388 );
389 bool HandleChar( WXDWORD wParam
390 ,WXLPARAM lParam
391 ,bool bIsASCII = FALSE
392 );
393 bool HandleKeyDown( WXWORD wParam
394 ,WXLPARAM lParam
395 );
396 bool HandleKeyUp( WXDWORD wParam
397 ,WXLPARAM lParam
398 );
399 bool HandleQueryDragIcon(WXHICON* phIcon);
400 bool HandleSetCursor( USHORT vId
401 ,WXHWND hWnd
402 );
403
404 bool IsMouseInWindow(void) const;
405 bool OS2GetCreateWindowCoords( const wxPoint& rPos
406 ,const wxSize& rSize
407 ,int& rnX
408 ,int& rnY
409 ,int& rnWidth
410 ,int& rnHeight
411 ) const;
412
413 // Window procedure
414 virtual MRESULT OS2WindowProc( WXUINT uMsg
415 ,WXWPARAM wParam
416 ,WXLPARAM lParam
417 );
418
419 // Calls an appropriate default window procedure
420 virtual MRESULT OS2DefWindowProc( WXUINT uMsg
421 ,WXWPARAM wParam
422 ,WXLPARAM lParam
423 );
424 virtual bool OS2ProcessMessage(WXMSG* pMsg);
425 virtual bool OS2TranslateMessage(WXMSG* pMsg);
426 virtual void OS2DestroyWindow(void);
427
428 // Detach "Window" menu from menu bar so it doesn't get deleted
429 void OS2DetachWindowMenu(void);
430
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
434 ,WXHWND hWnd
435 ,WXUINT uCtlColor
436 ,WXUINT uMessage
437 ,WXWPARAM wParam
438 ,WXLPARAM lParam
439 );
440
441 #if WXWIN_COMPATIBILITY
442 void SetShowing(bool bShow) { (void)Show(show); }
443 bool IsUserEnabled(void) const { return IsEnabled(); }
444 #endif // WXWIN_COMPATIBILITY
445
446 // Responds to colour changes: passes event on to children.
447 void OnSysColourChanged(wxSysColourChangedEvent& rEvent);
448
449 // initialize various fields of wxMouseEvent (common part of OS2OnMouseXXX)
450 void InitMouseEvent( wxMouseEvent& rEvent
451 ,int nX
452 ,int nY
453 ,WXUINT uFlags
454 );
455
456 void MoveChildren(int nDiff);
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 // 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
532 ,int nY
533 ,int nWidth
534 ,int nHeight
535 );
536
537 #if wxUSE_TOOLTIPS
538 virtual void DoSetToolTip(wxToolTip* pTip);
539 #endif // wxUSE_TOOLTIPS
540
541 int GetOS2ParentHeight(wxWindowOS2* pParent);
542
543 private:
544 // common part of all ctors
545 void Init(void);
546
547 // the (non-virtual) handlers for the events
548 bool HandleMove( int nX
549 ,int nY
550 );
551 bool HandleJoystickEvent( WXUINT uMsg
552 ,int pX
553 ,int pY
554 ,WXUINT uFlags
555 );
556
557 bool HandleNotify( int nIdCtrl
558 ,WXLPARAM lParam
559 ,WXLPARAM* pResult
560 );
561 // the helper functions used by HandleChar/KeyXXX methods
562 wxKeyEvent CreateKeyEvent(wxEventType evType, int id, WXLPARAM lp) const;
563
564 DECLARE_DYNAMIC_CLASS(wxWindowOS2);
565 DECLARE_NO_COPY_CLASS(wxWindowOS2)
566 DECLARE_EVENT_TABLE()
567 private:
568 HWND m_hWndScrollBarHorz;
569 HWND m_hWndScrollBarVert;
570
571 // Virtual function hiding supression
572 inline virtual bool Reparent(wxWindowBase* pNewParent)
573 { return(wxWindowBase::Reparent(pNewParent));};
574 }; // end of wxWindow
575
576 class wxWindowCreationHook
577 {
578 public:
579 wxWindowCreationHook(wxWindow* pWinBeingCreated);
580 ~wxWindowCreationHook();
581 }; // end of CLASS wxWindowCreationHook
582
583 // ---------------------------------------------------------------------------
584 // global functions
585 // ---------------------------------------------------------------------------
586
587 // kbd code translation
588 WXDLLEXPORT int wxCharCodeOS2ToWX(int nKeySym);
589 WXDLLEXPORT int wxCharCodeWXToOS2( int nId
590 ,bool* pbIsVirtual
591 );
592 #endif
593 // _WX_WINDOW_H_