3 // Author: David Webster
7 // Copyright: (c) David Webster
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
14 #include "wx/wxprec.h"
20 #include "wx/window.h"
25 #include "wx/dcclient.h"
29 #include "wx/layout.h"
30 #include "wx/dialog.h"
32 #include "wx/listbox.h"
33 #include "wx/button.h"
34 #include "wx/msgdlg.h"
35 #include "wx/scrolwin.h"
36 #include "wx/radiobox.h"
37 #include "wx/slider.h"
38 #include "wx/statusbr.h"
39 #include "wx/toolbar.h"
40 #include "wx/settings.h"
45 #include "wx/ownerdrw.h"
48 #if wxUSE_DRAG_AND_DROP
52 #include "wx/menuitem.h"
55 #include "wx/os2/private.h"
58 #include "wx/tooltip.h"
69 #include "wx/textctrl.h"
74 // Place compiler, OS specific includes here
78 // Standard macros -- these are for OS/2 PM, but most GUI's have something similar
82 // SHORT1FROMMP -- LOWORD
84 #define GET_X_LPARAM(mp) ((unsigned short)(unsigned long)(mp))
86 // SHORT2FROMMP -- HIWORD
88 #define GET_Y_LPARAM(mp) ((unsigned short)(unsigned long)(mp >> 16))
89 #endif // GET_X_LPARAM
92 # define CW_USEDEFAULT ((int)0x80000000)
95 // ---------------------------------------------------------------------------
97 // ---------------------------------------------------------------------------
100 // The last PM message we got (MT-UNSAFE)
104 #if wxUSE_MENUS_NATIVE
105 wxMenu
* wxCurrentPopupMenu
= NULL
;
106 #endif // wxUSE_MENUS_NATIVE
108 wxList
* wxWinHandleList
= NULL
;
110 // ---------------------------------------------------------------------------
112 // ---------------------------------------------------------------------------
115 // the window proc for all our windows; most gui's have something similar
117 MRESULT EXPENTRY
wxWndProc( HWND hWnd
124 const char *wxGetMessageName(int message
);
127 void wxRemoveHandleAssociation(wxWindowOS2
* pWin
);
128 void wxAssociateWinWithHandle( HWND hWnd
131 wxWindow
* wxFindWinFromHandle(WXHWND hWnd
);
134 // This magical function is used to translate VK_APPS key presses to right
139 static void TranslateKbdEventToMouse( wxWindow
* pWin
146 // get the current state of SHIFT/CTRL keys
148 static inline bool IsShiftDown() { return (::WinGetKeyState(HWND_DESKTOP
, VK_SHIFT
) & 0x8000) != 0; }
149 static inline bool IsCtrlDown() { return (::WinGetKeyState(HWND_DESKTOP
, VK_CTRL
) & 0x8000) != 0; }
151 static wxWindow
* gpWinBeingCreated
= NULL
;
153 // ---------------------------------------------------------------------------
155 // ---------------------------------------------------------------------------
157 // in wxUniv-OS/2 this class is abstract because it doesn't have DoPopupMenu()
159 #ifdef __WXUNIVERSAL__
160 IMPLEMENT_ABSTRACT_CLASS(wxWindowOS2
, wxWindowBase
)
162 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
)
163 #endif // __WXUNIVERSAL__/__WXPM__
165 BEGIN_EVENT_TABLE(wxWindowOS2
, wxWindowBase
)
166 EVT_ERASE_BACKGROUND(wxWindowOS2::OnEraseBackground
)
167 EVT_SYS_COLOUR_CHANGED(wxWindowOS2::OnSysColourChanged
)
168 EVT_INIT_DIALOG(wxWindowOS2::OnInitDialog
)
169 EVT_IDLE(wxWindowOS2::OnIdle
)
170 EVT_SET_FOCUS(wxWindowOS2::OnSetFocus
)
173 // ===========================================================================
175 // ===========================================================================
177 // ---------------------------------------------------------------------------
178 // wxWindow utility functions
179 // ---------------------------------------------------------------------------
182 // Find an item given the PM Window id
184 wxWindow
* wxWindowOS2::FindItem(
189 wxControl
* pItem
= wxDynamicCast(this, wxControl
);
194 // I it we or one of our "internal" children?
196 if (pItem
->GetId() == lId
197 #ifndef __WXUNIVERSAL__
198 || (pItem
->GetSubcontrols().Index(lId
) != wxNOT_FOUND
)
205 #endif // wxUSE_CONTROLS
207 wxWindowList::Node
* pCurrent
= GetChildren().GetFirst();
211 wxWindow
* pChildWin
= pCurrent
->GetData();
212 wxWindow
* pWnd
= pChildWin
->FindItem(lId
);
217 pCurrent
= pCurrent
->GetNext();
220 } // end of wxWindowOS2::FindItem
223 // Find an item given the PM Window handle
225 wxWindow
* wxWindowOS2::FindItemByHWND(
230 wxWindowList::Node
* pCurrent
= GetChildren().GetFirst();
234 wxWindow
* pParent
= pCurrent
->GetData();
237 // Do a recursive search.
239 wxWindow
* pWnd
= pParent
->FindItemByHWND(hWnd
);
246 || pParent
->IsKindOf(CLASSINFO(wxControl
))
247 #endif // wxUSE_CONTROLS
250 wxWindow
* pItem
= pCurrent
->GetData();
252 if (pItem
->GetHWND() == hWnd
)
256 if (pItem
->ContainsHWND(hWnd
))
260 pCurrent
= pCurrent
->GetNext();
263 } // end of wxWindowOS2::FindItemByHWND
266 // Default command handler
268 bool wxWindowOS2::OS2Command(
269 WXUINT
WXUNUSED(uParam
)
270 , WXWORD
WXUNUSED(uId
)
276 // ----------------------------------------------------------------------------
277 // constructors and such
278 // ----------------------------------------------------------------------------
280 void wxWindowOS2::Init()
290 m_bDoubleClickAllowed
= 0;
291 m_bWinCaptured
= FALSE
;
293 m_isBeingDeleted
= FALSE
;
296 m_bMouseInWindow
= FALSE
;
303 m_hWndScrollBarHorz
= 0L;
304 m_hWndScrollBarVert
= 0L;
307 // Pass WM_GETDLGCODE to DefWindowProc()
312 m_bBackgroundTransparent
= FALSE
;
315 // As all windows are created with WS_VISIBLE style...
319 #if wxUSE_MOUSEEVENT_HACK
322 m_nLastMouseEvent
= -1;
323 #endif // wxUSE_MOUSEEVENT_HACK
324 } // wxWindowOS2::Init
329 wxWindowOS2::~wxWindowOS2()
331 m_isBeingDeleted
= TRUE
;
333 for (wxWindow
* pWin
= GetParent(); pWin
; pWin
= pWin
->GetParent())
335 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
339 if (pFrame
->GetLastFocus() == this)
340 pFrame
->SetLastFocus((wxWindow
*)NULL
);
347 m_parent
->RemoveChild(this);
351 if(!::WinDestroyWindow(GetHWND()))
352 wxLogLastError(wxT("DestroyWindow"));
354 // remove hWnd <-> wxWindow association
356 wxRemoveHandleAssociation(this);
358 } // end of wxWindowOS2::~wxWindowOS2
360 // real construction (Init() must have been called before!)
361 bool wxWindowOS2::Create(
364 , const wxPoint
& rPos
365 , const wxSize
& rSize
367 , const wxString
& rName
370 HWND hParent
= NULLHANDLE
;
371 ULONG ulCreateFlags
= 0;
372 WXDWORD dwExStyle
= 0;
374 wxCHECK_MSG(pParent
, FALSE
, wxT("can't create wxWindow without parent"));
376 if ( !CreateBase( pParent
390 pParent
->AddChild(this);
391 hParent
= GetWinHwnd(pParent
);
393 if ( pParent
->IsKindOf(CLASSINFO(wxGenericScrolledWindow
)) ||
394 pParent
->IsKindOf(CLASSINFO(wxScrolledWindow
))
396 ulCreateFlags
|= WS_CLIPSIBLINGS
;
400 // Most wxSTYLES are really PM Class specific styles and will be
401 // set in those class create procs. PM's basic windows styles are
404 ulCreateFlags
|= WS_VISIBLE
;
407 #ifdef __WXUNIVERSAL__
408 // no 3d effects, we draw them ourselves
410 #else // !wxUniversal
411 if (lStyle
& wxCLIP_SIBLINGS
)
412 ulCreateFlags
|= WS_CLIPSIBLINGS
;
414 if (lStyle
& wxCLIP_CHILDREN
)
415 ulCreateFlags
|= WS_CLIPCHILDREN
;
421 dwExStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &bWant3D
);
426 // Add the simple border style as we'll use this to draw borders
428 if (lStyle
& wxSIMPLE_BORDER
)
429 dwExStyle
|= wxSIMPLE_BORDER
;
431 if (lStyle
& wxPOPUP_WINDOW
)
433 // a popup window floats on top of everything
435 // exStyle |= WS_EX_TOPMOST | WS_EX_TOOLWINDOW;
437 // it is also created hidden as other top level windows
438 ulCreateFlags
&= ~WS_VISIBLE
;
443 // Generic OS/2 Windows have no Control Data but other classes
444 // that call OS2Create may have some.
446 OS2Create( (PSZ
)wxCanvasClassName
451 ,NULL
// Control Data
457 } // end of wxWindowOS2::Create
459 // ---------------------------------------------------------------------------
461 // ---------------------------------------------------------------------------
463 void wxWindowOS2::SetFocus()
465 HWND hWnd
= GetHwnd();
466 wxCHECK_RET( hWnd
, _T("can't set focus to invalid window") );
469 ::WinSetFocus(HWND_DESKTOP
, hWnd
);
470 } // end of wxWindowOS2::SetFocus
472 wxWindow
* wxWindowBase::FindFocus()
474 HWND hWnd
= ::WinQueryFocus(HWND_DESKTOP
);
478 return wxFindWinFromHandle((WXHWND
)hWnd
);
481 } // wxWindowBase::FindFocus
483 bool wxWindowOS2::Enable(
487 if (!wxWindowBase::Enable(bEnable
))
490 HWND hWnd
= GetHwnd();
493 ::WinEnableWindow(hWnd
, (BOOL
)bEnable
);
495 wxWindowList::Node
* pNode
= GetChildren().GetFirst();
499 wxWindow
* pChild
= pNode
->GetData();
501 pChild
->Enable(bEnable
);
502 pNode
= pNode
->GetNext();
505 } // end of wxWindowOS2::Enable
507 bool wxWindowOS2::Show(
511 if (!wxWindowBase::Show(bShow
))
514 HWND hWnd
= GetHwnd();
516 ::WinShowWindow(hWnd
, bShow
);
520 ::WinSetWindowPos(hWnd
, HWND_TOP
, 0, 0, 0, 0, SWP_ACTIVATE
| SWP_ZORDER
);
523 } // end of wxWindowOS2::Show
525 void wxWindowOS2::Raise()
527 ::WinSetWindowPos(GetHwnd(), HWND_TOP
, 0, 0, 0, 0, SWP_ZORDER
| SWP_ACTIVATE
);
528 } // end of wxWindowOS2::Raise
530 void wxWindowOS2::Lower()
532 ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_ZORDER
| SWP_DEACTIVATE
);
533 } // end of wxWindowOS2::Lower
535 void wxWindowOS2::SetTitle(
536 const wxString
& rTitle
539 ::WinSetWindowText(GetHwnd(), rTitle
.c_str());
540 } // end of wxWindowOS2::SetTitle
542 wxString
wxWindowOS2::GetTitle() const
544 return wxGetWindowText(GetHWND());
545 } // end of wxWindowOS2::GetTitle
547 void wxWindowOS2::DoCaptureMouse()
549 HWND hWnd
= GetHwnd();
551 if (hWnd
&& !m_bWinCaptured
)
553 ::WinSetCapture(HWND_DESKTOP
, hWnd
);
554 m_bWinCaptured
= TRUE
;
556 } // end of wxWindowOS2::GetTitle
558 void wxWindowOS2::DoReleaseMouse()
562 ::WinSetCapture(HWND_DESKTOP
, NULLHANDLE
);
563 m_bWinCaptured
= FALSE
;
565 } // end of wxWindowOS2::ReleaseMouse
567 /* static */ wxWindow
* wxWindowBase::GetCapture()
569 HWND hwnd
= ::WinQueryCapture(HWND_DESKTOP
);
570 return hwnd
? wxFindWinFromHandle((WXHWND
)hwnd
) : (wxWindow
*)NULL
;
571 } // end of wxWindowBase::GetCapture
573 bool wxWindowOS2::SetFont(
577 if (!wxWindowBase::SetFont(rFont
))
583 HWND hWnd
= GetHwnd();
589 } // end of wxWindowOS2::SetFont
591 bool wxWindowOS2::SetCursor(
592 const wxCursor
& rCursor
593 ) // check if base implementation is OK
595 if ( !wxWindowBase::SetCursor(rCursor
))
601 if ( m_cursor
.Ok() ) {
602 HWND hWnd
= GetHwnd();
606 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
607 ::WinQueryWindowRect(hWnd
, &vRect
);
609 if (::WinPtInRect(vHabmain
, &vRect
, &vPoint
) && !wxIsBusy())
611 ::WinSetPointer(HWND_DESKTOP
, (HPOINTER
)m_cursor
.GetHCURSOR());
615 } // end of wxWindowOS2::SetCursor
617 void wxWindowOS2::WarpPointer(
626 ::WinQueryWindowRect(GetHwnd(), &vRect
);
630 ::WinSetPointerPos(HWND_DESKTOP
, (LONG
)nX
, (LONG
)(nY
));
631 } // end of wxWindowOS2::WarpPointer
633 #if WXWIN_COMPATIBILITY
634 void wxWindowOS2::OS2DeviceToLogical (float *x
, float *y
) const
637 #endif // WXWIN_COMPATIBILITY
639 // ---------------------------------------------------------------------------
641 // ---------------------------------------------------------------------------
643 #if WXWIN_COMPATIBILITY
644 void wxWindowOS2::SetScrollRange(
650 int nRange1
= nRange
;
651 int nPageSize
= GetScrollPage(nOrient
);
653 if (nPpageSize
> 1 && nRange
> 0)
655 nRange1
+= (nPageSize
- 1);
658 if (nOrient
== wxHORIZONTAL
)
660 ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETSCROLLBAR
, (MPARAM
)0, MPFROM2SHORT(0, (SHORT
)nRange1
));
661 ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETTHUMBSIZE
, MPFROM2SHORT((SHORT
)nThumbVisible
, (SHORT
)nRange1
), (MPARAM
)0);
665 ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETSCROLLBAR
, (MPARAM
)0, MPFROM2SHORT(0, (SHORT
)nRange1
));
666 ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETTHUMBSIZE
, MPFROM2SHORT((SHORT
)nThumbVisible
, (SHORT
)nRange1
), (MPARAM
)0);
668 } // end of wxWindowOS2::SetScrollRange
670 void wxWindowOS2::SetScrollPage(
676 if (nOrient
== wxHORIZONTAL
)
677 m_nXThumbSize
= nPage
;
679 m_nYThumbSize
= nPage
;
680 } // end of wxWindowOS2::SetScrollPage
682 int wxWindowOS2::OldGetScrollRange(
687 HWND hWnd
= GetHwnd();
691 mRc
= WinSendMsg(hWnd
, SBM_QUERYRANGE
, (MPARAM
)0L, (MPARAM
)0L);
692 return(SHORT2FROMMR(mRc
));
695 } // end of wxWindowOS2::OldGetScrollRange
697 int wxWindowOS2::GetScrollPage(
701 if (nOrient
== wxHORIZONTAL
)
702 return m_nXThumbSize
;
704 return m_nYThumbSize
;
705 } // end of wxWindowOS2::GetScrollPage
706 #endif // WXWIN_COMPATIBILITY
708 int wxWindowOS2::GetScrollPos(
712 if (nOrient
== wxHORIZONTAL
)
713 return((int)::WinSendMsg(m_hWndScrollBarHorz
, SBM_QUERYPOS
, (MPARAM
)NULL
, (MPARAM
)NULL
));
715 return((int)::WinSendMsg(m_hWndScrollBarVert
, SBM_QUERYPOS
, (MPARAM
)NULL
, (MPARAM
)NULL
));
716 } // end of wxWindowOS2::GetScrollPos
718 int wxWindowOS2::GetScrollRange(
724 if (nOrient
== wxHORIZONTAL
)
725 mr
= ::WinSendMsg(m_hWndScrollBarHorz
, SBM_QUERYRANGE
, (MPARAM
)NULL
, (MPARAM
)NULL
);
727 mr
= ::WinSendMsg(m_hWndScrollBarVert
, SBM_QUERYRANGE
, (MPARAM
)NULL
, (MPARAM
)NULL
);
728 return((int)SHORT2FROMMR(mr
));
729 } // end of wxWindowOS2::GetScrollRange
731 int wxWindowOS2::GetScrollThumb(
735 if (nOrient
== wxHORIZONTAL
)
736 return m_nXThumbSize
;
738 return m_nYThumbSize
;
739 } // end of wxWindowOS2::GetScrollThumb
741 void wxWindowOS2::SetScrollPos(
744 , bool WXUNUSED(bRefresh
)
747 if (nOrient
== wxHORIZONTAL
)
748 ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETPOS
, (MPARAM
)nPos
, (MPARAM
)NULL
);
750 ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETPOS
, (MPARAM
)nPos
, (MPARAM
)NULL
);
751 } // end of wxWindowOS2::SetScrollPos
753 void wxWindowOS2::SetScrollbar(
758 , bool WXUNUSED(bRefresh
)
761 HWND hWnd
= GetHwnd();
762 int nOldRange
= nRange
- nThumbVisible
;
763 int nRange1
= nOldRange
;
764 int nPageSize
= nThumbVisible
;
767 ULONG ulStyle
= WS_VISIBLE
| WS_SYNCPAINT
;
773 wxWindow
* pParent
= GetParent();
775 if (pParent
&& pParent
->IsKindOf(CLASSINFO(wxFrame
)))
779 pFrame
= wxDynamicCast(pParent
, wxFrame
);
780 hWndParent
= pFrame
->GetFrame();
781 hWndClient
= GetHwndOf(pParent
);
786 hWndParent
= GetHwndOf(pParent
);
788 hWndParent
= GetHwnd();
789 hWndClient
= hWndParent
;
791 ::WinQueryWindowPos(hWndClient
, &vSwp
);
792 ::WinQueryWindowPos(hWnd
, &vSwpOwner
);
794 if (nPageSize
> 1 && nRange
> 0)
796 nRange1
+= (nPageSize
- 1);
799 vInfo
.cb
= sizeof(SBCDATA
);
801 vInfo
.posLast
= (SHORT
)nRange1
;
802 vInfo
.posThumb
= nPos
;
804 if (nOrient
== wxHORIZONTAL
)
807 if (m_hWndScrollBarHorz
== 0L)
810 // Since the scrollbars are usually created before the owner is
811 // sized either via an OnSize event directly or via sizers or
812 // layout constraints, we will initially just use the coords of
813 // the parent window (this is usually a frame client window). But
814 // the bars themselves, are children of the parent frame (i.e
815 // siblings of the frame client. The owner, however is the actual
816 // window being scrolled (or at least the one responsible for
817 // handling the scroll events). The owner will be resized later,
818 // as it is usually a child of a top level window, and when that
819 // is done its scrollbars will be resized and repositioned as well.
821 m_hWndScrollBarHorz
= ::WinCreateWindow( hWndParent
839 // The owner (the scrolled window) is a child of the Frame's
840 // client window, usually. The scrollbars are children of the
841 // frame, itself, and thus are positioned relative to the frame's
842 // origin, not the frame's client window origin.
843 // The starting x position is the same as the starting x position
844 // of the owner, but in terms of the parent frame.
845 // The starting y position is 20 pels below the origin of the
846 // owner in terms of the parent frame.
847 // The horz bar is the same width as the owner and 20 pels high.
849 ::WinSetWindowPos( m_hWndScrollBarHorz
851 ,vSwp
.x
+ vSwpOwner
.x
852 ,(vSwp
.y
+ vSwpOwner
.y
) - 20
855 ,SWP_MOVE
| SWP_SIZE
| SWP_SHOW
| SWP_ACTIVATE
| SWP_ZORDER
857 ::WinSendMsg( m_hWndScrollBarHorz
860 ,MPFROM2SHORT(0, (SHORT
)nRange1
)
862 ::WinSendMsg( m_hWndScrollBarHorz
864 ,MPFROM2SHORT( (SHORT
)nThumbVisible
874 if (m_hWndScrollBarVert
== 0L)
877 // Since the scrollbars are usually created before the owner is
878 // sized either via an OnSize event directly or via sizers or
879 // layout constraints, we will initially just use the coords of
880 // the parent window (this is usually a frame client window). But
881 // the bars themselves, are children of the parent frame (i.e
882 // siblings of the frame client. The owner, however is the actual
883 // window being scrolled (or at least the one responsible for
884 // handling the scroll events). The owner will be resized later,
885 // as it is usually a child of a top level window, and when that
886 // is done its scrollbars will be resized and repositioned as well.
888 m_hWndScrollBarVert
= ::WinCreateWindow( hWndParent
892 ,vSwp
.x
+ vSwp
.cx
- 20
905 ::WinQueryWindowPos(hWnd
, &vSwpOwner
);
907 // The owner (the scrolled window) is a child of the Frame's
908 // client window, usually. The scrollbars are children of the
909 // frame, itself and thus are positioned relative to the frame's
910 // origin, not the frame's client window's origin.
911 // Thus, the x position will be frame client's x (usually a few
912 // pels inside the parent frame, plus the width of the owner.
913 // Since we may be using sizers or layout constraints for multiple
914 // child scrolled windows, the y position will be the frame client's
915 // y pos plus the scrolled windows y position, yielding the y
916 // position of the scrollbar relative to the parent frame (the vert
917 // scrollbar is on the right and starts at the bottom of the
919 // It is 20 pels wide and the same height as the owner.
921 ::WinSetWindowPos( m_hWndScrollBarVert
923 ,vSwp
.x
+ vSwpOwner
.x
+ vSwpOwner
.cx
924 ,vSwp
.y
+ vSwpOwner
.y
927 ,SWP_ACTIVATE
| SWP_MOVE
| SWP_SIZE
| SWP_SHOW
929 ::WinSendMsg( m_hWndScrollBarVert
932 ,MPFROM2SHORT(0, (SHORT
)nRange1
)
934 ::WinSendMsg( m_hWndScrollBarVert
936 ,MPFROM2SHORT( (SHORT
)nThumbVisible
942 m_nYThumbSize
= nThumbVisible
;
944 } // end of wxWindowOS2::SetScrollbar
946 void wxWindowOS2::ScrollWindow(
949 , const wxRect
* pRect
959 vRect
.xLeft
= pRect
->x
;
960 vRect
.yTop
= pRect
->y
+ pRect
->height
;
961 vRect
.xRight
= pRect
->x
+ pRect
->width
;
962 vRect
.yBottom
= pRect
->y
;
966 ::WinQueryWindowRect(GetHwnd(), &vRect
);
968 nDy
*= -1; // flip the sign of Dy as OS/2 is opposite Windows.
969 ::WinScrollWindow( GetHwnd()
976 ,SW_SCROLLCHILDREN
| SW_INVALIDATERGN
978 } // end of wxWindowOS2::ScrollWindow
980 // ---------------------------------------------------------------------------
982 // ---------------------------------------------------------------------------
984 void wxWindowOS2::SubclassWin(
988 HWND hwnd
= (HWND
)hWnd
;
990 wxCHECK_RET(::WinIsWindow(vHabmain
, hwnd
), wxT("invalid HWND in SubclassWin") );
991 wxAssociateWinWithHandle( hWnd
994 if (!wxCheckWindowWndProc( hWnd
995 ,(WXFARPROC
)wxWndProc
998 m_fnOldWndProc
= (WXFARPROC
) ::WinSubclassWindow(hwnd
, (PFNWP
)wxWndProc
);
1002 m_fnOldWndProc
= (WXFARPROC
)NULL
;
1004 } // end of wxWindowOS2::SubclassWin
1006 void wxWindowOS2::UnsubclassWin()
1009 // Restore old Window proc
1011 HWND hwnd
= GetHWND();
1015 wxCHECK_RET( ::WinIsWindow(vHabmain
, hwnd
), wxT("invalid HWND in UnsubclassWin") );
1017 PFNWP fnProc
= (PFNWP
)::WinQueryWindowPtr(hwnd
, QWP_PFNWP
);
1019 if ( (m_fnOldWndProc
!= 0) && (fnProc
!= (PFNWP
) m_fnOldWndProc
))
1021 WinSubclassWindow(hwnd
, (PFNWP
)m_fnOldWndProc
);
1025 } // end of wxWindowOS2::UnsubclassWin
1027 bool wxCheckWindowWndProc(
1029 , WXFARPROC fnWndProc
1032 static char zBuffer
[512];
1035 ::WinQueryClassName((HWND
)hWnd
, (LONG
)512, (PCH
)zBuffer
);
1036 ::WinQueryClassInfo(wxGetInstance(), (PSZ
)zBuffer
, &vCls
);
1037 return(fnWndProc
== (WXFARPROC
)vCls
.pfnWindowProc
);
1038 } // end of WinGuiBase_CheckWindowWndProc
1041 // Make a Windows extended style from the given wxWindows window style
1043 WXDWORD
wxWindowOS2::MakeExtendedStyle(
1045 , bool bEliminateBorders
1049 // Simply fill out with wxWindow extended styles. We'll conjure
1050 // something up in OS2Create and all window redrawing pieces later
1052 WXDWORD dwStyle
= 0;
1054 if (lStyle
& wxTRANSPARENT_WINDOW
)
1055 dwStyle
|= wxTRANSPARENT_WINDOW
;
1057 if (!bEliminateBorders
)
1059 if (lStyle
& wxSUNKEN_BORDER
)
1060 dwStyle
|= wxSUNKEN_BORDER
;
1061 if (lStyle
& wxDOUBLE_BORDER
)
1062 dwStyle
|= wxDOUBLE_BORDER
;
1063 if (lStyle
& wxRAISED_BORDER
)
1064 dwStyle
|= wxRAISED_BORDER
;
1065 if (lStyle
& wxSTATIC_BORDER
)
1066 dwStyle
|= wxSTATIC_BORDER
;
1069 } // end of wxWindowOS2::MakeExtendedStyle
1072 // Determines whether simulated 3D effects or CTL3D should be used,
1073 // applying a default border style if required, and returning an extended
1074 // style to pass to OS2Create.
1076 WXDWORD
wxWindowOS2::Determine3DEffects(
1077 WXDWORD dwDefaultBorderStyle
1081 WXDWORD dwStyle
= 0L;
1084 // Native PM does not have any specialize 3D effects like WIN32 does,
1085 // so we have to try and invent them.
1089 // If matches certain criteria, then assume no 3D effects
1090 // unless specifically requested (dealt with in MakeExtendedStyle)
1093 !IsKindOf(CLASSINFO(wxControl
)) ||
1094 (m_windowStyle
& wxNO_BORDER
)
1098 return MakeExtendedStyle(m_windowStyle
, FALSE
);
1102 // 1) App can specify global 3D effects
1104 *pbWant3D
= wxTheApp
->GetAuto3D();
1107 // 2) If the parent is being drawn with user colours, or simple border
1108 // specified, switch effects off.
1111 (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS
) ||
1112 (m_windowStyle
& wxSIMPLE_BORDER
)
1117 // 3) Control can override this global setting by defining
1118 // a border style, e.g. wxSUNKEN_BORDER
1120 if ((m_windowStyle
& wxDOUBLE_BORDER
) ||
1121 (m_windowStyle
& wxRAISED_BORDER
) ||
1122 (m_windowStyle
& wxSTATIC_BORDER
) ||
1123 (m_windowStyle
& wxSUNKEN_BORDER
)
1127 dwStyle
= MakeExtendedStyle( m_windowStyle
1132 // If we want 3D, but haven't specified a border here,
1133 // apply the default border style specified.
1135 if (dwDefaultBorderStyle
&& (*pbWant3D
) &&
1136 !((m_windowStyle
& wxDOUBLE_BORDER
) ||
1137 (m_windowStyle
& wxRAISED_BORDER
) ||
1138 (m_windowStyle
& wxSTATIC_BORDER
) ||
1139 (m_windowStyle
& wxSIMPLE_BORDER
)
1142 dwStyle
|= dwDefaultBorderStyle
;
1144 } // end of wxWindowOS2::Determine3DEffects
1146 #if WXWIN_COMPATIBILITY
1147 void wxWindowOS2::OnCommand(
1149 , wxCommandEvent
& rEvent
1152 if (GetEventHandler()->ProcessEvent(rEvent
))
1155 m_parent
->GetEventHandler()->OnCommand( rWin
1158 } // end of wxWindowOS2::OnCommand
1160 wxObject
* wxWindowOS2::GetChild(
1165 // Return a pointer to the Nth object in the Panel
1167 wxNode
* pNode
= GetChildren().First();
1170 while (pNode
&& n
--)
1171 pNode
= pNode
->Next();
1174 wxObject
* pObj
= (wxObject
*)pNode
->Data();
1179 } // end of wxWindowOS2::GetChild
1181 #endif // WXWIN_COMPATIBILITY
1184 // Setup background and foreground colours correctly
1186 void wxWindowOS2::SetupColours()
1189 SetBackgroundColour(GetParent()->GetBackgroundColour());
1190 } // end of wxWindowOS2::SetupColours
1192 void wxWindowOS2::OnIdle(
1193 wxIdleEvent
& WXUNUSED(rEvent
)
1197 // Check if we need to send a LEAVE event
1199 if (m_bMouseInWindow
)
1203 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
1204 if (::WinWindowFromPoint(HWND_DESKTOP
, &vPoint
, FALSE
) != (HWND
)GetHwnd())
1207 // Generate a LEAVE event
1209 m_bMouseInWindow
= FALSE
;
1212 // Unfortunately the mouse button and keyboard state may have changed
1213 // by the time the OnIdle function is called, so 'state' may be
1218 if (::WinGetKeyState(HWND_DESKTOP
, VK_SHIFT
) != 0)
1220 if (::WinGetKeyState(HWND_DESKTOP
, VK_CTRL
) != 0);
1223 wxMouseEvent
rEvent(wxEVT_LEAVE_WINDOW
);
1225 InitMouseEvent( rEvent
1230 (void)GetEventHandler()->ProcessEvent(rEvent
);
1234 } // end of wxWindowOS2::OnIdle
1237 // Set this window to be the child of 'parent'.
1239 bool wxWindowOS2::Reparent(
1243 if (!wxWindowBase::Reparent(pParent
))
1246 HWND hWndChild
= GetHwnd();
1247 HWND hWndParent
= GetParent() ? GetWinHwnd(GetParent()) : (HWND
)0;
1249 ::WinSetParent(hWndChild
, hWndParent
, TRUE
);
1251 } // end of wxWindowOS2::Reparent
1253 void wxWindowOS2::Clear()
1255 wxClientDC
vDc((wxWindow
*)this);
1256 wxBrush
vBrush( GetBackgroundColour()
1260 vDc
.SetBackground(vBrush
);
1262 } // end of wxWindowOS2::Clear
1264 void wxWindowOS2::Update()
1266 ::WinUpdateWindow(GetHwnd());
1267 } // end of wxWindowOS2::Update
1269 void wxWindowOS2::Freeze()
1271 ::WinSendMsg(GetHwnd(), WM_VRNDISABLED
, (MPARAM
)0, (MPARAM
)0);
1272 } // end of wxWindowOS2::Freeze
1274 void wxWindowOS2::Thaw()
1276 ::WinSendMsg(GetHwnd(), WM_VRNENABLED
, (MPARAM
)TRUE
, (MPARAM
)0);
1279 // We need to refresh everything or otherwise he invalidated area is not
1283 } // end of wxWindowOS2::Thaw
1285 void wxWindowOS2::Refresh(
1287 , const wxRect
* pRect
1290 HWND hWnd
= GetHwnd();
1298 vOs2Rect
.xLeft
= pRect
->x
;
1299 vOs2Rect
.yTop
= pRect
->y
;
1300 vOs2Rect
.xRight
= pRect
->x
+ pRect
->width
;
1301 vOs2Rect
.yBottom
= pRect
->y
+ pRect
->height
;
1303 ::WinInvalidateRect(hWnd
, &vOs2Rect
, bEraseBack
);
1306 ::WinInvalidateRect(hWnd
, NULL
, bEraseBack
);
1307 if (m_hWndScrollBarHorz
!= NULLHANDLE
)
1308 ::WinInvalidateRect(m_hWndScrollBarHorz
, NULL
, TRUE
);
1309 if (m_hWndScrollBarVert
!= NULLHANDLE
)
1310 ::WinInvalidateRect(m_hWndScrollBarVert
, NULL
, TRUE
);
1312 } // end of wxWindowOS2::Refresh
1314 // ---------------------------------------------------------------------------
1316 // ---------------------------------------------------------------------------
1318 #if wxUSE_DRAG_AND_DROP
1319 void wxWindowOS2::SetDropTarget(
1320 wxDropTarget
* pDropTarget
1323 if (m_dropTarget
!= 0)
1325 m_dropTarget
->Revoke(m_hWnd
);
1326 delete m_dropTarget
;
1328 m_dropTarget
= pDropTarget
;
1329 if (m_dropTarget
!= 0)
1330 m_dropTarget
->Register(m_hWnd
);
1331 } // end of wxWindowOS2::SetDropTarget
1335 // old style file-manager drag&drop support: we retain the old-style
1336 // DragAcceptFiles in parallel with SetDropTarget.
1338 void wxWindowOS2::DragAcceptFiles(
1342 HWND hWnd
= GetHwnd();
1344 if (hWnd
&& bAccept
)
1345 ::DrgAcceptDroppedFiles(hWnd
, NULL
, NULL
, DO_COPY
, 0L);
1346 } // end of wxWindowOS2::DragAcceptFiles
1348 // ----------------------------------------------------------------------------
1350 // ----------------------------------------------------------------------------
1354 void wxWindowOS2::DoSetToolTip(
1358 wxWindowBase::DoSetToolTip(pTooltip
);
1361 m_tooltip
->SetWindow(this);
1362 } // end of wxWindowOS2::DoSetToolTip
1364 #endif // wxUSE_TOOLTIPS
1366 // ---------------------------------------------------------------------------
1367 // moving and resizing
1368 // ---------------------------------------------------------------------------
1371 void wxWindowOS2::DoGetSize(
1379 if (IsKindOf(CLASSINFO(wxFrame
)))
1381 wxFrame
* pFrame
= wxDynamicCast(this, wxFrame
);
1382 hWnd
= pFrame
->GetFrame();
1387 ::WinQueryWindowRect(hWnd
, &vRect
);
1390 *pWidth
= vRect
.xRight
- vRect
.xLeft
;
1392 // OS/2 PM is backwards from windows
1393 *pHeight
= vRect
.yTop
- vRect
.yBottom
;
1394 } // end of wxWindowOS2::DoGetSize
1396 void wxWindowOS2::DoGetPosition(
1401 HWND hWnd
= GetHwnd();
1404 wxWindow
* pParent
= GetParent();
1407 // It would seem that WinQueryWindowRect would be the correlary to
1408 // the WIN32 WinGetRect, but unlike WinGetRect which returns the window
1409 // origin position in screen coordinates, WinQueryWindowRect returns it
1410 // relative to itself, i.e. (0,0). To get the same under PM we must
1411 // us WinQueryWindowPos. This call, unlike the WIN32 call, however,
1412 // returns a position relative to it's parent, so no parent adujstments
1413 // are needed under OS/2. Also, windows should be created using
1414 // wxWindow coordinates, i.e 0,0 is the TOP left so vSwp will already
1417 ::WinQueryWindowPos(hWnd
, &vSwp
);
1423 // We may be faking the client origin. So a window that's really at (0,
1424 // 30) may appear (to wxWin apps) to be at (0, 0).
1428 wxPoint
vPt(pParent
->GetClientAreaOrigin());
1438 } // end of wxWindowOS2::DoGetPosition
1440 void wxWindowOS2::DoScreenToClient(
1445 HWND hWnd
= GetHwnd();
1448 ::WinQueryWindowPos(hWnd
, &vSwp
);
1454 } // end of wxWindowOS2::DoScreenToClient
1456 void wxWindowOS2::DoClientToScreen(
1461 HWND hWnd
= GetHwnd();
1464 ::WinQueryWindowPos(hWnd
, &vSwp
);
1470 } // end of wxWindowOS2::DoClientToScreen
1473 // Get size *available for subwindows* i.e. excluding menu bar etc.
1474 // Must be a frame type window
1476 void wxWindowOS2::DoGetClientSize(
1481 HWND hWnd
= GetHwnd();
1484 ::WinQueryWindowRect(hWnd
, &vRect
);
1485 if (IsKindOf(CLASSINFO(wxDialog
)))
1490 // For a Dialog we have to explicitly request the client portion.
1491 // For a Frame the hWnd IS the client window
1493 hWndTitle
= ::WinWindowFromID(hWnd
, FID_TITLEBAR
);
1494 if (::WinQueryWindowRect(hWndTitle
, &vTitle
))
1496 if (vTitle
.yTop
- vTitle
.yBottom
== 0)
1499 // Dialog has not been created yet, use a default
1503 vRect
.yTop
-= (vTitle
.yTop
- vTitle
.yBottom
);
1506 ULONG uStyle
= ::WinQueryWindowULong(hWnd
, QWL_STYLE
);
1509 // Deal with borders
1511 if (uStyle
& FCF_DLGBORDER
)
1518 else if (uStyle
& FCF_SIZEBORDER
)
1525 else if (uStyle
& FCF_BORDER
)
1532 else // make some kind of adjustment or top sizers ram into the titlebar!
1541 *pWidth
= vRect
.xRight
- vRect
.xLeft
;
1543 *pHeight
= vRect
.yTop
- vRect
.yBottom
;
1544 } // end of wxWindowOS2::DoGetClientSize
1546 void wxWindowOS2::DoMoveWindow(
1555 wxWindow
* pParent
= GetParent();
1557 if (pParent
&& !IsKindOf(CLASSINFO(wxDialog
)))
1559 int nOS2Height
= GetOS2ParentHeight(pParent
);
1561 nY
= nOS2Height
- (nY
+ nHeight
);
1567 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
1568 nY
= vRect
.yTop
- (nY
+ nHeight
);
1570 ::WinSetWindowPos( GetHwnd()
1576 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
1578 if (m_vWinSwp
.cx
== 0 && m_vWinSwp
.cy
== 0 && m_vWinSwp
.fl
== 0)
1582 ::WinQueryWindowPos(GetHwnd(), &m_vWinSwp
);
1585 int nYDiff
= m_vWinSwp
.cy
- nHeight
;
1588 // Handle resizing of scrolled windows. The target or window to
1589 // be scrolled is the owner (gets the scroll notificaitons). The
1590 // parent is usually the parent frame of the scrolled panel window.
1591 // In order to show the scrollbars the target window will be shrunk
1592 // by the size of the scroll bar widths (20) and moved in the X and Y
1593 // directon. That value will be computed as part of the diff for
1594 // moving the children. Everytime the window is sized the
1595 // toplevel OnSize is going to resize the panel to fit the client
1596 // or the whole sizer and will need to me resized. This will send
1597 // a WM_SIZE out which will be intercepted by the ScrollHelper
1598 // which will cause the scrollbars to be displayed via the SetScrollbar
1601 if ( pParent
->IsKindOf(CLASSINFO(wxGenericScrolledWindow
)) ||
1602 pParent
->IsKindOf(CLASSINFO(wxScrolledWindow
))
1605 int nAdjustWidth
= 0;
1606 int nAdjustHeight
= 0;
1609 if (GetScrollBarHorz() != NULLHANDLE
)
1610 nAdjustHeight
= 20L;
1611 if (GetScrollBarVert() != NULLHANDLE
)
1613 ::WinQueryWindowPos(GetHWND(), &vSwpScroll
);
1614 ::WinSetWindowPos( GetHWND()
1617 ,vSwpScroll
.y
+ nAdjustHeight
1618 ,vSwpScroll
.cx
- nAdjustWidth
1619 ,vSwpScroll
.cy
- nAdjustHeight
1620 ,SWP_MOVE
| SWP_SIZE
1624 MoveChildren(nYDiff
);
1625 ::WinQueryWindowPos(GetHwnd(), &m_vWinSwp
);
1627 } // end of wxWindowOS2::DoMoveWindow
1630 // Set the size of the window: if the dimensions are positive, just use them,
1631 // but if any of them is equal to -1, it means that we must find the value for
1632 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
1633 // which case -1 is a valid value for x and y)
1635 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
1636 // the width/height to best suit our contents, otherwise we reuse the current
1639 void wxWindowOS2::DoSetSize(
1648 // Get the current size and position...
1654 wxSize
vSize(-1, -1);
1656 GetPosition(&nCurrentX
, &nCurrentY
);
1657 GetSize(&nCurrentWidth
, &nCurrentHeight
);
1660 // ... and don't do anything (avoiding flicker) if it's already ok
1663 // Must convert Y coords to test for equality under OS/2
1666 wxWindow
* pParent
= (wxWindow
*)GetParent();
1668 if (pParent
&& !IsKindOf(CLASSINFO(wxDialog
)))
1670 int nOS2Height
= GetOS2ParentHeight(pParent
);
1672 nY2
= nOS2Height
- (nY2
+ nHeight
);
1678 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
1679 nY2
= vRect
.yTop
- (nY2
+ nHeight
);
1681 if (nX
== nCurrentX
&& nY2
== nCurrentY
&&
1682 nWidth
== nCurrentWidth
&& nHeight
== nCurrentHeight
)
1687 if (nX
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
1689 if (nY
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
1692 AdjustForParentClientOrigin(nX
, nY
, nSizeFlags
);
1696 if (nSizeFlags
& wxSIZE_AUTO_WIDTH
)
1698 vSize
= DoGetBestSize();
1704 // Just take the current one
1706 nWidth
= nCurrentWidth
;
1712 if (nSizeFlags
& wxSIZE_AUTO_HEIGHT
)
1716 vSize
= DoGetBestSize();
1722 // just take the current one
1723 nHeight
= nCurrentHeight
;
1732 } // end of wxWindowOS2::DoSetSize
1734 void wxWindowOS2::DoSetClientSize(
1739 wxWindow
* pParent
= GetParent();
1740 HWND hWnd
= GetHwnd();
1741 HWND hParentWnd
= (HWND
)0;
1746 HWND hClientWnd
= (HWND
)0;
1748 hClientWnd
= ::WinWindowFromID(hWnd
, FID_CLIENT
);
1749 ::WinQueryWindowRect(hClientWnd
, &vRect2
);
1750 ::WinQueryWindowRect(hWnd
, &vRect
);
1751 ::WinQueryWindowRect(hParentWnd
, &vRect3
);
1753 int nActualWidth
= vRect2
.xRight
- vRect2
.xLeft
- vRect
.xRight
+ nWidth
;
1754 int nActualHeight
= vRect2
.yTop
- vRect2
.yBottom
- vRect
.yTop
+ nHeight
;
1756 vPoint
.x
= vRect2
.xLeft
;
1757 vPoint
.y
= vRect2
.yBottom
;
1760 vPoint
.x
-= vRect3
.xLeft
;
1761 vPoint
.y
-= vRect3
.yBottom
;
1764 DoMoveWindow(vPoint
.x
, vPoint
.y
, nActualWidth
, nActualHeight
);
1766 wxSizeEvent
vEvent(wxSize(nWidth
, nHeight
), m_windowId
);
1767 vEvent
.SetEventObject(this);
1768 GetEventHandler()->ProcessEvent(vEvent
);
1769 } // end of wxWindowOS2::DoSetClientSize
1771 wxPoint
wxWindowOS2::GetClientAreaOrigin() const
1773 return wxPoint(0, 0);
1774 } // end of wxWindowOS2::GetClientAreaOrigin
1776 // ---------------------------------------------------------------------------
1778 // ---------------------------------------------------------------------------
1780 int wxWindowOS2::GetCharHeight() const
1783 FONTMETRICS vFontMetrics
;
1785 hPs
= ::WinGetPS(GetHwnd());
1787 if(!GpiQueryFontMetrics(hPs
, sizeof(FONTMETRICS
), &vFontMetrics
))
1789 ::WinReleasePS(hPs
);
1792 ::WinReleasePS(hPs
);
1793 return(vFontMetrics
.lMaxAscender
+ vFontMetrics
.lMaxDescender
);
1794 } // end of wxWindowOS2::GetCharHeight
1796 int wxWindowOS2::GetCharWidth() const
1799 FONTMETRICS vFontMetrics
;
1801 hPs
= ::WinGetPS(GetHwnd());
1803 if(!GpiQueryFontMetrics(hPs
, sizeof(FONTMETRICS
), &vFontMetrics
))
1805 ::WinReleasePS(hPs
);
1808 ::WinReleasePS(hPs
);
1809 return(vFontMetrics
.lAveCharWidth
);
1810 } // end of wxWindowOS2::GetCharWidth
1812 void wxWindowOS2::GetTextExtent(
1813 const wxString
& rString
1817 , int* pExternalLeading
1818 , const wxFont
* pTheFont
1821 POINTL avPoint
[TXTBOX_COUNT
];
1826 FONTMETRICS vFM
; // metrics structure
1829 ERRORID vErrorCode
; // last error id code
1833 hPS
= ::WinGetPS(GetHwnd());
1835 l
= rString
.Length();
1838 pStr
= (PCH
)rString
.c_str();
1841 // In world coordinates.
1843 bRc
= ::GpiQueryTextBox( hPS
1846 ,TXTBOX_COUNT
// return maximum information
1847 ,avPoint
// array of coordinates points
1851 vPtMin
.x
= avPoint
[0].x
;
1852 vPtMax
.x
= avPoint
[0].x
;
1853 vPtMin
.y
= avPoint
[0].y
;
1854 vPtMax
.y
= avPoint
[0].y
;
1855 for (i
= 1; i
< 4; i
++)
1857 if(vPtMin
.x
> avPoint
[i
].x
) vPtMin
.x
= avPoint
[i
].x
;
1858 if(vPtMin
.y
> avPoint
[i
].y
) vPtMin
.y
= avPoint
[i
].y
;
1859 if(vPtMax
.x
< avPoint
[i
].x
) vPtMax
.x
= avPoint
[i
].x
;
1860 if(vPtMax
.y
< avPoint
[i
].y
) vPtMax
.y
= avPoint
[i
].y
;
1862 bRc
= ::GpiQueryFontMetrics( hPS
1863 ,sizeof(FONTMETRICS
)
1890 *pX
= (vPtMax
.x
- vPtMin
.x
+ 1);
1892 *pY
= (vPtMax
.y
- vPtMin
.y
+ 1);
1896 *pDescent
= vFM
.lMaxDescender
;
1900 if (pExternalLeading
)
1903 *pExternalLeading
= vFM
.lExternalLeading
;
1905 *pExternalLeading
= 0;
1907 ::WinReleasePS(hPS
);
1908 } // end of wxWindow::GetTextExtent
1910 bool wxWindowOS2::IsMouseInWindow() const
1913 // Get the mouse position
1916 ::WinQueryPointerPos(HWND_DESKTOP
, &vPt
);
1919 // Find the window which currently has the cursor and go up the window
1920 // chain until we find this window - or exhaust it
1922 HWND hWnd
= ::WinWindowFromPoint(HWND_DESKTOP
, &vPt
, TRUE
);
1924 while (hWnd
&& (hWnd
!= GetHwnd()))
1925 hWnd
= ::WinQueryWindow(hWnd
, QW_PARENT
);
1927 return hWnd
!= NULL
;
1928 } // end of wxWindowOS2::IsMouseInWindow
1930 #if wxUSE_CARET && WXWIN_COMPATIBILITY
1931 // ---------------------------------------------------------------------------
1932 // Caret manipulation
1933 // ---------------------------------------------------------------------------
1935 void wxWindowOS2::CreateCaret(
1940 SetCaret(new wxCaret( this
1944 } // end of wxWindowOS2::CreateCaret
1946 void wxWindowOS2::CreateCaret(
1947 const wxBitmap
* pBitmap
1950 wxFAIL_MSG("not implemented");
1951 } // end of wxWindowOS2::CreateCaret
1953 void wxWindowOS2::ShowCaret(
1957 wxCHECK_RET( m_caret
, "no caret to show" );
1959 m_caret
->Show(bShow
);
1960 } // end of wxWindowOS2::ShowCaret
1962 void wxWindowOS2::DestroyCaret()
1965 } // end of wxWindowOS2::DestroyCaret
1967 void wxWindowOS2::SetCaretPos(
1971 wxCHECK_RET( m_caret
, "no caret to move" );
1976 } // end of wxWindowOS2::SetCaretPos
1978 void wxWindowOS2::GetCaretPos(
1983 wxCHECK_RET( m_caret
, "no caret to get position of" );
1985 m_caret
->GetPosition( pX
1988 } // end of wxWindowOS2::GetCaretPos
1990 #endif //wxUSE_CARET
1992 // ---------------------------------------------------------------------------
1994 // ---------------------------------------------------------------------------
1996 #if wxUSE_MENUS_NATIVE
1997 static void wxYieldForCommandsOnly()
2000 // Peek all WM_COMMANDs (it will always return WM_QUIT too but we don't
2001 // want to process it here)
2005 while (::WinPeekMsg(vHabmain
, &vMsg
, (HWND
)0, WM_COMMAND
, WM_COMMAND
, PM_REMOVE
)
2006 && vMsg
.msg
!= WM_QUIT
)
2008 wxTheApp
->DoMessage((WXMSG
*)&vMsg
);
2011 #endif // wxUSE_MENUS_NATIVE
2013 #if wxUSE_MENUS_NATIVE
2014 bool wxWindowOS2::DoPopupMenu(
2020 HWND hWndOwner
= GetHwnd();
2021 HWND hWndParent
= GetHwnd();
2022 HWND hMenu
= GetHmenuOf(pMenu
);
2023 bool bIsWaiting
= TRUE
;
2025 pMenu
->SetInvokingWindow(this);
2028 DoClientToScreen( &nX
2031 wxCurrentPopupMenu
= pMenu
;
2033 ::WinPopupMenu( hWndParent
2039 ,PU_HCONSTRAIN
| PU_VCONSTRAIN
| PU_MOUSEBUTTON1
| PU_KEYBOARD
2045 BOOL bRc
= ::WinGetMsg(vHabmain
, &vMsg
, HWND(NULL
), 0, 0);
2047 if (vMsg
.msg
== WM_MENUEND
|| vMsg
.msg
== WM_COMMAND
)
2051 ::WinDispatchMsg(vHabmain
, (PQMSG
)&vMsg
);
2054 wxCurrentPopupMenu
= NULL
;
2055 pMenu
->SetInvokingWindow(NULL
);
2057 } // end of wxWindowOS2::DoPopupMenu
2058 #endif // wxUSE_MENUS_NATIVE
2060 // ===========================================================================
2061 // pre/post message processing
2062 // ===========================================================================
2064 MRESULT
wxWindowOS2::OS2DefWindowProc(
2071 return (MRESULT
)m_fnOldWndProc(GetHWND(), uMsg
, (MPARAM
)wParam
, (MPARAM
)lParam
);
2073 return ::WinDefWindowProc(GetHWND(), uMsg
, (MPARAM
)wParam
, (MPARAM
)lParam
);
2074 } // end of wxWindowOS2::OS2DefWindowProc
2076 bool wxWindowOS2::OS2ProcessMessage(
2080 // wxUniversal implements tab traversal itself
2081 #ifndef __WXUNIVERSAL__
2082 QMSG
* pQMsg
= (QMSG
*)pMsg
;
2084 if (m_hWnd
!= 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL
))
2087 // Intercept dialog navigation keys
2089 bool bProcess
= TRUE
;
2090 USHORT uKeyFlags
= SHORT1FROMMP(pQMsg
->mp1
);
2092 if (uKeyFlags
& KC_KEYUP
)
2095 if (uKeyFlags
& KC_ALT
)
2098 if (!(uKeyFlags
& KC_VIRTUALKEY
))
2103 bool bCtrlDown
= IsCtrlDown();
2104 bool bShiftDown
= IsShiftDown();
2107 // WM_QUERYDLGCODE: ask the control if it wants the key for itself,
2108 // don't process it if it's the case (except for Ctrl-Tab/Enter
2109 // combinations which are always processed)
2111 ULONG ulDlgCode
= 0;
2115 ulDlgCode
= (ULONG
)::WinSendMsg(pQMsg
->hwnd
, WM_QUERYDLGCODE
, pQMsg
, 0);
2118 bool bForward
= TRUE
;
2119 bool bWindowChange
= FALSE
;
2121 switch (SHORT2FROMMP(pQMsg
->mp2
))
2124 // Going to make certain assumptions about specific types of controls
2125 // here, so we may have to alter some things later if they prove invalid
2129 // Shift tabl will always be a nav-key but tabs may be wanted
2138 // Entry Fields want tabs for themselve usually
2142 case DLGC_ENTRYFIELD
:
2152 // Ctrl-Tab cycles thru notebook pages
2154 bWindowChange
= bCtrlDown
;
2155 bForward
= !bShiftDown
;
2178 // ctrl-enter is not processed
2182 else if (ulDlgCode
& DLGC_BUTTON
)
2185 // buttons want process Enter themselevs
2191 wxButton
* pBtn
= wxDynamicCast( GetDefaultItem()
2195 if (pBtn
&& pBtn
->IsEnabled())
2198 // If we do have a default button, do press it
2200 pBtn
->OS2Command(BN_CLICKED
, 0 /* unused */);
2203 // else: but if it does not it makes sense to make
2204 // it work like a TAB - and that's what we do.
2205 // Note that Ctrl-Enter always works this way.
2216 wxNavigationKeyEvent vEvent
;
2218 vEvent
.SetDirection(bForward
);
2219 vEvent
.SetWindowChange(bWindowChange
);
2220 vEvent
.SetEventObject(this);
2222 if (GetEventHandler()->ProcessEvent(vEvent
))
2224 wxButton
* pBtn
= wxDynamicCast(FindFocus(), wxButton
);
2229 // The button which has focus should be default
2238 // Let Dialogs process
2240 if (::WinSendMsg(pQMsg
->hwnd
, WM_QUERYDLGCODE
, pQMsg
, 0));
2244 pMsg
= pMsg
; // just shut up the compiler
2245 #endif // __WXUNIVERSAL__
2250 // relay mouse move events to the tooltip control
2251 QMSG
* pQMsg
= (QMSG
*)pMsg
;
2253 if (pQMsg
->msg
== WM_MOUSEMOVE
)
2254 m_tooltip
->RelayEvent(pMsg
);
2256 #endif // wxUSE_TOOLTIPS
2259 } // end of wxWindowOS2::OS2ProcessMessage
2261 bool wxWindowOS2::OS2TranslateMessage(
2265 #if wxUSE_ACCEL && !defined(__WXUNIVERSAL__)
2266 return m_acceleratorTable
.Translate(m_hWnd
, pMsg
);
2270 #endif //wxUSE_ACCEL
2271 } // end of wxWindowOS2::OS2TranslateMessage
2273 bool wxWindowOS2::OS2ShouldPreProcessMessage(
2277 // preprocess all messages by default
2279 } // end of wxWindowOS2::OS2ShouldPreProcessMessage
2281 // ---------------------------------------------------------------------------
2282 // message params unpackers
2283 // ---------------------------------------------------------------------------
2285 void wxWindowOS2::UnpackCommand(
2293 *pId
= LOWORD(wParam
);
2294 *phWnd
= NULL
; // or may be GetHWND() ?
2295 *pCmd
= LOWORD(lParam
);
2296 } // end of wxWindowOS2::UnpackCommand
2298 void wxWindowOS2::UnpackActivate(
2305 *pState
= LOWORD(wParam
);
2306 *phWnd
= (WXHWND
)lParam
;
2307 } // end of wxWindowOS2::UnpackActivate
2309 void wxWindowOS2::UnpackScroll(
2320 ulId
= (ULONG
)LONGFROMMP(wParam
);
2321 hWnd
= ::WinWindowFromID(GetHwnd(), ulId
);
2322 if (hWnd
== m_hWndScrollBarHorz
|| hWnd
== m_hWndScrollBarVert
)
2323 *phWnd
= NULLHANDLE
;
2327 *pPos
= SHORT1FROMMP(lParam
);
2328 *pCode
= SHORT2FROMMP(lParam
);
2329 } // end of wxWindowOS2::UnpackScroll
2331 void wxWindowOS2::UnpackMenuSelect(
2339 *pItem
= (WXWORD
)LOWORD(wParam
);
2340 *pFlags
= HIWORD(wParam
);
2341 *phMenu
= (WXHMENU
)lParam
;
2342 } // end of wxWindowOS2::UnpackMenuSelect
2344 // ---------------------------------------------------------------------------
2345 // Main wxWindows window proc and the window proc for wxWindow
2346 // ---------------------------------------------------------------------------
2349 // Hook for new window just as it's being created, when the window isn't yet
2350 // associated with the handle
2352 wxWindowOS2
* wxWndHook
= NULL
;
2357 MRESULT EXPENTRY
wxWndProc(
2365 // Trace all ulMsgs - useful for the debugging
2368 wxLogTrace(wxTraceMessages
, wxT("Processing %s(wParam=%8lx, lParam=%8lx)"),
2369 wxGetMessageName(ulMsg
), wParam
, lParam
);
2370 #endif // __WXDEBUG__
2372 wxWindowOS2
* pWnd
= wxFindWinFromHandle((WXHWND
)hWnd
);
2375 // When we get the first message for the HWND we just created, we associate
2376 // it with wxWindow stored in wxWndHook
2378 if (!pWnd
&& wxWndHook
)
2380 wxAssociateWinWithHandle(hWnd
, wxWndHook
);
2383 pWnd
->SetHWND((WXHWND
)hWnd
);
2386 MRESULT rc
= (MRESULT
)0;
2390 // Stop right here if we don't have a valid handle in our wxWindow object.
2392 if (pWnd
&& !pWnd
->GetHWND())
2394 pWnd
->SetHWND((WXHWND
) hWnd
);
2395 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
2402 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
2403 if ( (pWnd
->GetScrollBarHorz() != NULLHANDLE
||
2404 pWnd
->GetScrollBarVert() != NULLHANDLE
) &&
2407 if (pWnd
->GetScrollBarHorz() != NULLHANDLE
)
2408 ::WinInvalidateRect(pWnd
->GetScrollBarHorz(), NULL
, TRUE
);
2409 if (pWnd
->GetScrollBarVert() != NULLHANDLE
)
2410 ::WinInvalidateRect(pWnd
->GetScrollBarVert(), NULL
, TRUE
);
2414 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
2418 } // end of wxWndProc
2421 // We will add (or delete) messages we need to handle at this default
2424 MRESULT
wxWindowOS2::OS2WindowProc(
2431 // Did we process the uMsg?
2433 bool bProcessed
= FALSE
;
2437 // For most messages we should return 0 when we do process the message
2439 mResult
= (MRESULT
)0;
2447 bProcessed
= HandleCreate( (WXLPCREATESTRUCT
)lParam
2453 // Return 0 to bAllow window creation
2455 mResult
= (MRESULT
)(bMayCreate
? 0 : -1);
2466 bProcessed
= HandleMove( LOWORD(lParam
)
2472 bProcessed
= HandleSize( LOWORD(lParam
)
2478 case WM_WINDOWPOSCHANGED
:
2481 // Dialogs under OS/2 do not get WM_SIZE events at all.
2482 // Instead they get this, which can function much like WM_SIZE
2483 // PSWP contains the new sizes and positioning, PSWP+1 the old
2484 // We use this because ADJUSTWINDOWPOS comes BEFORE the new
2485 // position is added and our auto layout does a WinQueryWindowRect
2486 // to get the CURRENT client size. That is the size used to position
2487 // child controls, so we need to already be sized
2488 // in order to get the child controls positoned properly.
2490 if (IsKindOf(CLASSINFO(wxDialog
)) || IsKindOf(CLASSINFO(wxFrame
)))
2492 PSWP pSwp
= (PSWP
)PVOIDFROMMP(wParam
);
2493 PSWP pSwp2
= pSwp
++;
2495 if (!(pSwp
->cx
== pSwp2
->cx
&&
2496 pSwp
->cy
== pSwp2
->cy
))
2497 bProcessed
= HandleSize( pSwp
->cx
2501 if (IsKindOf(CLASSINFO(wxFrame
)))
2503 wxFrame
* pFrame
= wxDynamicCast(this, wxFrame
);
2507 if (pFrame
->GetStatusBar())
2508 pFrame
->PositionStatusBar();
2519 UnpackActivate( wParam
2525 bProcessed
= HandleActivate( wState
2533 if (SHORT1FROMMP((MPARAM
)lParam
) == TRUE
)
2534 bProcessed
= HandleSetFocus((WXHWND
)(HWND
)wParam
);
2536 bProcessed
= HandleKillFocus((WXHWND
)(HWND
)wParam
);
2540 bProcessed
= HandlePaint();
2545 // Don't let the DefWindowProc() destroy our window - we'll do it
2546 // ourselves in ~wxWindow
2549 mResult
= (MRESULT
)TRUE
;
2553 bProcessed
= HandleShow(wParam
!= 0, (int)lParam
);
2557 // Under OS2 PM Joysticks are treated just like mouse events
2558 // The "Motion" events will be prevelent in joysticks
2561 case WM_BUTTON1DOWN
:
2563 case WM_BUTTON1DBLCLK
:
2564 case WM_BUTTON1MOTIONEND
:
2565 case WM_BUTTON1MOTIONSTART
:
2566 case WM_BUTTON2DOWN
:
2568 case WM_BUTTON2DBLCLK
:
2569 case WM_BUTTON2MOTIONEND
:
2570 case WM_BUTTON2MOTIONSTART
:
2571 case WM_BUTTON3DOWN
:
2573 case WM_BUTTON3DBLCLK
:
2574 case WM_BUTTON3MOTIONEND
:
2575 case WM_BUTTON3MOTIONSTART
:
2577 short x
= LOWORD(wParam
);
2578 short y
= HIWORD(wParam
);
2580 bProcessed
= HandleMouseEvent(uMsg
, x
, y
, (WXUINT
)wParam
);
2584 bProcessed
= HandleSysCommand(wParam
, lParam
);
2591 UnpackCommand(wParam
, lParam
, &id
, &hwnd
, &cmd
);
2593 bProcessed
= HandleCommand(id
, cmd
, hwnd
);
2598 // For these messages we must return TRUE if process the message
2601 case WM_MEASUREITEM
:
2603 int nIdCtrl
= (UINT
)wParam
;
2605 if ( uMsg
== WM_DRAWITEM
)
2607 bProcessed
= OS2OnDrawItem(nIdCtrl
,
2608 (WXDRAWITEMSTRUCT
*)lParam
);
2612 bProcessed
= OS2OnMeasureItem(nIdCtrl
,
2613 (WXMEASUREITEMSTRUCT
*)lParam
);
2617 mResult
= (MRESULT
)TRUE
;
2621 case WM_QUERYDLGCODE
:
2624 mResult
= (MRESULT
)m_lDlgCode
;
2628 //else: get the dlg code from the DefWindowProc()
2633 // In OS/2 PM all keyboard events are of the WM_CHAR type. Virtual key and key-up
2634 // and key-down events are obtained from the WM_CHAR params.
2638 USHORT uKeyFlags
= SHORT1FROMMP((MPARAM
)wParam
);
2640 if (uKeyFlags
& KC_KEYUP
)
2642 //TODO: check if the cast to WXWORD isn't causing trouble
2643 bProcessed
= HandleKeyUp((WXDWORD
)wParam
, lParam
);
2646 else // keydown event
2649 // If this has been processed by an event handler,
2650 // return 0 now (we've handled it). DON't RETURN
2651 // we still need to process further
2653 HandleKeyDown((WXDWORD
)wParam
, lParam
);
2654 if (uKeyFlags
& KC_VIRTUALKEY
)
2656 USHORT uVk
= SHORT2FROMMP((MPARAM
)lParam
);
2659 // We consider these message "not interesting" to OnChar
2661 if (uVk
== VK_SHIFT
|| uVk
== VK_CTRL
)
2669 // Avoid duplicate messages to OnChar for these ASCII keys: they
2670 // will be translated by TranslateMessage() and received in WM_CHAR
2676 // But set processed to FALSE, not TRUE to still pass them to
2677 // the control's default window proc - otherwise built-in
2678 // keyboard handling won't work
2687 bProcessed
= HandleChar((WXDWORD
)wParam
, lParam
);
2691 else // WM_CHAR -- Always an ASCII character
2693 bProcessed
= HandleChar((WXDWORD
)wParam
, lParam
, TRUE
);
2705 UnpackScroll( wParam
2712 bProcessed
= OS2OnScroll( uMsg
== WM_HSCROLL
? wxHORIZONTAL
2722 switch(SHORT2FROMMP(wParam
))
2725 case SPBN_DOWNARROW
:
2731 ::WinSendMsg( HWNDFROMMP(lParam
)
2734 ,MPFROM2SHORT( (USHORT
)10
2735 ,(USHORT
)SPBQ_UPDATEIFVALID
2739 bProcessed
= OS2OnScroll( wxVERTICAL
2740 ,(int)SHORT2FROMMP(wParam
)
2747 case SLN_SLIDERTRACK
:
2749 HWND hWnd
= ::WinWindowFromID(GetHWND(), SHORT1FROMMP(wParam
));
2750 wxWindowOS2
* pChild
= wxFindWinFromHandle(hWnd
);
2752 if (pChild
->IsKindOf(CLASSINFO(wxSlider
)))
2753 bProcessed
= OS2OnScroll( wxVERTICAL
2754 ,(int)SHORT2FROMMP(wParam
)
2755 ,(int)LONGFROMMP(lParam
)
2763 #if defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
2764 case WM_CTLCOLORCHANGE
:
2766 bProcessed
= HandleCtlColor(&hBrush
);
2770 case WM_ERASEBACKGROUND
:
2772 // Returning TRUE to requestw PM to paint the window background
2773 // in SYSCLR_WINDOW. We don't really want that
2775 bProcessed
= HandleEraseBkgnd((WXHDC
)(HPS
)wParam
);
2776 mResult
= (MRESULT
)(FALSE
);
2779 // the return value for this message is ignored
2780 case WM_SYSCOLORCHANGE
:
2781 bProcessed
= HandleSysColorChange();
2784 case WM_REALIZEPALETTE
:
2785 bProcessed
= HandlePaletteChanged();
2788 // move all drag and drops to wxDrg
2790 bProcessed
= HandleEndDrag(wParam
);
2794 bProcessed
= HandleInitDialog((WXHWND
)(HWND
)wParam
);
2798 // we never set focus from here
2803 // wxFrame specific message
2804 case WM_MINMAXFRAME
:
2805 bProcessed
= HandleGetMinMaxInfo((PSWP
)wParam
);
2808 case WM_SYSVALUECHANGED
:
2809 // TODO: do something
2810 mResult
= (MRESULT
)TRUE
;
2814 // Comparable to WM_SETPOINTER for windows, only for just controls
2816 case WM_CONTROLPOINTER
:
2817 bProcessed
= HandleSetCursor( SHORT1FROMMP(wParam
) // Control ID
2818 ,(HWND
)lParam
// Cursor Handle
2823 // Returning TRUE stops the DefWindowProc() from further
2824 // processing this message - exactly what we need because we've
2825 // just set the cursor.
2827 mResult
= (MRESULT
)TRUE
;
2834 wxLogTrace(wxTraceMessages
, wxT("Forwarding %s to DefWindowProc."),
2835 wxGetMessageName(uMsg
));
2836 #endif // __WXDEBUG__
2837 if (IsKindOf(CLASSINFO(wxFrame
)))
2838 mResult
= ::WinDefWindowProc(m_hWnd
, uMsg
, wParam
, lParam
);
2839 else if (IsKindOf(CLASSINFO(wxDialog
)))
2840 mResult
= ::WinDefDlgProc( m_hWnd
, uMsg
, wParam
, lParam
);
2842 mResult
= OS2DefWindowProc(uMsg
, wParam
, lParam
);
2845 } // end of wxWindowOS2::OS2WindowProc
2848 // clashes with wxDlgProc in toplevel.cpp?
2850 // Dialog window proc
2855 , MPARAM
WXUNUSED(wParam
)
2856 , MPARAM
WXUNUSED(lParam
))
2858 if (uMsg
== WM_INITDLG
)
2861 // For this message, returning TRUE tells system to set focus to the
2862 // first control in the dialog box
2864 return (MRESULT
)TRUE
;
2869 // For all the other ones, FALSE means that we didn't process the
2874 } // end of wxDlgProc
2877 wxWindow
* wxFindWinFromHandle(
2881 wxNode
* pNode
= wxWinHandleList
->Find((long)hWnd
);
2885 return (wxWindow
*)pNode
->Data();
2886 } // end of wxFindWinFromHandle
2888 void wxAssociateWinWithHandle(
2894 // Adding NULL hWnd is (first) surely a result of an error and
2895 // (secondly) breaks menu command processing
2897 wxCHECK_RET( hWnd
!= (HWND
)NULL
,
2898 wxT("attempt to add a NULL hWnd to window list ignored") );
2901 wxWindow
* pOldWin
= wxFindWinFromHandle((WXHWND
) hWnd
);
2903 if (pOldWin
&& (pOldWin
!= pWin
))
2905 wxString
str(pWin
->GetClassInfo()->GetClassName());
2906 wxLogError( "Bug! Found existing HWND %X for new window of class %s"
2913 wxWinHandleList
->Append( (long)hWnd
2917 } // end of wxAssociateWinWithHandle
2919 void wxRemoveHandleAssociation(
2923 wxWinHandleList
->DeleteObject(pWin
);
2924 } // end of wxRemoveHandleAssociation
2927 // Default destroyer - override if you destroy it in some other way
2928 // (e.g. with MDI child windows)
2930 void wxWindowOS2::OS2DestroyWindow()
2934 bool wxWindowOS2::OS2GetCreateWindowCoords(
2936 , const wxSize
& rSize
2943 bool bNonDefault
= FALSE
;
2948 // If set x to CW_USEDEFAULT, y parameter is ignored anyhow so we can
2949 // just as well set it to CW_USEDEFAULT as well
2950 rnX
= rnY
= CW_USEDEFAULT
;
2955 rnY
= rPos
.y
== -1 ? CW_USEDEFAULT
: rPos
.y
;
2961 // As abobe, h is not used at all in this case anyhow
2963 rnWidth
= rnHeight
= CW_USEDEFAULT
;
2968 rnHeight
= rSize
.y
== -1 ? CW_USEDEFAULT
: rSize
.y
;
2972 } // end of wxWindowOS2::OS2GetCreateWindowCoords
2974 bool wxWindowOS2::OS2Create(
2976 , const char* zTitle
2978 , const wxPoint
& rPos
2979 , const wxSize
& rSize
2991 wxWindow
* pParent
= GetParent();
2992 HWND hWnd
= NULLHANDLE
;
2994 long lControlId
= 0L;
2995 wxWindowCreationHook
vHook(this);
2996 wxString
sClassName((wxChar
*)zClass
);
2998 OS2GetCreateWindowCoords( rPos
3006 if (GetWindowStyleFlag() & wxPOPUP_WINDOW
)
3007 hParent
= HWND_DESKTOP
;
3010 if ((bIsChild
|| HasFlag(wxFRAME_TOOL_WINDOW
)) && pParent
)
3013 // This is either a normal child window or a top level window with
3014 // wxFRAME_TOOL_WINDOW style (see below)
3016 hParent
= GetHwndOf(pParent
);
3021 // This is either a window for which no parent was specified (not
3022 // much we can do then) or a frame without wxFRAME_TOOL_WINDOW
3023 // style: we should use NULL parent HWND for it or it would be
3024 // always on top of its parent which is not what we usually want
3025 // (in fact, we only want it for frames with the special
3026 // wxFRAME_TOOL_WINDOW as above)
3033 lControlId
= GetId();
3034 if (GetWindowStyleFlag() & wxCLIP_SIBLINGS
)
3036 dwStyle
|= WS_CLIPSIBLINGS
;
3040 // For each class "Foo" we have we also have "FooNR" ("no repaint") class
3041 // which is the same but without CS_[HV]REDRAW class styles so using it
3042 // ensures that the window is not fully repainted on each resize
3044 if (GetWindowStyleFlag() & wxNO_FULL_REPAINT_ON_RESIZE
)
3046 sClassName
+= wxT("NR");
3050 // If the window being created is a Frame's Statusbar we need to use
3051 // the actual Frame's size, not its client
3055 if ( pParent
->IsKindOf(CLASSINFO(wxGenericScrolledWindow
)) ||
3056 pParent
->IsKindOf(CLASSINFO(wxScrolledWindow
))
3059 if (IsKindOf(CLASSINFO(wxStatusBar
)) &&
3060 pParent
->IsKindOf(CLASSINFO(wxFrame
)))
3063 wxFrame
* pFrame
= wxDynamicCast(pParent
, wxFrame
);
3065 ::WinQueryWindowRect((HWND
)pFrame
->GetFrame(), &vRect
);
3066 nY
= vRect
.yTop
- (nY
+ nHeight
);
3069 nY
= pParent
->GetSize().y
- (nY
+ nHeight
);
3076 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
3077 nY
= vRect
.yTop
- (nY
+ nHeight
);
3079 m_hWnd
= (WXHWND
)::WinCreateWindow( (HWND
)hParent
3080 ,(PSZ
)sClassName
.c_str()
3081 ,(PSZ
)zTitle
? zTitle
: ""
3095 vError
= ::WinGetLastError(wxGetInstance());
3096 sError
= wxPMErrorToStr(vError
);
3099 SubclassWin(m_hWnd
);
3100 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
3107 } // end of WinGuiBase_Window::OS2Create
3109 // ===========================================================================
3110 // OS2 PM message handlers
3111 // ===========================================================================
3113 // ---------------------------------------------------------------------------
3114 // window creation/destruction
3115 // ---------------------------------------------------------------------------
3117 bool wxWindowOS2::HandleCreate(
3118 WXLPCREATESTRUCT
WXUNUSED(vCs
)
3122 wxWindowCreateEvent
vEvent((wxWindow
*)this);
3124 (void)GetEventHandler()->ProcessEvent(vEvent
);
3125 *pbMayCreate
= TRUE
;
3127 } // end of wxWindowOS2::HandleCreate
3129 bool wxWindowOS2::HandleDestroy()
3131 wxWindowDestroyEvent
vEvent((wxWindow
*)this);
3133 (void)GetEventHandler()->ProcessEvent(vEvent
);
3136 // Delete our drop target if we've got one
3138 #if wxUSE_DRAG_AND_DROP
3139 if (m_dropTarget
!= NULL
)
3141 m_dropTarget
->Revoke(m_hWnd
);
3142 delete m_dropTarget
;
3143 m_dropTarget
= NULL
;
3145 #endif // wxUSE_DRAG_AND_DROP
3148 // WM_DESTROY handled
3151 } // end of wxWindowOS2::HandleDestroy
3153 // ---------------------------------------------------------------------------
3155 // ---------------------------------------------------------------------------
3156 void wxWindowOS2::OnSetFocus(
3157 wxFocusEvent
& rEvent
3161 } // end of wxWindowOS2::OnSetFocus
3163 bool wxWindowOS2::HandleActivate(
3165 , WXHWND
WXUNUSED(hActivate
)
3168 wxActivateEvent
vEvent( wxEVT_ACTIVATE
3172 vEvent
.SetEventObject(this);
3173 return GetEventHandler()->ProcessEvent(vEvent
);
3174 } // end of wxWindowOS2::HandleActivate
3176 bool wxWindowOS2::HandleSetFocus(
3177 WXHWND
WXUNUSED(hWnd
)
3181 // Notify the parent keeping track of focus for the kbd navigation
3182 // purposes that we got it
3184 wxChildFocusEvent
vEventFocus((wxWindow
*)this);
3185 (void)GetEventHandler()->ProcessEvent(vEventFocus
);
3193 m_caret
->OnSetFocus();
3195 #endif // wxUSE_CARET
3198 // If it's a wxTextCtrl don't send the event as it will be done
3199 // after the control gets to process it from EN_FOCUS handler
3200 if ( wxDynamicCastThis(wxTextCtrl
) )
3204 #endif // wxUSE_TEXTCTRL
3206 wxFocusEvent
vEvent(wxEVT_SET_FOCUS
, m_windowId
);
3208 vEvent
.SetEventObject(this);
3209 return GetEventHandler()->ProcessEvent(vEvent
);
3210 } // end of wxWindowOS2::HandleSetFocus
3212 bool wxWindowOS2::HandleKillFocus(
3213 WXHWND
WXUNUSED(hWnd
)
3222 m_caret
->OnKillFocus();
3224 #endif // wxUSE_CARET
3226 wxFocusEvent
vEvent( wxEVT_KILL_FOCUS
3230 vEvent
.SetEventObject(this);
3231 return GetEventHandler()->ProcessEvent(vEvent
);
3232 } // end of wxWindowOS2::HandleKillFocus
3234 // ---------------------------------------------------------------------------
3236 // ---------------------------------------------------------------------------
3238 bool wxWindowOS2::HandleShow(
3240 , int WXUNUSED(nStatus
)
3243 wxShowEvent
vEvent(GetId(), bShow
);
3245 vEvent
.m_eventObject
= this;
3246 return GetEventHandler()->ProcessEvent(vEvent
);
3247 } // end of wxWindowOS2::HandleShow
3249 bool wxWindowOS2::HandleInitDialog(
3250 WXHWND
WXUNUSED(hWndFocus
)
3253 wxInitDialogEvent
vEvent(GetId());
3255 vEvent
.m_eventObject
= this;
3256 return GetEventHandler()->ProcessEvent(vEvent
);
3257 } // end of wxWindowOS2::HandleInitDialog
3259 bool wxWindowOS2::HandleEndDrag(WXWPARAM
WXUNUSED(wParam
))
3261 // TODO: We'll handle drag and drop later
3265 bool wxWindowOS2::HandleSetCursor(
3266 USHORT
WXUNUSED(vId
)
3271 // Under OS/2 PM this allows the pointer to be changed
3272 // as it passes over a control
3274 ::WinSetPointer(HWND_DESKTOP
, (HPOINTER
)hPointer
);
3276 } // end of wxWindowOS2::HandleSetCursor
3278 // ---------------------------------------------------------------------------
3279 // owner drawn stuff
3280 // ---------------------------------------------------------------------------
3281 bool wxWindowOS2::OS2OnDrawItem(
3283 , WXDRAWITEMSTRUCT
* pItemStruct
3286 #if wxUSE_OWNER_DRAWN
3289 #if wxUSE_MENUS_NATIVE
3291 // Is it a menu item?
3297 POWNERITEM pMeasureStruct
= (POWNERITEM
)pItemStruct
;
3298 wxFrame
* pFrame
= (wxFrame
*)this;
3299 wxMenuItem
* pMenuItem
= pFrame
->GetMenuBar()->FindItem(pMeasureStruct
->idItem
, pMeasureStruct
->hItem
);
3300 HDC hDC
= ::GpiQueryDevice(pMeasureStruct
->hps
);
3301 wxRect
vRect( pMeasureStruct
->rclItem
.xLeft
3302 ,pMeasureStruct
->rclItem
.yBottom
3303 ,pMeasureStruct
->rclItem
.xRight
- pMeasureStruct
->rclItem
.xLeft
3304 ,pMeasureStruct
->rclItem
.yTop
- pMeasureStruct
->rclItem
.yBottom
3309 vDc
.SetHPS(pMeasureStruct
->hps
);
3311 // Load the wxWindows Pallete and set to RGB mode
3313 if (!::GpiCreateLogColorTable( pMeasureStruct
->hps
3317 ,(LONG
)wxTheColourDatabase
->m_nSize
3318 ,(PLONG
)wxTheColourDatabase
->m_palTable
3321 vError
= ::WinGetLastError(vHabmain
);
3322 sError
= wxPMErrorToStr(vError
);
3323 wxLogError("Unable to set current color table. Error: %s\n", sError
);
3326 // Set the color table to RGB mode
3328 if (!::GpiCreateLogColorTable( pMeasureStruct
->hps
3336 vError
= ::WinGetLastError(vHabmain
);
3337 sError
= wxPMErrorToStr(vError
);
3338 wxLogError("Unable to set current color table. Error: %s\n", sError
);
3341 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
3347 if (pMeasureStruct
->fsAttribute
== pMeasureStruct
->fsAttributeOld
)
3350 // Entire Item needs to be redrawn (either it has reappeared from
3351 // behind another window or is being displayed for the first time
3353 eAction
= wxOwnerDrawn::wxODDrawAll
;
3355 if (pMeasureStruct
->fsAttribute
& MIA_HILITED
)
3358 // If it is currently selected we let the system handle it
3360 eStatus
|= wxOwnerDrawn::wxODSelected
;
3362 if (pMeasureStruct
->fsAttribute
& MIA_CHECKED
)
3365 // If it is currently checked we draw our own
3367 eStatus
|= wxOwnerDrawn::wxODChecked
;
3368 pMeasureStruct
->fsAttributeOld
= pMeasureStruct
->fsAttribute
&= ~MIA_CHECKED
;
3370 if (pMeasureStruct
->fsAttribute
& MIA_DISABLED
)
3373 // If it is currently disabled we let the system handle it
3375 eStatus
|= wxOwnerDrawn::wxODDisabled
;
3378 // Don't really care about framed (indicationg focus) or NoDismiss
3383 if (pMeasureStruct
->fsAttribute
& MIA_HILITED
)
3385 eAction
= wxOwnerDrawn::wxODDrawAll
;
3386 eStatus
|= wxOwnerDrawn::wxODSelected
;
3388 // Keep the system from trying to highlight with its bogus colors
3390 pMeasureStruct
->fsAttributeOld
= pMeasureStruct
->fsAttribute
&= ~MIA_HILITED
;
3392 else if (!(pMeasureStruct
->fsAttribute
& MIA_HILITED
))
3394 eAction
= wxOwnerDrawn::wxODDrawAll
;
3397 // Keep the system from trying to highlight with its bogus colors
3399 pMeasureStruct
->fsAttribute
= pMeasureStruct
->fsAttributeOld
&= ~MIA_HILITED
;
3404 // For now we don't care about anything else
3405 // just ignore the entire message!
3411 // Now redraw the item
3413 return(pMenuItem
->OnDrawItem( vDc
3415 ,(wxOwnerDrawn::wxODAction
)eAction
3416 ,(wxOwnerDrawn::wxODStatus
)eStatus
3419 // leave the fsAttribute and fsOldAttribute unchanged. If different,
3420 // the system will do the highlight or fraeming or disabling for us,
3421 // otherwise, we'd have to do it ourselves.
3424 #endif // wxUSE_MENUS_NATIVE
3426 wxWindow
* pItem
= FindItem(vId
);
3428 if (pItem
&& pItem
->IsKindOf(CLASSINFO(wxControl
)))
3430 return ((wxControl
*)pItem
)->OS2OnDraw(pItemStruct
);
3434 pItemStruct
= pItemStruct
;
3437 } // end of wxWindowOS2::OS2OnDrawItem
3439 bool wxWindowOS2::OS2OnMeasureItem(
3441 , WXMEASUREITEMSTRUCT
* pItemStruct
3444 #if wxUSE_OWNER_DRAWN
3446 // Is it a menu item?
3448 if (lId
== 65536) // I really don't like this...has to be a better indicator
3450 if (IsKindOf(CLASSINFO(wxFrame
))) // we'll assume if Frame then a menu
3454 POWNERITEM pMeasureStruct
= (POWNERITEM
)pItemStruct
;
3455 wxFrame
* pFrame
= (wxFrame
*)this;
3456 wxMenuItem
* pMenuItem
= pFrame
->GetMenuBar()->FindItem(pMeasureStruct
->idItem
, pMeasureStruct
->hItem
);
3458 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
3461 if (pMenuItem
->OnMeasureItem( &nWidth
3465 pMeasureStruct
->rclItem
.xRight
= nWidth
;
3466 pMeasureStruct
->rclItem
.xLeft
= 0L;
3467 pMeasureStruct
->rclItem
.yTop
= nHeight
;
3468 pMeasureStruct
->rclItem
.yBottom
= 0L;
3474 wxWindow
* pItem
= FindItem(lId
);
3476 if (pItem
&& pItem
->IsKindOf(CLASSINFO(wxControl
)))
3478 return ((wxControl
*)pItem
)->OS2OnMeasure(pItemStruct
);
3482 pItemStruct
= pItemStruct
;
3483 #endif // wxUSE_OWNER_DRAWN
3487 // ---------------------------------------------------------------------------
3488 // colours and palettes
3489 // ---------------------------------------------------------------------------
3491 bool wxWindowOS2::HandleSysColorChange()
3493 wxSysColourChangedEvent vEvent
;
3495 vEvent
.SetEventObject(this);
3496 return GetEventHandler()->ProcessEvent(vEvent
);
3497 } // end of wxWindowOS2::HandleSysColorChange
3499 bool wxWindowOS2::HandleCtlColor(
3500 WXHBRUSH
* WXUNUSED(phBrush
)
3504 // Not much provided with message. So not sure I can do anything with it
3507 } // end of wxWindowOS2::HandleCtlColor
3510 // Define for each class of dialog and control
3511 WXHBRUSH
wxWindowOS2::OnCtlColor(WXHDC
WXUNUSED(hDC
),
3512 WXHWND
WXUNUSED(hWnd
),
3513 WXUINT
WXUNUSED(nCtlColor
),
3514 WXUINT
WXUNUSED(message
),
3515 WXWPARAM
WXUNUSED(wParam
),
3516 WXLPARAM
WXUNUSED(lParam
))
3521 bool wxWindowOS2::HandlePaletteChanged()
3523 // need to set this to something first
3524 WXHWND hWndPalChange
= NULLHANDLE
;
3526 wxPaletteChangedEvent
vEvent(GetId());
3528 vEvent
.SetEventObject(this);
3529 vEvent
.SetChangedWindow(wxFindWinFromHandle(hWndPalChange
));
3531 return GetEventHandler()->ProcessEvent(vEvent
);
3532 } // end of wxWindowOS2::HandlePaletteChanged
3535 // Responds to colour changes: passes event on to children.
3537 void wxWindowOS2::OnSysColourChanged(
3538 wxSysColourChangedEvent
& rEvent
3541 wxNode
* pNode
= GetChildren().First();
3546 // Only propagate to non-top-level windows
3548 wxWindow
* pWin
= (wxWindow
*)pNode
->Data();
3550 if (pWin
->GetParent())
3552 wxSysColourChangedEvent vEvent
;
3554 rEvent
.m_eventObject
= pWin
;
3555 pWin
->GetEventHandler()->ProcessEvent(vEvent
);
3557 pNode
= pNode
->Next();
3559 } // end of wxWindowOS2::OnSysColourChanged
3561 // ---------------------------------------------------------------------------
3563 // ---------------------------------------------------------------------------
3565 bool wxWindowOS2::HandlePaint()
3568 wxPaintEvent
vEvent(m_windowId
);
3573 // Create empty region
3574 // TODO: get HPS somewhere else if possible
3575 hPS
= ::WinGetPS(GetHwnd());
3576 hRgn
= ::GpiCreateRegion(hPS
, 0, NULL
);
3578 if (::WinQueryUpdateRegion(GetHwnd(), hRgn
) == RGN_ERROR
)
3580 wxLogLastError("CreateRectRgn");
3584 m_updateRegion
= wxRegion(hRgn
, hPS
);
3586 vEvent
.SetEventObject(this);
3587 bProcessed
= GetEventHandler()->ProcessEvent(vEvent
);
3589 return GetEventHandler()->ProcessEvent(vEvent
); //bProcessed;
3590 } // end of wxWindowOS2::HandlePaint
3592 bool wxWindowOS2::HandleEraseBkgnd(
3599 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
3600 if (vSwp
.fl
& SWP_MINIMIZE
)
3605 vDC
.m_hPS
= (HPS
)hDC
; // this is really a PS
3606 vDC
.SetWindow((wxWindow
*)this);
3609 wxEraseEvent
vEvent(m_windowId
, &vDC
);
3611 vEvent
.SetEventObject(this);
3613 rc
= GetEventHandler()->ProcessEvent(vEvent
);
3616 vDC
.m_hPS
= NULLHANDLE
;
3618 } // end of wxWindowOS2::HandleEraseBkgnd
3620 void wxWindowOS2::OnEraseBackground(
3621 wxEraseEvent
& rEvent
3625 HPS hPS
= rEvent
.m_dc
->m_hPS
;
3627 LONG lColor
= m_backgroundColour
.GetPixel();
3629 rc
= ::WinQueryWindowRect(GetHwnd(), &vRect
);
3630 rc
= ::WinFillRect(hPS
, &vRect
, lColor
);
3631 } // end of wxWindowOS2::OnEraseBackground
3633 // ---------------------------------------------------------------------------
3634 // moving and resizing
3635 // ---------------------------------------------------------------------------
3637 bool wxWindowOS2::HandleMinimize()
3639 wxIconizeEvent
vEvent(m_windowId
);
3641 vEvent
.SetEventObject(this);
3642 return GetEventHandler()->ProcessEvent(vEvent
);
3643 } // end of wxWindowOS2::HandleMinimize
3645 bool wxWindowOS2::HandleMaximize()
3647 wxMaximizeEvent
vEvent(m_windowId
);
3649 vEvent
.SetEventObject(this);
3650 return GetEventHandler()->ProcessEvent(vEvent
);
3651 } // end of wxWindowOS2::HandleMaximize
3653 bool wxWindowOS2::HandleMove(
3658 wxMoveEvent
vEvent(wxPoint(nX
, nY
), m_windowId
);
3660 vEvent
.SetEventObject(this);
3661 return GetEventHandler()->ProcessEvent(vEvent
);
3662 } // end of wxWindowOS2::HandleMove
3664 bool wxWindowOS2::HandleSize(
3667 , WXUINT
WXUNUSED(nFlag
)
3670 wxSizeEvent
vEvent(wxSize(nWidth
, nHeight
), m_windowId
);
3672 vEvent
.SetEventObject(this);
3673 return GetEventHandler()->ProcessEvent(vEvent
);
3674 } // end of wxWindowOS2::HandleSize
3676 bool wxWindowOS2::HandleGetMinMaxInfo(
3686 ::WinGetMaxPosition(GetHwnd(), pSwp
);
3687 m_maxWidth
= pSwp
->cx
;
3688 m_maxHeight
= pSwp
->cy
;
3692 ::WinGetMinPosition(GetHwnd(), pSwp
, &vPoint
);
3693 m_minWidth
= pSwp
->cx
;
3694 m_minHeight
= pSwp
->cy
;
3701 } // end of wxWindowOS2::HandleGetMinMaxInfo
3703 // ---------------------------------------------------------------------------
3705 // ---------------------------------------------------------------------------
3706 bool wxWindowOS2::HandleCommand(
3712 #if wxUSE_MENUS_NATIVE
3713 if (wxCurrentPopupMenu
)
3715 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
3717 wxCurrentPopupMenu
= NULL
;
3718 return pPopupMenu
->OS2Command(wCmd
, wId
);
3720 #endif // wxUSE_MENUS_NATIVE
3722 wxWindow
* pWin
= FindItem(wId
);
3726 pWin
= wxFindWinFromHandle(hControl
);
3730 return pWin
->OS2Command(wCmd
, wId
);
3733 } // end of wxWindowOS2::HandleCommand
3735 bool wxWindowOS2::HandleSysCommand(
3737 , WXLPARAM
WXUNUSED(lParam
)
3741 // 4 bits are reserved
3743 switch (SHORT1FROMMP(wParam
))
3746 return HandleMaximize();
3749 return HandleMinimize();
3752 } // end of wxWindowOS2::HandleSysCommand
3754 // ---------------------------------------------------------------------------
3756 // ---------------------------------------------------------------------------
3757 //TODO!!! check against MSW
3758 void wxWindowOS2::InitMouseEvent(
3759 wxMouseEvent
& rEvent
3767 rEvent
.m_shiftDown
= ((uFlags
& VK_SHIFT
) != 0);
3768 rEvent
.m_controlDown
= ((uFlags
& VK_CTRL
) != 0);
3769 rEvent
.m_leftDown
= ((uFlags
& VK_BUTTON1
) != 0);
3770 rEvent
.m_middleDown
= ((uFlags
& VK_BUTTON3
) != 0);
3771 rEvent
.m_rightDown
= ((uFlags
& VK_BUTTON2
) != 0);
3772 rEvent
.SetTimestamp(s_currentMsg
.time
);
3773 rEvent
.m_eventObject
= this;
3775 #if wxUSE_MOUSEEVENT_HACK
3778 m_lastMouseEvent
= rEvent
.GetEventType();
3779 #endif // wxUSE_MOUSEEVENT_HACK
3780 } // end of wxWindowOS2::InitMouseEvent
3782 bool wxWindowOS2::HandleMouseEvent(
3790 // The mouse events take consecutive IDs from WM_MOUSEFIRST to
3791 // WM_MOUSELAST, so it's enough to substract WM_MOUSEMOVE == WM_MOUSEFIRST
3792 // from the message id and take the value in the table to get wxWin event
3795 static const wxEventType eventsMouse
[] =
3809 wxMouseEvent
vEvent(eventsMouse
[uMsg
- WM_MOUSEMOVE
]);
3811 InitMouseEvent( vEvent
3817 return GetEventHandler()->ProcessEvent(vEvent
);
3818 } // end of wxWindowOS2::HandleMouseEvent
3820 bool wxWindowOS2::HandleMouseMove(
3826 if (!m_bMouseInWindow
)
3829 // Generate an ENTER event
3831 m_bMouseInWindow
= TRUE
;
3833 wxMouseEvent
vEvent(wxEVT_ENTER_WINDOW
);
3835 InitMouseEvent( vEvent
3841 (void)GetEventHandler()->ProcessEvent(vEvent
);
3843 return HandleMouseEvent( WM_MOUSEMOVE
3848 } // end of wxWindowOS2::HandleMouseMove
3850 // ---------------------------------------------------------------------------
3851 // keyboard handling
3852 // ---------------------------------------------------------------------------
3855 // Create the key event of the given type for the given key - used by
3856 // HandleChar and HandleKeyDown/Up
3858 wxKeyEvent
wxWindowOS2::CreateKeyEvent(
3864 wxKeyEvent
vEvent(eType
);
3866 vEvent
.SetId(GetId());
3867 vEvent
.m_shiftDown
= IsShiftDown();
3868 vEvent
.m_controlDown
= IsCtrlDown();
3869 vEvent
.m_altDown
= (HIWORD(lParam
) & KC_ALT
) == KC_ALT
;
3871 vEvent
.m_eventObject
= (wxWindow
*)this; // const_cast
3872 vEvent
.m_keyCode
= nId
;
3873 vEvent
.SetTimestamp(s_currentMsg
.time
);
3876 // Translate the position to client coords
3881 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
3882 ::WinQueryWindowRect( GetHwnd()
3886 vPoint
.x
-= vRect
.xLeft
;
3887 vPoint
.y
-= vRect
.yBottom
;
3889 vEvent
.m_x
= vPoint
.x
;
3890 vEvent
.m_y
= vPoint
.y
;
3893 } // end of wxWindowOS2::CreateKeyEvent
3896 // isASCII is TRUE only when we're called from WM_CHAR handler and not from
3899 bool wxWindowOS2::HandleChar(
3905 bool bCtrlDown
= FALSE
;
3911 // If 1 -> 26, translate to CTRL plus a letter.
3914 if ((vId
> 0) && (vId
< 27))
3936 else if ( (vId
= wxCharCodeOS2ToWX(wParam
)) == 0)
3939 // It's ASCII and will be processed here only when called from
3940 // WM_CHAR (i.e. when isASCII = TRUE), don't process it now
3947 wxKeyEvent
vEvent(CreateKeyEvent( wxEVT_CHAR
3954 vEvent
.m_controlDown
= TRUE
;
3957 if (GetEventHandler()->ProcessEvent(vEvent
))
3963 bool wxWindowOS2::HandleKeyDown(
3968 int nId
= wxCharCodeOS2ToWX(wParam
);
3973 // Normal ASCII char
3980 wxKeyEvent
vEvent(CreateKeyEvent( wxEVT_KEY_DOWN
3985 if (GetEventHandler()->ProcessEvent(vEvent
))
3991 } // end of wxWindowOS2::HandleKeyDown
3993 bool wxWindowOS2::HandleKeyUp(
3998 int nId
= wxCharCodeOS2ToWX(wParam
);
4003 // Normal ASCII char
4010 wxKeyEvent
vEvent(CreateKeyEvent( wxEVT_KEY_UP
4015 if (GetEventHandler()->ProcessEvent(vEvent
))
4019 } // end of wxWindowOS2::HandleKeyUp
4021 // ---------------------------------------------------------------------------
4023 // ---------------------------------------------------------------------------
4025 // ---------------------------------------------------------------------------
4027 // ---------------------------------------------------------------------------
4029 bool wxWindowOS2::OS2OnScroll(
4038 wxWindow
* pChild
= wxFindWinFromHandle(hControl
);
4041 return pChild
->OS2OnScroll( nOrientation
4048 wxScrollWinEvent vEvent
;
4050 vEvent
.SetPosition(wPos
);
4051 vEvent
.SetOrientation(nOrientation
);
4052 vEvent
.m_eventObject
= this;
4057 vEvent
.m_eventType
= wxEVT_SCROLLWIN_LINEUP
;
4061 vEvent
.m_eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
4065 vEvent
.m_eventType
= wxEVT_SCROLLWIN_PAGEUP
;
4069 vEvent
.m_eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
4072 case SB_SLIDERPOSITION
:
4073 vEvent
.m_eventType
= wxEVT_SCROLLWIN_THUMBRELEASE
;
4076 case SB_SLIDERTRACK
:
4077 vEvent
.m_eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
4083 return GetEventHandler()->ProcessEvent(vEvent
);
4084 } // end of wxWindowOS2::OS2OnScroll
4086 void wxWindowOS2::MoveChildren(
4092 for (wxWindowList::Node
* pNode
= GetChildren().GetFirst();
4094 pNode
= pNode
->GetNext())
4096 wxWindow
* pWin
= pNode
->GetData();
4098 ::WinQueryWindowPos( GetHwndOf(pWin
)
4101 if (pWin
->IsKindOf(CLASSINFO(wxControl
)))
4106 // Must deal with controls that have margins like ENTRYFIELD. The SWP
4107 // struct of such a control will have and origin offset from its intended
4108 // position by the width of the margins.
4110 pCtrl
= wxDynamicCast(pWin
, wxControl
);
4111 vSwp
.y
-= pCtrl
->GetYComp();
4112 vSwp
.x
-= pCtrl
->GetXComp();
4114 ::WinSetWindowPos( GetHwndOf(pWin
)
4120 ,SWP_MOVE
| SWP_ZORDER
4122 ::WinQueryWindowPos(GetHwndOf(pWin
), pWin
->GetSwp());
4123 if (pWin
->IsKindOf(CLASSINFO(wxRadioBox
)))
4125 wxRadioBox
* pRadioBox
;
4127 pRadioBox
= wxDynamicCast(pWin
, wxRadioBox
);
4128 pRadioBox
->AdjustButtons( (int)vSwp
.x
4129 ,(int)vSwp
.y
- nDiff
4132 ,pRadioBox
->GetSizeFlags()
4135 if (pWin
->IsKindOf(CLASSINFO(wxSlider
)))
4139 pSlider
= wxDynamicCast(pWin
, wxSlider
);
4140 pSlider
->AdjustSubControls( (int)vSwp
.x
4141 ,(int)vSwp
.y
- nDiff
4144 ,(int)pSlider
->GetSizeFlags()
4148 } // end of wxWindowOS2::MoveChildren
4151 // Getting the Y position for a window, like a control, is a real
4152 // pain. There are three sitatuions we must deal with in determining
4153 // the OS2 to wxWindows Y coordinate.
4155 // 1) The controls are created in a dialog.
4156 // This is the easiest since a dialog is created with its original
4157 // size so the standard: Y = ParentHeight - (Y + ControlHeight);
4159 // 2) The controls are direct children of a frame
4160 // In this instance the controls are actually children of the Frame's
4161 // client. During creation the frame's client resizes several times
4162 // during creation of the status bar and toolbars. The CFrame class
4163 // will take care of this using its AlterChildPos proc.
4165 // 3) The controls are children of a panel, which in turn is a child of
4167 // The panel may be one of many, in which case the same treatment
4168 // as 1 applies. It may be the only child, though.
4169 // This is the nastiest case. A panel is created as the only child of
4170 // the frame and as such, when a frame has only one child, the child is
4171 // expanded to fit the entire client area of the frame. Because the
4172 // controls are created BEFORE this occurs their positions are totally
4173 // whacked and any call to WinQueryWindowPos will return invalid
4174 // coordinates. So for this situation we have to compare the size of
4175 // the panel at control creation time with that of the frame client. If
4176 // they are the same we can use the standard Y position equation. If
4177 // not, then we must use the Frame Client's dimensions to position them
4178 // as that will be the eventual size of the panel after the frame resizes
4181 int wxWindowOS2::GetOS2ParentHeight(
4182 wxWindowOS2
* pParent
4185 wxWindowOS2
* pGrandParent
= NULL
;
4190 if (pParent
->IsKindOf(CLASSINFO(wxDialog
)))
4191 return(pParent
->GetClientSize().y
);
4194 // Case 2 -- if we are one of the separately built standard Frame
4195 // children, like a statusbar, menubar, or toolbar we want to
4196 // use the frame, itself, for positioning. Otherwise we are
4197 // child window and want to use the Frame's client.
4199 else if (pParent
->IsKindOf(CLASSINFO(wxFrame
)))
4201 if (IsKindOf(CLASSINFO(wxStatusBar
)) ||
4202 IsKindOf(CLASSINFO(wxMenuBar
)) ||
4203 IsKindOf(CLASSINFO(wxToolBar
))
4205 return(pParent
->GetSize().y
);
4207 return(pParent
->GetClientSize().y
);
4210 // Case 3a -- One of many Frame children. Will be positioned normally
4212 else if (pParent
->GetChildren().GetCount() > 1)
4213 return(pParent
->GetClientSize().y
);
4215 // Case 3b -- this is for any window that is the sole child of a Frame.
4216 // The grandparent must exist and it must be of type CFrame
4217 // and it's height must be different. Otherwise the standard
4222 pGrandParent
= pParent
->GetParent();
4224 pGrandParent
->IsKindOf(CLASSINFO(wxFrame
)) &&
4225 pGrandParent
->GetClientSize().y
!= pParent
->GetSize().y
4228 int nParentHeight
= 0L;
4229 int nStatusBarHeight
= 0L;
4230 wxFrame
* pFrame
= wxDynamicCast(pGrandParent
, wxFrame
);
4231 wxStatusBar
* pStatbar
= pFrame
->GetStatusBar();
4233 nParentHeight
= pGrandParent
->GetClientSize().y
;
4235 nStatusBarHeight
= pStatbar
->GetSize().y
;
4236 nParentHeight
-= nStatusBarHeight
;
4237 return(nParentHeight
);
4241 // Panel is a child of some other kind of window so we'll
4242 // just use it's original size
4244 return(pParent
->GetClientSize().y
);
4247 } // end of wxWindowOS2::GetOS2ParentHeight
4250 // OS/2 needs a lot extra manipulation to deal with layouts
4251 // for canvas windows, particularly scrolled ones.
4253 wxWindowCreationHook::wxWindowCreationHook(
4254 wxWindow
* pWinBeingCreated
4257 gpWinBeingCreated
= pWinBeingCreated
;
4258 } // end of wxWindowCreationHook::wxWindowCreationHook
4260 wxWindowCreationHook::~wxWindowCreationHook()
4262 gpWinBeingCreated
= NULL
;
4263 } // end of wxWindowCreationHook::~wxWindowCreationHook
4265 // ===========================================================================
4267 // ===========================================================================
4273 ,wxFont
* WXUNUSED(pTheFont
)
4280 hPS
=::WinGetPS(hWnd
);
4282 rc
= ::GpiQueryFontMetrics(hPS
, sizeof(FONTMETRICS
), &vFM
);
4286 *pX
= vFM
.lAveCharWidth
;
4288 *pY
= vFM
.lEmHeight
+ vFM
.lExternalLeading
;
4297 ::WinReleasePS(hPS
);
4298 } // end of wxGetCharSize
4301 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
4302 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
4304 int wxCharCodeOS2ToWX(
4312 case VK_BACKTAB
: nId
= WXK_BACK
; break;
4313 case VK_TAB
: nId
= WXK_TAB
; break;
4314 case VK_CLEAR
: nId
= WXK_CLEAR
; break;
4315 case VK_ENTER
: nId
= WXK_RETURN
; break;
4316 case VK_SHIFT
: nId
= WXK_SHIFT
; break;
4317 case VK_CTRL
: nId
= WXK_CONTROL
; break;
4318 case VK_PAUSE
: nId
= WXK_PAUSE
; break;
4319 case VK_SPACE
: nId
= WXK_SPACE
; break;
4320 case VK_ESC
: nId
= WXK_ESCAPE
; break;
4321 case VK_END
: nId
= WXK_END
; break;
4322 case VK_HOME
: nId
= WXK_HOME
; break;
4323 case VK_LEFT
: nId
= WXK_LEFT
; break;
4324 case VK_UP
: nId
= WXK_UP
; break;
4325 case VK_RIGHT
: nId
= WXK_RIGHT
; break;
4326 case VK_DOWN
: nId
= WXK_DOWN
; break;
4327 case VK_PRINTSCRN
: nId
= WXK_PRINT
; break;
4328 case VK_INSERT
: nId
= WXK_INSERT
; break;
4329 case VK_DELETE
: nId
= WXK_DELETE
; break;
4330 case VK_F1
: nId
= WXK_F1
; break;
4331 case VK_F2
: nId
= WXK_F2
; break;
4332 case VK_F3
: nId
= WXK_F3
; break;
4333 case VK_F4
: nId
= WXK_F4
; break;
4334 case VK_F5
: nId
= WXK_F5
; break;
4335 case VK_F6
: nId
= WXK_F6
; break;
4336 case VK_F7
: nId
= WXK_F7
; break;
4337 case VK_F8
: nId
= WXK_F8
; break;
4338 case VK_F9
: nId
= WXK_F9
; break;
4339 case VK_F10
: nId
= WXK_F10
; break;
4340 case VK_F11
: nId
= WXK_F11
; break;
4341 case VK_F12
: nId
= WXK_F12
; break;
4342 case VK_F13
: nId
= WXK_F13
; break;
4343 case VK_F14
: nId
= WXK_F14
; break;
4344 case VK_F15
: nId
= WXK_F15
; break;
4345 case VK_F16
: nId
= WXK_F16
; break;
4346 case VK_F17
: nId
= WXK_F17
; break;
4347 case VK_F18
: nId
= WXK_F18
; break;
4348 case VK_F19
: nId
= WXK_F19
; break;
4349 case VK_F20
: nId
= WXK_F20
; break;
4350 case VK_F21
: nId
= WXK_F21
; break;
4351 case VK_F22
: nId
= WXK_F22
; break;
4352 case VK_F23
: nId
= WXK_F23
; break;
4353 case VK_F24
: nId
= WXK_F24
; break;
4354 case VK_NUMLOCK
: nId
= WXK_NUMLOCK
; break;
4355 case VK_SCRLLOCK
: nId
= WXK_SCROLL
; break;
4362 } // end of wxCharCodeOS2ToWX
4364 int wxCharCodeWXToOS2(
4374 case WXK_CLEAR
: nKeySym
= VK_CLEAR
; break;
4375 case WXK_SHIFT
: nKeySym
= VK_SHIFT
; break;
4376 case WXK_CONTROL
: nKeySym
= VK_CTRL
; break;
4377 case WXK_PAUSE
: nKeySym
= VK_PAUSE
; break;
4378 case WXK_END
: nKeySym
= VK_END
; break;
4379 case WXK_HOME
: nKeySym
= VK_HOME
; break;
4380 case WXK_LEFT
: nKeySym
= VK_LEFT
; break;
4381 case WXK_UP
: nKeySym
= VK_UP
; break;
4382 case WXK_RIGHT
: nKeySym
= VK_RIGHT
; break;
4383 case WXK_DOWN
: nKeySym
= VK_DOWN
; break;
4384 case WXK_PRINT
: nKeySym
= VK_PRINTSCRN
; break;
4385 case WXK_INSERT
: nKeySym
= VK_INSERT
; break;
4386 case WXK_DELETE
: nKeySym
= VK_DELETE
; break;
4387 case WXK_F1
: nKeySym
= VK_F1
; break;
4388 case WXK_F2
: nKeySym
= VK_F2
; break;
4389 case WXK_F3
: nKeySym
= VK_F3
; break;
4390 case WXK_F4
: nKeySym
= VK_F4
; break;
4391 case WXK_F5
: nKeySym
= VK_F5
; break;
4392 case WXK_F6
: nKeySym
= VK_F6
; break;
4393 case WXK_F7
: nKeySym
= VK_F7
; break;
4394 case WXK_F8
: nKeySym
= VK_F8
; break;
4395 case WXK_F9
: nKeySym
= VK_F9
; break;
4396 case WXK_F10
: nKeySym
= VK_F10
; break;
4397 case WXK_F11
: nKeySym
= VK_F11
; break;
4398 case WXK_F12
: nKeySym
= VK_F12
; break;
4399 case WXK_F13
: nKeySym
= VK_F13
; break;
4400 case WXK_F14
: nKeySym
= VK_F14
; break;
4401 case WXK_F15
: nKeySym
= VK_F15
; break;
4402 case WXK_F16
: nKeySym
= VK_F16
; break;
4403 case WXK_F17
: nKeySym
= VK_F17
; break;
4404 case WXK_F18
: nKeySym
= VK_F18
; break;
4405 case WXK_F19
: nKeySym
= VK_F19
; break;
4406 case WXK_F20
: nKeySym
= VK_F20
; break;
4407 case WXK_F21
: nKeySym
= VK_F21
; break;
4408 case WXK_F22
: nKeySym
= VK_F22
; break;
4409 case WXK_F23
: nKeySym
= VK_F23
; break;
4410 case WXK_F24
: nKeySym
= VK_F24
; break;
4411 case WXK_NUMLOCK
: nKeySym
= VK_NUMLOCK
; break;
4412 case WXK_SCROLL
: nKeySym
= VK_SCRLLOCK
; break;
4415 *bIsVirtual
= FALSE
;
4421 } // end of wxCharCodeWXToOS2
4423 wxWindow
* wxGetActiveWindow()
4425 HWND hWnd
= ::WinQueryActiveWindow(HWND_DESKTOP
);
4429 return wxFindWinFromHandle((WXHWND
)hWnd
);
4432 } // end of wxGetActiveWindow
4435 const char* wxGetMessageName(
4440 case 0x0000: return "WM_NULL";
4441 case 0x0001: return "WM_CREATE";
4442 case 0x0002: return "WM_DESTROY";
4443 case 0x0004: return "WM_ENABLE";
4444 case 0x0005: return "WM_SHOW";
4445 case 0x0006: return "WM_MOVE";
4446 case 0x0007: return "WM_SIZE";
4447 case 0x0008: return "WM_ADJUSTWINDOWPOS";
4448 case 0x0009: return "WM_CALCVALIDRECTS";
4449 case 0x000A: return "WM_SETWINDOWPARAMS";
4450 case 0x000B: return "WM_QUERYWINDOWPARAMS";
4451 case 0x000C: return "WM_HITTEST";
4452 case 0x000D: return "WM_ACTIVATE";
4453 case 0x000F: return "WM_SETFOCUS";
4454 case 0x0010: return "WM_SETSELECTION";
4455 case 0x0011: return "WM_PPAINT";
4456 case 0x0012: return "WM_PSETFOCUS";
4457 case 0x0013: return "WM_PSYSCOLORCHANGE";
4458 case 0x0014: return "WM_PSIZE";
4459 case 0x0015: return "WM_PACTIVATE";
4460 case 0x0016: return "WM_PCONTROL";
4461 case 0x0020: return "WM_COMMAND";
4462 case 0x0021: return "WM_SYSCOMMAND";
4463 case 0x0022: return "WM_HELP";
4464 case 0x0023: return "WM_PAINT";
4465 case 0x0024: return "WM_TIMER";
4466 case 0x0025: return "WM_SEM1";
4467 case 0x0026: return "WM_SEM2";
4468 case 0x0027: return "WM_SEM3";
4469 case 0x0028: return "WM_SEM4";
4470 case 0x0029: return "WM_CLOSE";
4471 case 0x002A: return "WM_QUIT";
4472 case 0x002B: return "WM_SYSCOLORCHANGE";
4473 case 0x002D: return "WM_SYSVALUECHANGE";
4474 case 0x002E: return "WM_APPTERMINATENOTIFY";
4475 case 0x002F: return "WM_PRESPARAMCHANGED";
4476 // Control notification messages
4477 case 0x0030: return "WM_CONTROL";
4478 case 0x0031: return "WM_VSCROLL";
4479 case 0x0032: return "WM_HSCROLL";
4480 case 0x0033: return "WM_INITMENU";
4481 case 0x0034: return "WM_MENUSELECT";
4482 case 0x0035: return "WM_MENUSEND";
4483 case 0x0036: return "WM_DRAWITEM";
4484 case 0x0037: return "WM_MEASUREITEM";
4485 case 0x0038: return "WM_CONTROLPOINTER";
4486 case 0x003A: return "WM_QUERYDLGCODE";
4487 case 0x003B: return "WM_INITDLG";
4488 case 0x003C: return "WM_SUBSTITUTESTRING";
4489 case 0x003D: return "WM_MATCHMNEMONIC";
4490 case 0x003E: return "WM_SAVEAPPLICATION";
4491 case 0x0129: return "WM_CTLCOLORCHANGE";
4492 case 0x0130: return "WM_QUERYCTLTYPE";
4494 case 0x0040: return "WM_FLASHWINDOW";
4495 case 0x0041: return "WM_FORMATFRAME";
4496 case 0x0042: return "WM_UPDATEFRAME";
4497 case 0x0043: return "WM_FOCUSCHANGE";
4498 case 0x0044: return "WM_SETBORDERSIZE";
4499 case 0x0045: return "WM_TRACKFRAME";
4500 case 0x0046: return "WM_MINMAXFRAME";
4501 case 0x0047: return "WM_SETICON";
4502 case 0x0048: return "WM_QUERYICON";
4503 case 0x0049: return "WM_SETACCELTABLE";
4504 case 0x004A: return "WM_QUERYACCELTABLE";
4505 case 0x004B: return "WM_TRANSLATEACCEL";
4506 case 0x004C: return "WM_QUERYTRACKINFO";
4507 case 0x004D: return "WM_QUERYBORDERSIZE";
4508 case 0x004E: return "WM_NEXTMENU";
4509 case 0x004F: return "WM_ERASEBACKGROUND";
4510 case 0x0050: return "WM_QUERYFRAMEINFO";
4511 case 0x0051: return "WM_QUERYFOCUSCHAIN";
4512 case 0x0052: return "WM_OWNERPOSCHANGE";
4513 case 0x0053: return "WM_CACLFRAMERECT";
4514 case 0x0055: return "WM_WINDOWPOSCHANGED";
4515 case 0x0056: return "WM_ADJUSTFRAMEPOS";
4516 case 0x0059: return "WM_QUERYFRAMECTLCOUNT";
4517 case 0x005B: return "WM_QUERYHELPINFO";
4518 case 0x005C: return "WM_SETHELPINFO";
4519 case 0x005D: return "WM_ERROR";
4520 case 0x005E: return "WM_REALIZEPALETTE";
4521 // Clipboard messages
4522 case 0x0060: return "WM_RENDERFMT";
4523 case 0x0061: return "WM_RENDERALLFMTS";
4524 case 0x0062: return "WM_DESTROYCLIPBOARD";
4525 case 0x0063: return "WM_PAINTCLIPBOARD";
4526 case 0x0064: return "WM_SIZECLIPBOARD";
4527 case 0x0065: return "WM_HSCROLLCLIPBOARD";
4528 case 0x0066: return "WM_VSCROLLCLIPBOARD";
4529 case 0x0067: return "WM_DRAWCLIPBOARD";
4531 case 0x0070: return "WM_MOUSEMOVE";
4532 case 0x0071: return "WM_BUTTON1DOWN";
4533 case 0x0072: return "WM_BUTTON1UP";
4534 case 0x0073: return "WM_BUTTON1DBLCLK";
4535 case 0x0074: return "WM_BUTTON2DOWN";
4536 case 0x0075: return "WM_BUTTON2UP";
4537 case 0x0076: return "WM_BUTTON2DBLCLK";
4538 case 0x0077: return "WM_BUTTON3DOWN";
4539 case 0x0078: return "WM_BUTTON3UP";
4540 case 0x0079: return "WM_BUTTON3DBLCLK";
4541 case 0x007D: return "WM_MOUSEMAP";
4542 case 0x007E: return "WM_VRNDISABLED";
4543 case 0x007F: return "WM_VRNENABLED";
4544 case 0x0410: return "WM_CHORD";
4545 case 0x0411: return "WM_BUTTON1MOTIONSTART";
4546 case 0x0412: return "WM_BUTTON1MOTIONEND";
4547 case 0x0413: return "WM_BUTTON1CLICK";
4548 case 0x0414: return "WM_BUTTON2MOTIONSTART";
4549 case 0x0415: return "WM_BUTTON2MOTIONEND";
4550 case 0x0416: return "WM_BUTTON2CLICK";
4551 case 0x0417: return "WM_BUTTON3MOTIONSTART";
4552 case 0x0418: return "WM_BUTTON3MOTIONEND";
4553 case 0x0419: return "WM_BUTTON3CLICK";
4554 case 0x0420: return "WM_BEGINDRAG";
4555 case 0x0421: return "WM_ENDDRAG";
4556 case 0x0422: return "WM_SINGLESELECT";
4557 case 0x0423: return "WM_OPEN";
4558 case 0x0424: return "WM_CONTEXTMENU";
4559 case 0x0425: return "WM_CONTEXTHELP";
4560 case 0x0426: return "WM_TEXTEDIT";
4561 case 0x0427: return "WM_BEGINSELECT";
4562 case 0x0228: return "WM_ENDSELECT";
4563 case 0x0429: return "WM_PICKUP";
4564 case 0x04C0: return "WM_PENFIRST";
4565 case 0x04FF: return "WM_PENLAST";
4566 case 0x0500: return "WM_MMPMFIRST";
4567 case 0x05FF: return "WM_MMPMLAST";
4568 case 0x0600: return "WM_STDDLGFIRST";
4569 case 0x06FF: return "WM_STDDLGLAST";
4570 case 0x0BD0: return "WM_BIDI_FIRST";
4571 case 0x0BFF: return "WM_BIDI_LAST";
4573 case 0x007A: return "WM_CHAR";
4574 case 0x007B: return "WM_VIOCHAR";
4576 case 0x00A0: return "WM_DDE_INITIATE";
4577 case 0x00A1: return "WM_DDE_REQUEST";
4578 case 0x00A2: return "WM_DDE_ACK";
4579 case 0x00A3: return "WM_DDE_DATA";
4580 case 0x00A4: return "WM_DDE_ADVISE";
4581 case 0x00A5: return "WM_DDE_UNADVISE";
4582 case 0x00A6: return "WM_DDE_POKE";
4583 case 0x00A7: return "WM_DDE_EXECUTE";
4584 case 0x00A8: return "WM_DDE_TERMINATE";
4585 case 0x00A9: return "WM_DDE_INITIATEACK";
4586 case 0x00AF: return "WM_DDE_LAST";
4588 case 0x0120: return "BM_CLICK";
4589 case 0x0121: return "BM_QUERYCHECKINDEX";
4590 case 0x0122: return "BM_QUERYHILITE";
4591 case 0x0123: return "BM_SETHILITE";
4592 case 0x0124: return "BM_QUERYCHECK";
4593 case 0x0125: return "BM_SETCHECK";
4594 case 0x0126: return "BM_SETDEFAULT";
4595 case 0x0128: return "BM_AUTOSIZE";
4597 case 0x029A: return "CBID_LIST";
4598 case 0x029B: return "CBID_EDIT";
4599 case 0x0170: return "CBM_SHOWLIST";
4600 case 0x0171: return "CBM_HILITE";
4601 case 0x0172: return "CBM_ISLISTSHOWING";
4603 case 0x0140: return "EM_QUERYCHANGED";
4604 case 0x0141: return "EM_QUERYSEL";
4605 case 0x0142: return "EM_SETSEL";
4606 case 0x0143: return "EM_SETTEXTLIMIT";
4607 case 0x0144: return "EM_CUT";
4608 case 0x0145: return "EM_COPY";
4609 case 0x0146: return "EM_CLEAR";
4610 case 0x0147: return "EM_PASTE";
4611 case 0x0148: return "EM_QUERYFIRSTCHAR";
4612 case 0x0149: return "EM_SETFIRSTCHAR";
4613 case 0x014A: return "EM_QUERYREADONLY";
4614 case 0x014B: return "EM_SETREADONLY";
4615 case 0x014C: return "EM_SETINSERTMODE";
4617 case 0x0160: return "LM_QUERYITEMCOUNT";
4618 case 0x0161: return "LM_INSERTITEM";
4619 case 0x0162: return "LM_SETOPENINDEX";
4620 case 0x0163: return "LM_DELETEITEM";
4621 case 0x0164: return "LM_SELECTITEM";
4622 case 0x0165: return "LM_QUERYSELECTION";
4623 case 0x0166: return "LM_SETITEMTEXT";
4624 case 0x0167: return "LM_QUERYITEMTEXTLENGTH";
4625 case 0x0168: return "LM_QUERYITEMTEXT";
4626 case 0x0169: return "LM_SETITEMHANDLE";
4627 case 0x016A: return "LM_QUERYITEMHANDLE";
4628 case 0x016B: return "LM_SEARCHSTRING";
4629 case 0x016C: return "LM_SETITEMHEIGHT";
4630 case 0x016D: return "LM_QUERYTOPINDEX";
4631 case 0x016E: return "LM_DELETEALL";
4632 case 0x016F: return "LM_INSERTMULITEMS";
4633 case 0x0660: return "LM_SETITEMWIDTH";
4635 case 0x0180: return "MM_INSERTITEM";
4636 case 0x0181: return "MM_DELETEITEM";
4637 case 0x0182: return "MM_QUERYITEM";
4638 case 0x0183: return "MM_SETITEM";
4639 case 0x0184: return "MM_QUERYITEMCOUNT";
4640 case 0x0185: return "MM_STARTMENUMODE";
4641 case 0x0186: return "MM_ENDMENUMODE";
4642 case 0x0188: return "MM_REMOVEITEM";
4643 case 0x0189: return "MM_SELECTITEM";
4644 case 0x018A: return "MM_QUERYSELITEMID";
4645 case 0x018B: return "MM_QUERYITEMTEXT";
4646 case 0x018C: return "MM_QUERYITEMTEXTLENGTH";
4647 case 0x018D: return "MM_SETITEMHANDLE";
4648 case 0x018E: return "MM_SETITEMTEXT";
4649 case 0x018F: return "MM_ITEMPOSITIONFROMID";
4650 case 0x0190: return "MM_ITEMIDFROMPOSITION";
4651 case 0x0191: return "MM_QUERYITEMATTR";
4652 case 0x0192: return "MM_SETITEMATTR";
4653 case 0x0193: return "MM_ISITEMVALID";
4654 case 0x0194: return "MM_QUERYITEMRECT";
4655 case 0x0431: return "MM_QUERYDEFAULTITEMID";
4656 case 0x0432: return "MM_SETDEFAULTITEMID";
4658 case 0x01A0: return "SBM_SETSCROLLBAR";
4659 case 0x01A1: return "SBM_SETPOS";
4660 case 0x01A2: return "SBM_QUERYPOS";
4661 case 0x01A3: return "SBM_QUERYRANGE";
4662 case 0x01A6: return "SBM_SETTHUMBSIZE";
4665 case 0x0F00: return "WM_HELPBASE";
4666 case 0x0FFF: return "WM_HELPTOP";
4667 // Beginning of user defined messages
4668 case 0x1000: return "WM_USER";
4670 // wxWindows user defined types
4673 // case 0x1000 + 0: return "LVM_GETBKCOLOR";
4674 case 0x1000 + 1: return "LVM_SETBKCOLOR";
4675 case 0x1000 + 2: return "LVM_GETIMAGELIST";
4676 case 0x1000 + 3: return "LVM_SETIMAGELIST";
4677 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
4678 case 0x1000 + 5: return "LVM_GETITEMA";
4679 case 0x1000 + 75: return "LVM_GETITEMW";
4680 case 0x1000 + 6: return "LVM_SETITEMA";
4681 case 0x1000 + 76: return "LVM_SETITEMW";
4682 case 0x1000 + 7: return "LVM_INSERTITEMA";
4683 case 0x1000 + 77: return "LVM_INSERTITEMW";
4684 case 0x1000 + 8: return "LVM_DELETEITEM";
4685 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
4686 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
4687 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
4688 case 0x1000 + 12: return "LVM_GETNEXTITEM";
4689 case 0x1000 + 13: return "LVM_FINDITEMA";
4690 case 0x1000 + 83: return "LVM_FINDITEMW";
4691 case 0x1000 + 14: return "LVM_GETITEMRECT";
4692 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
4693 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
4694 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
4695 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
4696 case 0x1000 + 18: return "LVM_HITTEST";
4697 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
4698 case 0x1000 + 20: return "LVM_SCROLL";
4699 case 0x1000 + 21: return "LVM_REDRAWITEMS";
4700 case 0x1000 + 22: return "LVM_ARRANGE";
4701 case 0x1000 + 23: return "LVM_EDITLABELA";
4702 case 0x1000 + 118: return "LVM_EDITLABELW";
4703 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
4704 case 0x1000 + 25: return "LVM_GETCOLUMNA";
4705 case 0x1000 + 95: return "LVM_GETCOLUMNW";
4706 case 0x1000 + 26: return "LVM_SETCOLUMNA";
4707 case 0x1000 + 96: return "LVM_SETCOLUMNW";
4708 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
4709 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
4710 case 0x1000 + 28: return "LVM_DELETECOLUMN";
4711 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
4712 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
4713 case 0x1000 + 31: return "LVM_GETHEADER";
4714 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
4715 case 0x1000 + 34: return "LVM_GETVIEWRECT";
4716 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
4717 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
4718 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
4719 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
4720 case 0x1000 + 39: return "LVM_GETTOPINDEX";
4721 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
4722 case 0x1000 + 41: return "LVM_GETORIGIN";
4723 case 0x1000 + 42: return "LVM_UPDATE";
4724 case 0x1000 + 43: return "LVM_SETITEMSTATE";
4725 case 0x1000 + 44: return "LVM_GETITEMSTATE";
4726 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
4727 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
4728 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
4729 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
4730 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
4731 case 0x1000 + 48: return "LVM_SORTITEMS";
4732 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
4733 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
4734 case 0x1000 + 51: return "LVM_GETITEMSPACING";
4735 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
4736 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
4737 case 0x1000 + 53: return "LVM_SETICONSPACING";
4738 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
4739 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
4740 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
4741 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
4742 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
4743 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
4744 case 0x1000 + 60: return "LVM_SETHOTITEM";
4745 case 0x1000 + 61: return "LVM_GETHOTITEM";
4746 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
4747 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
4748 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
4749 case 0x1000 + 65: return "LVM_SETWORKAREA";
4752 case 0x1100 + 0: return "TVM_INSERTITEMA";
4753 case 0x1100 + 50: return "TVM_INSERTITEMW";
4754 case 0x1100 + 1: return "TVM_DELETEITEM";
4755 case 0x1100 + 2: return "TVM_EXPAND";
4756 case 0x1100 + 4: return "TVM_GETITEMRECT";
4757 case 0x1100 + 5: return "TVM_GETCOUNT";
4758 case 0x1100 + 6: return "TVM_GETINDENT";
4759 case 0x1100 + 7: return "TVM_SETINDENT";
4760 case 0x1100 + 8: return "TVM_GETIMAGELIST";
4761 case 0x1100 + 9: return "TVM_SETIMAGELIST";
4762 case 0x1100 + 10: return "TVM_GETNEXTITEM";
4763 case 0x1100 + 11: return "TVM_SELECTITEM";
4764 case 0x1100 + 12: return "TVM_GETITEMA";
4765 case 0x1100 + 62: return "TVM_GETITEMW";
4766 case 0x1100 + 13: return "TVM_SETITEMA";
4767 case 0x1100 + 63: return "TVM_SETITEMW";
4768 case 0x1100 + 14: return "TVM_EDITLABELA";
4769 case 0x1100 + 65: return "TVM_EDITLABELW";
4770 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
4771 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
4772 case 0x1100 + 17: return "TVM_HITTEST";
4773 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
4774 case 0x1100 + 19: return "TVM_SORTCHILDREN";
4775 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
4776 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
4777 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
4778 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
4779 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
4780 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
4781 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
4784 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
4785 case 0x1200 + 1: return "HDM_INSERTITEMA";
4786 case 0x1200 + 10: return "HDM_INSERTITEMW";
4787 case 0x1200 + 2: return "HDM_DELETEITEM";
4788 case 0x1200 + 3: return "HDM_GETITEMA";
4789 case 0x1200 + 11: return "HDM_GETITEMW";
4790 case 0x1200 + 4: return "HDM_SETITEMA";
4791 case 0x1200 + 12: return "HDM_SETITEMW";
4792 case 0x1200 + 5: return "HDM_LAYOUT";
4793 case 0x1200 + 6: return "HDM_HITTEST";
4794 case 0x1200 + 7: return "HDM_GETITEMRECT";
4795 case 0x1200 + 8: return "HDM_SETIMAGELIST";
4796 case 0x1200 + 9: return "HDM_GETIMAGELIST";
4797 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
4798 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
4799 case 0x1200 + 17: return "HDM_GETORDERARRAY";
4800 case 0x1200 + 18: return "HDM_SETORDERARRAY";
4801 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
4804 case 0x1300 + 2: return "TCM_GETIMAGELIST";
4805 case 0x1300 + 3: return "TCM_SETIMAGELIST";
4806 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
4807 case 0x1300 + 5: return "TCM_GETITEMA";
4808 case 0x1300 + 60: return "TCM_GETITEMW";
4809 case 0x1300 + 6: return "TCM_SETITEMA";
4810 case 0x1300 + 61: return "TCM_SETITEMW";
4811 case 0x1300 + 7: return "TCM_INSERTITEMA";
4812 case 0x1300 + 62: return "TCM_INSERTITEMW";
4813 case 0x1300 + 8: return "TCM_DELETEITEM";
4814 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
4815 case 0x1300 + 10: return "TCM_GETITEMRECT";
4816 case 0x1300 + 11: return "TCM_GETCURSEL";
4817 case 0x1300 + 12: return "TCM_SETCURSEL";
4818 case 0x1300 + 13: return "TCM_HITTEST";
4819 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
4820 case 0x1300 + 40: return "TCM_ADJUSTRECT";
4821 case 0x1300 + 41: return "TCM_SETITEMSIZE";
4822 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
4823 case 0x1300 + 43: return "TCM_SETPADDING";
4824 case 0x1300 + 44: return "TCM_GETROWCOUNT";
4825 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
4826 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
4827 case 0x1300 + 47: return "TCM_GETCURFOCUS";
4828 case 0x1300 + 48: return "TCM_SETCURFOCUS";
4829 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
4830 case 0x1300 + 50: return "TCM_DESELECTALL";
4833 case WM_USER
+1000+1: return "TB_ENABLEBUTTON";
4834 case WM_USER
+1000+2: return "TB_CHECKBUTTON";
4835 case WM_USER
+1000+3: return "TB_PRESSBUTTON";
4836 case WM_USER
+1000+4: return "TB_HIDEBUTTON";
4837 case WM_USER
+1000+5: return "TB_INDETERMINATE";
4838 case WM_USER
+1000+9: return "TB_ISBUTTONENABLED";
4839 case WM_USER
+1000+10: return "TB_ISBUTTONCHECKED";
4840 case WM_USER
+1000+11: return "TB_ISBUTTONPRESSED";
4841 case WM_USER
+1000+12: return "TB_ISBUTTONHIDDEN";
4842 case WM_USER
+1000+13: return "TB_ISBUTTONINDETERMINATE";
4843 case WM_USER
+1000+17: return "TB_SETSTATE";
4844 case WM_USER
+1000+18: return "TB_GETSTATE";
4845 case WM_USER
+1000+19: return "TB_ADDBITMAP";
4846 case WM_USER
+1000+20: return "TB_ADDBUTTONS";
4847 case WM_USER
+1000+21: return "TB_INSERTBUTTON";
4848 case WM_USER
+1000+22: return "TB_DELETEBUTTON";
4849 case WM_USER
+1000+23: return "TB_GETBUTTON";
4850 case WM_USER
+1000+24: return "TB_BUTTONCOUNT";
4851 case WM_USER
+1000+25: return "TB_COMMANDTOINDEX";
4852 case WM_USER
+1000+26: return "TB_SAVERESTOREA";
4853 case WM_USER
+1000+76: return "TB_SAVERESTOREW";
4854 case WM_USER
+1000+27: return "TB_CUSTOMIZE";
4855 case WM_USER
+1000+28: return "TB_ADDSTRINGA";
4856 case WM_USER
+1000+77: return "TB_ADDSTRINGW";
4857 case WM_USER
+1000+29: return "TB_GETITEMRECT";
4858 case WM_USER
+1000+30: return "TB_BUTTONSTRUCTSIZE";
4859 case WM_USER
+1000+31: return "TB_SETBUTTONSIZE";
4860 case WM_USER
+1000+32: return "TB_SETBITMAPSIZE";
4861 case WM_USER
+1000+33: return "TB_AUTOSIZE";
4862 case WM_USER
+1000+35: return "TB_GETTOOLTIPS";
4863 case WM_USER
+1000+36: return "TB_SETTOOLTIPS";
4864 case WM_USER
+1000+37: return "TB_SETPARENT";
4865 case WM_USER
+1000+39: return "TB_SETROWS";
4866 case WM_USER
+1000+40: return "TB_GETROWS";
4867 case WM_USER
+1000+42: return "TB_SETCMDID";
4868 case WM_USER
+1000+43: return "TB_CHANGEBITMAP";
4869 case WM_USER
+1000+44: return "TB_GETBITMAP";
4870 case WM_USER
+1000+45: return "TB_GETBUTTONTEXTA";
4871 case WM_USER
+1000+75: return "TB_GETBUTTONTEXTW";
4872 case WM_USER
+1000+46: return "TB_REPLACEBITMAP";
4873 case WM_USER
+1000+47: return "TB_SETINDENT";
4874 case WM_USER
+1000+48: return "TB_SETIMAGELIST";
4875 case WM_USER
+1000+49: return "TB_GETIMAGELIST";
4876 case WM_USER
+1000+50: return "TB_LOADIMAGES";
4877 case WM_USER
+1000+51: return "TB_GETRECT";
4878 case WM_USER
+1000+52: return "TB_SETHOTIMAGELIST";
4879 case WM_USER
+1000+53: return "TB_GETHOTIMAGELIST";
4880 case WM_USER
+1000+54: return "TB_SETDISABLEDIMAGELIST";
4881 case WM_USER
+1000+55: return "TB_GETDISABLEDIMAGELIST";
4882 case WM_USER
+1000+56: return "TB_SETSTYLE";
4883 case WM_USER
+1000+57: return "TB_GETSTYLE";
4884 case WM_USER
+1000+58: return "TB_GETBUTTONSIZE";
4885 case WM_USER
+1000+59: return "TB_SETBUTTONWIDTH";
4886 case WM_USER
+1000+60: return "TB_SETMAXTEXTROWS";
4887 case WM_USER
+1000+61: return "TB_GETTEXTROWS";
4888 case WM_USER
+1000+41: return "TB_GETBITMAPFLAGS";
4891 static char s_szBuf
[128];
4892 sprintf(s_szBuf
, "<unknown message = %d>", nMessage
);
4896 } // end of wxGetMessageName
4898 #endif // __WXDEBUG__
4902 static void TranslateKbdEventToMouse(
4910 // Construct the key mask
4911 ULONG
& fwKeys
= *pFlags
;
4913 fwKeys
= VK_BUTTON2
;
4914 if ((::WinGetKeyState(HWND_DESKTOP
, VK_CTRL
) & 0x100) != 0)
4916 if ((::WinGetKeyState(HWND_DESKTOP
, VK_SHIFT
) & 0x100) != 0)
4920 // Simulate right mouse button click
4924 ::WinQueryMsgPos(vHabmain
, &vPoint
);
4928 pWin
->ScreenToClient(pX
, pY
);
4929 } // end of TranslateKbdEventToMouse
4932 // Find the wxWindow at the current mouse position, returning the mouse
4934 wxWindow
* wxFindWindowAtPointer(
4935 wxPoint
& WXUNUSED(rPt
)
4938 return wxFindWindowAtPoint(wxGetMousePosition());
4941 wxWindow
* wxFindWindowAtPoint(
4950 HWND hWndHit
= ::WinWindowFromPoint(HWND_DESKTOP
, &vPt2
, FALSE
);
4951 wxWindow
* pWin
= wxFindWinFromHandle((WXHWND
)hWndHit
) ;
4952 HWND hWnd
= hWndHit
;
4955 // Try to find a window with a wxWindow associated with it
4957 while (!pWin
&& (hWnd
!= 0))
4959 hWnd
= ::WinQueryWindow(hWnd
, QW_PARENT
);
4960 pWin
= wxFindWinFromHandle((WXHWND
)hWnd
) ;
4965 // Get the current mouse position.
4966 wxPoint
wxGetMousePosition()
4970 ::WinQueryPointerPos(HWND_DESKTOP
, &vPt
);
4971 return wxPoint(vPt
.x
, vPt
.y
);