]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/window.h
HTML help: index panel now displays only part of index matching given substring ...
[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 wxWindow : public wxWindowBase
48 {
49 DECLARE_DYNAMIC_CLASS(wxWindow);
50
51 public:
52 wxWindow() { Init(); }
53
54 wxWindow( wxWindow* pParent
55 ,wxWindowID vId
56 ,const wxPoint& rPos = wxDefaultPosition
57 ,const wxSize& rSize = wxDefaultSize
58 ,long lStyle = 0
59 ,const wxString& rName = wxPanelNameStr
60 )
61 {
62 Init();
63 Create( pParent
64 ,vId
65 ,rPos
66 ,rSize
67 ,lStyle
68 ,rName
69 );
70 }
71
72 virtual ~wxWindow();
73
74 bool Create( wxWindow* pParent
75 ,wxWindowID vId
76 ,const wxPoint& rPos = wxDefaultPosition
77 ,const wxSize& rSize = wxDefaultSize
78 ,long lStyle = 0
79 ,const wxString& rName = wxPanelNameStr
80 );
81
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
92 ,int y
93 );
94 virtual void CaptureMouse(void);
95 virtual void ReleaseMouse(void);
96 virtual void Refresh( bool bEraseBackground = TRUE
97 ,const wxRect* pRect = (const wxRect *)NULL
98 );
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
105 ,int* pX
106 ,int* pY
107 ,int* pDescent = (int *)NULL
108 ,int* pExternalLeading = (int *)NULL
109 ,const wxFont* pTheFont = (const wxFont *)NULL
110 ) const;
111 virtual bool DoPopupMenu( wxMenu* pMenu
112 ,int nX
113 ,int nY
114 );
115
116 virtual void SetScrollbar( int nOrient
117 ,int nPos
118 ,int nThumbVisible
119 ,int nRange
120 ,bool bRefresh = TRUE
121 );
122 virtual void SetScrollPos( int nOrient
123 ,int nPos
124 ,bool bRefresh = TRUE
125 );
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
130 ,int nDy
131 ,const wxRect* pRect = (wxRect *)NULL
132 );
133
134 #if wxUSE_DRAG_AND_DROP
135 virtual void SetDropTarget(wxDropTarget* pDropTarget);
136 #endif // wxUSE_DRAG_AND_DROP
137
138 // Accept files for dragging
139 virtual void DragAcceptFiles(bool bAccept);
140
141 #if WXWIN_COMPATIBILITY
142 // Set/get scroll attributes
143 virtual void SetScrollRange( int nOrient
144 ,int nRange
145 ,bool bRefresh = TRUE
146 );
147 virtual void SetScrollPage( int nOrient
148 ,int nPage
149 ,bool bRefresh = TRUE
150 );
151 virtual int OldGetScrollRange(int nOrient) const;
152 virtual int GetScrollPage(int nOrient) const;
153
154 //
155 // event handlers
156 //
157 // Handle a control command
158 virtual void OnCommand( wxWindow& rWin
159 ,wxCommandEvent& rEvent
160 );
161
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
166
167 #if wxUSE_CARET && WXWIN_COMPATIBILITY
168 void CreateCaret( int nWidth
169 ,int nHeight
170 );
171 void CreateCaret(const wxBitmap* pBitmap);
172 void DestroyCaret(void);
173 void ShowCaret(bool bShow);
174 void SetCaretPos( int nX
175 ,int nY
176 );
177 void GetCaretPos( int* pX
178 ,int* pY
179 ) const;
180 #endif // wxUSE_CARET
181
182 // Native resource loading (implemented in src/os2/nativdlg.cpp)
183 // FIXME: should they really be all virtual?
184 virtual bool LoadNativeDialog( wxWindow* pParent
185 ,wxWindowID& vId
186 );
187 virtual bool LoadNativeDialog( wxWindow* pParent
188 ,const wxString& rName
189 );
190 wxWindow* GetWindowChild1(wxWindowID vId);
191 wxWindow* GetWindowChild(wxWindowID vId);
192
193 // implementation from now on
194 // --------------------------
195
196 // simple accessors
197 // ----------------
198
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; }
205
206 // event handlers
207 // --------------
208 void OnEraseBackground(wxEraseEvent& rEvent);
209 void OnIdle(wxIdleEvent& rEvent);
210
211 public:
212 // For implementation purposes - sometimes decorations make the client area
213 // smaller
214 virtual wxPoint GetClientAreaOrigin(void) const;
215
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
219 ,int& rY
220 ,int nSizeFlags
221 );
222
223 // Windows subclassing
224 void SubclassWin(WXHWND hWnd);
225 void UnsubclassWin(void);
226
227 WXFARPROC OS2GetOldWndProc(void) const { return m_fnOldWndProc; }
228 void OS2SetOldWndProc(WXFARPROC fnProc) { m_fnOldWndProc = fnProc; }
229
230 wxWindow* FindItem(long lId) const;
231 wxWindow* FindItemByHWND( WXHWND hWnd
232 ,bool bControlOnly = FALSE
233 ) const;
234
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
238 );
239 // Determine whether 3D effects are wanted
240 WXDWORD Determine3DEffects( WXDWORD dwDefaultBorderStyle
241 ,bool* pbWant3D
242 ) const;
243
244 // PM only: TRUE if this control is part of the main control
245 virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; };
246
247 // returns TRUE if the window has been created
248 bool OS2Create( int nId
249 ,wxWindow* pParent
250 ,const wxChar* zWclass
251 ,wxWindow* pWxWin
252 ,const wxChar* zTitle
253 ,int nX
254 ,int nY
255 ,int nWidth
256 ,int nHeight
257 ,WXDWORD dwStyle
258 ,const wxChar* zDialogTemplate = NULL
259 ,WXDWORD dwExendedStyle = 0
260 );
261 virtual bool OS2Command( WXUINT uParam
262 ,WXWORD nId
263 );
264
265 #if WXWIN_COMPATIBILITY
266 wxObject* GetChild(int nNumber) const;
267 virtual void OS2DeviceToLogical( float* pfX
268 ,float* pfY
269 ) const;
270 #endif // WXWIN_COMPATIBILITY
271
272 // Create an appropriate wxWindow from a HWND
273 virtual wxWindow* CreateWindowFromHWND( wxWindow* pParent
274 ,WXHWND hWnd
275 );
276
277 // Make sure the window style reflects the HWND style (roughly)
278 virtual void AdoptAttributesFromHWND(void);
279
280 // Setup background and foreground colours correctly
281 virtual void SetupColours(void);
282
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 // ------------------------------------------------------------------------
288
289 void UnpackCommand( WXWPARAM wParam
290 ,WXLPARAM lParam,
291 WXWORD* pId
292 ,WXHWND* pHwnd
293 ,WXWORD* pCmd
294 );
295 void UnpackActivate( WXWPARAM wParam
296 ,WXLPARAM lParam
297 ,WXWORD* pState
298 ,WXWORD* pMinimized
299 ,WXHWND* pHwnd
300 );
301 void UnpackScroll( WXWPARAM wParam
302 ,WXLPARAM lParam
303 ,WXWORD* pCode
304 ,WXWORD* pPos
305 ,WXHWND* pHwnd
306 );
307 void UnpackCtlColor( WXWPARAM wParam
308 ,WXLPARAM lParam
309 ,WXWORD* pCtlColor
310 ,WXHDC* pHdc
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 virtual bool OS2OnNotify( int nIdCtrl
340 ,WXLPARAM lParam
341 ,WXLPARAM* pResult
342 );
343
344 // owner-drawn controls need to process these messages
345 virtual bool OS2OnDrawItem( int nId
346 ,WXDRAWITEMSTRUCT* pItem
347 );
348 virtual bool OS2OnMeasureItem( int nId
349 ,WXMEASUREITEMSTRUCT* pItem
350 );
351
352 // the rest are not virtual
353 bool HandleCreate( WXLPCREATESTRUCT vCs
354 ,bool* pMayCreate
355 );
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
363 ,int nY
364 ,WXUINT uFlag
365 );
366 bool HandleGetMinMaxInfo(void* pMmInfo);
367 bool HandleShow( bool bShow
368 ,int nStatus
369 );
370 bool HandleActivate( int nFlag
371 ,bool bMinimized
372 ,WXHWND hActivate
373 );
374 bool HandleCommand( WXWORD nId
375 ,WXWORD nCmd
376 ,WXHWND hControl
377 );
378 bool HandleSysCommand( WXWPARAM wParam
379 ,WXLPARAM lParam
380 );
381 bool HandleCtlColor( WXHBRUSH* phBrush
382 ,WXHDC hDc
383 ,WXHWND hWnd
384 ,WXUINT uCtlColor
385 ,WXUINT uMessage
386 ,WXWPARAM wParam
387 ,WXLPARAM lParam
388 );
389 bool HandlePaletteChanged(WXHWND hWndPalChange);
390 bool HandleQueryNewPalette(void);
391 bool HandleSysColorChange(void);
392 bool HandleQueryEndSession( long lLogOff
393 ,bool* pbMayEnd
394 );
395 bool HandleEndSession( bool bEndSession
396 ,long lLogOff
397 );
398 bool HandleSetFocus(WXHWND hWnd);
399 bool HandleKillFocus(WXHWND hWnd);
400 bool HandleDropFiles(WXWPARAM wParam);
401 bool HandleMouseEvent( WXUINT uMsg
402 ,int nX
403 ,int nY
404 ,WXUINT uFlags
405 );
406 bool HandleMouseMove( int nX
407 ,int nY
408 ,WXUINT uFlags
409 );
410 bool HandleChar( WXWORD wParam
411 ,WXLPARAM lParam
412 ,bool bIsASCII = FALSE
413 );
414 bool HandleKeyDown( WXWORD wParam
415 ,WXLPARAM lParam
416 );
417 bool HandleKeyUp( WXWORD wParam
418 ,WXLPARAM lParam
419 );
420 bool HandleQueryDragIcon(WXHICON* phIcon);
421 bool HandleSetCursor( WXHWND hWnd
422 ,short nHitTest
423 ,int nMouseMsg
424 );
425
426 // Window procedure
427 virtual MRESULT OS2WindowProc( HWND hwnd
428 ,WXUINT uMsg
429 ,WXWPARAM wParam
430 ,WXLPARAM lParam
431 );
432
433 // Calls an appropriate default window procedure
434 virtual MRESULT OS2DefWindowProc( HWND hwnd
435 ,WXUINT uMsg
436 ,WXWPARAM wParam
437 ,WXLPARAM lParam
438 );
439 virtual bool OS2ProcessMessage(WXMSG* pMsg);
440 virtual bool OS2TranslateMessage(WXMSG* pMsg);
441 virtual void OS2DestroyWindow(void);
442
443 // Detach "Window" menu from menu bar so it doesn't get deleted
444 void OS2DetachWindowMenu(void);
445
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
449 ,WXHWND hWnd
450 ,WXUINT uCtlColor
451 ,WXUINT uMessage
452 ,WXWPARAM wParam
453 ,WXLPARAM lParam
454 );
455
456 #if WXWIN_COMPATIBILITY
457 void SetShowing(bool bShow) { (void)Show(show); }
458 bool IsUserEnabled(void) const { return IsEnabled(); }
459 #endif // WXWIN_COMPATIBILITY
460
461 // Responds to colour changes: passes event on to children.
462 void OnSysColourChanged(wxSysColourChangedEvent& rEvent);
463
464 // initialize various fields of wxMouseEvent (common part of OS2OnMouseXXX)
465 void InitMouseEvent( wxMouseEvent& rEvent
466 ,int nX
467 ,int nY
468 ,WXUINT uFlags
469 );
470
471 protected:
472 // the window handle
473 WXHWND m_hWnd;
474
475 // the old window proc (we subclass all windows)
476 WXFARPROC m_fnOldWndProc;
477
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;
484
485 // the size of one page for scrolling
486 int m_nXThumbSize;
487 int m_nYThumbSize;
488
489 #if wxUSE_MOUSEEVENT_HACK
490 // the coordinates of the last mouse event and the type of it
491 long m_lLastMouseX,
492 long m_lLastMouseY;
493 int m_nLastMouseEvent;
494 #endif // wxUSE_MOUSEEVENT_HACK
495
496 WXHMENU m_hMenu; // Menu, 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 // ::MoveWindow() 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 private:
542 // common part of all ctors
543 void Init(void);
544
545 // the (non-virtual) handlers for the events
546 bool HandleMove( int nX
547 ,int nY
548 );
549 bool HandleJoystickEvent( WXUINT uMsg
550 ,int pX
551 ,int pY
552 ,WXUINT uFlags
553 );
554
555 bool HandleNotify( int nIdCtrl
556 ,WXLPARAM lParam
557 ,WXLPARAM* pResult
558 );
559 DECLARE_NO_COPY_CLASS(wxWindow);
560 DECLARE_EVENT_TABLE()
561 private:
562 // Virtual function hiding supression
563 inline virtual bool Reparent(wxWindowBase* pNewParent)
564 { return(wxWindowBase::Reparent(pNewParent));};
565 };
566
567 // ---------------------------------------------------------------------------
568 // global functions
569 // ---------------------------------------------------------------------------
570
571 // kbd code translation
572 WXDLLEXPORT int wxCharCodeOS2ToWX(int nKeySym);
573 WXDLLEXPORT int wxCharCodeWXToOS2( int nId
574 ,bool* pbIsVirtual
575 );
576 #endif
577 // _WX_WINDOW_H_