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