1 /////////////////////////////////////////////////////////////////////////////
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 // For compilers that support precompilation, includes "wx.h".
15 #include "wx/wxprec.h"
21 #include "wx/window.h"
26 #include "wx/dcclient.h"
30 #include "wx/layout.h"
31 #include "wx/dialog.h"
33 #include "wx/listbox.h"
34 #include "wx/button.h"
35 #include "wx/msgdlg.h"
36 #include "wx/scrolwin.h"
42 #include "wx/ownerdrw.h"
45 #if wxUSE_DRAG_AND_DROP
49 #include "wx/menuitem.h"
52 #include "wx/os2/private.h"
55 #include "wx/tooltip.h"
66 #include "wx/textctrl.h"
71 // Place compiler, OS specific includes here
75 // Standard macros -- these are for OS/2 PM, but most GUI's have something similar
79 // SHORT1FROMMP -- LOWORD
81 #define GET_X_LPARAM(mp) ((unsigned short)(unsigned long)(mp))
83 // SHORT2FROMMP -- HIWORD
85 #define GET_Y_LPARAM(mp) ((unsigned short)(unsigned long)(mp >> 16))
86 #endif // GET_X_LPARAM
89 # define CW_USEDEFAULT ((int)0x80000000)
92 // ---------------------------------------------------------------------------
94 // ---------------------------------------------------------------------------
97 // The last PM message we got (MT-UNSAFE)
101 #if wxUSE_MENUS_NATIVE
102 wxMenu
* wxCurrentPopupMenu
= NULL
;
103 #endif // wxUSE_MENUS_NATIVE
105 wxList
* wxWinHandleList
= NULL
;
107 // ---------------------------------------------------------------------------
109 // ---------------------------------------------------------------------------
112 // the window proc for all our windows; most gui's have something similar
114 MRESULT EXPENTRY
wxWndProc( HWND hWnd
121 const char *wxGetMessageName(int message
);
124 void wxRemoveHandleAssociation(wxWindowOS2
* pWin
);
125 void wxAssociateWinWithHandle( HWND hWnd
128 wxWindow
* wxFindWinFromHandle(WXHWND hWnd
);
131 // This magical function is used to translate VK_APPS key presses to right
136 static void TranslateKbdEventToMouse( wxWindow
* pWin
143 // get the current state of SHIFT/CTRL keys
145 static inline bool IsShiftDown() { return (::WinGetKeyState(HWND_DESKTOP
, VK_SHIFT
) & 0x8000) != 0; }
146 static inline bool IsCtrlDown() { return (::WinGetKeyState(HWND_DESKTOP
, VK_CTRL
) & 0x8000) != 0; }
148 static wxWindow
* gpWinBeingCreated
= NULL
;
150 // ---------------------------------------------------------------------------
152 // ---------------------------------------------------------------------------
154 // in wxUniv-OS/2 this class is abstract because it doesn't have DoPopupMenu()
156 #ifdef __WXUNIVERSAL__
157 IMPLEMENT_ABSTRACT_CLASS(wxWindowOS2
, wxWindowBase
)
159 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
)
160 #endif // __WXUNIVERSAL__/__WXPM__
162 BEGIN_EVENT_TABLE(wxWindowOS2
, wxWindowBase
)
163 EVT_ERASE_BACKGROUND(wxWindowOS2::OnEraseBackground
)
164 EVT_SYS_COLOUR_CHANGED(wxWindowOS2::OnSysColourChanged
)
165 EVT_INIT_DIALOG(wxWindowOS2::OnInitDialog
)
166 EVT_IDLE(wxWindowOS2::OnIdle
)
167 EVT_SET_FOCUS(wxWindowOS2::OnSetFocus
)
170 // ===========================================================================
172 // ===========================================================================
174 // ---------------------------------------------------------------------------
175 // wxWindow utility functions
176 // ---------------------------------------------------------------------------
179 // Find an item given the PM Window id
181 wxWindow
* wxWindowOS2::FindItem(
186 wxControl
* pItem
= wxDynamicCast(this, wxControl
);
191 // I it we or one of our "internal" children?
193 if (pItem
->GetId() == lId
194 #ifndef __WXUNIVERSAL__
195 || (pItem
->GetSubcontrols().Index(lId
) != wxNOT_FOUND
)
202 #endif // wxUSE_CONTROLS
204 wxWindowList::Node
* pCurrent
= GetChildren().GetFirst();
208 wxWindow
* pChildWin
= pCurrent
->GetData();
209 wxWindow
* pWnd
= pChildWin
->FindItem(lId
);
214 pCurrent
= pCurrent
->GetNext();
217 } // end of wxWindowOS2::FindItem
220 // Find an item given the PM Window handle
222 wxWindow
* wxWindowOS2::FindItemByHWND(
227 wxWindowList::Node
* pCurrent
= GetChildren().GetFirst();
231 wxWindow
* pParent
= pCurrent
->GetData();
234 // Do a recursive search.
236 wxWindow
* pWnd
= pParent
->FindItemByHWND(hWnd
);
243 || pParent
->IsKindOf(CLASSINFO(wxControl
))
244 #endif // wxUSE_CONTROLS
247 wxWindow
* pItem
= pCurrent
->GetData();
249 if (pItem
->GetHWND() == hWnd
)
253 if (pItem
->ContainsHWND(hWnd
))
257 pCurrent
= pCurrent
->GetNext();
260 } // end of wxWindowOS2::FindItemByHWND
263 // Default command handler
265 bool wxWindowOS2::OS2Command(
266 WXUINT
WXUNUSED(uParam
)
267 , WXWORD
WXUNUSED(uId
)
273 // ----------------------------------------------------------------------------
274 // constructors and such
275 // ----------------------------------------------------------------------------
277 void wxWindowOS2::Init()
287 m_bDoubleClickAllowed
= 0;
288 m_bWinCaptured
= FALSE
;
290 m_isBeingDeleted
= FALSE
;
293 m_bMouseInWindow
= FALSE
;
300 m_hWndScrollBarHorz
= 0L;
301 m_hWndScrollBarVert
= 0L;
304 // Pass WM_GETDLGCODE to DefWindowProc()
309 m_bBackgroundTransparent
= FALSE
;
312 // As all windows are created with WS_VISIBLE style...
316 #if wxUSE_MOUSEEVENT_HACK
319 m_nLastMouseEvent
= -1;
320 #endif // wxUSE_MOUSEEVENT_HACK
321 } // wxWindowOS2::Init
326 wxWindowOS2::~wxWindowOS2()
328 m_isBeingDeleted
= TRUE
;
330 for (wxWindow
* pWin
= GetParent(); pWin
; pWin
= pWin
->GetParent())
332 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
336 if (pFrame
->GetLastFocus() == this)
337 pFrame
->SetLastFocus((wxWindow
*)NULL
);
344 m_parent
->RemoveChild(this);
348 if(!::WinDestroyWindow(GetHWND()))
349 wxLogLastError(wxT("DestroyWindow"));
351 // remove hWnd <-> wxWindow association
353 wxRemoveHandleAssociation(this);
355 } // end of wxWindowOS2::~wxWindowOS2
357 // real construction (Init() must have been called before!)
358 bool wxWindowOS2::Create(
361 , const wxPoint
& rPos
362 , const wxSize
& rSize
364 , const wxString
& rName
367 HWND hParent
= NULLHANDLE
;
368 ULONG ulCreateFlags
= 0;
369 WXDWORD dwExStyle
= 0;
371 wxCHECK_MSG(pParent
, FALSE
, wxT("can't create wxWindow without parent"));
373 if ( !CreateBase( pParent
387 pParent
->AddChild(this);
388 hParent
= GetWinHwnd(pParent
);
390 if ( pParent
->IsKindOf(CLASSINFO(wxGenericScrolledWindow
)) ||
391 pParent
->IsKindOf(CLASSINFO(wxScrolledWindow
))
393 ulCreateFlags
|= WS_CLIPSIBLINGS
;
397 // Most wxSTYLES are really PM Class specific styles and will be
398 // set in those class create procs. PM's basic windows styles are
401 ulCreateFlags
|= WS_VISIBLE
;
404 #ifdef __WXUNIVERSAL__
405 // no 3d effects, we draw them ourselves
407 #else // !wxUniversal
408 if (lStyle
& wxCLIP_SIBLINGS
)
409 ulCreateFlags
|= WS_CLIPSIBLINGS
;
411 if (lStyle
& wxCLIP_CHILDREN
)
412 ulCreateFlags
|= WS_CLIPCHILDREN
;
418 dwExStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &bWant3D
);
423 // Add the simple border style as we'll use this to draw borders
425 if (lStyle
& wxSIMPLE_BORDER
)
426 dwExStyle
|= wxSIMPLE_BORDER
;
428 if (lStyle
& wxPOPUP_WINDOW
)
430 // a popup window floats on top of everything
432 // exStyle |= WS_EX_TOPMOST | WS_EX_TOOLWINDOW;
434 // it is also created hidden as other top level windows
435 ulCreateFlags
&= ~WS_VISIBLE
;
440 // Generic OS/2 Windows have no Control Data but other classes
441 // that call OS2Create may have some.
443 OS2Create( (PSZ
)wxCanvasClassName
448 ,NULL
// Control Data
454 } // end of wxWindowOS2::Create
456 // ---------------------------------------------------------------------------
458 // ---------------------------------------------------------------------------
460 void wxWindowOS2::SetFocus()
462 HWND hWnd
= GetHwnd();
463 wxCHECK_RET( hWnd
, _T("can't set focus to invalid window") );
466 ::WinSetFocus(HWND_DESKTOP
, hWnd
);
467 } // end of wxWindowOS2::SetFocus
469 wxWindow
* wxWindowBase::FindFocus()
471 HWND hWnd
= ::WinQueryFocus(HWND_DESKTOP
);
475 return wxFindWinFromHandle((WXHWND
)hWnd
);
478 } // wxWindowBase::FindFocus
480 bool wxWindowOS2::Enable(
484 if (!wxWindowBase::Enable(bEnable
))
487 HWND hWnd
= GetHwnd();
490 ::WinEnableWindow(hWnd
, (BOOL
)bEnable
);
492 wxWindowList::Node
* pNode
= GetChildren().GetFirst();
496 wxWindow
* pChild
= pNode
->GetData();
498 pChild
->Enable(bEnable
);
499 pNode
= pNode
->GetNext();
502 } // end of wxWindowOS2::Enable
504 bool wxWindowOS2::Show(
508 if (!wxWindowBase::Show(bShow
))
511 HWND hWnd
= GetHwnd();
513 ::WinShowWindow(hWnd
, bShow
);
517 ::WinSetWindowPos(hWnd
, HWND_TOP
, 0, 0, 0, 0, SWP_ACTIVATE
| SWP_ZORDER
);
520 } // end of wxWindowOS2::Show
522 void wxWindowOS2::Raise()
524 ::WinSetWindowPos(GetHwnd(), HWND_TOP
, 0, 0, 0, 0, SWP_ZORDER
| SWP_ACTIVATE
);
525 } // end of wxWindowOS2::Raise
527 void wxWindowOS2::Lower()
529 ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_ZORDER
| SWP_DEACTIVATE
);
530 } // end of wxWindowOS2::Lower
532 void wxWindowOS2::SetTitle(
533 const wxString
& rTitle
536 ::WinSetWindowText(GetHwnd(), rTitle
.c_str());
537 } // end of wxWindowOS2::SetTitle
539 wxString
wxWindowOS2::GetTitle() const
541 return wxGetWindowText(GetHWND());
542 } // end of wxWindowOS2::GetTitle
544 void wxWindowOS2::CaptureMouse()
546 HWND hWnd
= GetHwnd();
548 if (hWnd
&& !m_bWinCaptured
)
550 ::WinSetCapture(HWND_DESKTOP
, hWnd
);
551 m_bWinCaptured
= TRUE
;
553 } // end of wxWindowOS2::GetTitle
555 void wxWindowOS2::ReleaseMouse()
559 ::WinSetCapture(HWND_DESKTOP
, NULLHANDLE
);
560 m_bWinCaptured
= FALSE
;
562 } // end of wxWindowOS2::ReleaseMouse
564 /* static */ wxWindow
* wxWindowBase::GetCapture()
566 HWND hwnd
= ::WinQueryCapture(HWND_DESKTOP
);
567 return hwnd
? wxFindWinFromHandle((WXHWND
)hwnd
) : (wxWindow
*)NULL
;
568 } // end of wxWindowBase::GetCapture
570 bool wxWindowOS2::SetFont(
574 if (!wxWindowBase::SetFont(rFont
))
580 HWND hWnd
= GetHwnd();
590 // The fonts available for Presentation Params are just three
591 // outline fonts, the rest are available to the GPI, so we must
592 // map the families to one of these three
594 switch(rFont
.GetFamily())
599 strcpy(zFacename
,"Times New Roman");
604 strcpy(zFacename
, "Courier");
610 strcpy(zFacename
, "Helvetica");
614 switch(rFont
.GetWeight())
623 case wxFONTWEIGHT_MAX
:
624 strcpy(zWeight
, "Bold");
627 switch(rFont
.GetStyle())
631 strcpy(zStyle
, "Italic");
638 sprintf(zFont
, "%d.%s", rFont
.GetPointSize(), zFacename
);
639 if (zWeight
[0] != '\0')
642 strcat(zFont
, zWeight
);
644 if (zStyle
[0] != '\0')
647 strcat(zFont
, zStyle
);
649 ::WinSetPresParam(hWnd
, PP_FONTNAMESIZE
, strlen(zFont
) + 1, (PVOID
)zFont
);
654 bool wxWindowOS2::SetCursor(
655 const wxCursor
& rCursor
656 ) // check if base implementation is OK
658 if ( !wxWindowBase::SetCursor(rCursor
))
664 if ( m_cursor
.Ok() ) {
665 HWND hWnd
= GetHwnd();
669 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
670 ::WinQueryWindowRect(hWnd
, &vRect
);
672 if (::WinPtInRect(vHabmain
, &vRect
, &vPoint
) && !wxIsBusy())
674 ::WinSetPointer(HWND_DESKTOP
, (HPOINTER
)m_cursor
.GetHCURSOR());
678 } // end of wxWindowOS2::SetCursor
680 void wxWindowOS2::WarpPointer(
689 ::WinQueryWindowRect(GetHwnd(), &vRect
);
693 ::WinSetPointerPos(HWND_DESKTOP
, (LONG
)nX
, (LONG
)(nY
));
694 } // end of wxWindowOS2::WarpPointer
696 #if WXWIN_COMPATIBILITY
697 void wxWindowOS2::OS2DeviceToLogical (float *x
, float *y
) const
700 #endif // WXWIN_COMPATIBILITY
702 // ---------------------------------------------------------------------------
704 // ---------------------------------------------------------------------------
706 #if WXWIN_COMPATIBILITY
707 void wxWindowOS2::SetScrollRange(
713 int nRange1
= nRange
;
714 int nPageSize
= GetScrollPage(nOrient
);
716 if (nPpageSize
> 1 && nRange
> 0)
718 nRange1
+= (nPageSize
- 1);
721 if (nOrient
== wxHORIZONTAL
)
723 ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETSCROLLBAR
, (MPARAM
)0, MPFROM2SHORT(0, (SHORT
)nRange1
));
724 ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETTHUMBSIZE
, MPFROM2SHORT((SHORT
)nThumbVisible
, (SHORT
)nRange1
), (MPARAM
)0);
728 ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETSCROLLBAR
, (MPARAM
)0, MPFROM2SHORT(0, (SHORT
)nRange1
));
729 ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETTHUMBSIZE
, MPFROM2SHORT((SHORT
)nThumbVisible
, (SHORT
)nRange1
), (MPARAM
)0);
731 } // end of wxWindowOS2::SetScrollRange
733 void wxWindowOS2::SetScrollPage(
739 if (nOrient
== wxHORIZONTAL
)
740 m_nXThumbSize
= nPage
;
742 m_nYThumbSize
= nPage
;
743 } // end of wxWindowOS2::SetScrollPage
745 int wxWindowOS2::OldGetScrollRange(
750 HWND hWnd
= GetHwnd();
754 mRc
= WinSendMsg(hWnd
, SBM_QUERYRANGE
, (MPARAM
)0L, (MPARAM
)0L);
755 return(SHORT2FROMMR(mRc
));
758 } // end of wxWindowOS2::OldGetScrollRange
760 int wxWindowOS2::GetScrollPage(
764 if (nOrient
== wxHORIZONTAL
)
765 return m_nXThumbSize
;
767 return m_nYThumbSize
;
768 } // end of wxWindowOS2::GetScrollPage
769 #endif // WXWIN_COMPATIBILITY
771 int wxWindowOS2::GetScrollPos(
775 if (nOrient
== wxHORIZONTAL
)
776 return((int)::WinSendMsg(m_hWndScrollBarHorz
, SBM_QUERYPOS
, (MPARAM
)NULL
, (MPARAM
)NULL
));
778 return((int)::WinSendMsg(m_hWndScrollBarVert
, SBM_QUERYPOS
, (MPARAM
)NULL
, (MPARAM
)NULL
));
779 } // end of wxWindowOS2::GetScrollPos
781 int wxWindowOS2::GetScrollRange(
787 if (nOrient
== wxHORIZONTAL
)
788 mr
= ::WinSendMsg(m_hWndScrollBarHorz
, SBM_QUERYRANGE
, (MPARAM
)NULL
, (MPARAM
)NULL
);
790 mr
= ::WinSendMsg(m_hWndScrollBarVert
, SBM_QUERYRANGE
, (MPARAM
)NULL
, (MPARAM
)NULL
);
791 return((int)SHORT2FROMMR(mr
));
792 } // end of wxWindowOS2::GetScrollRange
794 int wxWindowOS2::GetScrollThumb(
798 if (nOrient
== wxHORIZONTAL
)
799 return m_nXThumbSize
;
801 return m_nYThumbSize
;
802 } // end of wxWindowOS2::GetScrollThumb
804 void wxWindowOS2::SetScrollPos(
807 , bool WXUNUSED(bRefresh
)
810 if (nOrient
== wxHORIZONTAL
)
811 ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETPOS
, (MPARAM
)nPos
, (MPARAM
)NULL
);
813 ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETPOS
, (MPARAM
)nPos
, (MPARAM
)NULL
);
814 } // end of wxWindowOS2::SetScrollPos
816 void wxWindowOS2::SetScrollbar(
821 , bool WXUNUSED(bRefresh
)
824 int nOldRange
= nRange
- nThumbVisible
;
825 int nRange1
= nOldRange
;
826 int nPageSize
= nThumbVisible
;
828 HWND hWnd
= GetHwnd();
829 ULONG ulStyle
= WS_VISIBLE
| WS_SYNCPAINT
;
832 ::WinQueryWindowRect(hWnd
, &vRect
);
833 if (nPageSize
> 1 && nRange
> 0)
835 nRange1
+= (nPageSize
- 1);
838 vInfo
.cb
= sizeof(SBCDATA
);
840 vInfo
.posLast
= (SHORT
)nRange1
;
841 vInfo
.posThumb
= nPos
;
843 if (nOrient
== wxHORIZONTAL
)
846 if (m_hWndScrollBarHorz
== 0L)
849 // We create the scrollbars with the desktop so that they are not
850 // registered as child windows of the window in order that child
851 // windows may be scrolled without scrolling the scrollbars themselves!
853 m_hWndScrollBarHorz
= ::WinCreateWindow( hWnd
859 ,vRect
.xRight
- vRect
.xLeft
873 // Only want to resize the scrollbar if it changes, otherwise
874 // we'd probably end up in a recursive loop until we crash the call stack
875 // because this method is called in a ScrolledWindow OnSize event and SWP_MOVE | SWP_SIZE
876 // generates those events.
878 ::WinQueryWindowRect(m_hWndScrollBarHorz
, &vRect2
);
879 if (!(vRect2
.xLeft
== vRect
.xLeft
&&
880 vRect2
.xRight
== vRect
.xRight
&&
881 vRect2
.yBottom
== vRect
.yBottom
&&
882 vRect2
.yTop
== vRect
.yTop
885 ::WinSetWindowPos( m_hWndScrollBarHorz
889 ,vRect
.xRight
- vRect
.xLeft
891 ,SWP_ACTIVATE
| SWP_MOVE
| SWP_SIZE
| SWP_SHOW
894 ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETSCROLLBAR
, (MPARAM
)nPos
, MPFROM2SHORT(0, (SHORT
)nRange1
));
895 ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETTHUMBSIZE
, MPFROM2SHORT((SHORT
)nThumbVisible
, (SHORT
)nRange1
), (MPARAM
)0);
901 if (m_hWndScrollBarVert
== 0L)
903 m_hWndScrollBarVert
= ::WinCreateWindow( hWnd
910 ,vRect
.yTop
- (vRect
.yBottom
+ 20)
923 // Only want to resize the scrollbar if it changes, otherwise
924 // we'd probably end up in a recursive loop until we crash the call stack
925 // because this method is called in a ScrolledWindow OnSize event and SWP_MOVE | SWP_SIZE
926 // generates those events.
928 ::WinQueryWindowRect(m_hWndScrollBarVert
, &vRect2
);
929 if (!(vRect2
.xLeft
== vRect
.xLeft
&&
930 vRect2
.xRight
== vRect
.xRight
&&
931 vRect2
.yBottom
== vRect
.yBottom
&&
932 vRect2
.yTop
== vRect
.yTop
935 ::WinSetWindowPos( m_hWndScrollBarVert
940 ,vRect
.yTop
- (vRect
.yBottom
+ 20)
941 ,SWP_ACTIVATE
| SWP_MOVE
| SWP_SIZE
| SWP_SHOW
944 ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETSCROLLBAR
, (MPARAM
)nPos
, MPFROM2SHORT(0, (SHORT
)nRange1
));
945 ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETTHUMBSIZE
, MPFROM2SHORT((SHORT
)nThumbVisible
, (SHORT
)nRange1
), (MPARAM
)0);
947 m_nYThumbSize
= nThumbVisible
;
949 } // end of wxWindowOS2::SetScrollbar
951 void wxWindowOS2::ScrollWindow(
954 , const wxRect
* pRect
960 nDy
*= -1; // flip the sign of Dy as OS/2 is opposite wxWin.
963 vRect2
.xLeft
= pRect
->x
;
964 vRect2
.yTop
= pRect
->y
+ pRect
->height
;
965 vRect2
.xRight
= pRect
->x
+ pRect
->width
;
966 vRect2
.yBottom
= pRect
->y
;
970 ::WinQueryWindowRect(GetHwnd(), &vRect2
);
971 ::WinQueryWindowRect(m_hWndScrollBarHorz
, &vRect
);
972 vRect2
.yBottom
+= vRect
.yTop
- vRect
.yBottom
;
973 ::WinQueryWindowRect(m_hWndScrollBarVert
, &vRect
);
974 vRect2
.xRight
-= vRect
.xRight
- vRect
.xLeft
;
978 ::WinScrollWindow( GetHwnd()
988 ::WinScrollWindow( GetHwnd()
1000 wxWindowList::Node
* pCurrent
= GetChildren().GetFirst();
1005 wxWindow
* pChildWin
= pCurrent
->GetData();
1007 if (pChildWin
->GetHWND() != NULLHANDLE
)
1009 ::WinQueryWindowPos(pChildWin
->GetHWND(), &vSwp
);
1010 ::WinQueryWindowRect(pChildWin
->GetHWND(), &vRect
);
1011 if (pChildWin
->GetHWND() == m_hWndScrollBarVert
||
1012 pChildWin
->GetHWND() == m_hWndScrollBarHorz
)
1014 ::WinSetWindowPos( pChildWin
->GetHWND()
1020 ,SWP_MOVE
| SWP_SHOW
| SWP_ZORDER
1025 ::WinSetWindowPos( pChildWin
->GetHWND()
1031 ,SWP_MOVE
| SWP_ZORDER
1033 ::WinInvalidateRect(pChildWin
->GetHWND(), &vRect
, FALSE
);
1036 pCurrent
= pCurrent
->GetNext();
1038 } // end of wxWindowOS2::ScrollWindow
1040 // ---------------------------------------------------------------------------
1042 // ---------------------------------------------------------------------------
1044 void wxWindowOS2::SubclassWin(
1048 HWND hwnd
= (HWND
)hWnd
;
1050 wxASSERT_MSG( !m_fnOldWndProc
, wxT("subclassing window twice?") );
1051 wxCHECK_RET(::WinIsWindow(vHabmain
, hwnd
), wxT("invalid HWND in SubclassWin") );
1052 m_fnOldWndProc
= (WXFARPROC
) ::WinSubclassWindow(hwnd
, (PFNWP
)wxWndProc
);
1053 } // end of wxWindowOS2::SubclassWin
1055 void wxWindowOS2::UnsubclassWin()
1058 // Restore old Window proc
1060 HWND hwnd
= GetHWND();
1064 wxCHECK_RET( ::WinIsWindow(vHabmain
, hwnd
), wxT("invalid HWND in UnsubclassWin") );
1066 PFNWP fnProc
= (PFNWP
)::WinQueryWindowPtr(hwnd
, QWP_PFNWP
);
1068 if ( (m_fnOldWndProc
!= 0) && (fnProc
!= (PFNWP
) m_fnOldWndProc
))
1070 WinSubclassWindow(hwnd
, (PFNWP
)m_fnOldWndProc
);
1074 } // end of wxWindowOS2::UnsubclassWin
1076 bool wxCheckWindowWndProc(
1078 , WXFARPROC fnWndProc
1081 static char zBuffer
[512];
1084 ::WinQueryClassName((HWND
)hWnd
, (LONG
)512, (PCH
)zBuffer
);
1085 ::WinQueryClassInfo(wxGetInstance(), (PSZ
)zBuffer
, &vCls
);
1086 return(fnWndProc
== (WXFARPROC
)vCls
.pfnWindowProc
);
1087 } // end of WinGuiBase_CheckWindowWndProc
1090 // Make a Windows extended style from the given wxWindows window style
1092 WXDWORD
wxWindowOS2::MakeExtendedStyle(
1094 , bool bEliminateBorders
1098 // Simply fill out with wxWindow extended styles. We'll conjure
1099 // something up in OS2Create and all window redrawing pieces later
1101 WXDWORD dwStyle
= 0;
1103 if (lStyle
& wxTRANSPARENT_WINDOW
)
1104 dwStyle
|= wxTRANSPARENT_WINDOW
;
1106 if (!bEliminateBorders
)
1108 if (lStyle
& wxSUNKEN_BORDER
)
1109 dwStyle
|= wxSUNKEN_BORDER
;
1110 if (lStyle
& wxDOUBLE_BORDER
)
1111 dwStyle
|= wxDOUBLE_BORDER
;
1112 if (lStyle
& wxRAISED_BORDER
)
1113 dwStyle
|= wxRAISED_BORDER
;
1114 if (lStyle
& wxSTATIC_BORDER
)
1115 dwStyle
|= wxSTATIC_BORDER
;
1118 } // end of wxWindowOS2::MakeExtendedStyle
1121 // Determines whether simulated 3D effects or CTL3D should be used,
1122 // applying a default border style if required, and returning an extended
1123 // style to pass to OS2Create.
1125 WXDWORD
wxWindowOS2::Determine3DEffects(
1126 WXDWORD dwDefaultBorderStyle
1130 WXDWORD dwStyle
= 0L;
1133 // Native PM does not have any specialize 3D effects like WIN32 does,
1134 // so we have to try and invent them.
1138 // If matches certain criteria, then assume no 3D effects
1139 // unless specifically requested (dealt with in MakeExtendedStyle)
1142 !IsKindOf(CLASSINFO(wxControl
)) ||
1143 (m_windowStyle
& wxNO_BORDER
)
1147 return MakeExtendedStyle(m_windowStyle
, FALSE
);
1151 // 1) App can specify global 3D effects
1153 *pbWant3D
= wxTheApp
->GetAuto3D();
1156 // 2) If the parent is being drawn with user colours, or simple border
1157 // specified, switch effects off.
1160 (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS
) ||
1161 (m_windowStyle
& wxSIMPLE_BORDER
)
1166 // 3) Control can override this global setting by defining
1167 // a border style, e.g. wxSUNKEN_BORDER
1169 if ((m_windowStyle
& wxDOUBLE_BORDER
) ||
1170 (m_windowStyle
& wxRAISED_BORDER
) ||
1171 (m_windowStyle
& wxSTATIC_BORDER
) ||
1172 (m_windowStyle
& wxSUNKEN_BORDER
)
1176 dwStyle
= MakeExtendedStyle( m_windowStyle
1181 // If we want 3D, but haven't specified a border here,
1182 // apply the default border style specified.
1184 if (dwDefaultBorderStyle
&& (*pbWant3D
) &&
1185 !((m_windowStyle
& wxDOUBLE_BORDER
) ||
1186 (m_windowStyle
& wxRAISED_BORDER
) ||
1187 (m_windowStyle
& wxSTATIC_BORDER
) ||
1188 (m_windowStyle
& wxSIMPLE_BORDER
)
1191 dwStyle
|= dwDefaultBorderStyle
;
1193 } // end of wxWindowOS2::Determine3DEffects
1195 #if WXWIN_COMPATIBILITY
1196 void wxWindowOS2::OnCommand(
1198 , wxCommandEvent
& rEvent
1201 if (GetEventHandler()->ProcessEvent(rEvent
))
1204 m_parent
->GetEventHandler()->OnCommand( rWin
1207 } // end of wxWindowOS2::OnCommand
1209 wxObject
* wxWindowOS2::GetChild(
1214 // Return a pointer to the Nth object in the Panel
1216 wxNode
* pNode
= GetChildren().First();
1219 while (pNode
&& n
--)
1220 pNode
= pNode
->Next();
1223 wxObject
* pObj
= (wxObject
*)pNode
->Data();
1228 } // end of wxWindowOS2::GetChild
1230 #endif // WXWIN_COMPATIBILITY
1233 // Setup background and foreground colours correctly
1235 void wxWindowOS2::SetupColours()
1238 SetBackgroundColour(GetParent()->GetBackgroundColour());
1239 } // end of wxWindowOS2::SetupColours
1241 void wxWindowOS2::OnIdle(
1242 wxIdleEvent
& WXUNUSED(rEvent
)
1246 // Check if we need to send a LEAVE event
1248 if (m_bMouseInWindow
)
1252 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
1253 if (::WinWindowFromPoint(HWND_DESKTOP
, &vPoint
, FALSE
) != (HWND
)GetHwnd())
1256 // Generate a LEAVE event
1258 m_bMouseInWindow
= FALSE
;
1261 // Unfortunately the mouse button and keyboard state may have changed
1262 // by the time the OnIdle function is called, so 'state' may be
1267 if (::WinGetKeyState(HWND_DESKTOP
, VK_SHIFT
) != 0)
1269 if (::WinGetKeyState(HWND_DESKTOP
, VK_CTRL
) != 0);
1272 wxMouseEvent
rEvent(wxEVT_LEAVE_WINDOW
);
1274 InitMouseEvent( rEvent
1279 (void)GetEventHandler()->ProcessEvent(rEvent
);
1283 } // end of wxWindowOS2::OnIdle
1286 // Set this window to be the child of 'parent'.
1288 bool wxWindowOS2::Reparent(
1292 if (!wxWindowBase::Reparent(pParent
))
1295 HWND hWndChild
= GetHwnd();
1296 HWND hWndParent
= GetParent() ? GetWinHwnd(GetParent()) : (HWND
)0;
1298 ::WinSetParent(hWndChild
, hWndParent
, TRUE
);
1300 } // end of wxWindowOS2::Reparent
1302 void wxWindowOS2::Clear()
1304 wxClientDC
vDc((wxWindow
*)this);
1305 wxBrush
vBrush( GetBackgroundColour()
1309 vDc
.SetBackground(vBrush
);
1311 } // end of wxWindowOS2::Clear
1313 void wxWindowOS2::Update()
1315 ::WinUpdateWindow(GetHwnd());
1316 } // end of wxWindowOS2::Update
1318 void wxWindowOS2::Freeze()
1320 ::WinSendMsg(GetHwnd(), WM_VRNDISABLED
, (MPARAM
)0, (MPARAM
)0);
1321 } // end of wxWindowOS2::Freeze
1323 void wxWindowOS2::Thaw()
1325 ::WinSendMsg(GetHwnd(), WM_VRNENABLED
, (MPARAM
)TRUE
, (MPARAM
)0);
1328 // We need to refresh everything or otherwise he invalidated area is not
1332 } // end of wxWindowOS2::Thaw
1334 void wxWindowOS2::Refresh(
1336 , const wxRect
* pRect
1339 HWND hWnd
= GetHwnd();
1347 vOs2Rect
.xLeft
= pRect
->x
;
1348 vOs2Rect
.yTop
= pRect
->y
;
1349 vOs2Rect
.xRight
= pRect
->x
+ pRect
->width
;
1350 vOs2Rect
.yBottom
= pRect
->y
+ pRect
->height
;
1352 ::WinInvalidateRect(hWnd
, &vOs2Rect
, bEraseBack
);
1355 ::WinInvalidateRect(hWnd
, NULL
, bEraseBack
);
1357 } // end of wxWindowOS2::Refresh
1359 // ---------------------------------------------------------------------------
1361 // ---------------------------------------------------------------------------
1363 #if wxUSE_DRAG_AND_DROP
1364 void wxWindowOS2::SetDropTarget(
1365 wxDropTarget
* pDropTarget
1368 if (m_dropTarget
!= 0)
1370 m_dropTarget
->Revoke(m_hWnd
);
1371 delete m_dropTarget
;
1373 m_dropTarget
= pDropTarget
;
1374 if (m_dropTarget
!= 0)
1375 m_dropTarget
->Register(m_hWnd
);
1376 } // end of wxWindowOS2::SetDropTarget
1380 // old style file-manager drag&drop support: we retain the old-style
1381 // DragAcceptFiles in parallel with SetDropTarget.
1383 void wxWindowOS2::DragAcceptFiles(
1387 HWND hWnd
= GetHwnd();
1389 if (hWnd
&& bAccept
)
1390 ::DrgAcceptDroppedFiles(hWnd
, NULL
, NULL
, DO_COPY
, 0L);
1391 } // end of wxWindowOS2::DragAcceptFiles
1393 // ----------------------------------------------------------------------------
1395 // ----------------------------------------------------------------------------
1399 void wxWindowOS2::DoSetToolTip(
1403 wxWindowBase::DoSetToolTip(pTooltip
);
1406 m_tooltip
->SetWindow(this);
1407 } // end of wxWindowOS2::DoSetToolTip
1409 #endif // wxUSE_TOOLTIPS
1411 // ---------------------------------------------------------------------------
1412 // moving and resizing
1413 // ---------------------------------------------------------------------------
1416 void wxWindowOS2::DoGetSize(
1424 if (IsKindOf(CLASSINFO(wxFrame
)))
1426 wxFrame
* pFrame
= wxDynamicCast(this, wxFrame
);
1427 hWnd
= pFrame
->GetFrame();
1432 ::WinQueryWindowRect(hWnd
, &vRect
);
1435 *pWidth
= vRect
.xRight
- vRect
.xLeft
;
1437 // OS/2 PM is backwards from windows
1438 *pHeight
= vRect
.yTop
- vRect
.yBottom
;
1439 } // end of wxWindowOS2::DoGetSize
1441 void wxWindowOS2::DoGetPosition(
1446 HWND hWnd
= GetHwnd();
1449 wxWindow
* pParent
= GetParent();
1452 // It would seem that WinQueryWindowRect would be the correlary to
1453 // the WIN32 WinGetRect, but unlike WinGetRect which returns the window
1454 // origin position in screen coordinates, WinQueryWindowRect returns it
1455 // relative to itself, i.e. (0,0). To get the same under PM we must
1456 // us WinQueryWindowPos. This call, unlike the WIN32 call, however,
1457 // returns a position relative to it's parent, so no parent adujstments
1458 // are needed under OS/2. Also, windows should be created using
1459 // wxWindow coordinates, i.e 0,0 is the TOP left so vSwp will already
1462 ::WinQueryWindowPos(hWnd
, &vSwp
);
1468 // We may be faking the client origin. So a window that's really at (0,
1469 // 30) may appear (to wxWin apps) to be at (0, 0).
1473 wxPoint
vPt(pParent
->GetClientAreaOrigin());
1483 } // end of wxWindowOS2::DoGetPosition
1485 void wxWindowOS2::DoScreenToClient(
1490 HWND hWnd
= GetHwnd();
1493 ::WinQueryWindowPos(hWnd
, &vSwp
);
1499 } // end of wxWindowOS2::DoScreenToClient
1501 void wxWindowOS2::DoClientToScreen(
1506 HWND hWnd
= GetHwnd();
1509 ::WinQueryWindowPos(hWnd
, &vSwp
);
1515 } // end of wxWindowOS2::DoClientToScreen
1518 // Get size *available for subwindows* i.e. excluding menu bar etc.
1519 // Must be a frame type window
1521 void wxWindowOS2::DoGetClientSize(
1526 HWND hWnd
= GetHwnd();
1529 ::WinQueryWindowRect(hWnd
, &vRect
);
1531 *pWidth
= vRect
.xRight
;
1533 *pHeight
= vRect
.yTop
;
1534 } // end of wxWindowOS2::DoGetClientSize
1536 void wxWindowOS2::DoMoveWindow(
1545 wxWindow
* pParent
= GetParent();
1547 if (pParent
&& !IsKindOf(CLASSINFO(wxDialog
)))
1549 int nOS2Height
= GetOS2ParentHeight(pParent
);
1551 nY
= nOS2Height
- (nY
+ nHeight
);
1557 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
1558 nY
= vRect
.yTop
- (nY
+ nHeight
);
1560 ::WinSetWindowPos( GetHwnd()
1566 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
1568 } // end of wxWindowOS2::DoMoveWindow
1571 // Set the size of the window: if the dimensions are positive, just use them,
1572 // but if any of them is equal to -1, it means that we must find the value for
1573 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
1574 // which case -1 is a valid value for x and y)
1576 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
1577 // the width/height to best suit our contents, otherwise we reuse the current
1580 void wxWindowOS2::DoSetSize(
1589 // Get the current size and position...
1595 wxSize
vSize(-1, -1);
1597 GetPosition(&nCurrentX
, &nCurrentY
);
1598 GetSize(&nCurrentWidth
, &nCurrentHeight
);
1601 // ... and don't do anything (avoiding flicker) if it's already ok
1604 // Must convert Y coords to test for equality under OS/2
1607 wxWindow
* pParent
= (wxWindow
*)GetParent();
1609 if (pParent
&& !IsKindOf(CLASSINFO(wxDialog
)))
1611 int nOS2Height
= GetOS2ParentHeight(pParent
);
1613 nY2
= nOS2Height
- (nY2
+ nHeight
);
1619 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
1620 nY2
= vRect
.yTop
- (nY2
+ nHeight
);
1622 if (nX
== nCurrentX
&& nY2
== nCurrentY
&&
1623 nWidth
== nCurrentWidth
&& nHeight
== nCurrentHeight
)
1628 if (nX
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
1630 if (nY
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
1633 AdjustForParentClientOrigin(nX
, nY
, nSizeFlags
);
1637 if (nSizeFlags
& wxSIZE_AUTO_WIDTH
)
1639 vSize
= DoGetBestSize();
1645 // Just take the current one
1647 nWidth
= nCurrentWidth
;
1653 if (nSizeFlags
& wxSIZE_AUTO_HEIGHT
)
1657 vSize
= DoGetBestSize();
1663 // just take the current one
1664 nHeight
= nCurrentHeight
;
1673 } // end of wxWindowOS2::DoSetSize
1675 void wxWindowOS2::DoSetClientSize(
1680 wxWindow
* pParent
= GetParent();
1681 HWND hWnd
= GetHwnd();
1682 HWND hParentWnd
= (HWND
)0;
1687 HWND hClientWnd
= (HWND
)0;
1689 hClientWnd
= ::WinWindowFromID(hWnd
, FID_CLIENT
);
1690 ::WinQueryWindowRect(hClientWnd
, &vRect2
);
1691 ::WinQueryWindowRect(hWnd
, &vRect
);
1692 ::WinQueryWindowRect(hParentWnd
, &vRect3
);
1694 int nActualWidth
= vRect2
.xRight
- vRect2
.xLeft
- vRect
.xRight
+ nWidth
;
1695 int nActualHeight
= vRect2
.yTop
- vRect2
.yBottom
- vRect
.yTop
+ nHeight
;
1697 vPoint
.x
= vRect2
.xLeft
;
1698 vPoint
.y
= vRect2
.yBottom
;
1701 vPoint
.x
-= vRect3
.xLeft
;
1702 vPoint
.y
-= vRect3
.yBottom
;
1705 DoMoveWindow(vPoint
.x
, vPoint
.y
, nActualWidth
, nActualHeight
);
1707 wxSizeEvent
vEvent(wxSize(nWidth
, nHeight
), m_windowId
);
1708 vEvent
.SetEventObject(this);
1709 GetEventHandler()->ProcessEvent(vEvent
);
1710 } // end of wxWindowOS2::DoSetClientSize
1712 wxPoint
wxWindowOS2::GetClientAreaOrigin() const
1714 return wxPoint(0, 0);
1715 } // end of wxWindowOS2::GetClientAreaOrigin
1717 // ---------------------------------------------------------------------------
1719 // ---------------------------------------------------------------------------
1721 int wxWindowOS2::GetCharHeight() const
1724 FONTMETRICS vFontMetrics
;
1726 hPs
= ::WinGetPS(GetHwnd());
1728 if(!GpiQueryFontMetrics(hPs
, sizeof(FONTMETRICS
), &vFontMetrics
))
1730 ::WinReleasePS(hPs
);
1733 ::WinReleasePS(hPs
);
1734 return(vFontMetrics
.lMaxAscender
+ vFontMetrics
.lMaxDescender
);
1735 } // end of wxWindowOS2::GetCharHeight
1737 int wxWindowOS2::GetCharWidth() const
1740 FONTMETRICS vFontMetrics
;
1742 hPs
= ::WinGetPS(GetHwnd());
1744 if(!GpiQueryFontMetrics(hPs
, sizeof(FONTMETRICS
), &vFontMetrics
))
1746 ::WinReleasePS(hPs
);
1749 ::WinReleasePS(hPs
);
1750 return(vFontMetrics
.lAveCharWidth
);
1751 } // end of wxWindowOS2::GetCharWidth
1753 void wxWindowOS2::GetTextExtent(
1754 const wxString
& rString
1758 , int* pExternalLeading
1759 , const wxFont
* pTheFont
1762 POINTL avPoint
[TXTBOX_COUNT
];
1767 FONTMETRICS vFM
; // metrics structure
1770 ERRORID vErrorCode
; // last error id code
1774 hPS
= ::WinGetPS(GetHwnd());
1776 l
= rString
.Length();
1779 pStr
= (PCH
)rString
.c_str();
1782 // In world coordinates.
1784 bRc
= ::GpiQueryTextBox( hPS
1787 ,TXTBOX_COUNT
// return maximum information
1788 ,avPoint
// array of coordinates points
1792 vPtMin
.x
= avPoint
[0].x
;
1793 vPtMax
.x
= avPoint
[0].x
;
1794 vPtMin
.y
= avPoint
[0].y
;
1795 vPtMax
.y
= avPoint
[0].y
;
1796 for (i
= 1; i
< 4; i
++)
1798 if(vPtMin
.x
> avPoint
[i
].x
) vPtMin
.x
= avPoint
[i
].x
;
1799 if(vPtMin
.y
> avPoint
[i
].y
) vPtMin
.y
= avPoint
[i
].y
;
1800 if(vPtMax
.x
< avPoint
[i
].x
) vPtMax
.x
= avPoint
[i
].x
;
1801 if(vPtMax
.y
< avPoint
[i
].y
) vPtMax
.y
= avPoint
[i
].y
;
1803 bRc
= ::GpiQueryFontMetrics( hPS
1804 ,sizeof(FONTMETRICS
)
1831 *pX
= (vPtMax
.x
- vPtMin
.x
+ 1);
1833 *pY
= (vPtMax
.y
- vPtMin
.y
+ 1);
1837 *pDescent
= vFM
.lMaxDescender
;
1841 if (pExternalLeading
)
1844 *pExternalLeading
= vFM
.lExternalLeading
;
1846 *pExternalLeading
= 0;
1848 ::WinReleasePS(hPS
);
1849 } // end of wxWindow::GetTextExtent
1851 bool wxWindowOS2::IsMouseInWindow() const
1854 // Get the mouse position
1857 ::WinQueryPointerPos(HWND_DESKTOP
, &vPt
);
1860 // Find the window which currently has the cursor and go up the window
1861 // chain until we find this window - or exhaust it
1863 HWND hWnd
= ::WinWindowFromPoint(HWND_DESKTOP
, &vPt
, TRUE
);
1865 while (hWnd
&& (hWnd
!= GetHwnd()))
1866 hWnd
= ::WinQueryWindow(hWnd
, QW_PARENT
);
1868 return hWnd
!= NULL
;
1869 } // end of wxWindowOS2::IsMouseInWindow
1871 #if wxUSE_CARET && WXWIN_COMPATIBILITY
1872 // ---------------------------------------------------------------------------
1873 // Caret manipulation
1874 // ---------------------------------------------------------------------------
1876 void wxWindowOS2::CreateCaret(
1881 SetCaret(new wxCaret( this
1885 } // end of wxWindowOS2::CreateCaret
1887 void wxWindowOS2::CreateCaret(
1888 const wxBitmap
* pBitmap
1891 wxFAIL_MSG("not implemented");
1892 } // end of wxWindowOS2::CreateCaret
1894 void wxWindowOS2::ShowCaret(
1898 wxCHECK_RET( m_caret
, "no caret to show" );
1900 m_caret
->Show(bShow
);
1901 } // end of wxWindowOS2::ShowCaret
1903 void wxWindowOS2::DestroyCaret()
1906 } // end of wxWindowOS2::DestroyCaret
1908 void wxWindowOS2::SetCaretPos(
1912 wxCHECK_RET( m_caret
, "no caret to move" );
1917 } // end of wxWindowOS2::SetCaretPos
1919 void wxWindowOS2::GetCaretPos(
1924 wxCHECK_RET( m_caret
, "no caret to get position of" );
1926 m_caret
->GetPosition( pX
1929 } // end of wxWindowOS2::GetCaretPos
1931 #endif //wxUSE_CARET
1933 // ---------------------------------------------------------------------------
1935 // ---------------------------------------------------------------------------
1937 #if wxUSE_MENUS_NATIVE
1938 static void wxYieldForCommandsOnly()
1941 // Peek all WM_COMMANDs (it will always return WM_QUIT too but we don't
1942 // want to process it here)
1946 while (::WinPeekMsg(vHabmain
, &vMsg
, (HWND
)0, WM_COMMAND
,
1947 WM_COMMAND
,PM_REMOVE
) && vMsg
.msg
!= WM_QUIT
)
1949 wxTheApp
->DoMessage((WXMSG
*)&vMsg
);
1952 #endif // wxUSE_MENUS_NATIVE
1954 #if wxUSE_MENUS_NATIVE
1955 bool wxWindowOS2::DoPopupMenu(
1961 HWND hWnd
= GetHwnd();
1962 HWND hWndParent
= GetParent() ? GetWinHwnd(GetParent()) : (HWND
)0;
1963 HWND hMenu
= GetHmenuOf(pMenu
);
1965 pMenu
->SetInvokingWindow(this);
1968 DoClientToScreen( &nX
1971 wxCurrentPopupMenu
= pMenu
;
1973 ::WinPopupMenu( hWndParent
1979 ,PU_MOUSEBUTTON2DOWN
| PU_MOUSEBUTTON2
| PU_KEYBOARD
1981 // we need to do it righ now as otherwise the events are never going to be
1982 // sent to wxCurrentPopupMenu from ;()
1984 // note that even eliminating (ugly) wxCurrentPopupMenu global wouldn't
1985 // help and we'd still need wxYieldForCommandsOnly() as the menu may be
1986 // destroyed as soon as we return (it can be a local variable in the caller
1987 // for example) and so we do need to process the event immediately
1988 wxYieldForCommandsOnly();
1989 wxCurrentPopupMenu
= NULL
;
1991 pMenu
->SetInvokingWindow(NULL
);
1993 } // end of wxWindowOS2::DoPopupMenu
1994 #endif // wxUSE_MENUS_NATIVE
1996 // ===========================================================================
1997 // pre/post message processing
1998 // ===========================================================================
2000 MRESULT
wxWindowOS2::OS2DefWindowProc(
2007 return (MRESULT
)m_fnOldWndProc(GetHWND(), uMsg
, (MPARAM
)wParam
, (MPARAM
)lParam
);
2009 return ::WinDefWindowProc(GetHWND(), uMsg
, (MPARAM
)wParam
, (MPARAM
)lParam
);
2010 } // end of wxWindowOS2::OS2DefWindowProc
2012 bool wxWindowOS2::OS2ProcessMessage(
2016 // wxUniversal implements tab traversal itself
2017 #ifndef __WXUNIVERSAL__
2018 QMSG
* pQMsg
= (QMSG
*)pMsg
;
2020 if (m_hWnd
!= 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL
))
2023 // Intercept dialog navigation keys
2025 bool bProcess
= TRUE
;
2026 USHORT uKeyFlags
= SHORT1FROMMP(pQMsg
->mp1
);
2028 if (uKeyFlags
& KC_KEYUP
)
2031 if (uKeyFlags
& KC_ALT
)
2034 if (!(uKeyFlags
& KC_VIRTUALKEY
))
2039 bool bCtrlDown
= IsCtrlDown();
2040 bool bShiftDown
= IsShiftDown();
2043 // WM_QUERYDLGCODE: ask the control if it wants the key for itself,
2044 // don't process it if it's the case (except for Ctrl-Tab/Enter
2045 // combinations which are always processed)
2047 ULONG ulDlgCode
= 0;
2051 ulDlgCode
= (ULONG
)::WinSendMsg(pQMsg
->hwnd
, WM_QUERYDLGCODE
, pQMsg
, 0);
2054 bool bForward
= TRUE
;
2055 bool bWindowChange
= FALSE
;
2057 switch (SHORT2FROMMP(pQMsg
->mp2
))
2060 // Going to make certain assumptions about specific types of controls
2061 // here, so we may have to alter some things later if they prove invalid
2065 // Shift tabl will always be a nav-key but tabs may be wanted
2074 // Entry Fields want tabs for themselve usually
2078 case DLGC_ENTRYFIELD
:
2088 // Ctrl-Tab cycles thru notebook pages
2090 bWindowChange
= bCtrlDown
;
2091 bForward
= !bShiftDown
;
2114 // ctrl-enter is not processed
2118 else if (ulDlgCode
& DLGC_BUTTON
)
2121 // buttons want process Enter themselevs
2127 wxButton
* pBtn
= wxDynamicCast( GetDefaultItem()
2131 if (pBtn
&& pBtn
->IsEnabled())
2134 // If we do have a default button, do press it
2136 pBtn
->OS2Command(BN_CLICKED
, 0 /* unused */);
2139 // else: but if it does not it makes sense to make
2140 // it work like a TAB - and that's what we do.
2141 // Note that Ctrl-Enter always works this way.
2152 wxNavigationKeyEvent vEvent
;
2154 vEvent
.SetDirection(bForward
);
2155 vEvent
.SetWindowChange(bWindowChange
);
2156 vEvent
.SetEventObject(this);
2158 if (GetEventHandler()->ProcessEvent(vEvent
))
2160 wxButton
* pBtn
= wxDynamicCast(FindFocus(), wxButton
);
2165 // The button which has focus should be default
2174 // Let Dialogs process
2176 if (::WinSendMsg(pQMsg
->hwnd
, WM_QUERYDLGCODE
, pQMsg
, 0));
2180 pMsg
= pMsg
; // just shut up the compiler
2181 #endif // __WXUNIVERSAL__
2186 // relay mouse move events to the tooltip control
2187 QMSG
* pQMsg
= (QMSG
*)pMsg
;
2189 if (pQMsg
->msg
== WM_MOUSEMOVE
)
2190 m_tooltip
->RelayEvent(pMsg
);
2192 #endif // wxUSE_TOOLTIPS
2195 } // end of wxWindowOS2::OS2ProcessMessage
2197 bool wxWindowOS2::OS2TranslateMessage(
2201 #if wxUSE_ACCEL && !defined(__WXUNIVERSAL__)
2202 return m_acceleratorTable
.Translate(m_hWnd
, pMsg
);
2206 #endif //wxUSE_ACCEL
2207 } // end of wxWindowOS2::OS2TranslateMessage
2209 // ---------------------------------------------------------------------------
2210 // message params unpackers
2211 // ---------------------------------------------------------------------------
2213 void wxWindowOS2::UnpackCommand(
2221 *pId
= LOWORD(wParam
);
2222 *phWnd
= NULL
; // or may be GetHWND() ?
2223 *pCmd
= LOWORD(lParam
);
2224 } // end of wxWindowOS2::UnpackCommand
2226 void wxWindowOS2::UnpackActivate(
2233 *pState
= LOWORD(wParam
);
2234 *phWnd
= (WXHWND
)lParam
;
2235 } // end of wxWindowOS2::UnpackActivate
2237 void wxWindowOS2::UnpackScroll(
2248 ulId
= (ULONG
)LONGFROMMP(wParam
);
2249 hWnd
= ::WinWindowFromID(GetHwnd(), ulId
);
2250 if (hWnd
== m_hWndScrollBarHorz
|| hWnd
== m_hWndScrollBarVert
)
2251 *phWnd
= NULLHANDLE
;
2255 *pPos
= SHORT1FROMMP(lParam
);
2256 *pCode
= SHORT2FROMMP(lParam
);
2257 } // end of wxWindowOS2::UnpackScroll
2259 void wxWindowOS2::UnpackMenuSelect(
2267 *pItem
= (WXWORD
)LOWORD(wParam
);
2268 *pFlags
= HIWORD(wParam
);
2269 *phMenu
= (WXHMENU
)lParam
;
2270 } // end of wxWindowOS2::UnpackMenuSelect
2272 // ---------------------------------------------------------------------------
2273 // Main wxWindows window proc and the window proc for wxWindow
2274 // ---------------------------------------------------------------------------
2277 // Hook for new window just as it's being created, when the window isn't yet
2278 // associated with the handle
2280 wxWindowOS2
* wxWndHook
= NULL
;
2285 MRESULT EXPENTRY
wxWndProc(
2293 // Trace all ulMsgs - useful for the debugging
2296 wxLogTrace(wxTraceMessages
, wxT("Processing %s(wParam=%8lx, lParam=%8lx)"),
2297 wxGetMessageName(ulMsg
), wParam
, lParam
);
2298 #endif // __WXDEBUG__
2300 wxWindowOS2
* pWnd
= wxFindWinFromHandle((WXHWND
)hWnd
);
2303 // When we get the first message for the HWND we just created, we associate
2304 // it with wxWindow stored in wxWndHook
2306 if (!pWnd
&& wxWndHook
)
2308 wxAssociateWinWithHandle(hWnd
, wxWndHook
);
2311 pWnd
->SetHWND((WXHWND
)hWnd
);
2314 MRESULT rc
= (MRESULT
)0;
2318 // Stop right here if we don't have a valid handle in our wxWindow object.
2320 if (pWnd
&& !pWnd
->GetHWND())
2322 pWnd
->SetHWND((WXHWND
) hWnd
);
2323 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
2329 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
2331 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
2335 } // end of wxWndProc
2338 // We will add (or delete) messages we need to handle at this default
2341 MRESULT
wxWindowOS2::OS2WindowProc(
2348 // Did we process the uMsg?
2350 bool bProcessed
= FALSE
;
2354 // For most messages we should return 0 when we do process the message
2356 mResult
= (MRESULT
)0;
2364 bProcessed
= HandleCreate( (WXLPCREATESTRUCT
)lParam
2370 // Return 0 to bAllow window creation
2372 mResult
= (MRESULT
)(bMayCreate
? 0 : -1);
2383 bProcessed
= HandleMove( LOWORD(lParam
)
2389 bProcessed
= HandleSize( LOWORD(lParam
)
2400 UnpackActivate( wParam
2406 bProcessed
= HandleActivate( wState
2414 if (SHORT1FROMMP((MPARAM
)lParam
) == TRUE
)
2415 bProcessed
= HandleSetFocus((WXHWND
)(HWND
)wParam
);
2417 bProcessed
= HandleKillFocus((WXHWND
)(HWND
)wParam
);
2421 bProcessed
= HandlePaint();
2426 // Don't let the DefWindowProc() destroy our window - we'll do it
2427 // ourselves in ~wxWindow
2430 mResult
= (MRESULT
)TRUE
;
2434 bProcessed
= HandleShow(wParam
!= 0, (int)lParam
);
2438 // Under OS2 PM Joysticks are treated just like mouse events
2439 // The "Motion" events will be prevelent in joysticks
2442 case WM_BUTTON1DOWN
:
2444 case WM_BUTTON1DBLCLK
:
2445 case WM_BUTTON1MOTIONEND
:
2446 case WM_BUTTON1MOTIONSTART
:
2447 case WM_BUTTON2DOWN
:
2449 case WM_BUTTON2DBLCLK
:
2450 case WM_BUTTON2MOTIONEND
:
2451 case WM_BUTTON2MOTIONSTART
:
2452 case WM_BUTTON3DOWN
:
2454 case WM_BUTTON3DBLCLK
:
2455 case WM_BUTTON3MOTIONEND
:
2456 case WM_BUTTON3MOTIONSTART
:
2458 short x
= LOWORD(lParam
);
2459 short y
= HIWORD(lParam
);
2461 bProcessed
= HandleMouseEvent(uMsg
, x
, y
, (WXUINT
)wParam
);
2465 bProcessed
= HandleSysCommand(wParam
, lParam
);
2472 UnpackCommand(wParam
, lParam
, &id
, &hwnd
, &cmd
);
2474 bProcessed
= HandleCommand(id
, cmd
, hwnd
);
2479 // For these messages we must return TRUE if process the message
2482 case WM_MEASUREITEM
:
2484 int nIdCtrl
= (UINT
)wParam
;
2486 if ( uMsg
== WM_DRAWITEM
)
2488 bProcessed
= OS2OnDrawItem(nIdCtrl
,
2489 (WXDRAWITEMSTRUCT
*)lParam
);
2493 bProcessed
= OS2OnMeasureItem(nIdCtrl
,
2494 (WXMEASUREITEMSTRUCT
*)lParam
);
2498 mResult
= (MRESULT
)TRUE
;
2502 case WM_QUERYDLGCODE
:
2505 mResult
= (MRESULT
)m_lDlgCode
;
2509 //else: get the dlg code from the DefWindowProc()
2514 // In OS/2 PM all keyboard events are of the WM_CHAR type. Virtual key and key-up
2515 // and key-down events are obtained from the WM_CHAR params.
2519 USHORT uKeyFlags
= SHORT1FROMMP((MPARAM
)wParam
);
2521 if (uKeyFlags
& KC_KEYUP
)
2523 //TODO: check if the cast to WXWORD isn't causing trouble
2524 bProcessed
= HandleKeyUp((WXDWORD
)wParam
, lParam
);
2527 else // keydown event
2530 // If this has been processed by an event handler,
2531 // return 0 now (we've handled it). DON't RETURN
2532 // we still need to process further
2534 HandleKeyDown((WXDWORD
)wParam
, lParam
);
2535 if (uKeyFlags
& KC_VIRTUALKEY
)
2537 USHORT uVk
= SHORT2FROMMP((MPARAM
)lParam
);
2540 // We consider these message "not interesting" to OnChar
2542 if (uVk
== VK_SHIFT
|| uVk
== VK_CTRL
)
2550 // Avoid duplicate messages to OnChar for these ASCII keys: they
2551 // will be translated by TranslateMessage() and received in WM_CHAR
2557 // But set processed to FALSE, not TRUE to still pass them to
2558 // the control's default window proc - otherwise built-in
2559 // keyboard handling won't work
2568 bProcessed
= HandleChar((WXDWORD
)wParam
, lParam
);
2572 else // WM_CHAR -- Always an ASCII character
2574 bProcessed
= HandleChar((WXDWORD
)wParam
, lParam
, TRUE
);
2586 UnpackScroll( wParam
2593 bProcessed
= OS2OnScroll( uMsg
== WM_HSCROLL
? wxHORIZONTAL
2603 switch(SHORT2FROMMP(wParam
))
2606 case SPBN_DOWNARROW
:
2612 ::WinSendMsg( HWNDFROMMP(lParam
)
2615 ,MPFROM2SHORT( (USHORT
)10
2616 ,(USHORT
)SPBQ_UPDATEIFVALID
2620 bProcessed
= OS2OnScroll( wxVERTICAL
2621 ,(int)SHORT2FROMMP(wParam
)
2628 case SLN_SLIDERTRACK
:
2630 HWND hWnd
= ::WinWindowFromID(GetHWND(), SHORT1FROMMP(wParam
));
2631 wxWindowOS2
* pChild
= wxFindWinFromHandle(hWnd
);
2633 if (pChild
->IsKindOf(CLASSINFO(wxSlider
)))
2634 bProcessed
= OS2OnScroll( wxVERTICAL
2635 ,(int)SHORT2FROMMP(wParam
)
2636 ,(int)LONGFROMMP(lParam
)
2644 #if defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
2645 case WM_CTLCOLORCHANGE
:
2647 bProcessed
= HandleCtlColor(&hBrush
);
2651 case WM_ERASEBACKGROUND
:
2653 // Returning TRUE to requestw PM to paint the window background
2654 // in SYSCLR_WINDOW. We don't really want that
2656 bProcessed
= HandleEraseBkgnd((WXHDC
)(HPS
)wParam
);
2657 mResult
= (MRESULT
)(FALSE
);
2660 // the return value for this message is ignored
2661 case WM_SYSCOLORCHANGE
:
2662 bProcessed
= HandleSysColorChange();
2665 case WM_REALIZEPALETTE
:
2666 bProcessed
= HandlePaletteChanged();
2669 // move all drag and drops to wxDrg
2671 bProcessed
= HandleEndDrag(wParam
);
2675 bProcessed
= HandleInitDialog((WXHWND
)(HWND
)wParam
);
2679 // we never set focus from here
2684 // wxFrame specific message
2685 case WM_MINMAXFRAME
:
2686 bProcessed
= HandleGetMinMaxInfo((PSWP
)wParam
);
2689 case WM_SYSVALUECHANGED
:
2690 // TODO: do something
2691 mResult
= (MRESULT
)TRUE
;
2695 // Comparable to WM_SETPOINTER for windows, only for just controls
2697 case WM_CONTROLPOINTER
:
2698 bProcessed
= HandleSetCursor( SHORT1FROMMP(wParam
) // Control ID
2699 ,(HWND
)lParam
// Cursor Handle
2704 // Returning TRUE stops the DefWindowProc() from further
2705 // processing this message - exactly what we need because we've
2706 // just set the cursor.
2708 mResult
= (MRESULT
)TRUE
;
2715 wxLogTrace(wxTraceMessages
, wxT("Forwarding %s to DefWindowProc."),
2716 wxGetMessageName(uMsg
));
2717 #endif // __WXDEBUG__
2718 if (IsKindOf(CLASSINFO(wxFrame
)))
2719 mResult
= ::WinDefWindowProc(m_hWnd
, uMsg
, wParam
, lParam
);
2720 else if (IsKindOf(CLASSINFO(wxDialog
)))
2721 mResult
= ::WinDefDlgProc( m_hWnd
, uMsg
, wParam
, lParam
);
2723 mResult
= OS2DefWindowProc(uMsg
, wParam
, lParam
);
2726 } // end of wxWindowOS2::OS2WindowProc
2729 // Dialog window proc
2734 , MPARAM
WXUNUSED(wParam
)
2735 , MPARAM
WXUNUSED(lParam
))
2737 if (uMsg
== WM_INITDLG
)
2740 // For this message, returning TRUE tells system to set focus to the
2741 // first control in the dialog box
2743 return (MRESULT
)TRUE
;
2748 // For all the other ones, FALSE means that we didn't process the
2753 } // end of wxDlgProc
2755 wxWindow
* wxFindWinFromHandle(
2759 wxNode
* pNode
= wxWinHandleList
->Find((long)hWnd
);
2763 return (wxWindow
*)pNode
->Data();
2764 } // end of wxFindWinFromHandle
2766 void wxAssociateWinWithHandle(
2772 // Adding NULL hWnd is (first) surely a result of an error and
2773 // (secondly) breaks menu command processing
2775 wxCHECK_RET( hWnd
!= (HWND
)NULL
,
2776 wxT("attempt to add a NULL hWnd to window list ignored") );
2779 wxWindow
* pOldWin
= wxFindWinFromHandle((WXHWND
) hWnd
);
2781 if (pOldWin
&& (pOldWin
!= pWin
))
2783 wxString
str(pWin
->GetClassInfo()->GetClassName());
2784 wxLogError( "Bug! Found existing HWND %X for new window of class %s"
2791 wxWinHandleList
->Append( (long)hWnd
2795 } // end of wxAssociateWinWithHandle
2797 void wxRemoveHandleAssociation(
2801 wxWinHandleList
->DeleteObject(pWin
);
2802 } // end of wxRemoveHandleAssociation
2805 // Default destroyer - override if you destroy it in some other way
2806 // (e.g. with MDI child windows)
2808 void wxWindowOS2::OS2DestroyWindow()
2812 bool wxWindowOS2::OS2GetCreateWindowCoords(
2814 , const wxSize
& rSize
2821 bool bNonDefault
= FALSE
;
2826 // If set x to CW_USEDEFAULT, y parameter is ignored anyhow so we can
2827 // just as well set it to CW_USEDEFAULT as well
2828 rnX
= rnY
= CW_USEDEFAULT
;
2833 rnY
= rPos
.y
== -1 ? CW_USEDEFAULT
: rPos
.y
;
2839 // As abobe, h is not used at all in this case anyhow
2841 rnWidth
= rnHeight
= CW_USEDEFAULT
;
2846 rnHeight
= rSize
.y
== -1 ? CW_USEDEFAULT
: rSize
.y
;
2850 } // end of wxWindowOS2::OS2GetCreateWindowCoords
2852 bool wxWindowOS2::OS2Create(
2854 , const char* zTitle
2856 , const wxPoint
& rPos
2857 , const wxSize
& rSize
2869 wxWindow
* pParent
= GetParent();
2870 HWND hWnd
= NULLHANDLE
;
2872 long lControlId
= 0L;
2873 wxWindowCreationHook
vHook(this);
2874 wxString
sClassName((wxChar
*)zClass
);
2876 OS2GetCreateWindowCoords( rPos
2884 if (GetWindowStyleFlag() & wxPOPUP_WINDOW
)
2885 hParent
= HWND_DESKTOP
;
2888 if ((bIsChild
|| HasFlag(wxFRAME_TOOL_WINDOW
)) && pParent
)
2891 // This is either a normal child window or a top level window with
2892 // wxFRAME_TOOL_WINDOW style (see below)
2894 hParent
= GetHwndOf(pParent
);
2899 // This is either a window for which no parent was specified (not
2900 // much we can do then) or a frame without wxFRAME_TOOL_WINDOW
2901 // style: we should use NULL parent HWND for it or it would be
2902 // always on top of its parent which is not what we usually want
2903 // (in fact, we only want it for frames with the special
2904 // wxFRAME_TOOL_WINDOW as above)
2911 lControlId
= GetId();
2912 if (GetWindowStyleFlag() & wxCLIP_SIBLINGS
)
2914 dwStyle
|= WS_CLIPSIBLINGS
;
2918 // For each class "Foo" we have we also have "FooNR" ("no repaint") class
2919 // which is the same but without CS_[HV]REDRAW class styles so using it
2920 // ensures that the window is not fully repainted on each resize
2922 if (GetWindowStyleFlag() & wxNO_FULL_REPAINT_ON_RESIZE
)
2924 sClassName
+= wxT("NR");
2928 // If the window being created is a Frame's Statusbar we need to use
2929 // the actual Frame's size, not its client
2933 if (IsKindOf(CLASSINFO(wxStatusBar
)) &&
2934 pParent
->IsKindOf(CLASSINFO(wxFrame
)))
2937 wxFrame
* pFrame
= wxDynamicCast(pParent
, wxFrame
);
2939 ::WinQueryWindowRect((HWND
)pFrame
->GetFrame(), &vRect
);
2940 nY
= vRect
.yTop
- (nY
+ nHeight
);
2943 nY
= pParent
->GetSize().y
- (nY
+ nHeight
);
2949 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
2950 nY
= vRect
.yTop
- (nY
+ nHeight
);
2952 m_hWnd
= (WXHWND
)::WinCreateWindow( (HWND
)hParent
2953 ,(PSZ
)sClassName
.c_str()
2954 ,(PSZ
)zTitle
? zTitle
: ""
2968 vError
= ::WinGetLastError(wxGetInstance());
2969 sError
= wxPMErrorToStr(vError
);
2972 SubclassWin(m_hWnd
);
2973 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
2980 } // end of WinGuiBase_Window::OS2Create
2982 // ===========================================================================
2983 // OS2 PM message handlers
2984 // ===========================================================================
2986 // ---------------------------------------------------------------------------
2987 // window creation/destruction
2988 // ---------------------------------------------------------------------------
2990 bool wxWindowOS2::HandleCreate(
2991 WXLPCREATESTRUCT
WXUNUSED(vCs
)
2995 wxWindowCreateEvent
vEvent((wxWindow
*)this);
2997 (void)GetEventHandler()->ProcessEvent(vEvent
);
2998 *pbMayCreate
= TRUE
;
3000 } // end of wxWindowOS2::HandleCreate
3002 bool wxWindowOS2::HandleDestroy()
3004 wxWindowDestroyEvent
vEvent((wxWindow
*)this);
3006 (void)GetEventHandler()->ProcessEvent(vEvent
);
3009 // Delete our drop target if we've got one
3011 #if wxUSE_DRAG_AND_DROP
3012 if (m_dropTarget
!= NULL
)
3014 m_dropTarget
->Revoke(m_hWnd
);
3015 delete m_dropTarget
;
3016 m_dropTarget
= NULL
;
3018 #endif // wxUSE_DRAG_AND_DROP
3021 // WM_DESTROY handled
3024 } // end of wxWindowOS2::HandleDestroy
3026 // ---------------------------------------------------------------------------
3028 // ---------------------------------------------------------------------------
3029 void wxWindowOS2::OnSetFocus(
3030 wxFocusEvent
& rEvent
3034 } // end of wxWindowOS2::OnSetFocus
3036 bool wxWindowOS2::HandleActivate(
3038 , WXHWND
WXUNUSED(hActivate
)
3041 wxActivateEvent
vEvent( wxEVT_ACTIVATE
3045 vEvent
.SetEventObject(this);
3046 return GetEventHandler()->ProcessEvent(vEvent
);
3047 } // end of wxWindowOS2::HandleActivate
3049 bool wxWindowOS2::HandleSetFocus(
3050 WXHWND
WXUNUSED(hWnd
)
3059 m_caret
->OnSetFocus();
3061 #endif // wxUSE_CARET
3064 // If it's a wxTextCtrl don't send the event as it will be done
3065 // after the control gets to process it from EN_FOCUS handler
3066 if ( wxDynamicCastThis(wxTextCtrl
) )
3070 #endif // wxUSE_TEXTCTRL
3072 wxFocusEvent
vEvent(wxEVT_SET_FOCUS
, m_windowId
);
3074 vEvent
.SetEventObject(this);
3075 return GetEventHandler()->ProcessEvent(vEvent
);
3076 } // end of wxWindowOS2::HandleSetFocus
3078 bool wxWindowOS2::HandleKillFocus(
3079 WXHWND
WXUNUSED(hWnd
)
3088 m_caret
->OnKillFocus();
3090 #endif // wxUSE_CARET
3092 wxFocusEvent
vEvent( wxEVT_KILL_FOCUS
3096 vEvent
.SetEventObject(this);
3097 return GetEventHandler()->ProcessEvent(vEvent
);
3098 } // end of wxWindowOS2::HandleKillFocus
3100 // ---------------------------------------------------------------------------
3102 // ---------------------------------------------------------------------------
3104 bool wxWindowOS2::HandleShow(
3106 , int WXUNUSED(nStatus
)
3109 wxShowEvent
vEvent(GetId(), bShow
);
3111 vEvent
.m_eventObject
= this;
3112 return GetEventHandler()->ProcessEvent(vEvent
);
3113 } // end of wxWindowOS2::HandleShow
3115 bool wxWindowOS2::HandleInitDialog(
3116 WXHWND
WXUNUSED(hWndFocus
)
3119 wxInitDialogEvent
vEvent(GetId());
3121 vEvent
.m_eventObject
= this;
3122 return GetEventHandler()->ProcessEvent(vEvent
);
3123 } // end of wxWindowOS2::HandleInitDialog
3125 bool wxWindowOS2::HandleEndDrag(WXWPARAM
WXUNUSED(wParam
))
3127 // TODO: We'll handle drag and drop later
3131 bool wxWindowOS2::HandleSetCursor(
3132 USHORT
WXUNUSED(vId
)
3137 // Under OS/2 PM this allows the pointer to be changed
3138 // as it passes over a control
3140 ::WinSetPointer(HWND_DESKTOP
, (HPOINTER
)hPointer
);
3142 } // end of wxWindowOS2::HandleSetCursor
3144 // ---------------------------------------------------------------------------
3145 // owner drawn stuff
3146 // ---------------------------------------------------------------------------
3147 bool wxWindowOS2::OS2OnDrawItem(
3149 , WXDRAWITEMSTRUCT
* pItemStruct
3152 #if wxUSE_OWNER_DRAWN
3155 #if wxUSE_MENUS_NATIVE
3157 // Is it a menu item?
3163 POWNERITEM pMeasureStruct
= (POWNERITEM
)pItemStruct
;
3164 wxFrame
* pFrame
= (wxFrame
*)this;
3165 wxMenuItem
* pMenuItem
= pFrame
->GetMenuBar()->FindItem(pMeasureStruct
->idItem
, pMeasureStruct
->hItem
);
3166 HDC hDC
= ::GpiQueryDevice(pMeasureStruct
->hps
);
3167 wxRect
vRect( pMeasureStruct
->rclItem
.xLeft
3168 ,pMeasureStruct
->rclItem
.yBottom
3169 ,pMeasureStruct
->rclItem
.xRight
- pMeasureStruct
->rclItem
.xLeft
3170 ,pMeasureStruct
->rclItem
.yTop
- pMeasureStruct
->rclItem
.yBottom
3175 vDc
.SetHPS(pMeasureStruct
->hps
);
3177 // Load the wxWindows Pallete and set to RGB mode
3179 if (!::GpiCreateLogColorTable( pMeasureStruct
->hps
3183 ,(LONG
)wxTheColourDatabase
->m_nSize
3184 ,(PLONG
)wxTheColourDatabase
->m_palTable
3187 vError
= ::WinGetLastError(vHabmain
);
3188 sError
= wxPMErrorToStr(vError
);
3189 wxLogError("Unable to set current color table. Error: %s\n", sError
);
3192 // Set the color table to RGB mode
3194 if (!::GpiCreateLogColorTable( pMeasureStruct
->hps
3202 vError
= ::WinGetLastError(vHabmain
);
3203 sError
= wxPMErrorToStr(vError
);
3204 wxLogError("Unable to set current color table. Error: %s\n", sError
);
3207 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
3213 if (pMeasureStruct
->fsAttribute
== pMeasureStruct
->fsAttributeOld
)
3216 // Entire Item needs to be redrawn (either it has reappeared from
3217 // behind another window or is being displayed for the first time
3219 eAction
= wxOwnerDrawn::wxODDrawAll
;
3221 if (pMeasureStruct
->fsAttribute
& MIA_HILITED
)
3224 // If it is currently selected we let the system handle it
3226 eStatus
|= wxOwnerDrawn::wxODSelected
;
3228 if (pMeasureStruct
->fsAttribute
& MIA_CHECKED
)
3231 // If it is currently checked we draw our own
3233 eStatus
|= wxOwnerDrawn::wxODChecked
;
3234 pMeasureStruct
->fsAttributeOld
= pMeasureStruct
->fsAttribute
&= ~MIA_CHECKED
;
3236 if (pMeasureStruct
->fsAttribute
& MIA_DISABLED
)
3239 // If it is currently disabled we let the system handle it
3241 eStatus
|= wxOwnerDrawn::wxODDisabled
;
3244 // Don't really care about framed (indicationg focus) or NoDismiss
3249 if (pMeasureStruct
->fsAttribute
& MIA_HILITED
)
3251 eAction
= wxOwnerDrawn::wxODDrawAll
;
3252 eStatus
|= wxOwnerDrawn::wxODSelected
;
3254 // Keep the system from trying to highlight with its bogus colors
3256 pMeasureStruct
->fsAttributeOld
= pMeasureStruct
->fsAttribute
&= ~MIA_HILITED
;
3258 else if (!(pMeasureStruct
->fsAttribute
& MIA_HILITED
))
3260 eAction
= wxOwnerDrawn::wxODDrawAll
;
3263 // Keep the system from trying to highlight with its bogus colors
3265 pMeasureStruct
->fsAttribute
= pMeasureStruct
->fsAttributeOld
&= ~MIA_HILITED
;
3270 // For now we don't care about anything else
3271 // just ignore the entire message!
3277 // Now redraw the item
3279 return(pMenuItem
->OnDrawItem( vDc
3281 ,(wxOwnerDrawn::wxODAction
)eAction
3282 ,(wxOwnerDrawn::wxODStatus
)eStatus
3285 // leave the fsAttribute and fsOldAttribute unchanged. If different,
3286 // the system will do the highlight or fraeming or disabling for us,
3287 // otherwise, we'd have to do it ourselves.
3290 #endif // wxUSE_MENUS_NATIVE
3292 wxWindow
* pItem
= FindItem(vId
);
3294 if (pItem
&& pItem
->IsKindOf(CLASSINFO(wxControl
)))
3296 return ((wxControl
*)pItem
)->OS2OnDraw(pItemStruct
);
3300 pItemStruct
= pItemStruct
;
3303 } // end of wxWindowOS2::OS2OnDrawItem
3305 bool wxWindowOS2::OS2OnMeasureItem(
3307 , WXMEASUREITEMSTRUCT
* pItemStruct
3310 #if wxUSE_OWNER_DRAWN
3312 // Is it a menu item?
3314 if (lId
== 65536) // I really don't like this...has to be a better indicator
3316 if (IsKindOf(CLASSINFO(wxFrame
))) // we'll assume if Frame then a menu
3320 POWNERITEM pMeasureStruct
= (POWNERITEM
)pItemStruct
;
3321 wxFrame
* pFrame
= (wxFrame
*)this;
3322 wxMenuItem
* pMenuItem
= pFrame
->GetMenuBar()->FindItem(pMeasureStruct
->idItem
, pMeasureStruct
->hItem
);
3324 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
3327 if (pMenuItem
->OnMeasureItem( &nWidth
3331 pMeasureStruct
->rclItem
.xRight
= nWidth
;
3332 pMeasureStruct
->rclItem
.xLeft
= 0L;
3333 pMeasureStruct
->rclItem
.yTop
= nHeight
;
3334 pMeasureStruct
->rclItem
.yBottom
= 0L;
3340 wxWindow
* pItem
= FindItem(lId
);
3342 if (pItem
&& pItem
->IsKindOf(CLASSINFO(wxControl
)))
3344 return ((wxControl
*)pItem
)->OS2OnMeasure(pItemStruct
);
3348 pItemStruct
= pItemStruct
;
3349 #endif // wxUSE_OWNER_DRAWN
3353 // ---------------------------------------------------------------------------
3354 // colours and palettes
3355 // ---------------------------------------------------------------------------
3357 bool wxWindowOS2::HandleSysColorChange()
3359 wxSysColourChangedEvent vEvent
;
3361 vEvent
.SetEventObject(this);
3362 return GetEventHandler()->ProcessEvent(vEvent
);
3363 } // end of wxWindowOS2::HandleSysColorChange
3365 bool wxWindowOS2::HandleCtlColor(
3366 WXHBRUSH
* WXUNUSED(phBrush
)
3370 // Not much provided with message. So not sure I can do anything with it
3373 } // end of wxWindowOS2::HandleCtlColor
3376 // Define for each class of dialog and control
3377 WXHBRUSH
wxWindowOS2::OnCtlColor(WXHDC
WXUNUSED(hDC
),
3378 WXHWND
WXUNUSED(hWnd
),
3379 WXUINT
WXUNUSED(nCtlColor
),
3380 WXUINT
WXUNUSED(message
),
3381 WXWPARAM
WXUNUSED(wParam
),
3382 WXLPARAM
WXUNUSED(lParam
))
3387 bool wxWindowOS2::HandlePaletteChanged()
3389 // need to set this to something first
3390 WXHWND hWndPalChange
= NULLHANDLE
;
3392 wxPaletteChangedEvent
vEvent(GetId());
3394 vEvent
.SetEventObject(this);
3395 vEvent
.SetChangedWindow(wxFindWinFromHandle(hWndPalChange
));
3397 return GetEventHandler()->ProcessEvent(vEvent
);
3398 } // end of wxWindowOS2::HandlePaletteChanged
3401 // Responds to colour changes: passes event on to children.
3403 void wxWindowOS2::OnSysColourChanged(
3404 wxSysColourChangedEvent
& rEvent
3407 wxNode
* pNode
= GetChildren().First();
3412 // Only propagate to non-top-level windows
3414 wxWindow
* pWin
= (wxWindow
*)pNode
->Data();
3416 if (pWin
->GetParent())
3418 wxSysColourChangedEvent vEvent
;
3420 rEvent
.m_eventObject
= pWin
;
3421 pWin
->GetEventHandler()->ProcessEvent(vEvent
);
3423 pNode
= pNode
->Next();
3425 } // end of wxWindowOS2::OnSysColourChanged
3427 // ---------------------------------------------------------------------------
3429 // ---------------------------------------------------------------------------
3431 bool wxWindowOS2::HandlePaint()
3434 wxPaintEvent
vEvent(m_windowId
);
3439 // Create empty region
3440 // TODO: get HPS somewhere else if possible
3441 hPS
= ::WinGetPS(GetHwnd());
3442 hRgn
= ::GpiCreateRegion(hPS
, 0, NULL
);
3444 if (::WinQueryUpdateRegion(GetHwnd(), hRgn
) == RGN_ERROR
)
3446 wxLogLastError("CreateRectRgn");
3450 m_updateRegion
= wxRegion(hRgn
, hPS
);
3452 vEvent
.SetEventObject(this);
3453 bProcessed
= GetEventHandler()->ProcessEvent(vEvent
);
3455 return GetEventHandler()->ProcessEvent(vEvent
); //bProcessed;
3456 } // end of wxWindowOS2::HandlePaint
3458 bool wxWindowOS2::HandleEraseBkgnd(
3465 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
3466 if (vSwp
.fl
& SWP_MINIMIZE
)
3471 vDC
.m_hPS
= (HPS
)hDC
; // this is really a PS
3472 vDC
.SetWindow((wxWindow
*)this);
3475 wxEraseEvent
vEvent(m_windowId
, &vDC
);
3477 vEvent
.SetEventObject(this);
3479 rc
= GetEventHandler()->ProcessEvent(vEvent
);
3482 vDC
.m_hPS
= NULLHANDLE
;
3484 } // end of wxWindowOS2::HandleEraseBkgnd
3486 void wxWindowOS2::OnEraseBackground(
3487 wxEraseEvent
& rEvent
3491 HPS hPS
= rEvent
.m_dc
->m_hPS
;
3493 LONG lColor
= m_backgroundColour
.GetPixel();
3495 rc
= ::WinQueryWindowRect(GetHwnd(), &vRect
);
3496 rc
= ::WinFillRect(hPS
, &vRect
, lColor
);
3497 } // end of wxWindowOS2::OnEraseBackground
3499 // ---------------------------------------------------------------------------
3500 // moving and resizing
3501 // ---------------------------------------------------------------------------
3503 bool wxWindowOS2::HandleMinimize()
3505 wxIconizeEvent
vEvent(m_windowId
);
3507 vEvent
.SetEventObject(this);
3508 return GetEventHandler()->ProcessEvent(vEvent
);
3509 } // end of wxWindowOS2::HandleMinimize
3511 bool wxWindowOS2::HandleMaximize()
3513 wxMaximizeEvent
vEvent(m_windowId
);
3515 vEvent
.SetEventObject(this);
3516 return GetEventHandler()->ProcessEvent(vEvent
);
3517 } // end of wxWindowOS2::HandleMaximize
3519 bool wxWindowOS2::HandleMove(
3524 wxMoveEvent
vEvent(wxPoint(nX
, nY
), m_windowId
);
3526 vEvent
.SetEventObject(this);
3527 return GetEventHandler()->ProcessEvent(vEvent
);
3528 } // end of wxWindowOS2::HandleMove
3530 bool wxWindowOS2::HandleSize(
3533 , WXUINT
WXUNUSED(nFlag
)
3536 wxSizeEvent
vEvent(wxSize(nWidth
, nHeight
), m_windowId
);
3538 vEvent
.SetEventObject(this);
3539 return GetEventHandler()->ProcessEvent(vEvent
);
3540 } // end of wxWindowOS2::HandleSize
3542 bool wxWindowOS2::HandleGetMinMaxInfo(
3552 ::WinGetMaxPosition(GetHwnd(), pSwp
);
3553 m_maxWidth
= pSwp
->cx
;
3554 m_maxHeight
= pSwp
->cy
;
3558 ::WinGetMinPosition(GetHwnd(), pSwp
, &vPoint
);
3559 m_minWidth
= pSwp
->cx
;
3560 m_minHeight
= pSwp
->cy
;
3567 } // end of wxWindowOS2::HandleGetMinMaxInfo
3569 // ---------------------------------------------------------------------------
3571 // ---------------------------------------------------------------------------
3572 bool wxWindowOS2::HandleCommand(
3578 #if wxUSE_MENUS_NATIVE
3579 if (wxCurrentPopupMenu
)
3581 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
3583 wxCurrentPopupMenu
= NULL
;
3584 return pPopupMenu
->OS2Command(wCmd
, wId
);
3586 #endif // wxUSE_MENUS_NATIVE
3588 wxWindow
* pWin
= FindItem(wId
);
3592 pWin
= wxFindWinFromHandle(hControl
);
3596 return pWin
->OS2Command(wCmd
, wId
);
3599 } // end of wxWindowOS2::HandleCommand
3601 bool wxWindowOS2::HandleSysCommand(
3603 , WXLPARAM
WXUNUSED(lParam
)
3607 // 4 bits are reserved
3609 switch (SHORT1FROMMP(wParam
))
3612 return HandleMaximize();
3615 return HandleMinimize();
3618 } // end of wxWindowOS2::HandleSysCommand
3620 // ---------------------------------------------------------------------------
3622 // ---------------------------------------------------------------------------
3623 //TODO!!! check against MSW
3624 void wxWindowOS2::InitMouseEvent(
3625 wxMouseEvent
& rEvent
3633 rEvent
.m_shiftDown
= ((uFlags
& VK_SHIFT
) != 0);
3634 rEvent
.m_controlDown
= ((uFlags
& VK_CTRL
) != 0);
3635 rEvent
.m_leftDown
= ((uFlags
& VK_BUTTON1
) != 0);
3636 rEvent
.m_middleDown
= ((uFlags
& VK_BUTTON3
) != 0);
3637 rEvent
.m_rightDown
= ((uFlags
& VK_BUTTON2
) != 0);
3638 rEvent
.SetTimestamp(s_currentMsg
.time
);
3639 rEvent
.m_eventObject
= this;
3641 #if wxUSE_MOUSEEVENT_HACK
3644 m_lastMouseEvent
= rEvent
.GetEventType();
3645 #endif // wxUSE_MOUSEEVENT_HACK
3646 } // end of wxWindowOS2::InitMouseEvent
3648 bool wxWindowOS2::HandleMouseEvent(
3656 // The mouse events take consecutive IDs from WM_MOUSEFIRST to
3657 // WM_MOUSELAST, so it's enough to substract WM_MOUSEMOVE == WM_MOUSEFIRST
3658 // from the message id and take the value in the table to get wxWin event
3661 static const wxEventType eventsMouse
[] =
3675 wxMouseEvent
vEvent(eventsMouse
[uMsg
- WM_MOUSEMOVE
]);
3677 InitMouseEvent( vEvent
3683 return GetEventHandler()->ProcessEvent(vEvent
);
3684 } // end of wxWindowOS2::HandleMouseEvent
3686 bool wxWindowOS2::HandleMouseMove(
3692 if (!m_bMouseInWindow
)
3695 // Generate an ENTER event
3697 m_bMouseInWindow
= TRUE
;
3699 wxMouseEvent
vEvent(wxEVT_ENTER_WINDOW
);
3701 InitMouseEvent( vEvent
3707 (void)GetEventHandler()->ProcessEvent(vEvent
);
3709 return HandleMouseEvent( WM_MOUSEMOVE
3714 } // end of wxWindowOS2::HandleMouseMove
3716 // ---------------------------------------------------------------------------
3717 // keyboard handling
3718 // ---------------------------------------------------------------------------
3721 // Create the key event of the given type for the given key - used by
3722 // HandleChar and HandleKeyDown/Up
3724 wxKeyEvent
wxWindowOS2::CreateKeyEvent(
3730 wxKeyEvent
vEvent(eType
);
3732 vEvent
.SetId(GetId());
3733 vEvent
.m_shiftDown
= IsShiftDown();
3734 vEvent
.m_controlDown
= IsCtrlDown();
3735 vEvent
.m_altDown
= (HIWORD(lParam
) & KC_ALT
) == KC_ALT
;
3737 vEvent
.m_eventObject
= (wxWindow
*)this; // const_cast
3738 vEvent
.m_keyCode
= nId
;
3739 vEvent
.SetTimestamp(s_currentMsg
.time
);
3742 // Translate the position to client coords
3747 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
3748 ::WinQueryWindowRect( GetHwnd()
3752 vPoint
.x
-= vRect
.xLeft
;
3753 vPoint
.y
-= vRect
.yBottom
;
3755 vEvent
.m_x
= vPoint
.x
;
3756 vEvent
.m_y
= vPoint
.y
;
3759 } // end of wxWindowOS2::CreateKeyEvent
3762 // isASCII is TRUE only when we're called from WM_CHAR handler and not from
3765 bool wxWindowOS2::HandleChar(
3771 bool bCtrlDown
= FALSE
;
3777 // If 1 -> 26, translate to CTRL plus a letter.
3780 if ((vId
> 0) && (vId
< 27))
3802 else if ( (vId
= wxCharCodeOS2ToWX(wParam
)) == 0)
3805 // It's ASCII and will be processed here only when called from
3806 // WM_CHAR (i.e. when isASCII = TRUE), don't process it now
3813 wxKeyEvent
vEvent(CreateKeyEvent( wxEVT_CHAR
3820 vEvent
.m_controlDown
= TRUE
;
3823 if (GetEventHandler()->ProcessEvent(vEvent
))
3829 bool wxWindowOS2::HandleKeyDown(
3834 int nId
= wxCharCodeOS2ToWX(wParam
);
3839 // Normal ASCII char
3846 wxKeyEvent
vEvent(CreateKeyEvent( wxEVT_KEY_DOWN
3851 if (GetEventHandler()->ProcessEvent(vEvent
))
3857 } // end of wxWindowOS2::HandleKeyDown
3859 bool wxWindowOS2::HandleKeyUp(
3864 int nId
= wxCharCodeOS2ToWX(wParam
);
3869 // Normal ASCII char
3876 wxKeyEvent
vEvent(CreateKeyEvent( wxEVT_KEY_UP
3881 if (GetEventHandler()->ProcessEvent(vEvent
))
3885 } // end of wxWindowOS2::HandleKeyUp
3887 // ---------------------------------------------------------------------------
3889 // ---------------------------------------------------------------------------
3891 // ---------------------------------------------------------------------------
3893 // ---------------------------------------------------------------------------
3895 bool wxWindowOS2::OS2OnScroll(
3904 wxWindow
* pChild
= wxFindWinFromHandle(hControl
);
3907 return pChild
->OS2OnScroll( nOrientation
3914 wxScrollWinEvent vEvent
;
3916 vEvent
.SetPosition(wPos
);
3917 vEvent
.SetOrientation(nOrientation
);
3918 vEvent
.m_eventObject
= this;
3923 vEvent
.m_eventType
= wxEVT_SCROLLWIN_LINEUP
;
3927 vEvent
.m_eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
3931 vEvent
.m_eventType
= wxEVT_SCROLLWIN_PAGEUP
;
3935 vEvent
.m_eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
3938 case SB_SLIDERPOSITION
:
3939 vEvent
.m_eventType
= wxEVT_SCROLLWIN_THUMBRELEASE
;
3942 case SB_SLIDERTRACK
:
3943 vEvent
.m_eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
3949 return GetEventHandler()->ProcessEvent(vEvent
);
3950 } // end of wxWindowOS2::OS2OnScroll
3952 void wxWindowOS2::MoveChildren(
3958 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
3960 pNode
= pNode
->GetNext())
3962 wxWindow
* pWin
= pNode
->GetData();
3964 ::WinQueryWindowPos( GetHwndOf(pWin
)
3967 if (pWin
->IsKindOf(CLASSINFO(wxControl
)))
3972 // Must deal with controls that have margins like ENTRYFIELD. The SWP
3973 // struct of such a control will have and origin offset from its intended
3974 // position by the width of the margins.
3976 pCtrl
= wxDynamicCast(pWin
, wxControl
);
3977 vSwp
.y
-= pCtrl
->GetYComp();
3978 vSwp
.x
-= pCtrl
->GetXComp();
3980 ::WinSetWindowPos( GetHwndOf(pWin
)
3988 if (pWin
->IsKindOf(CLASSINFO(wxRadioBox
)))
3990 wxRadioBox
* pRadioBox
;
3992 pRadioBox
= wxDynamicCast(pWin
, wxRadioBox
);
3993 pRadioBox
->AdjustButtons( (int)vSwp
.x
3994 ,(int)vSwp
.y
- nDiff
3997 ,pRadioBox
->GetSizeFlags()
4000 if (pWin
->IsKindOf(CLASSINFO(wxSlider
)))
4004 pSlider
= wxDynamicCast(pWin
, wxSlider
);
4005 pSlider
->AdjustSubControls( (int)vSwp
.x
4006 ,(int)vSwp
.y
- nDiff
4009 ,(int)pSlider
->GetSizeFlags()
4013 } // end of wxWindowOS2::MoveChildren
4016 // Getting the Y position for a window, like a control, is a real
4017 // pain. There are three sitatuions we must deal with in determining
4018 // the OS2 to wxWindows Y coordinate.
4020 // 1) The controls are created in a dialog.
4021 // This is the easiest since a dialog is created with its original
4022 // size so the standard: Y = ParentHeight - (Y + ControlHeight);
4024 // 2) The controls are direct children of a frame
4025 // In this instance the controls are actually children of the Frame's
4026 // client. During creation the frame's client resizes several times
4027 // during creation of the status bar and toolbars. The CFrame class
4028 // will take care of this using its AlterChildPos proc.
4030 // 3) The controls are children of a panel, which in turn is a child of
4032 // This is the nastiest case. A panel is created as the only child of
4033 // the frame and as such, when a frame has only one child, the child is
4034 // expanded to fit the entire client area of the frame. Because the
4035 // controls are created BEFORE this occurs their positions are totally
4036 // whacked and any call to WinQueryWindowPos will return invalid
4037 // coordinates. So for this situation we have to compare the size of
4038 // the panel at control creation time with that of the frame client. If
4039 // they are the same we can use the standard Y position equation. If
4040 // not, then we must use the Frame Client's dimensions to position them
4041 // as that will be the eventual size of the panel after the frame resizes
4044 int wxWindowOS2::GetOS2ParentHeight(
4045 wxWindowOS2
* pParent
4048 wxWindowOS2
* pGrandParent
= NULL
;
4053 if (pParent
->IsKindOf(CLASSINFO(wxDialog
)))
4054 return(pParent
->GetSize().y
);
4057 // Case 2 -- if we are one of the separately built standard Frame
4058 // children, like a statusbar, menubar, or toolbar we want to
4059 // use the frame, itself, for positioning. Otherwise we are
4060 // child window and want to use the Frame's client.
4062 else if (pParent
->IsKindOf(CLASSINFO(wxFrame
)))
4064 if (IsKindOf(CLASSINFO(wxStatusBar
)) ||
4065 IsKindOf(CLASSINFO(wxMenuBar
)) ||
4066 IsKindOf(CLASSINFO(wxToolBar
))
4068 return(pParent
->GetSize().y
);
4070 return(pParent
->GetClientSize().y
);
4074 // Case 3 -- this is for any window that is the sole child of a Frame.
4075 // The grandparent must exist and it must be of type CFrame
4076 // and it's height must be different. Otherwise the standard
4081 pGrandParent
= pParent
->GetParent();
4083 pGrandParent
->IsKindOf(CLASSINFO(wxFrame
)) &&
4084 pGrandParent
->GetClientSize().y
!= pParent
->GetSize().y
4087 int nParentHeight
= 0L;
4088 int nStatusBarHeight
= 0L;
4089 wxFrame
* pFrame
= wxDynamicCast(pGrandParent
, wxFrame
);
4090 wxStatusBar
* pStatbar
= pFrame
->GetStatusBar();
4092 nParentHeight
= pGrandParent
->GetClientSize().y
;
4094 nStatusBarHeight
= pStatbar
->GetSize().y
;
4095 nParentHeight
-= nStatusBarHeight
;
4096 return(nParentHeight
);
4100 // Panel is a child of some other kind of window so we'll
4101 // just use it's original size
4103 return(pParent
->GetClientSize().y
);
4106 } // end of wxWindowOS2::GetOS2ParentHeight
4108 wxWindowCreationHook::wxWindowCreationHook(
4109 wxWindow
* pWinBeingCreated
4112 gpWinBeingCreated
= pWinBeingCreated
;
4113 } // end of wxWindowCreationHook::wxWindowCreationHook
4115 wxWindowCreationHook::~wxWindowCreationHook()
4117 gpWinBeingCreated
= NULL
;
4118 } // end of wxWindowCreationHook::~wxWindowCreationHook
4120 // ===========================================================================
4122 // ===========================================================================
4128 ,wxFont
* WXUNUSED(pTheFont
)
4135 hPS
=::WinGetPS(hWnd
);
4137 rc
= ::GpiQueryFontMetrics(hPS
, sizeof(FONTMETRICS
), &vFM
);
4141 *pX
= vFM
.lAveCharWidth
;
4143 *pY
= vFM
.lEmHeight
+ vFM
.lExternalLeading
;
4152 ::WinReleasePS(hPS
);
4153 } // end of wxGetCharSize
4156 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
4157 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
4159 int wxCharCodeOS2ToWX(
4167 case VK_BACKTAB
: nId
= WXK_BACK
; break;
4168 case VK_TAB
: nId
= WXK_TAB
; break;
4169 case VK_CLEAR
: nId
= WXK_CLEAR
; break;
4170 case VK_ENTER
: nId
= WXK_RETURN
; break;
4171 case VK_SHIFT
: nId
= WXK_SHIFT
; break;
4172 case VK_CTRL
: nId
= WXK_CONTROL
; break;
4173 case VK_PAUSE
: nId
= WXK_PAUSE
; break;
4174 case VK_SPACE
: nId
= WXK_SPACE
; break;
4175 case VK_ESC
: nId
= WXK_ESCAPE
; break;
4176 case VK_END
: nId
= WXK_END
; break;
4177 case VK_HOME
: nId
= WXK_HOME
; break;
4178 case VK_LEFT
: nId
= WXK_LEFT
; break;
4179 case VK_UP
: nId
= WXK_UP
; break;
4180 case VK_RIGHT
: nId
= WXK_RIGHT
; break;
4181 case VK_DOWN
: nId
= WXK_DOWN
; break;
4182 case VK_PRINTSCRN
: nId
= WXK_PRINT
; break;
4183 case VK_INSERT
: nId
= WXK_INSERT
; break;
4184 case VK_DELETE
: nId
= WXK_DELETE
; break;
4185 case VK_F1
: nId
= WXK_F1
; break;
4186 case VK_F2
: nId
= WXK_F2
; break;
4187 case VK_F3
: nId
= WXK_F3
; break;
4188 case VK_F4
: nId
= WXK_F4
; break;
4189 case VK_F5
: nId
= WXK_F5
; break;
4190 case VK_F6
: nId
= WXK_F6
; break;
4191 case VK_F7
: nId
= WXK_F7
; break;
4192 case VK_F8
: nId
= WXK_F8
; break;
4193 case VK_F9
: nId
= WXK_F9
; break;
4194 case VK_F10
: nId
= WXK_F10
; break;
4195 case VK_F11
: nId
= WXK_F11
; break;
4196 case VK_F12
: nId
= WXK_F12
; break;
4197 case VK_F13
: nId
= WXK_F13
; break;
4198 case VK_F14
: nId
= WXK_F14
; break;
4199 case VK_F15
: nId
= WXK_F15
; break;
4200 case VK_F16
: nId
= WXK_F16
; break;
4201 case VK_F17
: nId
= WXK_F17
; break;
4202 case VK_F18
: nId
= WXK_F18
; break;
4203 case VK_F19
: nId
= WXK_F19
; break;
4204 case VK_F20
: nId
= WXK_F20
; break;
4205 case VK_F21
: nId
= WXK_F21
; break;
4206 case VK_F22
: nId
= WXK_F22
; break;
4207 case VK_F23
: nId
= WXK_F23
; break;
4208 case VK_F24
: nId
= WXK_F24
; break;
4209 case VK_NUMLOCK
: nId
= WXK_NUMLOCK
; break;
4210 case VK_SCRLLOCK
: nId
= WXK_SCROLL
; break;
4217 } // end of wxCharCodeOS2ToWX
4219 int wxCharCodeWXToOS2(
4229 case WXK_CLEAR
: nKeySym
= VK_CLEAR
; break;
4230 case WXK_SHIFT
: nKeySym
= VK_SHIFT
; break;
4231 case WXK_CONTROL
: nKeySym
= VK_CTRL
; break;
4232 case WXK_PAUSE
: nKeySym
= VK_PAUSE
; break;
4233 case WXK_END
: nKeySym
= VK_END
; break;
4234 case WXK_HOME
: nKeySym
= VK_HOME
; break;
4235 case WXK_LEFT
: nKeySym
= VK_LEFT
; break;
4236 case WXK_UP
: nKeySym
= VK_UP
; break;
4237 case WXK_RIGHT
: nKeySym
= VK_RIGHT
; break;
4238 case WXK_DOWN
: nKeySym
= VK_DOWN
; break;
4239 case WXK_PRINT
: nKeySym
= VK_PRINTSCRN
; break;
4240 case WXK_INSERT
: nKeySym
= VK_INSERT
; break;
4241 case WXK_DELETE
: nKeySym
= VK_DELETE
; break;
4242 case WXK_F1
: nKeySym
= VK_F1
; break;
4243 case WXK_F2
: nKeySym
= VK_F2
; break;
4244 case WXK_F3
: nKeySym
= VK_F3
; break;
4245 case WXK_F4
: nKeySym
= VK_F4
; break;
4246 case WXK_F5
: nKeySym
= VK_F5
; break;
4247 case WXK_F6
: nKeySym
= VK_F6
; break;
4248 case WXK_F7
: nKeySym
= VK_F7
; break;
4249 case WXK_F8
: nKeySym
= VK_F8
; break;
4250 case WXK_F9
: nKeySym
= VK_F9
; break;
4251 case WXK_F10
: nKeySym
= VK_F10
; break;
4252 case WXK_F11
: nKeySym
= VK_F11
; break;
4253 case WXK_F12
: nKeySym
= VK_F12
; break;
4254 case WXK_F13
: nKeySym
= VK_F13
; break;
4255 case WXK_F14
: nKeySym
= VK_F14
; break;
4256 case WXK_F15
: nKeySym
= VK_F15
; break;
4257 case WXK_F16
: nKeySym
= VK_F16
; break;
4258 case WXK_F17
: nKeySym
= VK_F17
; break;
4259 case WXK_F18
: nKeySym
= VK_F18
; break;
4260 case WXK_F19
: nKeySym
= VK_F19
; break;
4261 case WXK_F20
: nKeySym
= VK_F20
; break;
4262 case WXK_F21
: nKeySym
= VK_F21
; break;
4263 case WXK_F22
: nKeySym
= VK_F22
; break;
4264 case WXK_F23
: nKeySym
= VK_F23
; break;
4265 case WXK_F24
: nKeySym
= VK_F24
; break;
4266 case WXK_NUMLOCK
: nKeySym
= VK_NUMLOCK
; break;
4267 case WXK_SCROLL
: nKeySym
= VK_SCRLLOCK
; break;
4270 *bIsVirtual
= FALSE
;
4276 } // end of wxCharCodeWXToOS2
4278 wxWindow
* wxGetActiveWindow()
4280 HWND hWnd
= ::WinQueryActiveWindow(HWND_DESKTOP
);
4284 return wxFindWinFromHandle((WXHWND
)hWnd
);
4287 } // end of wxGetActiveWindow
4290 const char* wxGetMessageName(
4295 case 0x0000: return "WM_NULL";
4296 case 0x0001: return "WM_CREATE";
4297 case 0x0002: return "WM_DESTROY";
4298 case 0x0004: return "WM_ENABLE";
4299 case 0x0005: return "WM_SHOW";
4300 case 0x0006: return "WM_MOVE";
4301 case 0x0007: return "WM_SIZE";
4302 case 0x0008: return "WM_ADJUSTWINDOWPOS";
4303 case 0x0009: return "WM_CALCVALIDRECTS";
4304 case 0x000A: return "WM_SETWINDOWPARAMS";
4305 case 0x000B: return "WM_QUERYWINDOWPARAMS";
4306 case 0x000C: return "WM_HITTEST";
4307 case 0x000D: return "WM_ACTIVATE";
4308 case 0x000F: return "WM_SETFOCUS";
4309 case 0x0010: return "WM_SETSELECTION";
4310 case 0x0011: return "WM_PPAINT";
4311 case 0x0012: return "WM_PSETFOCUS";
4312 case 0x0013: return "WM_PSYSCOLORCHANGE";
4313 case 0x0014: return "WM_PSIZE";
4314 case 0x0015: return "WM_PACTIVATE";
4315 case 0x0016: return "WM_PCONTROL";
4316 case 0x0020: return "WM_COMMAND";
4317 case 0x0021: return "WM_SYSCOMMAND";
4318 case 0x0022: return "WM_HELP";
4319 case 0x0023: return "WM_PAINT";
4320 case 0x0024: return "WM_TIMER";
4321 case 0x0025: return "WM_SEM1";
4322 case 0x0026: return "WM_SEM2";
4323 case 0x0027: return "WM_SEM3";
4324 case 0x0028: return "WM_SEM4";
4325 case 0x0029: return "WM_CLOSE";
4326 case 0x002A: return "WM_QUIT";
4327 case 0x002B: return "WM_SYSCOLORCHANGE";
4328 case 0x002D: return "WM_SYSVALUECHANGE";
4329 case 0x002E: return "WM_APPTERMINATENOTIFY";
4330 case 0x002F: return "WM_PRESPARAMCHANGED";
4331 // Control notification messages
4332 case 0x0030: return "WM_CONTROL";
4333 case 0x0031: return "WM_VSCROLL";
4334 case 0x0032: return "WM_HSCROLL";
4335 case 0x0033: return "WM_INITMENU";
4336 case 0x0034: return "WM_MENUSELECT";
4337 case 0x0035: return "WM_MENUSEND";
4338 case 0x0036: return "WM_DRAWITEM";
4339 case 0x0037: return "WM_MEASUREITEM";
4340 case 0x0038: return "WM_CONTROLPOINTER";
4341 case 0x003A: return "WM_QUERYDLGCODE";
4342 case 0x003B: return "WM_INITDLG";
4343 case 0x003C: return "WM_SUBSTITUTESTRING";
4344 case 0x003D: return "WM_MATCHMNEMONIC";
4345 case 0x003E: return "WM_SAVEAPPLICATION";
4346 case 0x0129: return "WM_CTLCOLORCHANGE";
4347 case 0x0130: return "WM_QUERYCTLTYPE";
4349 case 0x0040: return "WM_FLASHWINDOW";
4350 case 0x0041: return "WM_FORMATFRAME";
4351 case 0x0042: return "WM_UPDATEFRAME";
4352 case 0x0043: return "WM_FOCUSCHANGE";
4353 case 0x0044: return "WM_SETBORDERSIZE";
4354 case 0x0045: return "WM_TRACKFRAME";
4355 case 0x0046: return "WM_MINMAXFRAME";
4356 case 0x0047: return "WM_SETICON";
4357 case 0x0048: return "WM_QUERYICON";
4358 case 0x0049: return "WM_SETACCELTABLE";
4359 case 0x004A: return "WM_QUERYACCELTABLE";
4360 case 0x004B: return "WM_TRANSLATEACCEL";
4361 case 0x004C: return "WM_QUERYTRACKINFO";
4362 case 0x004D: return "WM_QUERYBORDERSIZE";
4363 case 0x004E: return "WM_NEXTMENU";
4364 case 0x004F: return "WM_ERASEBACKGROUND";
4365 case 0x0050: return "WM_QUERYFRAMEINFO";
4366 case 0x0051: return "WM_QUERYFOCUSCHAIN";
4367 case 0x0052: return "WM_OWNERPOSCHANGE";
4368 case 0x0053: return "WM_CACLFRAMERECT";
4369 case 0x0055: return "WM_WINDOWPOSCHANGED";
4370 case 0x0056: return "WM_ADJUSTFRAMEPOS";
4371 case 0x0059: return "WM_QUERYFRAMECTLCOUNT";
4372 case 0x005B: return "WM_QUERYHELPINFO";
4373 case 0x005C: return "WM_SETHELPINFO";
4374 case 0x005D: return "WM_ERROR";
4375 case 0x005E: return "WM_REALIZEPALETTE";
4376 // Clipboard messages
4377 case 0x0060: return "WM_RENDERFMT";
4378 case 0x0061: return "WM_RENDERALLFMTS";
4379 case 0x0062: return "WM_DESTROYCLIPBOARD";
4380 case 0x0063: return "WM_PAINTCLIPBOARD";
4381 case 0x0064: return "WM_SIZECLIPBOARD";
4382 case 0x0065: return "WM_HSCROLLCLIPBOARD";
4383 case 0x0066: return "WM_VSCROLLCLIPBOARD";
4384 case 0x0067: return "WM_DRAWCLIPBOARD";
4386 case 0x0070: return "WM_MOUSEMOVE";
4387 case 0x0071: return "WM_BUTTON1DOWN";
4388 case 0x0072: return "WM_BUTTON1UP";
4389 case 0x0073: return "WM_BUTTON1DBLCLK";
4390 case 0x0074: return "WM_BUTTON2DOWN";
4391 case 0x0075: return "WM_BUTTON2UP";
4392 case 0x0076: return "WM_BUTTON2DBLCLK";
4393 case 0x0077: return "WM_BUTTON3DOWN";
4394 case 0x0078: return "WM_BUTTON3UP";
4395 case 0x0079: return "WM_BUTTON3DBLCLK";
4396 case 0x007D: return "WM_MOUSEMAP";
4397 case 0x007E: return "WM_VRNDISABLED";
4398 case 0x007F: return "WM_VRNENABLED";
4399 case 0x0410: return "WM_CHORD";
4400 case 0x0411: return "WM_BUTTON1MOTIONSTART";
4401 case 0x0412: return "WM_BUTTON1MOTIONEND";
4402 case 0x0413: return "WM_BUTTON1CLICK";
4403 case 0x0414: return "WM_BUTTON2MOTIONSTART";
4404 case 0x0415: return "WM_BUTTON2MOTIONEND";
4405 case 0x0416: return "WM_BUTTON2CLICK";
4406 case 0x0417: return "WM_BUTTON3MOTIONSTART";
4407 case 0x0418: return "WM_BUTTON3MOTIONEND";
4408 case 0x0419: return "WM_BUTTON3CLICK";
4409 case 0x0420: return "WM_BEGINDRAG";
4410 case 0x0421: return "WM_ENDDRAG";
4411 case 0x0422: return "WM_SINGLESELECT";
4412 case 0x0423: return "WM_OPEN";
4413 case 0x0424: return "WM_CONTEXTMENU";
4414 case 0x0425: return "WM_CONTEXTHELP";
4415 case 0x0426: return "WM_TEXTEDIT";
4416 case 0x0427: return "WM_BEGINSELECT";
4417 case 0x0228: return "WM_ENDSELECT";
4418 case 0x0429: return "WM_PICKUP";
4419 case 0x04C0: return "WM_PENFIRST";
4420 case 0x04FF: return "WM_PENLAST";
4421 case 0x0500: return "WM_MMPMFIRST";
4422 case 0x05FF: return "WM_MMPMLAST";
4423 case 0x0600: return "WM_STDDLGFIRST";
4424 case 0x06FF: return "WM_STDDLGLAST";
4425 case 0x0BD0: return "WM_BIDI_FIRST";
4426 case 0x0BFF: return "WM_BIDI_LAST";
4428 case 0x007A: return "WM_CHAR";
4429 case 0x007B: return "WM_VIOCHAR";
4431 case 0x00A0: return "WM_DDE_INITIATE";
4432 case 0x00A1: return "WM_DDE_REQUEST";
4433 case 0x00A2: return "WM_DDE_ACK";
4434 case 0x00A3: return "WM_DDE_DATA";
4435 case 0x00A4: return "WM_DDE_ADVISE";
4436 case 0x00A5: return "WM_DDE_UNADVISE";
4437 case 0x00A6: return "WM_DDE_POKE";
4438 case 0x00A7: return "WM_DDE_EXECUTE";
4439 case 0x00A8: return "WM_DDE_TERMINATE";
4440 case 0x00A9: return "WM_DDE_INITIATEACK";
4441 case 0x00AF: return "WM_DDE_LAST";
4443 case 0x0120: return "BM_CLICK";
4444 case 0x0121: return "BM_QUERYCHECKINDEX";
4445 case 0x0122: return "BM_QUERYHILITE";
4446 case 0x0123: return "BM_SETHILITE";
4447 case 0x0124: return "BM_QUERYCHECK";
4448 case 0x0125: return "BM_SETCHECK";
4449 case 0x0126: return "BM_SETDEFAULT";
4450 case 0x0128: return "BM_AUTOSIZE";
4452 case 0x029A: return "CBID_LIST";
4453 case 0x029B: return "CBID_EDIT";
4454 case 0x0170: return "CBM_SHOWLIST";
4455 case 0x0171: return "CBM_HILITE";
4456 case 0x0172: return "CBM_ISLISTSHOWING";
4458 case 0x0140: return "EM_QUERYCHANGED";
4459 case 0x0141: return "EM_QUERYSEL";
4460 case 0x0142: return "EM_SETSEL";
4461 case 0x0143: return "EM_SETTEXTLIMIT";
4462 case 0x0144: return "EM_CUT";
4463 case 0x0145: return "EM_COPY";
4464 case 0x0146: return "EM_CLEAR";
4465 case 0x0147: return "EM_PASTE";
4466 case 0x0148: return "EM_QUERYFIRSTCHAR";
4467 case 0x0149: return "EM_SETFIRSTCHAR";
4468 case 0x014A: return "EM_QUERYREADONLY";
4469 case 0x014B: return "EM_SETREADONLY";
4470 case 0x014C: return "EM_SETINSERTMODE";
4472 case 0x0160: return "LM_QUERYITEMCOUNT";
4473 case 0x0161: return "LM_INSERTITEM";
4474 case 0x0162: return "LM_SETOPENINDEX";
4475 case 0x0163: return "LM_DELETEITEM";
4476 case 0x0164: return "LM_SELECTITEM";
4477 case 0x0165: return "LM_QUERYSELECTION";
4478 case 0x0166: return "LM_SETITEMTEXT";
4479 case 0x0167: return "LM_QUERYITEMTEXTLENGTH";
4480 case 0x0168: return "LM_QUERYITEMTEXT";
4481 case 0x0169: return "LM_SETITEMHANDLE";
4482 case 0x016A: return "LM_QUERYITEMHANDLE";
4483 case 0x016B: return "LM_SEARCHSTRING";
4484 case 0x016C: return "LM_SETITEMHEIGHT";
4485 case 0x016D: return "LM_QUERYTOPINDEX";
4486 case 0x016E: return "LM_DELETEALL";
4487 case 0x016F: return "LM_INSERTMULITEMS";
4488 case 0x0660: return "LM_SETITEMWIDTH";
4490 case 0x0180: return "MM_INSERTITEM";
4491 case 0x0181: return "MM_DELETEITEM";
4492 case 0x0182: return "MM_QUERYITEM";
4493 case 0x0183: return "MM_SETITEM";
4494 case 0x0184: return "MM_QUERYITEMCOUNT";
4495 case 0x0185: return "MM_STARTMENUMODE";
4496 case 0x0186: return "MM_ENDMENUMODE";
4497 case 0x0188: return "MM_REMOVEITEM";
4498 case 0x0189: return "MM_SELECTITEM";
4499 case 0x018A: return "MM_QUERYSELITEMID";
4500 case 0x018B: return "MM_QUERYITEMTEXT";
4501 case 0x018C: return "MM_QUERYITEMTEXTLENGTH";
4502 case 0x018D: return "MM_SETITEMHANDLE";
4503 case 0x018E: return "MM_SETITEMTEXT";
4504 case 0x018F: return "MM_ITEMPOSITIONFROMID";
4505 case 0x0190: return "MM_ITEMIDFROMPOSITION";
4506 case 0x0191: return "MM_QUERYITEMATTR";
4507 case 0x0192: return "MM_SETITEMATTR";
4508 case 0x0193: return "MM_ISITEMVALID";
4509 case 0x0194: return "MM_QUERYITEMRECT";
4510 case 0x0431: return "MM_QUERYDEFAULTITEMID";
4511 case 0x0432: return "MM_SETDEFAULTITEMID";
4513 case 0x01A0: return "SBM_SETSCROLLBAR";
4514 case 0x01A1: return "SBM_SETPOS";
4515 case 0x01A2: return "SBM_QUERYPOS";
4516 case 0x01A3: return "SBM_QUERYRANGE";
4517 case 0x01A6: return "SBM_SETTHUMBSIZE";
4520 case 0x0F00: return "WM_HELPBASE";
4521 case 0x0FFF: return "WM_HELPTOP";
4522 // Beginning of user defined messages
4523 case 0x1000: return "WM_USER";
4525 // wxWindows user defined types
4528 // case 0x1000 + 0: return "LVM_GETBKCOLOR";
4529 case 0x1000 + 1: return "LVM_SETBKCOLOR";
4530 case 0x1000 + 2: return "LVM_GETIMAGELIST";
4531 case 0x1000 + 3: return "LVM_SETIMAGELIST";
4532 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
4533 case 0x1000 + 5: return "LVM_GETITEMA";
4534 case 0x1000 + 75: return "LVM_GETITEMW";
4535 case 0x1000 + 6: return "LVM_SETITEMA";
4536 case 0x1000 + 76: return "LVM_SETITEMW";
4537 case 0x1000 + 7: return "LVM_INSERTITEMA";
4538 case 0x1000 + 77: return "LVM_INSERTITEMW";
4539 case 0x1000 + 8: return "LVM_DELETEITEM";
4540 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
4541 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
4542 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
4543 case 0x1000 + 12: return "LVM_GETNEXTITEM";
4544 case 0x1000 + 13: return "LVM_FINDITEMA";
4545 case 0x1000 + 83: return "LVM_FINDITEMW";
4546 case 0x1000 + 14: return "LVM_GETITEMRECT";
4547 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
4548 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
4549 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
4550 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
4551 case 0x1000 + 18: return "LVM_HITTEST";
4552 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
4553 case 0x1000 + 20: return "LVM_SCROLL";
4554 case 0x1000 + 21: return "LVM_REDRAWITEMS";
4555 case 0x1000 + 22: return "LVM_ARRANGE";
4556 case 0x1000 + 23: return "LVM_EDITLABELA";
4557 case 0x1000 + 118: return "LVM_EDITLABELW";
4558 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
4559 case 0x1000 + 25: return "LVM_GETCOLUMNA";
4560 case 0x1000 + 95: return "LVM_GETCOLUMNW";
4561 case 0x1000 + 26: return "LVM_SETCOLUMNA";
4562 case 0x1000 + 96: return "LVM_SETCOLUMNW";
4563 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
4564 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
4565 case 0x1000 + 28: return "LVM_DELETECOLUMN";
4566 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
4567 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
4568 case 0x1000 + 31: return "LVM_GETHEADER";
4569 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
4570 case 0x1000 + 34: return "LVM_GETVIEWRECT";
4571 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
4572 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
4573 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
4574 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
4575 case 0x1000 + 39: return "LVM_GETTOPINDEX";
4576 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
4577 case 0x1000 + 41: return "LVM_GETORIGIN";
4578 case 0x1000 + 42: return "LVM_UPDATE";
4579 case 0x1000 + 43: return "LVM_SETITEMSTATE";
4580 case 0x1000 + 44: return "LVM_GETITEMSTATE";
4581 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
4582 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
4583 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
4584 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
4585 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
4586 case 0x1000 + 48: return "LVM_SORTITEMS";
4587 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
4588 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
4589 case 0x1000 + 51: return "LVM_GETITEMSPACING";
4590 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
4591 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
4592 case 0x1000 + 53: return "LVM_SETICONSPACING";
4593 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
4594 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
4595 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
4596 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
4597 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
4598 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
4599 case 0x1000 + 60: return "LVM_SETHOTITEM";
4600 case 0x1000 + 61: return "LVM_GETHOTITEM";
4601 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
4602 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
4603 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
4604 case 0x1000 + 65: return "LVM_SETWORKAREA";
4607 case 0x1100 + 0: return "TVM_INSERTITEMA";
4608 case 0x1100 + 50: return "TVM_INSERTITEMW";
4609 case 0x1100 + 1: return "TVM_DELETEITEM";
4610 case 0x1100 + 2: return "TVM_EXPAND";
4611 case 0x1100 + 4: return "TVM_GETITEMRECT";
4612 case 0x1100 + 5: return "TVM_GETCOUNT";
4613 case 0x1100 + 6: return "TVM_GETINDENT";
4614 case 0x1100 + 7: return "TVM_SETINDENT";
4615 case 0x1100 + 8: return "TVM_GETIMAGELIST";
4616 case 0x1100 + 9: return "TVM_SETIMAGELIST";
4617 case 0x1100 + 10: return "TVM_GETNEXTITEM";
4618 case 0x1100 + 11: return "TVM_SELECTITEM";
4619 case 0x1100 + 12: return "TVM_GETITEMA";
4620 case 0x1100 + 62: return "TVM_GETITEMW";
4621 case 0x1100 + 13: return "TVM_SETITEMA";
4622 case 0x1100 + 63: return "TVM_SETITEMW";
4623 case 0x1100 + 14: return "TVM_EDITLABELA";
4624 case 0x1100 + 65: return "TVM_EDITLABELW";
4625 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
4626 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
4627 case 0x1100 + 17: return "TVM_HITTEST";
4628 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
4629 case 0x1100 + 19: return "TVM_SORTCHILDREN";
4630 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
4631 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
4632 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
4633 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
4634 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
4635 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
4636 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
4639 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
4640 case 0x1200 + 1: return "HDM_INSERTITEMA";
4641 case 0x1200 + 10: return "HDM_INSERTITEMW";
4642 case 0x1200 + 2: return "HDM_DELETEITEM";
4643 case 0x1200 + 3: return "HDM_GETITEMA";
4644 case 0x1200 + 11: return "HDM_GETITEMW";
4645 case 0x1200 + 4: return "HDM_SETITEMA";
4646 case 0x1200 + 12: return "HDM_SETITEMW";
4647 case 0x1200 + 5: return "HDM_LAYOUT";
4648 case 0x1200 + 6: return "HDM_HITTEST";
4649 case 0x1200 + 7: return "HDM_GETITEMRECT";
4650 case 0x1200 + 8: return "HDM_SETIMAGELIST";
4651 case 0x1200 + 9: return "HDM_GETIMAGELIST";
4652 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
4653 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
4654 case 0x1200 + 17: return "HDM_GETORDERARRAY";
4655 case 0x1200 + 18: return "HDM_SETORDERARRAY";
4656 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
4659 case 0x1300 + 2: return "TCM_GETIMAGELIST";
4660 case 0x1300 + 3: return "TCM_SETIMAGELIST";
4661 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
4662 case 0x1300 + 5: return "TCM_GETITEMA";
4663 case 0x1300 + 60: return "TCM_GETITEMW";
4664 case 0x1300 + 6: return "TCM_SETITEMA";
4665 case 0x1300 + 61: return "TCM_SETITEMW";
4666 case 0x1300 + 7: return "TCM_INSERTITEMA";
4667 case 0x1300 + 62: return "TCM_INSERTITEMW";
4668 case 0x1300 + 8: return "TCM_DELETEITEM";
4669 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
4670 case 0x1300 + 10: return "TCM_GETITEMRECT";
4671 case 0x1300 + 11: return "TCM_GETCURSEL";
4672 case 0x1300 + 12: return "TCM_SETCURSEL";
4673 case 0x1300 + 13: return "TCM_HITTEST";
4674 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
4675 case 0x1300 + 40: return "TCM_ADJUSTRECT";
4676 case 0x1300 + 41: return "TCM_SETITEMSIZE";
4677 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
4678 case 0x1300 + 43: return "TCM_SETPADDING";
4679 case 0x1300 + 44: return "TCM_GETROWCOUNT";
4680 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
4681 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
4682 case 0x1300 + 47: return "TCM_GETCURFOCUS";
4683 case 0x1300 + 48: return "TCM_SETCURFOCUS";
4684 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
4685 case 0x1300 + 50: return "TCM_DESELECTALL";
4688 case WM_USER
+1000+1: return "TB_ENABLEBUTTON";
4689 case WM_USER
+1000+2: return "TB_CHECKBUTTON";
4690 case WM_USER
+1000+3: return "TB_PRESSBUTTON";
4691 case WM_USER
+1000+4: return "TB_HIDEBUTTON";
4692 case WM_USER
+1000+5: return "TB_INDETERMINATE";
4693 case WM_USER
+1000+9: return "TB_ISBUTTONENABLED";
4694 case WM_USER
+1000+10: return "TB_ISBUTTONCHECKED";
4695 case WM_USER
+1000+11: return "TB_ISBUTTONPRESSED";
4696 case WM_USER
+1000+12: return "TB_ISBUTTONHIDDEN";
4697 case WM_USER
+1000+13: return "TB_ISBUTTONINDETERMINATE";
4698 case WM_USER
+1000+17: return "TB_SETSTATE";
4699 case WM_USER
+1000+18: return "TB_GETSTATE";
4700 case WM_USER
+1000+19: return "TB_ADDBITMAP";
4701 case WM_USER
+1000+20: return "TB_ADDBUTTONS";
4702 case WM_USER
+1000+21: return "TB_INSERTBUTTON";
4703 case WM_USER
+1000+22: return "TB_DELETEBUTTON";
4704 case WM_USER
+1000+23: return "TB_GETBUTTON";
4705 case WM_USER
+1000+24: return "TB_BUTTONCOUNT";
4706 case WM_USER
+1000+25: return "TB_COMMANDTOINDEX";
4707 case WM_USER
+1000+26: return "TB_SAVERESTOREA";
4708 case WM_USER
+1000+76: return "TB_SAVERESTOREW";
4709 case WM_USER
+1000+27: return "TB_CUSTOMIZE";
4710 case WM_USER
+1000+28: return "TB_ADDSTRINGA";
4711 case WM_USER
+1000+77: return "TB_ADDSTRINGW";
4712 case WM_USER
+1000+29: return "TB_GETITEMRECT";
4713 case WM_USER
+1000+30: return "TB_BUTTONSTRUCTSIZE";
4714 case WM_USER
+1000+31: return "TB_SETBUTTONSIZE";
4715 case WM_USER
+1000+32: return "TB_SETBITMAPSIZE";
4716 case WM_USER
+1000+33: return "TB_AUTOSIZE";
4717 case WM_USER
+1000+35: return "TB_GETTOOLTIPS";
4718 case WM_USER
+1000+36: return "TB_SETTOOLTIPS";
4719 case WM_USER
+1000+37: return "TB_SETPARENT";
4720 case WM_USER
+1000+39: return "TB_SETROWS";
4721 case WM_USER
+1000+40: return "TB_GETROWS";
4722 case WM_USER
+1000+42: return "TB_SETCMDID";
4723 case WM_USER
+1000+43: return "TB_CHANGEBITMAP";
4724 case WM_USER
+1000+44: return "TB_GETBITMAP";
4725 case WM_USER
+1000+45: return "TB_GETBUTTONTEXTA";
4726 case WM_USER
+1000+75: return "TB_GETBUTTONTEXTW";
4727 case WM_USER
+1000+46: return "TB_REPLACEBITMAP";
4728 case WM_USER
+1000+47: return "TB_SETINDENT";
4729 case WM_USER
+1000+48: return "TB_SETIMAGELIST";
4730 case WM_USER
+1000+49: return "TB_GETIMAGELIST";
4731 case WM_USER
+1000+50: return "TB_LOADIMAGES";
4732 case WM_USER
+1000+51: return "TB_GETRECT";
4733 case WM_USER
+1000+52: return "TB_SETHOTIMAGELIST";
4734 case WM_USER
+1000+53: return "TB_GETHOTIMAGELIST";
4735 case WM_USER
+1000+54: return "TB_SETDISABLEDIMAGELIST";
4736 case WM_USER
+1000+55: return "TB_GETDISABLEDIMAGELIST";
4737 case WM_USER
+1000+56: return "TB_SETSTYLE";
4738 case WM_USER
+1000+57: return "TB_GETSTYLE";
4739 case WM_USER
+1000+58: return "TB_GETBUTTONSIZE";
4740 case WM_USER
+1000+59: return "TB_SETBUTTONWIDTH";
4741 case WM_USER
+1000+60: return "TB_SETMAXTEXTROWS";
4742 case WM_USER
+1000+61: return "TB_GETTEXTROWS";
4743 case WM_USER
+1000+41: return "TB_GETBITMAPFLAGS";
4746 static char s_szBuf
[128];
4747 sprintf(s_szBuf
, "<unknown message = %d>", nMessage
);
4751 } // end of wxGetMessageName
4753 #endif // __WXDEBUG__
4757 static void TranslateKbdEventToMouse(
4765 // Construct the key mask
4766 ULONG
& fwKeys
= *pFlags
;
4768 fwKeys
= VK_BUTTON2
;
4769 if ((::WinGetKeyState(HWND_DESKTOP
, VK_CTRL
) & 0x100) != 0)
4771 if ((::WinGetKeyState(HWND_DESKTOP
, VK_SHIFT
) & 0x100) != 0)
4775 // Simulate right mouse button click
4779 ::WinQueryMsgPos(vHabmain
, &vPoint
);
4783 pWin
->ScreenToClient(pX
, pY
);
4784 } // end of TranslateKbdEventToMouse
4787 // Find the wxWindow at the current mouse position, returning the mouse
4789 wxWindow
* wxFindWindowAtPointer(
4790 wxPoint
& WXUNUSED(rPt
)
4793 return wxFindWindowAtPoint(wxGetMousePosition());
4796 wxWindow
* wxFindWindowAtPoint(
4805 HWND hWndHit
= ::WinWindowFromPoint(HWND_DESKTOP
, &vPt2
, FALSE
);
4806 wxWindow
* pWin
= wxFindWinFromHandle((WXHWND
)hWndHit
) ;
4807 HWND hWnd
= hWndHit
;
4810 // Try to find a window with a wxWindow associated with it
4812 while (!pWin
&& (hWnd
!= 0))
4814 hWnd
= ::WinQueryWindow(hWnd
, QW_PARENT
);
4815 pWin
= wxFindWinFromHandle((WXHWND
)hWnd
) ;
4820 // Get the current mouse position.
4821 wxPoint
wxGetMousePosition()
4825 ::WinQueryPointerPos(HWND_DESKTOP
, &vPt
);
4826 return wxPoint(vPt
.x
, vPt
.y
);