]> git.saurik.com Git - wxWidgets.git/blob - src/os2/window.cpp
XRC spec: relax requirements on some commonly omitted properties.
[wxWidgets.git] / src / os2 / window.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/window.cpp
3 // Purpose: wxWindow
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/12/99
7 // Copyright: (c) David Webster
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 //
12 // For compilers that support precompilation, includes "wx.h".
13 //
14 #include "wx/wxprec.h"
15
16 #include "wx/window.h"
17
18 #ifndef WX_PRECOMP
19 #define INCL_DOS
20 #define INCL_PM
21 #include <os2.h>
22 #include "wx/accel.h"
23 #include "wx/menu.h"
24 #include "wx/dc.h"
25 #include "wx/dcclient.h"
26 #include "wx/utils.h"
27 #include "wx/app.h"
28 #include "wx/panel.h"
29 #include "wx/layout.h"
30 #include "wx/checkbox.h"
31 #include "wx/combobox.h"
32 #include "wx/dialog.h"
33 #include "wx/frame.h"
34 #include "wx/listbox.h"
35 #include "wx/button.h"
36 #include "wx/bmpbuttn.h"
37 #include "wx/msgdlg.h"
38 #include "wx/scrolwin.h"
39 #include "wx/radiobox.h"
40 #include "wx/radiobut.h"
41 #include "wx/slider.h"
42 #include "wx/statbox.h"
43 #include "wx/statusbr.h"
44 #include "wx/toolbar.h"
45 #include "wx/settings.h"
46 #include "wx/intl.h"
47 #include "wx/log.h"
48 #include "wx/textctrl.h"
49 #include "wx/menuitem.h"
50 #include <stdio.h>
51 #endif
52
53 #include "wx/os2/dcclient.h"
54
55 #if wxUSE_OWNER_DRAWN
56 #include "wx/ownerdrw.h"
57 #endif
58
59 #if wxUSE_DRAG_AND_DROP
60 #include "wx/dnd.h"
61 #endif
62
63 #include "wx/os2/private.h"
64
65 #if wxUSE_TOOLTIPS
66 #include "wx/tooltip.h"
67 #endif
68
69 #if wxUSE_NOTEBOOK
70 #include "wx/notebook.h"
71 #endif
72
73 #if wxUSE_CARET
74 #include "wx/caret.h"
75 #endif // wxUSE_CARET
76
77 #include <string.h>
78
79 //
80 // Place compiler, OS specific includes here
81 //
82
83 //
84 // Standard macros -- these are for OS/2 PM, but most GUI's have something similar
85 //
86 #ifndef GET_X_LPARAM
87 //
88 // SHORT1FROMMP -- LOWORD
89 //
90 #define GET_X_LPARAM(mp) ((unsigned short)(unsigned long)(mp))
91 //
92 // SHORT2FROMMP -- HIWORD
93 //
94 #define GET_Y_LPARAM(mp) ((unsigned short)(unsigned long)(mp >> 16))
95 #endif // GET_X_LPARAM
96
97 #ifndef CW_USEDEFAULT
98 # define CW_USEDEFAULT ((int)0x80000000)
99 #endif
100
101 #ifndef VK_OEM_1
102 #define VK_OEM_1 0xBA
103 #define VK_OEM_PLUS 0xBB
104 #define VK_OEM_COMMA 0xBC
105 #define VK_OEM_MINUS 0xBD
106 #define VK_OEM_PERIOD 0xBE
107 #define VK_OEM_2 0xBF
108 #define VK_OEM_3 0xC0
109 #define VK_OEM_4 0xDB
110 #define VK_OEM_5 0xDC
111 #define VK_OEM_6 0xDD
112 #define VK_OEM_7 0xDE
113 #endif
114
115 // ---------------------------------------------------------------------------
116 // global variables
117 // ---------------------------------------------------------------------------
118
119 //
120 // The last PM message we got (MT-UNSAFE)
121 //
122 QMSG s_currentMsg;
123
124 #if wxUSE_MENUS_NATIVE
125 extern wxMenu* wxCurrentPopupMenu;
126 #endif // wxUSE_MENUS_NATIVE
127
128 // ---------------------------------------------------------------------------
129 // private functions
130 // ---------------------------------------------------------------------------
131
132 //
133 // the window proc for all our windows; most gui's have something similar
134 //
135 MRESULT EXPENTRY wxWndProc( HWND hWnd
136 ,ULONG message
137 ,MPARAM mp1
138 ,MPARAM mp2
139 );
140
141 #ifdef __WXDEBUG__
142 const wxChar *wxGetMessageName(int message);
143 #endif //__WXDEBUG__
144
145 wxWindowOS2* FindWindowForMouseEvent( wxWindow* pWin
146 ,short* pnX
147 ,short* pnY
148 );
149 void wxRemoveHandleAssociation(wxWindowOS2* pWin);
150 void wxAssociateWinWithHandle( HWND hWnd
151 ,wxWindowOS2* pWin
152 );
153 wxWindow* wxFindWinFromHandle(WXHWND hWnd);
154
155 //
156 // get the current state of SHIFT/CTRL keys
157 //
158 static inline bool IsKeyDown(LONG key) {return (::WinGetKeyState(HWND_DESKTOP, key) & 0x8000) != 0; }
159 static inline bool IsShiftDown() { return IsKeyDown(VK_SHIFT); }
160 static inline bool IsCtrlDown() { return IsKeyDown(VK_CTRL); }
161
162 static wxWindow* gpWinBeingCreated = NULL;
163
164 // ---------------------------------------------------------------------------
165 // event tables
166 // ---------------------------------------------------------------------------
167
168 // in wxUniv-OS/2 this class is abstract because it doesn't have DoPopupMenu()
169 // method
170 #ifdef __WXUNIVERSAL__
171 IMPLEMENT_ABSTRACT_CLASS(wxWindowOS2, wxWindowBase)
172 #endif // __WXUNIVERSAL__
173
174 BEGIN_EVENT_TABLE(wxWindowOS2, wxWindowBase)
175 EVT_ERASE_BACKGROUND(wxWindowOS2::OnEraseBackground)
176 EVT_SYS_COLOUR_CHANGED(wxWindowOS2::OnSysColourChanged)
177 EVT_IDLE(wxWindowOS2::OnIdle)
178 EVT_SET_FOCUS(wxWindowOS2::OnSetFocus)
179 END_EVENT_TABLE()
180
181 // ===========================================================================
182 // implementation
183 // ===========================================================================
184
185 // ---------------------------------------------------------------------------
186 // wxWindow utility functions
187 // ---------------------------------------------------------------------------
188
189 //
190 // Find an item given the PM Window id
191 //
192 wxWindow* wxWindowOS2::FindItem(
193 long lId
194 ) const
195 {
196 #if wxUSE_CONTROLS
197 wxControl* pItem = wxDynamicCast(this, wxControl);
198
199 if (pItem)
200 {
201 //
202 // I it we or one of our "internal" children?
203 //
204 if (pItem->GetId() == lId
205 #ifndef __WXUNIVERSAL__
206 || (pItem->GetSubcontrols().Index(lId) != wxNOT_FOUND)
207 #endif
208 )
209 {
210 return pItem;
211 }
212 }
213 #endif // wxUSE_CONTROLS
214
215 wxWindowList::compatibility_iterator current = GetChildren().GetFirst();
216
217 while (current)
218 {
219 wxWindow* pChildWin = current->GetData();
220 wxWindow* pWnd = pChildWin->FindItem(lId);
221
222 if (pWnd)
223 return pWnd;
224
225 current = current->GetNext();
226 }
227 return(NULL);
228 } // end of wxWindowOS2::FindItem
229
230 //
231 // Find an item given the PM Window handle
232 //
233 wxWindow* wxWindowOS2::FindItemByHWND(
234 WXHWND hWnd
235 , bool bControlOnly
236 ) const
237 {
238 wxWindowList::compatibility_iterator current = GetChildren().GetFirst();
239
240 while (current)
241 {
242 wxWindow* pParent = current->GetData();
243
244 //
245 // Do a recursive search.
246 //
247 wxWindow* pWnd = pParent->FindItemByHWND(hWnd);
248
249 if (pWnd)
250 return(pWnd);
251
252 if (!bControlOnly
253 #if wxUSE_CONTROLS
254 || pParent->IsKindOf(CLASSINFO(wxControl))
255 #endif // wxUSE_CONTROLS
256 )
257 {
258 wxWindow* pItem = current->GetData();
259
260 if (pItem->GetHWND() == hWnd)
261 return(pItem);
262 else
263 {
264 if (pItem->ContainsHWND(hWnd))
265 return(pItem);
266 }
267 }
268 current = current->GetNext();
269 }
270 return(NULL);
271 } // end of wxWindowOS2::FindItemByHWND
272
273 //
274 // Default command handler
275 //
276 bool wxWindowOS2::OS2Command( WXUINT WXUNUSED(uParam),
277 WXWORD WXUNUSED(uId) )
278 {
279 return false;
280 }
281
282 // ----------------------------------------------------------------------------
283 // constructors and such
284 // ----------------------------------------------------------------------------
285
286 void wxWindowOS2::Init()
287 {
288 //
289 // PM specific
290 //
291 m_bWinCaptured = false;
292
293 m_fnOldWndProc = NULL;
294 m_bUseCtl3D = false;
295 m_bMouseInWindow = false;
296 m_bLastKeydownProcessed = false;
297
298 //
299 // wxWnd
300 //
301 m_hMenu = 0L;
302 m_hWnd = 0L;
303 m_hWndScrollBarHorz = 0L;
304 m_hWndScrollBarVert = 0L;
305
306 memset(&m_vWinSwp, '\0', sizeof (SWP));
307
308 //
309 // Pass WM_GETDLGCODE to DefWindowProc()
310 //
311 m_lDlgCode = 0;
312
313 m_nXThumbSize = 0;
314 m_nYThumbSize = 0;
315 m_bBackgroundTransparent = false;
316
317 //
318 // As all windows are created with WS_VISIBLE style...
319 //
320 m_isShown = true;
321
322 #if wxUSE_MOUSEEVENT_HACK
323 m_lLastMouseX =
324 m_lLastMouseY = -1;
325 m_nLastMouseEvent = -1;
326 #endif // wxUSE_MOUSEEVENT_HACK
327 } // wxWindowOS2::Init
328
329 //
330 // Destructor
331 //
332 wxWindowOS2::~wxWindowOS2()
333 {
334 SendDestroyEvent();
335
336 for (wxWindow* pWin = GetParent(); pWin; pWin = pWin->GetParent())
337 {
338 wxTopLevelWindow* pFrame = wxDynamicCast(pWin, wxTopLevelWindow);
339
340 if (pFrame)
341 {
342 if (pFrame->GetLastFocus() == this)
343 pFrame->SetLastFocus(NULL);
344 }
345 }
346
347 DestroyChildren();
348
349 if (m_hWnd)
350 {
351 if(!::WinDestroyWindow(GetHWND()))
352 {
353 wxLogLastError(wxT("DestroyWindow"));
354 }
355 //
356 // remove hWnd <-> wxWindow association
357 //
358 wxRemoveHandleAssociation(this);
359 }
360 } // end of wxWindowOS2::~wxWindowOS2
361
362 // real construction (Init() must have been called before!)
363 bool wxWindowOS2::Create( wxWindow* pParent,
364 wxWindowID vId,
365 const wxPoint& rPos,
366 const wxSize& rSize,
367 long lStyle,
368 const wxString& rName )
369 {
370 HWND hParent = NULLHANDLE;
371 ULONG ulCreateFlags = 0;
372 WXDWORD dwExStyle = 0;
373
374 wxCHECK_MSG(pParent, false, wxT("can't create wxWindow without parent"));
375
376 #if wxUSE_STATBOX
377 //
378 // wxGTK doesn't allow to create controls with static box as the parent so
379 // this will result in a crash when the program is ported to wxGTK - warn
380 // about it
381 //
382 // the correct solution is to create the controls as siblings of the
383 // static box
384 //
385 wxASSERT_MSG( !wxDynamicCast(pParent, wxStaticBox),
386 wxT("wxStaticBox can't be used as a window parent!") );
387 #endif // wxUSE_STATBOX
388
389 // Ensure groupbox backgrounds are painted
390 if (IsKindOf(CLASSINFO(wxPanel)))
391 lStyle &= ~wxCLIP_CHILDREN;
392
393 if ( !CreateBase( pParent
394 ,vId
395 ,rPos
396 ,rSize
397 ,lStyle
398 ,wxDefaultValidator
399 ,rName
400 ))
401 return false;
402
403 if (pParent)
404 {
405 pParent->AddChild(this);
406 hParent = GetWinHwnd(pParent);
407
408 if (pParent->IsKindOf(CLASSINFO(wxScrolledWindow)))
409 ulCreateFlags |= WS_CLIPSIBLINGS;
410 }
411
412 //
413 // Most wxSTYLES are really PM Class specific styles and will be
414 // set in those class create procs. PM's basic windows styles are
415 // very limited.
416 //
417 ulCreateFlags |= OS2GetCreateWindowFlags(&dwExStyle);
418
419
420 #ifdef __WXUNIVERSAL__
421 // no 3d effects, we draw them ourselves
422 WXDWORD exStyle = 0;
423 #endif // !wxUniversal
424 if (lStyle & wxPOPUP_WINDOW)
425 {
426 ulCreateFlags &= ~WS_VISIBLE;
427 m_isShown = false;
428 }
429 else
430 {
431 ulCreateFlags |= WS_VISIBLE;
432 }
433
434 //
435 // Generic OS/2 Windows have no Control Data but other classes
436 // that call OS2Create may have some.
437 //
438 return(OS2Create( (PSZ)wxCanvasClassName
439 ,rName.c_str()
440 ,ulCreateFlags
441 ,rPos
442 ,rSize
443 ,NULL // Control Data
444 ,dwExStyle
445 ,true // Child
446 ));
447 } // end of wxWindowOS2::Create
448
449 // ---------------------------------------------------------------------------
450 // basic operations
451 // ---------------------------------------------------------------------------
452
453 void wxWindowOS2::SetFocus()
454 {
455 HWND hWnd = GetHwnd();
456 wxCHECK_RET( hWnd, wxT("can't set focus to invalid window") );
457
458 if (hWnd)
459 ::WinSetFocus(HWND_DESKTOP, hWnd);
460 } // end of wxWindowOS2::SetFocus
461
462 void wxWindowOS2::SetFocusFromKbd()
463 {
464 //
465 // Nothing else to do under OS/2
466 //
467 wxWindowBase::SetFocusFromKbd();
468 } // end of wxWindowOS2::SetFocus
469
470 wxWindow* wxWindowBase::DoFindFocus()
471 {
472 HWND hWnd = ::WinQueryFocus(HWND_DESKTOP);
473
474 if (hWnd)
475 {
476 return wxFindWinFromHandle((WXHWND)hWnd);
477 }
478 return NULL;
479 } // wxWindowBase::DoFindFocus
480
481 void wxWindowOS2::DoEnable( bool bEnable )
482 {
483 HWND hWnd = GetHwnd();
484 if ( hWnd )
485 ::WinEnableWindow(hWnd, (BOOL)bEnable);
486 }
487
488 bool wxWindowOS2::Show( bool bShow )
489 {
490 if (!wxWindowBase::Show(bShow))
491 return false;
492
493 HWND hWnd = GetHwnd();
494
495 ::WinShowWindow(hWnd, bShow);
496
497 if (bShow)
498 {
499 ::WinSetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER);
500 }
501 return true;
502 } // end of wxWindowOS2::Show
503
504 void wxWindowOS2::Raise()
505 {
506 ::WinSetWindowPos(GetHwnd(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | SWP_ACTIVATE);
507 } // end of wxWindowOS2::Raise
508
509 void wxWindowOS2::Lower()
510 {
511 ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER | SWP_DEACTIVATE);
512 } // end of wxWindowOS2::Lower
513
514 void wxWindowOS2::SetLabel( const wxString& label )
515 {
516 ::WinSetWindowText(GetHwnd(), label.c_str());
517 } // end of wxWindowOS2::SetLabel
518
519 wxString wxWindowOS2::GetLabel() const
520 {
521 return wxGetWindowText(GetHWND());
522 } // end of wxWindowOS2::GetLabel
523
524 void wxWindowOS2::DoCaptureMouse()
525 {
526 HWND hWnd = GetHwnd();
527
528 if (hWnd && !m_bWinCaptured)
529 {
530 ::WinSetCapture(HWND_DESKTOP, hWnd);
531 m_bWinCaptured = true;
532 }
533 } // end of wxWindowOS2::DoCaptureMouse
534
535 void wxWindowOS2::DoReleaseMouse()
536 {
537 if (m_bWinCaptured)
538 {
539 ::WinSetCapture(HWND_DESKTOP, NULLHANDLE);
540 m_bWinCaptured = false;
541 }
542 } // end of wxWindowOS2::ReleaseMouse
543
544 /* static */ wxWindow* wxWindowBase::GetCapture()
545 {
546 HWND hwnd = ::WinQueryCapture(HWND_DESKTOP);
547 return hwnd ? wxFindWinFromHandle((WXHWND)hwnd) : NULL;
548 } // end of wxWindowBase::GetCapture
549
550 bool wxWindowOS2::SetFont( const wxFont& rFont )
551 {
552 if (!wxWindowBase::SetFont(rFont))
553 {
554 // nothing to do
555 return false;
556 }
557
558 HWND hWnd = GetHwnd();
559
560 wxOS2SetFont( hWnd, rFont );
561 return true;
562 } // end of wxWindowOS2::SetFont
563
564 // check if base implementation is OK
565 bool wxWindowOS2::SetCursor( const wxCursor& rCursor)
566 {
567 if ( !wxWindowBase::SetCursor(rCursor))
568 {
569 // no change
570 return false;
571 }
572
573 if ( m_cursor.IsOk() ) {
574 HWND hWnd = GetHwnd();
575 POINTL vPoint;
576 RECTL vRect;
577
578 ::WinQueryPointerPos(HWND_DESKTOP, &vPoint);
579 ::WinQueryWindowRect(hWnd, &vRect);
580
581 if (::WinPtInRect(vHabmain, &vRect, &vPoint) && !wxIsBusy())
582 {
583 ::WinSetPointer(HWND_DESKTOP, (HPOINTER)m_cursor.GetHCURSOR());
584 }
585 }
586 return true;
587 } // end of wxWindowOS2::SetCursor
588
589 void wxWindowOS2::WarpPointer(
590 int nXPos
591 , int nYPos
592 )
593 {
594 int nX = nXPos;
595 int nY = nYPos;
596 RECTL vRect;
597
598 ::WinQueryWindowRect(GetHwnd(), &vRect);
599 nX += vRect.xLeft;
600 nY += vRect.yBottom;
601
602 ::WinSetPointerPos(HWND_DESKTOP, (LONG)nX, (LONG)(nY));
603 } // end of wxWindowOS2::WarpPointer
604
605
606 // ---------------------------------------------------------------------------
607 // scrolling stuff
608 // ---------------------------------------------------------------------------
609
610 int wxWindowOS2::GetScrollPos(
611 int nOrient
612 ) const
613 {
614 if (nOrient == wxHORIZONTAL)
615 return((int)::WinSendMsg(m_hWndScrollBarHorz, SBM_QUERYPOS, (MPARAM)NULL, (MPARAM)NULL));
616 else
617 return((int)::WinSendMsg(m_hWndScrollBarVert, SBM_QUERYPOS, (MPARAM)NULL, (MPARAM)NULL));
618 } // end of wxWindowOS2::GetScrollPos
619
620 int wxWindowOS2::GetScrollRange(
621 int nOrient
622 ) const
623 {
624 MRESULT mr;
625
626 if (nOrient == wxHORIZONTAL)
627 mr = ::WinSendMsg(m_hWndScrollBarHorz, SBM_QUERYRANGE, (MPARAM)NULL, (MPARAM)NULL);
628 else
629 mr = ::WinSendMsg(m_hWndScrollBarVert, SBM_QUERYRANGE, (MPARAM)NULL, (MPARAM)NULL);
630 return((int)SHORT2FROMMR(mr));
631 } // end of wxWindowOS2::GetScrollRange
632
633 int wxWindowOS2::GetScrollThumb(
634 int nOrient
635 ) const
636 {
637 if (nOrient == wxHORIZONTAL )
638 return m_nXThumbSize;
639 else
640 return m_nYThumbSize;
641 } // end of wxWindowOS2::GetScrollThumb
642
643 void wxWindowOS2::SetScrollPos(
644 int nOrient
645 , int nPos
646 , bool WXUNUSED(bRefresh)
647 )
648 {
649 if (nOrient == wxHORIZONTAL )
650 ::WinSendMsg(m_hWndScrollBarHorz, SBM_SETPOS, (MPARAM)nPos, (MPARAM)NULL);
651 else
652 ::WinSendMsg(m_hWndScrollBarVert, SBM_SETPOS, (MPARAM)nPos, (MPARAM)NULL);
653 } // end of wxWindowOS2::SetScrollPos
654
655 void wxWindowOS2::SetScrollbar( int nOrient,
656 int nPos,
657 int nThumbVisible,
658 int nRange,
659 bool WXUNUSED(bRefresh) )
660 {
661 HWND hWnd = GetHwnd();
662 int nOldRange = nRange - nThumbVisible;
663 int nRange1 = nOldRange;
664 int nPageSize = nThumbVisible;
665 int nVSBWidth = wxSystemSettingsNative::GetMetric(wxSYS_VSCROLL_X,
666 this);
667 int nHSBHeight = wxSystemSettingsNative::GetMetric(wxSYS_HSCROLL_Y,
668 this);
669
670 SBCDATA vInfo;
671 ULONG ulStyle = WS_VISIBLE | WS_SYNCPAINT;
672 SWP vSwp;
673 SWP vSwpOwner;
674 HWND hWndParent;
675 HWND hWndClient;
676 wxWindow* pParent = GetParent();
677
678 if (pParent && pParent->IsKindOf(CLASSINFO(wxFrame)))
679 {
680 wxFrame* pFrame;
681
682 pFrame = wxDynamicCast(pParent, wxFrame);
683 hWndParent = pFrame->GetFrame();
684 hWndClient = GetHwndOf(pParent);
685 }
686 else
687 {
688 if (pParent)
689 hWndParent = GetHwndOf(pParent);
690 else
691 hWndParent = GetHwnd();
692 hWndClient = hWndParent;
693 }
694 ::WinQueryWindowPos(hWndClient, &vSwp);
695 ::WinQueryWindowPos(hWnd, &vSwpOwner);
696
697 if (nPageSize > 1 && nRange > 0)
698 {
699 nRange1 += (nPageSize - 1);
700 }
701
702 vInfo.cb = sizeof(SBCDATA);
703 vInfo.posFirst = 0;
704 vInfo.posLast = (SHORT)nRange1;
705 vInfo.posThumb = (SHORT)nPos;
706
707 if (nOrient == wxHORIZONTAL )
708 {
709 ulStyle |= SBS_HORZ;
710 if (m_hWndScrollBarHorz == 0L)
711 {
712 //
713 // Since the scrollbars are usually created before the owner is
714 // sized either via an OnSize event directly or via sizers or
715 // layout constraints, we will initially just use the coords of
716 // the parent window (this is usually a frame client window). But
717 // the bars themselves, are children of the parent frame (i.e
718 // siblings of the frame client. The owner, however is the actual
719 // window being scrolled (or at least the one responsible for
720 // handling the scroll events). The owner will be resized later,
721 // as it is usually a child of a top level window, and when that
722 // is done its scrollbars will be resized and repositioned as well.
723 //
724 m_hWndScrollBarHorz = ::WinCreateWindow( hWndParent
725 ,WC_SCROLLBAR
726 ,(PSZ)NULL
727 ,ulStyle
728 ,vSwp.x
729 ,vSwp.y
730 ,vSwp.cx - nVSBWidth
731 ,nHSBHeight
732 ,hWnd
733 ,HWND_TOP
734 ,60000
735 ,&vInfo
736 ,NULL
737 );
738 }
739 else
740 {
741 //
742 // The owner (the scrolled window) is a child of the Frame's
743 // client window, usually. The scrollbars are children of the
744 // frame, itself, and thus are positioned relative to the frame's
745 // origin, not the frame's client window origin.
746 // The starting x position is the same as the starting x position
747 // of the owner, but in terms of the parent frame.
748 // The starting y position is wxSYS_HSCROLL_Y pels below the
749 // origin of the owner in terms of the parent frame.
750 // The horz bar is the same width as the owner and wxSYS_HSCROLL_Y
751 // pels high.
752 //
753 if (nRange1 >= nThumbVisible)
754 {
755 ::WinSetWindowPos( m_hWndScrollBarHorz
756 ,HWND_TOP
757 ,vSwp.x + vSwpOwner.x
758 ,(vSwp.y + vSwpOwner.y) - nHSBHeight
759 ,vSwpOwner.cx
760 ,nHSBHeight
761 ,SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER
762 );
763 ::WinSendMsg( m_hWndScrollBarHorz
764 ,SBM_SETSCROLLBAR
765 ,(MPARAM)nPos
766 ,MPFROM2SHORT(0, (SHORT)nRange1)
767 );
768 ::WinSendMsg( m_hWndScrollBarHorz
769 ,SBM_SETTHUMBSIZE
770 ,MPFROM2SHORT( (SHORT)nThumbVisible
771 ,(SHORT)nRange1
772 )
773 ,(MPARAM)0
774 );
775 }
776 else
777 ::WinShowWindow(m_hWndScrollBarHorz, FALSE);
778 }
779 }
780 else
781 {
782 ulStyle |= SBS_VERT;
783 if (m_hWndScrollBarVert == 0L)
784 {
785 //
786 // Since the scrollbars are usually created before the owner is
787 // sized either via an OnSize event directly or via sizers or
788 // layout constraints, we will initially just use the coords of
789 // the parent window (this is usually a frame client window). But
790 // the bars themselves, are children of the parent frame (i.e
791 // siblings of the frame client. The owner, however is the actual
792 // window being scrolled (or at least the one responsible for
793 // handling the scroll events). The owner will be resized later,
794 // as it is usually a child of a top level window, and when that
795 // is done its scrollbars will be resized and repositioned as well.
796 //
797 m_hWndScrollBarVert = ::WinCreateWindow( hWndParent
798 ,WC_SCROLLBAR
799 ,(PSZ)NULL
800 ,ulStyle
801 ,vSwp.x + vSwp.cx - nVSBWidth
802 ,vSwp.y + nHSBHeight
803 ,nVSBWidth
804 ,vSwp.cy - nHSBHeight
805 ,hWnd
806 ,HWND_TOP
807 ,60001
808 ,&vInfo
809 ,NULL
810 );
811 }
812 else
813 {
814 //
815 // The owner (the scrolled window) is a child of the Frame's
816 // client window, usually. The scrollbars are children of the
817 // frame, itself and thus are positioned relative to the frame's
818 // origin, not the frame's client window's origin.
819 // Thus, the x position will be frame client's x (usually a few
820 // pels inside the parent frame, plus the width of the owner.
821 // Since we may be using sizers or layout constraints for multiple
822 // child scrolled windows, the y position will be the frame client's
823 // y pos plus the scrolled windows y position, yielding the y
824 // position of the scrollbar relative to the parent frame (the vert
825 // scrollbar is on the right and starts at the bottom of the
826 // owner window).
827 // It is wxSYS_VSCROLL_X pels wide and the same height as the owner.
828 //
829 if (nRange1 >= nThumbVisible)
830 {
831 ::WinSetWindowPos( m_hWndScrollBarVert
832 ,HWND_TOP
833 ,vSwp.x + vSwpOwner.x + vSwpOwner.cx
834 ,vSwp.y + vSwpOwner.y
835 ,nVSBWidth
836 ,vSwpOwner.cy
837 ,SWP_ACTIVATE | SWP_MOVE | SWP_SIZE | SWP_SHOW
838 );
839 ::WinSendMsg( m_hWndScrollBarVert
840 ,SBM_SETSCROLLBAR
841 ,(MPARAM)nPos
842 ,MPFROM2SHORT(0, (SHORT)nRange1)
843 );
844 ::WinSendMsg( m_hWndScrollBarVert
845 ,SBM_SETTHUMBSIZE
846 ,MPFROM2SHORT( (SHORT)nThumbVisible
847 ,(SHORT)nRange1
848 )
849 ,(MPARAM)0
850 );
851 }
852 else
853 ::WinShowWindow(m_hWndScrollBarVert, FALSE);
854 }
855 m_nYThumbSize = nThumbVisible;
856 }
857 } // end of wxWindowOS2::SetScrollbar
858
859
860 void wxWindowOS2::ScrollWindow( int nDx,
861 int nDy,
862 const wxRect* pRect )
863 {
864 RECTL vRect;
865
866 ::WinQueryWindowRect(GetHwnd(), &vRect);
867 int height = vRect.yTop;
868 if (pRect)
869 {
870 vRect.xLeft = pRect->x;
871 vRect.yTop = height - pRect->y;
872 vRect.xRight = pRect->x + pRect->width;
873 vRect.yBottom = vRect.yTop - pRect->height;
874 }
875 nDy *= -1; // flip the sign of Dy as OS/2 is opposite Windows.
876 ::WinScrollWindow( GetHwnd()
877 ,(LONG)nDx
878 ,(LONG)nDy
879 ,&vRect
880 ,&vRect
881 ,NULL
882 ,NULL
883 ,SW_SCROLLCHILDREN | SW_INVALIDATERGN
884 );
885 } // end of wxWindowOS2::ScrollWindow
886
887 // ---------------------------------------------------------------------------
888 // subclassing
889 // ---------------------------------------------------------------------------
890
891 void wxWindowOS2::SubclassWin(
892 WXHWND hWnd
893 )
894 {
895 HWND hwnd = (HWND)hWnd;
896
897 wxCHECK_RET(::WinIsWindow(vHabmain, hwnd), wxT("invalid HWND in SubclassWin") );
898 wxAssociateWinWithHandle( hWnd
899 ,(wxWindow*)this
900 );
901 if (!wxCheckWindowWndProc( hWnd
902 ,(WXFARPROC)wxWndProc
903 ))
904 {
905 m_fnOldWndProc = (WXFARPROC) ::WinSubclassWindow(hwnd, (PFNWP)wxWndProc);
906 }
907 else
908 {
909 m_fnOldWndProc = (WXFARPROC)NULL;
910 }
911 } // end of wxWindowOS2::SubclassWin
912
913 void wxWindowOS2::UnsubclassWin()
914 {
915 //
916 // Restore old Window proc
917 //
918 HWND hwnd = GetHWND();
919
920 if (m_hWnd)
921 {
922 wxCHECK_RET( ::WinIsWindow(vHabmain, hwnd), wxT("invalid HWND in UnsubclassWin") );
923
924 PFNWP fnProc = (PFNWP)::WinQueryWindowPtr(hwnd, QWP_PFNWP);
925
926 if ( (m_fnOldWndProc != 0) && (fnProc != (PFNWP) m_fnOldWndProc))
927 {
928 WinSubclassWindow(hwnd, (PFNWP)m_fnOldWndProc);
929 m_fnOldWndProc = 0;
930 }
931 }
932 } // end of wxWindowOS2::UnsubclassWin
933
934 bool wxCheckWindowWndProc(
935 WXHWND hWnd
936 , WXFARPROC fnWndProc
937 )
938 {
939 static char zBuffer[512];
940 CLASSINFO vCls;
941
942 ::WinQueryClassName((HWND)hWnd, (LONG)512, (PCH)zBuffer);
943 ::WinQueryClassInfo(wxGetInstance(), (PSZ)zBuffer, &vCls);
944 return(fnWndProc == (WXFARPROC)vCls.pfnWindowProc);
945 } // end of WinGuiBase_CheckWindowWndProc
946
947 void wxWindowOS2::SetWindowStyleFlag(
948 long lFlags
949 )
950 {
951 long lFlagsOld = GetWindowStyleFlag();
952
953 if (lFlags == lFlagsOld)
954 return;
955
956 //
957 // Update the internal variable
958 //
959 wxWindowBase::SetWindowStyleFlag(lFlags);
960
961 //
962 // Now update the Windows style as well if needed - and if the window had
963 // been already created
964 //
965 if (!GetHwnd())
966 return;
967
968 WXDWORD dwExstyle;
969 WXDWORD dwExstyleOld;
970 long lStyle = OS2GetStyle( lFlags
971 ,&dwExstyle
972 );
973 long lStyleOld = OS2GetStyle( lFlagsOld
974 ,&dwExstyleOld
975 );
976
977 if (lStyle != lStyleOld)
978 {
979 //
980 // Some flags (e.g. WS_VISIBLE or WS_DISABLED) should not be changed by
981 // this function so instead of simply setting the style to the new
982 // value we clear the bits which were set in styleOld but are set in
983 // the new one and set the ones which were not set before
984 //
985 long lStyleReal = ::WinQueryWindowULong(GetHwnd(), QWL_STYLE);
986
987 lStyleReal &= ~lStyleOld;
988 lStyleReal |= lStyle;
989
990 ::WinSetWindowULong(GetHwnd(), QWL_STYLE, lStyleReal);
991 }
992 } // end of wxWindowOS2::SetWindowStyleFlag
993
994 WXDWORD wxWindowOS2::OS2GetStyle( long lFlags,
995 WXDWORD* WXUNUSED(pdwExstyle) ) const
996 {
997 WXDWORD dwStyle = 0L;
998
999 if (lFlags & wxCLIP_CHILDREN )
1000 dwStyle |= WS_CLIPCHILDREN;
1001
1002 if (lFlags & wxCLIP_SIBLINGS )
1003 dwStyle |= WS_CLIPSIBLINGS;
1004
1005 return dwStyle;
1006 } // end of wxWindowOS2::OS2GetStyle
1007
1008 //
1009 // Make a Windows extended style from the given wxWidgets window style
1010 //
1011 WXDWORD wxWindowOS2::MakeExtendedStyle(
1012 long lStyle
1013 , bool bEliminateBorders
1014 )
1015 {
1016 //
1017 // Simply fill out with wxWindow extended styles. We'll conjure
1018 // something up in OS2Create and all window redrawing pieces later
1019 //
1020 WXDWORD dwStyle = 0;
1021
1022 if (lStyle & wxTRANSPARENT_WINDOW )
1023 dwStyle |= wxTRANSPARENT_WINDOW;
1024
1025 if (!bEliminateBorders)
1026 {
1027 if (lStyle & wxSUNKEN_BORDER)
1028 dwStyle |= wxSUNKEN_BORDER;
1029 if (lStyle & wxDOUBLE_BORDER)
1030 dwStyle |= wxDOUBLE_BORDER;
1031 if (lStyle & wxRAISED_BORDER )
1032 dwStyle |= wxRAISED_BORDER;
1033 if (lStyle & wxSTATIC_BORDER)
1034 dwStyle |= wxSTATIC_BORDER;
1035 }
1036 return dwStyle;
1037 } // end of wxWindowOS2::MakeExtendedStyle
1038
1039 //
1040 // Setup background and foreground colours correctly
1041 //
1042 void wxWindowOS2::SetupColours()
1043 {
1044 if ( GetParent() )
1045 SetBackgroundColour(GetParent()->GetBackgroundColour());
1046 } // end of wxWindowOS2::SetupColours
1047
1048 void wxWindowOS2::OnIdle(
1049 wxIdleEvent& WXUNUSED(rEvent)
1050 )
1051 {
1052 //
1053 // Check if we need to send a LEAVE event
1054 //
1055 if (m_bMouseInWindow)
1056 {
1057 POINTL vPoint;
1058
1059 ::WinQueryPointerPos(HWND_DESKTOP, &vPoint);
1060 if (::WinWindowFromPoint(HWND_DESKTOP, &vPoint, FALSE) != (HWND)GetHwnd())
1061 {
1062 //
1063 // Generate a LEAVE event
1064 //
1065 m_bMouseInWindow = false;
1066
1067 //
1068 // Unfortunately the mouse button and keyboard state may have changed
1069 // by the time the OnIdle function is called, so 'state' may be
1070 // meaningless.
1071 //
1072 int nState = 0;
1073
1074 if (IsShiftDown())
1075 nState |= KC_SHIFT;
1076 if (IsCtrlDown())
1077 nState |= KC_CTRL;
1078
1079 wxMouseEvent rEvent(wxEVT_LEAVE_WINDOW);
1080
1081 InitMouseEvent( rEvent
1082 ,vPoint.x
1083 ,vPoint.y
1084 ,nState
1085 );
1086 (void)HandleWindowEvent(rEvent);
1087 }
1088 }
1089 } // end of wxWindowOS2::OnIdle
1090
1091 //
1092 // Set this window to be the child of 'parent'.
1093 //
1094 bool wxWindowOS2::Reparent( wxWindowBase* pParent)
1095 {
1096 if (!wxWindowBase::Reparent(pParent))
1097 return false;
1098
1099 HWND hWndChild = GetHwnd();
1100 HWND hWndParent = GetParent() ? GetWinHwnd(GetParent()) : (HWND)0;
1101
1102 ::WinSetParent(hWndChild, hWndParent, TRUE);
1103 return true;
1104 } // end of wxWindowOS2::Reparent
1105
1106 void wxWindowOS2::Update()
1107 {
1108 ::WinUpdateWindow(GetHwnd());
1109 } // end of wxWindowOS2::Update
1110
1111 void wxWindowOS2::DoFreeze()
1112 {
1113 ::WinSendMsg(GetHwnd(), WM_VRNDISABLED, (MPARAM)0, (MPARAM)0);
1114 } // end of wxWindowOS2::Freeze
1115
1116 void wxWindowOS2::DoThaw()
1117 {
1118 ::WinSendMsg(GetHwnd(), WM_VRNENABLED, (MPARAM)TRUE, (MPARAM)0);
1119
1120 //
1121 // We need to refresh everything or otherwise he invalidated area is not
1122 // repainted.
1123 //
1124 Refresh();
1125 } // end of wxWindowOS2::Thaw
1126
1127 void wxWindowOS2::Refresh( bool bEraseBack,
1128 const wxRect* pRect )
1129 {
1130 HWND hWnd = GetHwnd();
1131
1132 if (hWnd)
1133 {
1134 if (pRect)
1135 {
1136 RECTL vOs2Rect;
1137 int height;
1138
1139 ::WinQueryWindowRect(GetHwnd(), &vOs2Rect);
1140 height = vOs2Rect.yTop;
1141 vOs2Rect.xLeft = pRect->x;
1142 vOs2Rect.yTop = height - pRect->y;
1143 vOs2Rect.xRight = pRect->x + pRect->width;
1144 vOs2Rect.yBottom = vOs2Rect.yTop - pRect->height;
1145
1146 ::WinInvalidateRect(hWnd, &vOs2Rect, bEraseBack);
1147 }
1148 else
1149 ::WinInvalidateRect(hWnd, NULL, bEraseBack);
1150 if (m_hWndScrollBarHorz != NULLHANDLE)
1151 ::WinInvalidateRect(m_hWndScrollBarHorz, NULL, TRUE);
1152 if (m_hWndScrollBarVert != NULLHANDLE)
1153 ::WinInvalidateRect(m_hWndScrollBarVert, NULL, TRUE);
1154 }
1155 } // end of wxWindowOS2::Refresh
1156
1157 // ---------------------------------------------------------------------------
1158 // drag and drop
1159 // ---------------------------------------------------------------------------
1160
1161 #if wxUSE_DRAG_AND_DROP
1162 void wxWindowOS2::SetDropTarget(
1163 wxDropTarget* pDropTarget
1164 )
1165 {
1166 m_dropTarget = pDropTarget;
1167 } // end of wxWindowOS2::SetDropTarget
1168 #endif
1169
1170 //
1171 // old style file-manager drag&drop support: we retain the old-style
1172 // DragAcceptFiles in parallel with SetDropTarget.
1173 //
1174 void wxWindowOS2::DragAcceptFiles(
1175 bool bAccept
1176 )
1177 {
1178 HWND hWnd = GetHwnd();
1179
1180 if (hWnd && bAccept)
1181 ::DrgAcceptDroppedFiles(hWnd, NULL, NULL, DO_COPY, 0L);
1182 } // end of wxWindowOS2::DragAcceptFiles
1183
1184 // ----------------------------------------------------------------------------
1185 // tooltips
1186 // ----------------------------------------------------------------------------
1187
1188 #if wxUSE_TOOLTIPS
1189
1190 void wxWindowOS2::DoSetToolTip(
1191 wxToolTip* pTooltip
1192 )
1193 {
1194 wxWindowBase::DoSetToolTip(pTooltip);
1195
1196 if (m_tooltip)
1197 m_tooltip->SetWindow(this);
1198 } // end of wxWindowOS2::DoSetToolTip
1199
1200 #endif // wxUSE_TOOLTIPS
1201
1202 // ---------------------------------------------------------------------------
1203 // moving and resizing
1204 // ---------------------------------------------------------------------------
1205
1206 // Get total size
1207 void wxWindowOS2::DoGetSize(
1208 int* pWidth
1209 , int* pHeight
1210 ) const
1211 {
1212 HWND hWnd;
1213 RECTL vRect;
1214
1215 if (IsKindOf(CLASSINFO(wxFrame)))
1216 {
1217 wxFrame* pFrame = wxDynamicCast(this, wxFrame);
1218 hWnd = pFrame->GetFrame();
1219 }
1220 else
1221 hWnd = GetHwnd();
1222
1223 ::WinQueryWindowRect(hWnd, &vRect);
1224
1225 if (pWidth)
1226 *pWidth = vRect.xRight - vRect.xLeft;
1227 if (pHeight )
1228 // OS/2 PM is backwards from windows
1229 *pHeight = vRect.yTop - vRect.yBottom;
1230 } // end of wxWindowOS2::DoGetSize
1231
1232 void wxWindowOS2::DoGetPosition(
1233 int* pX
1234 , int* pY
1235 ) const
1236 {
1237 //
1238 // Return parameters assume wxWidgets coordinate system
1239 //
1240 HWND hWnd;
1241 SWP vSwp;
1242 POINTL vPoint;
1243 wxWindow* pParent = GetParent();
1244
1245 //
1246 // It would seem that WinQueryWindowRect would be the correlary to
1247 // the WIN32 WinGetRect, but unlike WinGetRect which returns the window
1248 // origin position in screen coordinates, WinQueryWindowRect returns it
1249 // relative to itself, i.e. (0,0). To get the same under PM we must
1250 // use WinQueryWindowPos. This call, unlike the WIN32 call, however,
1251 // returns a position relative to it's parent, so no parent adujstments
1252 // are needed under OS/2. Also, windows should be created using
1253 // wxWindow coordinates, i.e. 0,0 is the TOP left.
1254 //
1255 if (IsKindOf(CLASSINFO(wxFrame)))
1256 {
1257 wxFrame* pFrame = wxDynamicCast(this, wxFrame);
1258 hWnd = pFrame->GetFrame();
1259 }
1260 else
1261 hWnd = GetHwnd();
1262
1263 ::WinQueryWindowPos(hWnd, &vSwp);
1264
1265 vPoint.x = vSwp.x;
1266 vPoint.y = vSwp.y;
1267
1268 // We need to convert to wxWidgets coordinates
1269 int vHeight;
1270 DoGetSize(NULL,&vHeight);
1271 wxWindow* pWindow = wxDynamicCast(this,wxWindow);
1272 vPoint.y = pWindow->GetOS2ParentHeight(pParent) - vPoint.y - vHeight;
1273
1274 //
1275 // We may be faking the client origin. So a window that's really at (0,
1276 // 30) may appear (to wxWin apps) to be at (0, 0).
1277 //
1278 if (pParent)
1279 {
1280 wxPoint vPt(pParent->GetClientAreaOrigin());
1281
1282 vPoint.x -= vPt.x;
1283 vPoint.y -= vPt.y;
1284 }
1285
1286 if (pX)
1287 *pX = vPoint.x;
1288 if (pY)
1289 *pY = vPoint.y;
1290 } // end of wxWindowOS2::DoGetPosition
1291
1292 void wxWindowOS2::DoScreenToClient(
1293 int* pX
1294 , int* pY
1295 ) const
1296 {
1297 HWND hWnd = GetHwnd();
1298 SWP vSwp;
1299
1300 ::WinQueryWindowPos(hWnd, &vSwp);
1301
1302 if (pX)
1303 *pX += vSwp.x;
1304 if (pY)
1305 *pY += vSwp.y;
1306 } // end of wxWindowOS2::DoScreenToClient
1307
1308 void wxWindowOS2::DoClientToScreen(
1309 int* pX
1310 , int* pY
1311 ) const
1312 {
1313 HWND hWnd = GetHwnd();
1314 SWP vSwp;
1315
1316 ::WinQueryWindowPos(hWnd, &vSwp);
1317
1318 if (pX)
1319 *pX += vSwp.x;
1320 if (pY)
1321 *pY += vSwp.y;
1322 } // end of wxWindowOS2::DoClientToScreen
1323
1324 //
1325 // Get size *available for subwindows* i.e. excluding menu bar etc.
1326 // Must be a frame type window
1327 //
1328 void wxWindowOS2::DoGetClientSize(
1329 int* pWidth
1330 , int* pHeight
1331 ) const
1332 {
1333 HWND hWnd = GetHwnd();
1334 RECTL vRect;
1335
1336 ::WinQueryWindowRect(hWnd, &vRect);
1337 if (IsKindOf(CLASSINFO(wxDialog)))
1338 {
1339 RECTL vTitle;
1340 HWND hWndTitle;
1341 //
1342 // For a Dialog we have to explicitly request the client portion.
1343 // For a Frame the hWnd IS the client window
1344 //
1345 hWndTitle = ::WinWindowFromID(hWnd, FID_TITLEBAR);
1346 if (::WinQueryWindowRect(hWndTitle, &vTitle))
1347 {
1348 if (vTitle.yTop - vTitle.yBottom == 0)
1349 {
1350 //
1351 // Dialog has not been created yet, use a default
1352 //
1353 vTitle.yTop = 20;
1354 }
1355 vRect.yTop -= (vTitle.yTop - vTitle.yBottom);
1356 }
1357
1358 ULONG uStyle = ::WinQueryWindowULong(hWnd, QWL_STYLE);
1359
1360 //
1361 // Deal with borders
1362 //
1363 if (uStyle & FCF_DLGBORDER)
1364 {
1365 vRect.xLeft += 4;
1366 vRect.xRight -= 4;
1367 vRect.yTop -= 4;
1368 vRect.yBottom += 4;
1369 }
1370 else if (uStyle & FCF_SIZEBORDER)
1371 {
1372 vRect.xLeft += 4;
1373 vRect.xRight -= 4;
1374 vRect.yTop -= 4;
1375 vRect.yBottom += 4;
1376 }
1377 else if (uStyle & FCF_BORDER)
1378 {
1379 vRect.xLeft += 2;
1380 vRect.xRight -= 2;
1381 vRect.yTop -= 2;
1382 vRect.yBottom += 2;
1383 }
1384 else // make some kind of adjustment or top sizers ram into the titlebar!
1385 {
1386 vRect.xLeft += 3;
1387 vRect.xRight -= 3;
1388 vRect.yTop -= 3;
1389 vRect.yBottom += 3;
1390 }
1391 }
1392 if (pWidth)
1393 *pWidth = vRect.xRight - vRect.xLeft;
1394 if (pHeight)
1395 *pHeight = vRect.yTop - vRect.yBottom;
1396 } // end of wxWindowOS2::DoGetClientSize
1397
1398 void wxWindowOS2::DoMoveWindow(
1399 int nX
1400 , int nY
1401 , int nWidth
1402 , int nHeight
1403 )
1404 {
1405 //
1406 // Input parameters assume wxWidgets coordinate system
1407 //
1408 RECTL vRect;
1409 wxWindow* pParent = GetParent();
1410 HWND hWnd = GetHwnd();
1411
1412 if (pParent && !IsKindOf(CLASSINFO(wxDialog)))
1413 {
1414 int nOS2Height = GetOS2ParentHeight(pParent);
1415
1416 nY = nOS2Height - (nY + nHeight);
1417 }
1418 else
1419 {
1420 RECTL vRect;
1421
1422 ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
1423 nY = vRect.yTop - (nY + nHeight);
1424 }
1425
1426 //
1427 // In the case of a frame whose client is sized, the client cannot be
1428 // large than its parent frame minus its borders! This usually happens
1429 // when using an autosizer to size a frame to precisely hold client
1430 // controls as in the notebook sample.
1431 //
1432 // In this case, we may need to resize both a frame and its client so we
1433 // need a quick calc of the frame border size, then if the frame
1434 // (less its borders) is smaller than the client, size the frame to
1435 // encompass the client with the appropriate border size.
1436 //
1437 if (IsKindOf(CLASSINFO(wxFrame)))
1438 {
1439 RECTL vFRect;
1440 int nWidthFrameDelta = 0;
1441 int nHeightFrameDelta = 0;
1442 wxFrame* pFrame;
1443
1444 pFrame = wxDynamicCast(this, wxFrame);
1445 hWnd = pFrame->GetFrame();
1446 ::WinQueryWindowRect(hWnd, &vRect);
1447 ::WinMapWindowPoints(hWnd, HWND_DESKTOP, (PPOINTL)&vRect, 2);
1448 vFRect = vRect;
1449 ::WinCalcFrameRect(hWnd, &vRect, TRUE);
1450 nWidthFrameDelta = ((vRect.xLeft - vFRect.xLeft) + (vFRect.xRight - vRect.xRight));
1451 nHeightFrameDelta = ((vRect.yBottom - vFRect.yBottom) + (vFRect.yTop - vRect.yTop));
1452 // Input values refer to the window position relative to its parent
1453 // which may be the Desktop so we need to calculate
1454 // the new frame values to keep the wxWidgets frame origin constant
1455 nY -= nHeightFrameDelta;
1456 nWidth += nWidthFrameDelta;
1457 nHeight += nHeightFrameDelta;
1458 }
1459 ::WinSetWindowPos( hWnd
1460 ,HWND_TOP
1461 ,(LONG)nX
1462 ,(LONG)nY
1463 ,(LONG)nWidth
1464 ,(LONG)nHeight
1465 ,SWP_SIZE | SWP_MOVE
1466 );
1467 if (m_vWinSwp.cx == 0 && m_vWinSwp.cy == 0 && m_vWinSwp.fl == 0)
1468 //
1469 // Uninitialized
1470 //
1471 ::WinQueryWindowPos(hWnd, &m_vWinSwp);
1472 else
1473 {
1474 //
1475 // Handle resizing of scrolled windows. The target or window to
1476 // be scrolled is the owner (gets the scroll notifications). The
1477 // parent is usually the parent frame of the scrolled panel window.
1478 // In order to show the scrollbars the target window will be shrunk
1479 // by the size of the scroll bar widths and moved in the X and Y
1480 // directon. That value will be computed as part of the diff for
1481 // moving the children. Everytime the window is sized the
1482 // toplevel OnSize is going to resize the panel to fit the client
1483 // or the whole sizer and will need to me resized. This will send
1484 // a WM_SIZE out which will be intercepted by the ScrollHelper
1485 // which will cause the scrollbars to be displayed via the SetScrollbar
1486 // call in CWindow.
1487 //
1488 if (IsKindOf(CLASSINFO(wxScrolledWindow)))
1489 {
1490 int nAdjustWidth = 0;
1491 int nAdjustHeight = 0;
1492 int nHSBHeight = wxSystemSettingsNative::GetMetric(wxSYS_HSCROLL_Y,
1493 this);
1494 int nVSBWidth = wxSystemSettingsNative::GetMetric(wxSYS_VSCROLL_X,
1495 this);
1496 SWP vSwpScroll;
1497
1498 if (GetScrollBarHorz() == NULLHANDLE ||
1499 !WinIsWindowShowing(GetScrollBarHorz()))
1500 nAdjustHeight = 0L;
1501 else
1502 nAdjustHeight = nHSBHeight;
1503 if (GetScrollBarVert() == NULLHANDLE ||
1504 !WinIsWindowShowing(GetScrollBarVert()))
1505 nAdjustWidth = 0L;
1506 else
1507 nAdjustWidth = nVSBWidth;
1508 ::WinQueryWindowPos(hWnd, &vSwpScroll);
1509 ::WinSetWindowPos( hWnd
1510 ,HWND_TOP
1511 ,vSwpScroll.x
1512 ,vSwpScroll.y + nAdjustHeight
1513 ,vSwpScroll.cx - nAdjustWidth
1514 ,vSwpScroll.cy - nAdjustHeight
1515 ,SWP_MOVE | SWP_SIZE
1516 );
1517 }
1518 ::WinQueryWindowPos(hWnd, &m_vWinSwp);
1519 }
1520 } // end of wxWindowOS2::DoMoveWindow
1521
1522 //
1523 // Set the size of the window: if the dimensions are positive, just use them,
1524 // but if any of them is equal to -1, it means that we must find the value for
1525 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
1526 // which case -1 is a valid value for x and y)
1527 //
1528 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
1529 // the width/height to best suit our contents, otherwise we reuse the current
1530 // width/height
1531 //
1532 void wxWindowOS2::DoSetSize( int nX,
1533 int nY,
1534 int nWidth,
1535 int nHeight,
1536 int nSizeFlags )
1537 {
1538 //
1539 // Input & output parameters assume wxWidgets coordinate system
1540 //
1541
1542 //
1543 // Get the current size and position...
1544 //
1545 int nCurrentX;
1546 int nCurrentY;
1547 int nCurrentWidth;
1548 int nCurrentHeight;
1549 wxSize vSize = wxDefaultSize;
1550
1551 GetPosition(&nCurrentX, &nCurrentY);
1552 GetSize(&nCurrentWidth, &nCurrentHeight);
1553
1554 //
1555 // ... and don't do anything (avoiding flicker) if it's already ok
1556 //
1557 if (nX == nCurrentX && nY == nCurrentY &&
1558 nWidth == nCurrentWidth && nHeight == nCurrentHeight)
1559 {
1560 return;
1561 }
1562
1563 if (nX == wxDefaultCoord && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE))
1564 nX = nCurrentX;
1565 if (nY == wxDefaultCoord && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE))
1566 nY = nCurrentY;
1567
1568 AdjustForParentClientOrigin(nX, nY, nSizeFlags);
1569
1570 if (nWidth == wxDefaultCoord)
1571 {
1572 if (nSizeFlags & wxSIZE_AUTO_WIDTH)
1573 {
1574 vSize = DoGetBestSize();
1575 nWidth = vSize.x;
1576 }
1577 else
1578 {
1579 //
1580 // Just take the current one
1581 //
1582 nWidth = nCurrentWidth;
1583 }
1584 }
1585
1586 if (nHeight == wxDefaultCoord)
1587 {
1588 if (nSizeFlags & wxSIZE_AUTO_HEIGHT)
1589 {
1590 if (vSize.x == wxDefaultCoord)
1591 {
1592 vSize = DoGetBestSize();
1593 }
1594 nHeight = vSize.y;
1595 }
1596 else
1597 {
1598 // just take the current one
1599 nHeight = nCurrentHeight;
1600 }
1601 }
1602
1603 DoMoveWindow( nX, nY, nWidth, nHeight );
1604 } // end of wxWindowOS2::DoSetSize
1605
1606 void wxWindowOS2::DoSetClientSize( int nWidth,
1607 int nHeight )
1608 {
1609 //
1610 // nX & nY assume wxWidgets coordinate system
1611 //
1612 int nX;
1613 int nY;
1614
1615 GetPosition(&nX, &nY);
1616
1617 DoMoveWindow( nX, nY, nWidth, nHeight );
1618
1619 wxSize size( nWidth, nHeight );
1620 wxSizeEvent vEvent( size, m_windowId );
1621 vEvent.SetEventObject(this);
1622 HandleWindowEvent(vEvent);
1623 } // end of wxWindowOS2::DoSetClientSize
1624
1625 // ---------------------------------------------------------------------------
1626 // text metrics
1627 // ---------------------------------------------------------------------------
1628
1629 int wxWindowOS2::GetCharHeight() const
1630 {
1631 HPS hPs;
1632 FONTMETRICS vFontMetrics;
1633
1634 hPs = ::WinGetPS(GetHwnd());
1635
1636 if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics))
1637 {
1638 ::WinReleasePS(hPs);
1639 return (0);
1640 }
1641 ::WinReleasePS(hPs);
1642 return(vFontMetrics.lMaxAscender + vFontMetrics.lMaxDescender);
1643 } // end of wxWindowOS2::GetCharHeight
1644
1645 int wxWindowOS2::GetCharWidth() const
1646 {
1647 HPS hPs;
1648 FONTMETRICS vFontMetrics;
1649
1650 hPs = ::WinGetPS(GetHwnd());
1651
1652 if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics))
1653 {
1654 ::WinReleasePS(hPs);
1655 return (0);
1656 }
1657 ::WinReleasePS(hPs);
1658 return(vFontMetrics.lAveCharWidth);
1659 } // end of wxWindowOS2::GetCharWidth
1660
1661 void wxWindowOS2::DoGetTextExtent( const wxString& rString,
1662 int* pX,
1663 int* pY,
1664 int* pDescent,
1665 int* pExternalLeading,
1666 const wxFont* WXUNUSED(pTheFont) ) const
1667 {
1668 POINTL avPoint[TXTBOX_COUNT];
1669 POINTL vPtMin;
1670 POINTL vPtMax;
1671 int i;
1672 int l;
1673 FONTMETRICS vFM; // metrics structure
1674 BOOL bRc = FALSE;
1675 HPS hPS;
1676
1677 hPS = ::WinGetPS(GetHwnd());
1678
1679 l = rString.length();
1680 if (l > 0L)
1681 {
1682 //
1683 // In world coordinates.
1684 //
1685 bRc = ::GpiQueryTextBox( hPS,
1686 l,
1687 (char*) rString.wx_str(),
1688 TXTBOX_COUNT,// return maximum information
1689 avPoint // array of coordinates points
1690 );
1691 if (bRc)
1692 {
1693 vPtMin.x = avPoint[0].x;
1694 vPtMax.x = avPoint[0].x;
1695 vPtMin.y = avPoint[0].y;
1696 vPtMax.y = avPoint[0].y;
1697 for (i = 1; i < 4; i++)
1698 {
1699 if(vPtMin.x > avPoint[i].x) vPtMin.x = avPoint[i].x;
1700 if(vPtMin.y > avPoint[i].y) vPtMin.y = avPoint[i].y;
1701 if(vPtMax.x < avPoint[i].x) vPtMax.x = avPoint[i].x;
1702 if(vPtMax.y < avPoint[i].y) vPtMax.y = avPoint[i].y;
1703 }
1704 bRc = ::GpiQueryFontMetrics( hPS
1705 ,sizeof(FONTMETRICS)
1706 ,&vFM
1707 );
1708 if (!bRc)
1709 {
1710 vPtMin.x = 0;
1711 vPtMin.y = 0;
1712 vPtMax.x = 0;
1713 vPtMax.y = 0;
1714 }
1715 }
1716 else
1717 {
1718 vPtMin.x = 0;
1719 vPtMin.y = 0;
1720 vPtMax.x = 0;
1721 vPtMax.y = 0;
1722 }
1723 }
1724 else
1725 {
1726 vPtMin.x = 0;
1727 vPtMin.y = 0;
1728 vPtMax.x = 0;
1729 vPtMax.y = 0;
1730 }
1731 if (pX)
1732 *pX = (vPtMax.x - vPtMin.x + 1);
1733 if (pY)
1734 *pY = (vPtMax.y - vPtMin.y + 1);
1735 if (pDescent)
1736 {
1737 if (bRc)
1738 *pDescent = vFM.lMaxDescender;
1739 else
1740 *pDescent = 0;
1741 }
1742 if (pExternalLeading)
1743 {
1744 if (bRc)
1745 *pExternalLeading = vFM.lExternalLeading;
1746 else
1747 *pExternalLeading = 0;
1748 }
1749 ::WinReleasePS(hPS);
1750 } // end of wxWindow::DoGetTextExtent
1751
1752 bool wxWindowOS2::IsMouseInWindow() const
1753 {
1754 //
1755 // Get the mouse position
1756 POINTL vPt;
1757
1758 ::WinQueryPointerPos(HWND_DESKTOP, &vPt);
1759
1760 //
1761 // Find the window which currently has the cursor and go up the window
1762 // chain until we find this window - or exhaust it
1763 //
1764 HWND hWnd = ::WinWindowFromPoint(HWND_DESKTOP, &vPt, TRUE);
1765
1766 while (hWnd && (hWnd != GetHwnd()))
1767 hWnd = ::WinQueryWindow(hWnd, QW_PARENT);
1768
1769 return hWnd != NULL;
1770 } // end of wxWindowOS2::IsMouseInWindow
1771
1772
1773 // ---------------------------------------------------------------------------
1774 // popup menu
1775 // ---------------------------------------------------------------------------
1776 //
1777 #if wxUSE_MENUS_NATIVE
1778 bool wxWindowOS2::DoPopupMenu( wxMenu* pMenu, int nX, int nY )
1779 {
1780 HWND hWndOwner = GetHwnd();
1781 HWND hWndParent = GetHwnd();
1782 HWND hMenu = GetHmenuOf(pMenu);
1783 bool bIsWaiting = true;
1784 int nHeight;
1785
1786 pMenu->UpdateUI();
1787
1788 if ( nX == -1 && nY == -1 )
1789 {
1790 wxPoint mouse = wxGetMousePosition();
1791 nX = mouse.x; nY = mouse.y;
1792 }
1793 else
1794 {
1795 DoClientToScreen( &nX
1796 ,&nY
1797 );
1798 DoGetSize(0,&nHeight);
1799 nY = nHeight - nY;
1800 }
1801
1802 ::WinPopupMenu( hWndParent
1803 ,hWndOwner
1804 ,hMenu
1805 ,nX
1806 ,nY
1807 ,0L
1808 ,PU_HCONSTRAIN | PU_VCONSTRAIN | PU_MOUSEBUTTON1 | PU_KEYBOARD
1809 );
1810
1811 while(bIsWaiting)
1812 {
1813 QMSG vMsg;
1814
1815 ::WinGetMsg(vHabmain,&vMsg, (HWND)0, 0, 0);
1816 if (vMsg.msg == WM_COMMAND)
1817 bIsWaiting = false;
1818 ::WinDispatchMsg(vHabmain, (PQMSG)&vMsg);
1819 }
1820
1821 return true;
1822 } // end of wxWindowOS2::DoPopupMenu
1823 #endif // wxUSE_MENUS_NATIVE
1824
1825 // ===========================================================================
1826 // pre/post message processing
1827 // ===========================================================================
1828
1829 MRESULT wxWindowOS2::OS2DefWindowProc( WXUINT uMsg,
1830 WXWPARAM wParam,
1831 WXLPARAM lParam )
1832 {
1833 if (m_fnOldWndProc)
1834 return (MRESULT)m_fnOldWndProc(GetHWND(), uMsg, (MPARAM)wParam, (MPARAM)lParam);
1835 else
1836 return ::WinDefWindowProc(GetHWND(), uMsg, (MPARAM)wParam, (MPARAM)lParam);
1837 } // end of wxWindowOS2::OS2DefWindowProc
1838
1839 bool wxWindowOS2::OS2ProcessMessage( WXMSG* pMsg )
1840 {
1841 // wxUniversal implements tab traversal itself
1842 #ifndef __WXUNIVERSAL__
1843 QMSG* pQMsg = (QMSG*)pMsg;
1844
1845 if (m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL))
1846 {
1847 //
1848 // Intercept dialog navigation keys
1849 //
1850 bool bProcess = true;
1851 USHORT uKeyFlags = SHORT1FROMMP(pQMsg->mp1);
1852
1853 if (uKeyFlags & KC_KEYUP)
1854 bProcess = false;
1855
1856 if (uKeyFlags & KC_ALT)
1857 bProcess = false;
1858
1859 if (!(uKeyFlags & KC_VIRTUALKEY))
1860 bProcess = false;
1861
1862 if (bProcess)
1863 {
1864 bool bCtrlDown = IsCtrlDown();
1865 bool bShiftDown = IsShiftDown();
1866
1867 //
1868 // WM_QUERYDLGCODE: ask the control if it wants the key for itself,
1869 // don't process it if it's the case (except for Ctrl-Tab/Enter
1870 // combinations which are always processed)
1871 //
1872 ULONG ulDlgCode = 0;
1873
1874 if (!bCtrlDown)
1875 {
1876 ulDlgCode = (ULONG)::WinSendMsg(pQMsg->hwnd, WM_QUERYDLGCODE, pQMsg, 0);
1877 }
1878
1879 bool bForward = true;
1880 bool bWindowChange = false;
1881
1882 switch (SHORT2FROMMP(pQMsg->mp2))
1883 {
1884 //
1885 // Going to make certain assumptions about specific types of controls
1886 // here, so we may have to alter some things later if they prove invalid
1887 //
1888 case VK_TAB:
1889 //
1890 // Shift tabl will always be a nav-key but tabs may be wanted
1891 //
1892 if (!bShiftDown)
1893 {
1894 bProcess = false;
1895 }
1896 else
1897 {
1898 //
1899 // Entry Fields want tabs for themselve usually
1900 //
1901 switch (ulDlgCode)
1902 {
1903 case DLGC_ENTRYFIELD:
1904 case DLGC_MLE:
1905 bProcess = true;
1906 break;
1907
1908 default:
1909 bProcess = false;
1910 }
1911
1912 //
1913 // Ctrl-Tab cycles thru notebook pages
1914 //
1915 bWindowChange = bCtrlDown;
1916 bForward = !bShiftDown;
1917 }
1918 break;
1919
1920 case VK_UP:
1921 case VK_LEFT:
1922 if (bCtrlDown)
1923 bProcess = false;
1924 else
1925 bForward = false;
1926 break;
1927
1928 case VK_DOWN:
1929 case VK_RIGHT:
1930 if (bCtrlDown)
1931 bProcess = false;
1932 break;
1933
1934 case VK_ENTER:
1935 {
1936 if (bCtrlDown)
1937 {
1938 //
1939 // ctrl-enter is not processed
1940 //
1941 return false;
1942 }
1943 else if (ulDlgCode & DLGC_BUTTON)
1944 {
1945 //
1946 // buttons want process Enter themselevs
1947 //
1948 bProcess = false;
1949 }
1950 else
1951 {
1952 wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
1953 wxButton* pBtn = NULL;
1954
1955 if (tlw)
1956 {
1957 pBtn = wxDynamicCast(tlw->GetDefaultItem(), wxButton);
1958 }
1959
1960 if (pBtn && pBtn->IsEnabled())
1961 {
1962 //
1963 // If we do have a default button, do press it
1964 //
1965 pBtn->OS2Command(BN_CLICKED, 0 /* unused */);
1966 return true;
1967 }
1968 else if (!IsTopLevel())
1969 {
1970 //
1971 // if not a top level window, let parent
1972 // handle it
1973 //
1974 return false;
1975 }
1976 // else: but if it does not it makes sense to make
1977 // it work like a TAB - and that's what we do.
1978 // Note that Ctrl-Enter always works this way.
1979 }
1980 }
1981 break;
1982
1983 default:
1984 bProcess = false;
1985 }
1986
1987 if (bProcess)
1988 {
1989 wxNavigationKeyEvent vEvent;
1990
1991 vEvent.SetDirection(bForward);
1992 vEvent.SetWindowChange(bWindowChange);
1993 vEvent.SetEventObject(this);
1994
1995 if (HandleWindowEvent(vEvent))
1996 {
1997 wxButton* pBtn = wxDynamicCast(FindFocus(), wxButton);
1998
1999 if (pBtn)
2000 {
2001 //
2002 // The button which has focus should be default
2003 //
2004 pBtn->SetDefault();
2005 }
2006 return true;
2007 }
2008 }
2009 }
2010 //
2011 // Let Dialogs process
2012 //
2013 if (::WinSendMsg(pQMsg->hwnd, WM_QUERYDLGCODE, pQMsg, 0));
2014 return true;
2015 }
2016 #else
2017 pMsg = pMsg; // just shut up the compiler
2018 #endif // __WXUNIVERSAL__
2019
2020 return false;
2021 } // end of wxWindowOS2::OS2ProcessMessage
2022
2023 bool wxWindowOS2::OS2TranslateMessage( WXMSG* pMsg )
2024 {
2025 #if wxUSE_ACCEL && !defined(__WXUNIVERSAL__)
2026 return m_acceleratorTable.Translate(m_hWnd, pMsg);
2027 #else
2028 pMsg = pMsg;
2029 return false;
2030 #endif //wxUSE_ACCEL
2031 } // end of wxWindowOS2::OS2TranslateMessage
2032
2033 bool wxWindowOS2::OS2ShouldPreProcessMessage( WXMSG* WXUNUSED(pMsg) )
2034 {
2035 // preprocess all messages by default
2036 return true;
2037 } // end of wxWindowOS2::OS2ShouldPreProcessMessage
2038
2039 // ---------------------------------------------------------------------------
2040 // message params unpackers
2041 // ---------------------------------------------------------------------------
2042
2043 void wxWindowOS2::UnpackCommand(
2044 WXWPARAM wParam
2045 , WXLPARAM lParam
2046 , WORD* pId
2047 , WXHWND* phWnd
2048 , WORD* pCmd
2049 )
2050 {
2051 *pId = LOWORD(wParam);
2052 *phWnd = NULL; // or may be GetHWND() ?
2053 *pCmd = LOWORD(lParam);
2054 } // end of wxWindowOS2::UnpackCommand
2055
2056 void wxWindowOS2::UnpackActivate(
2057 WXWPARAM wParam
2058 , WXLPARAM lParam
2059 , WXWORD* pState
2060 , WXHWND* phWnd
2061 )
2062 {
2063 *pState = LOWORD(wParam);
2064 *phWnd = (WXHWND)lParam;
2065 } // end of wxWindowOS2::UnpackActivate
2066
2067 void wxWindowOS2::UnpackScroll(
2068 WXWPARAM wParam
2069 , WXLPARAM lParam
2070 , WXWORD* pCode
2071 , WXWORD* pPos
2072 , WXHWND* phWnd
2073 )
2074 {
2075 ULONG ulId;
2076 HWND hWnd;
2077
2078 ulId = (ULONG)LONGFROMMP(wParam);
2079 hWnd = ::WinWindowFromID(GetHwnd(), ulId);
2080 if (hWnd == m_hWndScrollBarHorz || hWnd == m_hWndScrollBarVert)
2081 *phWnd = NULLHANDLE;
2082 else
2083 *phWnd = hWnd;
2084
2085 *pPos = SHORT1FROMMP(lParam);
2086 *pCode = SHORT2FROMMP(lParam);
2087 } // end of wxWindowOS2::UnpackScroll
2088
2089 void wxWindowOS2::UnpackMenuSelect(
2090 WXWPARAM wParam
2091 , WXLPARAM lParam
2092 , WXWORD* pItem
2093 , WXWORD* pFlags
2094 , WXHMENU* phMenu
2095 )
2096 {
2097 *pItem = (WXWORD)LOWORD(wParam);
2098 *pFlags = HIWORD(wParam);
2099 *phMenu = (WXHMENU)lParam;
2100 } // end of wxWindowOS2::UnpackMenuSelect
2101
2102 // ---------------------------------------------------------------------------
2103 // Main wxWidgets window proc and the window proc for wxWindow
2104 // ---------------------------------------------------------------------------
2105
2106 //
2107 // Hook for new window just as it's being created, when the window isn't yet
2108 // associated with the handle
2109 //
2110 wxWindowOS2* wxWndHook = NULL;
2111
2112 //
2113 // Main window proc
2114 //
2115 MRESULT EXPENTRY wxWndProc(
2116 HWND hWnd
2117 , ULONG ulMsg
2118 , MPARAM wParam
2119 , MPARAM lParam
2120 )
2121 {
2122 wxWindowOS2* pWnd = wxFindWinFromHandle((WXHWND)hWnd);
2123
2124 //
2125 // When we get the first message for the HWND we just created, we associate
2126 // it with wxWindow stored in wxWndHook
2127 //
2128 if (!pWnd && wxWndHook)
2129 {
2130 wxAssociateWinWithHandle(hWnd, wxWndHook);
2131 pWnd = wxWndHook;
2132 wxWndHook = NULL;
2133 pWnd->SetHWND((WXHWND)hWnd);
2134 }
2135
2136 MRESULT rc = (MRESULT)0;
2137
2138
2139 //
2140 // Stop right here if we don't have a valid handle in our wxWindow object.
2141 //
2142 if (pWnd && !pWnd->GetHWND())
2143 {
2144 pWnd->SetHWND((WXHWND) hWnd);
2145 rc = pWnd->OS2DefWindowProc(ulMsg, wParam, lParam );
2146 pWnd->SetHWND(0);
2147 }
2148 else
2149 {
2150 if (pWnd)
2151 {
2152 rc = pWnd->OS2WindowProc(ulMsg, wParam, lParam);
2153 if ( (pWnd->GetScrollBarHorz() != NULLHANDLE ||
2154 pWnd->GetScrollBarVert() != NULLHANDLE) &&
2155 ulMsg == WM_PAINT)
2156 {
2157 if (pWnd->GetScrollBarHorz() != NULLHANDLE)
2158 ::WinInvalidateRect(pWnd->GetScrollBarHorz(), NULL, TRUE);
2159 if (pWnd->GetScrollBarVert() != NULLHANDLE)
2160 ::WinInvalidateRect(pWnd->GetScrollBarVert(), NULL, TRUE);
2161 }
2162 }
2163 else
2164 rc = ::WinDefWindowProc(hWnd, ulMsg, wParam, lParam);
2165 }
2166
2167 return rc;
2168 } // end of wxWndProc
2169
2170 //
2171 // We will add (or delete) messages we need to handle at this default
2172 // level as we go
2173 //
2174 MRESULT wxWindowOS2::OS2WindowProc( WXUINT uMsg,
2175 WXWPARAM wParam,
2176 WXLPARAM lParam )
2177 {
2178 //
2179 // Did we process the uMsg?
2180 //
2181 bool bProcessed = false;
2182 MRESULT mResult;
2183
2184 //
2185 // For most messages we should return 0 when we do process the message
2186 //
2187 mResult = (MRESULT)0;
2188
2189 switch (uMsg)
2190 {
2191 case WM_CREATE:
2192 {
2193 bool bMayCreate;
2194
2195 bProcessed = HandleCreate( (WXLPCREATESTRUCT)lParam
2196 ,&bMayCreate
2197 );
2198 if (bProcessed)
2199 {
2200 //
2201 // Return 0 to bAllow window creation
2202 //
2203 mResult = (MRESULT)(bMayCreate ? 0 : -1);
2204 }
2205 }
2206 break;
2207
2208 case WM_DESTROY:
2209 HandleDestroy();
2210 bProcessed = true;
2211 break;
2212
2213 case WM_MOVE:
2214 bProcessed = HandleMove( LOWORD(lParam)
2215 ,HIWORD(lParam)
2216 );
2217 break;
2218
2219 case WM_SIZE:
2220 bProcessed = HandleSize( LOWORD(lParam)
2221 ,HIWORD(lParam)
2222 ,(WXUINT)wParam
2223 );
2224 break;
2225
2226 case WM_WINDOWPOSCHANGED:
2227
2228 //
2229 // Dialogs under OS/2 do not get WM_SIZE events at all.
2230 // Instead they get this, which can function much like WM_SIZE
2231 // PSWP contains the new sizes and positioning, PSWP+1 the old
2232 // We use this because ADJUSTWINDOWPOS comes BEFORE the new
2233 // position is added and our auto layout does a WinQueryWindowRect
2234 // to get the CURRENT client size. That is the size used to position
2235 // child controls, so we need to already be sized
2236 // in order to get the child controls positoned properly.
2237 //
2238 if (IsKindOf(CLASSINFO(wxDialog)) || IsKindOf(CLASSINFO(wxFrame)))
2239 {
2240 PSWP pSwp = (PSWP)PVOIDFROMMP(wParam);
2241 PSWP pSwp2 = pSwp++;
2242
2243 if (!(pSwp->cx == pSwp2->cx &&
2244 pSwp->cy == pSwp2->cy))
2245 bProcessed = HandleSize( pSwp->cx
2246 ,pSwp->cy
2247 ,(WXUINT)lParam
2248 );
2249 if (IsKindOf(CLASSINFO(wxFrame)))
2250 {
2251 wxFrame* pFrame = wxDynamicCast(this, wxFrame);
2252
2253 if (pFrame)
2254 {
2255 if (pFrame->GetStatusBar())
2256 pFrame->PositionStatusBar();
2257 if (pFrame->GetToolBar())
2258 pFrame->PositionToolBar();
2259 }
2260 }
2261 }
2262 break;
2263
2264 case WM_ACTIVATE:
2265 {
2266 WXWORD wState;
2267 WXHWND hWnd;
2268
2269 UnpackActivate( wParam
2270 ,lParam
2271 ,&wState
2272 ,&hWnd
2273 );
2274
2275 bProcessed = HandleActivate( wState
2276 ,(WXHWND)hWnd
2277 );
2278 bProcessed = false;
2279 }
2280 break;
2281
2282 case WM_SETFOCUS:
2283 if (SHORT1FROMMP((MPARAM)lParam) == TRUE)
2284 bProcessed = HandleSetFocus((WXHWND)(HWND)wParam);
2285 else
2286 bProcessed = HandleKillFocus((WXHWND)(HWND)wParam);
2287 break;
2288
2289 case WM_PAINT:
2290 bProcessed = HandlePaint();
2291 break;
2292
2293 case WM_CLOSE:
2294 //
2295 // Don't let the DefWindowProc() destroy our window - we'll do it
2296 // ourselves in ~wxWindow
2297 //
2298 bProcessed = true;
2299 mResult = (MRESULT)TRUE;
2300 break;
2301
2302 case WM_SHOW:
2303 bProcessed = HandleShow(wParam != 0, (int)lParam);
2304 break;
2305
2306 //
2307 // Under OS2 PM Joysticks are treated just like mouse events
2308 // The "Motion" events will be prevelent in joysticks
2309 //
2310 case WM_MOUSEMOVE:
2311 case WM_BUTTON1DOWN:
2312 case WM_BUTTON1UP:
2313 case WM_BUTTON1DBLCLK:
2314 case WM_BUTTON1MOTIONEND:
2315 case WM_BUTTON1MOTIONSTART:
2316 case WM_BUTTON2DOWN:
2317 case WM_BUTTON2UP:
2318 case WM_BUTTON2DBLCLK:
2319 case WM_BUTTON2MOTIONEND:
2320 case WM_BUTTON2MOTIONSTART:
2321 case WM_BUTTON3DOWN:
2322 case WM_BUTTON3UP:
2323 case WM_BUTTON3DBLCLK:
2324 case WM_BUTTON3MOTIONEND:
2325 case WM_BUTTON3MOTIONSTART:
2326 {
2327 short nX = LOWORD(wParam);
2328 short nY = HIWORD(wParam);
2329
2330 //
2331 // Redirect the event to a static control if necessary
2332 //
2333 if (this == GetCapture())
2334 {
2335 bProcessed = HandleMouseEvent( uMsg
2336 ,nX
2337 ,nY
2338 ,(WXUINT)SHORT2FROMMP(lParam)
2339 );
2340 }
2341 else
2342 {
2343 wxWindow* pWin = FindWindowForMouseEvent( this
2344 ,&nX
2345 ,&nY
2346 );
2347 if (!pWin->IsOfStandardClass())
2348 {
2349 if (uMsg == WM_BUTTON1DOWN && pWin->CanAcceptFocus() )
2350 pWin->SetFocus();
2351 }
2352 bProcessed = pWin->HandleMouseEvent( uMsg
2353 ,nX
2354 ,nY
2355 ,(WXUINT)SHORT2FROMMP(lParam)
2356 );
2357 }
2358 }
2359 break;
2360
2361 case WM_SYSCOMMAND:
2362 bProcessed = HandleSysCommand(wParam, lParam);
2363 break;
2364
2365 case WM_COMMAND:
2366 {
2367 WORD id, cmd;
2368 WXHWND hwnd;
2369 UnpackCommand(wParam, lParam, &id, &hwnd, &cmd);
2370
2371 bProcessed = HandleCommand(id, cmd, hwnd);
2372 }
2373 break;
2374
2375 //
2376 // For these messages we must return TRUE if process the message
2377 //
2378 case WM_DRAWITEM:
2379 case WM_MEASUREITEM:
2380 {
2381 int nIdCtrl = (UINT)wParam;
2382
2383 if ( uMsg == WM_DRAWITEM )
2384 {
2385 bProcessed = OS2OnDrawItem(nIdCtrl,
2386 (WXDRAWITEMSTRUCT *)lParam);
2387 }
2388 else
2389 {
2390 return MRFROMLONG(OS2OnMeasureItem( nIdCtrl
2391 ,(WXMEASUREITEMSTRUCT *)lParam
2392 ));
2393 }
2394
2395 if ( bProcessed )
2396 mResult = (MRESULT)TRUE;
2397 }
2398 break;
2399
2400 case WM_QUERYDLGCODE:
2401 if (!IsOfStandardClass())
2402 {
2403 if ( m_lDlgCode )
2404 {
2405 mResult = (MRESULT)m_lDlgCode;
2406 bProcessed = true;
2407 }
2408 }
2409 //
2410 //else: get the dlg code from the DefWindowProc()
2411 //
2412 break;
2413
2414 //
2415 // In OS/2 PM all keyboard events are of the WM_CHAR type. Virtual key and key-up
2416 // and key-down events are obtained from the WM_CHAR params.
2417 //
2418 case WM_CHAR:
2419 {
2420 USHORT uKeyFlags = SHORT1FROMMP((MPARAM)wParam);
2421
2422 if (uKeyFlags & KC_KEYUP)
2423 {
2424 //TODO: check if the cast to WXWORD isn't causing trouble
2425 bProcessed = HandleKeyUp(wParam, lParam);
2426 break;
2427 }
2428 else // keydown event
2429 {
2430 m_bLastKeydownProcessed = false;
2431 //
2432 // If this has been processed by an event handler,
2433 // return 0 now (we've handled it). DON't RETURN
2434 // we still need to process further
2435 //
2436 m_bLastKeydownProcessed = HandleKeyDown(wParam, lParam);
2437 if (uKeyFlags & KC_VIRTUALKEY)
2438 {
2439 USHORT uVk = SHORT2FROMMP((MPARAM)lParam);
2440
2441 //
2442 // We consider these message "not interesting" to OnChar
2443 //
2444 switch(uVk)
2445 {
2446 case VK_SHIFT:
2447 case VK_CTRL:
2448 case VK_MENU:
2449 case VK_CAPSLOCK:
2450 case VK_NUMLOCK:
2451 case VK_SCRLLOCK:
2452 bProcessed = true;
2453 break;
2454
2455 // Avoid duplicate messages to OnChar for these ASCII keys: they
2456 // will be translated by TranslateMessage() and received in WM_CHAR
2457 case VK_ESC:
2458 case VK_ENTER:
2459 case VK_BACKSPACE:
2460 case VK_TAB:
2461 // But set processed to false, not true to still pass them to
2462 // the control's default window proc - otherwise built-in
2463 // keyboard handling won't work
2464 bProcessed = false;
2465 break;
2466
2467 default:
2468 bProcessed = HandleChar(wParam, lParam);
2469 }
2470 break;
2471 }
2472 else // WM_CHAR -- Always an ASCII character
2473 {
2474 if (m_bLastKeydownProcessed)
2475 {
2476 //
2477 // The key was handled in the EVT_KEY_DOWN and handling
2478 // a key in an EVT_KEY_DOWN handler is meant, by
2479 // design, to prevent EVT_CHARs from happening
2480 //
2481 m_bLastKeydownProcessed = false;
2482 bProcessed = true;
2483 }
2484 else // do generate a CHAR event
2485 {
2486 bProcessed = HandleChar(wParam, lParam, true);
2487 break;
2488 }
2489 }
2490 }
2491 }
2492
2493 case WM_HSCROLL:
2494 case WM_VSCROLL:
2495 {
2496 WXWORD wCode;
2497 WXWORD wPos;
2498 WXHWND hWnd;
2499 UnpackScroll( wParam
2500 ,lParam
2501 ,&wCode
2502 ,&wPos
2503 ,&hWnd
2504 );
2505
2506 bProcessed = OS2OnScroll( uMsg == WM_HSCROLL ? wxHORIZONTAL
2507 : wxVERTICAL
2508 ,wCode
2509 ,wPos
2510 ,hWnd
2511 );
2512 }
2513 break;
2514
2515 case WM_CONTROL:
2516 switch(SHORT2FROMMP(wParam))
2517 {
2518 case BN_PAINT:
2519 {
2520 HWND hWnd = ::WinWindowFromID((HWND)GetHwnd(), SHORT1FROMMP(wParam));
2521 wxWindowOS2* pWin = wxFindWinFromHandle(hWnd);
2522
2523 if (!pWin)
2524 {
2525 bProcessed = false;
2526 break;
2527 }
2528 if (pWin->IsKindOf(CLASSINFO(wxBitmapButton)))
2529 {
2530 wxBitmapButton* pBitmapButton = wxDynamicCast(pWin, wxBitmapButton);
2531
2532 pBitmapButton->OS2OnDraw((WXDRAWITEMSTRUCT *)lParam);
2533 }
2534 return 0;
2535 }
2536 // break;
2537
2538 case BKN_PAGESELECTEDPENDING:
2539 {
2540 PPAGESELECTNOTIFY pPage = (PPAGESELECTNOTIFY)lParam;
2541
2542 if ((pPage->ulPageIdNew != pPage->ulPageIdCur) &&
2543 (pPage->ulPageIdNew > 0L && pPage->ulPageIdCur > 0L))
2544 {
2545 wxWindowOS2* pWin = wxFindWinFromHandle(pPage->hwndBook);
2546 wxBookCtrlEvent vEvent( wxEVT_NOTEBOOK_PAGE_CHANGED
2547 ,(int)SHORT1FROMMP(wParam)
2548 ,(int)pPage->ulPageIdNew
2549 ,(int)pPage->ulPageIdCur
2550 );
2551 if (!pWin)
2552 {
2553 bProcessed = false;
2554 break;
2555 }
2556 if (pWin->IsKindOf(CLASSINFO(wxNotebook)))
2557 {
2558 wxNotebook* pNotebook = wxDynamicCast(pWin, wxNotebook);
2559
2560 vEvent.SetEventObject(pWin);
2561 pNotebook->OnSelChange(vEvent);
2562 bProcessed = true;
2563 }
2564 else
2565 bProcessed = false;
2566 }
2567 else
2568 bProcessed = false;
2569 }
2570 break;
2571
2572 case CBN_LBSELECT:
2573 case BN_CLICKED: // Dups as LN_SELECT and CBN_LBSELECT
2574 {
2575 HWND hWnd = ::WinWindowFromID((HWND)GetHwnd(), SHORT1FROMMP(wParam));
2576 wxWindowOS2* pWin = wxFindWinFromHandle(hWnd);
2577
2578 if (!pWin)
2579 {
2580 bProcessed = false;
2581 break;
2582 }
2583 //
2584 // Simulate a WM_COMMAND here, as wxWidgets expects all control
2585 // button clicks to generate WM_COMMAND msgs, not WM_CONTROL
2586 //
2587 if (pWin->IsKindOf(CLASSINFO(wxRadioBox)))
2588 {
2589 wxRadioBox* pRadioBox = wxDynamicCast(pWin, wxRadioBox);
2590
2591 pRadioBox->OS2Command( (WXUINT)SHORT2FROMMP(wParam)
2592 ,(WXWORD)SHORT1FROMMP(wParam)
2593 );
2594 }
2595 if (pWin->IsKindOf(CLASSINFO(wxRadioButton)))
2596 {
2597 wxRadioButton* pRadioButton = wxDynamicCast(pWin, wxRadioButton);
2598
2599 pRadioButton->OS2Command( (WXUINT)SHORT2FROMMP(wParam)
2600 ,(WXWORD)SHORT1FROMMP(wParam)
2601 );
2602 }
2603 if (pWin->IsKindOf(CLASSINFO(wxCheckBox)))
2604 {
2605 wxCheckBox* pCheckBox = wxDynamicCast(pWin, wxCheckBox);
2606
2607 pCheckBox->OS2Command( (WXUINT)SHORT2FROMMP(wParam)
2608 ,(WXWORD)SHORT1FROMMP(wParam)
2609 );
2610 }
2611 if (pWin->IsKindOf(CLASSINFO(wxListBox)))
2612 {
2613 wxListBox* pListBox = wxDynamicCast(pWin, wxListBox);
2614
2615 pListBox->OS2Command( (WXUINT)SHORT2FROMMP(wParam)
2616 ,(WXWORD)SHORT1FROMMP(wParam)
2617 );
2618 if (pListBox->GetWindowStyle() & wxLB_OWNERDRAW)
2619 Refresh();
2620 }
2621 if (pWin->IsKindOf(CLASSINFO(wxComboBox)))
2622 {
2623 wxComboBox* pComboBox = wxDynamicCast(pWin, wxComboBox);
2624
2625 pComboBox->OS2Command( (WXUINT)SHORT2FROMMP(wParam)
2626 ,(WXWORD)SHORT1FROMMP(wParam)
2627 );
2628 }
2629 if (pWin->IsKindOf(CLASSINFO(wxChoice)))
2630 {
2631 wxChoice* pChoice = wxDynamicCast(pWin, wxChoice);
2632
2633 pChoice->OS2Command( (WXUINT)SHORT2FROMMP(wParam)
2634 ,(WXWORD)SHORT1FROMMP(wParam)
2635 );
2636 }
2637 return 0;
2638 }
2639 // break;
2640
2641 case LN_ENTER:
2642 {
2643 HWND hWnd = HWNDFROMMP(lParam);
2644 wxWindowOS2* pWin = wxFindWinFromHandle(hWnd);
2645
2646 if (!pWin)
2647 {
2648 bProcessed = false;
2649 break;
2650 }
2651 //
2652 // Simulate a WM_COMMAND here, as wxWidgets expects all control
2653 // button clicks to generate WM_COMMAND msgs, not WM_CONTROL
2654 //
2655 if (pWin->IsKindOf(CLASSINFO(wxListBox)))
2656 {
2657 wxListBox* pListBox = wxDynamicCast(pWin, wxListBox);
2658
2659 pListBox->OS2Command( (WXUINT)SHORT2FROMMP(wParam)
2660 ,(WXWORD)SHORT1FROMMP(wParam)
2661 );
2662 if (pListBox->GetWindowStyle() & wxLB_OWNERDRAW)
2663 Refresh();
2664
2665 }
2666 if (pWin->IsKindOf(CLASSINFO(wxComboBox)))
2667 {
2668 wxComboBox* pComboBox = wxDynamicCast(pWin, wxComboBox);
2669
2670 pComboBox->OS2Command( (WXUINT)SHORT2FROMMP(wParam)
2671 ,(WXWORD)SHORT1FROMMP(wParam)
2672 );
2673 }
2674 return 0;
2675 }
2676 // break;
2677
2678 case SPBN_UPARROW:
2679 case SPBN_DOWNARROW:
2680 case SPBN_CHANGE:
2681 {
2682 char zVal[10];
2683 long lVal;
2684
2685 ::WinSendMsg( HWNDFROMMP(lParam)
2686 ,SPBM_QUERYVALUE
2687 ,&zVal[0]
2688 ,MPFROM2SHORT( (USHORT)10
2689 ,(USHORT)SPBQ_UPDATEIFVALID
2690 )
2691 );
2692 lVal = atol(zVal);
2693 bProcessed = OS2OnScroll( wxVERTICAL
2694 ,(WXWORD)SHORT2FROMMP(wParam)
2695 ,(WXWORD)lVal
2696 ,HWNDFROMMP(lParam)
2697 );
2698 }
2699 break;
2700
2701 case SLN_SLIDERTRACK:
2702 {
2703 HWND hWnd = ::WinWindowFromID(GetHWND(), SHORT1FROMMP(wParam));
2704 wxWindowOS2* pChild = wxFindWinFromHandle(hWnd);
2705
2706 if (!pChild)
2707 {
2708 bProcessed = false;
2709 break;
2710 }
2711 if (pChild->IsKindOf(CLASSINFO(wxSlider)))
2712 bProcessed = OS2OnScroll( wxVERTICAL
2713 ,(WXWORD)SHORT2FROMMP(wParam)
2714 ,(WXWORD)LONGFROMMP(lParam)
2715 ,hWnd
2716 );
2717 }
2718 break;
2719 }
2720 break;
2721
2722 #if defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
2723 case WM_CTLCOLORCHANGE:
2724 {
2725 bProcessed = HandleCtlColor(&hBrush);
2726 }
2727 break;
2728 #endif
2729 case WM_ERASEBACKGROUND:
2730 //
2731 // Returning TRUE to requestw PM to paint the window background
2732 // in SYSCLR_WINDOW. We don't really want that
2733 //
2734 bProcessed = HandleEraseBkgnd((WXHDC)(HPS)wParam);
2735 mResult = (MRESULT)(FALSE);
2736 break;
2737
2738 // the return value for this message is ignored
2739 case WM_SYSCOLORCHANGE:
2740 bProcessed = HandleSysColorChange();
2741 break;
2742
2743 case WM_REALIZEPALETTE:
2744 bProcessed = HandlePaletteChanged();
2745 break;
2746
2747 // move all drag and drops to wxDrg
2748 case WM_ENDDRAG:
2749 bProcessed = HandleEndDrag(wParam);
2750 break;
2751
2752 case WM_INITDLG:
2753 bProcessed = HandleInitDialog((WXHWND)(HWND)wParam);
2754
2755 if ( bProcessed )
2756 {
2757 // we never set focus from here
2758 mResult = (MRESULT)FALSE;
2759 }
2760 break;
2761
2762 // wxFrame specific message
2763 case WM_MINMAXFRAME:
2764 bProcessed = HandleGetMinMaxInfo((PSWP)wParam);
2765 break;
2766
2767 case WM_SYSVALUECHANGED:
2768 // TODO: do something
2769 mResult = (MRESULT)TRUE;
2770 break;
2771
2772 //
2773 // Comparable to WM_SETPOINTER for windows, only for just controls
2774 //
2775 case WM_CONTROLPOINTER:
2776 bProcessed = HandleSetCursor( SHORT1FROMMP(wParam) // Control ID
2777 ,(HWND)lParam // Cursor Handle
2778 );
2779 if (bProcessed )
2780 {
2781 //
2782 // Returning TRUE stops the DefWindowProc() from further
2783 // processing this message - exactly what we need because we've
2784 // just set the cursor.
2785 //
2786 mResult = (MRESULT)TRUE;
2787 }
2788 break;
2789
2790 #if wxUSE_MENUS_NATIVE
2791 case WM_MENUEND:
2792 if (wxCurrentPopupMenu)
2793 {
2794 if (GetHmenuOf(wxCurrentPopupMenu) == (HWND)lParam)
2795 {
2796 // Break out of msg loop in DoPopupMenu
2797 ::WinPostMsg((HWND)lParam,WM_COMMAND,wParam,0);
2798 }
2799 }
2800 break;
2801 #endif // wxUSE_MENUS_NATIVE
2802
2803 }
2804 if (!bProcessed)
2805 {
2806 #ifdef __WXDEBUG__
2807 wxLogTrace(wxTraceMessages, wxT("Forwarding %s to DefWindowProc."),
2808 wxGetMessageName(uMsg));
2809 #endif // __WXDEBUG__
2810 if (IsKindOf(CLASSINFO(wxFrame)))
2811 mResult = ::WinDefWindowProc(m_hWnd, uMsg, wParam, lParam);
2812 else if (IsKindOf(CLASSINFO(wxDialog)))
2813 mResult = ::WinDefDlgProc( m_hWnd, uMsg, wParam, lParam);
2814 else
2815 mResult = OS2DefWindowProc(uMsg, wParam, lParam);
2816 }
2817 return mResult;
2818 } // end of wxWindowOS2::OS2WindowProc
2819
2820 // ----------------------------------------------------------------------------
2821 // wxWindow <-> HWND map
2822 // ----------------------------------------------------------------------------
2823
2824 wxWinHashTable *wxWinHandleHash = NULL;
2825
2826 wxWindow* wxFindWinFromHandle(
2827 WXHWND hWnd
2828 )
2829 {
2830 return (wxWindow *)wxWinHandleHash->Get((long)hWnd);
2831 } // end of wxFindWinFromHandle
2832
2833 void wxAssociateWinWithHandle(
2834 HWND hWnd
2835 , wxWindowOS2* pWin
2836 )
2837 {
2838 //
2839 // Adding NULL hWnd is (first) surely a result of an error and
2840 // (secondly) breaks menu command processing
2841 //
2842 wxCHECK_RET( hWnd != (HWND)NULL,
2843 wxT("attempt to add a NULL hWnd to window list ignored") );
2844
2845 wxWindow* pOldWin = wxFindWinFromHandle((WXHWND) hWnd);
2846
2847 if (pOldWin && (pOldWin != pWin))
2848 {
2849 wxString Newstr(pWin->GetClassInfo()->GetClassName());
2850 wxString Oldstr(pOldWin->GetClassInfo()->GetClassName());
2851 wxLogError( wxT("Bug! New window of class %s has same HWND %X as old window of class %s"),
2852 Newstr.c_str(),
2853 (int)hWnd,
2854 Oldstr.c_str()
2855 );
2856 }
2857 else if (!pOldWin)
2858 {
2859 wxWinHandleHash->Put( (long)hWnd
2860 ,(wxWindow *)pWin
2861 );
2862 }
2863 } // end of wxAssociateWinWithHandle
2864
2865 void wxRemoveHandleAssociation( wxWindowOS2* pWin )
2866 {
2867 wxWinHandleHash->Delete((long)pWin->GetHWND());
2868 } // end of wxRemoveHandleAssociation
2869
2870 //
2871 // Default destroyer - override if you destroy it in some other way
2872 // (e.g. with MDI child windows)
2873 //
2874 void wxWindowOS2::OS2DestroyWindow()
2875 {
2876 }
2877
2878 bool wxWindowOS2::OS2GetCreateWindowCoords( const wxPoint& rPos,
2879 const wxSize& rSize,
2880 int& rnX,
2881 int& rnY,
2882 int& rnWidth,
2883 int& rnHeight ) const
2884 {
2885 bool bNonDefault = false;
2886 static const int DEFAULT_Y = 200;
2887 static const int DEFAULT_H = 250;
2888
2889 if (rPos.x == wxDefaultCoord)
2890 {
2891 rnX = rnY = CW_USEDEFAULT;
2892 }
2893 else
2894 {
2895 rnX = rPos.x;
2896 rnY = rPos.y == wxDefaultCoord ? DEFAULT_Y : rPos.y;
2897 bNonDefault = true;
2898 }
2899 if (rSize.x == wxDefaultCoord)
2900 {
2901 rnWidth = rnHeight = CW_USEDEFAULT;
2902 }
2903 else
2904 {
2905 rnWidth = rSize.x;
2906 rnHeight = rSize.y == wxDefaultCoord ? DEFAULT_H : rSize.y;
2907 bNonDefault = true;
2908 }
2909 return bNonDefault;
2910 } // end of wxWindowOS2::OS2GetCreateWindowCoords
2911
2912 WXHWND wxWindowOS2::OS2GetParent() const
2913 {
2914 return m_parent ? m_parent->GetHWND() : NULL;
2915 }
2916
2917 bool wxWindowOS2::OS2Create( PSZ zClass,
2918 const wxChar* zTitle,
2919 WXDWORD dwStyle,
2920 const wxPoint& rPos,
2921 const wxSize& rSize,
2922 void* pCtlData,
2923 WXDWORD WXUNUSED(dwExStyle),
2924 bool bIsChild )
2925 {
2926 ERRORID vError;
2927 wxString sError;
2928 int nX = 0L;
2929 int nY = 0L;
2930 int nWidth = 0L;
2931 int nHeight = 0L;
2932 long lControlId = 0L;
2933 wxWindowCreationHook vHook(this);
2934 wxString sClassName((wxChar*)zClass);
2935 wxString sTitle(zTitle ? zTitle : wxEmptyString);
2936
2937 OS2GetCreateWindowCoords( rPos
2938 ,rSize
2939 ,nX
2940 ,nY
2941 ,nWidth
2942 ,nHeight
2943 );
2944
2945 if (bIsChild)
2946 {
2947 lControlId = GetId();
2948 if (GetWindowStyleFlag() & wxCLIP_SIBLINGS)
2949 {
2950 dwStyle |= WS_CLIPSIBLINGS;
2951 }
2952 }
2953 //
2954 // For each class "Foo" we have we also have "FooNR" ("no repaint") class
2955 // which is the same but without CS_[HV]REDRAW class styles so using it
2956 // ensures that the window is not fully repainted on each resize
2957 //
2958 if (!HasFlag(wxFULL_REPAINT_ON_RESIZE))
2959 {
2960 sClassName += wxT("NR");
2961 }
2962 m_hWnd = (WXHWND)::WinCreateWindow( (HWND)OS2GetParent()
2963 ,sClassName.c_str()
2964 ,sTitle.c_str()
2965 ,(ULONG)dwStyle
2966 ,(LONG)0L
2967 ,(LONG)0L
2968 ,(LONG)0L
2969 ,(LONG)0L
2970 ,NULLHANDLE
2971 ,HWND_TOP
2972 ,(ULONG)lControlId
2973 ,pCtlData
2974 ,NULL
2975 );
2976 if (!m_hWnd)
2977 {
2978 vError = ::WinGetLastError(wxGetInstance());
2979 sError = wxPMErrorToStr(vError);
2980 return false;
2981 }
2982 SubclassWin(m_hWnd);
2983 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
2984
2985 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
2986
2987 LONG lColor = (LONG)m_backgroundColour.GetPixel();
2988
2989 if (!::WinSetPresParam( m_hWnd
2990 ,PP_BACKGROUNDCOLOR
2991 ,sizeof(LONG)
2992 ,(PVOID)&lColor
2993 ))
2994 {
2995 vError = ::WinGetLastError(vHabmain);
2996 sError = wxPMErrorToStr(vError);
2997 wxLogError(wxT("Error creating frame. Error: %s\n"), sError.c_str());
2998 return false;
2999 }
3000 SetSize( nX
3001 ,nY
3002 ,nWidth
3003 ,nHeight
3004 );
3005 return true;
3006 } // end of wxWindowOS2::OS2Create
3007
3008 // ===========================================================================
3009 // OS2 PM message handlers
3010 // ===========================================================================
3011
3012 // ---------------------------------------------------------------------------
3013 // window creation/destruction
3014 // ---------------------------------------------------------------------------
3015
3016 bool wxWindowOS2::HandleCreate( WXLPCREATESTRUCT WXUNUSED(vCs),
3017 bool* pbMayCreate )
3018 {
3019 wxWindowCreateEvent vEvent((wxWindow*)this);
3020
3021 (void)HandleWindowEvent(vEvent);
3022 *pbMayCreate = true;
3023 return true;
3024 } // end of wxWindowOS2::HandleCreate
3025
3026 bool wxWindowOS2::HandleDestroy()
3027 {
3028 wxWindowDestroyEvent vEvent((wxWindow*)this);
3029 vEvent.SetId(GetId());
3030 (void)HandleWindowEvent(vEvent);
3031
3032 //
3033 // Delete our drop target if we've got one
3034 //
3035 #if wxUSE_DRAG_AND_DROP
3036 wxDELETE(m_dropTarget);
3037 #endif // wxUSE_DRAG_AND_DROP
3038
3039 //
3040 // WM_DESTROY handled
3041 //
3042 return true;
3043 } // end of wxWindowOS2::HandleDestroy
3044
3045 // ---------------------------------------------------------------------------
3046 // activation/focus
3047 // ---------------------------------------------------------------------------
3048 void wxWindowOS2::OnSetFocus(
3049 wxFocusEvent& rEvent
3050 )
3051 {
3052 rEvent.Skip();
3053 } // end of wxWindowOS2::OnSetFocus
3054
3055 bool wxWindowOS2::HandleActivate(
3056 int nState
3057 , WXHWND WXUNUSED(hActivate)
3058 )
3059 {
3060 wxActivateEvent vEvent( wxEVT_ACTIVATE
3061 ,(bool)nState
3062 ,m_windowId
3063 );
3064 vEvent.SetEventObject(this);
3065 return HandleWindowEvent(vEvent);
3066 } // end of wxWindowOS2::HandleActivate
3067
3068 bool wxWindowOS2::HandleSetFocus( WXHWND WXUNUSED(hWnd) )
3069 {
3070 //
3071 // Notify the parent keeping track of focus for the kbd navigation
3072 // purposes that we got it
3073 //
3074 wxChildFocusEvent vEventFocus((wxWindow *)this);
3075 (void)HandleWindowEvent(vEventFocus);
3076
3077 #if wxUSE_CARET
3078 //
3079 // Deal with caret
3080 //
3081 if (m_caret)
3082 {
3083 m_caret->OnSetFocus();
3084 }
3085 #endif // wxUSE_CARET
3086
3087 #if wxUSE_TEXTCTRL
3088 // If it's a wxTextCtrl don't send the event as it will be done
3089 // after the control gets to process it from EN_FOCUS handler
3090 if ( wxDynamicCastThis(wxTextCtrl) )
3091 {
3092 return false;
3093 }
3094 #endif // wxUSE_TEXTCTRL
3095
3096 wxFocusEvent vEvent(wxEVT_SET_FOCUS, m_windowId);
3097
3098 vEvent.SetEventObject(this);
3099 return HandleWindowEvent(vEvent);
3100 } // end of wxWindowOS2::HandleSetFocus
3101
3102 bool wxWindowOS2::HandleKillFocus( WXHWND hWnd )
3103 {
3104 #if wxUSE_CARET
3105 //
3106 // Deal with caret
3107 //
3108 if (m_caret)
3109 {
3110 m_caret->OnKillFocus();
3111 }
3112 #endif // wxUSE_CARET
3113
3114 #if wxUSE_TEXTCTRL
3115 //
3116 // If it's a wxTextCtrl don't send the event as it will be done
3117 // after the control gets to process it.
3118 //
3119 wxTextCtrl* pCtrl = wxDynamicCastThis(wxTextCtrl);
3120
3121 if (pCtrl)
3122 {
3123 return false;
3124 }
3125 #endif
3126
3127 //
3128 // Don't send the event when in the process of being deleted. This can
3129 // only cause problems if the event handler tries to access the object.
3130 //
3131 if ( m_isBeingDeleted )
3132 {
3133 return false;
3134 }
3135
3136 wxFocusEvent vEvent( wxEVT_KILL_FOCUS
3137 ,m_windowId
3138 );
3139
3140 vEvent.SetEventObject(this);
3141
3142 //
3143 // wxFindWinFromHandle() may return NULL, it is ok
3144 //
3145 vEvent.SetWindow(wxFindWinFromHandle(hWnd));
3146 return HandleWindowEvent(vEvent);
3147 } // end of wxWindowOS2::HandleKillFocus
3148
3149 // ---------------------------------------------------------------------------
3150 // miscellaneous
3151 // ---------------------------------------------------------------------------
3152
3153 bool wxWindowOS2::HandleShow(
3154 bool bShow
3155 , int WXUNUSED(nStatus)
3156 )
3157 {
3158 wxShowEvent vEvent(GetId(), bShow);
3159
3160 vEvent.SetEventObject(this);
3161 return HandleWindowEvent(vEvent);
3162 } // end of wxWindowOS2::HandleShow
3163
3164 bool wxWindowOS2::HandleInitDialog( WXHWND WXUNUSED(hWndFocus) )
3165 {
3166 wxInitDialogEvent vEvent(GetId());
3167
3168 vEvent.SetEventObject(this);
3169 return HandleWindowEvent(vEvent);
3170 } // end of wxWindowOS2::HandleInitDialog
3171
3172 bool wxWindowOS2::HandleEndDrag(WXWPARAM WXUNUSED(wParam))
3173 {
3174 // TODO: We'll handle drag and drop later
3175 return false;
3176 }
3177
3178 bool wxWindowOS2::HandleSetCursor( USHORT WXUNUSED(vId),
3179 WXHWND hPointer )
3180 {
3181 //
3182 // Under OS/2 PM this allows the pointer to be changed
3183 // as it passes over a control
3184 //
3185 ::WinSetPointer(HWND_DESKTOP, (HPOINTER)hPointer);
3186 return true;
3187 } // end of wxWindowOS2::HandleSetCursor
3188
3189 // ---------------------------------------------------------------------------
3190 // owner drawn stuff
3191 // ---------------------------------------------------------------------------
3192 bool wxWindowOS2::OS2OnDrawItem( int vId,
3193 WXDRAWITEMSTRUCT* pItemStruct )
3194 {
3195 #if wxUSE_OWNER_DRAWN
3196 wxClientDC vDc(this);
3197
3198 #if wxUSE_MENUS_NATIVE
3199 //
3200 // Is it a menu item?
3201 //
3202 if (vId == 0)
3203 {
3204 ERRORID vError;
3205 wxString sError;
3206 POWNERITEM pMeasureStruct = (POWNERITEM)pItemStruct;
3207 wxFrame* pFrame = (wxFrame*)this;
3208 wxMenuItem* pMenuItem = pFrame->GetMenuBar()->FindItem(pMeasureStruct->idItem, pMeasureStruct->hItem);
3209 HDC hDC = ::GpiQueryDevice(pMeasureStruct->hps);
3210 wxRect vRect( pMeasureStruct->rclItem.xLeft
3211 ,pMeasureStruct->rclItem.yBottom
3212 ,pMeasureStruct->rclItem.xRight - pMeasureStruct->rclItem.xLeft
3213 ,pMeasureStruct->rclItem.yTop - pMeasureStruct->rclItem.yBottom
3214 );
3215
3216 wxPMDCImpl *impl = (wxPMDCImpl*) vDc.GetImpl();
3217 impl->SetHDC( hDC, false );
3218 impl->SetHPS( pMeasureStruct->hps );
3219 //
3220 // Load the wxWidgets Pallete and set to RGB mode
3221 //
3222 if (!::GpiCreateLogColorTable( pMeasureStruct->hps
3223 ,0L
3224 ,LCOLF_CONSECRGB
3225 ,0L
3226 ,(LONG)wxTheColourDatabase->m_nSize
3227 ,(PLONG)wxTheColourDatabase->m_palTable
3228 ))
3229 {
3230 vError = ::WinGetLastError(vHabmain);
3231 sError = wxPMErrorToStr(vError);
3232 wxLogError(wxT("Unable to set current color table (1). Error: %s\n"), sError.c_str());
3233 }
3234 //
3235 // Set the color table to RGB mode
3236 //
3237 if (!::GpiCreateLogColorTable( pMeasureStruct->hps
3238 ,0L
3239 ,LCOLF_RGB
3240 ,0L
3241 ,0L
3242 ,NULL
3243 ))
3244 {
3245 vError = ::WinGetLastError(vHabmain);
3246 sError = wxPMErrorToStr(vError);
3247 wxLogError(wxT("Unable to set current color table (2). Error: %s\n"), sError.c_str());
3248 }
3249
3250 wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
3251
3252 int eAction = 0;
3253 int eStatus = 0;
3254
3255 if (pMeasureStruct->fsAttribute == pMeasureStruct->fsAttributeOld)
3256 {
3257 //
3258 // Entire Item needs to be redrawn (either it has reappeared from
3259 // behind another window or is being displayed for the first time
3260 //
3261 eAction = wxOwnerDrawn::wxODDrawAll;
3262
3263 if (pMeasureStruct->fsAttribute & MIA_HILITED)
3264 {
3265 //
3266 // If it is currently selected we let the system handle it
3267 //
3268 eStatus |= wxOwnerDrawn::wxODSelected;
3269 }
3270 if (pMeasureStruct->fsAttribute & MIA_CHECKED)
3271 {
3272 //
3273 // If it is currently checked we draw our own
3274 //
3275 eStatus |= wxOwnerDrawn::wxODChecked;
3276 pMeasureStruct->fsAttributeOld = pMeasureStruct->fsAttribute &= ~MIA_CHECKED;
3277 }
3278 if (pMeasureStruct->fsAttribute & MIA_DISABLED)
3279 {
3280 //
3281 // If it is currently disabled we let the system handle it
3282 //
3283 eStatus |= wxOwnerDrawn::wxODDisabled;
3284 }
3285 //
3286 // Don't really care about framed (indicationg focus) or NoDismiss
3287 //
3288 }
3289 else
3290 {
3291 if (pMeasureStruct->fsAttribute & MIA_HILITED)
3292 {
3293 eAction = wxOwnerDrawn::wxODDrawAll;
3294 eStatus |= wxOwnerDrawn::wxODSelected;
3295 //
3296 // Keep the system from trying to highlight with its bogus colors
3297 //
3298 pMeasureStruct->fsAttributeOld = pMeasureStruct->fsAttribute &= ~MIA_HILITED;
3299 }
3300 else if (!(pMeasureStruct->fsAttribute & MIA_HILITED))
3301 {
3302 eAction = wxOwnerDrawn::wxODDrawAll;
3303 eStatus = 0;
3304 //
3305 // Keep the system from trying to highlight with its bogus colors
3306 //
3307 pMeasureStruct->fsAttribute = pMeasureStruct->fsAttributeOld &= ~MIA_HILITED;
3308 }
3309 else
3310 {
3311 //
3312 // For now we don't care about anything else
3313 // just ignore the entire message!
3314 //
3315 return true;
3316 }
3317 }
3318 //
3319 // Now redraw the item
3320 //
3321 return(pMenuItem->OnDrawItem( vDc
3322 ,vRect
3323 ,(wxOwnerDrawn::wxODAction)eAction
3324 ,(wxOwnerDrawn::wxODStatus)eStatus
3325 ));
3326 //
3327 // leave the fsAttribute and fsOldAttribute unchanged. If different,
3328 // the system will do the highlight or fraeming or disabling for us,
3329 // otherwise, we'd have to do it ourselves.
3330 //
3331 }
3332 #endif // wxUSE_MENUS_NATIVE
3333
3334 wxWindow* pItem = FindItem(vId);
3335
3336 if (pItem && pItem->IsKindOf(CLASSINFO(wxControl)))
3337 {
3338 return ((wxControl *)pItem)->OS2OnDraw(pItemStruct);
3339 }
3340 #else
3341 vId = vId;
3342 pItemStruct = pItemStruct;
3343 #endif
3344 return false;
3345 } // end of wxWindowOS2::OS2OnDrawItem
3346
3347 long wxWindowOS2::OS2OnMeasureItem( int lId,
3348 WXMEASUREITEMSTRUCT* pItemStruct )
3349 {
3350 #if wxUSE_OWNER_DRAWN
3351 //
3352 // Is it a menu item?
3353 //
3354 if (lId == 65536) // I really don't like this...has to be a better indicator
3355 {
3356 if (IsKindOf(CLASSINFO(wxFrame))) // we'll assume if Frame then a menu
3357 {
3358 size_t nWidth;
3359 size_t nHeight;
3360 POWNERITEM pMeasureStruct = (POWNERITEM)pItemStruct;
3361 wxFrame* pFrame = (wxFrame*)this;
3362 wxMenuItem* pMenuItem = pFrame->GetMenuBar()->FindItem(pMeasureStruct->idItem, pMeasureStruct->hItem);
3363
3364 wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
3365 nWidth = 0L;
3366 nHeight = 0L;
3367 if (pMenuItem->OnMeasureItem( &nWidth
3368 ,&nHeight
3369 ))
3370 {
3371 MRESULT mRc;
3372
3373 pMeasureStruct->rclItem.xRight = nWidth;
3374 pMeasureStruct->rclItem.xLeft = 0L;
3375 pMeasureStruct->rclItem.yTop = nHeight;
3376 pMeasureStruct->rclItem.yBottom = 0L;
3377 mRc = MRFROM2SHORT(nHeight, nWidth);
3378 return LONGFROMMR(mRc);
3379 }
3380 return 0L;
3381 }
3382 }
3383 wxWindow* pItem = FindItem(lId);
3384
3385 if (pItem && pItem->IsKindOf(CLASSINFO(wxControl)))
3386 {
3387 OWNERITEM vItem;
3388
3389 vItem.idItem = (LONG)pItemStruct;
3390 return ((wxControl *)pItem)->OS2OnMeasure((WXMEASUREITEMSTRUCT*)&vItem);
3391 }
3392 #else
3393 lId = lId;
3394 pItemStruct = pItemStruct;
3395 #endif // wxUSE_OWNER_DRAWN
3396 return FALSE;
3397 }
3398
3399 // ---------------------------------------------------------------------------
3400 // colours and palettes
3401 // ---------------------------------------------------------------------------
3402
3403 bool wxWindowOS2::HandleSysColorChange()
3404 {
3405 wxSysColourChangedEvent vEvent;
3406
3407 vEvent.SetEventObject(this);
3408 return HandleWindowEvent(vEvent);
3409 } // end of wxWindowOS2::HandleSysColorChange
3410
3411 bool wxWindowOS2::HandleCtlColor( WXHBRUSH* WXUNUSED(phBrush) )
3412 {
3413 //
3414 // Not much provided with message. So not sure I can do anything with it
3415 //
3416 return true;
3417 } // end of wxWindowOS2::HandleCtlColor
3418
3419
3420 // Define for each class of dialog and control
3421 WXHBRUSH wxWindowOS2::OnCtlColor(WXHDC WXUNUSED(hDC),
3422 WXHWND WXUNUSED(hWnd),
3423 WXUINT WXUNUSED(nCtlColor),
3424 WXUINT WXUNUSED(message),
3425 WXWPARAM WXUNUSED(wParam),
3426 WXLPARAM WXUNUSED(lParam))
3427 {
3428 return (WXHBRUSH)0;
3429 }
3430
3431 bool wxWindowOS2::HandlePaletteChanged()
3432 {
3433 // need to set this to something first
3434 WXHWND hWndPalChange = NULLHANDLE;
3435
3436 wxPaletteChangedEvent vEvent(GetId());
3437
3438 vEvent.SetEventObject(this);
3439 vEvent.SetChangedWindow(wxFindWinFromHandle(hWndPalChange));
3440
3441 return HandleWindowEvent(vEvent);
3442 } // end of wxWindowOS2::HandlePaletteChanged
3443
3444 //
3445 // Responds to colour changes: passes event on to children.
3446 //
3447 void wxWindowOS2::OnSysColourChanged(
3448 wxSysColourChangedEvent& rEvent
3449 )
3450 {
3451 wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
3452
3453 while (node)
3454 {
3455 //
3456 // Only propagate to non-top-level windows
3457 //
3458 wxWindow* pWin = (wxWindow *)node->GetData();
3459
3460 if (pWin->GetParent())
3461 {
3462 wxSysColourChangedEvent vEvent;
3463
3464 rEvent.SetEventObject(pWin);
3465 pWin->HandleWindowEvent(vEvent);
3466 }
3467 node = node->GetNext();
3468 }
3469 } // end of wxWindowOS2::OnSysColourChanged
3470
3471 // ---------------------------------------------------------------------------
3472 // painting
3473 // ---------------------------------------------------------------------------
3474
3475 void wxWindow::OnPaint (
3476 wxPaintEvent& rEvent
3477 )
3478 {
3479 HDC hDC = (HDC)wxPaintDCImpl::FindDCInCache((wxWindow*) rEvent.GetEventObject());
3480
3481 if (hDC != 0)
3482 {
3483 OS2DefWindowProc( (WXUINT)WM_PAINT
3484 ,(WXWPARAM)hDC
3485 ,(WXLPARAM)0
3486 );
3487 }
3488 } // end of wxWindow::OnPaint
3489
3490 bool wxWindowOS2::HandlePaint()
3491 {
3492 HRGN hRgn;
3493 wxPaintEvent vEvent(m_windowId);
3494 HPS hPS;
3495 bool bProcessed;
3496
3497 // Create empty region
3498 // TODO: get HPS somewhere else if possible
3499 hPS = ::WinGetPS(GetHwnd());
3500 hRgn = ::GpiCreateRegion(hPS, 0, NULL);
3501
3502 if (::WinQueryUpdateRegion(GetHwnd(), hRgn) == RGN_ERROR)
3503 {
3504 wxLogLastError(wxT("CreateRectRgn"));
3505 return false;
3506 }
3507 // Get all the rectangles from the region, convert the individual
3508 // rectangles to "the other" coordinate system and reassemble a
3509 // region from the rectangles, to be feed into m_updateRegion.
3510 //
3511 RGNRECT vRgnData;
3512 PRECTL pUpdateRects = NULL;
3513 vRgnData.ulDirection = RECTDIR_LFRT_TOPBOT;
3514 if (::GpiQueryRegionRects( hPS // Pres space
3515 ,hRgn // Handle of region to query
3516 ,NULL // Return all RECTs
3517 ,&vRgnData // Will contain number or RECTs in region
3518 ,NULL // NULL to return number of RECTs
3519 ))
3520 {
3521 pUpdateRects = new RECTL[vRgnData.crcReturned];
3522 vRgnData.crc = vRgnData.crcReturned;
3523 vRgnData.ircStart = 1;
3524 if (::GpiQueryRegionRects( hPS // Pres space of source
3525 ,hRgn // Handle of source region
3526 ,NULL // Return all RECTs
3527 ,&vRgnData // Operations set to return rects
3528 ,pUpdateRects // Will contain the actual RECTS
3529 ))
3530 {
3531 int height;
3532 RECT vRect;
3533 ::WinQueryWindowRect(GetHwnd(), &vRect);
3534 height = vRect.yTop;
3535
3536 for(size_t i = 0; i < vRgnData.crc; i++)
3537 {
3538 int rectHeight;
3539 rectHeight = pUpdateRects[i].yTop - pUpdateRects[i].yBottom;
3540 pUpdateRects[i].yBottom = height - pUpdateRects[i].yTop;
3541 pUpdateRects[i].yTop = pUpdateRects[i].yBottom + rectHeight;
3542 }
3543 ::GpiSetRegion(hPS, hRgn, vRgnData.crc, pUpdateRects);
3544 delete [] pUpdateRects;
3545 }
3546 }
3547 m_updateRegion = wxRegion(hRgn, hPS);
3548
3549 vEvent.SetEventObject(this);
3550 bProcessed = HandleWindowEvent(vEvent);
3551
3552 if (!bProcessed &&
3553 IsKindOf(CLASSINFO(wxPanel)) &&
3554 GetChildren().GetCount() == 0
3555 )
3556 {
3557 //
3558 // OS/2 needs to process this right here, not by the default proc
3559 // Window's default proc correctly paints everything, OS/2 does not.
3560 // For decorative panels that typically have no children, we draw
3561 // borders.
3562 //
3563 HPS hPS;
3564 RECTL vRect;
3565
3566 hPS = ::WinBeginPaint( GetHwnd()
3567 ,NULLHANDLE
3568 ,&vRect
3569 );
3570 if(hPS)
3571 {
3572 ::GpiCreateLogColorTable( hPS
3573 ,0L
3574 ,LCOLF_CONSECRGB
3575 ,0L
3576 ,(LONG)wxTheColourDatabase->m_nSize
3577 ,(PLONG)wxTheColourDatabase->m_palTable
3578 );
3579 ::GpiCreateLogColorTable( hPS
3580 ,0L
3581 ,LCOLF_RGB
3582 ,0L
3583 ,0L
3584 ,NULL
3585 );
3586 if (::WinIsWindowVisible(GetHWND()))
3587 ::WinFillRect(hPS, &vRect, GetBackgroundColour().GetPixel());
3588 if (m_dwExStyle)
3589 {
3590 LINEBUNDLE vLineBundle;
3591
3592 vLineBundle.lColor = 0x00000000; // Black
3593 vLineBundle.usMixMode = FM_OVERPAINT;
3594 vLineBundle.fxWidth = 1;
3595 vLineBundle.lGeomWidth = 1;
3596 vLineBundle.usType = LINETYPE_SOLID;
3597 vLineBundle.usEnd = 0;
3598 vLineBundle.usJoin = 0;
3599 ::GpiSetAttrs( hPS
3600 ,PRIM_LINE
3601 ,LBB_COLOR | LBB_MIX_MODE | LBB_WIDTH | LBB_GEOM_WIDTH | LBB_TYPE
3602 ,0L
3603 ,&vLineBundle
3604 );
3605 ::WinQueryWindowRect(GetHwnd(), &vRect);
3606 wxDrawBorder( hPS
3607 ,vRect
3608 ,m_dwExStyle
3609 );
3610 }
3611 }
3612 ::WinEndPaint(hPS);
3613 bProcessed = true;
3614 }
3615 else if (!bProcessed &&
3616 IsKindOf(CLASSINFO(wxPanel))
3617 )
3618 {
3619 //
3620 // Panel with children, usually fills a frame client so no borders.
3621 //
3622 HPS hPS;
3623 RECTL vRect;
3624
3625 hPS = ::WinBeginPaint( GetHwnd()
3626 ,NULLHANDLE
3627 ,&vRect
3628 );
3629 if(hPS)
3630 {
3631 ::GpiCreateLogColorTable( hPS
3632 ,0L
3633 ,LCOLF_CONSECRGB
3634 ,0L
3635 ,(LONG)wxTheColourDatabase->m_nSize
3636 ,(PLONG)wxTheColourDatabase->m_palTable
3637 );
3638 ::GpiCreateLogColorTable( hPS
3639 ,0L
3640 ,LCOLF_RGB
3641 ,0L
3642 ,0L
3643 ,NULL
3644 );
3645
3646 if (::WinIsWindowVisible(GetHWND()))
3647 ::WinFillRect(hPS, &vRect, GetBackgroundColour().GetPixel());
3648 }
3649 ::WinEndPaint(hPS);
3650 bProcessed = true;
3651 }
3652 return bProcessed;
3653 } // end of wxWindowOS2::HandlePaint
3654
3655 bool wxWindowOS2::HandleEraseBkgnd( WXHDC hDC )
3656 {
3657 SWP vSwp;
3658 bool rc;
3659
3660 ::WinQueryWindowPos(GetHwnd(), &vSwp);
3661 if (vSwp.fl & SWP_MINIMIZE)
3662 return true;
3663
3664 wxClientDC vDC(this);
3665 wxPMDCImpl *impl = (wxPMDCImpl*) vDC.GetImpl();
3666 impl->SetHDC(hDC);
3667 impl->SetHPS((HPS)hDC); // this is really a PS
3668
3669 wxEraseEvent vEvent(m_windowId, &vDC);
3670
3671 vEvent.SetEventObject(this);
3672
3673 rc = HandleWindowEvent(vEvent);
3674
3675 impl->SetHPS(NULLHANDLE);
3676 return true;
3677 } // end of wxWindowOS2::HandleEraseBkgnd
3678
3679 void wxWindowOS2::OnEraseBackground(wxEraseEvent& rEvent)
3680 {
3681 RECTL vRect;
3682 wxPMDCImpl *impl = (wxPMDCImpl*) rEvent.GetDC()->GetImpl();
3683 HPS hPS = impl->GetHPS();
3684 APIRET rc;
3685 LONG lColor = m_backgroundColour.GetPixel();
3686
3687 rc = ::WinQueryWindowRect(GetHwnd(), &vRect);
3688 rc = ::WinFillRect(hPS, &vRect, lColor);
3689 } // end of wxWindowOS2::OnEraseBackground
3690
3691 // ---------------------------------------------------------------------------
3692 // moving and resizing
3693 // ---------------------------------------------------------------------------
3694
3695 bool wxWindowOS2::HandleMinimize()
3696 {
3697 wxIconizeEvent vEvent(m_windowId);
3698
3699 vEvent.SetEventObject(this);
3700 return HandleWindowEvent(vEvent);
3701 } // end of wxWindowOS2::HandleMinimize
3702
3703 bool wxWindowOS2::HandleMaximize()
3704 {
3705 wxMaximizeEvent vEvent(m_windowId);
3706
3707 vEvent.SetEventObject(this);
3708 return HandleWindowEvent(vEvent);
3709 } // end of wxWindowOS2::HandleMaximize
3710
3711 bool wxWindowOS2::HandleMove( int nX, int nY )
3712 {
3713 wxPoint pt(nX, nY);
3714 wxMoveEvent vEvent(pt, m_windowId);
3715
3716 vEvent.SetEventObject(this);
3717 return HandleWindowEvent(vEvent);
3718 } // end of wxWindowOS2::HandleMove
3719
3720 bool wxWindowOS2::HandleSize( int nWidth,
3721 int nHeight,
3722 WXUINT WXUNUSED(nFlag) )
3723 {
3724 wxSize sz(nWidth, nHeight);
3725 wxSizeEvent vEvent(sz, m_windowId);
3726
3727 vEvent.SetEventObject(this);
3728 return HandleWindowEvent(vEvent);
3729 } // end of wxWindowOS2::HandleSize
3730
3731 bool wxWindowOS2::HandleGetMinMaxInfo( PSWP pSwp )
3732 {
3733 POINTL vPoint;
3734
3735 switch(pSwp->fl)
3736 {
3737 case SWP_MAXIMIZE:
3738 ::WinGetMaxPosition(GetHwnd(), pSwp);
3739 m_maxWidth = pSwp->cx;
3740 m_maxHeight = pSwp->cy;
3741 break;
3742
3743 case SWP_MINIMIZE:
3744 ::WinGetMinPosition(GetHwnd(), pSwp, &vPoint);
3745 m_minWidth = pSwp->cx;
3746 m_minHeight = pSwp->cy;
3747 break;
3748
3749 default:
3750 return false;
3751 }
3752 return true;
3753 } // end of wxWindowOS2::HandleGetMinMaxInfo
3754
3755 // ---------------------------------------------------------------------------
3756 // command messages
3757 // ---------------------------------------------------------------------------
3758 bool wxWindowOS2::HandleCommand( WXWORD wId,
3759 WXWORD wCmd,
3760 WXHWND hControl )
3761 {
3762 #if wxUSE_MENUS_NATIVE
3763 if (wxCurrentPopupMenu)
3764 {
3765 wxMenu* pPopupMenu = wxCurrentPopupMenu;
3766
3767 wxCurrentPopupMenu = NULL;
3768 return pPopupMenu->OS2Command(wCmd, wId);
3769 }
3770 #endif // wxUSE_MENUS_NATIVE
3771
3772 wxWindow* pWin = FindItem(wId);
3773
3774 if (!pWin)
3775 {
3776 pWin = wxFindWinFromHandle(hControl);
3777 }
3778
3779 if (pWin)
3780 return pWin->OS2Command(wCmd, wId);
3781
3782 return false;
3783 } // end of wxWindowOS2::HandleCommand
3784
3785 bool wxWindowOS2::HandleSysCommand( WXWPARAM wParam,
3786 WXLPARAM WXUNUSED(lParam) )
3787 {
3788 //
3789 // 4 bits are reserved
3790 //
3791 switch (SHORT1FROMMP(wParam))
3792 {
3793 case SC_MAXIMIZE:
3794 return HandleMaximize();
3795
3796 case SC_MINIMIZE:
3797 return HandleMinimize();
3798 }
3799 return false;
3800 } // end of wxWindowOS2::HandleSysCommand
3801
3802 // ---------------------------------------------------------------------------
3803 // mouse events
3804 // ---------------------------------------------------------------------------
3805 //TODO: check against MSW
3806 void wxWindowOS2::InitMouseEvent(
3807 wxMouseEvent& rEvent
3808 , int nX
3809 , int nY
3810 , WXUINT uFlags
3811 )
3812 {
3813 int nHeight;
3814 DoGetSize(0, &nHeight);
3815 rEvent.m_x = nX;
3816 // Convert to wxWidgets standard coordinate system!
3817 rEvent.m_y = nHeight - nY;
3818 rEvent.m_shiftDown = ((uFlags & KC_SHIFT) != 0);
3819 rEvent.m_controlDown = ((uFlags & KC_CTRL) != 0);
3820 rEvent.m_altDown = ((uFlags & KC_ALT) != 0);
3821 rEvent.m_leftDown = IsKeyDown(VK_BUTTON1);
3822 rEvent.m_middleDown = IsKeyDown(VK_BUTTON3);
3823 rEvent.m_rightDown = IsKeyDown(VK_BUTTON2);
3824 rEvent.SetTimestamp(s_currentMsg.time);
3825 rEvent.SetEventObject(this);
3826 rEvent.SetId(GetId());
3827
3828 #if wxUSE_MOUSEEVENT_HACK
3829 m_lastMouseX = nX;
3830 m_lastMouseY = nY;
3831 m_lastMouseEvent = rEvent.GetEventType();
3832 #endif // wxUSE_MOUSEEVENT_HACK
3833 } // end of wxWindowOS2::InitMouseEvent
3834
3835 bool wxWindowOS2::HandleMouseEvent( WXUINT uMsg,
3836 int nX,
3837 int nY,
3838 WXUINT uFlags )
3839 {
3840 bool bProcessed = false;
3841
3842 //
3843 // The mouse events take consecutive IDs from WM_MOUSEFIRST to
3844 // WM_MOUSELAST, so it's enough to subtract WM_MOUSEMOVE == WM_MOUSEFIRST
3845 // from the message id and take the value in the table to get wxWin event
3846 // id
3847 //
3848 static const wxEventType eventsMouse[] =
3849 {
3850 wxEVT_MOTION,
3851 wxEVT_LEFT_DOWN,
3852 wxEVT_LEFT_UP,
3853 wxEVT_LEFT_DCLICK,
3854 wxEVT_RIGHT_DOWN,
3855 wxEVT_RIGHT_UP,
3856 wxEVT_RIGHT_DCLICK,
3857 wxEVT_MIDDLE_DOWN,
3858 wxEVT_MIDDLE_UP,
3859 wxEVT_MIDDLE_DCLICK
3860 };
3861
3862 // Bounds check
3863 if ((uMsg >= WM_MOUSEMOVE) && (uMsg <= WM_BUTTON3DBLCLK))
3864 {
3865 wxMouseEvent vEvent(eventsMouse[uMsg - WM_MOUSEMOVE]);
3866
3867 InitMouseEvent( vEvent
3868 ,nX
3869 ,nY
3870 ,uFlags
3871 );
3872
3873 bProcessed = HandleWindowEvent(vEvent);
3874 if (!bProcessed)
3875 {
3876 HPOINTER hCursor = (HPOINTER)GetCursor().GetHCURSOR();
3877
3878 if (hCursor != NULLHANDLE)
3879 {
3880 ::WinSetPointer(HWND_DESKTOP, hCursor);
3881 bProcessed = true;
3882 }
3883 }
3884 }
3885 return bProcessed;
3886 } // end of wxWindowOS2::HandleMouseEvent
3887
3888 bool wxWindowOS2::HandleMouseMove( int nX,
3889 int nY,
3890 WXUINT uFlags )
3891 {
3892 if (!m_bMouseInWindow)
3893 {
3894 //
3895 // Generate an ENTER event
3896 //
3897 m_bMouseInWindow = true;
3898
3899 wxMouseEvent vEvent(wxEVT_ENTER_WINDOW);
3900
3901 InitMouseEvent( vEvent
3902 ,nX
3903 ,nY
3904 ,uFlags
3905 );
3906
3907 (void)HandleWindowEvent(vEvent);
3908 }
3909 return HandleMouseEvent( WM_MOUSEMOVE
3910 ,nX
3911 ,nY
3912 ,uFlags
3913 );
3914 } // end of wxWindowOS2::HandleMouseMove
3915
3916 // ---------------------------------------------------------------------------
3917 // keyboard handling
3918 // ---------------------------------------------------------------------------
3919
3920 //
3921 // Create the key event of the given type for the given key - used by
3922 // HandleChar and HandleKeyDown/Up
3923 //
3924 wxKeyEvent wxWindowOS2::CreateKeyEvent(
3925 wxEventType eType
3926 , int nId
3927 , WXLPARAM lParam
3928 , WXWPARAM wParam
3929 ) const
3930 {
3931 wxKeyEvent vEvent(eType);
3932
3933 vEvent.SetId(GetId());
3934 vEvent.m_shiftDown = IsShiftDown();
3935 vEvent.m_controlDown = IsCtrlDown();
3936 vEvent.m_altDown = (HIWORD(lParam) & KC_ALT) == KC_ALT;
3937
3938 vEvent.SetEventObject((wxWindow *)this); // const_cast
3939 vEvent.m_keyCode = nId;
3940 vEvent.m_rawCode = (wxUint32)wParam;
3941 vEvent.m_rawFlags = (wxUint32)lParam;
3942 vEvent.SetTimestamp(s_currentMsg.time);
3943
3944 //
3945 // Translate the position to client coords
3946 //
3947 POINTL vPoint;
3948 RECTL vRect;
3949
3950 ::WinQueryPointerPos(HWND_DESKTOP, &vPoint);
3951 ::WinQueryWindowRect( GetHwnd()
3952 ,&vRect
3953 );
3954
3955 vPoint.x -= vRect.xLeft;
3956 vPoint.y -= vRect.yBottom;
3957
3958 vEvent.m_x = vPoint.x;
3959 vEvent.m_y = vPoint.y;
3960
3961 return vEvent;
3962 } // end of wxWindowOS2::CreateKeyEvent
3963
3964 //
3965 // isASCII is true only when we're called from WM_CHAR handler and not from
3966 // WM_KEYDOWN one
3967 //
3968 bool wxWindowOS2::HandleChar( WXWPARAM WXUNUSED(wParam),
3969 WXLPARAM lParam,
3970 bool isASCII )
3971 {
3972 bool bCtrlDown = false;
3973 int vId;
3974
3975 if (m_bLastKeydownProcessed)
3976 {
3977 //
3978 // The key was handled in the EVT_KEY_DOWN. Handling a key in an
3979 // EVT_KEY_DOWN handler is meant, by design, to prevent EVT_CHARs
3980 // from happening, so just bail out at this point.
3981 //
3982 m_bLastKeydownProcessed = false;
3983 return true;
3984 }
3985 if (isASCII)
3986 {
3987 //
3988 // If 1 -> 26, translate to either special keycode or just set
3989 // ctrlDown. IOW, Ctrl-C should result in keycode == 3 and
3990 // ControlDown() == true.
3991 //
3992 vId = SHORT1FROMMP(lParam);
3993 if ((vId > 0) && (vId < 27))
3994 {
3995 switch (vId)
3996 {
3997 case 13:
3998 vId = WXK_RETURN;
3999 break;
4000
4001 case 8:
4002 vId = WXK_BACK;
4003 break;
4004
4005 case 9:
4006 vId = WXK_TAB;
4007 break;
4008
4009 default:
4010 bCtrlDown = true;
4011 break;
4012 }
4013 }
4014 }
4015 else // we're called from WM_KEYDOWN
4016 {
4017 vId = wxCharCodeOS2ToWX((int)SHORT2FROMMP(lParam));
4018 if (vId == 0)
4019 return false;
4020 }
4021
4022 wxKeyEvent vEvent(CreateKeyEvent( wxEVT_CHAR, vId, lParam ));
4023
4024 if (bCtrlDown)
4025 {
4026 vEvent.m_controlDown = true;
4027 }
4028
4029 return (HandleWindowEvent(vEvent));
4030 }
4031
4032 bool wxWindowOS2::HandleKeyDown( WXWPARAM wParam,
4033 WXLPARAM lParam )
4034 {
4035 int nId = wxCharCodeOS2ToWX((int)SHORT2FROMMP(lParam));
4036
4037 if (!nId)
4038 {
4039 //
4040 // Normal ASCII char
4041 //
4042 nId = SHORT1FROMMP(lParam);
4043 }
4044
4045 if (nId != -1)
4046 {
4047 wxKeyEvent vEvent(CreateKeyEvent( wxEVT_KEY_DOWN
4048 ,nId
4049 ,(MPARAM)lParam
4050 ,(MPARAM)wParam
4051 ));
4052
4053 if (HandleWindowEvent(vEvent))
4054 {
4055 return true;
4056 }
4057 }
4058 return false;
4059 } // end of wxWindowOS2::HandleKeyDown
4060
4061 bool wxWindowOS2::HandleKeyUp( WXWPARAM wParam,
4062 WXLPARAM lParam )
4063 {
4064 int nId = wxCharCodeOS2ToWX((int)SHORT2FROMMP(lParam));
4065
4066 if (!nId)
4067 {
4068 //
4069 // Normal ASCII char
4070 //
4071 nId = CHAR1FROMMP(lParam);
4072 }
4073
4074 if (nId != -1)
4075 {
4076 wxKeyEvent vEvent(CreateKeyEvent( wxEVT_KEY_UP
4077 ,nId
4078 ,(MPARAM)lParam
4079 ,(MPARAM)wParam
4080 ));
4081
4082 if (HandleWindowEvent(vEvent))
4083 return true;
4084 }
4085 return false;
4086 } // end of wxWindowOS2::HandleKeyUp
4087
4088 // ---------------------------------------------------------------------------
4089 // joystick
4090 // ---------------------------------------------------------------------------
4091
4092 // ---------------------------------------------------------------------------
4093 // scrolling
4094 // ---------------------------------------------------------------------------
4095
4096 bool wxWindowOS2::OS2OnScroll( int nOrientation,
4097 WXWORD wParam,
4098 WXWORD wPos,
4099 WXHWND hControl )
4100 {
4101 if (hControl)
4102 {
4103 wxWindow* pChild = wxFindWinFromHandle(hControl);
4104
4105 if (pChild )
4106 return pChild->OS2OnScroll( nOrientation
4107 ,wParam
4108 ,wPos
4109 ,hControl
4110 );
4111 }
4112
4113 wxScrollWinEvent vEvent;
4114
4115 vEvent.SetPosition(wPos);
4116 vEvent.SetOrientation(nOrientation);
4117 vEvent.SetEventObject(this);
4118
4119 switch (wParam)
4120 {
4121 case SB_LINEUP:
4122 vEvent.SetEventType(wxEVT_SCROLLWIN_LINEUP);
4123 break;
4124
4125 case SB_LINEDOWN:
4126 vEvent.SetEventType(wxEVT_SCROLLWIN_LINEDOWN);
4127 break;
4128
4129 case SB_PAGEUP:
4130 vEvent.SetEventType(wxEVT_SCROLLWIN_PAGEUP);
4131 break;
4132
4133 case SB_PAGEDOWN:
4134 vEvent.SetEventType(wxEVT_SCROLLWIN_PAGEDOWN);
4135 break;
4136
4137 case SB_SLIDERPOSITION:
4138 vEvent.SetEventType(wxEVT_SCROLLWIN_THUMBRELEASE);
4139 break;
4140
4141 case SB_SLIDERTRACK:
4142 vEvent.SetEventType(wxEVT_SCROLLWIN_THUMBTRACK);
4143 break;
4144
4145 default:
4146 return false;
4147 }
4148 return HandleWindowEvent(vEvent);
4149 } // end of wxWindowOS2::OS2OnScroll
4150
4151 //
4152 // Getting the Y position for a window, like a control, is a real
4153 // pain. There are three situations we must deal with in determining
4154 // the OS2 to wxWidgets Y coordinate.
4155 //
4156 // 1) The controls are created in a dialog.
4157 // This is the easiest since a dialog is created with its original
4158 // size so the standard: Y = ParentHeight - (Y + ControlHeight);
4159 //
4160 // 2) The controls are direct children of a frame
4161 // In this instance the controls are actually children of the Frame's
4162 // client. During creation the frame's client resizes several times
4163 // during creation of the status bar and toolbars. The CFrame class
4164 // will take care of this using its AlterChildPos proc.
4165 //
4166 // 3) The controls are children of a panel, which in turn is a child of
4167 // a frame.
4168 // The panel may be one of many, in which case the same treatment
4169 // as 1 applies. It may be the only child, though.
4170 // This is the nastiest case. A panel is created as the only child of
4171 // the frame and as such, when a frame has only one child, the child is
4172 // expanded to fit the entire client area of the frame. Because the
4173 // controls are created BEFORE this occurs their positions are totally
4174 // whacked and any call to WinQueryWindowPos will return invalid
4175 // coordinates. So for this situation we have to compare the size of
4176 // the panel at control creation time with that of the frame client. If
4177 // they are the same we can use the standard Y position equation. If
4178 // not, then we must use the Frame Client's dimensions to position them
4179 // as that will be the eventual size of the panel after the frame resizes
4180 // it!
4181 //
4182 int wxWindowOS2::GetOS2ParentHeight( wxWindowOS2* pParent )
4183 {
4184 if (pParent)
4185 {
4186 //
4187 // Case 1
4188 //
4189 if (pParent->IsKindOf(CLASSINFO(wxDialog)))
4190 return(pParent->GetClientSize().y);
4191
4192 //
4193 // Case 2 -- if we are one of the separately built standard Frame
4194 // children, like a statusbar, menubar, or toolbar we want to
4195 // use the frame, itself, for positioning. Otherwise we are
4196 // child window and want to use the Frame's client.
4197 //
4198 else if (pParent->IsKindOf(CLASSINFO(wxFrame)))
4199 {
4200 if (IsKindOf(CLASSINFO(wxStatusBar)) ||
4201 IsKindOf(CLASSINFO(wxMenuBar)) ||
4202 IsKindOf(CLASSINFO(wxToolBar))
4203 )
4204 {
4205 if (IsKindOf(CLASSINFO(wxToolBar)))
4206 {
4207 wxFrame* pFrame = wxDynamicCast(GetParent(), wxFrame);
4208
4209 if (pFrame->GetToolBar() == this)
4210 return(pParent->GetSize().y);
4211 else
4212 return(pParent->GetClientSize().y);
4213 }
4214 else
4215 return(pParent->GetSize().y);
4216 }
4217 else
4218 return(pParent->GetClientSize().y);
4219 }
4220 //
4221 // Case -- this is for any window that is the sole child of a Frame.
4222 // The grandparent must exist and it must be of type CFrame
4223 // and it's height must be different. Otherwise the standard
4224 // applies.
4225 //
4226 else
4227 return(pParent->GetClientSize().y);
4228 }
4229 else // We must be a child of the screen
4230 {
4231 int nHeight;
4232 wxDisplaySize(NULL,&nHeight);
4233 return(nHeight);
4234 }
4235 } // end of wxWindowOS2::GetOS2ParentHeight
4236
4237 //
4238 // OS/2 needs a lot extra manipulation to deal with layouts
4239 // for canvas windows, particularly scrolled ones.
4240 //
4241 wxWindowCreationHook::wxWindowCreationHook(
4242 wxWindow* pWinBeingCreated
4243 )
4244 {
4245 gpWinBeingCreated = pWinBeingCreated;
4246 } // end of wxWindowCreationHook::wxWindowCreationHook
4247
4248 wxWindowCreationHook::~wxWindowCreationHook()
4249 {
4250 gpWinBeingCreated = NULL;
4251 } // end of wxWindowCreationHook::~wxWindowCreationHook
4252
4253 // ===========================================================================
4254 // global functions
4255 // ===========================================================================
4256
4257 void wxGetCharSize(
4258 WXHWND hWnd
4259 , int* pX
4260 , int* pY
4261 ,wxFont* WXUNUSED(pTheFont)
4262 )
4263 {
4264 FONTMETRICS vFM;
4265 HPS hPS;
4266 BOOL rc;
4267
4268 hPS =::WinGetPS(hWnd);
4269
4270 rc = ::GpiQueryFontMetrics(hPS, sizeof(FONTMETRICS), &vFM);
4271 if (rc)
4272 {
4273 if (pX)
4274 *pX = vFM.lAveCharWidth;
4275 if (pY)
4276 *pY = vFM.lEmHeight + vFM.lExternalLeading;
4277 }
4278 else
4279 {
4280 if (pX)
4281 *pX = 10;
4282 if (pY)
4283 *pY = 15;
4284 }
4285 ::WinReleasePS(hPS);
4286 } // end of wxGetCharSize
4287
4288 //
4289 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
4290 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
4291 //
4292 int wxCharCodeOS2ToWX(
4293 int nKeySym
4294 )
4295 {
4296 int nId = 0;
4297
4298 switch (nKeySym)
4299 {
4300 case VK_BACKTAB: nId = WXK_BACK; break;
4301 case VK_TAB: nId = WXK_TAB; break;
4302 case VK_CLEAR: nId = WXK_CLEAR; break;
4303 case VK_ENTER: nId = WXK_RETURN; break;
4304 case VK_SHIFT: nId = WXK_SHIFT; break;
4305 case VK_CTRL: nId = WXK_CONTROL; break;
4306 case VK_PAUSE: nId = WXK_PAUSE; break;
4307 case VK_SPACE: nId = WXK_SPACE; break;
4308 case VK_PAGEUP: nId = WXK_PAGEUP; break;
4309 case VK_PAGEDOWN: nId = WXK_PAGEDOWN; break;
4310 case VK_ESC: nId = WXK_ESCAPE; break;
4311 case VK_END: nId = WXK_END; break;
4312 case VK_HOME : nId = WXK_HOME; break;
4313 case VK_LEFT : nId = WXK_LEFT; break;
4314 case VK_UP: nId = WXK_UP; break;
4315 case VK_RIGHT: nId = WXK_RIGHT; break;
4316 case VK_DOWN : nId = WXK_DOWN; break;
4317 case VK_PRINTSCRN: nId = WXK_PRINT; break;
4318 case VK_INSERT: nId = WXK_INSERT; break;
4319 case VK_DELETE: nId = WXK_DELETE; break;
4320 case VK_CAPSLOCK: nId = WXK_CAPITAL; break;
4321 case VK_F1: nId = WXK_F1; break;
4322 case VK_F2: nId = WXK_F2; break;
4323 case VK_F3: nId = WXK_F3; break;
4324 case VK_F4: nId = WXK_F4; break;
4325 case VK_F5: nId = WXK_F5; break;
4326 case VK_F6: nId = WXK_F6; break;
4327 case VK_F7: nId = WXK_F7; break;
4328 case VK_F8: nId = WXK_F8; break;
4329 case VK_F9: nId = WXK_F9; break;
4330 case VK_F10: nId = WXK_F10; break;
4331 case VK_F11: nId = WXK_F11; break;
4332 case VK_F12: nId = WXK_F12; break;
4333 case VK_F13: nId = WXK_F13; break;
4334 case VK_F14: nId = WXK_F14; break;
4335 case VK_F15: nId = WXK_F15; break;
4336 case VK_F16: nId = WXK_F16; break;
4337 case VK_F17: nId = WXK_F17; break;
4338 case VK_F18: nId = WXK_F18; break;
4339 case VK_F19: nId = WXK_F19; break;
4340 case VK_F20: nId = WXK_F20; break;
4341 case VK_F21: nId = WXK_F21; break;
4342 case VK_F22: nId = WXK_F22; break;
4343 case VK_F23: nId = WXK_F23; break;
4344 case VK_F24: nId = WXK_F24; break;
4345 case VK_OEM_1: nId = ';'; break;
4346 case VK_OEM_PLUS: nId = '+'; break;
4347 case VK_OEM_COMMA: nId = ','; break;
4348 case VK_OEM_MINUS: nId = '-'; break;
4349 case VK_OEM_PERIOD: nId = '.'; break;
4350 case VK_OEM_2: nId = '/'; break;
4351 case VK_OEM_3: nId = '~'; break;
4352 case VK_OEM_4: nId = '['; break;
4353 case VK_OEM_5: nId = '\\'; break;
4354 case VK_OEM_6: nId = ']'; break;
4355 case VK_OEM_7: nId = '\''; break;
4356 case VK_NUMLOCK: nId = WXK_NUMLOCK; break;
4357 case VK_SCRLLOCK: nId = WXK_SCROLL; break;
4358 default:
4359 {
4360 return 0;
4361 }
4362 }
4363 return nId;
4364 } // end of wxCharCodeOS2ToWX
4365
4366 int wxCharCodeWXToOS2( int nId,
4367 bool* bIsVirtual)
4368 {
4369 int nKeySym = 0;
4370
4371 if ( bIsVirtual )
4372 *bIsVirtual = true;
4373 switch (nId)
4374 {
4375 case WXK_CLEAR: nKeySym = VK_CLEAR; break;
4376 case WXK_SHIFT: nKeySym = VK_SHIFT; break;
4377 case WXK_CONTROL: nKeySym = VK_CTRL; break;
4378 case WXK_PAUSE: nKeySym = VK_PAUSE; break;
4379 case WXK_PAGEUP: nKeySym = VK_PAGEUP; break;
4380 case WXK_PAGEDOWN: nKeySym = VK_PAGEDOWN; break;
4381 case WXK_END: nKeySym = VK_END; break;
4382 case WXK_HOME : nKeySym = VK_HOME; break;
4383 case WXK_LEFT : nKeySym = VK_LEFT; break;
4384 case WXK_UP: nKeySym = VK_UP; break;
4385 case WXK_RIGHT: nKeySym = VK_RIGHT; break;
4386 case WXK_DOWN : nKeySym = VK_DOWN; break;
4387 case WXK_PRINT: nKeySym = VK_PRINTSCRN; break;
4388 case WXK_INSERT: nKeySym = VK_INSERT; break;
4389 case WXK_DELETE: nKeySym = VK_DELETE; break;
4390 case WXK_F1: nKeySym = VK_F1; break;
4391 case WXK_F2: nKeySym = VK_F2; break;
4392 case WXK_F3: nKeySym = VK_F3; break;
4393 case WXK_F4: nKeySym = VK_F4; break;
4394 case WXK_F5: nKeySym = VK_F5; break;
4395 case WXK_F6: nKeySym = VK_F6; break;
4396 case WXK_F7: nKeySym = VK_F7; break;
4397 case WXK_F8: nKeySym = VK_F8; break;
4398 case WXK_F9: nKeySym = VK_F9; break;
4399 case WXK_F10: nKeySym = VK_F10; break;
4400 case WXK_F11: nKeySym = VK_F11; break;
4401 case WXK_F12: nKeySym = VK_F12; break;
4402 case WXK_F13: nKeySym = VK_F13; break;
4403 case WXK_F14: nKeySym = VK_F14; break;
4404 case WXK_F15: nKeySym = VK_F15; break;
4405 case WXK_F16: nKeySym = VK_F16; break;
4406 case WXK_F17: nKeySym = VK_F17; break;
4407 case WXK_F18: nKeySym = VK_F18; break;
4408 case WXK_F19: nKeySym = VK_F19; break;
4409 case WXK_F20: nKeySym = VK_F20; break;
4410 case WXK_F21: nKeySym = VK_F21; break;
4411 case WXK_F22: nKeySym = VK_F22; break;
4412 case WXK_F23: nKeySym = VK_F23; break;
4413 case WXK_F24: nKeySym = VK_F24; break;
4414 case WXK_NUMLOCK: nKeySym = VK_NUMLOCK; break;
4415 case WXK_SCROLL: nKeySym = VK_SCRLLOCK; break;
4416 default:
4417 {
4418 if ( bIsVirtual )
4419 *bIsVirtual = false;
4420 nKeySym = nId;
4421 break;
4422 }
4423 }
4424 return nKeySym;
4425 } // end of wxCharCodeWXToOS2
4426
4427
4428 bool wxGetKeyState(wxKeyCode key)
4429 {
4430 wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key !=
4431 WXK_MBUTTON, wxT("can't use wxGetKeyState() for mouse buttons"));
4432
4433 const LONG vk = wxCharCodeWXToOS2(key);
4434 // if the requested key is a LED key, return true if the led is pressed
4435 if ( key == WXK_NUMLOCK || key == WXK_CAPITAL || key == WXK_SCROLL )
4436 {
4437 // low order bit means LED is highlighted and high order one means the
4438 // key is down; for compatibility with the other ports return true if
4439 // either one is set
4440 return ::WinGetKeyState(HWND_DESKTOP, vk) != 0;
4441
4442 }
4443 else // normal key
4444 {
4445 return IsKeyDown(vk);
4446 }
4447 }
4448
4449
4450 wxWindow* wxGetActiveWindow()
4451 {
4452 HWND hWnd = ::WinQueryActiveWindow(HWND_DESKTOP);
4453
4454 if (hWnd != 0)
4455 {
4456 return wxFindWinFromHandle((WXHWND)hWnd);
4457 }
4458 return NULL;
4459 } // end of wxGetActiveWindow
4460
4461 #ifdef __WXDEBUG__
4462 const wxChar* wxGetMessageName( int nMessage )
4463 {
4464 switch (nMessage)
4465 {
4466 case 0x0000: return wxT("WM_NULL");
4467 case 0x0001: return wxT("WM_CREATE");
4468 case 0x0002: return wxT("WM_DESTROY");
4469 case 0x0004: return wxT("WM_ENABLE");
4470 case 0x0005: return wxT("WM_SHOW");
4471 case 0x0006: return wxT("WM_MOVE");
4472 case 0x0007: return wxT("WM_SIZE");
4473 case 0x0008: return wxT("WM_ADJUSTWINDOWPOS");
4474 case 0x0009: return wxT("WM_CALCVALIDRECTS");
4475 case 0x000A: return wxT("WM_SETWINDOWPARAMS");
4476 case 0x000B: return wxT("WM_QUERYWINDOWPARAMS");
4477 case 0x000C: return wxT("WM_HITTEST");
4478 case 0x000D: return wxT("WM_ACTIVATE");
4479 case 0x000F: return wxT("WM_SETFOCUS");
4480 case 0x0010: return wxT("WM_SETSELECTION");
4481 case 0x0011: return wxT("WM_PPAINT");
4482 case 0x0012: return wxT("WM_PSETFOCUS");
4483 case 0x0013: return wxT("WM_PSYSCOLORCHANGE");
4484 case 0x0014: return wxT("WM_PSIZE");
4485 case 0x0015: return wxT("WM_PACTIVATE");
4486 case 0x0016: return wxT("WM_PCONTROL");
4487 case 0x0020: return wxT("WM_COMMAND");
4488 case 0x0021: return wxT("WM_SYSCOMMAND");
4489 case 0x0022: return wxT("WM_HELP");
4490 case 0x0023: return wxT("WM_PAINT");
4491 case 0x0024: return wxT("WM_TIMER");
4492 case 0x0025: return wxT("WM_SEM1");
4493 case 0x0026: return wxT("WM_SEM2");
4494 case 0x0027: return wxT("WM_SEM3");
4495 case 0x0028: return wxT("WM_SEM4");
4496 case 0x0029: return wxT("WM_CLOSE");
4497 case 0x002A: return wxT("WM_QUIT");
4498 case 0x002B: return wxT("WM_SYSCOLORCHANGE");
4499 case 0x002D: return wxT("WM_SYSVALUECHANGE");
4500 case 0x002E: return wxT("WM_APPTERMINATENOTIFY");
4501 case 0x002F: return wxT("WM_PRESPARAMCHANGED");
4502 // Control notification messages
4503 case 0x0030: return wxT("WM_CONTROL");
4504 case 0x0031: return wxT("WM_VSCROLL");
4505 case 0x0032: return wxT("WM_HSCROLL");
4506 case 0x0033: return wxT("WM_INITMENU");
4507 case 0x0034: return wxT("WM_MENUSELECT");
4508 case 0x0035: return wxT("WM_MENUSEND");
4509 case 0x0036: return wxT("WM_DRAWITEM");
4510 case 0x0037: return wxT("WM_MEASUREITEM");
4511 case 0x0038: return wxT("WM_CONTROLPOINTER");
4512 case 0x003A: return wxT("WM_QUERYDLGCODE");
4513 case 0x003B: return wxT("WM_INITDLG");
4514 case 0x003C: return wxT("WM_SUBSTITUTESTRING");
4515 case 0x003D: return wxT("WM_MATCHMNEMONIC");
4516 case 0x003E: return wxT("WM_SAVEAPPLICATION");
4517 case 0x0129: return wxT("WM_CTLCOLORCHANGE");
4518 case 0x0130: return wxT("WM_QUERYCTLTYPE");
4519 // Frame messages
4520 case 0x0040: return wxT("WM_FLASHWINDOW");
4521 case 0x0041: return wxT("WM_FORMATFRAME");
4522 case 0x0042: return wxT("WM_UPDATEFRAME");
4523 case 0x0043: return wxT("WM_FOCUSCHANGE");
4524 case 0x0044: return wxT("WM_SETBORDERSIZE");
4525 case 0x0045: return wxT("WM_TRACKFRAME");
4526 case 0x0046: return wxT("WM_MINMAXFRAME");
4527 case 0x0047: return wxT("WM_SETICON");
4528 case 0x0048: return wxT("WM_QUERYICON");
4529 case 0x0049: return wxT("WM_SETACCELTABLE");
4530 case 0x004A: return wxT("WM_QUERYACCELTABLE");
4531 case 0x004B: return wxT("WM_TRANSLATEACCEL");
4532 case 0x004C: return wxT("WM_QUERYTRACKINFO");
4533 case 0x004D: return wxT("WM_QUERYBORDERSIZE");
4534 case 0x004E: return wxT("WM_NEXTMENU");
4535 case 0x004F: return wxT("WM_ERASEBACKGROUND");
4536 case 0x0050: return wxT("WM_QUERYFRAMEINFO");
4537 case 0x0051: return wxT("WM_QUERYFOCUSCHAIN");
4538 case 0x0052: return wxT("WM_OWNERPOSCHANGE");
4539 case 0x0053: return wxT("WM_CACLFRAMERECT");
4540 case 0x0055: return wxT("WM_WINDOWPOSCHANGED");
4541 case 0x0056: return wxT("WM_ADJUSTFRAMEPOS");
4542 case 0x0059: return wxT("WM_QUERYFRAMECTLCOUNT");
4543 case 0x005B: return wxT("WM_QUERYHELPINFO");
4544 case 0x005C: return wxT("WM_SETHELPINFO");
4545 case 0x005D: return wxT("WM_ERROR");
4546 case 0x005E: return wxT("WM_REALIZEPALETTE");
4547 // Clipboard messages
4548 case 0x0060: return wxT("WM_RENDERFMT");
4549 case 0x0061: return wxT("WM_RENDERALLFMTS");
4550 case 0x0062: return wxT("WM_DESTROYCLIPBOARD");
4551 case 0x0063: return wxT("WM_PAINTCLIPBOARD");
4552 case 0x0064: return wxT("WM_SIZECLIPBOARD");
4553 case 0x0065: return wxT("WM_HSCROLLCLIPBOARD");
4554 case 0x0066: return wxT("WM_VSCROLLCLIPBOARD");
4555 case 0x0067: return wxT("WM_DRAWCLIPBOARD");
4556 // mouse messages
4557 case 0x0070: return wxT("WM_MOUSEMOVE");
4558 case 0x0071: return wxT("WM_BUTTON1DOWN");
4559 case 0x0072: return wxT("WM_BUTTON1UP");
4560 case 0x0073: return wxT("WM_BUTTON1DBLCLK");
4561 case 0x0074: return wxT("WM_BUTTON2DOWN");
4562 case 0x0075: return wxT("WM_BUTTON2UP");
4563 case 0x0076: return wxT("WM_BUTTON2DBLCLK");
4564 case 0x0077: return wxT("WM_BUTTON3DOWN");
4565 case 0x0078: return wxT("WM_BUTTON3UP");
4566 case 0x0079: return wxT("WM_BUTTON3DBLCLK");
4567 case 0x007D: return wxT("WM_MOUSEMAP");
4568 case 0x007E: return wxT("WM_VRNDISABLED");
4569 case 0x007F: return wxT("WM_VRNENABLED");
4570 case 0x0410: return wxT("WM_CHORD");
4571 case 0x0411: return wxT("WM_BUTTON1MOTIONSTART");
4572 case 0x0412: return wxT("WM_BUTTON1MOTIONEND");
4573 case 0x0413: return wxT("WM_BUTTON1CLICK");
4574 case 0x0414: return wxT("WM_BUTTON2MOTIONSTART");
4575 case 0x0415: return wxT("WM_BUTTON2MOTIONEND");
4576 case 0x0416: return wxT("WM_BUTTON2CLICK");
4577 case 0x0417: return wxT("WM_BUTTON3MOTIONSTART");
4578 case 0x0418: return wxT("WM_BUTTON3MOTIONEND");
4579 case 0x0419: return wxT("WM_BUTTON3CLICK");
4580 case 0x0420: return wxT("WM_BEGINDRAG");
4581 case 0x0421: return wxT("WM_ENDDRAG");
4582 case 0x0422: return wxT("WM_SINGLESELECT");
4583 case 0x0423: return wxT("WM_OPEN");
4584 case 0x0424: return wxT("WM_CONTEXTMENU");
4585 case 0x0425: return wxT("WM_CONTEXTHELP");
4586 case 0x0426: return wxT("WM_TEXTEDIT");
4587 case 0x0427: return wxT("WM_BEGINSELECT");
4588 case 0x0228: return wxT("WM_ENDSELECT");
4589 case 0x0429: return wxT("WM_PICKUP");
4590 case 0x04C0: return wxT("WM_PENFIRST");
4591 case 0x04FF: return wxT("WM_PENLAST");
4592 case 0x0500: return wxT("WM_MMPMFIRST");
4593 case 0x05FF: return wxT("WM_MMPMLAST");
4594 case 0x0600: return wxT("WM_STDDLGFIRST");
4595 case 0x06FF: return wxT("WM_STDDLGLAST");
4596 case 0x0BD0: return wxT("WM_BIDI_FIRST");
4597 case 0x0BFF: return wxT("WM_BIDI_LAST");
4598 // keyboard input
4599 case 0x007A: return wxT("WM_CHAR");
4600 case 0x007B: return wxT("WM_VIOCHAR");
4601 // DDE messages
4602 case 0x00A0: return wxT("WM_DDE_INITIATE");
4603 case 0x00A1: return wxT("WM_DDE_REQUEST");
4604 case 0x00A2: return wxT("WM_DDE_ACK");
4605 case 0x00A3: return wxT("WM_DDE_DATA");
4606 case 0x00A4: return wxT("WM_DDE_ADVISE");
4607 case 0x00A5: return wxT("WM_DDE_UNADVISE");
4608 case 0x00A6: return wxT("WM_DDE_POKE");
4609 case 0x00A7: return wxT("WM_DDE_EXECUTE");
4610 case 0x00A8: return wxT("WM_DDE_TERMINATE");
4611 case 0x00A9: return wxT("WM_DDE_INITIATEACK");
4612 case 0x00AF: return wxT("WM_DDE_LAST");
4613 // Buttons
4614 case 0x0120: return wxT("BM_CLICK");
4615 case 0x0121: return wxT("BM_QUERYCHECKINDEX");
4616 case 0x0122: return wxT("BM_QUERYHILITE");
4617 case 0x0123: return wxT("BM_SETHILITE");
4618 case 0x0124: return wxT("BM_QUERYCHECK");
4619 case 0x0125: return wxT("BM_SETCHECK");
4620 case 0x0126: return wxT("BM_SETDEFAULT");
4621 case 0x0128: return wxT("BM_AUTOSIZE");
4622 // Combo boxes
4623 case 0x029A: return wxT("CBID_LIST");
4624 case 0x029B: return wxT("CBID_EDIT");
4625 case 0x0170: return wxT("CBM_SHOWLIST");
4626 case 0x0171: return wxT("CBM_HILITE");
4627 case 0x0172: return wxT("CBM_ISLISTSHOWING");
4628 // Edit fields
4629 case 0x0140: return wxT("EM_QUERYCHANGED");
4630 case 0x0141: return wxT("EM_QUERYSEL");
4631 case 0x0142: return wxT("EM_SETSEL");
4632 case 0x0143: return wxT("EM_SETTEXTLIMIT");
4633 case 0x0144: return wxT("EM_CUT");
4634 case 0x0145: return wxT("EM_COPY");
4635 case 0x0146: return wxT("EM_CLEAR");
4636 case 0x0147: return wxT("EM_PASTE");
4637 case 0x0148: return wxT("EM_QUERYFIRSTCHAR");
4638 case 0x0149: return wxT("EM_SETFIRSTCHAR");
4639 case 0x014A: return wxT("EM_QUERYREADONLY");
4640 case 0x014B: return wxT("EM_SETREADONLY");
4641 case 0x014C: return wxT("EM_SETINSERTMODE");
4642 // Listboxes
4643 case 0x0160: return wxT("LM_QUERYITEMCOUNT");
4644 case 0x0161: return wxT("LM_INSERTITEM");
4645 case 0x0162: return wxT("LM_SETOPENINDEX");
4646 case 0x0163: return wxT("LM_DELETEITEM");
4647 case 0x0164: return wxT("LM_SELECTITEM");
4648 case 0x0165: return wxT("LM_QUERYSELECTION");
4649 case 0x0166: return wxT("LM_SETITEMTEXT");
4650 case 0x0167: return wxT("LM_QUERYITEMTEXTLENGTH");
4651 case 0x0168: return wxT("LM_QUERYITEMTEXT");
4652 case 0x0169: return wxT("LM_SETITEMHANDLE");
4653 case 0x016A: return wxT("LM_QUERYITEMHANDLE");
4654 case 0x016B: return wxT("LM_SEARCHSTRING");
4655 case 0x016C: return wxT("LM_SETITEMHEIGHT");
4656 case 0x016D: return wxT("LM_QUERYTOPINDEX");
4657 case 0x016E: return wxT("LM_DELETEALL");
4658 case 0x016F: return wxT("LM_INSERTMULITEMS");
4659 case 0x0660: return wxT("LM_SETITEMWIDTH");
4660 // Menus
4661 case 0x0180: return wxT("MM_INSERTITEM");
4662 case 0x0181: return wxT("MM_DELETEITEM");
4663 case 0x0182: return wxT("MM_QUERYITEM");
4664 case 0x0183: return wxT("MM_SETITEM");
4665 case 0x0184: return wxT("MM_QUERYITEMCOUNT");
4666 case 0x0185: return wxT("MM_STARTMENUMODE");
4667 case 0x0186: return wxT("MM_ENDMENUMODE");
4668 case 0x0188: return wxT("MM_REMOVEITEM");
4669 case 0x0189: return wxT("MM_SELECTITEM");
4670 case 0x018A: return wxT("MM_QUERYSELITEMID");
4671 case 0x018B: return wxT("MM_QUERYITEMTEXT");
4672 case 0x018C: return wxT("MM_QUERYITEMTEXTLENGTH");
4673 case 0x018D: return wxT("MM_SETITEMHANDLE");
4674 case 0x018E: return wxT("MM_SETITEMTEXT");
4675 case 0x018F: return wxT("MM_ITEMPOSITIONFROMID");
4676 case 0x0190: return wxT("MM_ITEMIDFROMPOSITION");
4677 case 0x0191: return wxT("MM_QUERYITEMATTR");
4678 case 0x0192: return wxT("MM_SETITEMATTR");
4679 case 0x0193: return wxT("MM_ISITEMVALID");
4680 case 0x0194: return wxT("MM_QUERYITEMRECT");
4681 case 0x0431: return wxT("MM_QUERYDEFAULTITEMID");
4682 case 0x0432: return wxT("MM_SETDEFAULTITEMID");
4683 // Scrollbars
4684 case 0x01A0: return wxT("SBM_SETSCROLLBAR");
4685 case 0x01A1: return wxT("SBM_SETPOS");
4686 case 0x01A2: return wxT("SBM_QUERYPOS");
4687 case 0x01A3: return wxT("SBM_QUERYRANGE");
4688 case 0x01A6: return wxT("SBM_SETTHUMBSIZE");
4689
4690 // Help messages
4691 case 0x0F00: return wxT("WM_HELPBASE");
4692 case 0x0FFF: return wxT("WM_HELPTOP");
4693 // Beginning of user defined messages
4694 case 0x1000: return wxT("WM_USER");
4695
4696 // wxWidgets user defined types
4697
4698 // listview
4699 // case 0x1000 + 0: return wxT("LVM_GETBKCOLOR");
4700 case 0x1000 + 1: return wxT("LVM_SETBKCOLOR");
4701 case 0x1000 + 2: return wxT("LVM_GETIMAGELIST");
4702 case 0x1000 + 3: return wxT("LVM_SETIMAGELIST");
4703 case 0x1000 + 4: return wxT("LVM_GETITEMCOUNT");
4704 case 0x1000 + 5: return wxT("LVM_GETITEMA");
4705 case 0x1000 + 75: return wxT("LVM_GETITEMW");
4706 case 0x1000 + 6: return wxT("LVM_SETITEMA");
4707 case 0x1000 + 76: return wxT("LVM_SETITEMW");
4708 case 0x1000 + 7: return wxT("LVM_INSERTITEMA");
4709 case 0x1000 + 77: return wxT("LVM_INSERTITEMW");
4710 case 0x1000 + 8: return wxT("LVM_DELETEITEM");
4711 case 0x1000 + 9: return wxT("LVM_DELETEALLITEMS");
4712 case 0x1000 + 10: return wxT("LVM_GETCALLBACKMASK");
4713 case 0x1000 + 11: return wxT("LVM_SETCALLBACKMASK");
4714 case 0x1000 + 12: return wxT("LVM_GETNEXTITEM");
4715 case 0x1000 + 13: return wxT("LVM_FINDITEMA");
4716 case 0x1000 + 83: return wxT("LVM_FINDITEMW");
4717 case 0x1000 + 14: return wxT("LVM_GETITEMRECT");
4718 case 0x1000 + 15: return wxT("LVM_SETITEMPOSITION");
4719 case 0x1000 + 16: return wxT("LVM_GETITEMPOSITION");
4720 case 0x1000 + 17: return wxT("LVM_GETSTRINGWIDTHA");
4721 case 0x1000 + 87: return wxT("LVM_GETSTRINGWIDTHW");
4722 case 0x1000 + 18: return wxT("LVM_HITTEST");
4723 case 0x1000 + 19: return wxT("LVM_ENSUREVISIBLE");
4724 case 0x1000 + 20: return wxT("LVM_SCROLL");
4725 case 0x1000 + 21: return wxT("LVM_REDRAWITEMS");
4726 case 0x1000 + 22: return wxT("LVM_ARRANGE");
4727 case 0x1000 + 23: return wxT("LVM_EDITLABELA");
4728 case 0x1000 + 118: return wxT("LVM_EDITLABELW");
4729 case 0x1000 + 24: return wxT("LVM_GETEDITCONTROL");
4730 case 0x1000 + 25: return wxT("LVM_GETCOLUMNA");
4731 case 0x1000 + 95: return wxT("LVM_GETCOLUMNW");
4732 case 0x1000 + 26: return wxT("LVM_SETCOLUMNA");
4733 case 0x1000 + 96: return wxT("LVM_SETCOLUMNW");
4734 case 0x1000 + 27: return wxT("LVM_INSERTCOLUMNA");
4735 case 0x1000 + 97: return wxT("LVM_INSERTCOLUMNW");
4736 case 0x1000 + 28: return wxT("LVM_DELETECOLUMN");
4737 case 0x1000 + 29: return wxT("LVM_GETCOLUMNWIDTH");
4738 case 0x1000 + 30: return wxT("LVM_SETCOLUMNWIDTH");
4739 case 0x1000 + 31: return wxT("LVM_GETHEADER");
4740 case 0x1000 + 33: return wxT("LVM_CREATEDRAGIMAGE");
4741 case 0x1000 + 34: return wxT("LVM_GETVIEWRECT");
4742 case 0x1000 + 35: return wxT("LVM_GETTEXTCOLOR");
4743 case 0x1000 + 36: return wxT("LVM_SETTEXTCOLOR");
4744 case 0x1000 + 37: return wxT("LVM_GETTEXTBKCOLOR");
4745 case 0x1000 + 38: return wxT("LVM_SETTEXTBKCOLOR");
4746 case 0x1000 + 39: return wxT("LVM_GETTOPINDEX");
4747 case 0x1000 + 40: return wxT("LVM_GETCOUNTPERPAGE");
4748 case 0x1000 + 41: return wxT("LVM_GETORIGIN");
4749 case 0x1000 + 42: return wxT("LVM_UPDATE");
4750 case 0x1000 + 43: return wxT("LVM_SETITEMSTATE");
4751 case 0x1000 + 44: return wxT("LVM_GETITEMSTATE");
4752 case 0x1000 + 45: return wxT("LVM_GETITEMTEXTA");
4753 case 0x1000 + 115: return wxT("LVM_GETITEMTEXTW");
4754 case 0x1000 + 46: return wxT("LVM_SETITEMTEXTA");
4755 case 0x1000 + 116: return wxT("LVM_SETITEMTEXTW");
4756 case 0x1000 + 47: return wxT("LVM_SETITEMCOUNT");
4757 case 0x1000 + 48: return wxT("LVM_SORTITEMS");
4758 case 0x1000 + 49: return wxT("LVM_SETITEMPOSITION32");
4759 case 0x1000 + 50: return wxT("LVM_GETSELECTEDCOUNT");
4760 case 0x1000 + 51: return wxT("LVM_GETITEMSPACING");
4761 case 0x1000 + 52: return wxT("LVM_GETISEARCHSTRINGA");
4762 case 0x1000 + 117: return wxT("LVM_GETISEARCHSTRINGW");
4763 case 0x1000 + 53: return wxT("LVM_SETICONSPACING");
4764 case 0x1000 + 54: return wxT("LVM_SETEXTENDEDLISTVIEWSTYLE");
4765 case 0x1000 + 55: return wxT("LVM_GETEXTENDEDLISTVIEWSTYLE");
4766 case 0x1000 + 56: return wxT("LVM_GETSUBITEMRECT");
4767 case 0x1000 + 57: return wxT("LVM_SUBITEMHITTEST");
4768 case 0x1000 + 58: return wxT("LVM_SETCOLUMNORDERARRAY");
4769 case 0x1000 + 59: return wxT("LVM_GETCOLUMNORDERARRAY");
4770 case 0x1000 + 60: return wxT("LVM_SETHOTITEM");
4771 case 0x1000 + 61: return wxT("LVM_GETHOTITEM");
4772 case 0x1000 + 62: return wxT("LVM_SETHOTCURSOR");
4773 case 0x1000 + 63: return wxT("LVM_GETHOTCURSOR");
4774 case 0x1000 + 64: return wxT("LVM_APPROXIMATEVIEWRECT");
4775 case 0x1000 + 65: return wxT("LVM_SETWORKAREA");
4776
4777 // tree view
4778 case 0x1100 + 0: return wxT("TVM_INSERTITEMA");
4779 case 0x1100 + 50: return wxT("TVM_INSERTITEMW");
4780 case 0x1100 + 1: return wxT("TVM_DELETEITEM");
4781 case 0x1100 + 2: return wxT("TVM_EXPAND");
4782 case 0x1100 + 4: return wxT("TVM_GETITEMRECT");
4783 case 0x1100 + 5: return wxT("TVM_GETCOUNT");
4784 case 0x1100 + 6: return wxT("TVM_GETINDENT");
4785 case 0x1100 + 7: return wxT("TVM_SETINDENT");
4786 case 0x1100 + 8: return wxT("TVM_GETIMAGELIST");
4787 case 0x1100 + 9: return wxT("TVM_SETIMAGELIST");
4788 case 0x1100 + 10: return wxT("TVM_GETNEXTITEM");
4789 case 0x1100 + 11: return wxT("TVM_SELECTITEM");
4790 case 0x1100 + 12: return wxT("TVM_GETITEMA");
4791 case 0x1100 + 62: return wxT("TVM_GETITEMW");
4792 case 0x1100 + 13: return wxT("TVM_SETITEMA");
4793 case 0x1100 + 63: return wxT("TVM_SETITEMW");
4794 case 0x1100 + 14: return wxT("TVM_EDITLABELA");
4795 case 0x1100 + 65: return wxT("TVM_EDITLABELW");
4796 case 0x1100 + 15: return wxT("TVM_GETEDITCONTROL");
4797 case 0x1100 + 16: return wxT("TVM_GETVISIBLECOUNT");
4798 case 0x1100 + 17: return wxT("TVM_HITTEST");
4799 case 0x1100 + 18: return wxT("TVM_CREATEDRAGIMAGE");
4800 case 0x1100 + 19: return wxT("TVM_SORTCHILDREN");
4801 case 0x1100 + 20: return wxT("TVM_ENSUREVISIBLE");
4802 case 0x1100 + 21: return wxT("TVM_SORTCHILDRENCB");
4803 case 0x1100 + 22: return wxT("TVM_ENDEDITLABELNOW");
4804 case 0x1100 + 23: return wxT("TVM_GETISEARCHSTRINGA");
4805 case 0x1100 + 64: return wxT("TVM_GETISEARCHSTRINGW");
4806 case 0x1100 + 24: return wxT("TVM_SETTOOLTIPS");
4807 case 0x1100 + 25: return wxT("TVM_GETTOOLTIPS");
4808
4809 // header
4810 case 0x1200 + 0: return wxT("HDM_GETITEMCOUNT");
4811 case 0x1200 + 1: return wxT("HDM_INSERTITEMA");
4812 case 0x1200 + 10: return wxT("HDM_INSERTITEMW");
4813 case 0x1200 + 2: return wxT("HDM_DELETEITEM");
4814 case 0x1200 + 3: return wxT("HDM_GETITEMA");
4815 case 0x1200 + 11: return wxT("HDM_GETITEMW");
4816 case 0x1200 + 4: return wxT("HDM_SETITEMA");
4817 case 0x1200 + 12: return wxT("HDM_SETITEMW");
4818 case 0x1200 + 5: return wxT("HDM_LAYOUT");
4819 case 0x1200 + 6: return wxT("HDM_HITTEST");
4820 case 0x1200 + 7: return wxT("HDM_GETITEMRECT");
4821 case 0x1200 + 8: return wxT("HDM_SETIMAGELIST");
4822 case 0x1200 + 9: return wxT("HDM_GETIMAGELIST");
4823 case 0x1200 + 15: return wxT("HDM_ORDERTOINDEX");
4824 case 0x1200 + 16: return wxT("HDM_CREATEDRAGIMAGE");
4825 case 0x1200 + 17: return wxT("HDM_GETORDERARRAY");
4826 case 0x1200 + 18: return wxT("HDM_SETORDERARRAY");
4827 case 0x1200 + 19: return wxT("HDM_SETHOTDIVIDER");
4828
4829 // tab control
4830 case 0x1300 + 2: return wxT("TCM_GETIMAGELIST");
4831 case 0x1300 + 3: return wxT("TCM_SETIMAGELIST");
4832 case 0x1300 + 4: return wxT("TCM_GETITEMCOUNT");
4833 case 0x1300 + 5: return wxT("TCM_GETITEMA");
4834 case 0x1300 + 60: return wxT("TCM_GETITEMW");
4835 case 0x1300 + 6: return wxT("TCM_SETITEMA");
4836 case 0x1300 + 61: return wxT("TCM_SETITEMW");
4837 case 0x1300 + 7: return wxT("TCM_INSERTITEMA");
4838 case 0x1300 + 62: return wxT("TCM_INSERTITEMW");
4839 case 0x1300 + 8: return wxT("TCM_DELETEITEM");
4840 case 0x1300 + 9: return wxT("TCM_DELETEALLITEMS");
4841 case 0x1300 + 10: return wxT("TCM_GETITEMRECT");
4842 case 0x1300 + 11: return wxT("TCM_GETCURSEL");
4843 case 0x1300 + 12: return wxT("TCM_SETCURSEL");
4844 case 0x1300 + 13: return wxT("TCM_HITTEST");
4845 case 0x1300 + 14: return wxT("TCM_SETITEMEXTRA");
4846 case 0x1300 + 40: return wxT("TCM_ADJUSTRECT");
4847 case 0x1300 + 41: return wxT("TCM_SETITEMSIZE");
4848 case 0x1300 + 42: return wxT("TCM_REMOVEIMAGE");
4849 case 0x1300 + 43: return wxT("TCM_SETPADDING");
4850 case 0x1300 + 44: return wxT("TCM_GETROWCOUNT");
4851 case 0x1300 + 45: return wxT("TCM_GETTOOLTIPS");
4852 case 0x1300 + 46: return wxT("TCM_SETTOOLTIPS");
4853 case 0x1300 + 47: return wxT("TCM_GETCURFOCUS");
4854 case 0x1300 + 48: return wxT("TCM_SETCURFOCUS");
4855 case 0x1300 + 49: return wxT("TCM_SETMINTABWIDTH");
4856 case 0x1300 + 50: return wxT("TCM_DESELECTALL");
4857
4858 // toolbar
4859 case WM_USER+1000+1: return wxT("TB_ENABLEBUTTON");
4860 case WM_USER+1000+2: return wxT("TB_CHECKBUTTON");
4861 case WM_USER+1000+3: return wxT("TB_PRESSBUTTON");
4862 case WM_USER+1000+4: return wxT("TB_HIDEBUTTON");
4863 case WM_USER+1000+5: return wxT("TB_INDETERMINATE");
4864 case WM_USER+1000+9: return wxT("TB_ISBUTTONENABLED");
4865 case WM_USER+1000+10: return wxT("TB_ISBUTTONCHECKED");
4866 case WM_USER+1000+11: return wxT("TB_ISBUTTONPRESSED");
4867 case WM_USER+1000+12: return wxT("TB_ISBUTTONHIDDEN");
4868 case WM_USER+1000+13: return wxT("TB_ISBUTTONINDETERMINATE");
4869 case WM_USER+1000+17: return wxT("TB_SETSTATE");
4870 case WM_USER+1000+18: return wxT("TB_GETSTATE");
4871 case WM_USER+1000+19: return wxT("TB_ADDBITMAP");
4872 case WM_USER+1000+20: return wxT("TB_ADDBUTTONS");
4873 case WM_USER+1000+21: return wxT("TB_INSERTBUTTON");
4874 case WM_USER+1000+22: return wxT("TB_DELETEBUTTON");
4875 case WM_USER+1000+23: return wxT("TB_GETBUTTON");
4876 case WM_USER+1000+24: return wxT("TB_BUTTONCOUNT");
4877 case WM_USER+1000+25: return wxT("TB_COMMANDTOINDEX");
4878 case WM_USER+1000+26: return wxT("TB_SAVERESTOREA");
4879 case WM_USER+1000+76: return wxT("TB_SAVERESTOREW");
4880 case WM_USER+1000+27: return wxT("TB_CUSTOMIZE");
4881 case WM_USER+1000+28: return wxT("TB_ADDSTRINGA");
4882 case WM_USER+1000+77: return wxT("TB_ADDSTRINGW");
4883 case WM_USER+1000+29: return wxT("TB_GETITEMRECT");
4884 case WM_USER+1000+30: return wxT("TB_BUTTONSTRUCTSIZE");
4885 case WM_USER+1000+31: return wxT("TB_SETBUTTONSIZE");
4886 case WM_USER+1000+32: return wxT("TB_SETBITMAPSIZE");
4887 case WM_USER+1000+33: return wxT("TB_AUTOSIZE");
4888 case WM_USER+1000+35: return wxT("TB_GETTOOLTIPS");
4889 case WM_USER+1000+36: return wxT("TB_SETTOOLTIPS");
4890 case WM_USER+1000+37: return wxT("TB_SETPARENT");
4891 case WM_USER+1000+39: return wxT("TB_SETROWS");
4892 case WM_USER+1000+40: return wxT("TB_GETROWS");
4893 case WM_USER+1000+42: return wxT("TB_SETCMDID");
4894 case WM_USER+1000+43: return wxT("TB_CHANGEBITMAP");
4895 case WM_USER+1000+44: return wxT("TB_GETBITMAP");
4896 case WM_USER+1000+45: return wxT("TB_GETBUTTONTEXTA");
4897 case WM_USER+1000+75: return wxT("TB_GETBUTTONTEXTW");
4898 case WM_USER+1000+46: return wxT("TB_REPLACEBITMAP");
4899 case WM_USER+1000+47: return wxT("TB_SETINDENT");
4900 case WM_USER+1000+48: return wxT("TB_SETIMAGELIST");
4901 case WM_USER+1000+49: return wxT("TB_GETIMAGELIST");
4902 case WM_USER+1000+50: return wxT("TB_LOADIMAGES");
4903 case WM_USER+1000+51: return wxT("TB_GETRECT");
4904 case WM_USER+1000+52: return wxT("TB_SETHOTIMAGELIST");
4905 case WM_USER+1000+53: return wxT("TB_GETHOTIMAGELIST");
4906 case WM_USER+1000+54: return wxT("TB_SETDISABLEDIMAGELIST");
4907 case WM_USER+1000+55: return wxT("TB_GETDISABLEDIMAGELIST");
4908 case WM_USER+1000+56: return wxT("TB_SETSTYLE");
4909 case WM_USER+1000+57: return wxT("TB_GETSTYLE");
4910 case WM_USER+1000+58: return wxT("TB_GETBUTTONSIZE");
4911 case WM_USER+1000+59: return wxT("TB_SETBUTTONWIDTH");
4912 case WM_USER+1000+60: return wxT("TB_SETMAXTEXTROWS");
4913 case WM_USER+1000+61: return wxT("TB_GETTEXTROWS");
4914 case WM_USER+1000+41: return wxT("TB_GETBITMAPFLAGS");
4915 }
4916
4917 static wxString s_szBuf;
4918 s_szBuf.Printf(wxT("<unknown message = %d>"), nMessage);
4919 return s_szBuf.c_str();
4920
4921 } // end of wxGetMessageName
4922
4923 #endif // __WXDEBUG__
4924
4925 // Unused?
4926 #if 0
4927 static void TranslateKbdEventToMouse(
4928 wxWindow* pWin
4929 , int* pX
4930 , int* pY
4931 , ULONG* pFlags
4932 )
4933 {
4934 //
4935 // Construct the key mask
4936 ULONG& fwKeys = *pFlags;
4937
4938 fwKeys = VK_BUTTON2;
4939 if ((::WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x100) != 0)
4940 fwKeys |= VK_CTRL;
4941 if ((::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x100) != 0)
4942 fwKeys |= VK_SHIFT;
4943
4944 //
4945 // Simulate right mouse button click
4946 //
4947 POINTL vPoint;
4948
4949 ::WinQueryMsgPos(vHabmain, &vPoint);
4950 *pX = vPoint.x;
4951 *pY = vPoint.y;
4952
4953 pWin->ScreenToClient(pX, pY);
4954 } // end of TranslateKbdEventToMouse
4955 #endif
4956
4957 // Find the wxWindow at the current mouse position, returning the mouse
4958 // position.
4959 wxWindow* wxFindWindowAtPointer(wxPoint& WXUNUSED(rPt))
4960 {
4961 return wxFindWindowAtPoint(wxGetMousePosition());
4962 }
4963
4964 wxWindow* wxFindWindowAtPoint(const wxPoint& rPt)
4965 {
4966 POINTL vPt2;
4967
4968 vPt2.x = rPt.x;
4969 vPt2.y = rPt.y;
4970
4971 HWND hWndHit = ::WinWindowFromPoint(HWND_DESKTOP, &vPt2, FALSE);
4972 wxWindow* pWin = wxFindWinFromHandle((WXHWND)hWndHit) ;
4973 HWND hWnd = hWndHit;
4974
4975 //
4976 // Try to find a window with a wxWindow associated with it
4977 //
4978 while (!pWin && (hWnd != 0))
4979 {
4980 hWnd = ::WinQueryWindow(hWnd, QW_PARENT);
4981 pWin = wxFindWinFromHandle((WXHWND)hWnd) ;
4982 }
4983 return pWin;
4984 }
4985
4986 // Get the current mouse position.
4987 wxPoint wxGetMousePosition()
4988 {
4989 POINTL vPt;
4990
4991 ::WinQueryPointerPos(HWND_DESKTOP, &vPt);
4992 return wxPoint(vPt.x, vPt.y);
4993 }
4994
4995 wxMouseState wxGetMouseState()
4996 {
4997 wxMouseState ms;
4998 wxPoint pt = wxGetMousePosition();
4999 ms.SetX(pt.x);
5000 ms.SetY(pt.y);
5001 ms.SetLeftDown(IsKeyDown(VK_BUTTON1));
5002 ms.SetMiddleDown(IsKeyDown(VK_BUTTON3));
5003 ms.SetRightDown(IsKeyDown(VK_BUTTON2));
5004 ms.SetControlDown(IsCtrlDown());
5005 ms.SetShiftDown(IsShiftDown());
5006 ms.SetAltDown(IsKeyDown(VK_ALT)|IsKeyDown(VK_ALTGRAF));
5007 ms.SetMetaDown(IsKeyDown(VK_ALTGRAF));
5008 return ms;
5009 }
5010
5011
5012 wxWindowOS2* FindWindowForMouseEvent( wxWindow* pWin,
5013 short* WXUNUSED(pnX),
5014 short* WXUNUSED(pnY) )
5015 {
5016 HWND hWnd = GetHwndOf(pWin);
5017 HWND hWndUnderMouse;
5018 POINTL vPoint;
5019 BOOL rcEnabled = FALSE;
5020 BOOL rcVisible = FALSE;
5021
5022 ::WinQueryPointerPos(HWND_DESKTOP, &vPoint);
5023 hWndUnderMouse = ::WinWindowFromPoint(HWND_DESKTOP, &vPoint, TRUE);
5024 if (hWndUnderMouse != HWND_DESKTOP)
5025 {
5026 wxWindow* pWinUnderMouse = wxFindWinFromHandle((WXHWND)hWndUnderMouse);
5027
5028 if (pWinUnderMouse)
5029 {
5030 wxWindowList::compatibility_iterator current = pWinUnderMouse->GetChildren().GetFirst();
5031 wxWindow* pGrandChild = NULL;
5032 RECTL vRect;
5033 POINTL vPoint2;
5034
5035 ::WinMapWindowPoints(HWND_DESKTOP, hWndUnderMouse, &vPoint, 1);
5036 //
5037 // Find a child window mouse might be under
5038 //
5039 while (current)
5040 {
5041 wxWindow* pChild = current->GetData();
5042
5043 vPoint2.x = vPoint.x;
5044 vPoint2.y = vPoint.y;
5045 ::WinMapWindowPoints(hWndUnderMouse, pChild->GetHWND(), &vPoint2, 1);
5046 ::WinQueryWindowRect(pChild->GetHWND(), &vRect);
5047 if (::WinPtInRect(vHabmain, &vRect, &vPoint2))
5048 {
5049 if (pChild->IsTopLevel())
5050 {
5051 POINTL vPoint3;
5052 wxWindowList::compatibility_iterator current2 =pChild->GetChildren().GetFirst();
5053
5054 while (current2)
5055 {
5056 wxWindow* pGrandChild = current2->GetData();
5057
5058 vPoint3.x = vPoint2.x;
5059 vPoint3.y = vPoint2.y;
5060 ::WinMapWindowPoints( pChild->GetHWND()
5061 ,pGrandChild->GetHWND()
5062 ,&vPoint3
5063 ,1
5064 );
5065 ::WinQueryWindowRect(pGrandChild->GetHWND(), &vRect);
5066 if (::WinPtInRect(vHabmain, &vRect, &vPoint3))
5067 {
5068 hWndUnderMouse = GetHwndOf(pGrandChild);
5069 pWinUnderMouse = pGrandChild;
5070 break;
5071 }
5072 current2 = current2->GetNext();
5073 }
5074 if (pGrandChild)
5075 break;
5076 }
5077 hWndUnderMouse = GetHwndOf(pChild);
5078 pWinUnderMouse = pChild;
5079 rcVisible = ::WinIsWindowVisible(hWndUnderMouse);
5080 rcEnabled = ::WinIsWindowEnabled(hWndUnderMouse);
5081 if (rcVisible && rcEnabled)
5082 break;
5083 }
5084 current = current->GetNext();
5085 }
5086 }
5087 }
5088 rcVisible = ::WinIsWindowVisible(hWndUnderMouse);
5089 rcEnabled = ::WinIsWindowEnabled(hWndUnderMouse);
5090
5091
5092 //
5093 // Check that we have a child window which is susceptible to receive mouse
5094 // events: for this it must be shown and enabled
5095 //
5096 if ( hWndUnderMouse &&
5097 hWndUnderMouse != hWnd &&
5098 rcVisible && rcEnabled)
5099 {
5100 wxWindow* pWinUnderMouse = wxFindWinFromHandle((WXHWND)hWndUnderMouse);
5101
5102 if (pWinUnderMouse)
5103 {
5104 //
5105 // Translate the mouse coords to the other window coords
5106 //
5107 pWin = pWinUnderMouse;
5108 }
5109 }
5110 return pWin;
5111 } // end of FindWindowForMouseEvent