3 // Author: David Webster
7 // Copyright: (c) David Webster
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
14 #include "wx/wxprec.h"
20 #include "wx/window.h"
25 #include "wx/dcclient.h"
29 #include "wx/layout.h"
30 #include "wx/checkbox.h"
31 #include "wx/combobox.h"
32 #include "wx/dialog.h"
34 #include "wx/listbox.h"
35 #include "wx/button.h"
36 #include "wx/bmpbuttn.h"
37 #include "wx/msgdlg.h"
38 #include "wx/scrolwin.h"
39 #include "wx/radiobox.h"
40 #include "wx/radiobut.h"
41 #include "wx/slider.h"
42 #include "wx/statbox.h"
43 #include "wx/statusbr.h"
44 #include "wx/toolbar.h"
45 #include "wx/settings.h"
50 #include "wx/ownerdrw.h"
53 #if wxUSE_DRAG_AND_DROP
57 #include "wx/menuitem.h"
60 #include "wx/os2/private.h"
63 #include "wx/tooltip.h"
67 #include "wx/notebook.h"
78 #include "wx/textctrl.h"
83 // Place compiler, OS specific includes here
87 // Standard macros -- these are for OS/2 PM, but most GUI's have something similar
91 // SHORT1FROMMP -- LOWORD
93 #define GET_X_LPARAM(mp) ((unsigned short)(unsigned long)(mp))
95 // SHORT2FROMMP -- HIWORD
97 #define GET_Y_LPARAM(mp) ((unsigned short)(unsigned long)(mp >> 16))
98 #endif // GET_X_LPARAM
100 #ifndef CW_USEDEFAULT
101 # define CW_USEDEFAULT ((int)0x80000000)
105 #define VK_OEM_1 0xBA
106 #define VK_OEM_PLUS 0xBB
107 #define VK_OEM_COMMA 0xBC
108 #define VK_OEM_MINUS 0xBD
109 #define VK_OEM_PERIOD 0xBE
110 #define VK_OEM_2 0xBF
111 #define VK_OEM_3 0xC0
112 #define VK_OEM_4 0xDB
113 #define VK_OEM_5 0xDC
114 #define VK_OEM_6 0xDD
115 #define VK_OEM_7 0xDE
118 // ---------------------------------------------------------------------------
120 // ---------------------------------------------------------------------------
123 // The last PM message we got (MT-UNSAFE)
127 #if wxUSE_MENUS_NATIVE
128 wxMenu
* wxCurrentPopupMenu
= NULL
;
129 #endif // wxUSE_MENUS_NATIVE
131 wxList
* wxWinHandleList
= NULL
;
133 // ---------------------------------------------------------------------------
135 // ---------------------------------------------------------------------------
138 // the window proc for all our windows; most gui's have something similar
140 MRESULT EXPENTRY
wxWndProc( HWND hWnd
147 const char *wxGetMessageName(int message
);
150 wxWindowOS2
* FindWindowForMouseEvent( wxWindow
* pWin
154 void wxRemoveHandleAssociation(wxWindowOS2
* pWin
);
155 void wxAssociateWinWithHandle( HWND hWnd
158 wxWindow
* wxFindWinFromHandle(WXHWND hWnd
);
161 // get the current state of SHIFT/CTRL keys
163 static inline bool IsShiftDown() { return (::WinGetKeyState(HWND_DESKTOP
, VK_SHIFT
) & 0x8000) != 0; }
164 static inline bool IsCtrlDown() { return (::WinGetKeyState(HWND_DESKTOP
, VK_CTRL
) & 0x8000) != 0; }
166 static wxWindow
* gpWinBeingCreated
= NULL
;
168 // ---------------------------------------------------------------------------
170 // ---------------------------------------------------------------------------
172 // in wxUniv-OS/2 this class is abstract because it doesn't have DoPopupMenu()
174 #ifdef __WXUNIVERSAL__
175 IMPLEMENT_ABSTRACT_CLASS(wxWindowOS2
, wxWindowBase
)
177 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
)
178 #endif // __WXUNIVERSAL__/__WXPM__
180 BEGIN_EVENT_TABLE(wxWindowOS2
, wxWindowBase
)
181 EVT_ERASE_BACKGROUND(wxWindowOS2::OnEraseBackground
)
182 EVT_SYS_COLOUR_CHANGED(wxWindowOS2::OnSysColourChanged
)
183 EVT_INIT_DIALOG(wxWindowOS2::OnInitDialog
)
184 EVT_IDLE(wxWindowOS2::OnIdle
)
185 EVT_SET_FOCUS(wxWindowOS2::OnSetFocus
)
188 // ===========================================================================
190 // ===========================================================================
192 // ---------------------------------------------------------------------------
193 // wxWindow utility functions
194 // ---------------------------------------------------------------------------
197 // Find an item given the PM Window id
199 wxWindow
* wxWindowOS2::FindItem(
204 wxControl
* pItem
= wxDynamicCast(this, wxControl
);
209 // I it we or one of our "internal" children?
211 if (pItem
->GetId() == lId
212 #ifndef __WXUNIVERSAL__
213 || (pItem
->GetSubcontrols().Index(lId
) != wxNOT_FOUND
)
220 #endif // wxUSE_CONTROLS
222 wxWindowList::Node
* pCurrent
= GetChildren().GetFirst();
226 wxWindow
* pChildWin
= pCurrent
->GetData();
227 wxWindow
* pWnd
= pChildWin
->FindItem(lId
);
232 pCurrent
= pCurrent
->GetNext();
235 } // end of wxWindowOS2::FindItem
238 // Find an item given the PM Window handle
240 wxWindow
* wxWindowOS2::FindItemByHWND(
245 wxWindowList::Node
* pCurrent
= GetChildren().GetFirst();
249 wxWindow
* pParent
= pCurrent
->GetData();
252 // Do a recursive search.
254 wxWindow
* pWnd
= pParent
->FindItemByHWND(hWnd
);
261 || pParent
->IsKindOf(CLASSINFO(wxControl
))
262 #endif // wxUSE_CONTROLS
265 wxWindow
* pItem
= pCurrent
->GetData();
267 if (pItem
->GetHWND() == hWnd
)
271 if (pItem
->ContainsHWND(hWnd
))
275 pCurrent
= pCurrent
->GetNext();
278 } // end of wxWindowOS2::FindItemByHWND
281 // Default command handler
283 bool wxWindowOS2::OS2Command(
284 WXUINT
WXUNUSED(uParam
)
285 , WXWORD
WXUNUSED(uId
)
291 // ----------------------------------------------------------------------------
292 // constructors and such
293 // ----------------------------------------------------------------------------
295 void wxWindowOS2::Init()
305 m_bWinCaptured
= FALSE
;
307 m_isBeingDeleted
= FALSE
;
308 m_fnOldWndProc
= NULL
;
310 m_bMouseInWindow
= FALSE
;
311 m_bLastKeydownProcessed
= FALSE
;
312 m_pChildrenDisabled
= NULL
;
319 m_hWndScrollBarHorz
= 0L;
320 m_hWndScrollBarVert
= 0L;
322 memset(&m_vWinSwp
, '\0', sizeof (SWP
));
325 // Pass WM_GETDLGCODE to DefWindowProc()
331 m_bBackgroundTransparent
= FALSE
;
334 // As all windows are created with WS_VISIBLE style...
338 #if wxUSE_MOUSEEVENT_HACK
341 m_nLastMouseEvent
= -1;
342 #endif // wxUSE_MOUSEEVENT_HACK
343 } // wxWindowOS2::Init
348 wxWindowOS2::~wxWindowOS2()
350 m_isBeingDeleted
= TRUE
;
352 for (wxWindow
* pWin
= GetParent(); pWin
; pWin
= pWin
->GetParent())
354 wxTopLevelWindow
* pFrame
= wxDynamicCast(pWin
, wxTopLevelWindow
);
358 if (pFrame
->GetLastFocus() == this)
359 pFrame
->SetLastFocus(NULL
);
366 m_parent
->RemoveChild(this);
370 if(!::WinDestroyWindow(GetHWND()))
371 wxLogLastError(wxT("DestroyWindow"));
373 // remove hWnd <-> wxWindow association
375 wxRemoveHandleAssociation(this);
377 delete m_pChildrenDisabled
;
378 } // end of wxWindowOS2::~wxWindowOS2
380 // real construction (Init() must have been called before!)
381 bool wxWindowOS2::Create(
384 , const wxPoint
& rPos
385 , const wxSize
& rSize
387 , const wxString
& rName
390 HWND hParent
= NULLHANDLE
;
391 ULONG ulCreateFlags
= 0;
392 WXDWORD dwExStyle
= 0;
394 wxCHECK_MSG(pParent
, FALSE
, wxT("can't create wxWindow without parent"));
398 // wxGTK doesn't allow to create controls with static box as the parent so
399 // this will result in a crash when the program is ported to wxGTK - warn
402 // the correct solution is to create the controls as siblings of the
405 wxASSERT_MSG( !wxDynamicCast(pParent
, wxStaticBox
),
406 _T("wxStaticBox can't be used as a window parent!") );
407 #endif // wxUSE_STATBOX
409 if ( !CreateBase( pParent
423 pParent
->AddChild(this);
424 hParent
= GetWinHwnd(pParent
);
426 if ( pParent
->IsKindOf(CLASSINFO(wxGenericScrolledWindow
)) ||
427 pParent
->IsKindOf(CLASSINFO(wxScrolledWindow
))
429 ulCreateFlags
|= WS_CLIPSIBLINGS
;
433 // Most wxSTYLES are really PM Class specific styles and will be
434 // set in those class create procs. PM's basic windows styles are
437 ulCreateFlags
|= OS2GetCreateWindowFlags(&dwExStyle
);
440 #ifdef __WXUNIVERSAL__
441 // no 3d effects, we draw them ourselves
443 #endif // !wxUniversal
444 if (lStyle
& wxPOPUP_WINDOW
)
446 ulCreateFlags
&= ~WS_VISIBLE
;
451 ulCreateFlags
|= WS_VISIBLE
;
455 // Generic OS/2 Windows have no Control Data but other classes
456 // that call OS2Create may have some.
458 return(OS2Create( (PSZ
)wxCanvasClassName
463 ,NULL
// Control Data
467 } // end of wxWindowOS2::Create
469 // ---------------------------------------------------------------------------
471 // ---------------------------------------------------------------------------
473 void wxWindowOS2::SetFocus()
475 HWND hWnd
= GetHwnd();
476 wxCHECK_RET( hWnd
, _T("can't set focus to invalid window") );
479 ::WinSetFocus(HWND_DESKTOP
, hWnd
);
480 } // end of wxWindowOS2::SetFocus
482 void wxWindowOS2::SetFocusFromKbd()
485 // Nothing else to do under OS/2
487 wxWindowBase::SetFocusFromKbd();
488 } // end of wxWindowOS2::SetFocus
490 wxWindow
* wxWindowBase::FindFocus()
492 HWND hWnd
= ::WinQueryFocus(HWND_DESKTOP
);
496 return wxFindWinFromHandle((WXHWND
)hWnd
);
499 } // wxWindowBase::FindFocus
501 bool wxWindowOS2::Enable(
505 if (!wxWindowBase::Enable(bEnable
))
508 HWND hWnd
= GetHwnd();
511 ::WinEnableWindow(hWnd
, (BOOL
)bEnable
);
514 // The logic below doesn't apply to the top level windows -- otherwise
515 // showing a modal dialog would result in total greying out (and ungreying
516 // out later) of everything which would be really ugly
521 wxWindowList::Node
* pNode
= GetChildren().GetFirst();
525 wxWindow
* pChild
= pNode
->GetData();
530 // Enable the child back unless it had been disabled before us
532 if (!m_pChildrenDisabled
|| !m_pChildrenDisabled
->Find(pChild
))
535 else // we're being disabled
537 if (pChild
->IsEnabled())
540 // Disable it as children shouldn't stay enabled while the
545 else // child already disabled, remember it
548 // Have we created the list of disabled children already?
550 if (!m_pChildrenDisabled
)
551 m_pChildrenDisabled
= new wxWindowList
;
552 m_pChildrenDisabled
->Append(pChild
);
555 pNode
= pNode
->GetNext();
557 if (bEnable
&& m_pChildrenDisabled
)
560 // We don't need this list any more, don't keep unused memory
562 delete m_pChildrenDisabled
;
563 m_pChildrenDisabled
= NULL
;
566 } // end of wxWindowOS2::Enable
568 bool wxWindowOS2::Show(
572 if (!wxWindowBase::Show(bShow
))
575 HWND hWnd
= GetHwnd();
577 ::WinShowWindow(hWnd
, bShow
);
581 ::WinSetWindowPos(hWnd
, HWND_TOP
, 0, 0, 0, 0, SWP_ACTIVATE
| SWP_ZORDER
);
584 } // end of wxWindowOS2::Show
586 void wxWindowOS2::Raise()
588 ::WinSetWindowPos(GetHwnd(), HWND_TOP
, 0, 0, 0, 0, SWP_ZORDER
| SWP_ACTIVATE
);
589 } // end of wxWindowOS2::Raise
591 void wxWindowOS2::Lower()
593 ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_ZORDER
| SWP_DEACTIVATE
);
594 } // end of wxWindowOS2::Lower
596 void wxWindowOS2::SetTitle(
597 const wxString
& rTitle
600 ::WinSetWindowText(GetHwnd(), rTitle
.c_str());
601 } // end of wxWindowOS2::SetTitle
603 wxString
wxWindowOS2::GetTitle() const
605 return wxGetWindowText(GetHWND());
606 } // end of wxWindowOS2::GetTitle
608 void wxWindowOS2::DoCaptureMouse()
610 HWND hWnd
= GetHwnd();
612 if (hWnd
&& !m_bWinCaptured
)
614 ::WinSetCapture(HWND_DESKTOP
, hWnd
);
615 m_bWinCaptured
= TRUE
;
617 } // end of wxWindowOS2::GetTitle
619 void wxWindowOS2::DoReleaseMouse()
623 ::WinSetCapture(HWND_DESKTOP
, NULLHANDLE
);
624 m_bWinCaptured
= FALSE
;
626 } // end of wxWindowOS2::ReleaseMouse
628 /* static */ wxWindow
* wxWindowBase::GetCapture()
630 HWND hwnd
= ::WinQueryCapture(HWND_DESKTOP
);
631 return hwnd
? wxFindWinFromHandle((WXHWND
)hwnd
) : (wxWindow
*)NULL
;
632 } // end of wxWindowBase::GetCapture
634 bool wxWindowOS2::SetFont(
638 if (!wxWindowBase::SetFont(rFont
))
644 HWND hWnd
= GetHwnd();
650 } // end of wxWindowOS2::SetFont
652 bool wxWindowOS2::SetCursor(
653 const wxCursor
& rCursor
654 ) // check if base implementation is OK
656 if ( !wxWindowBase::SetCursor(rCursor
))
662 if ( m_cursor
.Ok() ) {
663 HWND hWnd
= GetHwnd();
667 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
668 ::WinQueryWindowRect(hWnd
, &vRect
);
670 if (::WinPtInRect(vHabmain
, &vRect
, &vPoint
) && !wxIsBusy())
672 ::WinSetPointer(HWND_DESKTOP
, (HPOINTER
)m_cursor
.GetHCURSOR());
676 } // end of wxWindowOS2::SetCursor
678 void wxWindowOS2::WarpPointer(
687 ::WinQueryWindowRect(GetHwnd(), &vRect
);
691 ::WinSetPointerPos(HWND_DESKTOP
, (LONG
)nX
, (LONG
)(nY
));
692 } // end of wxWindowOS2::WarpPointer
695 // ---------------------------------------------------------------------------
697 // ---------------------------------------------------------------------------
699 int wxWindowOS2::GetScrollPos(
703 if (nOrient
== wxHORIZONTAL
)
704 return((int)::WinSendMsg(m_hWndScrollBarHorz
, SBM_QUERYPOS
, (MPARAM
)NULL
, (MPARAM
)NULL
));
706 return((int)::WinSendMsg(m_hWndScrollBarVert
, SBM_QUERYPOS
, (MPARAM
)NULL
, (MPARAM
)NULL
));
707 } // end of wxWindowOS2::GetScrollPos
709 int wxWindowOS2::GetScrollRange(
715 if (nOrient
== wxHORIZONTAL
)
716 mr
= ::WinSendMsg(m_hWndScrollBarHorz
, SBM_QUERYRANGE
, (MPARAM
)NULL
, (MPARAM
)NULL
);
718 mr
= ::WinSendMsg(m_hWndScrollBarVert
, SBM_QUERYRANGE
, (MPARAM
)NULL
, (MPARAM
)NULL
);
719 return((int)SHORT2FROMMR(mr
));
720 } // end of wxWindowOS2::GetScrollRange
722 int wxWindowOS2::GetScrollThumb(
726 if (nOrient
== wxHORIZONTAL
)
727 return m_nXThumbSize
;
729 return m_nYThumbSize
;
730 } // end of wxWindowOS2::GetScrollThumb
732 void wxWindowOS2::SetScrollPos(
735 , bool WXUNUSED(bRefresh
)
738 if (nOrient
== wxHORIZONTAL
)
739 ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETPOS
, (MPARAM
)nPos
, (MPARAM
)NULL
);
741 ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETPOS
, (MPARAM
)nPos
, (MPARAM
)NULL
);
742 } // end of wxWindowOS2::SetScrollPos
744 void wxWindowOS2::SetScrollbar(
749 , bool WXUNUSED(bRefresh
)
752 HWND hWnd
= GetHwnd();
753 int nOldRange
= nRange
- nThumbVisible
;
754 int nRange1
= nOldRange
;
755 int nPageSize
= nThumbVisible
;
758 ULONG ulStyle
= WS_VISIBLE
| WS_SYNCPAINT
;
764 wxWindow
* pParent
= GetParent();
766 if (pParent
&& pParent
->IsKindOf(CLASSINFO(wxFrame
)))
770 pFrame
= wxDynamicCast(pParent
, wxFrame
);
771 hWndParent
= pFrame
->GetFrame();
772 hWndClient
= GetHwndOf(pParent
);
777 hWndParent
= GetHwndOf(pParent
);
779 hWndParent
= GetHwnd();
780 hWndClient
= hWndParent
;
782 ::WinQueryWindowPos(hWndClient
, &vSwp
);
783 ::WinQueryWindowPos(hWnd
, &vSwpOwner
);
785 if (nPageSize
> 1 && nRange
> 0)
787 nRange1
+= (nPageSize
- 1);
790 vInfo
.cb
= sizeof(SBCDATA
);
792 vInfo
.posLast
= (SHORT
)nRange1
;
793 vInfo
.posThumb
= nPos
;
795 if (nOrient
== wxHORIZONTAL
)
798 if (m_hWndScrollBarHorz
== 0L)
801 // Since the scrollbars are usually created before the owner is
802 // sized either via an OnSize event directly or via sizers or
803 // layout constraints, we will initially just use the coords of
804 // the parent window (this is usually a frame client window). But
805 // the bars themselves, are children of the parent frame (i.e
806 // siblings of the frame client. The owner, however is the actual
807 // window being scrolled (or at least the one responsible for
808 // handling the scroll events). The owner will be resized later,
809 // as it is usually a child of a top level window, and when that
810 // is done its scrollbars will be resized and repositioned as well.
812 m_hWndScrollBarHorz
= ::WinCreateWindow( hWndParent
830 // The owner (the scrolled window) is a child of the Frame's
831 // client window, usually. The scrollbars are children of the
832 // frame, itself, and thus are positioned relative to the frame's
833 // origin, not the frame's client window origin.
834 // The starting x position is the same as the starting x position
835 // of the owner, but in terms of the parent frame.
836 // The starting y position is 20 pels below the origin of the
837 // owner in terms of the parent frame.
838 // The horz bar is the same width as the owner and 20 pels high.
840 if (nRange1
>= nThumbVisible
)
842 ::WinSetWindowPos( m_hWndScrollBarHorz
844 ,vSwp
.x
+ vSwpOwner
.x
845 ,(vSwp
.y
+ vSwpOwner
.y
) - 20
848 ,SWP_MOVE
| SWP_SIZE
| SWP_SHOW
| SWP_ACTIVATE
| SWP_ZORDER
850 ::WinSendMsg( m_hWndScrollBarHorz
853 ,MPFROM2SHORT(0, (SHORT
)nRange1
)
855 ::WinSendMsg( m_hWndScrollBarHorz
857 ,MPFROM2SHORT( (SHORT
)nThumbVisible
864 ::WinShowWindow(m_hWndScrollBarHorz
, FALSE
);
870 if (m_hWndScrollBarVert
== 0L)
873 // Since the scrollbars are usually created before the owner is
874 // sized either via an OnSize event directly or via sizers or
875 // layout constraints, we will initially just use the coords of
876 // the parent window (this is usually a frame client window). But
877 // the bars themselves, are children of the parent frame (i.e
878 // siblings of the frame client. The owner, however is the actual
879 // window being scrolled (or at least the one responsible for
880 // handling the scroll events). The owner will be resized later,
881 // as it is usually a child of a top level window, and when that
882 // is done its scrollbars will be resized and repositioned as well.
884 m_hWndScrollBarVert
= ::WinCreateWindow( hWndParent
888 ,vSwp
.x
+ vSwp
.cx
- 20
902 // The owner (the scrolled window) is a child of the Frame's
903 // client window, usually. The scrollbars are children of the
904 // frame, itself and thus are positioned relative to the frame's
905 // origin, not the frame's client window's origin.
906 // Thus, the x position will be frame client's x (usually a few
907 // pels inside the parent frame, plus the width of the owner.
908 // Since we may be using sizers or layout constraints for multiple
909 // child scrolled windows, the y position will be the frame client's
910 // y pos plus the scrolled windows y position, yielding the y
911 // position of the scrollbar relative to the parent frame (the vert
912 // scrollbar is on the right and starts at the bottom of the
914 // It is 20 pels wide and the same height as the owner.
916 if (nRange1
>= nThumbVisible
)
918 ::WinSetWindowPos( m_hWndScrollBarVert
920 ,vSwp
.x
+ vSwpOwner
.x
+ vSwpOwner
.cx
921 ,vSwp
.y
+ vSwpOwner
.y
924 ,SWP_ACTIVATE
| SWP_MOVE
| SWP_SIZE
| SWP_SHOW
926 ::WinSendMsg( m_hWndScrollBarVert
929 ,MPFROM2SHORT(0, (SHORT
)nRange1
)
931 ::WinSendMsg( m_hWndScrollBarVert
933 ,MPFROM2SHORT( (SHORT
)nThumbVisible
940 ::WinShowWindow(m_hWndScrollBarVert
, FALSE
);
942 m_nYThumbSize
= nThumbVisible
;
944 } // end of wxWindowOS2::SetScrollbar
946 void wxWindowOS2::ScrollWindow(
949 , const wxRect
* pRect
959 vRect
.xLeft
= pRect
->x
;
960 vRect
.yTop
= pRect
->y
+ pRect
->height
;
961 vRect
.xRight
= pRect
->x
+ pRect
->width
;
962 vRect
.yBottom
= pRect
->y
;
966 ::WinQueryWindowRect(GetHwnd(), &vRect
);
968 nDy
*= -1; // flip the sign of Dy as OS/2 is opposite Windows.
969 ::WinScrollWindow( GetHwnd()
976 ,SW_SCROLLCHILDREN
| SW_INVALIDATERGN
979 } // end of wxWindowOS2::ScrollWindow
981 // ---------------------------------------------------------------------------
983 // ---------------------------------------------------------------------------
985 void wxWindowOS2::SubclassWin(
989 HWND hwnd
= (HWND
)hWnd
;
991 wxCHECK_RET(::WinIsWindow(vHabmain
, hwnd
), wxT("invalid HWND in SubclassWin") );
992 wxAssociateWinWithHandle( hWnd
995 if (!wxCheckWindowWndProc( hWnd
996 ,(WXFARPROC
)wxWndProc
999 m_fnOldWndProc
= (WXFARPROC
) ::WinSubclassWindow(hwnd
, (PFNWP
)wxWndProc
);
1003 m_fnOldWndProc
= (WXFARPROC
)NULL
;
1005 } // end of wxWindowOS2::SubclassWin
1007 void wxWindowOS2::UnsubclassWin()
1010 // Restore old Window proc
1012 HWND hwnd
= GetHWND();
1016 wxCHECK_RET( ::WinIsWindow(vHabmain
, hwnd
), wxT("invalid HWND in UnsubclassWin") );
1018 PFNWP fnProc
= (PFNWP
)::WinQueryWindowPtr(hwnd
, QWP_PFNWP
);
1020 if ( (m_fnOldWndProc
!= 0) && (fnProc
!= (PFNWP
) m_fnOldWndProc
))
1022 WinSubclassWindow(hwnd
, (PFNWP
)m_fnOldWndProc
);
1026 } // end of wxWindowOS2::UnsubclassWin
1028 bool wxCheckWindowWndProc(
1030 , WXFARPROC fnWndProc
1033 static char zBuffer
[512];
1036 ::WinQueryClassName((HWND
)hWnd
, (LONG
)512, (PCH
)zBuffer
);
1037 ::WinQueryClassInfo(wxGetInstance(), (PSZ
)zBuffer
, &vCls
);
1038 return(fnWndProc
== (WXFARPROC
)vCls
.pfnWindowProc
);
1039 } // end of WinGuiBase_CheckWindowWndProc
1041 void wxWindowOS2::SetWindowStyleFlag(
1045 long lFlagsOld
= GetWindowStyleFlag();
1047 if (lFlags
== lFlagsOld
)
1051 // Update the internal variable
1053 wxWindowBase::SetWindowStyleFlag(lFlags
);
1056 // Now update the Windows style as well if needed - and if the window had
1057 // been already created
1063 WXDWORD dwExstyleOld
;
1064 long lStyle
= OS2GetStyle( lFlags
1067 long lStyleOld
= OS2GetStyle( lFlagsOld
1071 if (lStyle
!= lStyleOld
)
1074 // Some flags (e.g. WS_VISIBLE or WS_DISABLED) should not be changed by
1075 // this function so instead of simply setting the style to the new
1076 // value we clear the bits which were set in styleOld but are set in
1077 // the new one and set the ones which were not set before
1079 long lStyleReal
= ::WinQueryWindowULong(GetHwnd(), QWL_STYLE
);
1081 lStyleReal
&= ~lStyleOld
;
1082 lStyleReal
|= lStyle
;
1084 ::WinSetWindowULong(GetHwnd(), QWL_STYLE
, lStyleReal
);
1086 } // end of wxWindowOS2::SetWindowStyleFlag
1088 WXDWORD
wxWindowOS2::OS2GetStyle(
1090 , WXDWORD
* pdwExstyle
1093 WXDWORD dwStyle
= 0L;
1095 if (lFlags
& wxCLIP_CHILDREN
)
1096 dwStyle
|= WS_CLIPCHILDREN
;
1098 if (lFlags
& wxCLIP_SIBLINGS
)
1099 dwStyle
|= WS_CLIPSIBLINGS
;
1102 } // end of wxWindowMSW::MSWGetStyle
1105 // Make a Windows extended style from the given wxWindows window style
1107 WXDWORD
wxWindowOS2::MakeExtendedStyle(
1109 , bool bEliminateBorders
1113 // Simply fill out with wxWindow extended styles. We'll conjure
1114 // something up in OS2Create and all window redrawing pieces later
1116 WXDWORD dwStyle
= 0;
1118 if (lStyle
& wxTRANSPARENT_WINDOW
)
1119 dwStyle
|= wxTRANSPARENT_WINDOW
;
1121 if (!bEliminateBorders
)
1123 if (lStyle
& wxSUNKEN_BORDER
)
1124 dwStyle
|= wxSUNKEN_BORDER
;
1125 if (lStyle
& wxDOUBLE_BORDER
)
1126 dwStyle
|= wxDOUBLE_BORDER
;
1127 if (lStyle
& wxRAISED_BORDER
)
1128 dwStyle
|= wxRAISED_BORDER
;
1129 if (lStyle
& wxSTATIC_BORDER
)
1130 dwStyle
|= wxSTATIC_BORDER
;
1133 } // end of wxWindowOS2::MakeExtendedStyle
1136 // Determines whether simulated 3D effects or CTL3D should be used,
1137 // applying a default border style if required, and returning an extended
1138 // style to pass to OS2Create.
1140 WXDWORD
wxWindowOS2::Determine3DEffects(
1141 WXDWORD dwDefaultBorderStyle
1145 WXDWORD dwStyle
= 0L;
1148 // Native PM does not have any specialize 3D effects like WIN32 does,
1149 // so we have to try and invent them.
1153 // If matches certain criteria, then assume no 3D effects
1154 // unless specifically requested (dealt with in MakeExtendedStyle)
1157 !IsKindOf(CLASSINFO(wxControl
)) ||
1158 (m_windowStyle
& wxNO_BORDER
)
1162 return MakeExtendedStyle(m_windowStyle
, FALSE
);
1166 // 1) App can specify global 3D effects
1168 *pbWant3D
= wxTheApp
->GetAuto3D();
1171 // 2) If the parent is being drawn with user colours, or simple border
1172 // specified, switch effects off.
1175 (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS
) ||
1176 (m_windowStyle
& wxSIMPLE_BORDER
)
1181 // 3) Control can override this global setting by defining
1182 // a border style, e.g. wxSUNKEN_BORDER
1184 if ((m_windowStyle
& wxDOUBLE_BORDER
) ||
1185 (m_windowStyle
& wxRAISED_BORDER
) ||
1186 (m_windowStyle
& wxSTATIC_BORDER
) ||
1187 (m_windowStyle
& wxSUNKEN_BORDER
)
1191 dwStyle
= MakeExtendedStyle( m_windowStyle
1196 // If we want 3D, but haven't specified a border here,
1197 // apply the default border style specified.
1199 if (dwDefaultBorderStyle
&& (*pbWant3D
) &&
1200 !((m_windowStyle
& wxDOUBLE_BORDER
) ||
1201 (m_windowStyle
& wxRAISED_BORDER
) ||
1202 (m_windowStyle
& wxSTATIC_BORDER
) ||
1203 (m_windowStyle
& wxSIMPLE_BORDER
)
1206 dwStyle
|= dwDefaultBorderStyle
;
1208 } // end of wxWindowOS2::Determine3DEffects
1211 // Setup background and foreground colours correctly
1213 void wxWindowOS2::SetupColours()
1216 SetBackgroundColour(GetParent()->GetBackgroundColour());
1217 } // end of wxWindowOS2::SetupColours
1219 void wxWindowOS2::OnIdle(
1220 wxIdleEvent
& WXUNUSED(rEvent
)
1224 // Check if we need to send a LEAVE event
1226 if (m_bMouseInWindow
)
1230 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
1231 if (::WinWindowFromPoint(HWND_DESKTOP
, &vPoint
, FALSE
) != (HWND
)GetHwnd())
1234 // Generate a LEAVE event
1236 m_bMouseInWindow
= FALSE
;
1239 // Unfortunately the mouse button and keyboard state may have changed
1240 // by the time the OnIdle function is called, so 'state' may be
1245 if (::WinGetKeyState(HWND_DESKTOP
, VK_SHIFT
) != 0)
1247 if (::WinGetKeyState(HWND_DESKTOP
, VK_CTRL
) != 0);
1250 wxMouseEvent
rEvent(wxEVT_LEAVE_WINDOW
);
1252 InitMouseEvent( rEvent
1257 (void)GetEventHandler()->ProcessEvent(rEvent
);
1260 if (wxUpdateUIEvent::CanUpdate(this))
1261 UpdateWindowUI(wxUPDATE_UI_FROMIDLE
);
1262 } // end of wxWindowOS2::OnIdle
1265 // Set this window to be the child of 'parent'.
1267 bool wxWindowOS2::Reparent(
1271 if (!wxWindowBase::Reparent(pParent
))
1274 HWND hWndChild
= GetHwnd();
1275 HWND hWndParent
= GetParent() ? GetWinHwnd(GetParent()) : (HWND
)0;
1277 ::WinSetParent(hWndChild
, hWndParent
, TRUE
);
1279 } // end of wxWindowOS2::Reparent
1281 void wxWindowOS2::Update()
1283 ::WinUpdateWindow(GetHwnd());
1284 } // end of wxWindowOS2::Update
1286 void wxWindowOS2::Freeze()
1288 ::WinSendMsg(GetHwnd(), WM_VRNDISABLED
, (MPARAM
)0, (MPARAM
)0);
1289 } // end of wxWindowOS2::Freeze
1291 void wxWindowOS2::Thaw()
1293 ::WinSendMsg(GetHwnd(), WM_VRNENABLED
, (MPARAM
)TRUE
, (MPARAM
)0);
1296 // We need to refresh everything or otherwise he invalidated area is not
1300 } // end of wxWindowOS2::Thaw
1302 void wxWindowOS2::Refresh(
1304 , const wxRect
* pRect
1307 HWND hWnd
= GetHwnd();
1315 vOs2Rect
.xLeft
= pRect
->x
;
1316 vOs2Rect
.yTop
= pRect
->y
;
1317 vOs2Rect
.xRight
= pRect
->x
+ pRect
->width
;
1318 vOs2Rect
.yBottom
= pRect
->y
+ pRect
->height
;
1320 ::WinInvalidateRect(hWnd
, &vOs2Rect
, bEraseBack
);
1323 ::WinInvalidateRect(hWnd
, NULL
, bEraseBack
);
1324 if (m_hWndScrollBarHorz
!= NULLHANDLE
)
1325 ::WinInvalidateRect(m_hWndScrollBarHorz
, NULL
, TRUE
);
1326 if (m_hWndScrollBarVert
!= NULLHANDLE
)
1327 ::WinInvalidateRect(m_hWndScrollBarVert
, NULL
, TRUE
);
1329 } // end of wxWindowOS2::Refresh
1331 // ---------------------------------------------------------------------------
1333 // ---------------------------------------------------------------------------
1335 #if wxUSE_DRAG_AND_DROP
1336 void wxWindowOS2::SetDropTarget(
1337 wxDropTarget
* pDropTarget
1340 m_dropTarget
= pDropTarget
;
1341 } // end of wxWindowOS2::SetDropTarget
1345 // old style file-manager drag&drop support: we retain the old-style
1346 // DragAcceptFiles in parallel with SetDropTarget.
1348 void wxWindowOS2::DragAcceptFiles(
1352 HWND hWnd
= GetHwnd();
1354 if (hWnd
&& bAccept
)
1355 ::DrgAcceptDroppedFiles(hWnd
, NULL
, NULL
, DO_COPY
, 0L);
1356 } // end of wxWindowOS2::DragAcceptFiles
1358 // ----------------------------------------------------------------------------
1360 // ----------------------------------------------------------------------------
1364 void wxWindowOS2::DoSetToolTip(
1368 wxWindowBase::DoSetToolTip(pTooltip
);
1371 m_tooltip
->SetWindow(this);
1372 } // end of wxWindowOS2::DoSetToolTip
1374 #endif // wxUSE_TOOLTIPS
1376 // ---------------------------------------------------------------------------
1377 // moving and resizing
1378 // ---------------------------------------------------------------------------
1381 void wxWindowOS2::DoGetSize(
1389 if (IsKindOf(CLASSINFO(wxFrame
)))
1391 wxFrame
* pFrame
= wxDynamicCast(this, wxFrame
);
1392 hWnd
= pFrame
->GetFrame();
1397 ::WinQueryWindowRect(hWnd
, &vRect
);
1400 *pWidth
= vRect
.xRight
- vRect
.xLeft
;
1402 // OS/2 PM is backwards from windows
1403 *pHeight
= vRect
.yTop
- vRect
.yBottom
;
1404 } // end of wxWindowOS2::DoGetSize
1406 void wxWindowOS2::DoGetPosition(
1411 HWND hWnd
= GetHwnd();
1414 wxWindow
* pParent
= GetParent();
1417 // It would seem that WinQueryWindowRect would be the correlary to
1418 // the WIN32 WinGetRect, but unlike WinGetRect which returns the window
1419 // origin position in screen coordinates, WinQueryWindowRect returns it
1420 // relative to itself, i.e. (0,0). To get the same under PM we must
1421 // us WinQueryWindowPos. This call, unlike the WIN32 call, however,
1422 // returns a position relative to it's parent, so no parent adujstments
1423 // are needed under OS/2. Also, windows should be created using
1424 // wxWindow coordinates, i.e 0,0 is the TOP left so vSwp will already
1427 ::WinQueryWindowPos(hWnd
, &vSwp
);
1433 // We may be faking the client origin. So a window that's really at (0,
1434 // 30) may appear (to wxWin apps) to be at (0, 0).
1438 wxPoint
vPt(pParent
->GetClientAreaOrigin());
1448 } // end of wxWindowOS2::DoGetPosition
1450 void wxWindowOS2::DoScreenToClient(
1455 HWND hWnd
= GetHwnd();
1458 ::WinQueryWindowPos(hWnd
, &vSwp
);
1464 } // end of wxWindowOS2::DoScreenToClient
1466 void wxWindowOS2::DoClientToScreen(
1471 HWND hWnd
= GetHwnd();
1474 ::WinQueryWindowPos(hWnd
, &vSwp
);
1480 } // end of wxWindowOS2::DoClientToScreen
1483 // Get size *available for subwindows* i.e. excluding menu bar etc.
1484 // Must be a frame type window
1486 void wxWindowOS2::DoGetClientSize(
1491 HWND hWnd
= GetHwnd();
1494 ::WinQueryWindowRect(hWnd
, &vRect
);
1495 if (IsKindOf(CLASSINFO(wxDialog
)))
1500 // For a Dialog we have to explicitly request the client portion.
1501 // For a Frame the hWnd IS the client window
1503 hWndTitle
= ::WinWindowFromID(hWnd
, FID_TITLEBAR
);
1504 if (::WinQueryWindowRect(hWndTitle
, &vTitle
))
1506 if (vTitle
.yTop
- vTitle
.yBottom
== 0)
1509 // Dialog has not been created yet, use a default
1513 vRect
.yTop
-= (vTitle
.yTop
- vTitle
.yBottom
);
1516 ULONG uStyle
= ::WinQueryWindowULong(hWnd
, QWL_STYLE
);
1519 // Deal with borders
1521 if (uStyle
& FCF_DLGBORDER
)
1528 else if (uStyle
& FCF_SIZEBORDER
)
1535 else if (uStyle
& FCF_BORDER
)
1542 else // make some kind of adjustment or top sizers ram into the titlebar!
1551 *pWidth
= vRect
.xRight
- vRect
.xLeft
;
1553 *pHeight
= vRect
.yTop
- vRect
.yBottom
;
1554 } // end of wxWindowOS2::DoGetClientSize
1556 void wxWindowOS2::DoMoveWindow(
1565 wxWindow
* pParent
= GetParent();
1567 if (pParent
&& !IsKindOf(CLASSINFO(wxDialog
)))
1569 int nOS2Height
= GetOS2ParentHeight(pParent
);
1571 nY
= nOS2Height
- (nY
+ nHeight
);
1577 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
1578 nY
= vRect
.yTop
- (nY
+ nHeight
);
1582 // In the case of a frame whose client is sized, the client cannot be
1583 // large than its parent frame minus its borders! This usually happens
1584 // when using an autosizer to size a frame to precisely hold client
1585 // controls as in the notebook sample.
1587 // In this case, we may need to resize both a frame and its client so we
1588 // need a quick calc of the frame border size, then if the frame
1589 // (less its borders) is smaller than the client, size the frame to
1590 // encompass the client with the appropriate border size.
1592 if (IsKindOf(CLASSINFO(wxFrame
)))
1596 int nWidthFrameDelta
= 0;
1597 int nHeightFrameDelta
= 0;
1598 int nHeightFrame
= 0;
1599 int nWidthFrame
= 0;
1600 ULONG ulFLag
= SWP_MOVE
;
1603 pFrame
= wxDynamicCast(this, wxFrame
);
1604 hWndFrame
= pFrame
->GetFrame();
1605 ::WinQueryWindowRect(hWndFrame
, &vRect
);
1606 ::WinMapWindowPoints(hWndFrame
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
1608 ::WinCalcFrameRect(hWndFrame
, &vRect
, TRUE
);
1609 nWidthFrameDelta
= ((vRect
.xLeft
- vFRect
.xLeft
) + (vFRect
.xRight
- vRect
.xRight
));
1610 nHeightFrameDelta
= ((vRect
.yBottom
- vFRect
.yBottom
) + (vFRect
.yTop
- vRect
.yTop
));
1611 nWidthFrame
= vFRect
.xRight
- vFRect
.xLeft
;
1612 nHeightFrame
= vFRect
.yTop
- vFRect
.yBottom
;
1614 if (nWidth
== vFRect
.xRight
- vFRect
.xLeft
&&
1615 nHeight
== vFRect
.yTop
- vFRect
.yBottom
)
1618 // In this case the caller is not aware of OS/2's need to size both
1619 // the frame and it's client and is really only moving the window,
1620 // not resizeing it. So move the frame, and back off the sizes
1621 // for a proper client fit.
1623 ::WinSetWindowPos( hWndFrame
1625 ,(LONG
)nX
- (vRect
.xLeft
- vFRect
.xLeft
)
1626 ,(LONG
)nY
- (vRect
.yBottom
- vFRect
.yBottom
)
1631 nX
+= (vRect
.xLeft
- vFRect
.xLeft
);
1632 nY
+= (vRect
.yBottom
- vFRect
.yBottom
);
1633 nWidth
-= nWidthFrameDelta
;
1634 nHeight
-= nHeightFrameDelta
;
1638 if (nWidth
> nWidthFrame
- nHeightFrameDelta
||
1639 nHeight
> nHeightFrame
- nHeightFrameDelta
)
1641 ::WinSetWindowPos( hWndFrame
1643 ,(LONG
)nX
- (vRect
.xLeft
- vFRect
.xLeft
)
1644 ,(LONG
)nY
- (vRect
.yBottom
- vFRect
.yBottom
)
1645 ,(LONG
)nWidth
+ nWidthFrameDelta
1646 ,(LONG
)nHeight
+ nHeightFrameDelta
1647 ,SWP_MOVE
| SWP_SIZE
1653 ::WinSetWindowPos( GetHwnd()
1659 ,SWP_SIZE
| SWP_MOVE
1661 if (m_vWinSwp
.cx
== 0 && m_vWinSwp
.cy
== 0 && m_vWinSwp
.fl
== 0)
1665 ::WinQueryWindowPos(GetHwnd(), &m_vWinSwp
);
1668 int nYDiff
= m_vWinSwp
.cy
- nHeight
;
1671 // Handle resizing of scrolled windows. The target or window to
1672 // be scrolled is the owner (gets the scroll notificaitons). The
1673 // parent is usually the parent frame of the scrolled panel window.
1674 // In order to show the scrollbars the target window will be shrunk
1675 // by the size of the scroll bar widths (20) and moved in the X and Y
1676 // directon. That value will be computed as part of the diff for
1677 // moving the children. Everytime the window is sized the
1678 // toplevel OnSize is going to resize the panel to fit the client
1679 // or the whole sizer and will need to me resized. This will send
1680 // a WM_SIZE out which will be intercepted by the ScrollHelper
1681 // which will cause the scrollbars to be displayed via the SetScrollbar
1684 if ( IsKindOf(CLASSINFO(wxGenericScrolledWindow
)) ||
1685 IsKindOf(CLASSINFO(wxScrolledWindow
))
1688 int nAdjustWidth
= 0;
1689 int nAdjustHeight
= 0;
1692 if (GetScrollBarHorz() == NULLHANDLE
||
1693 !WinIsWindowShowing(GetScrollBarHorz()))
1696 nAdjustHeight
= 20L;
1697 if (GetScrollBarVert() == NULLHANDLE
||
1698 !WinIsWindowShowing(GetScrollBarVert()))
1702 ::WinQueryWindowPos(GetHWND(), &vSwpScroll
);
1703 ::WinSetWindowPos( GetHWND()
1706 ,vSwpScroll
.y
+ nAdjustHeight
1707 ,vSwpScroll
.cx
- nAdjustWidth
1708 ,vSwpScroll
.cy
- nAdjustHeight
1709 ,SWP_MOVE
| SWP_SIZE
1711 nYDiff
+= nAdjustHeight
;
1713 MoveChildren(nYDiff
);
1714 ::WinQueryWindowPos(GetHwnd(), &m_vWinSwp
);
1716 } // end of wxWindowOS2::DoMoveWindow
1719 // Set the size of the window: if the dimensions are positive, just use them,
1720 // but if any of them is equal to -1, it means that we must find the value for
1721 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
1722 // which case -1 is a valid value for x and y)
1724 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
1725 // the width/height to best suit our contents, otherwise we reuse the current
1728 void wxWindowOS2::DoSetSize(
1737 // Get the current size and position...
1743 wxSize
vSize(-1, -1);
1745 GetPosition(&nCurrentX
, &nCurrentY
);
1746 GetSize(&nCurrentWidth
, &nCurrentHeight
);
1749 // ... and don't do anything (avoiding flicker) if it's already ok
1752 // Must convert Y coords to test for equality under OS/2
1755 wxWindow
* pParent
= (wxWindow
*)GetParent();
1757 if (nX
== nCurrentX
&& nY2
== nCurrentY
&&
1758 nWidth
== nCurrentWidth
&& nHeight
== nCurrentHeight
)
1763 if (nX
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
1765 if (nY
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
1768 AdjustForParentClientOrigin(nX
, nY
, nSizeFlags
);
1772 if (nSizeFlags
& wxSIZE_AUTO_WIDTH
)
1774 vSize
= DoGetBestSize();
1780 // Just take the current one
1782 nWidth
= nCurrentWidth
;
1788 if (nSizeFlags
& wxSIZE_AUTO_HEIGHT
)
1792 vSize
= DoGetBestSize();
1798 // just take the current one
1799 nHeight
= nCurrentHeight
;
1808 } // end of wxWindowOS2::DoSetSize
1810 void wxWindowOS2::DoSetClientSize(
1818 wxWindow
* pParent
= (wxWindow
*)GetParent();
1819 HWND hParentWnd
= (HWND
)0;
1822 hParentWnd
= (HWND
)pParent
->GetHWND();
1824 if (IsKindOf(CLASSINFO(wxFrame
)))
1826 wxFrame
* pFrame
= wxDynamicCast(this, wxFrame
);
1827 HWND hFrame
= pFrame
->GetFrame();
1832 ::WinQueryWindowRect(GetHwnd(), &vRect2
);
1833 ::WinQueryWindowRect(hFrame
, &vRect
);
1834 ::WinQueryWindowRect(hParentWnd
, &vRect3
);
1835 nActualWidth
= vRect2
.xRight
- vRect2
.xLeft
- vRect
.xRight
+ nWidth
;
1836 nActualHeight
= vRect2
.yTop
- vRect2
.yBottom
- vRect
.yTop
+ nHeight
;
1838 vPoint
.x
= vRect2
.xLeft
;
1839 vPoint
.y
= vRect2
.yBottom
;
1842 vPoint
.x
-= vRect3
.xLeft
;
1843 vPoint
.y
-= vRect3
.yBottom
;
1851 GetPosition(&nX
, &nY
);
1852 nActualWidth
= nWidth
;
1853 nActualHeight
= nHeight
;
1858 DoMoveWindow( vPoint
.x
1864 wxSizeEvent
vEvent( wxSize( nWidth
1870 vEvent
.SetEventObject(this);
1871 GetEventHandler()->ProcessEvent(vEvent
);
1872 } // end of wxWindowOS2::DoSetClientSize
1874 wxPoint
wxWindowOS2::GetClientAreaOrigin() const
1876 return wxPoint(0, 0);
1877 } // end of wxWindowOS2::GetClientAreaOrigin
1879 // ---------------------------------------------------------------------------
1881 // ---------------------------------------------------------------------------
1883 int wxWindowOS2::GetCharHeight() const
1886 FONTMETRICS vFontMetrics
;
1888 hPs
= ::WinGetPS(GetHwnd());
1890 if(!GpiQueryFontMetrics(hPs
, sizeof(FONTMETRICS
), &vFontMetrics
))
1892 ::WinReleasePS(hPs
);
1895 ::WinReleasePS(hPs
);
1896 return(vFontMetrics
.lMaxAscender
+ vFontMetrics
.lMaxDescender
);
1897 } // end of wxWindowOS2::GetCharHeight
1899 int wxWindowOS2::GetCharWidth() const
1902 FONTMETRICS vFontMetrics
;
1904 hPs
= ::WinGetPS(GetHwnd());
1906 if(!GpiQueryFontMetrics(hPs
, sizeof(FONTMETRICS
), &vFontMetrics
))
1908 ::WinReleasePS(hPs
);
1911 ::WinReleasePS(hPs
);
1912 return(vFontMetrics
.lAveCharWidth
);
1913 } // end of wxWindowOS2::GetCharWidth
1915 void wxWindowOS2::GetTextExtent(
1916 const wxString
& rString
1920 , int* pExternalLeading
1921 , const wxFont
* pTheFont
1924 POINTL avPoint
[TXTBOX_COUNT
];
1929 FONTMETRICS vFM
; // metrics structure
1932 ERRORID vErrorCode
; // last error id code
1936 hPS
= ::WinGetPS(GetHwnd());
1938 l
= rString
.Length();
1941 pStr
= (PCH
)rString
.c_str();
1944 // In world coordinates.
1946 bRc
= ::GpiQueryTextBox( hPS
1949 ,TXTBOX_COUNT
// return maximum information
1950 ,avPoint
// array of coordinates points
1954 vPtMin
.x
= avPoint
[0].x
;
1955 vPtMax
.x
= avPoint
[0].x
;
1956 vPtMin
.y
= avPoint
[0].y
;
1957 vPtMax
.y
= avPoint
[0].y
;
1958 for (i
= 1; i
< 4; i
++)
1960 if(vPtMin
.x
> avPoint
[i
].x
) vPtMin
.x
= avPoint
[i
].x
;
1961 if(vPtMin
.y
> avPoint
[i
].y
) vPtMin
.y
= avPoint
[i
].y
;
1962 if(vPtMax
.x
< avPoint
[i
].x
) vPtMax
.x
= avPoint
[i
].x
;
1963 if(vPtMax
.y
< avPoint
[i
].y
) vPtMax
.y
= avPoint
[i
].y
;
1965 bRc
= ::GpiQueryFontMetrics( hPS
1966 ,sizeof(FONTMETRICS
)
1993 *pX
= (vPtMax
.x
- vPtMin
.x
+ 1);
1995 *pY
= (vPtMax
.y
- vPtMin
.y
+ 1);
1999 *pDescent
= vFM
.lMaxDescender
;
2003 if (pExternalLeading
)
2006 *pExternalLeading
= vFM
.lExternalLeading
;
2008 *pExternalLeading
= 0;
2010 ::WinReleasePS(hPS
);
2011 } // end of wxWindow::GetTextExtent
2013 bool wxWindowOS2::IsMouseInWindow() const
2016 // Get the mouse position
2019 ::WinQueryPointerPos(HWND_DESKTOP
, &vPt
);
2022 // Find the window which currently has the cursor and go up the window
2023 // chain until we find this window - or exhaust it
2025 HWND hWnd
= ::WinWindowFromPoint(HWND_DESKTOP
, &vPt
, TRUE
);
2027 while (hWnd
&& (hWnd
!= GetHwnd()))
2028 hWnd
= ::WinQueryWindow(hWnd
, QW_PARENT
);
2030 return hWnd
!= NULL
;
2031 } // end of wxWindowOS2::IsMouseInWindow
2034 // ---------------------------------------------------------------------------
2036 // ---------------------------------------------------------------------------
2038 #if wxUSE_MENUS_NATIVE
2039 static void wxYieldForCommandsOnly()
2042 // Peek all WM_COMMANDs (it will always return WM_QUIT too but we don't
2043 // want to process it here)
2047 while (::WinPeekMsg(vHabmain
, &vMsg
, (HWND
)0, WM_COMMAND
, WM_COMMAND
, PM_REMOVE
)
2048 && vMsg
.msg
!= WM_QUIT
)
2050 wxTheApp
->DoMessage((WXMSG
*)&vMsg
);
2052 if (vMsg
.msg
== WM_QUIT
)
2053 ::WinPostMsg(NULL
, WM_QUIT
, 0, 0);
2055 #endif // wxUSE_MENUS_NATIVE
2057 #if wxUSE_MENUS_NATIVE
2058 bool wxWindowOS2::DoPopupMenu(
2064 HWND hWndOwner
= GetHwnd();
2065 HWND hWndParent
= GetHwnd();
2066 HWND hMenu
= GetHmenuOf(pMenu
);
2067 bool bIsWaiting
= TRUE
;
2069 pMenu
->SetInvokingWindow(this);
2072 DoClientToScreen( &nX
2075 wxCurrentPopupMenu
= pMenu
;
2077 ::WinPopupMenu( hWndParent
2083 ,PU_HCONSTRAIN
| PU_VCONSTRAIN
| PU_MOUSEBUTTON1
| PU_KEYBOARD
2089 BOOL bRc
= ::WinGetMsg(vHabmain
, &vMsg
, HWND(NULL
), 0, 0);
2091 if (vMsg
.msg
== WM_MENUEND
|| vMsg
.msg
== WM_COMMAND
)
2095 ::WinDispatchMsg(vHabmain
, (PQMSG
)&vMsg
);
2098 wxCurrentPopupMenu
= NULL
;
2099 pMenu
->SetInvokingWindow(NULL
);
2101 } // end of wxWindowOS2::DoPopupMenu
2102 #endif // wxUSE_MENUS_NATIVE
2104 // ===========================================================================
2105 // pre/post message processing
2106 // ===========================================================================
2108 MRESULT
wxWindowOS2::OS2DefWindowProc(
2115 return (MRESULT
)m_fnOldWndProc(GetHWND(), uMsg
, (MPARAM
)wParam
, (MPARAM
)lParam
);
2117 return ::WinDefWindowProc(GetHWND(), uMsg
, (MPARAM
)wParam
, (MPARAM
)lParam
);
2118 } // end of wxWindowOS2::OS2DefWindowProc
2120 bool wxWindowOS2::OS2ProcessMessage(
2124 // wxUniversal implements tab traversal itself
2125 #ifndef __WXUNIVERSAL__
2126 QMSG
* pQMsg
= (QMSG
*)pMsg
;
2128 if (m_hWnd
!= 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL
))
2131 // Intercept dialog navigation keys
2133 bool bProcess
= TRUE
;
2134 USHORT uKeyFlags
= SHORT1FROMMP(pQMsg
->mp1
);
2136 if (uKeyFlags
& KC_KEYUP
)
2139 if (uKeyFlags
& KC_ALT
)
2142 if (!(uKeyFlags
& KC_VIRTUALKEY
))
2147 bool bCtrlDown
= IsCtrlDown();
2148 bool bShiftDown
= IsShiftDown();
2151 // WM_QUERYDLGCODE: ask the control if it wants the key for itself,
2152 // don't process it if it's the case (except for Ctrl-Tab/Enter
2153 // combinations which are always processed)
2155 ULONG ulDlgCode
= 0;
2159 ulDlgCode
= (ULONG
)::WinSendMsg(pQMsg
->hwnd
, WM_QUERYDLGCODE
, pQMsg
, 0);
2162 bool bForward
= TRUE
;
2163 bool bWindowChange
= FALSE
;
2165 switch (SHORT2FROMMP(pQMsg
->mp2
))
2168 // Going to make certain assumptions about specific types of controls
2169 // here, so we may have to alter some things later if they prove invalid
2173 // Shift tabl will always be a nav-key but tabs may be wanted
2182 // Entry Fields want tabs for themselve usually
2186 case DLGC_ENTRYFIELD
:
2196 // Ctrl-Tab cycles thru notebook pages
2198 bWindowChange
= bCtrlDown
;
2199 bForward
= !bShiftDown
;
2222 // ctrl-enter is not processed
2226 else if (ulDlgCode
& DLGC_BUTTON
)
2229 // buttons want process Enter themselevs
2235 wxButton
* pBtn
= wxDynamicCast( GetDefaultItem()
2239 if (pBtn
&& pBtn
->IsEnabled())
2242 // If we do have a default button, do press it
2244 pBtn
->OS2Command(BN_CLICKED
, 0 /* unused */);
2247 else if (!IsTopLevel())
2250 // if not a top level window, let parent
2255 // else: but if it does not it makes sense to make
2256 // it work like a TAB - and that's what we do.
2257 // Note that Ctrl-Enter always works this way.
2268 wxNavigationKeyEvent vEvent
;
2270 vEvent
.SetDirection(bForward
);
2271 vEvent
.SetWindowChange(bWindowChange
);
2272 vEvent
.SetEventObject(this);
2274 if (GetEventHandler()->ProcessEvent(vEvent
))
2276 wxButton
* pBtn
= wxDynamicCast(FindFocus(), wxButton
);
2281 // The button which has focus should be default
2290 // Let Dialogs process
2292 if (::WinSendMsg(pQMsg
->hwnd
, WM_QUERYDLGCODE
, pQMsg
, 0));
2296 pMsg
= pMsg
; // just shut up the compiler
2297 #endif // __WXUNIVERSAL__
2300 } // end of wxWindowOS2::OS2ProcessMessage
2302 bool wxWindowOS2::OS2TranslateMessage(
2306 #if wxUSE_ACCEL && !defined(__WXUNIVERSAL__)
2307 return m_acceleratorTable
.Translate(m_hWnd
, pMsg
);
2311 #endif //wxUSE_ACCEL
2312 } // end of wxWindowOS2::OS2TranslateMessage
2314 bool wxWindowOS2::OS2ShouldPreProcessMessage(
2318 // preprocess all messages by default
2320 } // end of wxWindowOS2::OS2ShouldPreProcessMessage
2322 // ---------------------------------------------------------------------------
2323 // message params unpackers
2324 // ---------------------------------------------------------------------------
2326 void wxWindowOS2::UnpackCommand(
2334 *pId
= LOWORD(wParam
);
2335 *phWnd
= NULL
; // or may be GetHWND() ?
2336 *pCmd
= LOWORD(lParam
);
2337 } // end of wxWindowOS2::UnpackCommand
2339 void wxWindowOS2::UnpackActivate(
2346 *pState
= LOWORD(wParam
);
2347 *phWnd
= (WXHWND
)lParam
;
2348 } // end of wxWindowOS2::UnpackActivate
2350 void wxWindowOS2::UnpackScroll(
2361 ulId
= (ULONG
)LONGFROMMP(wParam
);
2362 hWnd
= ::WinWindowFromID(GetHwnd(), ulId
);
2363 if (hWnd
== m_hWndScrollBarHorz
|| hWnd
== m_hWndScrollBarVert
)
2364 *phWnd
= NULLHANDLE
;
2368 *pPos
= SHORT1FROMMP(lParam
);
2369 *pCode
= SHORT2FROMMP(lParam
);
2370 } // end of wxWindowOS2::UnpackScroll
2372 void wxWindowOS2::UnpackMenuSelect(
2380 *pItem
= (WXWORD
)LOWORD(wParam
);
2381 *pFlags
= HIWORD(wParam
);
2382 *phMenu
= (WXHMENU
)lParam
;
2383 } // end of wxWindowOS2::UnpackMenuSelect
2385 // ---------------------------------------------------------------------------
2386 // Main wxWindows window proc and the window proc for wxWindow
2387 // ---------------------------------------------------------------------------
2390 // Hook for new window just as it's being created, when the window isn't yet
2391 // associated with the handle
2393 wxWindowOS2
* wxWndHook
= NULL
;
2398 MRESULT EXPENTRY
wxWndProc(
2406 // Trace all ulMsgs - useful for the debugging
2409 wxLogTrace(wxTraceMessages
, wxT("Processing %s(wParam=%8lx, lParam=%8lx)"),
2410 wxGetMessageName(ulMsg
), wParam
, lParam
);
2411 #endif // __WXDEBUG__
2413 wxWindowOS2
* pWnd
= wxFindWinFromHandle((WXHWND
)hWnd
);
2416 // When we get the first message for the HWND we just created, we associate
2417 // it with wxWindow stored in wxWndHook
2419 if (!pWnd
&& wxWndHook
)
2421 wxAssociateWinWithHandle(hWnd
, wxWndHook
);
2424 pWnd
->SetHWND((WXHWND
)hWnd
);
2427 MRESULT rc
= (MRESULT
)0;
2431 // Stop right here if we don't have a valid handle in our wxWindow object.
2433 if (pWnd
&& !pWnd
->GetHWND())
2435 pWnd
->SetHWND((WXHWND
) hWnd
);
2436 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
2443 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
2444 if ( (pWnd
->GetScrollBarHorz() != NULLHANDLE
||
2445 pWnd
->GetScrollBarVert() != NULLHANDLE
) &&
2448 if (pWnd
->GetScrollBarHorz() != NULLHANDLE
)
2449 ::WinInvalidateRect(pWnd
->GetScrollBarHorz(), NULL
, TRUE
);
2450 if (pWnd
->GetScrollBarVert() != NULLHANDLE
)
2451 ::WinInvalidateRect(pWnd
->GetScrollBarVert(), NULL
, TRUE
);
2455 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
2459 } // end of wxWndProc
2462 // We will add (or delete) messages we need to handle at this default
2465 MRESULT
wxWindowOS2::OS2WindowProc(
2472 // Did we process the uMsg?
2474 bool bProcessed
= FALSE
;
2478 // For most messages we should return 0 when we do process the message
2480 mResult
= (MRESULT
)0;
2488 bProcessed
= HandleCreate( (WXLPCREATESTRUCT
)lParam
2494 // Return 0 to bAllow window creation
2496 mResult
= (MRESULT
)(bMayCreate
? 0 : -1);
2507 bProcessed
= HandleMove( LOWORD(lParam
)
2513 bProcessed
= HandleSize( LOWORD(lParam
)
2519 case WM_WINDOWPOSCHANGED
:
2522 // Dialogs under OS/2 do not get WM_SIZE events at all.
2523 // Instead they get this, which can function much like WM_SIZE
2524 // PSWP contains the new sizes and positioning, PSWP+1 the old
2525 // We use this because ADJUSTWINDOWPOS comes BEFORE the new
2526 // position is added and our auto layout does a WinQueryWindowRect
2527 // to get the CURRENT client size. That is the size used to position
2528 // child controls, so we need to already be sized
2529 // in order to get the child controls positoned properly.
2531 if (IsKindOf(CLASSINFO(wxDialog
)) || IsKindOf(CLASSINFO(wxFrame
)))
2533 PSWP pSwp
= (PSWP
)PVOIDFROMMP(wParam
);
2534 PSWP pSwp2
= pSwp
++;
2536 if (!(pSwp
->cx
== pSwp2
->cx
&&
2537 pSwp
->cy
== pSwp2
->cy
))
2538 bProcessed
= HandleSize( pSwp
->cx
2542 if (IsKindOf(CLASSINFO(wxFrame
)))
2544 wxFrame
* pFrame
= wxDynamicCast(this, wxFrame
);
2548 if (pFrame
->GetStatusBar())
2549 pFrame
->PositionStatusBar();
2550 if (pFrame
->GetToolBar())
2551 pFrame
->PositionToolBar();
2562 UnpackActivate( wParam
2568 bProcessed
= HandleActivate( wState
2576 if (SHORT1FROMMP((MPARAM
)lParam
) == TRUE
)
2577 bProcessed
= HandleSetFocus((WXHWND
)(HWND
)wParam
);
2579 bProcessed
= HandleKillFocus((WXHWND
)(HWND
)wParam
);
2583 bProcessed
= HandlePaint();
2588 // Don't let the DefWindowProc() destroy our window - we'll do it
2589 // ourselves in ~wxWindow
2592 mResult
= (MRESULT
)TRUE
;
2596 bProcessed
= HandleShow(wParam
!= 0, (int)lParam
);
2600 // Under OS2 PM Joysticks are treated just like mouse events
2601 // The "Motion" events will be prevelent in joysticks
2604 case WM_BUTTON1DOWN
:
2606 case WM_BUTTON1DBLCLK
:
2607 case WM_BUTTON1MOTIONEND
:
2608 case WM_BUTTON1MOTIONSTART
:
2609 case WM_BUTTON2DOWN
:
2611 case WM_BUTTON2DBLCLK
:
2612 case WM_BUTTON2MOTIONEND
:
2613 case WM_BUTTON2MOTIONSTART
:
2614 case WM_BUTTON3DOWN
:
2616 case WM_BUTTON3DBLCLK
:
2617 case WM_BUTTON3MOTIONEND
:
2618 case WM_BUTTON3MOTIONSTART
:
2620 if (uMsg
== WM_BUTTON1DOWN
&& AcceptsFocus())
2623 short nX
= LOWORD(wParam
);
2624 short nY
= HIWORD(wParam
);
2627 // Redirect the event to a static control if necessary
2629 if (this == GetCapture())
2631 bProcessed
= HandleMouseEvent( uMsg
2634 ,(WXUINT
)SHORT1FROMMP(wParam
)
2639 wxWindow
* pWin
= FindWindowForMouseEvent( this
2643 if (!pWin
->IsOfStandardClass())
2645 if (uMsg
== WM_BUTTON1DOWN
&& pWin
->AcceptsFocus() )
2648 bProcessed
= pWin
->HandleMouseEvent( uMsg
2651 ,(WXUINT
)SHORT1FROMMP(wParam
)
2658 bProcessed
= HandleSysCommand(wParam
, lParam
);
2665 UnpackCommand(wParam
, lParam
, &id
, &hwnd
, &cmd
);
2667 bProcessed
= HandleCommand(id
, cmd
, hwnd
);
2672 // For these messages we must return TRUE if process the message
2675 case WM_MEASUREITEM
:
2677 int nIdCtrl
= (UINT
)wParam
;
2679 if ( uMsg
== WM_DRAWITEM
)
2681 bProcessed
= OS2OnDrawItem(nIdCtrl
,
2682 (WXDRAWITEMSTRUCT
*)lParam
);
2686 return MRFROMLONG(OS2OnMeasureItem( nIdCtrl
2687 ,(WXMEASUREITEMSTRUCT
*)lParam
2692 mResult
= (MRESULT
)TRUE
;
2696 case WM_QUERYDLGCODE
:
2697 if (!IsOfStandardClass())
2701 mResult
= (MRESULT
)m_lDlgCode
;
2706 //else: get the dlg code from the DefWindowProc()
2711 // In OS/2 PM all keyboard events are of the WM_CHAR type. Virtual key and key-up
2712 // and key-down events are obtained from the WM_CHAR params.
2716 USHORT uKeyFlags
= SHORT1FROMMP((MPARAM
)wParam
);
2718 if (uKeyFlags
& KC_KEYUP
)
2720 //TODO: check if the cast to WXWORD isn't causing trouble
2721 bProcessed
= HandleKeyUp(wParam
, lParam
);
2724 else // keydown event
2726 m_bLastKeydownProcessed
= FALSE
;
2728 // If this has been processed by an event handler,
2729 // return 0 now (we've handled it). DON't RETURN
2730 // we still need to process further
2732 m_bLastKeydownProcessed
= HandleKeyDown(wParam
, lParam
);
2733 if (uKeyFlags
& KC_VIRTUALKEY
)
2735 USHORT uVk
= SHORT2FROMMP((MPARAM
)lParam
);
2738 // We consider these message "not interesting" to OnChar
2751 // Avoid duplicate messages to OnChar for these ASCII keys: they
2752 // will be translated by TranslateMessage() and received in WM_CHAR
2757 // But set processed to FALSE, not TRUE to still pass them to
2758 // the control's default window proc - otherwise built-in
2759 // keyboard handling won't work
2764 bProcessed
= HandleChar(wParam
, lParam
);
2768 else // WM_CHAR -- Always an ASCII character
2770 if (m_bLastKeydownProcessed
)
2773 // The key was handled in the EVT_KEY_DOWN and handling
2774 // a key in an EVT_KEY_DOWN handler is meant, by
2775 // design, to prevent EVT_CHARs from happening
2777 m_bLastKeydownProcessed
= FALSE
;
2780 else // do generate a CHAR event
2782 bProcessed
= HandleChar(wParam
, lParam
, TRUE
);
2795 UnpackScroll( wParam
2802 bProcessed
= OS2OnScroll( uMsg
== WM_HSCROLL
? wxHORIZONTAL
2812 switch(SHORT2FROMMP(wParam
))
2816 HWND hWnd
= ::WinWindowFromID((HWND
)GetHwnd(), SHORT1FROMMP(wParam
));
2817 wxWindowOS2
* pWin
= wxFindWinFromHandle(hWnd
);
2824 if (pWin
->IsKindOf(CLASSINFO(wxBitmapButton
)))
2826 wxBitmapButton
* pBitmapButton
= wxDynamicCast(pWin
, wxBitmapButton
);
2828 pBitmapButton
->OS2OnDraw((WXDRAWITEMSTRUCT
*)lParam
);
2834 case BKN_PAGESELECTEDPENDING
:
2836 PPAGESELECTNOTIFY pPage
= (PPAGESELECTNOTIFY
)lParam
;
2838 if ((pPage
->ulPageIdNew
!= pPage
->ulPageIdCur
) &&
2839 (pPage
->ulPageIdNew
> 0L && pPage
->ulPageIdCur
> 0L))
2841 wxWindowOS2
* pWin
= wxFindWinFromHandle(pPage
->hwndBook
);
2842 wxNotebookEvent
vEvent( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
2843 ,(int)SHORT1FROMMP(wParam
)
2844 ,(int)pPage
->ulPageIdNew
2845 ,(int)pPage
->ulPageIdCur
2852 if (pWin
->IsKindOf(CLASSINFO(wxNotebook
)))
2854 wxNotebook
* pNotebook
= wxDynamicCast(pWin
, wxNotebook
);
2856 vEvent
.SetEventObject(pWin
);
2857 pNotebook
->OnSelChange(vEvent
);
2868 case BN_CLICKED
: // Dups as LN_SELECT and CBN_LBSELECT
2870 HWND hWnd
= ::WinWindowFromID((HWND
)GetHwnd(), SHORT1FROMMP(wParam
));
2871 wxWindowOS2
* pWin
= wxFindWinFromHandle(hWnd
);
2879 // Simulate a WM_COMMAND here, as wxWindows expects all control
2880 // button clicks to generate WM_COMMAND msgs, not WM_CONTROL
2882 if (pWin
->IsKindOf(CLASSINFO(wxRadioBox
)))
2884 wxRadioBox
* pRadioBox
= wxDynamicCast(pWin
, wxRadioBox
);
2886 pRadioBox
->OS2Command( (WXUINT
)SHORT2FROMMP(wParam
)
2887 ,(WXUINT
)SHORT1FROMMP(wParam
)
2890 if (pWin
->IsKindOf(CLASSINFO(wxRadioButton
)))
2892 wxRadioButton
* pRadioButton
= wxDynamicCast(pWin
, wxRadioButton
);
2894 pRadioButton
->OS2Command( (WXUINT
)SHORT2FROMMP(wParam
)
2895 ,(WXUINT
)SHORT1FROMMP(wParam
)
2898 if (pWin
->IsKindOf(CLASSINFO(wxCheckBox
)))
2900 wxCheckBox
* pCheckBox
= wxDynamicCast(pWin
, wxCheckBox
);
2902 pCheckBox
->OS2Command( (WXUINT
)SHORT2FROMMP(wParam
)
2903 ,(WXUINT
)SHORT1FROMMP(wParam
)
2906 if (pWin
->IsKindOf(CLASSINFO(wxListBox
)))
2908 wxListBox
* pListBox
= wxDynamicCast(pWin
, wxListBox
);
2910 pListBox
->OS2Command( (WXUINT
)SHORT2FROMMP(wParam
)
2911 ,(WXUINT
)SHORT1FROMMP(wParam
)
2913 if (pListBox
->GetWindowStyle() & wxLB_OWNERDRAW
)
2916 if (pWin
->IsKindOf(CLASSINFO(wxComboBox
)))
2918 wxComboBox
* pComboBox
= wxDynamicCast(pWin
, wxComboBox
);
2920 pComboBox
->OS2Command( (WXUINT
)SHORT2FROMMP(wParam
)
2921 ,(WXUINT
)SHORT1FROMMP(wParam
)
2928 case LN_ENTER
: /* dups as CBN_EFCHANGE */
2930 HWND hWnd
= HWNDFROMMP(lParam
);
2931 wxWindowOS2
* pWin
= wxFindWinFromHandle(hWnd
);
2939 // Simulate a WM_COMMAND here, as wxWindows expects all control
2940 // button clicks to generate WM_COMMAND msgs, not WM_CONTROL
2942 if (pWin
->IsKindOf(CLASSINFO(wxListBox
)))
2944 wxListBox
* pListBox
= wxDynamicCast(pWin
, wxListBox
);
2946 pListBox
->OS2Command( (WXUINT
)SHORT2FROMMP(wParam
)
2947 ,(WXUINT
)SHORT1FROMMP(wParam
)
2949 if (pListBox
->GetWindowStyle() & wxLB_OWNERDRAW
)
2953 if (pWin
->IsKindOf(CLASSINFO(wxComboBox
)))
2955 wxComboBox
* pComboBox
= wxDynamicCast(pWin
, wxComboBox
);
2957 pComboBox
->OS2Command( (WXUINT
)SHORT2FROMMP(wParam
)
2958 ,(WXUINT
)SHORT1FROMMP(wParam
)
2966 case SPBN_DOWNARROW
:
2972 ::WinSendMsg( HWNDFROMMP(lParam
)
2975 ,MPFROM2SHORT( (USHORT
)10
2976 ,(USHORT
)SPBQ_UPDATEIFVALID
2980 bProcessed
= OS2OnScroll( wxVERTICAL
2981 ,(int)SHORT2FROMMP(wParam
)
2988 case SLN_SLIDERTRACK
:
2990 HWND hWnd
= ::WinWindowFromID(GetHWND(), SHORT1FROMMP(wParam
));
2991 wxWindowOS2
* pChild
= wxFindWinFromHandle(hWnd
);
2998 if (pChild
->IsKindOf(CLASSINFO(wxSlider
)))
2999 bProcessed
= OS2OnScroll( wxVERTICAL
3000 ,(int)SHORT2FROMMP(wParam
)
3001 ,(int)LONGFROMMP(lParam
)
3009 #if defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
3010 case WM_CTLCOLORCHANGE
:
3012 bProcessed
= HandleCtlColor(&hBrush
);
3016 case WM_ERASEBACKGROUND
:
3018 // Returning TRUE to requestw PM to paint the window background
3019 // in SYSCLR_WINDOW. We don't really want that
3021 bProcessed
= HandleEraseBkgnd((WXHDC
)(HPS
)wParam
);
3022 mResult
= (MRESULT
)(FALSE
);
3025 // the return value for this message is ignored
3026 case WM_SYSCOLORCHANGE
:
3027 bProcessed
= HandleSysColorChange();
3030 case WM_REALIZEPALETTE
:
3031 bProcessed
= HandlePaletteChanged();
3034 // move all drag and drops to wxDrg
3036 bProcessed
= HandleEndDrag(wParam
);
3040 bProcessed
= HandleInitDialog((WXHWND
)(HWND
)wParam
);
3044 // we never set focus from here
3045 mResult
= (MRESULT
)FALSE
;
3049 // wxFrame specific message
3050 case WM_MINMAXFRAME
:
3051 bProcessed
= HandleGetMinMaxInfo((PSWP
)wParam
);
3054 case WM_SYSVALUECHANGED
:
3055 // TODO: do something
3056 mResult
= (MRESULT
)TRUE
;
3060 // Comparable to WM_SETPOINTER for windows, only for just controls
3062 case WM_CONTROLPOINTER
:
3063 bProcessed
= HandleSetCursor( SHORT1FROMMP(wParam
) // Control ID
3064 ,(HWND
)lParam
// Cursor Handle
3069 // Returning TRUE stops the DefWindowProc() from further
3070 // processing this message - exactly what we need because we've
3071 // just set the cursor.
3073 mResult
= (MRESULT
)TRUE
;
3080 wxLogTrace(wxTraceMessages
, wxT("Forwarding %s to DefWindowProc."),
3081 wxGetMessageName(uMsg
));
3082 #endif // __WXDEBUG__
3083 if (IsKindOf(CLASSINFO(wxFrame
)))
3084 mResult
= ::WinDefWindowProc(m_hWnd
, uMsg
, wParam
, lParam
);
3085 else if (IsKindOf(CLASSINFO(wxDialog
)))
3086 mResult
= ::WinDefDlgProc( m_hWnd
, uMsg
, wParam
, lParam
);
3088 mResult
= OS2DefWindowProc(uMsg
, wParam
, lParam
);
3091 } // end of wxWindowOS2::OS2WindowProc
3094 // clashes with wxDlgProc in toplevel.cpp?
3096 // Dialog window proc
3101 , MPARAM
WXUNUSED(wParam
)
3102 , MPARAM
WXUNUSED(lParam
))
3104 if (uMsg
== WM_INITDLG
)
3107 // For this message, returning TRUE tells system to set focus to the
3108 // first control in the dialog box
3110 return (MRESULT
)TRUE
;
3115 // For all the other ones, FALSE means that we didn't process the
3120 } // end of wxDlgProc
3123 wxWindow
* wxFindWinFromHandle(
3127 wxNode
* pNode
= wxWinHandleList
->Find((long)hWnd
);
3131 return (wxWindow
*)pNode
->Data();
3132 } // end of wxFindWinFromHandle
3134 void wxAssociateWinWithHandle(
3140 // Adding NULL hWnd is (first) surely a result of an error and
3141 // (secondly) breaks menu command processing
3143 wxCHECK_RET( hWnd
!= (HWND
)NULL
,
3144 wxT("attempt to add a NULL hWnd to window list ignored") );
3147 wxWindow
* pOldWin
= wxFindWinFromHandle((WXHWND
) hWnd
);
3149 if (pOldWin
&& (pOldWin
!= pWin
))
3151 wxString
str(pWin
->GetClassInfo()->GetClassName());
3152 wxLogError( "Bug! Found existing HWND %X for new window of class %s"
3159 wxWinHandleList
->Append( (long)hWnd
3163 } // end of wxAssociateWinWithHandle
3165 void wxRemoveHandleAssociation(
3169 wxWinHandleList
->DeleteObject(pWin
);
3170 } // end of wxRemoveHandleAssociation
3173 // Default destroyer - override if you destroy it in some other way
3174 // (e.g. with MDI child windows)
3176 void wxWindowOS2::OS2DestroyWindow()
3180 bool wxWindowOS2::OS2GetCreateWindowCoords(
3182 , const wxSize
& rSize
3189 bool bNonDefault
= FALSE
;
3190 static const int DEFAULT_Y
= 200;
3191 static const int DEFAULT_H
= 250;
3195 rnX
= rnY
= CW_USEDEFAULT
;
3200 rnY
= rPos
.y
== -1 ? DEFAULT_Y
: rPos
.y
;
3205 rnWidth
= rnHeight
= CW_USEDEFAULT
;
3210 rnHeight
= rSize
.y
== -1 ? DEFAULT_H
: rSize
.y
;
3214 } // end of wxWindowOS2::OS2GetCreateWindowCoords
3216 WXHWND
wxWindowOS2::OS2GetParent() const
3218 return m_parent
? m_parent
->GetHWND() : NULL
;
3221 bool wxWindowOS2::OS2Create(
3223 , const char* zTitle
3225 , const wxPoint
& rPos
3226 , const wxSize
& rSize
3238 wxWindow
* pParent
= GetParent();
3239 HWND hWnd
= NULLHANDLE
;
3241 long lControlId
= 0L;
3242 wxWindowCreationHook
vHook(this);
3243 wxString
sClassName((wxChar
*)zClass
);
3245 OS2GetCreateWindowCoords( rPos
3255 lControlId
= GetId();
3256 if (GetWindowStyleFlag() & wxCLIP_SIBLINGS
)
3258 dwStyle
|= WS_CLIPSIBLINGS
;
3262 // For each class "Foo" we have we also have "FooNR" ("no repaint") class
3263 // which is the same but without CS_[HV]REDRAW class styles so using it
3264 // ensures that the window is not fully repainted on each resize
3266 if (GetWindowStyleFlag() & wxNO_FULL_REPAINT_ON_RESIZE
)
3268 sClassName
+= wxT("NR");
3270 m_hWnd
= (WXHWND
)::WinCreateWindow( (HWND
)OS2GetParent()
3271 ,(PSZ
)sClassName
.c_str()
3272 ,(PSZ
)zTitle
? zTitle
: ""
3286 vError
= ::WinGetLastError(wxGetInstance());
3287 sError
= wxPMErrorToStr(vError
);
3290 SubclassWin(m_hWnd
);
3291 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
3293 m_backgroundColour
.Set(wxString("GREY"));
3295 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
3297 if (!::WinSetPresParam( m_hWnd
3303 vError
= ::WinGetLastError(vHabmain
);
3304 sError
= wxPMErrorToStr(vError
);
3305 wxLogError("Error creating frame. Error: %s\n", sError
);
3314 } // end of WinGuiBase_Window::OS2Create
3316 // ===========================================================================
3317 // OS2 PM message handlers
3318 // ===========================================================================
3320 // ---------------------------------------------------------------------------
3321 // window creation/destruction
3322 // ---------------------------------------------------------------------------
3324 bool wxWindowOS2::HandleCreate(
3325 WXLPCREATESTRUCT
WXUNUSED(vCs
)
3329 wxWindowCreateEvent
vEvent((wxWindow
*)this);
3331 (void)GetEventHandler()->ProcessEvent(vEvent
);
3332 *pbMayCreate
= TRUE
;
3334 } // end of wxWindowOS2::HandleCreate
3336 bool wxWindowOS2::HandleDestroy()
3338 wxWindowDestroyEvent
vEvent((wxWindow
*)this);
3339 vEvent
.SetId(GetId());
3340 (void)GetEventHandler()->ProcessEvent(vEvent
);
3343 // Delete our drop target if we've got one
3345 #if wxUSE_DRAG_AND_DROP
3346 if (m_dropTarget
!= NULL
)
3348 delete m_dropTarget
;
3349 m_dropTarget
= NULL
;
3351 #endif // wxUSE_DRAG_AND_DROP
3354 // WM_DESTROY handled
3357 } // end of wxWindowOS2::HandleDestroy
3359 // ---------------------------------------------------------------------------
3361 // ---------------------------------------------------------------------------
3362 void wxWindowOS2::OnSetFocus(
3363 wxFocusEvent
& rEvent
3367 } // end of wxWindowOS2::OnSetFocus
3369 bool wxWindowOS2::HandleActivate(
3371 , WXHWND
WXUNUSED(hActivate
)
3374 wxActivateEvent
vEvent( wxEVT_ACTIVATE
3378 vEvent
.SetEventObject(this);
3379 return GetEventHandler()->ProcessEvent(vEvent
);
3380 } // end of wxWindowOS2::HandleActivate
3382 bool wxWindowOS2::HandleSetFocus(
3383 WXHWND
WXUNUSED(hWnd
)
3387 // Notify the parent keeping track of focus for the kbd navigation
3388 // purposes that we got it
3390 wxChildFocusEvent
vEventFocus((wxWindow
*)this);
3391 (void)GetEventHandler()->ProcessEvent(vEventFocus
);
3399 m_caret
->OnSetFocus();
3401 #endif // wxUSE_CARET
3404 // If it's a wxTextCtrl don't send the event as it will be done
3405 // after the control gets to process it from EN_FOCUS handler
3406 if ( wxDynamicCastThis(wxTextCtrl
) )
3410 #endif // wxUSE_TEXTCTRL
3412 wxFocusEvent
vEvent(wxEVT_SET_FOCUS
, m_windowId
);
3414 vEvent
.SetEventObject(this);
3415 return GetEventHandler()->ProcessEvent(vEvent
);
3416 } // end of wxWindowOS2::HandleSetFocus
3418 bool wxWindowOS2::HandleKillFocus(
3428 m_caret
->OnKillFocus();
3430 #endif // wxUSE_CARET
3434 // If it's a wxTextCtrl don't send the event as it will be done
3435 // after the control gets to process it.
3437 wxTextCtrl
* pCtrl
= wxDynamicCastThis(wxTextCtrl
);
3446 // Don't send the event when in the process of being deleted. This can
3447 // only cause problems if the event handler tries to access the object.
3449 if ( m_isBeingDeleted
)
3454 wxFocusEvent
vEvent( wxEVT_KILL_FOCUS
3458 vEvent
.SetEventObject(this);
3461 // wxFindWinFromHandle() may return NULL, it is ok
3463 vEvent
.SetWindow(wxFindWinFromHandle(hWnd
));
3464 return GetEventHandler()->ProcessEvent(vEvent
);
3465 } // end of wxWindowOS2::HandleKillFocus
3467 // ---------------------------------------------------------------------------
3469 // ---------------------------------------------------------------------------
3471 bool wxWindowOS2::HandleShow(
3473 , int WXUNUSED(nStatus
)
3476 wxShowEvent
vEvent(GetId(), bShow
);
3478 vEvent
.m_eventObject
= this;
3479 return GetEventHandler()->ProcessEvent(vEvent
);
3480 } // end of wxWindowOS2::HandleShow
3482 bool wxWindowOS2::HandleInitDialog(
3483 WXHWND
WXUNUSED(hWndFocus
)
3486 wxInitDialogEvent
vEvent(GetId());
3488 vEvent
.m_eventObject
= this;
3489 return GetEventHandler()->ProcessEvent(vEvent
);
3490 } // end of wxWindowOS2::HandleInitDialog
3492 bool wxWindowOS2::HandleEndDrag(WXWPARAM
WXUNUSED(wParam
))
3494 // TODO: We'll handle drag and drop later
3498 bool wxWindowOS2::HandleSetCursor(
3499 USHORT
WXUNUSED(vId
)
3504 // Under OS/2 PM this allows the pointer to be changed
3505 // as it passes over a control
3507 ::WinSetPointer(HWND_DESKTOP
, (HPOINTER
)hPointer
);
3509 } // end of wxWindowOS2::HandleSetCursor
3511 // ---------------------------------------------------------------------------
3512 // owner drawn stuff
3513 // ---------------------------------------------------------------------------
3514 bool wxWindowOS2::OS2OnDrawItem(
3516 , WXDRAWITEMSTRUCT
* pItemStruct
3519 #if wxUSE_OWNER_DRAWN
3522 #if wxUSE_MENUS_NATIVE
3524 // Is it a menu item?
3530 POWNERITEM pMeasureStruct
= (POWNERITEM
)pItemStruct
;
3531 wxFrame
* pFrame
= (wxFrame
*)this;
3532 wxMenuItem
* pMenuItem
= pFrame
->GetMenuBar()->FindItem(pMeasureStruct
->idItem
, pMeasureStruct
->hItem
);
3533 HDC hDC
= ::GpiQueryDevice(pMeasureStruct
->hps
);
3534 wxRect
vRect( pMeasureStruct
->rclItem
.xLeft
3535 ,pMeasureStruct
->rclItem
.yBottom
3536 ,pMeasureStruct
->rclItem
.xRight
- pMeasureStruct
->rclItem
.xLeft
3537 ,pMeasureStruct
->rclItem
.yTop
- pMeasureStruct
->rclItem
.yBottom
3542 vDc
.SetHPS(pMeasureStruct
->hps
);
3544 // Load the wxWindows Pallete and set to RGB mode
3546 if (!::GpiCreateLogColorTable( pMeasureStruct
->hps
3550 ,(LONG
)wxTheColourDatabase
->m_nSize
3551 ,(PLONG
)wxTheColourDatabase
->m_palTable
3554 vError
= ::WinGetLastError(vHabmain
);
3555 sError
= wxPMErrorToStr(vError
);
3556 wxLogError("Unable to set current color table. Error: %s\n", sError
);
3559 // Set the color table to RGB mode
3561 if (!::GpiCreateLogColorTable( pMeasureStruct
->hps
3569 vError
= ::WinGetLastError(vHabmain
);
3570 sError
= wxPMErrorToStr(vError
);
3571 wxLogError("Unable to set current color table. Error: %s\n", sError
);
3574 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
3580 if (pMeasureStruct
->fsAttribute
== pMeasureStruct
->fsAttributeOld
)
3583 // Entire Item needs to be redrawn (either it has reappeared from
3584 // behind another window or is being displayed for the first time
3586 eAction
= wxOwnerDrawn::wxODDrawAll
;
3588 if (pMeasureStruct
->fsAttribute
& MIA_HILITED
)
3591 // If it is currently selected we let the system handle it
3593 eStatus
|= wxOwnerDrawn::wxODSelected
;
3595 if (pMeasureStruct
->fsAttribute
& MIA_CHECKED
)
3598 // If it is currently checked we draw our own
3600 eStatus
|= wxOwnerDrawn::wxODChecked
;
3601 pMeasureStruct
->fsAttributeOld
= pMeasureStruct
->fsAttribute
&= ~MIA_CHECKED
;
3603 if (pMeasureStruct
->fsAttribute
& MIA_DISABLED
)
3606 // If it is currently disabled we let the system handle it
3608 eStatus
|= wxOwnerDrawn::wxODDisabled
;
3611 // Don't really care about framed (indicationg focus) or NoDismiss
3616 if (pMeasureStruct
->fsAttribute
& MIA_HILITED
)
3618 eAction
= wxOwnerDrawn::wxODDrawAll
;
3619 eStatus
|= wxOwnerDrawn::wxODSelected
;
3621 // Keep the system from trying to highlight with its bogus colors
3623 pMeasureStruct
->fsAttributeOld
= pMeasureStruct
->fsAttribute
&= ~MIA_HILITED
;
3625 else if (!(pMeasureStruct
->fsAttribute
& MIA_HILITED
))
3627 eAction
= wxOwnerDrawn::wxODDrawAll
;
3630 // Keep the system from trying to highlight with its bogus colors
3632 pMeasureStruct
->fsAttribute
= pMeasureStruct
->fsAttributeOld
&= ~MIA_HILITED
;
3637 // For now we don't care about anything else
3638 // just ignore the entire message!
3644 // Now redraw the item
3646 return(pMenuItem
->OnDrawItem( vDc
3648 ,(wxOwnerDrawn::wxODAction
)eAction
3649 ,(wxOwnerDrawn::wxODStatus
)eStatus
3652 // leave the fsAttribute and fsOldAttribute unchanged. If different,
3653 // the system will do the highlight or fraeming or disabling for us,
3654 // otherwise, we'd have to do it ourselves.
3657 #endif // wxUSE_MENUS_NATIVE
3659 wxWindow
* pItem
= FindItem(vId
);
3661 if (pItem
&& pItem
->IsKindOf(CLASSINFO(wxControl
)))
3663 return ((wxControl
*)pItem
)->OS2OnDraw(pItemStruct
);
3667 pItemStruct
= pItemStruct
;
3670 } // end of wxWindowOS2::OS2OnDrawItem
3672 long wxWindowOS2::OS2OnMeasureItem(
3674 , WXMEASUREITEMSTRUCT
* pItemStruct
3677 #if wxUSE_OWNER_DRAWN
3679 // Is it a menu item?
3681 if (lId
== 65536) // I really don't like this...has to be a better indicator
3683 if (IsKindOf(CLASSINFO(wxFrame
))) // we'll assume if Frame then a menu
3687 POWNERITEM pMeasureStruct
= (POWNERITEM
)pItemStruct
;
3688 wxFrame
* pFrame
= (wxFrame
*)this;
3689 wxMenuItem
* pMenuItem
= pFrame
->GetMenuBar()->FindItem(pMeasureStruct
->idItem
, pMeasureStruct
->hItem
);
3691 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
3694 if (pMenuItem
->OnMeasureItem( &nWidth
3700 pMeasureStruct
->rclItem
.xRight
= nWidth
;
3701 pMeasureStruct
->rclItem
.xLeft
= 0L;
3702 pMeasureStruct
->rclItem
.yTop
= nHeight
;
3703 pMeasureStruct
->rclItem
.yBottom
= 0L;
3704 mRc
= MRFROM2SHORT(nHeight
, nWidth
);
3705 return LONGFROMMR(mRc
);
3710 wxWindow
* pItem
= FindItem(lId
);
3712 if (pItem
&& pItem
->IsKindOf(CLASSINFO(wxControl
)))
3716 vItem
.idItem
= (LONG
)pItemStruct
;
3717 return ((wxControl
*)pItem
)->OS2OnMeasure((WXMEASUREITEMSTRUCT
*)&vItem
);
3721 pItemStruct
= pItemStruct
;
3722 #endif // wxUSE_OWNER_DRAWN
3726 // ---------------------------------------------------------------------------
3727 // colours and palettes
3728 // ---------------------------------------------------------------------------
3730 bool wxWindowOS2::HandleSysColorChange()
3732 wxSysColourChangedEvent vEvent
;
3734 vEvent
.SetEventObject(this);
3735 return GetEventHandler()->ProcessEvent(vEvent
);
3736 } // end of wxWindowOS2::HandleSysColorChange
3738 bool wxWindowOS2::HandleCtlColor(
3739 WXHBRUSH
* WXUNUSED(phBrush
)
3743 // Not much provided with message. So not sure I can do anything with it
3746 } // end of wxWindowOS2::HandleCtlColor
3749 // Define for each class of dialog and control
3750 WXHBRUSH
wxWindowOS2::OnCtlColor(WXHDC
WXUNUSED(hDC
),
3751 WXHWND
WXUNUSED(hWnd
),
3752 WXUINT
WXUNUSED(nCtlColor
),
3753 WXUINT
WXUNUSED(message
),
3754 WXWPARAM
WXUNUSED(wParam
),
3755 WXLPARAM
WXUNUSED(lParam
))
3760 bool wxWindowOS2::HandlePaletteChanged()
3762 // need to set this to something first
3763 WXHWND hWndPalChange
= NULLHANDLE
;
3765 wxPaletteChangedEvent
vEvent(GetId());
3767 vEvent
.SetEventObject(this);
3768 vEvent
.SetChangedWindow(wxFindWinFromHandle(hWndPalChange
));
3770 return GetEventHandler()->ProcessEvent(vEvent
);
3771 } // end of wxWindowOS2::HandlePaletteChanged
3774 // Responds to colour changes: passes event on to children.
3776 void wxWindowOS2::OnSysColourChanged(
3777 wxSysColourChangedEvent
& rEvent
3780 wxNode
* pNode
= GetChildren().First();
3785 // Only propagate to non-top-level windows
3787 wxWindow
* pWin
= (wxWindow
*)pNode
->Data();
3789 if (pWin
->GetParent())
3791 wxSysColourChangedEvent vEvent
;
3793 rEvent
.m_eventObject
= pWin
;
3794 pWin
->GetEventHandler()->ProcessEvent(vEvent
);
3796 pNode
= pNode
->Next();
3798 } // end of wxWindowOS2::OnSysColourChanged
3800 // ---------------------------------------------------------------------------
3802 // ---------------------------------------------------------------------------
3804 void wxWindow::OnPaint (
3805 wxPaintEvent
& rEvent
3808 HDC hDC
= (HDC
)wxPaintDC::FindDCInCache((wxWindow
*) rEvent
.GetEventObject());
3812 OS2DefWindowProc( (WXUINT
)WM_PAINT
3817 } // end of wxWindow::OnPaint
3819 bool wxWindowOS2::HandlePaint()
3822 wxPaintEvent
vEvent(m_windowId
);
3827 // Create empty region
3828 // TODO: get HPS somewhere else if possible
3829 hPS
= ::WinGetPS(GetHwnd());
3830 hRgn
= ::GpiCreateRegion(hPS
, 0, NULL
);
3832 if (::WinQueryUpdateRegion(GetHwnd(), hRgn
) == RGN_ERROR
)
3834 wxLogLastError("CreateRectRgn");
3838 m_updateRegion
= wxRegion(hRgn
, hPS
);
3840 vEvent
.SetEventObject(this);
3841 bProcessed
= GetEventHandler()->ProcessEvent(vEvent
);
3844 IsKindOf(CLASSINFO(wxPanel
)) &&
3845 GetChildren().GetCount() == 0
3849 // OS/2 needs to process this right here, not by the default proc
3850 // Window's default proc correctly paints everything, OS/2 does not.
3851 // For decorative panels that typically have no children, we draw
3859 hPS
= ::WinBeginPaint( GetHwnd()
3865 ::GpiCreateLogColorTable( hPS
3869 ,(LONG
)wxTheColourDatabase
->m_nSize
3870 ,(PLONG
)wxTheColourDatabase
->m_palTable
3872 ::GpiCreateLogColorTable( hPS
3879 if (::WinIsWindowVisible(GetHWND()))
3880 ::WinFillRect(hPS
, &vRect
, GetBackgroundColour().GetPixel());
3883 LINEBUNDLE vLineBundle
;
3885 vLineBundle
.lColor
= 0x00000000; // Black
3886 vLineBundle
.usMixMode
= FM_OVERPAINT
;
3887 vLineBundle
.fxWidth
= 1;
3888 vLineBundle
.lGeomWidth
= 1;
3889 vLineBundle
.usType
= LINETYPE_SOLID
;
3890 vLineBundle
.usEnd
= 0;
3891 vLineBundle
.usJoin
= 0;
3894 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
3898 ::WinQueryWindowRect(GetHwnd(), &vRect
);
3908 else if (!bProcessed
&&
3909 IsKindOf(CLASSINFO(wxPanel
))
3913 // Panel with children, usually fills a frame client so no borders.
3920 hPS
= ::WinBeginPaint( GetHwnd()
3926 ::GpiCreateLogColorTable( hPS
3930 ,(LONG
)wxTheColourDatabase
->m_nSize
3931 ,(PLONG
)wxTheColourDatabase
->m_palTable
3933 ::GpiCreateLogColorTable( hPS
3941 if (::WinIsWindowVisible(GetHWND()))
3942 ::WinFillRect(hPS
, &vRect
, GetBackgroundColour().GetPixel());
3948 } // end of wxWindowOS2::HandlePaint
3950 bool wxWindowOS2::HandleEraseBkgnd(
3957 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
3958 if (vSwp
.fl
& SWP_MINIMIZE
)
3963 vDC
.m_hPS
= (HPS
)hDC
; // this is really a PS
3964 vDC
.SetWindow((wxWindow
*)this);
3967 wxEraseEvent
vEvent(m_windowId
, &vDC
);
3969 vEvent
.SetEventObject(this);
3971 rc
= GetEventHandler()->ProcessEvent(vEvent
);
3974 vDC
.m_hPS
= NULLHANDLE
;
3976 } // end of wxWindowOS2::HandleEraseBkgnd
3978 void wxWindowOS2::OnEraseBackground(
3979 wxEraseEvent
& rEvent
3983 HPS hPS
= rEvent
.m_dc
->m_hPS
;
3985 LONG lColor
= m_backgroundColour
.GetPixel();
3987 rc
= ::WinQueryWindowRect(GetHwnd(), &vRect
);
3988 rc
= ::WinFillRect(hPS
, &vRect
, lColor
);
3989 } // end of wxWindowOS2::OnEraseBackground
3991 // ---------------------------------------------------------------------------
3992 // moving and resizing
3993 // ---------------------------------------------------------------------------
3995 bool wxWindowOS2::HandleMinimize()
3997 wxIconizeEvent
vEvent(m_windowId
);
3999 vEvent
.SetEventObject(this);
4000 return GetEventHandler()->ProcessEvent(vEvent
);
4001 } // end of wxWindowOS2::HandleMinimize
4003 bool wxWindowOS2::HandleMaximize()
4005 wxMaximizeEvent
vEvent(m_windowId
);
4007 vEvent
.SetEventObject(this);
4008 return GetEventHandler()->ProcessEvent(vEvent
);
4009 } // end of wxWindowOS2::HandleMaximize
4011 bool wxWindowOS2::HandleMove(
4016 wxMoveEvent
vEvent(wxPoint(nX
, nY
), m_windowId
);
4018 vEvent
.SetEventObject(this);
4019 return GetEventHandler()->ProcessEvent(vEvent
);
4020 } // end of wxWindowOS2::HandleMove
4022 bool wxWindowOS2::HandleSize(
4025 , WXUINT
WXUNUSED(nFlag
)
4028 wxSizeEvent
vEvent(wxSize(nWidth
, nHeight
), m_windowId
);
4030 vEvent
.SetEventObject(this);
4031 return GetEventHandler()->ProcessEvent(vEvent
);
4032 } // end of wxWindowOS2::HandleSize
4034 bool wxWindowOS2::HandleGetMinMaxInfo(
4044 ::WinGetMaxPosition(GetHwnd(), pSwp
);
4045 m_maxWidth
= pSwp
->cx
;
4046 m_maxHeight
= pSwp
->cy
;
4050 ::WinGetMinPosition(GetHwnd(), pSwp
, &vPoint
);
4051 m_minWidth
= pSwp
->cx
;
4052 m_minHeight
= pSwp
->cy
;
4059 } // end of wxWindowOS2::HandleGetMinMaxInfo
4061 // ---------------------------------------------------------------------------
4063 // ---------------------------------------------------------------------------
4064 bool wxWindowOS2::HandleCommand(
4070 #if wxUSE_MENUS_NATIVE
4071 if (wxCurrentPopupMenu
)
4073 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
4075 wxCurrentPopupMenu
= NULL
;
4076 return pPopupMenu
->OS2Command(wCmd
, wId
);
4078 #endif // wxUSE_MENUS_NATIVE
4080 wxWindow
* pWin
= FindItem(wId
);
4084 pWin
= wxFindWinFromHandle(hControl
);
4088 return pWin
->OS2Command(wCmd
, wId
);
4091 } // end of wxWindowOS2::HandleCommand
4093 bool wxWindowOS2::HandleSysCommand(
4095 , WXLPARAM
WXUNUSED(lParam
)
4099 // 4 bits are reserved
4101 switch (SHORT1FROMMP(wParam
))
4104 return HandleMaximize();
4107 return HandleMinimize();
4110 } // end of wxWindowOS2::HandleSysCommand
4112 // ---------------------------------------------------------------------------
4114 // ---------------------------------------------------------------------------
4115 //TODO!!! check against MSW
4116 void wxWindowOS2::InitMouseEvent(
4117 wxMouseEvent
& rEvent
4125 rEvent
.m_shiftDown
= ((uFlags
& VK_SHIFT
) != 0);
4126 rEvent
.m_controlDown
= ((uFlags
& VK_CTRL
) != 0);
4127 rEvent
.m_leftDown
= ((uFlags
& VK_BUTTON1
) != 0);
4128 rEvent
.m_middleDown
= ((uFlags
& VK_BUTTON3
) != 0);
4129 rEvent
.m_rightDown
= ((uFlags
& VK_BUTTON2
) != 0);
4130 rEvent
.SetTimestamp(s_currentMsg
.time
);
4131 rEvent
.m_eventObject
= this;
4132 rEvent
.SetId(GetId());
4134 #if wxUSE_MOUSEEVENT_HACK
4137 m_lastMouseEvent
= rEvent
.GetEventType();
4138 #endif // wxUSE_MOUSEEVENT_HACK
4139 } // end of wxWindowOS2::InitMouseEvent
4141 bool wxWindowOS2::HandleMouseEvent(
4148 bool bProcessed
= FALSE
;
4151 // The mouse events take consecutive IDs from WM_MOUSEFIRST to
4152 // WM_MOUSELAST, so it's enough to substract WM_MOUSEMOVE == WM_MOUSEFIRST
4153 // from the message id and take the value in the table to get wxWin event
4156 static const wxEventType eventsMouse
[] =
4170 wxMouseEvent
vEvent(eventsMouse
[uMsg
- WM_MOUSEMOVE
]);
4172 InitMouseEvent( vEvent
4178 bProcessed
= GetEventHandler()->ProcessEvent(vEvent
);
4181 HPOINTER hPtr
= ::WinQuerySysPointer(HWND_DESKTOP
, SPTR_WAIT
, FALSE
);
4182 HPOINTER hCursor
= (HPOINTER
)GetCursor().GetHCURSOR();
4184 if (hCursor
!= NULLHANDLE
)
4186 ::WinSetPointer(HWND_DESKTOP
, hCursor
);
4190 return GetEventHandler()->ProcessEvent(vEvent
);
4191 } // end of wxWindowOS2::HandleMouseEvent
4193 bool wxWindowOS2::HandleMouseMove(
4199 if (!m_bMouseInWindow
)
4202 // Generate an ENTER event
4204 m_bMouseInWindow
= TRUE
;
4206 wxMouseEvent
vEvent(wxEVT_ENTER_WINDOW
);
4208 InitMouseEvent( vEvent
4214 (void)GetEventHandler()->ProcessEvent(vEvent
);
4216 return HandleMouseEvent( WM_MOUSEMOVE
4221 } // end of wxWindowOS2::HandleMouseMove
4223 // ---------------------------------------------------------------------------
4224 // keyboard handling
4225 // ---------------------------------------------------------------------------
4228 // Create the key event of the given type for the given key - used by
4229 // HandleChar and HandleKeyDown/Up
4231 wxKeyEvent
wxWindowOS2::CreateKeyEvent(
4238 wxKeyEvent
vEvent(eType
);
4240 vEvent
.SetId(GetId());
4241 vEvent
.m_shiftDown
= IsShiftDown();
4242 vEvent
.m_controlDown
= IsCtrlDown();
4243 vEvent
.m_altDown
= (HIWORD(lParam
) & KC_ALT
) == KC_ALT
;
4245 vEvent
.m_eventObject
= (wxWindow
*)this; // const_cast
4246 vEvent
.m_keyCode
= nId
;
4247 vEvent
.m_rawCode
= (wxUint32
)wParam
;
4248 vEvent
.m_rawFlags
= (wxUint32
)lParam
;
4249 vEvent
.SetTimestamp(s_currentMsg
.time
);
4252 // Translate the position to client coords
4257 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
4258 ::WinQueryWindowRect( GetHwnd()
4262 vPoint
.x
-= vRect
.xLeft
;
4263 vPoint
.y
-= vRect
.yBottom
;
4265 vEvent
.m_x
= vPoint
.x
;
4266 vEvent
.m_y
= vPoint
.y
;
4269 } // end of wxWindowOS2::CreateKeyEvent
4272 // isASCII is TRUE only when we're called from WM_CHAR handler and not from
4275 bool wxWindowOS2::HandleChar(
4281 bool bCtrlDown
= FALSE
;
4284 if (m_bLastKeydownProcessed
)
4287 // The key was handled in the EVT_KEY_DOWN. Handling a key in an
4288 // EVT_KEY_DOWN handler is meant, by design, to prevent EVT_CHARs
4289 // from happening, so just bail out at this point.
4291 m_bLastKeydownProcessed
= FALSE
;
4297 // If 1 -> 26, translate to either special keycode or just set
4298 // ctrlDown. IOW, Ctrl-C should result in keycode == 3 and
4299 // ControlDown() == TRUE.
4301 vId
= SHORT1FROMMP(lParam
);
4302 if ((vId
> 0) && (vId
< 27))
4324 else // we're called from WM_KEYDOWN
4326 vId
= wxCharCodeOS2ToWX((int)SHORT2FROMMP(lParam
));
4331 wxKeyEvent
vEvent(CreateKeyEvent( wxEVT_CHAR
4338 vEvent
.m_controlDown
= TRUE
;
4340 return (GetEventHandler()->ProcessEvent(vEvent
));
4343 bool wxWindowOS2::HandleKeyDown(
4348 int nId
= wxCharCodeOS2ToWX((int)SHORT2FROMMP(lParam
));
4353 // Normal ASCII char
4355 nId
= SHORT1FROMMP(lParam
);
4360 wxKeyEvent
vEvent(CreateKeyEvent( wxEVT_KEY_DOWN
4366 if (GetEventHandler()->ProcessEvent(vEvent
))
4372 } // end of wxWindowOS2::HandleKeyDown
4374 bool wxWindowOS2::HandleKeyUp(
4379 int nId
= wxCharCodeOS2ToWX((int)SHORT2FROMMP(lParam
));
4384 // Normal ASCII char
4391 wxKeyEvent
vEvent(CreateKeyEvent( wxEVT_KEY_UP
4397 if (GetEventHandler()->ProcessEvent(vEvent
))
4401 } // end of wxWindowOS2::HandleKeyUp
4403 // ---------------------------------------------------------------------------
4405 // ---------------------------------------------------------------------------
4407 // ---------------------------------------------------------------------------
4409 // ---------------------------------------------------------------------------
4411 bool wxWindowOS2::OS2OnScroll(
4420 wxWindow
* pChild
= wxFindWinFromHandle(hControl
);
4423 return pChild
->OS2OnScroll( nOrientation
4430 wxScrollWinEvent vEvent
;
4432 vEvent
.SetPosition(wPos
);
4433 vEvent
.SetOrientation(nOrientation
);
4434 vEvent
.m_eventObject
= this;
4439 vEvent
.m_eventType
= wxEVT_SCROLLWIN_LINEUP
;
4443 vEvent
.m_eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
4447 vEvent
.m_eventType
= wxEVT_SCROLLWIN_PAGEUP
;
4451 vEvent
.m_eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
4454 case SB_SLIDERPOSITION
:
4455 vEvent
.m_eventType
= wxEVT_SCROLLWIN_THUMBRELEASE
;
4458 case SB_SLIDERTRACK
:
4459 vEvent
.m_eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
4465 return GetEventHandler()->ProcessEvent(vEvent
);
4466 } // end of wxWindowOS2::OS2OnScroll
4468 void wxWindowOS2::MoveChildren(
4473 // We want to handle top levels ourself, manually
4475 if (!IsTopLevel() && GetAutoLayout())
4483 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
4485 pNode
= pNode
->GetNext())
4487 wxWindow
* pWin
= pNode
->GetData();
4489 ::WinQueryWindowPos( GetHwndOf(pWin
)
4492 if (pWin
->IsKindOf(CLASSINFO(wxControl
)))
4497 // Must deal with controls that have margins like ENTRYFIELD. The SWP
4498 // struct of such a control will have and origin offset from its intended
4499 // position by the width of the margins.
4501 pCtrl
= wxDynamicCast(pWin
, wxControl
);
4502 vSwp
.y
-= pCtrl
->GetYComp();
4503 vSwp
.x
-= pCtrl
->GetXComp();
4505 ::WinSetWindowPos( GetHwndOf(pWin
)
4511 ,SWP_MOVE
| SWP_SHOW
| SWP_ZORDER
4513 ::WinQueryWindowPos(GetHwndOf(pWin
), pWin
->GetSwp());
4514 if (pWin
->IsKindOf(CLASSINFO(wxRadioBox
)))
4516 wxRadioBox
* pRadioBox
;
4518 pRadioBox
= wxDynamicCast(pWin
, wxRadioBox
);
4519 pRadioBox
->AdjustButtons( (int)vSwp
.x
4520 ,(int)vSwp
.y
- nDiff
4523 ,pRadioBox
->GetSizeFlags()
4526 if (pWin
->IsKindOf(CLASSINFO(wxSlider
)))
4530 pSlider
= wxDynamicCast(pWin
, wxSlider
);
4531 pSlider
->AdjustSubControls( (int)vSwp
.x
4532 ,(int)vSwp
.y
- nDiff
4535 ,(int)pSlider
->GetSizeFlags()
4541 } // end of wxWindowOS2::MoveChildren
4544 // Getting the Y position for a window, like a control, is a real
4545 // pain. There are three sitatuions we must deal with in determining
4546 // the OS2 to wxWindows Y coordinate.
4548 // 1) The controls are created in a dialog.
4549 // This is the easiest since a dialog is created with its original
4550 // size so the standard: Y = ParentHeight - (Y + ControlHeight);
4552 // 2) The controls are direct children of a frame
4553 // In this instance the controls are actually children of the Frame's
4554 // client. During creation the frame's client resizes several times
4555 // during creation of the status bar and toolbars. The CFrame class
4556 // will take care of this using its AlterChildPos proc.
4558 // 3) The controls are children of a panel, which in turn is a child of
4560 // The panel may be one of many, in which case the same treatment
4561 // as 1 applies. It may be the only child, though.
4562 // This is the nastiest case. A panel is created as the only child of
4563 // the frame and as such, when a frame has only one child, the child is
4564 // expanded to fit the entire client area of the frame. Because the
4565 // controls are created BEFORE this occurs their positions are totally
4566 // whacked and any call to WinQueryWindowPos will return invalid
4567 // coordinates. So for this situation we have to compare the size of
4568 // the panel at control creation time with that of the frame client. If
4569 // they are the same we can use the standard Y position equation. If
4570 // not, then we must use the Frame Client's dimensions to position them
4571 // as that will be the eventual size of the panel after the frame resizes
4574 int wxWindowOS2::GetOS2ParentHeight(
4575 wxWindowOS2
* pParent
4578 wxWindowOS2
* pGrandParent
= NULL
;
4583 if (pParent
->IsKindOf(CLASSINFO(wxDialog
)))
4584 return(pParent
->GetClientSize().y
);
4587 // Case 2 -- if we are one of the separately built standard Frame
4588 // children, like a statusbar, menubar, or toolbar we want to
4589 // use the frame, itself, for positioning. Otherwise we are
4590 // child window and want to use the Frame's client.
4592 else if (pParent
->IsKindOf(CLASSINFO(wxFrame
)))
4594 if (IsKindOf(CLASSINFO(wxStatusBar
)) ||
4595 IsKindOf(CLASSINFO(wxMenuBar
)) ||
4596 IsKindOf(CLASSINFO(wxToolBar
))
4599 if (IsKindOf(CLASSINFO(wxToolBar
)))
4601 wxFrame
* pFrame
= wxDynamicCast(GetParent(), wxFrame
);
4603 if (pFrame
->GetToolBar() == this)
4604 return(pParent
->GetSize().y
);
4606 return(pParent
->GetClientSize().y
);
4609 return(pParent
->GetSize().y
);
4612 return(pParent
->GetClientSize().y
);
4615 // Case -- this is for any window that is the sole child of a Frame.
4616 // The grandparent must exist and it must be of type CFrame
4617 // and it's height must be different. Otherwise the standard
4622 return(pParent
->GetClientSize().y
);
4625 } // end of wxWindowOS2::GetOS2ParentHeight
4628 // OS/2 needs a lot extra manipulation to deal with layouts
4629 // for canvas windows, particularly scrolled ones.
4631 wxWindowCreationHook::wxWindowCreationHook(
4632 wxWindow
* pWinBeingCreated
4635 gpWinBeingCreated
= pWinBeingCreated
;
4636 } // end of wxWindowCreationHook::wxWindowCreationHook
4638 wxWindowCreationHook::~wxWindowCreationHook()
4640 gpWinBeingCreated
= NULL
;
4641 } // end of wxWindowCreationHook::~wxWindowCreationHook
4643 // ===========================================================================
4645 // ===========================================================================
4651 ,wxFont
* WXUNUSED(pTheFont
)
4658 hPS
=::WinGetPS(hWnd
);
4660 rc
= ::GpiQueryFontMetrics(hPS
, sizeof(FONTMETRICS
), &vFM
);
4664 *pX
= vFM
.lAveCharWidth
;
4666 *pY
= vFM
.lEmHeight
+ vFM
.lExternalLeading
;
4675 ::WinReleasePS(hPS
);
4676 } // end of wxGetCharSize
4679 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
4680 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
4682 int wxCharCodeOS2ToWX(
4690 case VK_BACKTAB
: nId
= WXK_BACK
; break;
4691 case VK_TAB
: nId
= WXK_TAB
; break;
4692 case VK_CLEAR
: nId
= WXK_CLEAR
; break;
4693 case VK_ENTER
: nId
= WXK_RETURN
; break;
4694 case VK_SHIFT
: nId
= WXK_SHIFT
; break;
4695 case VK_CTRL
: nId
= WXK_CONTROL
; break;
4696 case VK_PAUSE
: nId
= WXK_PAUSE
; break;
4697 case VK_SPACE
: nId
= WXK_SPACE
; break;
4698 case VK_ESC
: nId
= WXK_ESCAPE
; break;
4699 case VK_END
: nId
= WXK_END
; break;
4700 case VK_HOME
: nId
= WXK_HOME
; break;
4701 case VK_LEFT
: nId
= WXK_LEFT
; break;
4702 case VK_UP
: nId
= WXK_UP
; break;
4703 case VK_RIGHT
: nId
= WXK_RIGHT
; break;
4704 case VK_DOWN
: nId
= WXK_DOWN
; break;
4705 case VK_PRINTSCRN
: nId
= WXK_PRINT
; break;
4706 case VK_INSERT
: nId
= WXK_INSERT
; break;
4707 case VK_DELETE
: nId
= WXK_DELETE
; break;
4708 case VK_CAPSLOCK
: nId
= WXK_CAPITAL
; break;
4709 case VK_F1
: nId
= WXK_F1
; break;
4710 case VK_F2
: nId
= WXK_F2
; break;
4711 case VK_F3
: nId
= WXK_F3
; break;
4712 case VK_F4
: nId
= WXK_F4
; break;
4713 case VK_F5
: nId
= WXK_F5
; break;
4714 case VK_F6
: nId
= WXK_F6
; break;
4715 case VK_F7
: nId
= WXK_F7
; break;
4716 case VK_F8
: nId
= WXK_F8
; break;
4717 case VK_F9
: nId
= WXK_F9
; break;
4718 case VK_F10
: nId
= WXK_F10
; break;
4719 case VK_F11
: nId
= WXK_F11
; break;
4720 case VK_F12
: nId
= WXK_F12
; break;
4721 case VK_F13
: nId
= WXK_F13
; break;
4722 case VK_F14
: nId
= WXK_F14
; break;
4723 case VK_F15
: nId
= WXK_F15
; break;
4724 case VK_F16
: nId
= WXK_F16
; break;
4725 case VK_F17
: nId
= WXK_F17
; break;
4726 case VK_F18
: nId
= WXK_F18
; break;
4727 case VK_F19
: nId
= WXK_F19
; break;
4728 case VK_F20
: nId
= WXK_F20
; break;
4729 case VK_F21
: nId
= WXK_F21
; break;
4730 case VK_F22
: nId
= WXK_F22
; break;
4731 case VK_F23
: nId
= WXK_F23
; break;
4732 case VK_F24
: nId
= WXK_F24
; break;
4733 case VK_OEM_1
: nId
= ';'; break;
4734 case VK_OEM_PLUS
: nId
= '+'; break;
4735 case VK_OEM_COMMA
: nId
= ','; break;
4736 case VK_OEM_MINUS
: nId
= '-'; break;
4737 case VK_OEM_PERIOD
: nId
= '.'; break;
4738 case VK_OEM_2
: nId
= '/'; break;
4739 case VK_OEM_3
: nId
= '~'; break;
4740 case VK_OEM_4
: nId
= '['; break;
4741 case VK_OEM_5
: nId
= '\\'; break;
4742 case VK_OEM_6
: nId
= ']'; break;
4743 case VK_OEM_7
: nId
= '\''; break;
4744 case VK_NUMLOCK
: nId
= WXK_NUMLOCK
; break;
4745 case VK_SCRLLOCK
: nId
= WXK_SCROLL
; break;
4752 } // end of wxCharCodeOS2ToWX
4754 int wxCharCodeWXToOS2(
4764 case WXK_CLEAR
: nKeySym
= VK_CLEAR
; break;
4765 case WXK_SHIFT
: nKeySym
= VK_SHIFT
; break;
4766 case WXK_CONTROL
: nKeySym
= VK_CTRL
; break;
4767 case WXK_PAUSE
: nKeySym
= VK_PAUSE
; break;
4768 case WXK_END
: nKeySym
= VK_END
; break;
4769 case WXK_HOME
: nKeySym
= VK_HOME
; break;
4770 case WXK_LEFT
: nKeySym
= VK_LEFT
; break;
4771 case WXK_UP
: nKeySym
= VK_UP
; break;
4772 case WXK_RIGHT
: nKeySym
= VK_RIGHT
; break;
4773 case WXK_DOWN
: nKeySym
= VK_DOWN
; break;
4774 case WXK_PRINT
: nKeySym
= VK_PRINTSCRN
; break;
4775 case WXK_INSERT
: nKeySym
= VK_INSERT
; break;
4776 case WXK_DELETE
: nKeySym
= VK_DELETE
; break;
4777 case WXK_F1
: nKeySym
= VK_F1
; break;
4778 case WXK_F2
: nKeySym
= VK_F2
; break;
4779 case WXK_F3
: nKeySym
= VK_F3
; break;
4780 case WXK_F4
: nKeySym
= VK_F4
; break;
4781 case WXK_F5
: nKeySym
= VK_F5
; break;
4782 case WXK_F6
: nKeySym
= VK_F6
; break;
4783 case WXK_F7
: nKeySym
= VK_F7
; break;
4784 case WXK_F8
: nKeySym
= VK_F8
; break;
4785 case WXK_F9
: nKeySym
= VK_F9
; break;
4786 case WXK_F10
: nKeySym
= VK_F10
; break;
4787 case WXK_F11
: nKeySym
= VK_F11
; break;
4788 case WXK_F12
: nKeySym
= VK_F12
; break;
4789 case WXK_F13
: nKeySym
= VK_F13
; break;
4790 case WXK_F14
: nKeySym
= VK_F14
; break;
4791 case WXK_F15
: nKeySym
= VK_F15
; break;
4792 case WXK_F16
: nKeySym
= VK_F16
; break;
4793 case WXK_F17
: nKeySym
= VK_F17
; break;
4794 case WXK_F18
: nKeySym
= VK_F18
; break;
4795 case WXK_F19
: nKeySym
= VK_F19
; break;
4796 case WXK_F20
: nKeySym
= VK_F20
; break;
4797 case WXK_F21
: nKeySym
= VK_F21
; break;
4798 case WXK_F22
: nKeySym
= VK_F22
; break;
4799 case WXK_F23
: nKeySym
= VK_F23
; break;
4800 case WXK_F24
: nKeySym
= VK_F24
; break;
4801 case WXK_NUMLOCK
: nKeySym
= VK_NUMLOCK
; break;
4802 case WXK_SCROLL
: nKeySym
= VK_SCRLLOCK
; break;
4805 *bIsVirtual
= FALSE
;
4811 } // end of wxCharCodeWXToOS2
4813 wxWindow
* wxGetActiveWindow()
4815 HWND hWnd
= ::WinQueryActiveWindow(HWND_DESKTOP
);
4819 return wxFindWinFromHandle((WXHWND
)hWnd
);
4822 } // end of wxGetActiveWindow
4825 const char* wxGetMessageName(
4830 case 0x0000: return "WM_NULL";
4831 case 0x0001: return "WM_CREATE";
4832 case 0x0002: return "WM_DESTROY";
4833 case 0x0004: return "WM_ENABLE";
4834 case 0x0005: return "WM_SHOW";
4835 case 0x0006: return "WM_MOVE";
4836 case 0x0007: return "WM_SIZE";
4837 case 0x0008: return "WM_ADJUSTWINDOWPOS";
4838 case 0x0009: return "WM_CALCVALIDRECTS";
4839 case 0x000A: return "WM_SETWINDOWPARAMS";
4840 case 0x000B: return "WM_QUERYWINDOWPARAMS";
4841 case 0x000C: return "WM_HITTEST";
4842 case 0x000D: return "WM_ACTIVATE";
4843 case 0x000F: return "WM_SETFOCUS";
4844 case 0x0010: return "WM_SETSELECTION";
4845 case 0x0011: return "WM_PPAINT";
4846 case 0x0012: return "WM_PSETFOCUS";
4847 case 0x0013: return "WM_PSYSCOLORCHANGE";
4848 case 0x0014: return "WM_PSIZE";
4849 case 0x0015: return "WM_PACTIVATE";
4850 case 0x0016: return "WM_PCONTROL";
4851 case 0x0020: return "WM_COMMAND";
4852 case 0x0021: return "WM_SYSCOMMAND";
4853 case 0x0022: return "WM_HELP";
4854 case 0x0023: return "WM_PAINT";
4855 case 0x0024: return "WM_TIMER";
4856 case 0x0025: return "WM_SEM1";
4857 case 0x0026: return "WM_SEM2";
4858 case 0x0027: return "WM_SEM3";
4859 case 0x0028: return "WM_SEM4";
4860 case 0x0029: return "WM_CLOSE";
4861 case 0x002A: return "WM_QUIT";
4862 case 0x002B: return "WM_SYSCOLORCHANGE";
4863 case 0x002D: return "WM_SYSVALUECHANGE";
4864 case 0x002E: return "WM_APPTERMINATENOTIFY";
4865 case 0x002F: return "WM_PRESPARAMCHANGED";
4866 // Control notification messages
4867 case 0x0030: return "WM_CONTROL";
4868 case 0x0031: return "WM_VSCROLL";
4869 case 0x0032: return "WM_HSCROLL";
4870 case 0x0033: return "WM_INITMENU";
4871 case 0x0034: return "WM_MENUSELECT";
4872 case 0x0035: return "WM_MENUSEND";
4873 case 0x0036: return "WM_DRAWITEM";
4874 case 0x0037: return "WM_MEASUREITEM";
4875 case 0x0038: return "WM_CONTROLPOINTER";
4876 case 0x003A: return "WM_QUERYDLGCODE";
4877 case 0x003B: return "WM_INITDLG";
4878 case 0x003C: return "WM_SUBSTITUTESTRING";
4879 case 0x003D: return "WM_MATCHMNEMONIC";
4880 case 0x003E: return "WM_SAVEAPPLICATION";
4881 case 0x0129: return "WM_CTLCOLORCHANGE";
4882 case 0x0130: return "WM_QUERYCTLTYPE";
4884 case 0x0040: return "WM_FLASHWINDOW";
4885 case 0x0041: return "WM_FORMATFRAME";
4886 case 0x0042: return "WM_UPDATEFRAME";
4887 case 0x0043: return "WM_FOCUSCHANGE";
4888 case 0x0044: return "WM_SETBORDERSIZE";
4889 case 0x0045: return "WM_TRACKFRAME";
4890 case 0x0046: return "WM_MINMAXFRAME";
4891 case 0x0047: return "WM_SETICON";
4892 case 0x0048: return "WM_QUERYICON";
4893 case 0x0049: return "WM_SETACCELTABLE";
4894 case 0x004A: return "WM_QUERYACCELTABLE";
4895 case 0x004B: return "WM_TRANSLATEACCEL";
4896 case 0x004C: return "WM_QUERYTRACKINFO";
4897 case 0x004D: return "WM_QUERYBORDERSIZE";
4898 case 0x004E: return "WM_NEXTMENU";
4899 case 0x004F: return "WM_ERASEBACKGROUND";
4900 case 0x0050: return "WM_QUERYFRAMEINFO";
4901 case 0x0051: return "WM_QUERYFOCUSCHAIN";
4902 case 0x0052: return "WM_OWNERPOSCHANGE";
4903 case 0x0053: return "WM_CACLFRAMERECT";
4904 case 0x0055: return "WM_WINDOWPOSCHANGED";
4905 case 0x0056: return "WM_ADJUSTFRAMEPOS";
4906 case 0x0059: return "WM_QUERYFRAMECTLCOUNT";
4907 case 0x005B: return "WM_QUERYHELPINFO";
4908 case 0x005C: return "WM_SETHELPINFO";
4909 case 0x005D: return "WM_ERROR";
4910 case 0x005E: return "WM_REALIZEPALETTE";
4911 // Clipboard messages
4912 case 0x0060: return "WM_RENDERFMT";
4913 case 0x0061: return "WM_RENDERALLFMTS";
4914 case 0x0062: return "WM_DESTROYCLIPBOARD";
4915 case 0x0063: return "WM_PAINTCLIPBOARD";
4916 case 0x0064: return "WM_SIZECLIPBOARD";
4917 case 0x0065: return "WM_HSCROLLCLIPBOARD";
4918 case 0x0066: return "WM_VSCROLLCLIPBOARD";
4919 case 0x0067: return "WM_DRAWCLIPBOARD";
4921 case 0x0070: return "WM_MOUSEMOVE";
4922 case 0x0071: return "WM_BUTTON1DOWN";
4923 case 0x0072: return "WM_BUTTON1UP";
4924 case 0x0073: return "WM_BUTTON1DBLCLK";
4925 case 0x0074: return "WM_BUTTON2DOWN";
4926 case 0x0075: return "WM_BUTTON2UP";
4927 case 0x0076: return "WM_BUTTON2DBLCLK";
4928 case 0x0077: return "WM_BUTTON3DOWN";
4929 case 0x0078: return "WM_BUTTON3UP";
4930 case 0x0079: return "WM_BUTTON3DBLCLK";
4931 case 0x007D: return "WM_MOUSEMAP";
4932 case 0x007E: return "WM_VRNDISABLED";
4933 case 0x007F: return "WM_VRNENABLED";
4934 case 0x0410: return "WM_CHORD";
4935 case 0x0411: return "WM_BUTTON1MOTIONSTART";
4936 case 0x0412: return "WM_BUTTON1MOTIONEND";
4937 case 0x0413: return "WM_BUTTON1CLICK";
4938 case 0x0414: return "WM_BUTTON2MOTIONSTART";
4939 case 0x0415: return "WM_BUTTON2MOTIONEND";
4940 case 0x0416: return "WM_BUTTON2CLICK";
4941 case 0x0417: return "WM_BUTTON3MOTIONSTART";
4942 case 0x0418: return "WM_BUTTON3MOTIONEND";
4943 case 0x0419: return "WM_BUTTON3CLICK";
4944 case 0x0420: return "WM_BEGINDRAG";
4945 case 0x0421: return "WM_ENDDRAG";
4946 case 0x0422: return "WM_SINGLESELECT";
4947 case 0x0423: return "WM_OPEN";
4948 case 0x0424: return "WM_CONTEXTMENU";
4949 case 0x0425: return "WM_CONTEXTHELP";
4950 case 0x0426: return "WM_TEXTEDIT";
4951 case 0x0427: return "WM_BEGINSELECT";
4952 case 0x0228: return "WM_ENDSELECT";
4953 case 0x0429: return "WM_PICKUP";
4954 case 0x04C0: return "WM_PENFIRST";
4955 case 0x04FF: return "WM_PENLAST";
4956 case 0x0500: return "WM_MMPMFIRST";
4957 case 0x05FF: return "WM_MMPMLAST";
4958 case 0x0600: return "WM_STDDLGFIRST";
4959 case 0x06FF: return "WM_STDDLGLAST";
4960 case 0x0BD0: return "WM_BIDI_FIRST";
4961 case 0x0BFF: return "WM_BIDI_LAST";
4963 case 0x007A: return "WM_CHAR";
4964 case 0x007B: return "WM_VIOCHAR";
4966 case 0x00A0: return "WM_DDE_INITIATE";
4967 case 0x00A1: return "WM_DDE_REQUEST";
4968 case 0x00A2: return "WM_DDE_ACK";
4969 case 0x00A3: return "WM_DDE_DATA";
4970 case 0x00A4: return "WM_DDE_ADVISE";
4971 case 0x00A5: return "WM_DDE_UNADVISE";
4972 case 0x00A6: return "WM_DDE_POKE";
4973 case 0x00A7: return "WM_DDE_EXECUTE";
4974 case 0x00A8: return "WM_DDE_TERMINATE";
4975 case 0x00A9: return "WM_DDE_INITIATEACK";
4976 case 0x00AF: return "WM_DDE_LAST";
4978 case 0x0120: return "BM_CLICK";
4979 case 0x0121: return "BM_QUERYCHECKINDEX";
4980 case 0x0122: return "BM_QUERYHILITE";
4981 case 0x0123: return "BM_SETHILITE";
4982 case 0x0124: return "BM_QUERYCHECK";
4983 case 0x0125: return "BM_SETCHECK";
4984 case 0x0126: return "BM_SETDEFAULT";
4985 case 0x0128: return "BM_AUTOSIZE";
4987 case 0x029A: return "CBID_LIST";
4988 case 0x029B: return "CBID_EDIT";
4989 case 0x0170: return "CBM_SHOWLIST";
4990 case 0x0171: return "CBM_HILITE";
4991 case 0x0172: return "CBM_ISLISTSHOWING";
4993 case 0x0140: return "EM_QUERYCHANGED";
4994 case 0x0141: return "EM_QUERYSEL";
4995 case 0x0142: return "EM_SETSEL";
4996 case 0x0143: return "EM_SETTEXTLIMIT";
4997 case 0x0144: return "EM_CUT";
4998 case 0x0145: return "EM_COPY";
4999 case 0x0146: return "EM_CLEAR";
5000 case 0x0147: return "EM_PASTE";
5001 case 0x0148: return "EM_QUERYFIRSTCHAR";
5002 case 0x0149: return "EM_SETFIRSTCHAR";
5003 case 0x014A: return "EM_QUERYREADONLY";
5004 case 0x014B: return "EM_SETREADONLY";
5005 case 0x014C: return "EM_SETINSERTMODE";
5007 case 0x0160: return "LM_QUERYITEMCOUNT";
5008 case 0x0161: return "LM_INSERTITEM";
5009 case 0x0162: return "LM_SETOPENINDEX";
5010 case 0x0163: return "LM_DELETEITEM";
5011 case 0x0164: return "LM_SELECTITEM";
5012 case 0x0165: return "LM_QUERYSELECTION";
5013 case 0x0166: return "LM_SETITEMTEXT";
5014 case 0x0167: return "LM_QUERYITEMTEXTLENGTH";
5015 case 0x0168: return "LM_QUERYITEMTEXT";
5016 case 0x0169: return "LM_SETITEMHANDLE";
5017 case 0x016A: return "LM_QUERYITEMHANDLE";
5018 case 0x016B: return "LM_SEARCHSTRING";
5019 case 0x016C: return "LM_SETITEMHEIGHT";
5020 case 0x016D: return "LM_QUERYTOPINDEX";
5021 case 0x016E: return "LM_DELETEALL";
5022 case 0x016F: return "LM_INSERTMULITEMS";
5023 case 0x0660: return "LM_SETITEMWIDTH";
5025 case 0x0180: return "MM_INSERTITEM";
5026 case 0x0181: return "MM_DELETEITEM";
5027 case 0x0182: return "MM_QUERYITEM";
5028 case 0x0183: return "MM_SETITEM";
5029 case 0x0184: return "MM_QUERYITEMCOUNT";
5030 case 0x0185: return "MM_STARTMENUMODE";
5031 case 0x0186: return "MM_ENDMENUMODE";
5032 case 0x0188: return "MM_REMOVEITEM";
5033 case 0x0189: return "MM_SELECTITEM";
5034 case 0x018A: return "MM_QUERYSELITEMID";
5035 case 0x018B: return "MM_QUERYITEMTEXT";
5036 case 0x018C: return "MM_QUERYITEMTEXTLENGTH";
5037 case 0x018D: return "MM_SETITEMHANDLE";
5038 case 0x018E: return "MM_SETITEMTEXT";
5039 case 0x018F: return "MM_ITEMPOSITIONFROMID";
5040 case 0x0190: return "MM_ITEMIDFROMPOSITION";
5041 case 0x0191: return "MM_QUERYITEMATTR";
5042 case 0x0192: return "MM_SETITEMATTR";
5043 case 0x0193: return "MM_ISITEMVALID";
5044 case 0x0194: return "MM_QUERYITEMRECT";
5045 case 0x0431: return "MM_QUERYDEFAULTITEMID";
5046 case 0x0432: return "MM_SETDEFAULTITEMID";
5048 case 0x01A0: return "SBM_SETSCROLLBAR";
5049 case 0x01A1: return "SBM_SETPOS";
5050 case 0x01A2: return "SBM_QUERYPOS";
5051 case 0x01A3: return "SBM_QUERYRANGE";
5052 case 0x01A6: return "SBM_SETTHUMBSIZE";
5055 case 0x0F00: return "WM_HELPBASE";
5056 case 0x0FFF: return "WM_HELPTOP";
5057 // Beginning of user defined messages
5058 case 0x1000: return "WM_USER";
5060 // wxWindows user defined types
5063 // case 0x1000 + 0: return "LVM_GETBKCOLOR";
5064 case 0x1000 + 1: return "LVM_SETBKCOLOR";
5065 case 0x1000 + 2: return "LVM_GETIMAGELIST";
5066 case 0x1000 + 3: return "LVM_SETIMAGELIST";
5067 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
5068 case 0x1000 + 5: return "LVM_GETITEMA";
5069 case 0x1000 + 75: return "LVM_GETITEMW";
5070 case 0x1000 + 6: return "LVM_SETITEMA";
5071 case 0x1000 + 76: return "LVM_SETITEMW";
5072 case 0x1000 + 7: return "LVM_INSERTITEMA";
5073 case 0x1000 + 77: return "LVM_INSERTITEMW";
5074 case 0x1000 + 8: return "LVM_DELETEITEM";
5075 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
5076 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
5077 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
5078 case 0x1000 + 12: return "LVM_GETNEXTITEM";
5079 case 0x1000 + 13: return "LVM_FINDITEMA";
5080 case 0x1000 + 83: return "LVM_FINDITEMW";
5081 case 0x1000 + 14: return "LVM_GETITEMRECT";
5082 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
5083 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
5084 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
5085 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
5086 case 0x1000 + 18: return "LVM_HITTEST";
5087 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
5088 case 0x1000 + 20: return "LVM_SCROLL";
5089 case 0x1000 + 21: return "LVM_REDRAWITEMS";
5090 case 0x1000 + 22: return "LVM_ARRANGE";
5091 case 0x1000 + 23: return "LVM_EDITLABELA";
5092 case 0x1000 + 118: return "LVM_EDITLABELW";
5093 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
5094 case 0x1000 + 25: return "LVM_GETCOLUMNA";
5095 case 0x1000 + 95: return "LVM_GETCOLUMNW";
5096 case 0x1000 + 26: return "LVM_SETCOLUMNA";
5097 case 0x1000 + 96: return "LVM_SETCOLUMNW";
5098 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
5099 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
5100 case 0x1000 + 28: return "LVM_DELETECOLUMN";
5101 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
5102 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
5103 case 0x1000 + 31: return "LVM_GETHEADER";
5104 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
5105 case 0x1000 + 34: return "LVM_GETVIEWRECT";
5106 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
5107 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
5108 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
5109 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
5110 case 0x1000 + 39: return "LVM_GETTOPINDEX";
5111 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
5112 case 0x1000 + 41: return "LVM_GETORIGIN";
5113 case 0x1000 + 42: return "LVM_UPDATE";
5114 case 0x1000 + 43: return "LVM_SETITEMSTATE";
5115 case 0x1000 + 44: return "LVM_GETITEMSTATE";
5116 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
5117 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
5118 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
5119 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
5120 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
5121 case 0x1000 + 48: return "LVM_SORTITEMS";
5122 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
5123 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
5124 case 0x1000 + 51: return "LVM_GETITEMSPACING";
5125 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
5126 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
5127 case 0x1000 + 53: return "LVM_SETICONSPACING";
5128 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
5129 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
5130 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
5131 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
5132 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
5133 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
5134 case 0x1000 + 60: return "LVM_SETHOTITEM";
5135 case 0x1000 + 61: return "LVM_GETHOTITEM";
5136 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
5137 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
5138 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
5139 case 0x1000 + 65: return "LVM_SETWORKAREA";
5142 case 0x1100 + 0: return "TVM_INSERTITEMA";
5143 case 0x1100 + 50: return "TVM_INSERTITEMW";
5144 case 0x1100 + 1: return "TVM_DELETEITEM";
5145 case 0x1100 + 2: return "TVM_EXPAND";
5146 case 0x1100 + 4: return "TVM_GETITEMRECT";
5147 case 0x1100 + 5: return "TVM_GETCOUNT";
5148 case 0x1100 + 6: return "TVM_GETINDENT";
5149 case 0x1100 + 7: return "TVM_SETINDENT";
5150 case 0x1100 + 8: return "TVM_GETIMAGELIST";
5151 case 0x1100 + 9: return "TVM_SETIMAGELIST";
5152 case 0x1100 + 10: return "TVM_GETNEXTITEM";
5153 case 0x1100 + 11: return "TVM_SELECTITEM";
5154 case 0x1100 + 12: return "TVM_GETITEMA";
5155 case 0x1100 + 62: return "TVM_GETITEMW";
5156 case 0x1100 + 13: return "TVM_SETITEMA";
5157 case 0x1100 + 63: return "TVM_SETITEMW";
5158 case 0x1100 + 14: return "TVM_EDITLABELA";
5159 case 0x1100 + 65: return "TVM_EDITLABELW";
5160 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
5161 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
5162 case 0x1100 + 17: return "TVM_HITTEST";
5163 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
5164 case 0x1100 + 19: return "TVM_SORTCHILDREN";
5165 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
5166 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
5167 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
5168 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
5169 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
5170 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
5171 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
5174 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
5175 case 0x1200 + 1: return "HDM_INSERTITEMA";
5176 case 0x1200 + 10: return "HDM_INSERTITEMW";
5177 case 0x1200 + 2: return "HDM_DELETEITEM";
5178 case 0x1200 + 3: return "HDM_GETITEMA";
5179 case 0x1200 + 11: return "HDM_GETITEMW";
5180 case 0x1200 + 4: return "HDM_SETITEMA";
5181 case 0x1200 + 12: return "HDM_SETITEMW";
5182 case 0x1200 + 5: return "HDM_LAYOUT";
5183 case 0x1200 + 6: return "HDM_HITTEST";
5184 case 0x1200 + 7: return "HDM_GETITEMRECT";
5185 case 0x1200 + 8: return "HDM_SETIMAGELIST";
5186 case 0x1200 + 9: return "HDM_GETIMAGELIST";
5187 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
5188 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
5189 case 0x1200 + 17: return "HDM_GETORDERARRAY";
5190 case 0x1200 + 18: return "HDM_SETORDERARRAY";
5191 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
5194 case 0x1300 + 2: return "TCM_GETIMAGELIST";
5195 case 0x1300 + 3: return "TCM_SETIMAGELIST";
5196 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
5197 case 0x1300 + 5: return "TCM_GETITEMA";
5198 case 0x1300 + 60: return "TCM_GETITEMW";
5199 case 0x1300 + 6: return "TCM_SETITEMA";
5200 case 0x1300 + 61: return "TCM_SETITEMW";
5201 case 0x1300 + 7: return "TCM_INSERTITEMA";
5202 case 0x1300 + 62: return "TCM_INSERTITEMW";
5203 case 0x1300 + 8: return "TCM_DELETEITEM";
5204 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
5205 case 0x1300 + 10: return "TCM_GETITEMRECT";
5206 case 0x1300 + 11: return "TCM_GETCURSEL";
5207 case 0x1300 + 12: return "TCM_SETCURSEL";
5208 case 0x1300 + 13: return "TCM_HITTEST";
5209 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
5210 case 0x1300 + 40: return "TCM_ADJUSTRECT";
5211 case 0x1300 + 41: return "TCM_SETITEMSIZE";
5212 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
5213 case 0x1300 + 43: return "TCM_SETPADDING";
5214 case 0x1300 + 44: return "TCM_GETROWCOUNT";
5215 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
5216 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
5217 case 0x1300 + 47: return "TCM_GETCURFOCUS";
5218 case 0x1300 + 48: return "TCM_SETCURFOCUS";
5219 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
5220 case 0x1300 + 50: return "TCM_DESELECTALL";
5223 case WM_USER
+1000+1: return "TB_ENABLEBUTTON";
5224 case WM_USER
+1000+2: return "TB_CHECKBUTTON";
5225 case WM_USER
+1000+3: return "TB_PRESSBUTTON";
5226 case WM_USER
+1000+4: return "TB_HIDEBUTTON";
5227 case WM_USER
+1000+5: return "TB_INDETERMINATE";
5228 case WM_USER
+1000+9: return "TB_ISBUTTONENABLED";
5229 case WM_USER
+1000+10: return "TB_ISBUTTONCHECKED";
5230 case WM_USER
+1000+11: return "TB_ISBUTTONPRESSED";
5231 case WM_USER
+1000+12: return "TB_ISBUTTONHIDDEN";
5232 case WM_USER
+1000+13: return "TB_ISBUTTONINDETERMINATE";
5233 case WM_USER
+1000+17: return "TB_SETSTATE";
5234 case WM_USER
+1000+18: return "TB_GETSTATE";
5235 case WM_USER
+1000+19: return "TB_ADDBITMAP";
5236 case WM_USER
+1000+20: return "TB_ADDBUTTONS";
5237 case WM_USER
+1000+21: return "TB_INSERTBUTTON";
5238 case WM_USER
+1000+22: return "TB_DELETEBUTTON";
5239 case WM_USER
+1000+23: return "TB_GETBUTTON";
5240 case WM_USER
+1000+24: return "TB_BUTTONCOUNT";
5241 case WM_USER
+1000+25: return "TB_COMMANDTOINDEX";
5242 case WM_USER
+1000+26: return "TB_SAVERESTOREA";
5243 case WM_USER
+1000+76: return "TB_SAVERESTOREW";
5244 case WM_USER
+1000+27: return "TB_CUSTOMIZE";
5245 case WM_USER
+1000+28: return "TB_ADDSTRINGA";
5246 case WM_USER
+1000+77: return "TB_ADDSTRINGW";
5247 case WM_USER
+1000+29: return "TB_GETITEMRECT";
5248 case WM_USER
+1000+30: return "TB_BUTTONSTRUCTSIZE";
5249 case WM_USER
+1000+31: return "TB_SETBUTTONSIZE";
5250 case WM_USER
+1000+32: return "TB_SETBITMAPSIZE";
5251 case WM_USER
+1000+33: return "TB_AUTOSIZE";
5252 case WM_USER
+1000+35: return "TB_GETTOOLTIPS";
5253 case WM_USER
+1000+36: return "TB_SETTOOLTIPS";
5254 case WM_USER
+1000+37: return "TB_SETPARENT";
5255 case WM_USER
+1000+39: return "TB_SETROWS";
5256 case WM_USER
+1000+40: return "TB_GETROWS";
5257 case WM_USER
+1000+42: return "TB_SETCMDID";
5258 case WM_USER
+1000+43: return "TB_CHANGEBITMAP";
5259 case WM_USER
+1000+44: return "TB_GETBITMAP";
5260 case WM_USER
+1000+45: return "TB_GETBUTTONTEXTA";
5261 case WM_USER
+1000+75: return "TB_GETBUTTONTEXTW";
5262 case WM_USER
+1000+46: return "TB_REPLACEBITMAP";
5263 case WM_USER
+1000+47: return "TB_SETINDENT";
5264 case WM_USER
+1000+48: return "TB_SETIMAGELIST";
5265 case WM_USER
+1000+49: return "TB_GETIMAGELIST";
5266 case WM_USER
+1000+50: return "TB_LOADIMAGES";
5267 case WM_USER
+1000+51: return "TB_GETRECT";
5268 case WM_USER
+1000+52: return "TB_SETHOTIMAGELIST";
5269 case WM_USER
+1000+53: return "TB_GETHOTIMAGELIST";
5270 case WM_USER
+1000+54: return "TB_SETDISABLEDIMAGELIST";
5271 case WM_USER
+1000+55: return "TB_GETDISABLEDIMAGELIST";
5272 case WM_USER
+1000+56: return "TB_SETSTYLE";
5273 case WM_USER
+1000+57: return "TB_GETSTYLE";
5274 case WM_USER
+1000+58: return "TB_GETBUTTONSIZE";
5275 case WM_USER
+1000+59: return "TB_SETBUTTONWIDTH";
5276 case WM_USER
+1000+60: return "TB_SETMAXTEXTROWS";
5277 case WM_USER
+1000+61: return "TB_GETTEXTROWS";
5278 case WM_USER
+1000+41: return "TB_GETBITMAPFLAGS";
5281 static char s_szBuf
[128];
5282 sprintf(s_szBuf
, "<unknown message = %d>", nMessage
);
5286 } // end of wxGetMessageName
5288 #endif // __WXDEBUG__
5292 static void TranslateKbdEventToMouse(
5300 // Construct the key mask
5301 ULONG
& fwKeys
= *pFlags
;
5303 fwKeys
= VK_BUTTON2
;
5304 if ((::WinGetKeyState(HWND_DESKTOP
, VK_CTRL
) & 0x100) != 0)
5306 if ((::WinGetKeyState(HWND_DESKTOP
, VK_SHIFT
) & 0x100) != 0)
5310 // Simulate right mouse button click
5314 ::WinQueryMsgPos(vHabmain
, &vPoint
);
5318 pWin
->ScreenToClient(pX
, pY
);
5319 } // end of TranslateKbdEventToMouse
5322 // Find the wxWindow at the current mouse position, returning the mouse
5324 wxWindow
* wxFindWindowAtPointer(
5325 wxPoint
& WXUNUSED(rPt
)
5328 return wxFindWindowAtPoint(wxGetMousePosition());
5331 wxWindow
* wxFindWindowAtPoint(
5340 HWND hWndHit
= ::WinWindowFromPoint(HWND_DESKTOP
, &vPt2
, FALSE
);
5341 wxWindow
* pWin
= wxFindWinFromHandle((WXHWND
)hWndHit
) ;
5342 HWND hWnd
= hWndHit
;
5345 // Try to find a window with a wxWindow associated with it
5347 while (!pWin
&& (hWnd
!= 0))
5349 hWnd
= ::WinQueryWindow(hWnd
, QW_PARENT
);
5350 pWin
= wxFindWinFromHandle((WXHWND
)hWnd
) ;
5355 // Get the current mouse position.
5356 wxPoint
wxGetMousePosition()
5360 ::WinQueryPointerPos(HWND_DESKTOP
, &vPt
);
5361 return wxPoint(vPt
.x
, vPt
.y
);
5364 wxWindowOS2
* FindWindowForMouseEvent(
5370 HWND hWnd
= GetHwndOf(pWin
);
5371 HWND hWndUnderMouse
;
5373 BOOL rcEnabled
= FALSE
;
5374 BOOL rcVisible
= FALSE
;
5375 HWND hWndDesktop
= HWND_DESKTOP
;
5377 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
5378 hWndUnderMouse
= ::WinWindowFromPoint(HWND_DESKTOP
, &vPoint
, TRUE
);
5379 if (hWndUnderMouse
!= HWND_DESKTOP
)
5381 wxWindow
* pWinUnderMouse
= wxFindWinFromHandle((WXHWND
)hWndUnderMouse
);
5385 wxWindowList::Node
* pCurrent
= pWinUnderMouse
->GetChildren().GetFirst();
5386 wxWindow
* pChild
= NULL
;
5387 wxWindow
* pGrandChild
= NULL
;
5391 ::WinMapWindowPoints(HWND_DESKTOP
, hWndUnderMouse
, &vPoint
, 1);
5393 // Find a child window mouse might be under
5397 wxWindow
* pChild
= pCurrent
->GetData();
5399 vPoint2
.x
= vPoint
.x
;
5400 vPoint2
.y
= vPoint
.y
;
5401 ::WinMapWindowPoints(hWndUnderMouse
, pChild
->GetHWND(), &vPoint2
, 1);
5402 ::WinQueryWindowRect(pChild
->GetHWND(), &vRect
);
5403 if (::WinPtInRect(vHabmain
, &vRect
, &vPoint2
))
5405 if (pChild
->IsTopLevel())
5408 wxWindowList::Node
* pCurrent2
=pChild
->GetChildren().GetFirst();
5412 wxWindow
* pGrandChild
= pCurrent2
->GetData();
5414 vPoint3
.x
= vPoint2
.x
;
5415 vPoint3
.y
= vPoint2
.y
;
5416 ::WinMapWindowPoints( pChild
->GetHWND()
5417 ,pGrandChild
->GetHWND()
5421 ::WinQueryWindowRect(pGrandChild
->GetHWND(), &vRect
);
5422 if (::WinPtInRect(vHabmain
, &vRect
, &vPoint3
))
5424 hWndUnderMouse
= GetHwndOf(pGrandChild
);
5425 pWinUnderMouse
= pGrandChild
;
5428 pCurrent2
= pCurrent2
->GetNext();
5433 hWndUnderMouse
= GetHwndOf(pChild
);
5434 pWinUnderMouse
= pChild
;
5435 rcVisible
= ::WinIsWindowVisible(hWndUnderMouse
);
5436 rcEnabled
= ::WinIsWindowEnabled(hWndUnderMouse
);
5437 if (rcVisible
&& rcEnabled
)
5440 pCurrent
= pCurrent
->GetNext();
5444 rcVisible
= ::WinIsWindowVisible(hWndUnderMouse
);
5445 rcEnabled
= ::WinIsWindowEnabled(hWndUnderMouse
);
5449 // Check that we have a child window which is susceptible to receive mouse
5450 // events: for this it must be shown and enabled
5452 if ( hWndUnderMouse
&&
5453 hWndUnderMouse
!= hWnd
&&
5454 rcVisible
&& rcEnabled
)
5456 wxWindow
* pWinUnderMouse
= wxFindWinFromHandle((WXHWND
)hWndUnderMouse
);
5461 // Translate the mouse coords to the other window coords
5463 pWin
= pWinUnderMouse
;
5467 } // end of FindWindowForMouseEvent