]> git.saurik.com Git - wxWidgets.git/blame - include/wx/os2/window.h
wxDateTime::ParseFormat() and ParseTime() added (compile but don't work)
[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{
cdf1e714 49 DECLARE_DYNAMIC_CLASS(wxWindow);
0e320a79
DW
50
51public:
cdf1e714
DW
52 wxWindow() { Init(); }
53
776d87d5
DW
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 )
0e320a79
DW
61 {
62 Init();
776d87d5
DW
63 Create( pParent
64 ,vId
65 ,rPos
66 ,rSize
67 ,lStyle
68 ,rName
69 );
0e320a79
DW
70 }
71
72 virtual ~wxWindow();
73
776d87d5
DW
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 );
0e320a79 81
cdf1e714 82 // implement base class pure virtuals
776d87d5
DW
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 );
0e320a79 133
cdf1e714 134#if wxUSE_DRAG_AND_DROP
776d87d5 135 virtual void SetDropTarget(wxDropTarget* pDropTarget);
cdf1e714 136#endif // wxUSE_DRAG_AND_DROP
0e320a79
DW
137
138 // Accept files for dragging
776d87d5 139 virtual void DragAcceptFiles(bool bAccept);
0e320a79 140
cdf1e714
DW
141#if WXWIN_COMPATIBILITY
142 // Set/get scroll attributes
776d87d5
DW
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 //
cdf1e714 155 // event handlers
776d87d5 156 //
cdf1e714 157 // Handle a control command
776d87d5
DW
158 virtual void OnCommand( wxWindow& rWin
159 ,wxCommandEvent& rEvent
160 );
0e320a79 161
cdf1e714
DW
162 // Override to define new behaviour for default action (e.g. double
163 // clicking on a listbox)
776d87d5 164 virtual void OnDefaultAction(wxControl* WXUNUSED(pInitiatingItem)) { }
cdf1e714 165#endif // WXWIN_COMPATIBILITY
0e320a79 166
cdf1e714 167#if wxUSE_CARET && WXWIN_COMPATIBILITY
776d87d5
DW
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;
cdf1e714
DW
180#endif // wxUSE_CARET
181
776d87d5 182 // Native resource loading (implemented in src/os2/nativdlg.cpp)
cdf1e714 183 // FIXME: should they really be all virtual?
776d87d5
DW
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);
cdf1e714
DW
192
193 // implementation from now on
194 // --------------------------
195
196 // simple accessors
197 // ----------------
86de7616 198
776d87d5
DW
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; }
54da4255 205
cdf1e714
DW
206 // event handlers
207 // --------------
776d87d5
DW
208 void OnEraseBackground(wxEraseEvent& rEvent);
209 void OnIdle(wxIdleEvent& rEvent);
cdf1e714
DW
210
211public:
0e320a79
DW
212 // For implementation purposes - sometimes decorations make the client area
213 // smaller
776d87d5 214 virtual wxPoint GetClientAreaOrigin(void) const;
0e320a79
DW
215
216 // Makes an adjustment to the window position (for example, a frame that has
217 // a toolbar that it manages itself).
776d87d5
DW
218 virtual void AdjustForParentClientOrigin( int& rX
219 ,int& rY
220 ,int nSizeFlags
221 );
0e320a79 222
86de7616
DW
223 // Windows subclassing
224 void SubclassWin(WXHWND hWnd);
776d87d5 225 void UnsubclassWin(void);
86de7616 226
776d87d5
DW
227 WXFARPROC OS2GetOldWndProc(void) const { return m_fnOldWndProc; }
228 void OS2SetOldWndProc(WXFARPROC fnProc) { m_fnOldWndProc = fnProc; }
86de7616 229
776d87d5
DW
230 wxWindow* FindItem(long lId) const;
231 wxWindow* FindItemByHWND( WXHWND hWnd
232 ,bool bControlOnly = FALSE
233 ) const;
86de7616 234
776d87d5
DW
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 );
86de7616 239 // Determine whether 3D effects are wanted
776d87d5
DW
240 WXDWORD Determine3DEffects( WXDWORD dwDefaultBorderStyle
241 ,bool* pbWant3D
242 ) const;
86de7616 243
776d87d5 244 // PM only: TRUE if this control is part of the main control
86de7616
DW
245 virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; };
246
cdf1e714 247 // returns TRUE if the window has been created
776d87d5
DW
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 );
cdf1e714
DW
264
265#if WXWIN_COMPATIBILITY
776d87d5
DW
266 wxObject* GetChild(int nNumber) const;
267 virtual void OS2DeviceToLogical( float* pfX
268 ,float* pfY
269 ) const;
cdf1e714
DW
270#endif // WXWIN_COMPATIBILITY
271
272 // Create an appropriate wxWindow from a HWND
776d87d5
DW
273 virtual wxWindow* CreateWindowFromHWND( wxWindow* pParent
274 ,WXHWND hWnd
275 );
cdf1e714
DW
276
277 // Make sure the window style reflects the HWND style (roughly)
776d87d5 278 virtual void AdoptAttributesFromHWND(void);
cdf1e714
DW
279
280 // Setup background and foreground colours correctly
776d87d5 281 virtual void SetupColours(void);
cdf1e714
DW
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
776d87d5
DW
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 );
cdf1e714
DW
319
320 // ------------------------------------------------------------------------
776d87d5 321 // internal handlers for OS2 messages: all handlers return a boolen value:
cdf1e714
DW
322 // TRUE means that the handler processed the event and FALSE that it didn't
323 // ------------------------------------------------------------------------
324
776d87d5 325 // there are several cases where we have virtual functions for PM
cdf1e714
DW
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
776d87d5 328 // messages, however, we do *not* have corresponding OS2OnXXX() function
cdf1e714 329 // and if the derived class wants to process them, it should override
776d87d5 330 // OS2WindowProc() directly.
cdf1e714
DW
331
332 // scroll event (both horizontal and vertical)
776d87d5
DW
333 virtual bool OS2OnScroll( int nOrientation
334 ,WXWORD nSBCode
335 ,WXWORD pos
336 ,WXHWND control
337 );
cdf1e714 338
776d87d5
DW
339 virtual bool OS2OnNotify( int nIdCtrl
340 ,WXLPARAM lParam
341 ,WXLPARAM* pResult
342 );
cdf1e714
DW
343
344 // owner-drawn controls need to process these messages
776d87d5
DW
345 virtual bool OS2OnDrawItem( int nId
346 ,WXDRAWITEMSTRUCT* pItem
347 );
348 virtual bool OS2OnMeasureItem( int nId
349 ,WXMEASUREITEMSTRUCT* pItem
350 );
cdf1e714
DW
351
352 // the rest are not virtual
776d87d5
DW
353 bool HandleCreate( WXLPCREATESTRUCT vCs
354 ,bool* pMayCreate
355 );
cdf1e714 356 bool HandleInitDialog(WXHWND hWndFocus);
776d87d5
DW
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 );
cdf1e714 389 bool HandlePaletteChanged(WXHWND hWndPalChange);
776d87d5
DW
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);
cdf1e714 400 bool HandleDropFiles(WXWPARAM wParam);
776d87d5
DW
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 );
0e320a79 425
cdf1e714 426 // Window procedure
776d87d5
DW
427 virtual MRESULT OS2WindowProc( HWND hwnd
428 ,WXUINT uMsg
429 ,WXWPARAM wParam
430 ,WXLPARAM lParam
431 );
0e320a79 432
cdf1e714 433 // Calls an appropriate default window procedure
776d87d5
DW
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);
0e320a79 442
cdf1e714 443 // Detach "Window" menu from menu bar so it doesn't get deleted
776d87d5 444 void OS2DetachWindowMenu(void);
27476f73 445
cdf1e714
DW
446 // this function should return the brush to paint the window background
447 // with or 0 for the default brush
776d87d5
DW
448 virtual WXHBRUSH OnCtlColor( WXHDC hDC
449 ,WXHWND hWnd
450 ,WXUINT uCtlColor
451 ,WXUINT uMessage
452 ,WXWPARAM wParam
453 ,WXLPARAM lParam
454 );
27476f73 455
cdf1e714 456#if WXWIN_COMPATIBILITY
776d87d5
DW
457 void SetShowing(bool bShow) { (void)Show(show); }
458 bool IsUserEnabled(void) const { return IsEnabled(); }
cdf1e714 459#endif // WXWIN_COMPATIBILITY
0e320a79 460
cdf1e714 461 // Responds to colour changes: passes event on to children.
776d87d5 462 void OnSysColourChanged(wxSysColourChangedEvent& rEvent);
0e320a79 463
776d87d5
DW
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 );
0e320a79 470
cdf1e714
DW
471protected:
472 // the window handle
776d87d5 473 WXHWND m_hWnd;
cdf1e714
DW
474
475 // the old window proc (we subclass all windows)
776d87d5 476 WXFARPROC m_fnOldWndProc;
cdf1e714
DW
477
478 // additional (MSW specific) flags
776d87d5
DW
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;
849949b1
DW
484
485 // the size of one page for scrolling
776d87d5
DW
486 int m_nXThumbSize;
487 int m_nYThumbSize;
0e320a79 488
cdf1e714
DW
489#if wxUSE_MOUSEEVENT_HACK
490 // the coordinates of the last mouse event and the type of it
776d87d5
DW
491 long m_lLastMouseX,
492 long m_lLastMouseY;
493 int m_nLastMouseEvent;
cdf1e714
DW
494#endif // wxUSE_MOUSEEVENT_HACK
495
776d87d5 496 WXHMENU m_hMenu; // Menu, if any
cdf1e714
DW
497
498 // the return value of WM_GETDLGCODE handler
776d87d5 499 long m_lDlgCode;
cdf1e714
DW
500
501 // implement the base class pure virtuals
776d87d5
DW
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 );
cdf1e714 526
cdf1e714
DW
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
776d87d5
DW
531 virtual void DoMoveWindow( int nX
532 ,int nY
533 ,int nWidth
534 ,int nHeight
535 );
cdf1e714
DW
536
537#if wxUSE_TOOLTIPS
776d87d5 538 virtual void DoSetToolTip(wxToolTip* pTip);
cdf1e714
DW
539#endif // wxUSE_TOOLTIPS
540
0e320a79 541private:
cdf1e714 542 // common part of all ctors
776d87d5 543 void Init(void);
0e320a79 544
cdf1e714 545 // the (non-virtual) handlers for the events
776d87d5
DW
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 );
cdf1e714
DW
559 DECLARE_NO_COPY_CLASS(wxWindow);
560 DECLARE_EVENT_TABLE()
63415778
DW
561private:
562 // Virtual function hiding supression
776d87d5
DW
563 inline virtual bool Reparent(wxWindowBase* pNewParent)
564 { return(wxWindowBase::Reparent(pNewParent));};
cdf1e714 565};
0e320a79 566
cdf1e714
DW
567// ---------------------------------------------------------------------------
568// global functions
569// ---------------------------------------------------------------------------
0e320a79 570
cdf1e714 571// kbd code translation
776d87d5
DW
572WXDLLEXPORT int wxCharCodeOS2ToWX(int nKeySym);
573WXDLLEXPORT int wxCharCodeWXToOS2( int nId
574 ,bool* pbIsVirtual
575 );
0e320a79
DW
576#endif
577 // _WX_WINDOW_H_