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