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