]>
Commit | Line | Data |
---|---|---|
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 | public: | |
50 | wxWindow() { Init(); } | |
51 | ||
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 | ) | |
59 | { | |
60 | Init(); | |
61 | Create( pParent | |
62 | ,vId | |
63 | ,rPos | |
64 | ,rSize | |
65 | ,lStyle | |
66 | ,rName | |
67 | ); | |
68 | } | |
69 | ||
70 | virtual ~wxWindow(); | |
71 | ||
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 | ); | |
79 | ||
80 | // implement base class pure virtuals | |
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 | ); | |
131 | ||
132 | #if wxUSE_DRAG_AND_DROP | |
133 | virtual void SetDropTarget(wxDropTarget* pDropTarget); | |
134 | #endif // wxUSE_DRAG_AND_DROP | |
135 | ||
136 | // Accept files for dragging | |
137 | virtual void DragAcceptFiles(bool bAccept); | |
138 | ||
139 | #if WXWIN_COMPATIBILITY | |
140 | // Set/get scroll attributes | |
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 | // | |
153 | // event handlers | |
154 | // | |
155 | // Handle a control command | |
156 | virtual void OnCommand( wxWindow& rWin | |
157 | ,wxCommandEvent& rEvent | |
158 | ); | |
159 | ||
160 | // Override to define new behaviour for default action (e.g. double | |
161 | // clicking on a listbox) | |
162 | virtual void OnDefaultAction(wxControl* WXUNUSED(pInitiatingItem)) { } | |
163 | #endif // WXWIN_COMPATIBILITY | |
164 | ||
165 | #if wxUSE_CARET && WXWIN_COMPATIBILITY | |
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; | |
178 | #endif // wxUSE_CARET | |
179 | ||
180 | // Native resource loading (implemented in src/os2/nativdlg.cpp) | |
181 | // FIXME: should they really be all virtual? | |
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); | |
190 | ||
191 | // implementation from now on | |
192 | // -------------------------- | |
193 | ||
194 | // simple accessors | |
195 | // ---------------- | |
196 | ||
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; } | |
203 | ||
204 | // event handlers | |
205 | // -------------- | |
206 | void OnSetFocus(wxFocusEvent& rEvent); | |
207 | void OnEraseBackground(wxEraseEvent& rEvent); | |
208 | void OnIdle(wxIdleEvent& rEvent); | |
209 | ||
210 | public: | |
211 | // For implementation purposes - sometimes decorations make the client area | |
212 | // smaller | |
213 | virtual wxPoint GetClientAreaOrigin(void) const; | |
214 | ||
215 | // Makes an adjustment to the window position (for example, a frame that has | |
216 | // a toolbar that it manages itself). | |
217 | virtual void AdjustForParentClientOrigin( int& rX | |
218 | ,int& rY | |
219 | ,int nSizeFlags | |
220 | ); | |
221 | ||
222 | // Windows subclassing | |
223 | void SubclassWin(WXHWND hWnd); | |
224 | void UnsubclassWin(void); | |
225 | ||
226 | WXFARPROC OS2GetOldWndProc(void) const { return m_fnOldWndProc; } | |
227 | void OS2SetOldWndProc(WXFARPROC fnProc) { m_fnOldWndProc = fnProc; } | |
228 | ||
229 | wxWindow* FindItem(long lId) const; | |
230 | wxWindow* FindItemByHWND( WXHWND hWnd | |
231 | ,bool bControlOnly = FALSE | |
232 | ) const; | |
233 | ||
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 | ); | |
238 | // Determine whether 3D effects are wanted | |
239 | WXDWORD Determine3DEffects( WXDWORD dwDefaultBorderStyle | |
240 | ,bool* pbWant3D | |
241 | ) const; | |
242 | ||
243 | // PM only: TRUE if this control is part of the main control | |
244 | virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; }; | |
245 | ||
246 | // returns TRUE if the window has been created | |
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 | ); | |
263 | ||
264 | #if WXWIN_COMPATIBILITY | |
265 | wxObject* GetChild(int nNumber) const; | |
266 | virtual void OS2DeviceToLogical( float* pfX | |
267 | ,float* pfY | |
268 | ) const; | |
269 | #endif // WXWIN_COMPATIBILITY | |
270 | ||
271 | // Create an appropriate wxWindow from a HWND | |
272 | virtual wxWindow* CreateWindowFromHWND( wxWindow* pParent | |
273 | ,WXHWND hWnd | |
274 | ); | |
275 | ||
276 | // Make sure the window style reflects the HWND style (roughly) | |
277 | virtual void AdoptAttributesFromHWND(void); | |
278 | ||
279 | // Setup background and foreground colours correctly | |
280 | virtual void SetupColours(void); | |
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 | ||
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 | ,WXHWND* pHwnd | |
298 | ); | |
299 | void UnpackScroll( WXWPARAM wParam | |
300 | ,WXLPARAM lParam | |
301 | ,WXWORD* pCode | |
302 | ,WXWORD* pPos | |
303 | ,WXHWND* pHwnd | |
304 | ); | |
305 | void UnpackMenuSelect( WXWPARAM wParam | |
306 | ,WXLPARAM lParam | |
307 | ,WXWORD* pTtem | |
308 | ,WXWORD* pFlags | |
309 | ,WXHMENU* pHmenu | |
310 | ); | |
311 | ||
312 | // ------------------------------------------------------------------------ | |
313 | // internal handlers for OS2 messages: all handlers return a boolen value: | |
314 | // TRUE means that the handler processed the event and FALSE that it didn't | |
315 | // ------------------------------------------------------------------------ | |
316 | ||
317 | // there are several cases where we have virtual functions for PM | |
318 | // message processing: this is because these messages often require to be | |
319 | // processed in a different manner in the derived classes. For all other | |
320 | // messages, however, we do *not* have corresponding OS2OnXXX() function | |
321 | // and if the derived class wants to process them, it should override | |
322 | // OS2WindowProc() directly. | |
323 | ||
324 | // scroll event (both horizontal and vertical) | |
325 | virtual bool OS2OnScroll( int nOrientation | |
326 | ,WXWORD nSBCode | |
327 | ,WXWORD pos | |
328 | ,WXHWND control | |
329 | ); | |
330 | ||
331 | // owner-drawn controls need to process these messages | |
332 | virtual bool OS2OnDrawItem( int nId | |
333 | ,WXDRAWITEMSTRUCT* pItem | |
334 | ); | |
335 | virtual bool OS2OnMeasureItem( int nId | |
336 | ,WXMEASUREITEMSTRUCT* pItem | |
337 | ); | |
338 | ||
339 | // the rest are not virtual | |
340 | bool HandleCreate( WXLPCREATESTRUCT vCs | |
341 | ,bool* pMayCreate | |
342 | ); | |
343 | bool HandleInitDialog(WXHWND hWndFocus); | |
344 | bool HandleDestroy(void); | |
345 | bool HandlePaint(void); | |
346 | bool HandleEraseBkgnd(WXHDC vDC); | |
347 | bool HandleMinimize(void); | |
348 | bool HandleMaximize(void); | |
349 | bool HandleSize( int nX | |
350 | ,int nY | |
351 | ,WXUINT uFlag | |
352 | ); | |
353 | bool HandleGetMinMaxInfo(PSWP pMmInfo); | |
354 | bool HandleShow( bool bShow | |
355 | ,int nStatus | |
356 | ); | |
357 | bool HandleActivate( int nFlag | |
358 | ,WXHWND hActivate | |
359 | ); | |
360 | bool HandleCommand( WXWORD nId | |
361 | ,WXWORD nCmd | |
362 | ,WXHWND hControl | |
363 | ); | |
364 | bool HandleSysCommand( WXWPARAM wParam | |
365 | ,WXLPARAM lParam | |
366 | ); | |
367 | bool HandleWindowParams( PWNDPARAMS pParams | |
368 | ,WXLPARAM lParam | |
369 | ); | |
370 | bool HandlePaletteChanged(); | |
371 | bool HandlePresParamChanged(WXWPARAM wParam); | |
372 | bool HandleSysColorChange(void); | |
373 | bool HandleCtlColor(WXHBRUSH* hBrush); | |
374 | bool HandleSetFocus(WXHWND hWnd); | |
375 | bool HandleKillFocus(WXHWND hWnd); | |
376 | bool HandleEndDrag(WXWPARAM wParam); | |
377 | bool HandleMouseEvent( WXUINT uMsg | |
378 | ,int nX | |
379 | ,int nY | |
380 | ,WXUINT uFlags | |
381 | ); | |
382 | bool HandleMouseMove( int nX | |
383 | ,int nY | |
384 | ,WXUINT uFlags | |
385 | ); | |
386 | bool HandleChar( WXWORD wParam | |
387 | ,WXLPARAM lParam | |
388 | ,bool bIsASCII = FALSE | |
389 | ); | |
390 | bool HandleKeyDown( WXWORD wParam | |
391 | ,WXLPARAM lParam | |
392 | ); | |
393 | bool HandleKeyUp( WXWORD wParam | |
394 | ,WXLPARAM lParam | |
395 | ); | |
396 | bool HandleQueryDragIcon(WXHICON* phIcon); | |
397 | bool HandleSetCursor( USHORT vId | |
398 | ,WXHWND hWnd | |
399 | ); | |
400 | ||
401 | // Window procedure | |
402 | virtual MRESULT OS2WindowProc( WXUINT uMsg | |
403 | ,WXWPARAM wParam | |
404 | ,WXLPARAM lParam | |
405 | ); | |
406 | ||
407 | // Calls an appropriate default window procedure | |
408 | virtual MRESULT OS2DefWindowProc( WXUINT uMsg | |
409 | ,WXWPARAM wParam | |
410 | ,WXLPARAM lParam | |
411 | ); | |
412 | virtual bool OS2ProcessMessage(WXMSG* pMsg); | |
413 | virtual bool OS2TranslateMessage(WXMSG* pMsg); | |
414 | virtual void OS2DestroyWindow(void); | |
415 | ||
416 | // Detach "Window" menu from menu bar so it doesn't get deleted | |
417 | void OS2DetachWindowMenu(void); | |
418 | ||
419 | // this function should return the brush to paint the window background | |
420 | // with or 0 for the default brush | |
421 | virtual WXHBRUSH OnCtlColor( WXHDC hDC | |
422 | ,WXHWND hWnd | |
423 | ,WXUINT uCtlColor | |
424 | ,WXUINT uMessage | |
425 | ,WXWPARAM wParam | |
426 | ,WXLPARAM lParam | |
427 | ); | |
428 | ||
429 | #if WXWIN_COMPATIBILITY | |
430 | void SetShowing(bool bShow) { (void)Show(show); } | |
431 | bool IsUserEnabled(void) const { return IsEnabled(); } | |
432 | #endif // WXWIN_COMPATIBILITY | |
433 | ||
434 | // Responds to colour changes: passes event on to children. | |
435 | void OnSysColourChanged(wxSysColourChangedEvent& rEvent); | |
436 | ||
437 | // initialize various fields of wxMouseEvent (common part of OS2OnMouseXXX) | |
438 | void InitMouseEvent( wxMouseEvent& rEvent | |
439 | ,int nX | |
440 | ,int nY | |
441 | ,WXUINT uFlags | |
442 | ); | |
443 | ||
444 | protected: | |
445 | // PM can't create some MSW styles natively but can perform these after | |
446 | // creation by sending messages | |
447 | typedef enum extra_flags { kFrameToolWindow = 0x0001 | |
448 | ,kVertCaption = 0x0002 | |
449 | ,kHorzCaption = 0x0004 | |
450 | } EExtraFlags; | |
451 | // Some internal sizeing id's to make it easy for event handlers | |
452 | typedef enum size_types { kSizeNormal | |
453 | ,kSizeMax | |
454 | ,kSizeMin | |
455 | } ESizeTypes; | |
456 | // the window handle | |
457 | WXHWND m_hWnd; | |
458 | ||
459 | // the old window proc (we subclass all windows) | |
460 | WXFARPROC m_fnOldWndProc; | |
461 | ||
462 | // additional (MSW specific) flags | |
463 | bool m_bUseCtl3D:1; // Using CTL3D for this control | |
464 | bool m_bBackgroundTransparent:1; | |
465 | bool m_bMouseInWindow:1; | |
466 | bool m_bDoubleClickAllowed:1; | |
467 | bool m_bWinCaptured:1; | |
468 | ||
469 | // the size of one page for scrolling | |
470 | int m_nXThumbSize; | |
471 | int m_nYThumbSize; | |
472 | ||
473 | #if wxUSE_MOUSEEVENT_HACK | |
474 | // the coordinates of the last mouse event and the type of it | |
475 | long m_lLastMouseX, | |
476 | long m_lLastMouseY; | |
477 | int m_nLastMouseEvent; | |
478 | #endif // wxUSE_MOUSEEVENT_HACK | |
479 | ||
480 | WXHMENU m_hMenu; // Menu, if any | |
481 | unsigned long m_ulMenubarId; // it's Id, if any | |
482 | ||
483 | // the return value of WM_GETDLGCODE handler | |
484 | long m_lDlgCode; | |
485 | ||
486 | // implement the base class pure virtuals | |
487 | virtual void DoClientToScreen( int* pX | |
488 | ,int* pY | |
489 | ) const; | |
490 | virtual void DoScreenToClient( int* pX | |
491 | ,int* pY | |
492 | ) const; | |
493 | virtual void DoGetPosition( int* pX | |
494 | ,int* pY | |
495 | ) const; | |
496 | virtual void DoGetSize( int* pWidth | |
497 | ,int* pHeight | |
498 | ) const; | |
499 | virtual void DoGetClientSize( int* pWidth | |
500 | ,int* pHeight | |
501 | ) const; | |
502 | virtual void DoSetSize( int nX | |
503 | ,int nY | |
504 | ,int nWidth | |
505 | ,int nHeight | |
506 | ,int nSizeFlags = wxSIZE_AUTO | |
507 | ); | |
508 | virtual void DoSetClientSize( int nWidth | |
509 | ,int nHeight | |
510 | ); | |
511 | ||
512 | // move the window to the specified location and resize it: this is called | |
513 | // from both DoSetSize() and DoSetClientSize() and would usually just call | |
514 | // ::MoveWindow() except for composite controls which will want to arrange | |
515 | // themselves inside the given rectangle | |
516 | virtual void DoMoveWindow( int nX | |
517 | ,int nY | |
518 | ,int nWidth | |
519 | ,int nHeight | |
520 | ); | |
521 | ||
522 | #if wxUSE_TOOLTIPS | |
523 | virtual void DoSetToolTip(wxToolTip* pTip); | |
524 | #endif // wxUSE_TOOLTIPS | |
525 | ||
526 | private: | |
527 | // common part of all ctors | |
528 | void Init(void); | |
529 | ||
530 | // the (non-virtual) handlers for the events | |
531 | bool HandleMove( int nX | |
532 | ,int nY | |
533 | ); | |
534 | bool HandleJoystickEvent( WXUINT uMsg | |
535 | ,int pX | |
536 | ,int pY | |
537 | ,WXUINT uFlags | |
538 | ); | |
539 | ||
540 | bool HandleNotify( int nIdCtrl | |
541 | ,WXLPARAM lParam | |
542 | ,WXLPARAM* pResult | |
543 | ); | |
544 | // the helper functions used by HandleChar/KeyXXX methods | |
545 | wxKeyEvent CreateKeyEvent(wxEventType evType, int id, WXLPARAM lp) const; | |
546 | ||
547 | DECLARE_DYNAMIC_CLASS(wxWindow); | |
548 | DECLARE_NO_COPY_CLASS(wxWindow); | |
549 | DECLARE_EVENT_TABLE() | |
550 | private: | |
551 | // Virtual function hiding supression | |
552 | inline virtual bool Reparent(wxWindowBase* pNewParent) | |
553 | { return(wxWindowBase::Reparent(pNewParent));}; | |
554 | }; // end of wxWindow | |
555 | ||
556 | // --------------------------------------------------------------------------- | |
557 | // global functions | |
558 | // --------------------------------------------------------------------------- | |
559 | ||
560 | // kbd code translation | |
561 | WXDLLEXPORT int wxCharCodeOS2ToWX(int nKeySym); | |
562 | WXDLLEXPORT int wxCharCodeWXToOS2( int nId | |
563 | ,bool* pbIsVirtual | |
564 | ); | |
565 | #endif | |
566 | // _WX_WINDOW_H_ |