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