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