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