]> git.saurik.com Git - wxWidgets.git/blob - src/os2/window.cpp
More scrolling support
[wxWidgets.git] / src / os2 / window.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: windows.cpp
3 // Purpose: wxWindow
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/12/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 //
13 // For compilers that support precompilation, includes "wx.h".
14 //
15 #include "wx/wxprec.h"
16
17 #ifndef WX_PRECOMP
18 #define INCL_DOS
19 #define INCL_PM
20 #include <os2.h>
21 #include "wx/window.h"
22 #include "wx/accel.h"
23 #include "wx/setup.h"
24 #include "wx/menu.h"
25 #include "wx/dc.h"
26 #include "wx/dcclient.h"
27 #include "wx/utils.h"
28 #include "wx/app.h"
29 #include "wx/panel.h"
30 #include "wx/layout.h"
31 #include "wx/dialog.h"
32 #include "wx/frame.h"
33 #include "wx/listbox.h"
34 #include "wx/button.h"
35 #include "wx/msgdlg.h"
36
37 #include <stdio.h>
38 #endif
39
40 #if wxUSE_OWNER_DRAWN
41 #include "wx/ownerdrw.h"
42 #endif
43
44 #if wxUSE_DRAG_AND_DROP
45 #include "wx/dnd.h"
46 #endif
47
48 #include "wx/menuitem.h"
49 #include "wx/log.h"
50
51 #include "wx/os2/private.h"
52
53 #if wxUSE_TOOLTIPS
54 #include "wx/tooltip.h"
55 #endif
56
57 #if wxUSE_CARET
58 #include "wx/caret.h"
59 #endif // wxUSE_CARET
60
61 #include "wx/intl.h"
62 #include "wx/log.h"
63
64
65 #include "wx/textctrl.h"
66
67 #include <string.h>
68
69 //
70 // Place compiler, OS specific includes here
71 //
72
73 //
74 // Standard macros -- these are for OS/2 PM, but most GUI's have something similar
75 //
76 #ifndef GET_X_LPARAM
77 //
78 // SHORT1FROMMP -- LOWORD
79 //
80 #define GET_X_LPARAM(mp) ((unsigned short)(unsigned long)(mp))
81 //
82 // SHORT2FROMMP -- HIWORD
83 //
84 #define GET_Y_LPARAM(mp) ((unsigned short)(unsigned long)(mp >> 16))
85 #endif // GET_X_LPARAM
86
87 #ifndef CW_USEDEFAULT
88 # define CW_USEDEFAULT ((int)0x80000000)
89 #endif
90
91 // ---------------------------------------------------------------------------
92 // global variables
93 // ---------------------------------------------------------------------------
94
95 //
96 // The last Windows message we got (MT-UNSAFE)
97 //
98 QMSG s_currentMsg;
99
100 wxMenu* wxCurrentPopupMenu = NULL;
101 extern wxList WXDLLEXPORT wxPendingDelete;
102 #if !defined(__VISAGECPP__) || (__IBMCPP__ < 400)
103 extern wxChar wxCanvasClassName[];
104 #endif
105 wxList* wxWinHandleList = NULL;
106
107 // ---------------------------------------------------------------------------
108 // private functions
109 // ---------------------------------------------------------------------------
110
111 //
112 // the window proc for all our windows; most gui's have something similar
113 //
114 MRESULT EXPENTRY wxWndProc( HWND hWnd
115 ,ULONG message
116 ,MPARAM mp1
117 ,MPARAM mp2
118 );
119
120 #ifdef __WXDEBUG__
121 const char *wxGetMessageName(int message);
122 #endif //__WXDEBUG__
123
124 void wxRemoveHandleAssociation(wxWindow* pWin);
125 void wxAssociateWinWithHandle( HWND hWnd
126 ,wxWindow* pWin
127 );
128 wxWindow* wxFindWinFromHandle(WXHWND hWnd);
129
130 //
131 // This magical function is used to translate VK_APPS key presses to right
132 // mouse clicks
133 //
134 static void TranslateKbdEventToMouse( wxWindow* pWin
135 ,int* pX
136 ,int* pY
137 ,MPARAM* pFlags
138 );
139
140 //
141 // get the current state of SHIFT/CTRL keys
142 //
143 static inline bool IsShiftDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000) != 0; }
144 static inline bool IsCtrlDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000) != 0; }
145 // ---------------------------------------------------------------------------
146 // event tables
147 // ---------------------------------------------------------------------------
148
149 IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase)
150
151 BEGIN_EVENT_TABLE(wxWindow, wxWindowBase)
152 EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground)
153 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
154 EVT_INIT_DIALOG(wxWindow::OnInitDialog)
155 EVT_IDLE(wxWindow::OnIdle)
156 EVT_SET_FOCUS(wxWindow::OnSetFocus)
157 END_EVENT_TABLE()
158
159 // ===========================================================================
160 // implementation
161 // ===========================================================================
162
163 //
164 // Find an item given the PM Window id
165 //
166 wxWindow* wxWindow::FindItem(
167 long lId
168 ) const
169 {
170 wxControl* pItem = wxDynamicCast( this
171 ,wxControl
172 );
173
174 if (pItem)
175 {
176 //
177 // I it we or one of our "internal" children?
178 //
179 if (pItem->GetId() == lId ||
180 (pItem->GetSubcontrols().Index(lId) != wxNOT_FOUND))
181 {
182 return pItem;
183 }
184 }
185
186 wxWindowList::Node* pCurrent = GetChildren().GetFirst();
187
188 while (pCurrent)
189 {
190 wxWindow* pChildWin = pCurrent->GetData();
191 wxWindow* pWnd = pChildWin->FindItem(lId);
192
193 if (pWnd)
194 return pWnd;
195
196 pCurrent = pCurrent->GetNext();
197 }
198 return(NULL);
199 } // end of wxWindow::FindItem
200
201 //
202 // Find an item given the PM Window handle
203 //
204 wxWindow* wxWindow::FindItemByHWND(
205 WXHWND hWnd
206 , bool bControlOnly
207 ) const
208 {
209 wxWindowList::Node* pCurrent = GetChildren().GetFirst();
210
211 while (pCurrent)
212 {
213 wxWindow* pParent = pCurrent->GetData();
214
215 //
216 // Do a recursive search.
217 //
218 wxWindow* pWnd = pParent->FindItemByHWND(hWnd);
219
220 if (pWnd)
221 return(pWnd);
222
223 if (!bControlOnly || pParent->IsKindOf(CLASSINFO(wxControl)))
224 {
225 wxWindow* pItem = pCurrent->GetData();
226
227 if (pItem->GetHWND() == hWnd)
228 return(pItem);
229 else
230 {
231 if (pItem->ContainsHWND(hWnd))
232 return(pItem);
233 }
234 }
235 pCurrent = pCurrent->GetNext();
236 }
237 return(NULL);
238 } // end of wxWindow::FindItemByHWND
239
240 //
241 // Default command handler
242 //
243 bool wxWindow::OS2Command(
244 WXUINT WXUNUSED(uParam)
245 , WXWORD WXUNUSED(uId)
246 )
247 {
248 return(FALSE);
249 }
250
251 // ----------------------------------------------------------------------------
252 // constructors and such
253 // ----------------------------------------------------------------------------
254
255 void wxWindow::Init()
256 {
257 //
258 // Generic
259 //
260 InitBase();
261
262 //
263 // PM specific
264 //
265 m_bDoubleClickAllowed = 0;
266 m_bWinCaptured = FALSE;
267
268 m_isBeingDeleted = FALSE;
269 m_fnOldWndProc = 0;
270 m_bUseCtl3D = FALSE;
271 m_bMouseInWindow = FALSE;
272
273 //
274 // wxWnd
275 //
276 m_hMenu = 0L;
277 m_hWnd = 0L;
278 m_hWndScrollBarHorz = 0L;
279 m_hWndScrollBarVert = 0L;
280
281 //
282 // Pass WM_GETDLGCODE to DefWindowProc()
283 m_lDlgCode = 0;
284
285 m_nXThumbSize = 0;
286 m_nYThumbSize = 0;
287 m_bBackgroundTransparent = FALSE;
288
289 //
290 // As all windows are created with WS_VISIBLE style...
291 //
292 m_isShown = TRUE;
293
294 #if wxUSE_MOUSEEVENT_HACK
295 m_lLastMouseX =
296 m_lLastMouseY = -1;
297 m_nLastMouseEvent = -1;
298 #endif // wxUSE_MOUSEEVENT_HACK
299 } // wxWindow::Init
300
301 //
302 // Destructor
303 //
304 wxWindow::~wxWindow()
305 {
306 m_isBeingDeleted = TRUE;
307
308 OS2DetachWindowMenu();
309 if (m_parent)
310 m_parent->RemoveChild(this);
311 DestroyChildren();
312
313 if (m_hWnd)
314 {
315 if(!::WinDestroyWindow(GetHWND()))
316 wxLogLastError(wxT("DestroyWindow"));
317 //
318 // remove hWnd <-> wxWindow association
319 //
320 wxRemoveHandleAssociation(this);
321 }
322 } // end of wxWindow::~wxWindow
323
324 bool wxWindow::Create(
325 wxWindow* pParent
326 , wxWindowID vId
327 , const wxPoint& rPos
328 , const wxSize& rSize
329 , long lStyle
330 , const wxString& rName
331 )
332 {
333 HWND hParent = NULLHANDLE;
334 wxPoint vPos = rPos; // The OS/2 position
335
336 wxCHECK_MSG(pParent, FALSE, wxT("can't create wxWindow without parent"));
337
338 if ( !CreateBase( pParent
339 ,vId
340 ,rPos
341 ,rSize
342 ,lStyle
343 ,wxDefaultValidator
344 ,rName
345 ))
346 return(FALSE);
347
348 if (pParent)
349 {
350 pParent->AddChild(this);
351 hParent = GetWinHwnd(pParent);
352 //
353 // OS2 uses normal coordinates, no bassackwards Windows ones
354 //
355 vPos.y = pParent->GetSize().y - (vPos.y + rSize.y);
356 }
357 else
358 {
359 RECTL vRect;
360
361 ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
362 hParent = HWND_DESKTOP;
363 vPos.y = vRect.yTop - (vPos.y + rSize.y);
364 }
365
366 ULONG ulCreateFlags = 0L;
367
368
369 //
370 // Most wxSTYLES are really PM Class specific styles and will be
371 // set in those class create procs. PM's basic windows styles are
372 // very limited.
373 //
374 ulCreateFlags |= WS_VISIBLE;
375
376
377 if ( lStyle & wxCLIP_SIBLINGS )
378 ulCreateFlags |= WS_CLIPSIBLINGS;
379
380 if (lStyle & wxCLIP_CHILDREN )
381 ulCreateFlags |= WS_CLIPCHILDREN;
382
383 //
384 // Empty stuff for now since PM has no custome 3D effects
385 // Doesn't mean someone cannot make some up though
386 //
387 bool bWant3D;
388 WXDWORD dwExStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &bWant3D);
389
390 //
391 // Generic OS/2 Windows are created with no owner, no Z Order, no Control data,
392 // and no presentation parameters
393 //
394 OS2Create( hParent
395 ,(PSZ)wxCanvasClassName
396 ,rName.c_str()
397 ,ulCreateFlags
398 ,vPos.x
399 ,vPos.y
400 ,WidthDefault(rSize.x)
401 ,HeightDefault(rSize.y)
402 ,NULLHANDLE
403 ,NULLHANDLE
404 ,m_windowId
405 );
406
407 return(TRUE);
408 } // end of wxWindow::Create
409
410 // ---------------------------------------------------------------------------
411 // basic operations
412 // ---------------------------------------------------------------------------
413
414 void wxWindow::SetFocus()
415 {
416 HWND hWnd = GetHwnd();
417
418 if (hWnd)
419 ::WinSetFocus(HWND_DESKTOP, hWnd);
420 } // end of wxWindow::SetFocus
421
422 wxWindow* wxWindowBase::FindFocus()
423 {
424 HWND hWnd = ::WinQueryFocus(HWND_DESKTOP);
425
426 if (hWnd)
427 {
428 return wxFindWinFromHandle((WXHWND)hWnd);
429 }
430 return NULL;
431 } // wxWindowBase::FindFocus
432
433 bool wxWindow::Enable(
434 bool bEnable
435 )
436 {
437 if (!wxWindowBase::Enable(bEnable))
438 return(FALSE);
439
440 HWND hWnd = GetHwnd();
441
442 if ( hWnd )
443 ::WinEnableWindow(hWnd, (BOOL)bEnable);
444
445 wxWindowList::Node* pNode = GetChildren().GetFirst();
446
447 while (pNode)
448 {
449 wxWindow* pChild = pNode->GetData();
450
451 pChild->Enable(bEnable);
452 pNode = pNode->GetNext();
453 }
454 return(TRUE);
455 } // end of wxWindow::Enable
456
457 bool wxWindow::Show(
458 bool bShow
459 )
460 {
461 if (!wxWindowBase::Show(bShow))
462 return(FALSE);
463
464 HWND hWnd = GetHwnd();
465
466 ::WinShowWindow(hWnd, bShow);
467
468 if (bShow)
469 {
470 ::WinSetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER);
471 }
472 return(TRUE);
473 } // end of wxWindow::Show
474
475 void wxWindow::Raise()
476 {
477 ::WinSetWindowPos(GetHwnd(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | SWP_ACTIVATE);
478 } // end of wxWindow::Raise
479
480 void wxWindow::Lower()
481 {
482 ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER | SWP_DEACTIVATE);
483 } // end of wxWindow::Lower
484
485 void wxWindow::SetTitle(
486 const wxString& rTitle
487 )
488 {
489 ::WinSetWindowText(GetHwnd(), rTitle.c_str());
490 } // end of wxWindow::SetTitle
491
492 wxString wxWindow::GetTitle() const
493 {
494 return wxGetWindowText(GetHWND());
495 } // end of wxWindow::GetTitle
496
497 void wxWindow::CaptureMouse()
498 {
499 HWND hWnd = GetHwnd();
500
501 if (hWnd && !m_bWinCaptured)
502 {
503 ::WinSetCapture(HWND_DESKTOP, hWnd);
504 m_bWinCaptured = TRUE;
505 }
506 } // end of wxWindow::GetTitle
507
508 void wxWindow::ReleaseMouse()
509 {
510 if (m_bWinCaptured)
511 {
512 ::WinSetCapture(HWND_DESKTOP, NULLHANDLE);
513 m_bWinCaptured = FALSE;
514 }
515 } // end of wxWindow::ReleaseMouse
516
517 bool wxWindow::SetFont(
518 const wxFont& rFont
519 )
520 {
521 if (!wxWindowBase::SetFont(rFont))
522 {
523 // nothing to do
524 return(FALSE);
525 }
526
527 HWND hWnd = GetHwnd();
528
529 if (hWnd != 0)
530 {
531 wxChar zFont[128];
532
533 sprintf(zFont, "%d.%s", rFont.GetPointSize(), rFont.GetFaceName().c_str());
534 return(::WinSetPresParam(hWnd, PP_FONTNAMESIZE, strlen(zFont), (PVOID)zFont));
535 }
536 return(TRUE);
537 }
538
539 bool wxWindow::SetCursor(
540 const wxCursor& rCursor
541 ) // check if base implementation is OK
542 {
543 if ( !wxWindowBase::SetCursor(rCursor))
544 {
545 // no change
546 return FALSE;
547 }
548
549 wxASSERT_MSG( m_cursor.Ok(),
550 wxT("cursor must be valid after call to the base version"));
551
552 HWND hWnd = GetHwnd();
553 POINTL vPoint;
554 RECTL vRect;
555 HPS hPS;
556 HRGN hRGN;
557
558 hPS = ::WinGetPS(hWnd);
559
560 ::WinQueryPointerPos(HWND_DESKTOP, &vPoint);
561 ::WinQueryWindowRect(hWnd, &vRect);
562
563 hRGN = ::GpiCreateRegion(hPS, 1L, &vRect);
564
565 if ((::GpiPtInRegion(hPS, hRGN, &vPoint) == PRGN_INSIDE) && !wxIsBusy())
566 {
567 ::WinSetPointer(HWND_DESKTOP, (HPOINTER)m_cursor.GetHCURSOR());
568 }
569 return TRUE;
570 } // end of wxWindow::SetCursor
571
572 void wxWindow::WarpPointer(
573 int nXPos
574 , int nYPos
575 )
576 {
577 int nX = nXPos;
578 int nY = nYPos;
579 RECTL vRect;
580
581 ::WinQueryWindowRect(GetHwnd(), &vRect);
582 nX += vRect.xLeft;
583 nY += vRect.yBottom;
584
585 ::WinSetPointerPos(HWND_DESKTOP, (LONG)nX, (LONG)(nY));
586 } // end of wxWindow::WarpPointer
587
588 #if WXWIN_COMPATIBILITY
589 void wxWindow::OS2DeviceToLogical (float *x, float *y) const
590 {
591 }
592 #endif // WXWIN_COMPATIBILITY
593
594 // ---------------------------------------------------------------------------
595 // scrolling stuff
596 // ---------------------------------------------------------------------------
597
598 #if WXWIN_COMPATIBILITY
599 void wxWindow::SetScrollRange(
600 int nOrient
601 , int nRange
602 , bool bRefresh
603 )
604 {
605 ::WinSendMsg(GetHwnd(), SBM_SETSCROLLBAR, (MPARAM)0, MPFROM2SHORT(0, nRange));
606 } // end of wxWindow::SetScrollRange
607
608 void wxWindow::SetScrollPage(
609 int nOrient
610 , int nPage
611 , bool bRefresh
612 )
613 {
614 if ( orient == wxHORIZONTAL )
615 m_xThumbSize = page;
616 else
617 m_yThumbSize = page;
618 }
619
620 int wxWindow::OldGetScrollRange(
621 int nOrient
622 ) const
623 {
624 MRESULT mRc;
625 HWND hWnd = GetHwnd();
626
627 if (hWnd)
628 {
629 mRc = WinSendMsg(hWnd, SBM_QUERYRANGE, (MPARAM)0L, (MPARAM)0L);
630 return(SHORT2FROMMR(mRc));
631 }
632 return 0;
633 } // end of wxWindow::OldGetScrollRange
634
635 int wxWindow::GetScrollPage(
636 int nOrient
637 ) const
638 {
639 if (nOrient == wxHORIZONTAL)
640 return m_nXThumbSize;
641 else
642 return m_nYThumbSize;
643 } // end of wxWindow::GetScrollPage
644 #endif // WXWIN_COMPATIBILITY
645
646 int wxWindow::GetScrollPos(
647 int nOrient
648 ) const
649 {
650 return((int)::WinSendMsg(GetHwnd(), SBM_QUERYPOS, (MPARAM)NULL, (MPARAM)NULL));
651 } // end of wxWindow::GetScrollPos
652
653 int wxWindow::GetScrollRange(
654 int nOrient
655 ) const
656 {
657 MRESULT mr;
658
659 mr = ::WinSendMsg(GetHwnd(), SBM_QUERYRANGE, (MPARAM)NULL, (MPARAM)NULL);
660 return((int)SHORT2FROMMR(mr));
661 } // end of wxWindow::GetScrollRange
662
663 int wxWindow::GetScrollThumb(
664 int nOrient
665 ) const
666 {
667 WNDPARAMS vWndParams;
668 PSBCDATA pSbcd;
669
670 ::WinSendMsg(GetHwnd(), WM_QUERYWINDOWPARAMS, (MPARAM)&vWndParams, (MPARAM)NULL);
671 pSbcd = (PSBCDATA)vWndParams.pCtlData;
672 return((int)pSbcd->posThumb);
673 } // end of wxWindow::GetScrollThumb
674
675 void wxWindow::SetScrollPos(
676 int nOrient
677 , int nPos
678 , bool bRefresh
679 )
680 {
681 ::WinSendMsg(GetHwnd(), SBM_SETPOS, (MPARAM)nPos, (MPARAM)NULL);
682 } // end of wxWindow::SetScrollPos(
683
684 void wxWindow::SetScrollbar(
685 int nOrient
686 , int nPos
687 , int nThumbVisible
688 , int nRange
689 , bool bRefresh
690 )
691 {
692 int nOldRange = nRange - nThumbVisible;
693 int nRange1 = nOldRange;
694 int nPageSize = nThumbVisible;
695 SBCDATA vInfo;
696 HWND hWnd = GetHwnd();
697 ULONG ulStyle = WS_VISIBLE;
698 RECTL vRect;
699
700 ::WinQueryWindowRect(hWnd, &vRect);
701 if (nPageSize > 1 && nRange > 0)
702 {
703 nRange1 += (nPageSize - 1);
704 }
705
706 vInfo.cb = sizeof(SBCDATA);
707 vInfo.posFirst = 0;
708 vInfo.posLast = (SHORT)nRange1;
709 vInfo.posThumb = nPos;
710
711 if (nOrient == wxHORIZONTAL )
712 {
713 ulStyle |= SBS_HORZ;
714 if (m_hWndScrollBarHorz == 0L)
715 {
716 m_hWndScrollBarHorz = ::WinCreateWindow( hWnd
717 ,WC_SCROLLBAR
718 ,(PSZ)NULL
719 ,ulStyle
720 ,vRect.xLeft
721 ,vRect.yBottom
722 ,vRect.xRight - vRect.xLeft
723 ,20
724 ,hWnd
725 ,HWND_TOP
726 ,-1
727 ,&vInfo
728 ,NULL
729 );
730 }
731 else
732 {
733 RECTL vRect2;
734
735 //
736 // Only want to resize the scrollbar if it changes, otherwise
737 // we'd probably end up in a recursive loop until we crash the call stack
738 // because this method is called in a ScrolledWindow OnSize event and SWP_MOVE | SWP_SIZE
739 // generates those events.
740 //
741 ::WinQueryWindowRect(m_hWndScrollBarHorz, &vRect2);
742 if (!(vRect2.xLeft == vRect.xLeft &&
743 vRect2.xRight == vRect.xRight &&
744 vRect2.yBottom == vRect.yBottom &&
745 vRect2.yTop == vRect.yTop
746 ) )
747 {
748 ::WinSetWindowPos( m_hWndScrollBarHorz
749 ,HWND_TOP
750 ,vRect.xLeft
751 ,vRect.yBottom
752 ,vRect.xRight - vRect.xLeft
753 ,20
754 ,SWP_ACTIVATE | SWP_MOVE | SWP_SIZE | SWP_SHOW
755 );
756 }
757 ::WinSendMsg(m_hWndScrollBarHorz, SBM_SETSCROLLBAR, (MPARAM)nPos, MPFROM2SHORT(0, (SHORT)nRange1));
758 ::WinSendMsg(m_hWndScrollBarHorz, SBM_SETTHUMBSIZE, MPFROM2SHORT((SHORT)nThumbVisible, (SHORT)nRange1), (MPARAM)0);
759 }
760 }
761 else
762 {
763 ulStyle |= SBS_VERT;
764 if (m_hWndScrollBarVert == 0L)
765 {
766 m_hWndScrollBarVert = ::WinCreateWindow( hWnd
767 ,WC_SCROLLBAR
768 ,(PSZ)NULL
769 ,ulStyle
770 ,vRect.xRight - 20
771 ,vRect.yBottom
772 ,20
773 ,vRect.yTop - vRect.yBottom
774 ,hWnd
775 ,HWND_TOP
776 ,-1
777 ,&vInfo
778 ,NULL
779 );
780 }
781 else
782 {
783 RECTL vRect2;
784
785 //
786 // Only want to resize the scrollbar if it changes, otherwise
787 // we'd probably end up in a recursive loop until we crash the call stack
788 // because this method is called in a ScrolledWindow OnSize event and SWP_MOVE | SWP_SIZE
789 // generates those events.
790 //
791 ::WinQueryWindowRect(m_hWndScrollBarVert, &vRect2);
792 if (!(vRect2.xLeft == vRect.xLeft &&
793 vRect2.xRight == vRect.xRight &&
794 vRect2.yBottom == vRect.yBottom &&
795 vRect2.yTop == vRect.yTop
796 ) )
797 {
798 ::WinSetWindowPos( m_hWndScrollBarVert
799 ,HWND_TOP
800 ,vRect.xRight - 20
801 ,vRect.yBottom
802 ,20
803 ,vRect.yTop - vRect.yBottom
804 ,SWP_ACTIVATE | SWP_MOVE | SWP_SIZE | SWP_SHOW
805 );
806 }
807 ::WinSendMsg(m_hWndScrollBarVert, SBM_SETSCROLLBAR, (MPARAM)nPos, MPFROM2SHORT(0, (SHORT)nRange1));
808 ::WinSendMsg(m_hWndScrollBarVert, SBM_SETTHUMBSIZE, MPFROM2SHORT((SHORT)nThumbVisible, (SHORT)nRange1), (MPARAM)0);
809 }
810 m_nYThumbSize = nThumbVisible;
811 }
812 } // end of wxWindow::SetScrollbar
813
814 void wxWindow::ScrollWindow(
815 int nDx
816 , int nDy
817 , const wxRect* pRect
818 )
819 {
820 RECTL vRect2;
821
822 if (pRect)
823 {
824 vRect2.xLeft = pRect->x;
825 vRect2.yTop = pRect->y;
826 vRect2.xRight = pRect->x + pRect->width;
827 vRect2.yBottom = pRect->y + pRect->height;
828 }
829
830 if (pRect)
831 ::WinScrollWindow(GetHwnd(), (LONG)nDx, (LONG)nDy, &vRect2, NULL, NULLHANDLE, NULL, 0L);
832 else
833 ::WinScrollWindow(GetHwnd(), nDx, nDy, NULL, NULL, NULLHANDLE, NULL, 0L);
834 } // end of wxWindow::ScrollWindow
835
836 // ---------------------------------------------------------------------------
837 // subclassing
838 // ---------------------------------------------------------------------------
839
840 void wxWindow::SubclassWin(
841 WXHWND hWnd
842 )
843 {
844 HWND hwnd = (HWND)hWnd;
845
846 wxASSERT_MSG( !m_fnOldWndProc, wxT("subclassing window twice?") );
847 wxCHECK_RET(::WinIsWindow(vHabmain, hwnd), wxT("invalid HWND in SubclassWin") );
848 m_fnOldWndProc = (WXFARPROC) ::WinSubclassWindow(hwnd, (PFNWP)wxWndProc);
849 } // end of wxWindow::SubclassWin
850
851 void wxWindow::UnsubclassWin()
852 {
853 //
854 // Restore old Window proc
855 //
856 HWND hwnd = GetHWND();
857
858 if (m_hWnd)
859 {
860 wxCHECK_RET( ::WinIsWindow(vHabmain, hwnd), wxT("invalid HWND in UnsubclassWin") );
861
862 PFNWP fnProc = (PFNWP)::WinQueryWindowPtr(hwnd, QWP_PFNWP);
863
864 if ( (m_fnOldWndProc != 0) && (fnProc != (PFNWP) m_fnOldWndProc))
865 {
866 WinSubclassWindow(hwnd, (PFNWP)m_fnOldWndProc);
867 m_fnOldWndProc = 0;
868 }
869 }
870 } // end of wxWindow::UnsubclassWin
871
872 //
873 // Make a Windows extended style from the given wxWindows window style
874 //
875 WXDWORD wxWindow::MakeExtendedStyle(
876 long lStyle
877 , bool bEliminateBorders
878 )
879 {
880 //
881 // PM does not support extended style
882 //
883 WXDWORD exStyle = 0;
884 return exStyle;
885 } // end of wxWindow::MakeExtendedStyle
886
887 //
888 // Determines whether native 3D effects or CTL3D should be used,
889 // applying a default border style if required, and returning an extended
890 // style to pass to CreateWindowEx.
891 //
892 WXDWORD wxWindow::Determine3DEffects(
893 WXDWORD dwDefaultBorderStyle
894 , bool* pbWant3D
895 ) const
896 {
897 WXDWORD dwStyle = 0L;
898
899 //
900 // Native PM does not have any specialize 3D effects like WIN32 does
901 //
902 *pbWant3D = FALSE;
903 return dwStyle;
904 } // end of wxWindow::Determine3DEffects
905
906 #if WXWIN_COMPATIBILITY
907 void wxWindow::OnCommand(
908 wxWindow& rWin
909 , wxCommandEvent& rEvent
910 )
911 {
912 if (GetEventHandler()->ProcessEvent(rEvent))
913 return;
914 if (m_parent)
915 m_parent->GetEventHandler()->OnCommand( rWin
916 ,rEvent
917 );
918 } // end of wxWindow::OnCommand
919
920 wxObject* wxWindow::GetChild(
921 int nNumber
922 ) const
923 {
924 //
925 // Return a pointer to the Nth object in the Panel
926 //
927 wxNode* pNode = GetChildren().First();
928 int n = nNumber;
929
930 while (pNode && n--)
931 pNode = pNode->Next();
932 if (pNode)
933 {
934 wxObject* pObj = (wxObject*)pNode->Data();
935 return(pObj);
936 }
937 else
938 return NULL;
939 } // end of wxWindow::GetChild
940
941 #endif // WXWIN_COMPATIBILITY
942
943 //
944 // Setup background and foreground colours correctly
945 //
946 void wxWindow::SetupColours()
947 {
948 if ( GetParent() )
949 SetBackgroundColour(GetParent()->GetBackgroundColour());
950 } // end of wxWindow::SetupColours
951
952 void wxWindow::OnIdle(
953 wxIdleEvent& rEvent
954 )
955 {
956 //
957 // Check if we need to send a LEAVE event
958 //
959 if (m_bMouseInWindow)
960 {
961 POINTL vPoint;
962
963 ::WinQueryPointerPos(HWND_DESKTOP, &vPoint);
964 if (::WinWindowFromPoint(HWND_DESKTOP, &vPoint, FALSE) != (HWND)GetHwnd())
965 {
966 //
967 // Generate a LEAVE event
968 //
969 m_bMouseInWindow = FALSE;
970
971 //
972 // Unfortunately the mouse button and keyboard state may have changed
973 // by the time the OnIdle function is called, so 'state' may be
974 // meaningless.
975 //
976 int nState = 0;
977
978 if (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) != 0)
979 nState |= VK_SHIFT;
980 if (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) != 0);
981 nState |= VK_CTRL;
982
983 wxMouseEvent rEvent(wxEVT_LEAVE_WINDOW);
984
985 InitMouseEvent( rEvent
986 ,vPoint.x
987 ,vPoint.y
988 ,nState
989 );
990 (void)GetEventHandler()->ProcessEvent(rEvent);
991 }
992 }
993 UpdateWindowUI();
994 } // end of wxWindow::OnIdle
995
996 //
997 // Set this window to be the child of 'parent'.
998 //
999 bool wxWindow::Reparent(
1000 wxWindow* pParent
1001 )
1002 {
1003 if (!wxWindowBase::Reparent(pParent))
1004 return FALSE;
1005
1006 HWND hWndChild = GetHwnd();
1007 HWND hWndParent = GetParent() ? GetWinHwnd(GetParent()) : (HWND)0;
1008
1009 ::WinSetParent(hWndChild, hWndParent, TRUE);
1010 return TRUE;
1011 } // end of wxWindow::Reparent
1012
1013 void wxWindow::Clear()
1014 {
1015 wxClientDC vDc(this);
1016 wxBrush vBrush( GetBackgroundColour()
1017 ,wxSOLID
1018 );
1019
1020 vDc.SetBackground(vBrush);
1021 vDc.Clear();
1022 } // end of wxWindow::Clear
1023
1024 void wxWindow::Refresh(
1025 bool bEraseBack
1026 , const wxRect* pRect
1027 )
1028 {
1029 HWND hWnd = GetHwnd();
1030
1031 if (hWnd)
1032 {
1033 if (pRect)
1034 {
1035 RECTL vOs2Rect;
1036
1037 vOs2Rect.xLeft = pRect->x;
1038 vOs2Rect.yTop = pRect->y;
1039 vOs2Rect.xRight = pRect->x + pRect->width;
1040 vOs2Rect.yBottom = pRect->y + pRect->height;
1041
1042 ::WinInvalidateRect(hWnd, &vOs2Rect, bEraseBack);
1043 }
1044 else
1045 ::WinInvalidateRect(hWnd, NULL, bEraseBack);
1046 }
1047 } // end of wxWindow::Refresh
1048
1049 // ---------------------------------------------------------------------------
1050 // drag and drop
1051 // ---------------------------------------------------------------------------
1052
1053 #if wxUSE_DRAG_AND_DROP
1054 void wxWindow::SetDropTarget(
1055 wxDropTarget* pDropTarget
1056 )
1057 {
1058 if (m_dropTarget != 0)
1059 {
1060 m_dropTarget->Revoke(m_hWnd);
1061 delete m_dropTarget;
1062 }
1063 m_dropTarget = pDropTarget;
1064 if (m_dropTarget != 0)
1065 m_dropTarget->Register(m_hWnd);
1066 } // end of wxWindow::SetDropTarget
1067 #endif
1068
1069 //
1070 // old style file-manager drag&drop support: we retain the old-style
1071 // DragAcceptFiles in parallel with SetDropTarget.
1072 //
1073 void wxWindow::DragAcceptFiles(
1074 bool bAccept
1075 )
1076 {
1077 HWND hWnd = GetHwnd();
1078
1079 if (hWnd && bAccept)
1080 ::DrgAcceptDroppedFiles(hWnd, NULL, NULL, DO_COPY, 0L);
1081 } // end of wxWindow::DragAcceptFiles
1082
1083 // ----------------------------------------------------------------------------
1084 // tooltips
1085 // ----------------------------------------------------------------------------
1086
1087 #if wxUSE_TOOLTIPS
1088
1089 void wxWindow::DoSetToolTip(
1090 wxToolTip* pTooltip
1091 )
1092 {
1093 wxWindowBase::DoSetToolTip(pTooltip);
1094
1095 if (m_tooltip)
1096 m_tooltip->SetWindow(this);
1097 } // end of wxWindow::DoSetToolTip
1098
1099 #endif // wxUSE_TOOLTIPS
1100
1101 // ---------------------------------------------------------------------------
1102 // moving and resizing
1103 // ---------------------------------------------------------------------------
1104
1105 // Get total size
1106 void wxWindow::DoGetSize(
1107 int* pWidth
1108 , int* pHeight
1109 ) const
1110 {
1111 HWND hWnd = GetHwnd();
1112 RECTL vRect;
1113
1114 ::WinQueryWindowRect(hWnd, &vRect);
1115
1116 if (pWidth)
1117 *pWidth = vRect.xRight - vRect.xLeft;
1118 if (pHeight )
1119 // OS/2 PM is backwards from windows
1120 *pHeight = vRect.yTop - vRect.yBottom;
1121 } // end of wxWindow::DoGetSize
1122
1123 void wxWindow::DoGetPosition(
1124 int* pX
1125 , int* pY
1126 ) const
1127 {
1128 HWND hWnd = GetHwnd();
1129 RECT vRect;
1130 POINTL vPoint;
1131
1132 ::WinQueryWindowRect(hWnd, &vRect);
1133
1134 vPoint.x = vRect.xLeft;
1135 vPoint.y = vRect.yBottom;
1136
1137 //
1138 // We do the adjustments with respect to the parent only for the "real"
1139 // children, not for the dialogs/frames
1140 //
1141 if (!IsTopLevel())
1142 {
1143 HWND hParentWnd = 0;
1144 wxWindow* pParent = GetParent();
1145
1146 if (pParent)
1147 hParentWnd = GetWinHwnd(pParent);
1148
1149 //
1150 // Since we now have the absolute screen coords, if there's a parent we
1151 // must subtract its bottom left corner
1152 //
1153 if (hParentWnd)
1154 {
1155 RECTL vRect2;
1156
1157 ::WinQueryWindowRect(hParentWnd, &vRect2);
1158 vPoint.x -= vRect.xLeft;
1159 vPoint.y -= vRect.yBottom;
1160 }
1161
1162 //
1163 // We may be faking the client origin. So a window that's really at (0,
1164 // 30) may appear (to wxWin apps) to be at (0, 0).
1165 //
1166 wxPoint vPt(pParent->GetClientAreaOrigin());
1167
1168 vPoint.x -= vPt.x;
1169 vPoint.y -= vPt.y;
1170 }
1171
1172 if (pX)
1173 *pX = vPoint.x;
1174 if (pY)
1175 *pY = vPoint.y;
1176 } // end of wxWindow::DoGetPosition
1177
1178 void wxWindow::DoScreenToClient(
1179 int* pX
1180 , int* pY
1181 ) const
1182 {
1183 HWND hWnd = GetHwnd();
1184 SWP vSwp;
1185
1186 ::WinQueryWindowPos(hWnd, &vSwp);
1187
1188 if (pX)
1189 *pX -= vSwp.x;
1190 if (pY)
1191 *pY -= vSwp.y;
1192 } // end of wxWindow::DoScreenToClient
1193
1194 void wxWindow::DoClientToScreen(
1195 int* pX
1196 , int* pY
1197 ) const
1198 {
1199 HWND hWnd = GetHwnd();
1200 SWP vSwp;
1201
1202 ::WinQueryWindowPos(hWnd, &vSwp);
1203
1204 if (pX)
1205 *pX += vSwp.x;
1206 if (pY)
1207 *pY += vSwp.y;
1208 } // end of wxWindow::DoClientToScreen
1209
1210 //
1211 // Get size *available for subwindows* i.e. excluding menu bar etc.
1212 // Must be a frame type window
1213 //
1214 void wxWindow::DoGetClientSize(
1215 int* pWidth
1216 , int* pHeight
1217 ) const
1218 {
1219 HWND hWnd = GetHwnd();
1220 HWND hWndClient;
1221 RECTL vRect;
1222
1223 hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
1224 if( hWndClient == NULLHANDLE)
1225 ::WinQueryWindowRect(GetHwnd(), &vRect);
1226 else
1227 ::WinQueryWindowRect(hWndClient, &vRect);
1228
1229 if (pWidth)
1230 *pWidth = vRect.xRight;
1231 if (pHeight)
1232 *pHeight = vRect.yTop;
1233 } // end of wxWindow::DoGetClientSize
1234
1235 void wxWindow::DoMoveWindow(
1236 int nX
1237 , int nY
1238 , int nWidth
1239 , int nHeight
1240 )
1241 {
1242 if ( !::WinSetWindowPos( GetHwnd()
1243 ,HWND_TOP
1244 ,(LONG)nX
1245 ,(LONG)nY
1246 ,(LONG)nWidth
1247 ,(LONG)nHeight
1248 ,SWP_SIZE | SWP_MOVE
1249 ))
1250 {
1251 wxLogLastError("MoveWindow");
1252 }
1253 } // end of wxWindow::DoMoveWindow
1254
1255 //
1256 // Set the size of the window: if the dimensions are positive, just use them,
1257 // but if any of them is equal to -1, it means that we must find the value for
1258 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
1259 // which case -1 is a valid value for x and y)
1260 //
1261 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
1262 // the width/height to best suit our contents, otherwise we reuse the current
1263 // width/height
1264 //
1265 void wxWindow::DoSetSize(
1266 int nX
1267 , int nY
1268 , int nWidth
1269 , int nHeight
1270 , int nSizeFlags
1271 )
1272 {
1273 //
1274 // Get the current size and position...
1275 //
1276 int nCurrentX;
1277 int nCurrentY;
1278 int nCurrentWidth;
1279 int nCurrentHeight;
1280 wxSize vSize(-1, -1);
1281
1282 GetPosition( &nCurrentX
1283 ,&nCurrentY
1284 );
1285 GetSize( &nCurrentWidth
1286 ,&nCurrentHeight
1287 );
1288
1289 //
1290 // ... and don't do anything (avoiding flicker) if it's already ok
1291 //
1292 if ( nX == nCurrentX &&
1293 nY == nCurrentY &&
1294 nWidth == nCurrentWidth &&
1295 nHeight == nCurrentHeight
1296 )
1297 {
1298 return;
1299 }
1300
1301 if (nX == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE))
1302 nX = nCurrentX;
1303 if (nY == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE))
1304 nY = nCurrentY;
1305
1306 AdjustForParentClientOrigin( nX
1307 ,nY
1308 ,nSizeFlags
1309 );
1310
1311 if (nWidth == -1)
1312 {
1313 if (nSizeFlags & wxSIZE_AUTO_WIDTH)
1314 {
1315 vSize = DoGetBestSize();
1316 nWidth = vSize.x;
1317 }
1318 else
1319 {
1320 //
1321 // Just take the current one
1322 //
1323 nWidth = nCurrentWidth;
1324 }
1325 }
1326
1327 if (nHeight == -1)
1328 {
1329 if (nSizeFlags & wxSIZE_AUTO_HEIGHT)
1330 {
1331 if (vSize.x == -1)
1332 {
1333 vSize = DoGetBestSize();
1334 }
1335 nHeight = vSize.y;
1336 }
1337 else
1338 {
1339 // just take the current one
1340 nHeight = nCurrentHeight;
1341 }
1342 }
1343
1344 DoMoveWindow( nX
1345 ,nY
1346 ,nWidth
1347 ,nHeight
1348 );
1349 } // end of wxWindow::DoSetSize
1350
1351 void wxWindow::DoSetClientSize(
1352 int nWidth
1353 , int nHeight
1354 )
1355 {
1356 wxWindow* pParent = GetParent();
1357 HWND hWnd = GetHwnd();
1358 HWND hParentWnd = (HWND)0;
1359 HWND hClientWnd = (HWND)0;
1360 RECTL vRect;
1361 RECT vRect2;
1362 RECT vRect3;
1363
1364 hClientWnd = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
1365 ::WinQueryWindowRect(hClientWnd, &vRect2);
1366
1367 if (pParent)
1368 hParentWnd = (HWND) pParent->GetHWND();
1369
1370 ::WinQueryWindowRect(hWnd, &vRect);
1371 ::WinQueryWindowRect(hParentWnd, &vRect3);
1372 //
1373 // Find the difference between the entire window (title bar and all)
1374 // and the client area; add this to the new client size to move the
1375 // window. OS/2 is backward from windows on height
1376 //
1377 int nActualWidth = vRect2.xRight - vRect2.xLeft - vRect.xRight + nWidth;
1378 int nActualHeight = vRect2.yTop - vRect2.yBottom - vRect.yTop + nHeight;
1379
1380 //
1381 // If there's a parent, must subtract the parent's bottom left corner
1382 // since MoveWindow moves relative to the parent
1383 //
1384 POINTL vPoint;
1385
1386 vPoint.x = vRect2.xLeft;
1387 vPoint.y = vRect2.yBottom;
1388 if (pParent)
1389 {
1390 vPoint.x -= vRect3.xLeft;
1391 vPoint.y -= vRect3.yBottom;
1392 }
1393
1394 DoMoveWindow( vPoint.x
1395 ,vPoint.y
1396 ,nActualWidth
1397 ,nActualHeight
1398 );
1399
1400 wxSizeEvent vEvent( wxSize( nWidth
1401 ,nHeight
1402 )
1403 ,m_windowId
1404 );
1405
1406 vEvent.SetEventObject(this);
1407 GetEventHandler()->ProcessEvent(vEvent);
1408 } // end of wxWindow::DoSetClientSize
1409
1410 wxPoint wxWindow::GetClientAreaOrigin() const
1411 {
1412 return wxPoint(0, 0);
1413 } // end of wxWindow::GetClientAreaOrigin
1414
1415 void wxWindow::AdjustForParentClientOrigin(
1416 int& rX
1417 , int& rY
1418 , int nSizeFlags
1419 )
1420 {
1421 //
1422 // Don't do it for the dialogs/frames - they float independently of their
1423 // parent
1424 //
1425 if (!IsTopLevel())
1426 {
1427 wxWindow* pParent = GetParent();
1428
1429 if (!(nSizeFlags & wxSIZE_NO_ADJUSTMENTS) && pParent)
1430 {
1431 wxPoint vPoint(pParent->GetClientAreaOrigin());
1432 rX += vPoint.x;
1433 rY += vPoint.y;
1434 }
1435 }
1436 } // end of wxWindow::AdjustForParentClientOrigin
1437
1438 // ---------------------------------------------------------------------------
1439 // text metrics
1440 // ---------------------------------------------------------------------------
1441
1442 int wxWindow::GetCharHeight() const
1443 {
1444 HPS hPs;
1445 FONTMETRICS vFontMetrics;
1446 BOOL bRc;
1447
1448 hPs = ::WinGetPS(GetHwnd());
1449
1450 if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics))
1451 {
1452 ::WinReleasePS(hPs);
1453 return (0);
1454 }
1455 ::WinReleasePS(hPs);
1456 return(vFontMetrics.lMaxAscender + vFontMetrics.lMaxDescender);
1457 } // end of wxWindow::GetCharHeight
1458
1459 int wxWindow::GetCharWidth() const
1460 {
1461 HPS hPs;
1462 FONTMETRICS vFontMetrics;
1463
1464 hPs = ::WinGetPS(GetHwnd());
1465
1466 if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics))
1467 {
1468 ::WinReleasePS(hPs);
1469 return (0);
1470 }
1471 ::WinReleasePS(hPs);
1472 return(vFontMetrics.lAveCharWidth);
1473 } // end of wxWindow::GetCharWidth
1474
1475 void wxWindow::GetTextExtent(
1476 const wxString& rString
1477 , int* pX
1478 , int* pY
1479 , int* pDescent
1480 , int* pExternalLeading
1481 , const wxFont* pTheFont
1482 ) const
1483 {
1484 const wxFont* pFontToUse = pTheFont;
1485 HPS hPs;
1486
1487 hPs = ::WinGetPS(GetHwnd());
1488 /*
1489 // TODO: Will have to play with fonts later
1490
1491 if (!pFontToUse)
1492 pFontToUse = &m_font;
1493
1494 HFONT hFnt = 0;
1495 HFONT hFfontOld = 0;
1496
1497 if (pFontToUse && pFontToUse->Ok())
1498 {
1499 ::GpiCreateLog
1500 hFnt = (HFONT)((wxFont *)pFontToUse)->GetResourceHandle(); // const_cast
1501 if (hFnt)
1502 hFontOld = (HFONT)SelectObject(dc,fnt);
1503 }
1504
1505 SIZE sizeRect;
1506 TEXTMETRIC tm;
1507 GetTextExtentPoint(dc, string, (int)string.Length(), &sizeRect);
1508 GetTextMetrics(dc, &tm);
1509
1510 if ( fontToUse && fnt && hfontOld )
1511 SelectObject(dc, hfontOld);
1512
1513 ReleaseDC(hWnd, dc);
1514
1515 if ( x )
1516 *x = sizeRect.cx;
1517 if ( y )
1518 *y = sizeRect.cy;
1519 if ( descent )
1520 *descent = tm.tmDescent;
1521 if ( externalLeading )
1522 *externalLeading = tm.tmExternalLeading;
1523 */
1524 ::WinReleasePS(hPs);
1525 }
1526
1527 #if wxUSE_CARET && WXWIN_COMPATIBILITY
1528 // ---------------------------------------------------------------------------
1529 // Caret manipulation
1530 // ---------------------------------------------------------------------------
1531
1532 void wxWindow::CreateCaret(
1533 int nWidth
1534 , int nHeight
1535 )
1536 {
1537 SetCaret(new wxCaret( this
1538 ,nWidth
1539 ,nHeight
1540 ));
1541 } // end of wxWindow::CreateCaret
1542
1543 void wxWindow::CreateCaret(
1544 const wxBitmap* pBitmap
1545 )
1546 {
1547 wxFAIL_MSG("not implemented");
1548 } // end of wxWindow::CreateCaret
1549
1550 void wxWindow::ShowCaret(
1551 bool bShow
1552 )
1553 {
1554 wxCHECK_RET( m_caret, "no caret to show" );
1555
1556 m_caret->Show(bShow);
1557 } // end of wxWindow::ShowCaret
1558
1559 void wxWindow::DestroyCaret()
1560 {
1561 SetCaret(NULL);
1562 } // end of wxWindow::DestroyCaret
1563
1564 void wxWindow::SetCaretPos(
1565 int nX
1566 , int nY)
1567 {
1568 wxCHECK_RET( m_caret, "no caret to move" );
1569
1570 m_caret->Move( nX
1571 ,nY
1572 );
1573 } // end of wxWindow::SetCaretPos
1574
1575 void wxWindow::GetCaretPos(
1576 int* pX
1577 , int* pY
1578 ) const
1579 {
1580 wxCHECK_RET( m_caret, "no caret to get position of" );
1581
1582 m_caret->GetPosition( pX
1583 ,pY
1584 );
1585 } // end of wxWindow::GetCaretPos
1586
1587 #endif //wxUSE_CARET
1588
1589 // ---------------------------------------------------------------------------
1590 // popup menu
1591 // ---------------------------------------------------------------------------
1592
1593 bool wxWindow::DoPopupMenu(
1594 wxMenu* pMenu
1595 , int nX
1596 , int nY
1597 )
1598 {
1599 HWND hWnd = GetHwnd();
1600 HWND hWndParent = GetParent() ? GetWinHwnd(GetParent()) : (HWND)0;
1601 HWND hMenu = GetHmenuOf(pMenu);
1602
1603 pMenu->SetInvokingWindow(this);
1604 pMenu->UpdateUI();
1605
1606 DoClientToScreen( &nX
1607 ,&nY
1608 );
1609 wxCurrentPopupMenu = pMenu;
1610
1611 ::WinPopupMenu( hWndParent
1612 ,hWnd
1613 ,hMenu
1614 ,nX
1615 ,nY
1616 ,0L
1617 ,PU_MOUSEBUTTON2DOWN | PU_MOUSEBUTTON2 | PU_KEYBOARD
1618 );
1619 wxYield();
1620 wxCurrentPopupMenu = NULL;
1621
1622 pMenu->SetInvokingWindow(NULL);
1623 return TRUE;
1624 } // end of wxWindow::DoPopupMenu
1625
1626 // ===========================================================================
1627 // pre/post message processing
1628 // ===========================================================================
1629
1630 MRESULT wxWindow::OS2DefWindowProc(
1631 WXUINT uMsg
1632 , WXWPARAM wParam
1633 , WXLPARAM lParam
1634 )
1635 {
1636 if (m_fnOldWndProc)
1637 return (MRESULT)m_fnOldWndProc(GetHWND(), (ULONG)uMsg, (MPARAM)wParam, (MPARAM)lParam);
1638 else
1639 return ::WinDefWindowProc(GetHWND(), (ULONG)uMsg, (MPARAM)wParam, (MPARAM)lParam);
1640 } // end of wxWindow::OS2DefWindowProc
1641
1642 bool wxWindow::OS2ProcessMessage(
1643 WXMSG* pMsg
1644 )
1645 {
1646 QMSG* pQMsg = (QMSG*)pMsg;
1647
1648 if (m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL))
1649 {
1650 //
1651 // Intercept dialog navigation keys
1652 //
1653 bool bProcess = TRUE;
1654 USHORT uKeyFlags = SHORT1FROMMP(pQMsg->mp1);
1655
1656 if (uKeyFlags & KC_KEYUP)
1657 bProcess = FALSE;
1658
1659 if (uKeyFlags & KC_ALT)
1660 bProcess = FALSE;
1661
1662 if (!(uKeyFlags & KC_VIRTUALKEY))
1663 bProcess = FALSE;
1664
1665 if (bProcess)
1666 {
1667 bool bCtrlDown = IsCtrlDown();
1668 bool bShiftDown = IsShiftDown();
1669
1670 //
1671 // WM_QUERYDLGCODE: ask the control if it wants the key for itself,
1672 // don't process it if it's the case (except for Ctrl-Tab/Enter
1673 // combinations which are always processed)
1674 //
1675 ULONG ulDlgCode = 0;
1676
1677 if (!bCtrlDown)
1678 {
1679 ulDlgCode = (ULONG)::WinSendMsg(pQMsg->hwnd, WM_QUERYDLGCODE, pQMsg, 0);
1680 }
1681
1682 bool bForward = TRUE;
1683 bool bWindowChange = FALSE;
1684
1685 switch (SHORT2FROMMP(pQMsg->mp2))
1686 {
1687 //
1688 // Going to make certain assumptions about specific types of controls
1689 // here, so we may have to alter some things later if they prove invalid
1690 //
1691 case VK_TAB:
1692 //
1693 // Shift tabl will always be a nav-key but tabs may be wanted
1694 //
1695 if (!bShiftDown)
1696 {
1697 bProcess = FALSE;
1698 }
1699 else
1700 {
1701 //
1702 // Entry Fields want tabs for themselve usually
1703 //
1704 switch (ulDlgCode)
1705 {
1706 case DLGC_ENTRYFIELD:
1707 case DLGC_MLE:
1708 bProcess = TRUE;
1709 break;
1710
1711 default:
1712 bProcess = FALSE;
1713 }
1714
1715 //
1716 // Ctrl-Tab cycles thru notebook pages
1717 //
1718 bWindowChange = bCtrlDown;
1719 bForward = !bShiftDown;
1720 }
1721 break;
1722
1723 case VK_UP:
1724 case VK_LEFT:
1725 if (bCtrlDown)
1726 bProcess = FALSE;
1727 else
1728 bForward = FALSE;
1729 break;
1730
1731 case VK_DOWN:
1732 case VK_RIGHT:
1733 if (bCtrlDown)
1734 bProcess = FALSE;
1735 break;
1736
1737 case VK_ENTER:
1738 {
1739 if (bCtrlDown)
1740 {
1741 //
1742 // ctrl-enter is not processed
1743 //
1744 return FALSE;
1745 }
1746 else if (ulDlgCode & DLGC_BUTTON)
1747 {
1748 //
1749 // buttons want process Enter themselevs
1750 //
1751 bProcess = FALSE;
1752 }
1753 else
1754 {
1755 wxPanel* pPanel = wxDynamicCast(this, wxPanel);
1756 wxButton* pBtn = NULL;
1757
1758 if (pPanel)
1759 {
1760 //
1761 // Panel may have a default button which should
1762 // be activated by Enter
1763 //
1764 pBtn = pPanel->GetDefaultItem();
1765 }
1766
1767 if (pBtn && pBtn->IsEnabled())
1768 {
1769 //
1770 // If we do have a default button, do press it
1771 //
1772 pBtn->OS2Command(BN_CLICKED, 0 /* unused */);
1773 return TRUE;
1774 }
1775 // else: but if it does not it makes sense to make
1776 // it work like a TAB - and that's what we do.
1777 // Note that Ctrl-Enter always works this way.
1778 }
1779 }
1780 break;
1781
1782 default:
1783 bProcess = FALSE;
1784 }
1785
1786 if (bProcess)
1787 {
1788 wxNavigationKeyEvent vEvent;
1789
1790 vEvent.SetDirection(bForward);
1791 vEvent.SetWindowChange(bWindowChange);
1792 vEvent.SetEventObject(this);
1793
1794 if (GetEventHandler()->ProcessEvent(vEvent))
1795 {
1796 wxButton* pBtn = wxDynamicCast(FindFocus(), wxButton);
1797
1798 if (pBtn)
1799 {
1800 //
1801 // The button which has focus should be default
1802 //
1803 pBtn->SetDefault();
1804 }
1805 return TRUE;
1806 }
1807 }
1808 }
1809 //
1810 // Let Dialogs process
1811 //
1812 if (::WinSendMsg(pQMsg->hwnd, WM_QUERYDLGCODE, pQMsg, 0));
1813 return TRUE;
1814 }
1815
1816 #if wxUSE_TOOLTIPS
1817 if ( m_tooltip )
1818 {
1819 // relay mouse move events to the tooltip control
1820 QMSG* pQMsg = (QMSG*)pMsg;
1821
1822 if (pQMsg->msg == WM_MOUSEMOVE )
1823 m_tooltip->RelayEvent(pMsg);
1824 }
1825 #endif // wxUSE_TOOLTIPS
1826
1827 return FALSE;
1828 } // end of wxWindow::OS2ProcessMessage
1829
1830 bool wxWindow::OS2TranslateMessage(
1831 WXMSG* pMsg
1832 )
1833 {
1834 #if wxUSE_ACCEL
1835 return m_acceleratorTable.Translate(m_hWnd, pMsg);
1836 #else
1837 return FALSE;
1838 #endif //wxUSE_ACCEL
1839 } // end of wxWindow::OS2TranslateMessage
1840
1841 // ---------------------------------------------------------------------------
1842 // message params unpackers
1843 // ---------------------------------------------------------------------------
1844
1845 void wxWindow::UnpackCommand(
1846 WXWPARAM wParam
1847 , WXLPARAM lParam
1848 , WORD* pId
1849 , WXHWND* phWnd
1850 , WORD* pCmd
1851 )
1852 {
1853 *pId = LOWORD(wParam);
1854 *phWnd = NULL; // or may be GetHWND() ?
1855 *pCmd = LOWORD(lParam);
1856 } // end of wxWindow::UnpackCommand
1857
1858 void wxWindow::UnpackActivate(
1859 WXWPARAM wParam
1860 , WXLPARAM lParam
1861 , WXWORD* pState
1862 , WXHWND* phWnd
1863 )
1864 {
1865 *pState = LOWORD(wParam);
1866 *phWnd = (WXHWND)lParam;
1867 } // end of wxWindow::UnpackActivate
1868
1869 void wxWindow::UnpackScroll(
1870 WXWPARAM wParam
1871 , WXLPARAM lParam
1872 , WXWORD* pCode
1873 , WXWORD* pPos
1874 , WXHWND* phWnd
1875 )
1876 {
1877 *pCode = LOWORD(wParam);
1878 *pPos = HIWORD(wParam);
1879 *phWnd = (WXHWND)lParam;
1880 } // end of wxWindow::UnpackScroll
1881
1882 void wxWindow::UnpackMenuSelect(
1883 WXWPARAM wParam
1884 , WXLPARAM lParam
1885 , WXWORD* pItem
1886 , WXWORD* pFlags
1887 , WXHMENU* phMenu
1888 )
1889 {
1890 *pItem = (WXWORD)LOWORD(wParam);
1891 *pFlags = HIWORD(wParam);
1892 *phMenu = (WXHMENU)lParam;
1893 } // end of wxWindow::UnpackMenuSelect
1894
1895 // ---------------------------------------------------------------------------
1896 // Main wxWindows window proc and the window proc for wxWindow
1897 // ---------------------------------------------------------------------------
1898
1899 //
1900 // Hook for new window just as it's being created, when the window isn't yet
1901 // associated with the handle
1902 //
1903 wxWindow* wxWndHook = NULL;
1904
1905 //
1906 // Main window proc
1907 //
1908 MRESULT EXPENTRY wxWndProc(
1909 HWND hWnd
1910 , ULONG ulMsg
1911 , MPARAM wParam
1912 , MPARAM lParam
1913 )
1914 {
1915 //
1916 // Trace all ulMsgs - useful for the debugging
1917 //
1918 #ifdef __WXDEBUG__
1919 wxLogTrace(wxTraceMessages, wxT("Processing %s(wParam=%8lx, lParam=%8lx)"),
1920 wxGetMessageName(ulMsg), wParam, lParam);
1921 #endif // __WXDEBUG__
1922
1923 wxWindow* pWnd = wxFindWinFromHandle((WXHWND)hWnd);
1924
1925 //
1926 // When we get the first message for the HWND we just created, we associate
1927 // it with wxWindow stored in wxWndHook
1928 //
1929 if (!pWnd && wxWndHook)
1930 {
1931 wxAssociateWinWithHandle(hWnd, wxWndHook);
1932 pWnd = wxWndHook;
1933 wxWndHook = NULL;
1934 pWnd->SetHWND((WXHWND)hWnd);
1935 }
1936
1937 MRESULT rc = (MRESULT)0;
1938
1939
1940 //
1941 // Stop right here if we don't have a valid handle in our wxWindow object.
1942 //
1943 if (pWnd && !pWnd->GetHWND())
1944 {
1945 pWnd->SetHWND((WXHWND) hWnd);
1946 rc = pWnd->OS2DefWindowProc(ulMsg, wParam, lParam );
1947 pWnd->SetHWND(0);
1948 }
1949 else
1950 {
1951 if (pWnd)
1952 rc = pWnd->OS2WindowProc(ulMsg, wParam, lParam);
1953 else
1954 rc = ::WinDefWindowProc(hWnd, ulMsg, wParam, lParam);
1955 }
1956
1957 return rc;
1958 } // end of wxWndProc
1959
1960 //
1961 // We will add (or delete) messages we need to handle at this default
1962 // level as we go
1963 //
1964 MRESULT wxWindow::OS2WindowProc(
1965 WXUINT uMsg
1966 , WXWPARAM wParam
1967 , WXLPARAM lParam
1968 )
1969 {
1970 //
1971 // Did we process the uMsg?
1972 //
1973 bool bProcessed = FALSE;
1974 bool bAllow;
1975 MRESULT mResult;
1976 WXHICON hIcon;
1977 WXHBRUSH hBrush;
1978
1979 //
1980 // For most messages we should return 0 when we do process the message
1981 //
1982 mResult = (MRESULT)0;
1983
1984 switch (uMsg)
1985 {
1986 case WM_CREATE:
1987 {
1988 bool bMayCreate;
1989
1990 bProcessed = HandleCreate( (WXLPCREATESTRUCT)lParam
1991 ,&bMayCreate
1992 );
1993 if (bProcessed)
1994 {
1995 //
1996 // Return 0 to bAllow window creation
1997 //
1998 mResult = (MRESULT)(bMayCreate ? 0 : -1);
1999 }
2000 }
2001 break;
2002
2003 case WM_DESTROY:
2004 HandleDestroy();
2005 bProcessed = TRUE;
2006 break;
2007
2008 case WM_MOVE:
2009 bProcessed = HandleMove( LOWORD(lParam)
2010 ,HIWORD(lParam)
2011 );
2012 break;
2013
2014 case WM_SIZE:
2015 bProcessed = HandleSize( LOWORD(lParam)
2016 ,HIWORD(lParam)
2017 ,(WXUINT)wParam
2018 );
2019 break;
2020
2021 case WM_ACTIVATE:
2022 {
2023 WXWORD wState;
2024 WXHWND hWnd;
2025
2026 UnpackActivate( wParam
2027 ,lParam
2028 ,&wState
2029 ,&hWnd
2030 );
2031
2032 bProcessed = HandleActivate( wState
2033 ,(WXHWND)hWnd
2034 );
2035 bProcessed = FALSE;
2036 }
2037 break;
2038
2039 case WM_SETFOCUS:
2040 if (SHORT1FROMMP((MPARAM)lParam) == TRUE)
2041 bProcessed = HandleSetFocus((WXHWND)(HWND)wParam);
2042 else
2043 bProcessed = HandleKillFocus((WXHWND)(HWND)wParam);
2044 break;
2045
2046 case WM_PAINT:
2047 bProcessed = HandlePaint();
2048 break;
2049
2050 case WM_CLOSE:
2051 //
2052 // Don't let the DefWindowProc() destroy our window - we'll do it
2053 // ourselves in ~wxWindow
2054 //
2055 bProcessed = TRUE;
2056 mResult = (MRESULT)TRUE;
2057 break;
2058
2059 case WM_SHOW:
2060 bProcessed = HandleShow(wParam != 0, (int)lParam);
2061 break;
2062
2063 //
2064 // Under OS2 PM Joysticks are treated just like mouse events
2065 // The "Motion" events will be prevelent in joysticks
2066 //
2067 case WM_MOUSEMOVE:
2068 case WM_BUTTON1DOWN:
2069 case WM_BUTTON1UP:
2070 case WM_BUTTON1DBLCLK:
2071 case WM_BUTTON1MOTIONEND:
2072 case WM_BUTTON1MOTIONSTART:
2073 case WM_BUTTON2DOWN:
2074 case WM_BUTTON2UP:
2075 case WM_BUTTON2DBLCLK:
2076 case WM_BUTTON2MOTIONEND:
2077 case WM_BUTTON2MOTIONSTART:
2078 case WM_BUTTON3DOWN:
2079 case WM_BUTTON3UP:
2080 case WM_BUTTON3DBLCLK:
2081 case WM_BUTTON3MOTIONEND:
2082 case WM_BUTTON3MOTIONSTART:
2083 {
2084 short x = LOWORD(lParam);
2085 short y = HIWORD(lParam);
2086
2087 bProcessed = HandleMouseEvent(uMsg, x, y, (WXUINT)wParam);
2088 }
2089 break;
2090 case WM_SYSCOMMAND:
2091 bProcessed = HandleSysCommand(wParam, lParam);
2092 break;
2093
2094 case WM_COMMAND:
2095 {
2096 WORD id, cmd;
2097 WXHWND hwnd;
2098 UnpackCommand(wParam, lParam, &id, &hwnd, &cmd);
2099
2100 bProcessed = HandleCommand(id, cmd, hwnd);
2101 }
2102 break;
2103
2104 //
2105 // For these messages we must return TRUE if process the message
2106 //
2107 case WM_DRAWITEM:
2108 case WM_MEASUREITEM:
2109 {
2110 int nIdCtrl = (UINT)wParam;
2111
2112 if ( uMsg == WM_DRAWITEM )
2113 {
2114 bProcessed = OS2OnDrawItem(nIdCtrl,
2115 (WXDRAWITEMSTRUCT *)lParam);
2116 }
2117 else
2118 {
2119 bProcessed = OS2OnMeasureItem(nIdCtrl,
2120 (WXMEASUREITEMSTRUCT *)lParam);
2121 }
2122
2123 if ( bProcessed )
2124 mResult = (MRESULT)TRUE;
2125 }
2126 break;
2127
2128 case WM_QUERYDLGCODE:
2129 if ( m_lDlgCode )
2130 {
2131 mResult = (MRESULT)m_lDlgCode;
2132 bProcessed = TRUE;
2133 }
2134 //
2135 //else: get the dlg code from the DefWindowProc()
2136 //
2137 break;
2138
2139 //
2140 // In OS/2 PM all keyboard events are of the WM_CHAR type. Virtual key and key-up
2141 // and key-down events are obtained from the WM_CHAR params.
2142 //
2143 case WM_CHAR:
2144 {
2145 USHORT uKeyFlags = SHORT1FROMMP((MPARAM)wParam);
2146
2147 if (uKeyFlags & KC_KEYUP)
2148 {
2149 bProcessed = HandleKeyUp((WXDWORD)wParam, lParam);
2150 break;
2151 }
2152 else // keydown event
2153 {
2154 //
2155 // If this has been processed by an event handler,
2156 // return 0 now (we've handled it). DON't RETURN
2157 // we still need to process further
2158 //
2159 HandleKeyDown((WXDWORD)wParam, lParam);
2160 if (uKeyFlags & KC_VIRTUALKEY)
2161 {
2162 USHORT uVk = SHORT2FROMMP((MPARAM)lParam);
2163
2164 //
2165 // We consider these message "not interesting" to OnChar
2166 //
2167 if (uVk == VK_SHIFT || uVk == VK_CTRL )
2168 {
2169 bProcessed = TRUE;
2170 break;
2171 }
2172 switch(uVk)
2173 {
2174 //
2175 // Avoid duplicate messages to OnChar for these ASCII keys: they
2176 // will be translated by TranslateMessage() and received in WM_CHAR
2177 case VK_ESC:
2178 case VK_SPACE:
2179 case VK_ENTER:
2180 case VK_BACKSPACE:
2181 case VK_TAB:
2182 // But set processed to FALSE, not TRUE to still pass them to
2183 // the control's default window proc - otherwise built-in
2184 // keyboard handling won't work
2185 bProcessed = FALSE;
2186 break;
2187
2188 case VK_LEFT:
2189 case VK_RIGHT:
2190 case VK_DOWN:
2191 case VK_UP:
2192 default:
2193 bProcessed = HandleChar((WXDWORD)wParam, lParam);
2194 }
2195 break;
2196 }
2197 else // WM_CHAR -- Always an ASCII character
2198 {
2199 bProcessed = HandleChar((WXDWORD)wParam, lParam, TRUE);
2200 break;
2201 }
2202 }
2203 }
2204
2205 case WM_HSCROLL:
2206 case WM_VSCROLL:
2207 {
2208 WXWORD wCode;
2209 WXWORD wPos;
2210 WXHWND hWnd;
2211 UnpackScroll( wParam
2212 ,lParam
2213 ,&wCode
2214 ,&wPos
2215 ,&hWnd
2216 );
2217
2218 bProcessed = OS2OnScroll( uMsg == WM_HSCROLL ? wxHORIZONTAL
2219 : wxVERTICAL
2220 ,wCode
2221 ,wPos
2222 ,hWnd
2223 );
2224 }
2225 break;
2226
2227 #if defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
2228 case WM_CTLCOLORCHANGE:
2229 {
2230 bProcessed = HandleCtlColor(&hBrush);
2231 }
2232 break;
2233 #endif
2234 case WM_ERASEBACKGROUND:
2235 //
2236 // Returning TRUE to requestw PM to paint the window background
2237 // in SYSCLR_WINDOW. We don't really want that
2238 //
2239 bProcessed = HandleEraseBkgnd((WXHDC)(HPS)wParam);
2240 mResult = (MRESULT)(FALSE);
2241 break;
2242
2243 //
2244 // Instead of CTLCOLOR messages PM sends QUERYWINDOWPARAMS to
2245 // things such as colors and fonts and such
2246 //
2247 case WM_QUERYWINDOWPARAMS:
2248 {
2249 PWNDPARAMS pWndParams = (PWNDPARAMS)wParam;
2250
2251 bProcessed = HandleWindowParams( pWndParams
2252 ,lParam
2253 );
2254 }
2255 break;
2256
2257 // the return value for this message is ignored
2258 case WM_SYSCOLORCHANGE:
2259 bProcessed = HandleSysColorChange();
2260 break;
2261
2262 case WM_REALIZEPALETTE:
2263 bProcessed = HandlePaletteChanged();
2264 break;
2265
2266 case WM_PRESPARAMCHANGED:
2267 bProcessed = HandlePresParamChanged(wParam);
2268 break;
2269
2270
2271 // move all drag and drops to wxDrg
2272 case WM_ENDDRAG:
2273 bProcessed = HandleEndDrag(wParam);
2274 break;
2275
2276 case WM_INITDLG:
2277 bProcessed = HandleInitDialog((WXHWND)(HWND)wParam);
2278
2279 if ( bProcessed )
2280 {
2281 // we never set focus from here
2282 mResult = FALSE;
2283 }
2284 break;
2285
2286 // wxFrame specific message
2287 case WM_MINMAXFRAME:
2288 bProcessed = HandleGetMinMaxInfo((PSWP)wParam);
2289 break;
2290
2291 case WM_SYSVALUECHANGED:
2292 // TODO: do something
2293 mResult = (MRESULT)TRUE;
2294 break;
2295
2296 //
2297 // Comparable to WM_SETPOINTER for windows, only for just controls
2298 //
2299 case WM_CONTROLPOINTER:
2300 bProcessed = HandleSetCursor( SHORT1FROMMP(wParam) // Control ID
2301 ,(HWND)lParam // Cursor Handle
2302 );
2303 if (bProcessed )
2304 {
2305 //
2306 // Returning TRUE stops the DefWindowProc() from further
2307 // processing this message - exactly what we need because we've
2308 // just set the cursor.
2309 //
2310 mResult = (MRESULT)TRUE;
2311 }
2312 break;
2313 }
2314 if (!bProcessed)
2315 {
2316 #ifdef __WXDEBUG__
2317 wxLogTrace(wxTraceMessages, wxT("Forwarding %s to DefWindowProc."),
2318 wxGetMessageName(uMsg));
2319 #endif // __WXDEBUG__
2320 if (IsKindOf(CLASSINFO(wxFrame)))
2321 mResult = ::WinDefWindowProc(m_hWnd, uMsg, wParam, lParam);
2322 else
2323 mResult = OS2DefWindowProc(uMsg, wParam, lParam);
2324 }
2325 return mResult;
2326 } // end of wxWindow::OS2WindowProc
2327
2328 //
2329 // Dialog window proc
2330 //
2331 MRESULT wxDlgProc(
2332 HWND hWnd
2333 , UINT uMsg
2334 , MPARAM wParam
2335 , MPARAM lParam)
2336 {
2337 if (uMsg == WM_INITDLG)
2338 {
2339 //
2340 // For this message, returning TRUE tells system to set focus to the
2341 // first control in the dialog box
2342 //
2343 return (MRESULT)TRUE;
2344 }
2345 else
2346 {
2347 //
2348 // For all the other ones, FALSE means that we didn't process the
2349 // message
2350 //
2351 return (MRESULT)0;
2352 }
2353 } // end of wxDlgProc
2354
2355 wxWindow* wxFindWinFromHandle(
2356 WXHWND hWnd
2357 )
2358 {
2359 wxNode* pNode = wxWinHandleList->Find((long)hWnd);
2360
2361 if (!pNode)
2362 return NULL;
2363 return (wxWindow *)pNode->Data();
2364 } // end of wxFindWinFromHandle
2365
2366 void wxAssociateWinWithHandle(
2367 HWND hWnd
2368 , wxWindow* pWin
2369 )
2370 {
2371 //
2372 // Adding NULL hWnd is (first) surely a result of an error and
2373 // (secondly) breaks menu command processing
2374 //
2375 wxCHECK_RET( hWnd != (HWND)NULL,
2376 wxT("attempt to add a NULL hWnd to window list ignored") );
2377
2378
2379 wxWindow* pOldWin = wxFindWinFromHandle((WXHWND) hWnd);
2380
2381 if (pOldWin && (pOldWin != pWin))
2382 {
2383 wxString str(pWin->GetClassInfo()->GetClassName());
2384 wxLogError( "Bug! Found existing HWND %X for new window of class %s"
2385 ,(int)hWnd
2386 ,(const char*)str
2387 );
2388 }
2389 else if (!pOldWin)
2390 {
2391 wxWinHandleList->Append( (long)hWnd
2392 ,pWin
2393 );
2394 }
2395 } // end of wxAssociateWinWithHandle
2396
2397 void wxRemoveHandleAssociation(
2398 wxWindow* pWin
2399 )
2400 {
2401 wxWinHandleList->DeleteObject(pWin);
2402 } // end of wxRemoveHandleAssociation
2403
2404 //
2405 // Default destroyer - override if you destroy it in some other way
2406 // (e.g. with MDI child windows)
2407 //
2408 void wxWindow::OS2DestroyWindow()
2409 {
2410 }
2411
2412 void wxWindow::OS2DetachWindowMenu()
2413 {
2414 if (m_hMenu)
2415 {
2416 HMENU hMenu = (HMENU)m_hMenu;
2417
2418 int nN = (int)::WinSendMsg(hMenu, MM_QUERYITEMCOUNT, 0, 0);
2419 int i;
2420
2421 for (i = 0; i < nN; i++)
2422 {
2423 wxChar zBuf[100];
2424 int nChars = (int)::WinSendMsg( hMenu
2425 ,MM_QUERYITEMTEXT
2426 ,MPFROM2SHORT(i, nN)
2427 ,zBuf
2428 );
2429 if (!nChars)
2430 {
2431 wxLogLastError(wxT("GetMenuString"));
2432 continue;
2433 }
2434
2435 if (wxStrcmp(zBuf, wxT("&Window")) == 0)
2436 {
2437 ::WinSendMsg(hMenu, MM_DELETEITEM, MPFROM2SHORT(i, TRUE), 0);
2438 break;
2439 }
2440 }
2441 }
2442 } // end of wxWindow::OS2DetachWindowMenu
2443
2444 bool wxWindow::OS2Create(
2445 WXHWND hParent
2446 , PSZ zClass
2447 , const wxChar* zTitle
2448 , WXDWORD dwStyle
2449 , long lX
2450 , long lY
2451 , long lWidth
2452 , long lHeight
2453 , WXHWND hOwner
2454 , WXHWND hZOrder
2455 , unsigned long ulId
2456 , void* pCtlData
2457 , void* pPresParams
2458 )
2459 {
2460 ERRORID vError;
2461 wxString sError;
2462 long lX1 = 0L;
2463 long lY1 = 0L;
2464 long lWidth1 = 20L;
2465 long lHeight1 = 20L;
2466 int nControlId = 0;
2467 int nNeedsubclass = 0;
2468 PCSZ pszClass = zClass;
2469
2470 //
2471 // Find parent's size, if it exists, to set up a possible default
2472 // panel size the size of the parent window
2473 //
2474 RECTL vParentRect;
2475 HWND hWndClient;
2476
2477 if (lX > -1L)
2478 lX1 = lX;
2479 if (lY > -1L)
2480 lY1 = lY;
2481 if (lWidth > -1L)
2482 lWidth1 = lWidth;
2483 if (lHeight > -1L)
2484 lHeight1 = lHeight;
2485
2486 wxWndHook = this;
2487
2488 //
2489 // check to see if the new window is a standard control
2490 //
2491 if ((ULONG)zClass == (ULONG)WC_BUTTON ||
2492 (ULONG)zClass == (ULONG)WC_COMBOBOX ||
2493 (ULONG)zClass == (ULONG)WC_CONTAINER ||
2494 (ULONG)zClass == (ULONG)WC_ENTRYFIELD ||
2495 (ULONG)zClass == (ULONG)WC_FRAME ||
2496 (ULONG)zClass == (ULONG)WC_LISTBOX ||
2497 (ULONG)zClass == (ULONG)WC_MENU ||
2498 (ULONG)zClass == (ULONG)WC_NOTEBOOK ||
2499 (ULONG)zClass == (ULONG)WC_SCROLLBAR ||
2500 (ULONG)zClass == (ULONG)WC_SPINBUTTON ||
2501 (ULONG)zClass == (ULONG)WC_STATIC ||
2502 (ULONG)zClass == (ULONG)WC_TITLEBAR ||
2503 (ULONG)zClass == (ULONG)WC_VALUESET
2504 )
2505 {
2506 nControlId = ulId;
2507 }
2508 else
2509 {
2510 // no standard controls
2511 if(wxString (wxT("wxFrameClass")) == wxString(zClass) )
2512 {
2513 pszClass = WC_FRAME;
2514 nNeedsubclass = 1;
2515 }
2516 else
2517 {
2518 nControlId = ulId;
2519 if(nControlId < 0)
2520 nControlId = FID_CLIENT;
2521 }
2522 }
2523
2524 //
2525 // We will either have a registered class via string name or a standard PM Class via a long
2526 //
2527 m_hWnd = (WXHWND)::WinCreateWindow( (HWND)hParent
2528 ,zClass
2529 ,(PSZ)zTitle ? zTitle : wxT("")
2530 ,(ULONG)dwStyle
2531 ,(LONG)lX1
2532 ,(LONG)lY1
2533 ,(LONG)lWidth
2534 ,(LONG)lHeight
2535 ,hOwner
2536 ,HWND_TOP
2537 ,(ULONG)nControlId
2538 ,pCtlData
2539 ,pPresParams
2540 );
2541 if (!m_hWnd)
2542 {
2543 vError = ::WinGetLastError(vHabmain);
2544 sError = wxPMErrorToStr(vError);
2545 wxLogError("Can't create window of class %s!. Error: %s\n", zClass, sError);
2546 return FALSE;
2547 }
2548 ::WinSetWindowULong(m_hWnd, QWL_USER, (ULONG) this);
2549 wxWndHook = NULL;
2550
2551 #ifdef __WXDEBUG__
2552 wxNode* pNode = wxWinHandleList->Member(this);
2553
2554 if (pNode)
2555 {
2556 HWND hWnd = (HWND)pNode->GetKeyInteger();
2557
2558 if (hWnd != (HWND)m_hWnd)
2559
2560 {
2561 wxLogError("A second HWND association is being added for the same window!");
2562 }
2563 }
2564 #endif
2565 wxAssociateWinWithHandle((HWND)m_hWnd
2566 ,this
2567 );
2568 //
2569 // Now need to subclass window.
2570 //
2571 if(!nNeedsubclass)
2572 {
2573 wxAssociateWinWithHandle((HWND)m_hWnd,this);
2574 }
2575 else
2576 {
2577 SubclassWin(GetHWND());
2578 }
2579 return TRUE;
2580 } // end of wxWindow::OS2Create
2581
2582 // ===========================================================================
2583 // OS2 PM message handlers
2584 // ===========================================================================
2585
2586 // ---------------------------------------------------------------------------
2587 // window creation/destruction
2588 // ---------------------------------------------------------------------------
2589
2590 bool wxWindow::HandleCreate(
2591 WXLPCREATESTRUCT vCs
2592 , bool* pbMayCreate
2593 )
2594 {
2595 wxWindowCreateEvent vEvent(this);
2596
2597 (void)GetEventHandler()->ProcessEvent(vEvent);
2598 *pbMayCreate = TRUE;
2599 return TRUE;
2600 } // end of wxWindow::HandleCreate
2601
2602 bool wxWindow::HandleDestroy()
2603 {
2604 wxWindowDestroyEvent vEvent(this);
2605
2606 (void)GetEventHandler()->ProcessEvent(vEvent);
2607
2608 //
2609 // Delete our drop target if we've got one
2610 //
2611 #if wxUSE_DRAG_AND_DROP
2612 if (m_dropTarget != NULL)
2613 {
2614 m_dropTarget->Revoke(m_hWnd);
2615 delete m_dropTarget;
2616 m_dropTarget = NULL;
2617 }
2618 #endif // wxUSE_DRAG_AND_DROP
2619
2620 //
2621 // WM_DESTROY handled
2622 //
2623 return TRUE;
2624 } // end of wxWindow::HandleDestroy
2625
2626 // ---------------------------------------------------------------------------
2627 // activation/focus
2628 // ---------------------------------------------------------------------------
2629 void wxWindow::OnSetFocus(
2630 wxFocusEvent& rEvent
2631 )
2632 {
2633 //
2634 // Panel wants to track the window which was the last to have focus in it,
2635 // so we want to set ourselves as the window which last had focus
2636 //
2637 // Notice that it's also important to do it upwards the tree becaus
2638 // otherwise when the top level panel gets focus, it won't set it back to
2639 // us, but to some other sibling
2640 //
2641 wxWindow* pWin = this;
2642
2643 while (pWin)
2644 {
2645 wxWindow* pParent = pWin->GetParent();
2646 wxPanel* pPanel = wxDynamicCast( pParent
2647 ,wxPanel
2648 );
2649 if (pPanel)
2650 {
2651 pPanel->SetLastFocus(pWin);
2652 }
2653 pWin = pParent;
2654 }
2655
2656 wxLogTrace(_T("focus"), _T("%s (0x%08x) gets focus"),
2657 GetClassInfo()->GetClassName(), GetHandle());
2658
2659 rEvent.Skip();
2660 } // end of wxWindow::OnSetFocus
2661
2662 bool wxWindow::HandleActivate(
2663 int nState
2664 , WXHWND WXUNUSED(hActivate)
2665 )
2666 {
2667 wxActivateEvent vEvent( wxEVT_ACTIVATE
2668 ,(bool)nState
2669 ,m_windowId
2670 );
2671 vEvent.SetEventObject(this);
2672 return GetEventHandler()->ProcessEvent(vEvent);
2673 } // end of wxWindow::HandleActivate
2674
2675 bool wxWindow::HandleSetFocus(
2676 WXHWND WXUNUSED(hWnd)
2677 )
2678 {
2679 #if wxUSE_CARET
2680 //
2681 // Deal with caret
2682 //
2683 if (m_caret)
2684 {
2685 m_caret->OnSetFocus();
2686 }
2687 #endif // wxUSE_CARET
2688
2689 //
2690 // Panel wants to track the window which was the last to have focus in it
2691 //
2692 wxPanel* pPanel = wxDynamicCast( GetParent()
2693 ,wxPanel
2694 );
2695 if (pPanel)
2696 {
2697 pPanel->SetLastFocus(this);
2698 }
2699
2700 wxFocusEvent vEvent(wxEVT_SET_FOCUS, m_windowId);
2701
2702 vEvent.SetEventObject(this);
2703 return GetEventHandler()->ProcessEvent(vEvent);
2704 } // end of wxWindow::HandleSetFocus
2705
2706 bool wxWindow::HandleKillFocus(
2707 WXHWND WXUNUSED(hWnd)
2708 )
2709 {
2710 #if wxUSE_CARET
2711 //
2712 // Deal with caret
2713 //
2714 if (m_caret)
2715 {
2716 m_caret->OnKillFocus();
2717 }
2718 #endif // wxUSE_CARET
2719
2720 wxFocusEvent vEvent( wxEVT_KILL_FOCUS
2721 ,m_windowId
2722 );
2723
2724 vEvent.SetEventObject(this);
2725 return GetEventHandler()->ProcessEvent(vEvent);
2726 } // end of wxWindow::HandleKillFocus
2727
2728 // ---------------------------------------------------------------------------
2729 // miscellaneous
2730 // ---------------------------------------------------------------------------
2731
2732 bool wxWindow::HandleShow(
2733 bool bShow
2734 , int nStatus
2735 )
2736 {
2737 wxShowEvent vEvent( GetId()
2738 ,bShow
2739 );
2740
2741 vEvent.m_eventObject = this;
2742 return GetEventHandler()->ProcessEvent(vEvent);
2743 } // end of wxWindow::HandleShow
2744
2745 bool wxWindow::HandleInitDialog(
2746 WXHWND WXUNUSED(hWndFocus)
2747 )
2748 {
2749 wxInitDialogEvent vEvent(GetId());
2750
2751 vEvent.m_eventObject = this;
2752 return GetEventHandler()->ProcessEvent(vEvent);
2753 } // end of wxWindow::HandleInitDialog
2754
2755 bool wxWindow::HandleEndDrag(WXWPARAM wParam)
2756 {
2757 // TODO: We'll handle drag and drop later
2758 return FALSE;
2759 }
2760
2761 bool wxWindow::HandleSetCursor(
2762 USHORT vId
2763 , WXHWND hPointer
2764 )
2765 {
2766 //
2767 // Under OS/2 PM this allows the pointer to be changed
2768 // as it passes over a control
2769 //
2770 ::WinSetPointer(HWND_DESKTOP, (HPOINTER)hPointer);
2771 return TRUE;
2772 } // end of wxWindow::HandleSetCursor
2773
2774 // ---------------------------------------------------------------------------
2775 // owner drawn stuff
2776 // ---------------------------------------------------------------------------
2777 bool wxWindow::OS2OnDrawItem(
2778 int vId
2779 , WXDRAWITEMSTRUCT* pItemStruct
2780 )
2781 {
2782 wxDC vDc;
2783
2784 #if wxUSE_OWNER_DRAWN
2785 //
2786 // Is it a menu item?
2787 //
2788 if (vId == 0)
2789 {
2790 ERRORID vError;
2791 wxString sError;
2792 POWNERITEM pMeasureStruct = (POWNERITEM)pItemStruct;
2793 wxFrame* pFrame = (wxFrame*)this;
2794 wxMenuItem* pMenuItem = pFrame->GetMenuBar()->FindItem(pMeasureStruct->idItem, pMeasureStruct->hItem);
2795 HDC hDC = ::GpiQueryDevice(pMeasureStruct->hps);
2796 wxRect vRect( pMeasureStruct->rclItem.xLeft
2797 ,pMeasureStruct->rclItem.yBottom
2798 ,pMeasureStruct->rclItem.xRight - pMeasureStruct->rclItem.xLeft
2799 ,pMeasureStruct->rclItem.yTop - pMeasureStruct->rclItem.yBottom
2800 );
2801 vDc.SetHDC( hDC
2802 ,FALSE
2803 );
2804 vDc.SetHPS(pMeasureStruct->hps);
2805 //
2806 // Load the wxWindows Pallete and set to RGB mode
2807 //
2808 if (!::GpiCreateLogColorTable( pMeasureStruct->hps
2809 ,0L
2810 ,LCOLF_CONSECRGB
2811 ,0L
2812 ,(LONG)wxTheColourDatabase->m_nSize
2813 ,(PLONG)wxTheColourDatabase->m_palTable
2814 ))
2815 {
2816 vError = ::WinGetLastError(vHabmain);
2817 sError = wxPMErrorToStr(vError);
2818 wxLogError("Unable to set current color table. Error: %s\n", sError);
2819 }
2820 //
2821 // Set the color table to RGB mode
2822 //
2823 if (!::GpiCreateLogColorTable( pMeasureStruct->hps
2824 ,0L
2825 ,LCOLF_RGB
2826 ,0L
2827 ,0L
2828 ,NULL
2829 ))
2830 {
2831 vError = ::WinGetLastError(vHabmain);
2832 sError = wxPMErrorToStr(vError);
2833 wxLogError("Unable to set current color table. Error: %s\n", sError);
2834 }
2835
2836 wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
2837
2838
2839 int eAction = 0;
2840 int eStatus = 0;
2841
2842 if (pMeasureStruct->fsAttribute == pMeasureStruct->fsAttributeOld)
2843 {
2844 //
2845 // Entire Item needs to be redrawn (either it has reappeared from
2846 // behind another window or is being displayed for the first time
2847 //
2848 eAction = wxOwnerDrawn::wxODDrawAll;
2849
2850 if (pMeasureStruct->fsAttribute & MIA_HILITED)
2851 {
2852 //
2853 // If it is currently selected we let the system handle it
2854 //
2855 eStatus |= wxOwnerDrawn::wxODSelected;
2856 }
2857 if (pMeasureStruct->fsAttribute & MIA_CHECKED)
2858 {
2859 //
2860 // If it is currently checked we draw our own
2861 //
2862 eStatus |= wxOwnerDrawn::wxODChecked;
2863 pMeasureStruct->fsAttributeOld = pMeasureStruct->fsAttribute &= ~MIA_CHECKED;
2864 }
2865 if (pMeasureStruct->fsAttribute & MIA_DISABLED)
2866 {
2867 //
2868 // If it is currently disabled we let the system handle it
2869 //
2870 eStatus |= wxOwnerDrawn::wxODDisabled;
2871 }
2872 //
2873 // Don't really care about framed (indicationg focus) or NoDismiss
2874 //
2875 }
2876 else
2877 {
2878 if (pMeasureStruct->fsAttribute & MIA_HILITED)
2879 {
2880 eAction = wxOwnerDrawn::wxODDrawAll;
2881 eStatus |= wxOwnerDrawn::wxODSelected;
2882 //
2883 // Keep the system from trying to highlight with its bogus colors
2884 //
2885 pMeasureStruct->fsAttributeOld = pMeasureStruct->fsAttribute &= ~MIA_HILITED;
2886 }
2887 else if (!(pMeasureStruct->fsAttribute & MIA_HILITED))
2888 {
2889 eAction = wxOwnerDrawn::wxODDrawAll;
2890 eStatus = 0;
2891 //
2892 // Keep the system from trying to highlight with its bogus colors
2893 //
2894 pMeasureStruct->fsAttribute = pMeasureStruct->fsAttributeOld &= ~MIA_HILITED;
2895 }
2896 else
2897 {
2898 //
2899 // For now we don't care about anything else
2900 // just ignore the entire message!
2901 //
2902 return TRUE;
2903 }
2904 }
2905 //
2906 // Now redraw the item
2907 //
2908 return(pMenuItem->OnDrawItem( vDc
2909 ,vRect
2910 ,(wxOwnerDrawn::wxODAction)eAction
2911 ,(wxOwnerDrawn::wxODStatus)eStatus
2912 ));
2913 //
2914 // leave the fsAttribute and fsOldAttribute unchanged. If different,
2915 // the system will do the highlight or fraeming or disabling for us,
2916 // otherwise, we'd have to do it ourselves.
2917 //
2918 }
2919
2920 wxWindow* pItem = FindItem(vId);
2921
2922 if (pItem && pItem->IsKindOf(CLASSINFO(wxControl)))
2923 {
2924 return ((wxControl *)pItem)->OS2OnDraw(pItemStruct);
2925 }
2926 #endif
2927 return FALSE;
2928 } // end of wxWindow::OS2OnDrawItem
2929
2930 bool wxWindow::OS2OnMeasureItem(
2931 int lId
2932 , WXMEASUREITEMSTRUCT* pItemStruct
2933 )
2934 {
2935 //
2936 // Is it a menu item?
2937 //
2938 if (lId == 65536) // I really don't like this...has to be a better indicator
2939 {
2940 if (IsKindOf(CLASSINFO(wxFrame))) // we'll assume if Frame then a menu
2941 {
2942 size_t nWidth;
2943 size_t nHeight;
2944 POWNERITEM pMeasureStruct = (POWNERITEM)pItemStruct;
2945 wxFrame* pFrame = (wxFrame*)this;
2946 wxMenuItem* pMenuItem = pFrame->GetMenuBar()->FindItem(pMeasureStruct->idItem, pMeasureStruct->hItem);
2947
2948 wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
2949 nWidth = 0L;
2950 nHeight = 0L;
2951 if (pMenuItem->OnMeasureItem( &nWidth
2952 ,&nHeight
2953 ))
2954 {
2955 pMeasureStruct->rclItem.xRight = nWidth;
2956 pMeasureStruct->rclItem.xLeft = 0L;
2957 pMeasureStruct->rclItem.yTop = nHeight;
2958 pMeasureStruct->rclItem.yBottom = 0L;
2959 return TRUE;
2960 }
2961 return FALSE;
2962 }
2963 }
2964 wxWindow* pItem = FindItem(lId);
2965
2966 if (pItem && pItem->IsKindOf(CLASSINFO(wxControl)))
2967 {
2968 return ((wxControl *)pItem)->OS2OnMeasure(pItemStruct);
2969 }
2970 return FALSE;
2971 }
2972
2973 // ---------------------------------------------------------------------------
2974 // colours and palettes
2975 // ---------------------------------------------------------------------------
2976
2977 bool wxWindow::HandleSysColorChange()
2978 {
2979 wxSysColourChangedEvent vEvent;
2980
2981 vEvent.SetEventObject(this);
2982 return GetEventHandler()->ProcessEvent(vEvent);
2983 } // end of wxWindow::HandleSysColorChange
2984
2985 bool wxWindow::HandleCtlColor(
2986 WXHBRUSH* phBrush
2987 )
2988 {
2989 //
2990 // Not much provided with message. So not sure I can do anything with it
2991 //
2992 return TRUE;
2993 } // end of wxWindow::HandleCtlColor
2994
2995 bool wxWindow::HandleWindowParams(
2996 PWNDPARAMS pWndParams
2997 , WXLPARAM lParam
2998 )
2999 {
3000 // TODO: I'll do something here, just not sure what yet
3001 return TRUE;
3002 }
3003
3004 // Define for each class of dialog and control
3005 WXHBRUSH wxWindow::OnCtlColor(WXHDC hDC,
3006 WXHWND hWnd,
3007 WXUINT nCtlColor,
3008 WXUINT message,
3009 WXWPARAM wParam,
3010 WXLPARAM lParam)
3011 {
3012 return (WXHBRUSH)0;
3013 }
3014
3015 bool wxWindow::HandlePaletteChanged()
3016 {
3017 // need to set this to something first
3018 WXHWND hWndPalChange = NULLHANDLE;
3019
3020 wxPaletteChangedEvent vEvent(GetId());
3021
3022 vEvent.SetEventObject(this);
3023 vEvent.SetChangedWindow(wxFindWinFromHandle(hWndPalChange));
3024
3025 return GetEventHandler()->ProcessEvent(vEvent);
3026 } // end of wxWindow::HandlePaletteChanged
3027
3028 bool wxWindow::HandlePresParamChanged(
3029 WXWPARAM wParam
3030 )
3031 {
3032 //
3033 // TODO: Once again I'll do something here when I need it
3034 //
3035 //wxQueryNewPaletteEvent event(GetId());
3036 //event.SetEventObject(this);
3037 // if the background is erased
3038 // bProcessed = HandleEraseBkgnd((WXHDC)(HDC)wParam);
3039
3040 return FALSE; //GetEventHandler()->ProcessEvent(event) && event.GetPaletteRealized();
3041 }
3042
3043 //
3044 // Responds to colour changes: passes event on to children.
3045 //
3046 void wxWindow::OnSysColourChanged(
3047 wxSysColourChangedEvent& rEvent
3048 )
3049 {
3050 wxNode* pNode = GetChildren().First();
3051
3052 while (pNode)
3053 {
3054 //
3055 // Only propagate to non-top-level windows
3056 //
3057 wxWindow* pWin = (wxWindow *)pNode->Data();
3058
3059 if (pWin->GetParent())
3060 {
3061 wxSysColourChangedEvent vEvent;
3062
3063 rEvent.m_eventObject = pWin;
3064 pWin->GetEventHandler()->ProcessEvent(vEvent);
3065 }
3066 pNode = pNode->Next();
3067 }
3068 } // end of wxWindow::OnSysColourChanged
3069
3070 // ---------------------------------------------------------------------------
3071 // painting
3072 // ---------------------------------------------------------------------------
3073
3074 bool wxWindow::HandlePaint()
3075 {
3076 HRGN hRgn = NULLHANDLE;
3077 wxPaintEvent vEvent;
3078 HPS hPS;
3079 RECTL vRect;
3080
3081 if (::WinQueryUpdateRegion(GetHwnd(), hRgn) == RGN_NULL)
3082 {
3083 wxLogLastError("CreateRectRgn");
3084 return FALSE;
3085 }
3086
3087 m_updateRegion = wxRegion(hRgn);
3088 vEvent.SetEventObject(this);
3089 if (!GetEventHandler()->ProcessEvent(vEvent))
3090 {
3091 HPS hPS;
3092
3093 hPS = ::WinBeginPaint( GetHwnd()
3094 ,NULLHANDLE
3095 ,&vRect
3096 );
3097 if(hPS)
3098 {
3099 ::GpiCreateLogColorTable( hPS
3100 ,0L
3101 ,LCOLF_CONSECRGB
3102 ,0L
3103 ,(LONG)wxTheColourDatabase->m_nSize
3104 ,(PLONG)wxTheColourDatabase->m_palTable
3105 );
3106 ::GpiCreateLogColorTable( hPS
3107 ,0L
3108 ,LCOLF_RGB
3109 ,0L
3110 ,0L
3111 ,NULL
3112 );
3113
3114 ::WinFillRect(hPS, &vRect, GetBackgroundColour().GetPixel());
3115 ::WinEndPaint(hPS);
3116 }
3117 }
3118 return (GetEventHandler()->ProcessEvent(vEvent));
3119 } // end of wxWindow::HandlePaint
3120
3121 bool wxWindow::HandleEraseBkgnd(
3122 WXHDC hDC
3123 )
3124 {
3125 SWP vSwp;
3126
3127 ::WinQueryWindowPos(GetHwnd(), &vSwp);
3128 if (vSwp.fl & SWP_MINIMIZE)
3129 return TRUE;
3130
3131 wxDC vDC;
3132
3133 vDC.m_hPS = (HPS)hDC; // this is really a PS
3134 vDC.SetWindow(this);
3135 vDC.BeginDrawing();
3136
3137 wxEraseEvent vEvent(m_windowId, &vDC);
3138
3139 vEvent.SetEventObject(this);
3140
3141 bool rc = GetEventHandler()->ProcessEvent(vEvent);
3142
3143 vDC.EndDrawing();
3144 vDC.m_hPS = NULLHANDLE;
3145 return TRUE;
3146 } // end of wxWindow::HandleEraseBkgnd
3147
3148 void wxWindow::OnEraseBackground(
3149 wxEraseEvent& rEvent
3150 )
3151 {
3152 RECTL vRect;
3153 HPS hPS = rEvent.m_dc->m_hPS;
3154
3155 ::WinQueryWindowRect(GetHwnd(), &vRect);
3156 ::WinFillRect(hPS, &vRect, m_backgroundColour.GetPixel());
3157 } // end of wxWindow::OnEraseBackground
3158
3159 // ---------------------------------------------------------------------------
3160 // moving and resizing
3161 // ---------------------------------------------------------------------------
3162
3163 bool wxWindow::HandleMinimize()
3164 {
3165 wxIconizeEvent vEvent(m_windowId);
3166
3167 vEvent.SetEventObject(this);
3168 return GetEventHandler()->ProcessEvent(vEvent);
3169 } // end of wxWindow::HandleMinimize
3170
3171 bool wxWindow::HandleMaximize()
3172 {
3173 wxMaximizeEvent vEvent(m_windowId);
3174
3175 vEvent.SetEventObject(this);
3176 return GetEventHandler()->ProcessEvent(vEvent);
3177 } // end of wxWindow::HandleMaximize
3178
3179 bool wxWindow::HandleMove(
3180 int nX
3181 , int nY
3182 )
3183 {
3184 wxMoveEvent vEvent( wxPoint( nX
3185 ,nY
3186 )
3187 ,m_windowId
3188 );
3189
3190 vEvent.SetEventObject(this);
3191 return GetEventHandler()->ProcessEvent(vEvent);
3192 } // end of wxWindow::HandleMove
3193
3194 bool wxWindow::HandleSize(
3195 int nWidth
3196 , int nHeight
3197 , WXUINT WXUNUSED(nFlag)
3198 )
3199 {
3200 wxSizeEvent vEvent( wxSize( nWidth
3201 ,nHeight
3202 )
3203 ,m_windowId
3204 );
3205
3206 vEvent.SetEventObject(this);
3207 return GetEventHandler()->ProcessEvent(vEvent);
3208 } // end of wxWindow::HandleSize
3209
3210 bool wxWindow::HandleGetMinMaxInfo(
3211 PSWP pSwp
3212 )
3213 {
3214 bool bRc = FALSE;
3215 POINTL vPoint;
3216
3217 switch(pSwp->fl)
3218 {
3219 case SWP_MAXIMIZE:
3220 ::WinGetMaxPosition(GetHwnd(), pSwp);
3221 m_maxWidth = pSwp->cx;
3222 m_maxHeight = pSwp->cy;
3223 break;
3224
3225 case SWP_MINIMIZE:
3226 ::WinGetMinPosition(GetHwnd(), pSwp, &vPoint);
3227 m_minWidth = pSwp->cx;
3228 m_minHeight = pSwp->cy;
3229 break;
3230
3231 default:
3232 return FALSE;
3233 }
3234 return TRUE;
3235 } // end of wxWindow::HandleGetMinMaxInfo
3236
3237 // ---------------------------------------------------------------------------
3238 // command messages
3239 // ---------------------------------------------------------------------------
3240 bool wxWindow::HandleCommand(
3241 WXWORD wId
3242 , WXWORD wCmd
3243 , WXHWND hControl
3244 )
3245 {
3246 if (wxCurrentPopupMenu)
3247 {
3248 wxMenu* pPopupMenu = wxCurrentPopupMenu;
3249
3250 wxCurrentPopupMenu = NULL;
3251 return pPopupMenu->OS2Command(wCmd, wId);
3252 }
3253
3254 wxWindow* pWin = FindItem(wId);
3255
3256 if (!pWin)
3257 {
3258 pWin = wxFindWinFromHandle(hControl);
3259 }
3260
3261 if (pWin)
3262 return pWin->OS2Command( wCmd
3263 ,wId
3264 );
3265 return FALSE;
3266 } // end of wxWindow::HandleCommand
3267
3268 bool wxWindow::HandleSysCommand(
3269 WXWPARAM wParam
3270 , WXLPARAM lParam
3271 )
3272 {
3273 //
3274 // 4 bits are reserved
3275 //
3276 switch (SHORT1FROMMP(wParam))
3277 {
3278 case SC_MAXIMIZE:
3279 return HandleMaximize();
3280
3281 case SC_MINIMIZE:
3282 return HandleMinimize();
3283 }
3284 return FALSE;
3285 } // end of wxWindow::HandleSysCommand
3286
3287 // ---------------------------------------------------------------------------
3288 // mouse events
3289 // ---------------------------------------------------------------------------
3290
3291 void wxWindow::InitMouseEvent(
3292 wxMouseEvent& rEvent
3293 , int nX
3294 , int nY
3295 , WXUINT uFlags
3296 )
3297 {
3298 rEvent.m_x = nX;
3299 rEvent.m_y = nY;
3300 rEvent.m_shiftDown = ((uFlags & VK_SHIFT) != 0);
3301 rEvent.m_controlDown = ((uFlags & VK_CTRL) != 0);
3302 rEvent.m_leftDown = ((uFlags & VK_BUTTON1) != 0);
3303 rEvent.m_middleDown = ((uFlags & VK_BUTTON3) != 0);
3304 rEvent.m_rightDown = ((uFlags & VK_BUTTON2) != 0);
3305 rEvent.SetTimestamp(s_currentMsg.time);
3306 rEvent.m_eventObject = this;
3307
3308 #if wxUSE_MOUSEEVENT_HACK
3309 m_lastMouseX = nX;
3310 m_lastMouseY = nY;
3311 m_lastMouseEvent = rEvent.GetEventType();
3312 #endif // wxUSE_MOUSEEVENT_HACK
3313 } // end of wxWindow::InitMouseEvent
3314
3315 bool wxWindow::HandleMouseEvent(
3316 WXUINT uMsg
3317 , int nX
3318 , int nY
3319 , WXUINT uFlags
3320 )
3321 {
3322 //
3323 // The mouse events take consecutive IDs from WM_MOUSEFIRST to
3324 // WM_MOUSELAST, so it's enough to substract WM_MOUSEMOVE == WM_MOUSEFIRST
3325 // from the message id and take the value in the table to get wxWin event
3326 // id
3327 //
3328 static const wxEventType eventsMouse[] =
3329 {
3330 wxEVT_MOTION,
3331 wxEVT_LEFT_DOWN,
3332 wxEVT_LEFT_UP,
3333 wxEVT_LEFT_DCLICK,
3334 wxEVT_RIGHT_DOWN,
3335 wxEVT_RIGHT_UP,
3336 wxEVT_RIGHT_DCLICK,
3337 wxEVT_MIDDLE_DOWN,
3338 wxEVT_MIDDLE_UP,
3339 wxEVT_MIDDLE_DCLICK
3340 };
3341
3342 wxMouseEvent vEvent(eventsMouse[uMsg - WM_MOUSEMOVE]);
3343
3344 InitMouseEvent( vEvent
3345 ,nX
3346 ,nY
3347 ,uFlags
3348 );
3349
3350 return GetEventHandler()->ProcessEvent(vEvent);
3351 } // end of wxWindow::HandleMouseEvent
3352
3353 bool wxWindow::HandleMouseMove(
3354 int nX
3355 , int nY
3356 , WXUINT uFlags
3357 )
3358 {
3359 if (!m_bMouseInWindow)
3360 {
3361 //
3362 // Generate an ENTER event
3363 //
3364 m_bMouseInWindow = TRUE;
3365
3366 wxMouseEvent vEvent(wxEVT_ENTER_WINDOW);
3367
3368 InitMouseEvent( vEvent
3369 ,nX
3370 ,nY
3371 ,uFlags
3372 );
3373
3374 (void)GetEventHandler()->ProcessEvent(vEvent);
3375 }
3376 return HandleMouseEvent( WM_MOUSEMOVE
3377 ,nX
3378 ,nY
3379 ,uFlags
3380 );
3381 } // end of wxWindow::HandleMouseMove
3382
3383 // ---------------------------------------------------------------------------
3384 // keyboard handling
3385 // ---------------------------------------------------------------------------
3386
3387 //
3388 // Create the key event of the given type for the given key - used by
3389 // HandleChar and HandleKeyDown/Up
3390 //
3391 wxKeyEvent wxWindow::CreateKeyEvent(
3392 wxEventType eType
3393 , int nId
3394 , WXLPARAM lParam
3395 ) const
3396 {
3397 wxKeyEvent vEvent(eType);
3398
3399 vEvent.SetId(GetId());
3400 vEvent.m_shiftDown = IsShiftDown();
3401 vEvent.m_controlDown = IsCtrlDown();
3402 vEvent.m_altDown = (HIWORD(lParam) & KC_ALT) == KC_ALT;
3403
3404 vEvent.m_eventObject = (wxWindow *)this; // const_cast
3405 vEvent.m_keyCode = nId;
3406 vEvent.SetTimestamp(s_currentMsg.time);
3407
3408 //
3409 // Translate the position to client coords
3410 //
3411 POINTL vPoint;
3412 RECTL vRect;
3413
3414 ::WinQueryPointerPos(HWND_DESKTOP, &vPoint);
3415 ::WinQueryWindowRect( GetHwnd()
3416 ,&vRect
3417 );
3418
3419 vPoint.x -= vRect.xLeft;
3420 vPoint.y -= vRect.yBottom;
3421
3422 vEvent.m_x = vPoint.x;
3423 vEvent.m_y = vPoint.y;
3424
3425 return vEvent;
3426 } // end of wxWindow::CreateKeyEvent
3427
3428 //
3429 // isASCII is TRUE only when we're called from WM_CHAR handler and not from
3430 // WM_KEYDOWN one
3431 //
3432 bool wxWindow::HandleChar(
3433 WXWORD wParam
3434 , WXLPARAM lParam
3435 , bool isASCII
3436 )
3437 {
3438 bool bCtrlDown = FALSE;
3439 int vId;
3440
3441 if (isASCII)
3442 {
3443 //
3444 // If 1 -> 26, translate to CTRL plus a letter.
3445 //
3446 vId = wParam;
3447 if ((vId > 0) && (vId < 27))
3448 {
3449 switch (vId)
3450 {
3451 case 13:
3452 vId = WXK_RETURN;
3453 break;
3454
3455 case 8:
3456 vId = WXK_BACK;
3457 break;
3458
3459 case 9:
3460 vId = WXK_TAB;
3461 break;
3462
3463 default:
3464 bCtrlDown = TRUE;
3465 vId = vId + 96;
3466 }
3467 }
3468 }
3469 else if ( (vId = wxCharCodeOS2ToWX(wParam)) == 0)
3470 {
3471 //
3472 // It's ASCII and will be processed here only when called from
3473 // WM_CHAR (i.e. when isASCII = TRUE), don't process it now
3474 //
3475 vId = -1;
3476 }
3477
3478 if (vId != -1)
3479 {
3480 wxKeyEvent vEvent(CreateKeyEvent( wxEVT_CHAR
3481 ,vId
3482 ,lParam
3483 ));
3484
3485 if (bCtrlDown)
3486 {
3487 vEvent.m_controlDown = TRUE;
3488 }
3489
3490 if (GetEventHandler()->ProcessEvent(vEvent))
3491 return TRUE;
3492 }
3493 return FALSE;
3494 }
3495
3496 bool wxWindow::HandleKeyDown(
3497 WXWORD wParam
3498 , WXLPARAM lParam
3499 )
3500 {
3501 int nId = wxCharCodeOS2ToWX(wParam);
3502
3503 if (!nId)
3504 {
3505 //
3506 // Normal ASCII char
3507 //
3508 nId = wParam;
3509 }
3510
3511 if (nId != -1)
3512 {
3513 wxKeyEvent vEvent(CreateKeyEvent( wxEVT_KEY_DOWN
3514 ,nId
3515 ,lParam
3516 ));
3517
3518 if (GetEventHandler()->ProcessEvent(vEvent))
3519 {
3520 return TRUE;
3521 }
3522 }
3523 return FALSE;
3524 } // end of wxWindow::HandleKeyDown
3525
3526 bool wxWindow::HandleKeyUp(
3527 WXWORD wParam
3528 , WXLPARAM lParam
3529 )
3530 {
3531 int nId = wxCharCodeOS2ToWX(wParam);
3532
3533 if (!nId)
3534 {
3535 //
3536 // Normal ASCII char
3537 //
3538 nId = wParam;
3539 }
3540
3541 if (nId != -1)
3542 {
3543 wxKeyEvent vEvent(CreateKeyEvent( wxEVT_KEY_UP
3544 ,nId
3545 ,lParam
3546 ));
3547
3548 if (GetEventHandler()->ProcessEvent(vEvent))
3549 return TRUE;
3550 }
3551 return FALSE;
3552 } // end of wxWindow::HandleKeyUp
3553
3554 // ---------------------------------------------------------------------------
3555 // joystick
3556 // ---------------------------------------------------------------------------
3557
3558 // ---------------------------------------------------------------------------
3559 // scrolling
3560 // ---------------------------------------------------------------------------
3561
3562 bool wxWindow::OS2OnScroll(
3563 int nOrientation
3564 , WXWORD wParam
3565 , WXWORD wPos
3566 , WXHWND hControl
3567 )
3568 {
3569 if (hControl)
3570 {
3571 wxWindow* pChild = wxFindWinFromHandle(hControl);
3572
3573 if (pChild )
3574 return pChild->OS2OnScroll( nOrientation
3575 ,wParam
3576 ,wPos
3577 ,hControl
3578 );
3579 }
3580
3581 wxScrollWinEvent vEvent;
3582
3583 vEvent.SetPosition(wPos);
3584 vEvent.SetOrientation(nOrientation);
3585 vEvent.m_eventObject = this;
3586
3587 switch (wParam)
3588 {
3589 case SB_LINEUP:
3590 vEvent.m_eventType = wxEVT_SCROLLWIN_LINEUP;
3591 break;
3592
3593 case SB_LINEDOWN:
3594 vEvent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN;
3595 break;
3596
3597 case SB_PAGEUP:
3598 vEvent.m_eventType = wxEVT_SCROLLWIN_PAGEUP;
3599 break;
3600
3601 case SB_PAGEDOWN:
3602 vEvent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN;
3603 break;
3604
3605 case SB_SLIDERPOSITION:
3606 vEvent.m_eventType = wxEVT_SCROLLWIN_THUMBRELEASE;
3607 break;
3608
3609 case SB_SLIDERTRACK:
3610 vEvent.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK;
3611 break;
3612
3613 default:
3614 return FALSE;
3615 }
3616 return GetEventHandler()->ProcessEvent(vEvent);
3617 } // end of wxWindow::OS2OnScroll
3618
3619 // ===========================================================================
3620 // global functions
3621 // ===========================================================================
3622
3623 void wxGetCharSize(
3624 WXHWND hWnd
3625 , int* pX
3626 , int* pY
3627 ,wxFont* pTheFont
3628 )
3629 {
3630 // TODO: we'll do this later
3631 } // end of wxGetCharSize
3632
3633 //
3634 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
3635 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
3636 //
3637 int wxCharCodeOS2ToWX(
3638 int nKeySym
3639 )
3640 {
3641 int nId = 0;
3642
3643 switch (nKeySym)
3644 {
3645 case VK_BACKTAB: nId = WXK_BACK; break;
3646 case VK_TAB: nId = WXK_TAB; break;
3647 case VK_CLEAR: nId = WXK_CLEAR; break;
3648 case VK_ENTER: nId = WXK_RETURN; break;
3649 case VK_SHIFT: nId = WXK_SHIFT; break;
3650 case VK_CTRL: nId = WXK_CONTROL; break;
3651 case VK_PAUSE: nId = WXK_PAUSE; break;
3652 case VK_SPACE: nId = WXK_SPACE; break;
3653 case VK_ESC: nId = WXK_ESCAPE; break;
3654 case VK_END: nId = WXK_END; break;
3655 case VK_HOME : nId = WXK_HOME; break;
3656 case VK_LEFT : nId = WXK_LEFT; break;
3657 case VK_UP: nId = WXK_UP; break;
3658 case VK_RIGHT: nId = WXK_RIGHT; break;
3659 case VK_DOWN : nId = WXK_DOWN; break;
3660 case VK_PRINTSCRN: nId = WXK_PRINT; break;
3661 case VK_INSERT: nId = WXK_INSERT; break;
3662 case VK_DELETE: nId = WXK_DELETE; break;
3663 case VK_F1: nId = WXK_F1; break;
3664 case VK_F2: nId = WXK_F2; break;
3665 case VK_F3: nId = WXK_F3; break;
3666 case VK_F4: nId = WXK_F4; break;
3667 case VK_F5: nId = WXK_F5; break;
3668 case VK_F6: nId = WXK_F6; break;
3669 case VK_F7: nId = WXK_F7; break;
3670 case VK_F8: nId = WXK_F8; break;
3671 case VK_F9: nId = WXK_F9; break;
3672 case VK_F10: nId = WXK_F10; break;
3673 case VK_F11: nId = WXK_F11; break;
3674 case VK_F12: nId = WXK_F12; break;
3675 case VK_F13: nId = WXK_F13; break;
3676 case VK_F14: nId = WXK_F14; break;
3677 case VK_F15: nId = WXK_F15; break;
3678 case VK_F16: nId = WXK_F16; break;
3679 case VK_F17: nId = WXK_F17; break;
3680 case VK_F18: nId = WXK_F18; break;
3681 case VK_F19: nId = WXK_F19; break;
3682 case VK_F20: nId = WXK_F20; break;
3683 case VK_F21: nId = WXK_F21; break;
3684 case VK_F22: nId = WXK_F22; break;
3685 case VK_F23: nId = WXK_F23; break;
3686 case VK_F24: nId = WXK_F24; break;
3687 case VK_NUMLOCK: nId = WXK_NUMLOCK; break;
3688 case VK_SCRLLOCK: nId = WXK_SCROLL; break;
3689 default:
3690 {
3691 return 0;
3692 }
3693 }
3694 return nId;
3695 } // end of wxCharCodeOS2ToWX
3696
3697 int wxCharCodeWXToOS2(
3698 int nId
3699 , bool* bIsVirtual
3700 )
3701 {
3702 int nKeySym = 0;
3703
3704 *bIsVirtual = TRUE;
3705 switch (nId)
3706 {
3707 case WXK_CLEAR: nKeySym = VK_CLEAR; break;
3708 case WXK_SHIFT: nKeySym = VK_SHIFT; break;
3709 case WXK_CONTROL: nKeySym = VK_CTRL; break;
3710 case WXK_PAUSE: nKeySym = VK_PAUSE; break;
3711 case WXK_END: nKeySym = VK_END; break;
3712 case WXK_HOME : nKeySym = VK_HOME; break;
3713 case WXK_LEFT : nKeySym = VK_LEFT; break;
3714 case WXK_UP: nKeySym = VK_UP; break;
3715 case WXK_RIGHT: nKeySym = VK_RIGHT; break;
3716 case WXK_DOWN : nKeySym = VK_DOWN; break;
3717 case WXK_PRINT: nKeySym = VK_PRINTSCRN; break;
3718 case WXK_INSERT: nKeySym = VK_INSERT; break;
3719 case WXK_DELETE: nKeySym = VK_DELETE; break;
3720 case WXK_F1: nKeySym = VK_F1; break;
3721 case WXK_F2: nKeySym = VK_F2; break;
3722 case WXK_F3: nKeySym = VK_F3; break;
3723 case WXK_F4: nKeySym = VK_F4; break;
3724 case WXK_F5: nKeySym = VK_F5; break;
3725 case WXK_F6: nKeySym = VK_F6; break;
3726 case WXK_F7: nKeySym = VK_F7; break;
3727 case WXK_F8: nKeySym = VK_F8; break;
3728 case WXK_F9: nKeySym = VK_F9; break;
3729 case WXK_F10: nKeySym = VK_F10; break;
3730 case WXK_F11: nKeySym = VK_F11; break;
3731 case WXK_F12: nKeySym = VK_F12; break;
3732 case WXK_F13: nKeySym = VK_F13; break;
3733 case WXK_F14: nKeySym = VK_F14; break;
3734 case WXK_F15: nKeySym = VK_F15; break;
3735 case WXK_F16: nKeySym = VK_F16; break;
3736 case WXK_F17: nKeySym = VK_F17; break;
3737 case WXK_F18: nKeySym = VK_F18; break;
3738 case WXK_F19: nKeySym = VK_F19; break;
3739 case WXK_F20: nKeySym = VK_F20; break;
3740 case WXK_F21: nKeySym = VK_F21; break;
3741 case WXK_F22: nKeySym = VK_F22; break;
3742 case WXK_F23: nKeySym = VK_F23; break;
3743 case WXK_F24: nKeySym = VK_F24; break;
3744 case WXK_NUMLOCK: nKeySym = VK_NUMLOCK; break;
3745 case WXK_SCROLL: nKeySym = VK_SCRLLOCK; break;
3746 default:
3747 {
3748 *bIsVirtual = FALSE;
3749 nKeySym = nId;
3750 break;
3751 }
3752 }
3753 return nKeySym;
3754 } // end of wxCharCodeWXToOS2
3755
3756 wxWindow* wxGetActiveWindow()
3757 {
3758 HWND hWnd = ::WinQueryActiveWindow(HWND_DESKTOP);
3759
3760 if (hWnd != 0)
3761 {
3762 return wxFindWinFromHandle((WXHWND)hWnd);
3763 }
3764 return NULL;
3765 } // end of wxGetActiveWindow
3766
3767 #ifdef __WXDEBUG__
3768 const char* wxGetMessageName(
3769 int nMessage)
3770 {
3771 switch (nMessage)
3772 {
3773 case 0x0000: return "WM_NULL";
3774 case 0x0001: return "WM_CREATE";
3775 case 0x0002: return "WM_DESTROY";
3776 case 0x0004: return "WM_ENABLE";
3777 case 0x0005: return "WM_SHOW";
3778 case 0x0006: return "WM_MOVE";
3779 case 0x0007: return "WM_SIZE";
3780 case 0x0008: return "WM_ADJUSTWINDOWPOS";
3781 case 0x0009: return "WM_CALCVALIDRECTS";
3782 case 0x000A: return "WM_SETWINDOWPARAMS";
3783 case 0x000B: return "WM_QUERYWINDOWPARAMS";
3784 case 0x000C: return "WM_HITTEST";
3785 case 0x000D: return "WM_ACTIVATE";
3786 case 0x000F: return "WM_SETFOCUS";
3787 case 0x0010: return "WM_SETSELECTION";
3788 case 0x0011: return "WM_PPAINT";
3789 case 0x0012: return "WM_PSETFOCUS";
3790 case 0x0013: return "WM_PSYSCOLORCHANGE";
3791 case 0x0014: return "WM_PSIZE";
3792 case 0x0015: return "WM_PACTIVATE";
3793 case 0x0016: return "WM_PCONTROL";
3794 case 0x0020: return "WM_COMMAND";
3795 case 0x0021: return "WM_SYSCOMMAND";
3796 case 0x0022: return "WM_HELP";
3797 case 0x0023: return "WM_PAINT";
3798 case 0x0024: return "WM_TIMER";
3799 case 0x0025: return "WM_SEM1";
3800 case 0x0026: return "WM_SEM2";
3801 case 0x0027: return "WM_SEM3";
3802 case 0x0028: return "WM_SEM4";
3803 case 0x0029: return "WM_CLOSE";
3804 case 0x002A: return "WM_QUIT";
3805 case 0x002B: return "WM_SYSCOLORCHANGE";
3806 case 0x002D: return "WM_SYSVALUECHANGE";
3807 case 0x002E: return "WM_APPTERMINATENOTIFY";
3808 case 0x002F: return "WM_PRESPARAMCHANGED";
3809 // Control notification messages
3810 case 0x0030: return "WM_CONTROL";
3811 case 0x0031: return "WM_VSCROLL";
3812 case 0x0032: return "WM_HSCROLL";
3813 case 0x0033: return "WM_INITMENU";
3814 case 0x0034: return "WM_MENUSELECT";
3815 case 0x0035: return "WM_MENUSEND";
3816 case 0x0036: return "WM_DRAWITEM";
3817 case 0x0037: return "WM_MEASUREITEM";
3818 case 0x0038: return "WM_CONTROLPOINTER";
3819 case 0x003A: return "WM_QUERYDLGCODE";
3820 case 0x003B: return "WM_INITDLG";
3821 case 0x003C: return "WM_SUBSTITUTESTRING";
3822 case 0x003D: return "WM_MATCHMNEMONIC";
3823 case 0x003E: return "WM_SAVEAPPLICATION";
3824 case 0x0129: return "WM_CTLCOLORCHANGE";
3825 case 0x0130: return "WM_QUERYCTLTYPE";
3826 // Frame messages
3827 case 0x0040: return "WM_FLASHWINDOW";
3828 case 0x0041: return "WM_FORMATFRAME";
3829 case 0x0042: return "WM_UPDATEFRAME";
3830 case 0x0043: return "WM_FOCUSCHANGE";
3831 case 0x0044: return "WM_SETBORDERSIZE";
3832 case 0x0045: return "WM_TRACKFRAME";
3833 case 0x0046: return "WM_MINMAXFRAME";
3834 case 0x0047: return "WM_SETICON";
3835 case 0x0048: return "WM_QUERYICON";
3836 case 0x0049: return "WM_SETACCELTABLE";
3837 case 0x004A: return "WM_QUERYACCELTABLE";
3838 case 0x004B: return "WM_TRANSLATEACCEL";
3839 case 0x004C: return "WM_QUERYTRACKINFO";
3840 case 0x004D: return "WM_QUERYBORDERSIZE";
3841 case 0x004E: return "WM_NEXTMENU";
3842 case 0x004F: return "WM_ERASEBACKGROUND";
3843 case 0x0050: return "WM_QUERYFRAMEINFO";
3844 case 0x0051: return "WM_QUERYFOCUSCHAIN";
3845 case 0x0052: return "WM_OWNERPOSCHANGE";
3846 case 0x0053: return "WM_CACLFRAMERECT";
3847 case 0x0055: return "WM_WINDOWPOSCHANGED";
3848 case 0x0056: return "WM_ADJUSTFRAMEPOS";
3849 case 0x0059: return "WM_QUERYFRAMECTLCOUNT";
3850 case 0x005B: return "WM_QUERYHELPINFO";
3851 case 0x005C: return "WM_SETHELPINFO";
3852 case 0x005D: return "WM_ERROR";
3853 case 0x005E: return "WM_REALIZEPALETTE";
3854 // Clipboard messages
3855 case 0x0060: return "WM_RENDERFMT";
3856 case 0x0061: return "WM_RENDERALLFMTS";
3857 case 0x0062: return "WM_DESTROYCLIPBOARD";
3858 case 0x0063: return "WM_PAINTCLIPBOARD";
3859 case 0x0064: return "WM_SIZECLIPBOARD";
3860 case 0x0065: return "WM_HSCROLLCLIPBOARD";
3861 case 0x0066: return "WM_VSCROLLCLIPBOARD";
3862 case 0x0067: return "WM_DRAWCLIPBOARD";
3863 // mouse messages
3864 case 0x0070: return "WM_MOUSEMOVE";
3865 case 0x0071: return "WM_BUTTON1DOWN";
3866 case 0x0072: return "WM_BUTTON1UP";
3867 case 0x0073: return "WM_BUTTON1DBLCLK";
3868 case 0x0074: return "WM_BUTTON2DOWN";
3869 case 0x0075: return "WM_BUTTON2UP";
3870 case 0x0076: return "WM_BUTTON2DBLCLK";
3871 case 0x0077: return "WM_BUTTON3DOWN";
3872 case 0x0078: return "WM_BUTTON3UP";
3873 case 0x0079: return "WM_BUTTON3DBLCLK";
3874 case 0x007D: return "WM_MOUSEMAP";
3875 case 0x007E: return "WM_VRNDISABLED";
3876 case 0x007F: return "WM_VRNENABLED";
3877 case 0x0410: return "WM_CHORD";
3878 case 0x0411: return "WM_BUTTON1MOTIONSTART";
3879 case 0x0412: return "WM_BUTTON1MOTIONEND";
3880 case 0x0413: return "WM_BUTTON1CLICK";
3881 case 0x0414: return "WM_BUTTON2MOTIONSTART";
3882 case 0x0415: return "WM_BUTTON2MOTIONEND";
3883 case 0x0416: return "WM_BUTTON2CLICK";
3884 case 0x0417: return "WM_BUTTON3MOTIONSTART";
3885 case 0x0418: return "WM_BUTTON3MOTIONEND";
3886 case 0x0419: return "WM_BUTTON3CLICK";
3887 case 0x0420: return "WM_BEGINDRAG";
3888 case 0x0421: return "WM_ENDDRAG";
3889 case 0x0422: return "WM_SINGLESELECT";
3890 case 0x0423: return "WM_OPEN";
3891 case 0x0424: return "WM_CONTEXTMENU";
3892 case 0x0425: return "WM_CONTEXTHELP";
3893 case 0x0426: return "WM_TEXTEDIT";
3894 case 0x0427: return "WM_BEGINSELECT";
3895 case 0x0228: return "WM_ENDSELECT";
3896 case 0x0429: return "WM_PICKUP";
3897 case 0x04C0: return "WM_PENFIRST";
3898 case 0x04FF: return "WM_PENLAST";
3899 case 0x0500: return "WM_MMPMFIRST";
3900 case 0x05FF: return "WM_MMPMLAST";
3901 case 0x0600: return "WM_STDDLGFIRST";
3902 case 0x06FF: return "WM_STDDLGLAST";
3903 case 0x0BD0: return "WM_BIDI_FIRST";
3904 case 0x0BFF: return "WM_BIDI_LAST";
3905 // keyboard input
3906 case 0x007A: return "WM_CHAR";
3907 case 0x007B: return "WM_VIOCHAR";
3908 // DDE messages
3909 case 0x00A0: return "WM_DDE_INITIATE";
3910 case 0x00A1: return "WM_DDE_REQUEST";
3911 case 0x00A2: return "WM_DDE_ACK";
3912 case 0x00A3: return "WM_DDE_DATA";
3913 case 0x00A4: return "WM_DDE_ADVISE";
3914 case 0x00A5: return "WM_DDE_UNADVISE";
3915 case 0x00A6: return "WM_DDE_POKE";
3916 case 0x00A7: return "WM_DDE_EXECUTE";
3917 case 0x00A8: return "WM_DDE_TERMINATE";
3918 case 0x00A9: return "WM_DDE_INITIATEACK";
3919 case 0x00AF: return "WM_DDE_LAST";
3920 // Buttons
3921 case 0x0120: return "BM_CLICK";
3922 case 0x0121: return "BM_QUERYCHECKINDEX";
3923 case 0x0122: return "BM_QUERYHILITE";
3924 case 0x0123: return "BM_SETHILITE";
3925 case 0x0124: return "BM_QUERYCHECK";
3926 case 0x0125: return "BM_SETCHECK";
3927 case 0x0126: return "BM_SETDEFAULT";
3928 case 0x0128: return "BM_AUTOSIZE";
3929 // Combo boxes
3930 case 0x029A: return "CBID_LIST";
3931 case 0x029B: return "CBID_EDIT";
3932 case 0x0170: return "CBM_SHOWLIST";
3933 case 0x0171: return "CBM_HILITE";
3934 case 0x0172: return "CBM_ISLISTSHOWING";
3935 // Edit fields
3936 case 0x0140: return "EM_QUERYCHANGED";
3937 case 0x0141: return "EM_QUERYSEL";
3938 case 0x0142: return "EM_SETSEL";
3939 case 0x0143: return "EM_SETTEXTLIMIT";
3940 case 0x0144: return "EM_CUT";
3941 case 0x0145: return "EM_COPY";
3942 case 0x0146: return "EM_CLEAR";
3943 case 0x0147: return "EM_PASTE";
3944 case 0x0148: return "EM_QUERYFIRSTCHAR";
3945 case 0x0149: return "EM_SETFIRSTCHAR";
3946 case 0x014A: return "EM_QUERYREADONLY";
3947 case 0x014B: return "EM_SETREADONLY";
3948 case 0x014C: return "EM_SETINSERTMODE";
3949 // Listboxes
3950 case 0x0160: return "LM_QUERYITEMCOUNT";
3951 case 0x0161: return "LM_INSERTITEM";
3952 case 0x0162: return "LM_SETOPENINDEX";
3953 case 0x0163: return "LM_DELETEITEM";
3954 case 0x0164: return "LM_SELECTITEM";
3955 case 0x0165: return "LM_QUERYSELECTION";
3956 case 0x0166: return "LM_SETITEMTEXT";
3957 case 0x0167: return "LM_QUERYITEMTEXTLENGTH";
3958 case 0x0168: return "LM_QUERYITEMTEXT";
3959 case 0x0169: return "LM_SETITEMHANDLE";
3960 case 0x016A: return "LM_QUERYITEMHANDLE";
3961 case 0x016B: return "LM_SEARCHSTRING";
3962 case 0x016C: return "LM_SETITEMHEIGHT";
3963 case 0x016D: return "LM_QUERYTOPINDEX";
3964 case 0x016E: return "LM_DELETEALL";
3965 case 0x016F: return "LM_INSERTMULITEMS";
3966 case 0x0660: return "LM_SETITEMWIDTH";
3967 // Menus
3968 case 0x0180: return "MM_INSERTITEM";
3969 case 0x0181: return "MM_DELETEITEM";
3970 case 0x0182: return "MM_QUERYITEM";
3971 case 0x0183: return "MM_SETITEM";
3972 case 0x0184: return "MM_QUERYITEMCOUNT";
3973 case 0x0185: return "MM_STARTMENUMODE";
3974 case 0x0186: return "MM_ENDMENUMODE";
3975 case 0x0188: return "MM_REMOVEITEM";
3976 case 0x0189: return "MM_SELECTITEM";
3977 case 0x018A: return "MM_QUERYSELITEMID";
3978 case 0x018B: return "MM_QUERYITEMTEXT";
3979 case 0x018C: return "MM_QUERYITEMTEXTLENGTH";
3980 case 0x018D: return "MM_SETITEMHANDLE";
3981 case 0x018E: return "MM_SETITEMTEXT";
3982 case 0x018F: return "MM_ITEMPOSITIONFROMID";
3983 case 0x0190: return "MM_ITEMIDFROMPOSITION";
3984 case 0x0191: return "MM_QUERYITEMATTR";
3985 case 0x0192: return "MM_SETITEMATTR";
3986 case 0x0193: return "MM_ISITEMVALID";
3987 case 0x0194: return "MM_QUERYITEMRECT";
3988 case 0x0431: return "MM_QUERYDEFAULTITEMID";
3989 case 0x0432: return "MM_SETDEFAULTITEMID";
3990 // Scrollbars
3991 case 0x01A0: return "SBM_SETSCROLLBAR";
3992 case 0x01A1: return "SBM_SETPOS";
3993 case 0x01A2: return "SBM_QUERYPOS";
3994 case 0x01A3: return "SBM_QUERYRANGE";
3995 case 0x01A6: return "SBM_SETTHUMBSIZE";
3996
3997 // Help messages
3998 case 0x0F00: return "WM_HELPBASE";
3999 case 0x0FFF: return "WM_HELPTOP";
4000 // Beginning of user defined messages
4001 case 0x1000: return "WM_USER";
4002
4003 // wxWindows user defined types
4004
4005 // listview
4006 // case 0x1000 + 0: return "LVM_GETBKCOLOR";
4007 case 0x1000 + 1: return "LVM_SETBKCOLOR";
4008 case 0x1000 + 2: return "LVM_GETIMAGELIST";
4009 case 0x1000 + 3: return "LVM_SETIMAGELIST";
4010 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
4011 case 0x1000 + 5: return "LVM_GETITEMA";
4012 case 0x1000 + 75: return "LVM_GETITEMW";
4013 case 0x1000 + 6: return "LVM_SETITEMA";
4014 case 0x1000 + 76: return "LVM_SETITEMW";
4015 case 0x1000 + 7: return "LVM_INSERTITEMA";
4016 case 0x1000 + 77: return "LVM_INSERTITEMW";
4017 case 0x1000 + 8: return "LVM_DELETEITEM";
4018 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
4019 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
4020 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
4021 case 0x1000 + 12: return "LVM_GETNEXTITEM";
4022 case 0x1000 + 13: return "LVM_FINDITEMA";
4023 case 0x1000 + 83: return "LVM_FINDITEMW";
4024 case 0x1000 + 14: return "LVM_GETITEMRECT";
4025 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
4026 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
4027 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
4028 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
4029 case 0x1000 + 18: return "LVM_HITTEST";
4030 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
4031 case 0x1000 + 20: return "LVM_SCROLL";
4032 case 0x1000 + 21: return "LVM_REDRAWITEMS";
4033 case 0x1000 + 22: return "LVM_ARRANGE";
4034 case 0x1000 + 23: return "LVM_EDITLABELA";
4035 case 0x1000 + 118: return "LVM_EDITLABELW";
4036 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
4037 case 0x1000 + 25: return "LVM_GETCOLUMNA";
4038 case 0x1000 + 95: return "LVM_GETCOLUMNW";
4039 case 0x1000 + 26: return "LVM_SETCOLUMNA";
4040 case 0x1000 + 96: return "LVM_SETCOLUMNW";
4041 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
4042 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
4043 case 0x1000 + 28: return "LVM_DELETECOLUMN";
4044 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
4045 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
4046 case 0x1000 + 31: return "LVM_GETHEADER";
4047 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
4048 case 0x1000 + 34: return "LVM_GETVIEWRECT";
4049 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
4050 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
4051 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
4052 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
4053 case 0x1000 + 39: return "LVM_GETTOPINDEX";
4054 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
4055 case 0x1000 + 41: return "LVM_GETORIGIN";
4056 case 0x1000 + 42: return "LVM_UPDATE";
4057 case 0x1000 + 43: return "LVM_SETITEMSTATE";
4058 case 0x1000 + 44: return "LVM_GETITEMSTATE";
4059 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
4060 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
4061 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
4062 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
4063 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
4064 case 0x1000 + 48: return "LVM_SORTITEMS";
4065 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
4066 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
4067 case 0x1000 + 51: return "LVM_GETITEMSPACING";
4068 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
4069 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
4070 case 0x1000 + 53: return "LVM_SETICONSPACING";
4071 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
4072 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
4073 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
4074 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
4075 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
4076 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
4077 case 0x1000 + 60: return "LVM_SETHOTITEM";
4078 case 0x1000 + 61: return "LVM_GETHOTITEM";
4079 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
4080 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
4081 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
4082 case 0x1000 + 65: return "LVM_SETWORKAREA";
4083
4084 // tree view
4085 case 0x1100 + 0: return "TVM_INSERTITEMA";
4086 case 0x1100 + 50: return "TVM_INSERTITEMW";
4087 case 0x1100 + 1: return "TVM_DELETEITEM";
4088 case 0x1100 + 2: return "TVM_EXPAND";
4089 case 0x1100 + 4: return "TVM_GETITEMRECT";
4090 case 0x1100 + 5: return "TVM_GETCOUNT";
4091 case 0x1100 + 6: return "TVM_GETINDENT";
4092 case 0x1100 + 7: return "TVM_SETINDENT";
4093 case 0x1100 + 8: return "TVM_GETIMAGELIST";
4094 case 0x1100 + 9: return "TVM_SETIMAGELIST";
4095 case 0x1100 + 10: return "TVM_GETNEXTITEM";
4096 case 0x1100 + 11: return "TVM_SELECTITEM";
4097 case 0x1100 + 12: return "TVM_GETITEMA";
4098 case 0x1100 + 62: return "TVM_GETITEMW";
4099 case 0x1100 + 13: return "TVM_SETITEMA";
4100 case 0x1100 + 63: return "TVM_SETITEMW";
4101 case 0x1100 + 14: return "TVM_EDITLABELA";
4102 case 0x1100 + 65: return "TVM_EDITLABELW";
4103 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
4104 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
4105 case 0x1100 + 17: return "TVM_HITTEST";
4106 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
4107 case 0x1100 + 19: return "TVM_SORTCHILDREN";
4108 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
4109 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
4110 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
4111 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
4112 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
4113 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
4114 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
4115
4116 // header
4117 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
4118 case 0x1200 + 1: return "HDM_INSERTITEMA";
4119 case 0x1200 + 10: return "HDM_INSERTITEMW";
4120 case 0x1200 + 2: return "HDM_DELETEITEM";
4121 case 0x1200 + 3: return "HDM_GETITEMA";
4122 case 0x1200 + 11: return "HDM_GETITEMW";
4123 case 0x1200 + 4: return "HDM_SETITEMA";
4124 case 0x1200 + 12: return "HDM_SETITEMW";
4125 case 0x1200 + 5: return "HDM_LAYOUT";
4126 case 0x1200 + 6: return "HDM_HITTEST";
4127 case 0x1200 + 7: return "HDM_GETITEMRECT";
4128 case 0x1200 + 8: return "HDM_SETIMAGELIST";
4129 case 0x1200 + 9: return "HDM_GETIMAGELIST";
4130 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
4131 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
4132 case 0x1200 + 17: return "HDM_GETORDERARRAY";
4133 case 0x1200 + 18: return "HDM_SETORDERARRAY";
4134 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
4135
4136 // tab control
4137 case 0x1300 + 2: return "TCM_GETIMAGELIST";
4138 case 0x1300 + 3: return "TCM_SETIMAGELIST";
4139 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
4140 case 0x1300 + 5: return "TCM_GETITEMA";
4141 case 0x1300 + 60: return "TCM_GETITEMW";
4142 case 0x1300 + 6: return "TCM_SETITEMA";
4143 case 0x1300 + 61: return "TCM_SETITEMW";
4144 case 0x1300 + 7: return "TCM_INSERTITEMA";
4145 case 0x1300 + 62: return "TCM_INSERTITEMW";
4146 case 0x1300 + 8: return "TCM_DELETEITEM";
4147 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
4148 case 0x1300 + 10: return "TCM_GETITEMRECT";
4149 case 0x1300 + 11: return "TCM_GETCURSEL";
4150 case 0x1300 + 12: return "TCM_SETCURSEL";
4151 case 0x1300 + 13: return "TCM_HITTEST";
4152 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
4153 case 0x1300 + 40: return "TCM_ADJUSTRECT";
4154 case 0x1300 + 41: return "TCM_SETITEMSIZE";
4155 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
4156 case 0x1300 + 43: return "TCM_SETPADDING";
4157 case 0x1300 + 44: return "TCM_GETROWCOUNT";
4158 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
4159 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
4160 case 0x1300 + 47: return "TCM_GETCURFOCUS";
4161 case 0x1300 + 48: return "TCM_SETCURFOCUS";
4162 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
4163 case 0x1300 + 50: return "TCM_DESELECTALL";
4164
4165 // toolbar
4166 case WM_USER+1000+1: return "TB_ENABLEBUTTON";
4167 case WM_USER+1000+2: return "TB_CHECKBUTTON";
4168 case WM_USER+1000+3: return "TB_PRESSBUTTON";
4169 case WM_USER+1000+4: return "TB_HIDEBUTTON";
4170 case WM_USER+1000+5: return "TB_INDETERMINATE";
4171 case WM_USER+1000+9: return "TB_ISBUTTONENABLED";
4172 case WM_USER+1000+10: return "TB_ISBUTTONCHECKED";
4173 case WM_USER+1000+11: return "TB_ISBUTTONPRESSED";
4174 case WM_USER+1000+12: return "TB_ISBUTTONHIDDEN";
4175 case WM_USER+1000+13: return "TB_ISBUTTONINDETERMINATE";
4176 case WM_USER+1000+17: return "TB_SETSTATE";
4177 case WM_USER+1000+18: return "TB_GETSTATE";
4178 case WM_USER+1000+19: return "TB_ADDBITMAP";
4179 case WM_USER+1000+20: return "TB_ADDBUTTONS";
4180 case WM_USER+1000+21: return "TB_INSERTBUTTON";
4181 case WM_USER+1000+22: return "TB_DELETEBUTTON";
4182 case WM_USER+1000+23: return "TB_GETBUTTON";
4183 case WM_USER+1000+24: return "TB_BUTTONCOUNT";
4184 case WM_USER+1000+25: return "TB_COMMANDTOINDEX";
4185 case WM_USER+1000+26: return "TB_SAVERESTOREA";
4186 case WM_USER+1000+76: return "TB_SAVERESTOREW";
4187 case WM_USER+1000+27: return "TB_CUSTOMIZE";
4188 case WM_USER+1000+28: return "TB_ADDSTRINGA";
4189 case WM_USER+1000+77: return "TB_ADDSTRINGW";
4190 case WM_USER+1000+29: return "TB_GETITEMRECT";
4191 case WM_USER+1000+30: return "TB_BUTTONSTRUCTSIZE";
4192 case WM_USER+1000+31: return "TB_SETBUTTONSIZE";
4193 case WM_USER+1000+32: return "TB_SETBITMAPSIZE";
4194 case WM_USER+1000+33: return "TB_AUTOSIZE";
4195 case WM_USER+1000+35: return "TB_GETTOOLTIPS";
4196 case WM_USER+1000+36: return "TB_SETTOOLTIPS";
4197 case WM_USER+1000+37: return "TB_SETPARENT";
4198 case WM_USER+1000+39: return "TB_SETROWS";
4199 case WM_USER+1000+40: return "TB_GETROWS";
4200 case WM_USER+1000+42: return "TB_SETCMDID";
4201 case WM_USER+1000+43: return "TB_CHANGEBITMAP";
4202 case WM_USER+1000+44: return "TB_GETBITMAP";
4203 case WM_USER+1000+45: return "TB_GETBUTTONTEXTA";
4204 case WM_USER+1000+75: return "TB_GETBUTTONTEXTW";
4205 case WM_USER+1000+46: return "TB_REPLACEBITMAP";
4206 case WM_USER+1000+47: return "TB_SETINDENT";
4207 case WM_USER+1000+48: return "TB_SETIMAGELIST";
4208 case WM_USER+1000+49: return "TB_GETIMAGELIST";
4209 case WM_USER+1000+50: return "TB_LOADIMAGES";
4210 case WM_USER+1000+51: return "TB_GETRECT";
4211 case WM_USER+1000+52: return "TB_SETHOTIMAGELIST";
4212 case WM_USER+1000+53: return "TB_GETHOTIMAGELIST";
4213 case WM_USER+1000+54: return "TB_SETDISABLEDIMAGELIST";
4214 case WM_USER+1000+55: return "TB_GETDISABLEDIMAGELIST";
4215 case WM_USER+1000+56: return "TB_SETSTYLE";
4216 case WM_USER+1000+57: return "TB_GETSTYLE";
4217 case WM_USER+1000+58: return "TB_GETBUTTONSIZE";
4218 case WM_USER+1000+59: return "TB_SETBUTTONWIDTH";
4219 case WM_USER+1000+60: return "TB_SETMAXTEXTROWS";
4220 case WM_USER+1000+61: return "TB_GETTEXTROWS";
4221 case WM_USER+1000+41: return "TB_GETBITMAPFLAGS";
4222
4223 default:
4224 static char s_szBuf[128];
4225 sprintf(s_szBuf, "<unknown message = %d>", nMessage);
4226 return s_szBuf;
4227 }
4228 return NULL;
4229 } // end of wxGetMessageName
4230
4231 #endif // __WXDEBUG__
4232
4233 static void TranslateKbdEventToMouse(
4234 wxWindow* pWin
4235 , int* pX
4236 , int* pY
4237 , ULONG* pFlags
4238 )
4239 {
4240 //
4241 // Construct the key mask
4242 ULONG& fwKeys = *pFlags;
4243
4244 fwKeys = VK_BUTTON2;
4245 if ((::WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x100) != 0)
4246 fwKeys |= VK_CTRL;
4247 if ((::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x100) != 0)
4248 fwKeys |= VK_SHIFT;
4249
4250 //
4251 // Simulate right mouse button click
4252 //
4253 POINTL vPoint;
4254
4255 ::WinQueryMsgPos(vHabmain, &vPoint);
4256 *pX = vPoint.x;
4257 *pY = vPoint.y;
4258
4259 pWin->ScreenToClient(pX, pY);
4260 } // end of TranslateKbdEventToMouse
4261
4262 // Find the wxWindow at the current mouse position, returning the mouse
4263 // position.
4264 wxWindow* wxFindWindowAtPointer(
4265 wxPoint& rPt
4266 )
4267 {
4268 return wxFindWindowAtPoint(wxGetMousePosition());
4269 }
4270
4271 wxWindow* wxFindWindowAtPoint(
4272 const wxPoint& rPt
4273 )
4274 {
4275 POINTL vPt2;
4276
4277 vPt2.x = rPt.x;
4278 vPt2.y = rPt.y;
4279
4280 HWND hWndHit = ::WinWindowFromPoint(HWND_DESKTOP, &vPt2, FALSE);
4281 wxWindow* pWin = wxFindWinFromHandle((WXHWND)hWndHit) ;
4282 HWND hWnd = hWndHit;
4283
4284 //
4285 // Try to find a window with a wxWindow associated with it
4286 //
4287 while (!pWin && (hWnd != 0))
4288 {
4289 hWnd = ::WinQueryWindow(hWnd, QW_PARENT);
4290 pWin = wxFindWinFromHandle((WXHWND)hWnd) ;
4291 }
4292 return pWin;
4293 }
4294
4295 // Get the current mouse position.
4296 wxPoint wxGetMousePosition()
4297 {
4298 POINTL vPt;
4299
4300 ::WinQueryPointerPos(HWND_DESKTOP, &vPt);
4301 return wxPoint(vPt.x, vPt.y);
4302 }
4303