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