X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9dea36ef6d117e0562f0079345a77ff1696d3a49..6433f6d3165a3f8633f42c59694a9104a7b37a93:/src/os2/window.cpp?ds=sidebyside diff --git a/src/os2/window.cpp b/src/os2/window.cpp index 865455f6c6..846ed5696f 100644 --- a/src/os2/window.cpp +++ b/src/os2/window.cpp @@ -9,7 +9,9 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +// // For compilers that support precompilation, includes "wx.h". +// #include "wx/wxprec.h" #ifndef WX_PRECOMP @@ -31,6 +33,7 @@ #include "wx/listbox.h" #include "wx/button.h" #include "wx/msgdlg.h" + #include "wx/scrolwin.h" #include #endif @@ -64,101 +67,159 @@ #include -// place compiler, OS specific includes here - +// +// Place compiler, OS specific includes here +// -// standard macros -- these are for OS/2 PM, but most GUI's have something similar +// +// Standard macros -- these are for OS/2 PM, but most GUI's have something similar +// #ifndef GET_X_LPARAM +// // SHORT1FROMMP -- LOWORD +// #define GET_X_LPARAM(mp) ((unsigned short)(unsigned long)(mp)) +// // SHORT2FROMMP -- HIWORD +// #define GET_Y_LPARAM(mp) ((unsigned short)(unsigned long)(mp >> 16)) #endif // GET_X_LPARAM +#ifndef CW_USEDEFAULT +# define CW_USEDEFAULT ((int)0x80000000) +#endif + // --------------------------------------------------------------------------- // global variables // --------------------------------------------------------------------------- -// the last Windows message we got (MT-UNSAFE) -extern WXMSGID s_currentMsg; -extern wxList WXDLLEXPORT wxPendingDelete; -extern wxChar wxCanvasClassName[]; +// +// The last PM message we got (MT-UNSAFE) +// +QMSG s_currentMsg; + +#if wxUSE_MENUS_NATIVE +wxMenu* wxCurrentPopupMenu = NULL; +#endif // wxUSE_MENUS_NATIVE -wxMenu *wxCurrentPopupMenu = NULL; -wxList *wxWinHandleList = NULL; +#if !defined(__VISAGECPP__) || (__IBMCPP__ < 400) +extern wxChar wxCanvasClassName[]; +#endif +wxList* wxWinHandleList = NULL; // --------------------------------------------------------------------------- // private functions // --------------------------------------------------------------------------- + +// // the window proc for all our windows; most gui's have something similar -MRESULT wxWndProc( HWND hWnd - ,ULONG message - ,MPARAM mp1 - ,MPARAM mp2 - ); +// +MRESULT EXPENTRY wxWndProc( HWND hWnd + ,ULONG message + ,MPARAM mp1 + ,MPARAM mp2 + ); #ifdef __WXDEBUG__ const char *wxGetMessageName(int message); #endif //__WXDEBUG__ -void wxRemoveHandleAssociation(wxWindow *win); -void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win); -wxWindow *wxFindWinFromHandle(WXHWND hWnd); +void wxRemoveHandleAssociation(wxWindowOS2* pWin); +void wxAssociateWinWithHandle( HWND hWnd + ,wxWindowOS2* pWin + ); +wxWindow* wxFindWinFromHandle(WXHWND hWnd); +// +// This magical function is used to translate VK_APPS key presses to right +// mouse clicks +// +// Unused? +#if 0 +static void TranslateKbdEventToMouse( wxWindow* pWin + ,int* pX + ,int* pY + ,MPARAM* pFlags + ); +#endif +// +// get the current state of SHIFT/CTRL keys +// +static inline bool IsShiftDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000) != 0; } +static inline bool IsCtrlDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000) != 0; } // --------------------------------------------------------------------------- // event tables // --------------------------------------------------------------------------- -#if !USE_SHARED_LIBRARY +// in wxUniv-OS/2 this class is abstract because it doesn't have DoPopupMenu() +// method +#ifdef __WXUNIVERSAL__ + IMPLEMENT_ABSTRACT_CLASS(wxWindowOS2, wxWindowBase) +#else // __WXPM__ IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) -#endif - -BEGIN_EVENT_TABLE(wxWindow, wxWindowBase) - EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground) - EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged) - EVT_INIT_DIALOG(wxWindow::OnInitDialog) - EVT_IDLE(wxWindow::OnIdle) +#endif // __WXUNIVERSAL__/__WXPM__ + +BEGIN_EVENT_TABLE(wxWindowOS2, wxWindowBase) + EVT_ERASE_BACKGROUND(wxWindowOS2::OnEraseBackground) + EVT_SYS_COLOUR_CHANGED(wxWindowOS2::OnSysColourChanged) + EVT_INIT_DIALOG(wxWindowOS2::OnInitDialog) + EVT_IDLE(wxWindowOS2::OnIdle) + EVT_SET_FOCUS(wxWindowOS2::OnSetFocus) END_EVENT_TABLE() // =========================================================================== // implementation // =========================================================================== +// --------------------------------------------------------------------------- +// wxWindow utility functions +// --------------------------------------------------------------------------- + +// // Find an item given the PM Window id -wxWindow* wxWindow::FindItem( - long ulId +// +wxWindow* wxWindowOS2::FindItem( + long lId ) const { +#if wxUSE_CONTROLS + wxControl* pItem = wxDynamicCast(this, wxControl); + + if (pItem) + { + // + // I it we or one of our "internal" children? + // + if (pItem->GetId() == lId +#ifndef __WXUNIVERSAL__ + || (pItem->GetSubcontrols().Index(lId) != wxNOT_FOUND) +#endif + ) + { + return pItem; + } + } +#endif // wxUSE_CONTROLS + wxWindowList::Node* pCurrent = GetChildren().GetFirst(); while (pCurrent) { wxWindow* pChildWin = pCurrent->GetData(); - wxWindow* pWnd = pChildWin->FindItem(ulId); + wxWindow* pWnd = pChildWin->FindItem(lId); if (pWnd) return pWnd; - if (pChildWin->IsKindOf(CLASSINFO(wxControl))) - { - wxControl* pItem = (wxControl *)pChildWin; - - if (pItem->GetId() == ulId) - return(pItem); - else - { - // In case it's a 'virtual' control (e.g. radiobox) - if (pItem->GetSubcontrols().Member((wxObject *)ulId)) - return(pItem); - } - } pCurrent = pCurrent->GetNext(); } return(NULL); -} +} // end of wxWindowOS2::FindItem +// // Find an item given the PM Window handle -wxWindow* wxWindow::FindItemByHWND( +// +wxWindow* wxWindowOS2::FindItemByHWND( WXHWND hWnd , bool bControlOnly ) const @@ -169,13 +230,19 @@ wxWindow* wxWindow::FindItemByHWND( { wxWindow* pParent = pCurrent->GetData(); + // // Do a recursive search. + // wxWindow* pWnd = pParent->FindItemByHWND(hWnd); if (pWnd) return(pWnd); - if (!bControlOnly || pParent->IsKindOf(CLASSINFO(wxControl))) + if (!bControlOnly +#if wxUSE_CONTROLS + || pParent->IsKindOf(CLASSINFO(wxControl)) +#endif // wxUSE_CONTROLS + ) { wxWindow* pItem = pCurrent->GetData(); @@ -190,10 +257,12 @@ wxWindow* wxWindow::FindItemByHWND( pCurrent = pCurrent->GetNext(); } return(NULL); -} +} // end of wxWindowOS2::FindItemByHWND +// // Default command handler -bool wxWindow::OS2Command( +// +bool wxWindowOS2::OS2Command( WXUINT WXUNUSED(uParam) , WXWORD WXUNUSED(uId) ) @@ -205,12 +274,16 @@ bool wxWindow::OS2Command( // constructors and such // ---------------------------------------------------------------------------- -void wxWindow::Init() +void wxWindowOS2::Init() { - // generic + // + // Generic + // InitBase(); + // // PM specific + // m_bDoubleClickAllowed = 0; m_bWinCaptured = FALSE; @@ -219,19 +292,25 @@ void wxWindow::Init() m_bUseCtl3D = FALSE; m_bMouseInWindow = FALSE; + // // wxWnd - m_hMenu = 0; - - m_hWnd = 0; - - // pass WM_GETDLGCODE to DefWindowProc() + // + m_hMenu = 0L; + m_hWnd = 0L; + m_hWndScrollBarHorz = 0L; + m_hWndScrollBarVert = 0L; + + // + // Pass WM_GETDLGCODE to DefWindowProc() m_lDlgCode = 0; m_nXThumbSize = 0; m_nYThumbSize = 0; m_bBackgroundTransparent = FALSE; - // as all windows are created with WS_VISIBLE style... + // + // As all windows are created with WS_VISIBLE style... + // m_isShown = TRUE; #if wxUSE_MOUSEEVENT_HACK @@ -239,28 +318,45 @@ void wxWindow::Init() m_lLastMouseY = -1; m_nLastMouseEvent = -1; #endif // wxUSE_MOUSEEVENT_HACK -} +} // wxWindowOS2::Init +// // Destructor -wxWindow::~wxWindow() +// +wxWindowOS2::~wxWindowOS2() { m_isBeingDeleted = TRUE; OS2DetachWindowMenu(); - // delete handlers? + for (wxWindow* pWin = GetParent(); pWin; pWin = pWin->GetParent()) + { + wxFrame* pFrame = wxDynamicCast(pWin, wxFrame); + + if (pFrame) + { + if (pFrame->GetLastFocus() == this) + pFrame->SetLastFocus((wxWindow*)NULL); + } + } + + DestroyChildren(); + if (m_parent) m_parent->RemoveChild(this); - DestroyChildren(); + if (m_hWnd) { - if(!WinDestroyWindow(GetHWND())) + if(!::WinDestroyWindow(GetHWND())) wxLogLastError(wxT("DestroyWindow")); + // // remove hWnd <-> wxWindow association + // wxRemoveHandleAssociation(this); } -} +} // end of wxWindowOS2::~wxWindowOS2 -bool wxWindow::Create( +// real construction (Init() must have been called before!) +bool wxWindowOS2::Create( wxWindow* pParent , wxWindowID vId , const wxPoint& rPos @@ -269,6 +365,11 @@ bool wxWindow::Create( , const wxString& rName ) { + HWND hParent = NULLHANDLE; + wxPoint vPos = rPos; // The OS/2 position + ULONG ulCreateFlags = 0; + WXDWORD dwExStyle = 0; + wxCHECK_MSG(pParent, FALSE, wxT("can't create wxWindow without parent")); if ( !CreateBase( pParent @@ -281,39 +382,97 @@ bool wxWindow::Create( )) return(FALSE); - pParent->AddChild(this); + if (pParent) + { + int nTempy; + + pParent->AddChild(this); + hParent = GetWinHwnd(pParent); + + if ( pParent->IsKindOf(CLASSINFO(wxGenericScrolledWindow)) || + pParent->IsKindOf(CLASSINFO(wxScrolledWindow)) + ) + ulCreateFlags |= WS_CLIPSIBLINGS; + } + + // + // Most wxSTYLES are really PM Class specific styles and will be + // set in those class create procs. PM's basic windows styles are + // very limited. + // + ulCreateFlags |= WS_VISIBLE; + + +#ifdef __WXUNIVERSAL__ + // no 3d effects, we draw them ourselves + WXDWORD exStyle = 0; +#else // !wxUniversal + if (lStyle & wxCLIP_SIBLINGS) + ulCreateFlags |= WS_CLIPSIBLINGS; + + if (lStyle & wxCLIP_CHILDREN ) + ulCreateFlags |= WS_CLIPCHILDREN; + // + // + // bool bWant3D; - WXDWORD dwExStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &bWant3D); - DWORD ulFlags = 0L; + dwExStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &bWant3D); - OS2Create( m_windowId - ,pParent - ,wxCanvasClassName - ,this - ,NULL - ,rPos.x - ,rPos.y +#endif + + // + // Add the simple border style as we'll use this to draw borders + // + if (lStyle & wxSIMPLE_BORDER) + dwExStyle |= wxSIMPLE_BORDER; + + if (lStyle & wxPOPUP_WINDOW) + { + // a popup window floats on top of everything +//TODO: fix this... +// exStyle |= WS_EX_TOPMOST | WS_EX_TOOLWINDOW; + + // it is also created hidden as other top level windows + ulCreateFlags &= ~WS_VISIBLE; + m_isShown = FALSE; + } + + // + // Generic OS/2 Windows are created with no owner, no Z Order, no Control data, + // and no presentation parameters + // + OS2Create( hParent + ,(PSZ)wxCanvasClassName + ,rName.c_str() + ,ulCreateFlags + ,vPos.x + ,vPos.y ,WidthDefault(rSize.x) ,HeightDefault(rSize.y) - ,ulFlags + ,NULLHANDLE + ,NULLHANDLE + ,m_windowId + ,NULL ,NULL ,dwExStyle ); + return(TRUE); -} +} // end of wxWindowOS2::Create // --------------------------------------------------------------------------- // basic operations // --------------------------------------------------------------------------- -void wxWindow::SetFocus() +void wxWindowOS2::SetFocus() { HWND hWnd = GetHwnd(); + wxCHECK_RET( hWnd, _T("can't set focus to invalid window") ); if (hWnd) ::WinSetFocus(HWND_DESKTOP, hWnd); -} +} // end of wxWindowOS2::SetFocus wxWindow* wxWindowBase::FindFocus() { @@ -324,9 +483,9 @@ wxWindow* wxWindowBase::FindFocus() return wxFindWinFromHandle((WXHWND)hWnd); } return NULL; -} +} // wxWindowBase::FindFocus -bool wxWindow::Enable( +bool wxWindowOS2::Enable( bool bEnable ) { @@ -347,10 +506,10 @@ bool wxWindow::Enable( pChild->Enable(bEnable); pNode = pNode->GetNext(); } - return(TRUE); -} + return TRUE; +} // end of wxWindowOS2::Enable -bool wxWindow::Show( +bool wxWindowOS2::Show( bool bShow ) { @@ -363,34 +522,34 @@ bool wxWindow::Show( if (bShow) { - ::WinSetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE); + ::WinSetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER); } - return(TRUE); -} + return TRUE; +} // end of wxWindowOS2::Show -void wxWindow::Raise() +void wxWindowOS2::Raise() { - ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, SWP_ACTIVATE); -} + ::WinSetWindowPos(GetHwnd(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | SWP_ACTIVATE); +} // end of wxWindowOS2::Raise -void wxWindow::Lower() +void wxWindowOS2::Lower() { - ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, SWP_DEACTIVATE); -} + ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER | SWP_DEACTIVATE); +} // end of wxWindowOS2::Lower -void wxWindow::SetTitle( +void wxWindowOS2::SetTitle( const wxString& rTitle ) { ::WinSetWindowText(GetHwnd(), rTitle.c_str()); -} +} // end of wxWindowOS2::SetTitle -wxString wxWindow::GetTitle() const +wxString wxWindowOS2::GetTitle() const { return wxGetWindowText(GetHWND()); -} +} // end of wxWindowOS2::GetTitle -void wxWindow::CaptureMouse() +void wxWindowOS2::CaptureMouse() { HWND hWnd = GetHwnd(); @@ -399,18 +558,24 @@ void wxWindow::CaptureMouse() ::WinSetCapture(HWND_DESKTOP, hWnd); m_bWinCaptured = TRUE; } -} +} // end of wxWindowOS2::GetTitle -void wxWindow::ReleaseMouse() +void wxWindowOS2::ReleaseMouse() { - if ( m_bWinCaptured ) + if (m_bWinCaptured) { ::WinSetCapture(HWND_DESKTOP, NULLHANDLE); m_bWinCaptured = FALSE; } -} +} // end of wxWindowOS2::ReleaseMouse + +/* static */ wxWindow* wxWindowBase::GetCapture() +{ + HWND hwnd = ::WinQueryCapture(HWND_DESKTOP); + return hwnd ? wxFindWinFromHandle((WXHWND)hwnd) : (wxWindow *)NULL; +} // end of wxWindowBase::GetCapture -bool wxWindow::SetFont( +bool wxWindowOS2::SetFont( const wxFont& rFont ) { @@ -424,15 +589,77 @@ bool wxWindow::SetFont( if (hWnd != 0) { - wxChar zFont[128]; + char zFont[128]; + char zFacename[30]; + char zWeight[30]; + char zStyle[30]; + + // + // The fonts available for Presentation Params are just three + // outline fonts, the rest are available to the GPI, so we must + // map the families to one of these three + // + switch(rFont.GetFamily()) + { + case wxSCRIPT: + case wxDECORATIVE: + case wxROMAN: + strcpy(zFacename,"Times New Roman"); + break; + + case wxTELETYPE: + case wxMODERN: + strcpy(zFacename, "Courier"); + break; - sprintf(zFont, "%d.%s", rFont.GetPointSize(), rFont.GetFaceName().c_str()); - return(::WinSetPresParam(hWnd, PP_FONTNAMESIZE, strlen(zFont), (PVOID)zFont)); + case wxSWISS: + case wxDEFAULT: + default: + strcpy(zFacename, "Helvetica"); + break; + } + + switch(rFont.GetWeight()) + { + default: + case wxNORMAL: + case wxLIGHT: + zWeight[0] = '\0'; + break; + + case wxBOLD: + case wxFONTWEIGHT_MAX: + strcpy(zWeight, "Bold"); + break; + } + switch(rFont.GetStyle()) + { + case wxITALIC: + case wxSLANT: + strcpy(zStyle, "Italic"); + break; + + default: + zStyle[0] = '\0'; + break; + } + sprintf(zFont, "%d.%s", rFont.GetPointSize(), zFacename); + if (zWeight[0] != '\0') + { + strcat(zFont, " "); + strcat(zFont, zWeight); + } + if (zStyle[0] != '\0') + { + strcat(zFont, " "); + strcat(zFont, zStyle); + } + ::WinSetPresParam(hWnd, PP_FONTNAMESIZE, strlen(zFont) + 1, (PVOID)zFont); } return(TRUE); } -bool wxWindow::SetCursor( +bool wxWindowOS2::SetCursor( const wxCursor& rCursor ) // check if base implementation is OK { @@ -442,36 +669,40 @@ bool wxWindow::SetCursor( return FALSE; } - wxASSERT_MSG( m_cursor.Ok(), - wxT("cursor must be valid after call to the base version")); - - HWND hWnd = GetHwnd(); - POINTL vPoint; - RECTL vRect; - HPS hPS; - HRGN hRGN; - - hPS = ::WinGetPS(hWnd); - - ::WinQueryPointerPos(HWND_DESKTOP, &vPoint); - ::WinQueryWindowRect(hWnd, &vRect); + if ( m_cursor.Ok() ) { + HWND hWnd = GetHwnd(); + POINTL vPoint; + RECTL vRect; - hRGN = ::GpiCreateRegion(hPS, 1L, &vRect); + ::WinQueryPointerPos(HWND_DESKTOP, &vPoint); + ::WinQueryWindowRect(hWnd, &vRect); - if ((::GpiPtInRegion(hPS, hRGN, &vPoint) == PRGN_INSIDE) && !wxIsBusy()) - { -// ::SetCursor((HCURSOR)m_cursor.GetHCURSOR()); + if (::WinPtInRect(vHabmain, &vRect, &vPoint) && !wxIsBusy()) + { + ::WinSetPointer(HWND_DESKTOP, (HPOINTER)m_cursor.GetHCURSOR()); + } } return TRUE; -} +} // end of wxWindowOS2::SetCursor -void wxWindow::WarpPointer(int x_pos, int y_pos) +void wxWindowOS2::WarpPointer( + int nXPos +, int nYPos +) { - // TODO: -} + int nX = nXPos; + int nY = nYPos; + RECTL vRect; + + ::WinQueryWindowRect(GetHwnd(), &vRect); + nX += vRect.xLeft; + nY += vRect.yBottom; + + ::WinSetPointerPos(HWND_DESKTOP, (LONG)nX, (LONG)(nY)); +} // end of wxWindowOS2::WarpPointer #if WXWIN_COMPATIBILITY -void wxWindow::OS2DeviceToLogical (float *x, float *y) const +void wxWindowOS2::OS2DeviceToLogical (float *x, float *y) const { } #endif // WXWIN_COMPATIBILITY @@ -481,271 +712,657 @@ void wxWindow::OS2DeviceToLogical (float *x, float *y) const // --------------------------------------------------------------------------- #if WXWIN_COMPATIBILITY -void wxWindow::SetScrollRange(int orient, int range, bool refresh) +void wxWindowOS2::SetScrollRange( + int nOrient +, int nRange +, bool bRefresh +) { - // TODO: -} + int nRange1 = nRange; + int nPageSize = GetScrollPage(nOrient); + + if (nPpageSize > 1 && nRange > 0) + { + nRange1 += (nPageSize - 1); + } -void wxWindow::SetScrollPage(int orient, int page, bool refresh) + if (nOrient == wxHORIZONTAL) + { + ::WinSendMsg(m_hWndScrollBarHorz, SBM_SETSCROLLBAR, (MPARAM)0, MPFROM2SHORT(0, (SHORT)nRange1)); + ::WinSendMsg(m_hWndScrollBarHorz, SBM_SETTHUMBSIZE, MPFROM2SHORT((SHORT)nThumbVisible, (SHORT)nRange1), (MPARAM)0); + } + else + { + ::WinSendMsg(m_hWndScrollBarVert, SBM_SETSCROLLBAR, (MPARAM)0, MPFROM2SHORT(0, (SHORT)nRange1)); + ::WinSendMsg(m_hWndScrollBarVert, SBM_SETTHUMBSIZE, MPFROM2SHORT((SHORT)nThumbVisible, (SHORT)nRange1), (MPARAM)0); + } +} // end of wxWindowOS2::SetScrollRange + +void wxWindowOS2::SetScrollPage( + int nOrient +, int nPage +, bool bRefresh +) { - // TODO: -} + if (nOrient == wxHORIZONTAL ) + m_nXThumbSize = nPage; + else + m_nYThumbSize = nPage; +} // end of wxWindowOS2::SetScrollPage -int wxWindow::OldGetScrollRange(int orient) const +int wxWindowOS2::OldGetScrollRange( + int nOrient +) const { - // TODO: - return 0; -} + MRESULT mRc; + HWND hWnd = GetHwnd(); -int wxWindow::GetScrollPage(int orient) const + if (hWnd) + { + mRc = WinSendMsg(hWnd, SBM_QUERYRANGE, (MPARAM)0L, (MPARAM)0L); + return(SHORT2FROMMR(mRc)); + } + return 0; +} // end of wxWindowOS2::OldGetScrollRange + +int wxWindowOS2::GetScrollPage( + int nOrient +) const { - // TODO: - return(1); -} + if (nOrient == wxHORIZONTAL) + return m_nXThumbSize; + else + return m_nYThumbSize; +} // end of wxWindowOS2::GetScrollPage #endif // WXWIN_COMPATIBILITY -int wxWindow::GetScrollPos(int orient) const +int wxWindowOS2::GetScrollPos( + int nOrient +) const { - // TODO: - return(1); -} + if (nOrient == wxHORIZONTAL) + return((int)::WinSendMsg(m_hWndScrollBarHorz, SBM_QUERYPOS, (MPARAM)NULL, (MPARAM)NULL)); + else + return((int)::WinSendMsg(m_hWndScrollBarVert, SBM_QUERYPOS, (MPARAM)NULL, (MPARAM)NULL)); +} // end of wxWindowOS2::GetScrollPos -int wxWindow::GetScrollRange(int orient) const +int wxWindowOS2::GetScrollRange( + int nOrient +) const { - // TODO: - return(1); -} + MRESULT mr; -int wxWindow::GetScrollThumb(int orient) const -{ - // TODO: - return(1); -} + if (nOrient == wxHORIZONTAL) + mr = ::WinSendMsg(m_hWndScrollBarHorz, SBM_QUERYRANGE, (MPARAM)NULL, (MPARAM)NULL); + else + mr = ::WinSendMsg(m_hWndScrollBarVert, SBM_QUERYRANGE, (MPARAM)NULL, (MPARAM)NULL); + return((int)SHORT2FROMMR(mr)); +} // end of wxWindowOS2::GetScrollRange -void wxWindow::SetScrollPos( int orient - ,int pos - ,bool refresh - ) +int wxWindowOS2::GetScrollThumb( + int nOrient +) const { - // TODO: -} + if (nOrient == wxHORIZONTAL ) + return m_nXThumbSize; + else + return m_nYThumbSize; +} // end of wxWindowOS2::GetScrollThumb -void wxWindow::SetScrollbar( int orient - ,int pos - ,int thumbVisible - ,int range - ,bool refresh - ) +void wxWindowOS2::SetScrollPos( + int nOrient +, int nPos +, bool WXUNUSED(bRefresh) +) { - // TODO: -} + if (nOrient == wxHORIZONTAL ) + ::WinSendMsg(m_hWndScrollBarHorz, SBM_SETPOS, (MPARAM)nPos, (MPARAM)NULL); + else + ::WinSendMsg(m_hWndScrollBarVert, SBM_SETPOS, (MPARAM)nPos, (MPARAM)NULL); +} // end of wxWindowOS2::SetScrollPos + +void wxWindowOS2::SetScrollbar( + int nOrient +, int nPos +, int nThumbVisible +, int nRange +, bool WXUNUSED(bRefresh) +) +{ + int nOldRange = nRange - nThumbVisible; + int nRange1 = nOldRange; + int nPageSize = nThumbVisible; + SBCDATA vInfo; + HWND hWnd = GetHwnd(); + ULONG ulStyle = WS_VISIBLE | WS_SYNCPAINT; + RECTL vRect; + + ::WinQueryWindowRect(hWnd, &vRect); + if (nPageSize > 1 && nRange > 0) + { + nRange1 += (nPageSize - 1); + } + + vInfo.cb = sizeof(SBCDATA); + vInfo.posFirst = 0; + vInfo.posLast = (SHORT)nRange1; + vInfo.posThumb = nPos; -void wxWindow::ScrollWindow( int dx - ,int dy - ,const wxRect* rect - ) + if (nOrient == wxHORIZONTAL ) + { + ulStyle |= SBS_HORZ; + if (m_hWndScrollBarHorz == 0L) + { + // + // We create the scrollbars with the desktop so that they are not + // registered as child windows of the window in order that child + // windows may be scrolled without scrolling the scrollbars themselves! + // + m_hWndScrollBarHorz = ::WinCreateWindow( hWnd + ,WC_SCROLLBAR + ,(PSZ)NULL + ,ulStyle + ,vRect.xLeft + ,vRect.yBottom + ,vRect.xRight - vRect.xLeft + ,20 + ,hWnd + ,HWND_TOP + ,FID_HORZSCROLL + ,&vInfo + ,NULL + ); + } + else + { + RECTL vRect2; + + // + // Only want to resize the scrollbar if it changes, otherwise + // we'd probably end up in a recursive loop until we crash the call stack + // because this method is called in a ScrolledWindow OnSize event and SWP_MOVE | SWP_SIZE + // generates those events. + // + ::WinQueryWindowRect(m_hWndScrollBarHorz, &vRect2); + if (!(vRect2.xLeft == vRect.xLeft && + vRect2.xRight == vRect.xRight && + vRect2.yBottom == vRect.yBottom && + vRect2.yTop == vRect.yTop + ) ) + { + ::WinSetWindowPos( m_hWndScrollBarHorz + ,HWND_TOP + ,vRect.xLeft + ,vRect.yBottom + ,vRect.xRight - vRect.xLeft + ,20 + ,SWP_ACTIVATE | SWP_MOVE | SWP_SIZE | SWP_SHOW + ); + } + ::WinSendMsg(m_hWndScrollBarHorz, SBM_SETSCROLLBAR, (MPARAM)nPos, MPFROM2SHORT(0, (SHORT)nRange1)); + ::WinSendMsg(m_hWndScrollBarHorz, SBM_SETTHUMBSIZE, MPFROM2SHORT((SHORT)nThumbVisible, (SHORT)nRange1), (MPARAM)0); + } + } + else + { + ulStyle |= SBS_VERT; + if (m_hWndScrollBarVert == 0L) + { + m_hWndScrollBarVert = ::WinCreateWindow( hWnd + ,WC_SCROLLBAR + ,(PSZ)NULL + ,ulStyle + ,vRect.xRight - 20 + ,vRect.yBottom + 20 + ,20 + ,vRect.yTop - (vRect.yBottom + 20) + ,hWnd + ,HWND_TOP + ,FID_VERTSCROLL + ,&vInfo + ,NULL + ); + } + else + { + RECTL vRect2; + + // + // Only want to resize the scrollbar if it changes, otherwise + // we'd probably end up in a recursive loop until we crash the call stack + // because this method is called in a ScrolledWindow OnSize event and SWP_MOVE | SWP_SIZE + // generates those events. + // + ::WinQueryWindowRect(m_hWndScrollBarVert, &vRect2); + if (!(vRect2.xLeft == vRect.xLeft && + vRect2.xRight == vRect.xRight && + vRect2.yBottom == vRect.yBottom && + vRect2.yTop == vRect.yTop + ) ) + { + ::WinSetWindowPos( m_hWndScrollBarVert + ,HWND_TOP + ,vRect.xRight - 20 + ,vRect.yBottom + 20 + ,20 + ,vRect.yTop - (vRect.yBottom + 20) + ,SWP_ACTIVATE | SWP_MOVE | SWP_SIZE | SWP_SHOW + ); + } + ::WinSendMsg(m_hWndScrollBarVert, SBM_SETSCROLLBAR, (MPARAM)nPos, MPFROM2SHORT(0, (SHORT)nRange1)); + ::WinSendMsg(m_hWndScrollBarVert, SBM_SETTHUMBSIZE, MPFROM2SHORT((SHORT)nThumbVisible, (SHORT)nRange1), (MPARAM)0); + } + m_nYThumbSize = nThumbVisible; + } +} // end of wxWindowOS2::SetScrollbar + +void wxWindowOS2::ScrollWindow( + int nDx +, int nDy +, const wxRect* pRect +) { - // TODO: -} + RECTL vRect; + RECTL vRect2; + + nDy *= -1; // flip the sign of Dy as OS/2 is opposite wxWin. + if (pRect) + { + vRect2.xLeft = pRect->x; + vRect2.yTop = pRect->y + pRect->height; + vRect2.xRight = pRect->x + pRect->width; + vRect2.yBottom = pRect->y; + } + else + { + ::WinQueryWindowRect(GetHwnd(), &vRect2); + ::WinQueryWindowRect(m_hWndScrollBarHorz, &vRect); + vRect2.yBottom += vRect.yTop - vRect.yBottom; + ::WinQueryWindowRect(m_hWndScrollBarVert, &vRect); + vRect2.xRight -= vRect.xRight - vRect.xLeft; + + } + if (pRect) + ::WinScrollWindow( GetHwnd() + ,(LONG)nDx + ,(LONG)nDy + ,&vRect2 + ,NULL + ,NULLHANDLE + ,NULL + ,SW_INVALIDATERGN + ); + else + ::WinScrollWindow( GetHwnd() + ,nDx + ,nDy + ,NULL + ,NULL + ,NULLHANDLE + ,NULL + ,SW_INVALIDATERGN + ); + + // + // Move the children + wxWindowList::Node* pCurrent = GetChildren().GetFirst(); + SWP vSwp; + + while (pCurrent) + { + wxWindow* pChildWin = pCurrent->GetData(); + + if (pChildWin->GetHWND() != NULLHANDLE) + { + ::WinQueryWindowPos(pChildWin->GetHWND(), &vSwp); + ::WinQueryWindowRect(pChildWin->GetHWND(), &vRect); + if (pChildWin->GetHWND() == m_hWndScrollBarVert || + pChildWin->GetHWND() == m_hWndScrollBarHorz) + { + ::WinSetWindowPos( pChildWin->GetHWND() + ,HWND_TOP + ,vSwp.x + nDx + ,vSwp.y + nDy + ,0 + ,0 + ,SWP_MOVE | SWP_SHOW | SWP_ZORDER + ); + } + else + { + ::WinSetWindowPos( pChildWin->GetHWND() + ,HWND_BOTTOM + ,vSwp.x + nDx + ,vSwp.y + nDy + ,0 + ,0 + ,SWP_MOVE | SWP_ZORDER + ); + ::WinInvalidateRect(pChildWin->GetHWND(), &vRect, FALSE); + } + } + pCurrent = pCurrent->GetNext(); + } +} // end of wxWindowOS2::ScrollWindow // --------------------------------------------------------------------------- // subclassing // --------------------------------------------------------------------------- -void wxWindow::SubclassWin(WXHWND hWnd) +void wxWindowOS2::SubclassWin( + WXHWND hWnd +) { - wxASSERT_MSG( !m_fnOldWndProc, wxT("subclassing window twice?") ); + HWND hwnd = (HWND)hWnd; - HWND hwnd = (HWND)hWnd; -/* -* TODO: implement something like this: -* wxCHECK_RET( ::IsWindow(hwnd), wxT("invalid HWND in SubclassWin") ); -* -* wxAssociateWinWithHandle(hwnd, this); -* -* m_oldWndProc = (WXFARPROC) GetWindowLong(hwnd, GWL_WNDPROC); -* SetWindowLong(hwnd, GWL_WNDPROC, (LONG) wxWndProc); -*/ -} + wxASSERT_MSG( !m_fnOldWndProc, wxT("subclassing window twice?") ); + wxCHECK_RET(::WinIsWindow(vHabmain, hwnd), wxT("invalid HWND in SubclassWin") ); + m_fnOldWndProc = (WXFARPROC) ::WinSubclassWindow(hwnd, (PFNWP)wxWndProc); +} // end of wxWindowOS2::SubclassWin -void wxWindow::UnsubclassWin() +void wxWindowOS2::UnsubclassWin() { -/* -* TODO: - - wxRemoveHandleAssociation(this); - + // // Restore old Window proc - HWND hwnd = GetHwnd(); - if ( hwnd ) + // + HWND hwnd = GetHWND(); + + if (m_hWnd) { - m_hWnd = 0; + wxCHECK_RET( ::WinIsWindow(vHabmain, hwnd), wxT("invalid HWND in UnsubclassWin") ); - wxCHECK_RET( ::IsWindow(hwnd), wxT("invalid HWND in UnsubclassWin") ); + PFNWP fnProc = (PFNWP)::WinQueryWindowPtr(hwnd, QWP_PFNWP); - FARPROC farProc = (FARPROC) GetWindowLong(hwnd, GWL_WNDPROC); - if ( (m_oldWndProc != 0) && (farProc != (FARPROC) m_oldWndProc) ) + if ( (m_fnOldWndProc != 0) && (fnProc != (PFNWP) m_fnOldWndProc)) { - SetWindowLong(hwnd, GWL_WNDPROC, (LONG) m_oldWndProc); - m_oldWndProc = 0; + WinSubclassWindow(hwnd, (PFNWP)m_fnOldWndProc); + m_fnOldWndProc = 0; } } -*/ -} +} // end of wxWindowOS2::UnsubclassWin +// // Make a Windows extended style from the given wxWindows window style -WXDWORD wxWindow::MakeExtendedStyle(long style, bool eliminateBorders) +// +WXDWORD wxWindowOS2::MakeExtendedStyle( + long lStyle +, bool bEliminateBorders +) { - // TODO: - WXDWORD exStyle = 0; -/* - if ( style & wxTRANSPARENT_WINDOW ) - exStyle |= WS_EX_TRANSPARENT; - - if ( !eliminateBorders ) - { - if ( style & wxSUNKEN_BORDER ) - exStyle |= WS_EX_CLIENTEDGE; - if ( style & wxDOUBLE_BORDER ) - exStyle |= WS_EX_DLGMODALFRAME; - if ( style & wxRAISED_BORDER ) - exStyle |= WS_EX_WINDOWEDGE; - if ( style & wxSTATIC_BORDER ) - exStyle |= WS_EX_STATICEDGE; - } -*/ - return exStyle; -} + // + // Simply fill out with wxWindow extended styles. We'll conjure + // something up in OS2Create and all window redrawing pieces later + // + WXDWORD dwStyle = 0; -// Determines whether native 3D effects or CTL3D should be used, -// applying a default border style if required, and returning an extended -// style to pass to CreateWindowEx. -WXDWORD wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle, - bool *want3D) const -{ - DWORD exStyle = 0L; // remove after implementation doe -/* TODO: this ought to be fun -* - // If matches certain criteria, then assume no 3D effects - // unless specifically requested (dealt with in MakeExtendedStyle) - if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl)) || (m_windowStyle & wxNO_BORDER) ) + if (lStyle & wxTRANSPARENT_WINDOW ) + dwStyle |= wxTRANSPARENT_WINDOW; + + if (!bEliminateBorders) { - *want3D = FALSE; - return MakeExtendedStyle(m_windowStyle, FALSE); + if (lStyle & wxSUNKEN_BORDER) + dwStyle |= wxSUNKEN_BORDER; + if (lStyle & wxDOUBLE_BORDER) + dwStyle |= wxDOUBLE_BORDER; + if (lStyle & wxRAISED_BORDER ) + dwStyle |= wxRAISED_BORDER; + if (lStyle & wxSTATIC_BORDER) + dwStyle |= wxSTATIC_BORDER; } + return dwStyle; +} // end of wxWindowOS2::MakeExtendedStyle - // Determine whether we should be using 3D effects or not. - bool nativeBorder = FALSE; // by default, we don't want a Win95 effect - - // 1) App can specify global 3D effects - *want3D = wxTheApp->GetAuto3D(); - - // 2) If the parent is being drawn with user colours, or simple border specified, - // switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D - if ( GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS) || (m_windowStyle & wxSIMPLE_BORDER) ) - *want3D = FALSE; +// +// Determines whether simulated 3D effects or CTL3D should be used, +// applying a default border style if required, and returning an extended +// style to pass to OS2Create. +// +WXDWORD wxWindowOS2::Determine3DEffects( + WXDWORD dwDefaultBorderStyle +, bool* pbWant3D +) const +{ + WXDWORD dwStyle = 0L; - // 3) Control can override this global setting by defining - // a border style, e.g. wxSUNKEN_BORDER - if ( m_windowStyle & wxSUNKEN_BORDER ) - *want3D = TRUE; + // + // Native PM does not have any specialize 3D effects like WIN32 does, + // so we have to try and invent them. + // - // 4) If it's a special border, CTL3D can't cope so we want a native border - if ( (m_windowStyle & wxDOUBLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) || - (m_windowStyle & wxSTATIC_BORDER) ) + // + // If matches certain criteria, then assume no 3D effects + // unless specifically requested (dealt with in MakeExtendedStyle) + // + if (!GetParent() || + !IsKindOf(CLASSINFO(wxControl)) || + (m_windowStyle & wxNO_BORDER) + ) { - *want3D = TRUE; - nativeBorder = TRUE; + *pbWant3D = FALSE; + return MakeExtendedStyle(m_windowStyle, FALSE); } - // 5) If this isn't a Win95 app, and we are using CTL3D, remove border - // effects from extended style -#if wxUSE_CTL3D - if ( *want3D ) - nativeBorder = FALSE; -#endif - - DWORD exStyle = MakeExtendedStyle(m_windowStyle, !nativeBorder); - + // + // 1) App can specify global 3D effects + // + *pbWant3D = wxTheApp->GetAuto3D(); + + // + // 2) If the parent is being drawn with user colours, or simple border + // specified, switch effects off. + // + if (GetParent() && + (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS) || + (m_windowStyle & wxSIMPLE_BORDER) + ) + *pbWant3D = FALSE; + + // + // 3) Control can override this global setting by defining + // a border style, e.g. wxSUNKEN_BORDER + // + if ((m_windowStyle & wxDOUBLE_BORDER) || + (m_windowStyle & wxRAISED_BORDER) || + (m_windowStyle & wxSTATIC_BORDER) || + (m_windowStyle & wxSUNKEN_BORDER) + ) + *pbWant3D = TRUE; + + dwStyle = MakeExtendedStyle( m_windowStyle + ,FALSE + ); + + // // If we want 3D, but haven't specified a border here, // apply the default border style specified. - // TODO what about non-Win95 WIN32? Does it have borders? -#if defined(__WIN95__) && !wxUSE_CTL3D - if ( defaultBorderStyle && (*want3D) && ! ((m_windowStyle & wxDOUBLE_BORDER) || (m_windowStyle & wxRAISED_BORDER ) || - (m_windowStyle & wxSTATIC_BORDER) || (m_windowStyle & wxSIMPLE_BORDER) )) - exStyle |= defaultBorderStyle; // WS_EX_CLIENTEDGE; -#endif -*/ - return exStyle; -} + // + if (dwDefaultBorderStyle && (*pbWant3D) && + !((m_windowStyle & wxDOUBLE_BORDER) || + (m_windowStyle & wxRAISED_BORDER) || + (m_windowStyle & wxSTATIC_BORDER) || + (m_windowStyle & wxSIMPLE_BORDER) + ) + ) + dwStyle |= dwDefaultBorderStyle; + return dwStyle; +} // end of wxWindowOS2::Determine3DEffects #if WXWIN_COMPATIBILITY -void wxWindow::OnCommand(wxWindow& win, wxCommandEvent& event) +void wxWindowOS2::OnCommand( + wxWindow& rWin +, wxCommandEvent& rEvent +) { - // TODO: -} + if (GetEventHandler()->ProcessEvent(rEvent)) + return; + if (m_parent) + m_parent->GetEventHandler()->OnCommand( rWin + ,rEvent + ); +} // end of wxWindowOS2::OnCommand -wxObject* wxWindow::GetChild(int number) const +wxObject* wxWindowOS2::GetChild( + int nNumber +) const { - // TODO: - return((wxObject*)this); -} + // + // Return a pointer to the Nth object in the Panel + // + wxNode* pNode = GetChildren().First(); + int n = nNumber; -void wxWindow::OnDefaultAction(wxControl *initiatingItem) -{ - // TODO: -} + while (pNode && n--) + pNode = pNode->Next(); + if (pNode) + { + wxObject* pObj = (wxObject*)pNode->Data(); + return(pObj); + } + else + return NULL; +} // end of wxWindowOS2::GetChild #endif // WXWIN_COMPATIBILITY +// // Setup background and foreground colours correctly -void wxWindow::SetupColours() +// +void wxWindowOS2::SetupColours() { if ( GetParent() ) SetBackgroundColour(GetParent()->GetBackgroundColour()); -} +} // end of wxWindowOS2::SetupColours -void wxWindow::OnIdle(wxIdleEvent& event) +void wxWindowOS2::OnIdle( + wxIdleEvent& WXUNUSED(rEvent) +) { - // TODO: -} + // + // Check if we need to send a LEAVE event + // + if (m_bMouseInWindow) + { + POINTL vPoint; + + ::WinQueryPointerPos(HWND_DESKTOP, &vPoint); + if (::WinWindowFromPoint(HWND_DESKTOP, &vPoint, FALSE) != (HWND)GetHwnd()) + { + // + // Generate a LEAVE event + // + m_bMouseInWindow = FALSE; + + // + // Unfortunately the mouse button and keyboard state may have changed + // by the time the OnIdle function is called, so 'state' may be + // meaningless. + // + int nState = 0; + + if (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) != 0) + nState |= VK_SHIFT; + if (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) != 0); + nState |= VK_CTRL; + + wxMouseEvent rEvent(wxEVT_LEAVE_WINDOW); + + InitMouseEvent( rEvent + ,vPoint.x + ,vPoint.y + ,nState + ); + (void)GetEventHandler()->ProcessEvent(rEvent); + } + } + UpdateWindowUI(); +} // end of wxWindowOS2::OnIdle +// // Set this window to be the child of 'parent'. -bool wxWindow::Reparent(wxWindow *parent) +// +bool wxWindowOS2::Reparent( + wxWindow* pParent +) { - if ( !wxWindowBase::Reparent(parent) ) + if (!wxWindowBase::Reparent(pParent)) return FALSE; - // TODO: - return FALSE; -} -void wxWindow::Clear() + HWND hWndChild = GetHwnd(); + HWND hWndParent = GetParent() ? GetWinHwnd(GetParent()) : (HWND)0; + + ::WinSetParent(hWndChild, hWndParent, TRUE); + return TRUE; +} // end of wxWindowOS2::Reparent + +void wxWindowOS2::Clear() { - // TODO: -} + wxClientDC vDc((wxWindow*)this); + wxBrush vBrush( GetBackgroundColour() + ,wxSOLID + ); + + vDc.SetBackground(vBrush); + vDc.Clear(); +} // end of wxWindowOS2::Clear -void wxWindow::Refresh(bool eraseBack, const wxRect *rect) +void wxWindowOS2::Refresh( + bool bEraseBack +, const wxRect* pRect +) { - // TODO: -} + HWND hWnd = GetHwnd(); + + if (hWnd) + { + if (pRect) + { + RECTL vOs2Rect; + + vOs2Rect.xLeft = pRect->x; + vOs2Rect.yTop = pRect->y; + vOs2Rect.xRight = pRect->x + pRect->width; + vOs2Rect.yBottom = pRect->y + pRect->height; + + ::WinInvalidateRect(hWnd, &vOs2Rect, bEraseBack); + } + else + ::WinInvalidateRect(hWnd, NULL, bEraseBack); + } +} // end of wxWindowOS2::Refresh // --------------------------------------------------------------------------- // drag and drop // --------------------------------------------------------------------------- #if wxUSE_DRAG_AND_DROP -void wxWindow::SetDropTarget(wxDropTarget *pDropTarget) +void wxWindowOS2::SetDropTarget( + wxDropTarget* pDropTarget +) { - // TODO: -} + if (m_dropTarget != 0) + { + m_dropTarget->Revoke(m_hWnd); + delete m_dropTarget; + } + m_dropTarget = pDropTarget; + if (m_dropTarget != 0) + m_dropTarget->Register(m_hWnd); +} // end of wxWindowOS2::SetDropTarget #endif +// // old style file-manager drag&drop support: we retain the old-style // DragAcceptFiles in parallel with SetDropTarget. -void wxWindow::DragAcceptFiles(bool accept) +// +void wxWindowOS2::DragAcceptFiles( + bool bAccept +) { - // TODO: -} + HWND hWnd = GetHwnd(); + + if (hWnd && bAccept) + ::DrgAcceptDroppedFiles(hWnd, NULL, NULL, DO_COPY, 0L); +} // end of wxWindowOS2::DragAcceptFiles // ---------------------------------------------------------------------------- // tooltips @@ -753,13 +1370,15 @@ void wxWindow::DragAcceptFiles(bool accept) #if wxUSE_TOOLTIPS -void wxWindow::DoSetToolTip(wxToolTip *tooltip) +void wxWindowOS2::DoSetToolTip( + wxToolTip* pTooltip +) { - wxWindowBase::DoSetToolTip(tooltip); + wxWindowBase::DoSetToolTip(pTooltip); - if ( m_tooltip ) + if (m_tooltip) m_tooltip->SetWindow(this); -} +} // end of wxWindowOS2::DoSetToolTip #endif // wxUSE_TOOLTIPS @@ -768,38 +1387,173 @@ void wxWindow::DoSetToolTip(wxToolTip *tooltip) // --------------------------------------------------------------------------- // Get total size -void wxWindow::DoGetSize( int *width, int *height ) const +void wxWindowOS2::DoGetSize( + int* pWidth +, int* pHeight +) const { - // TODO: -} + HWND hWnd = GetHwnd(); + RECTL vRect; -void wxWindow::DoGetPosition( int *x, int *y ) const + ::WinQueryWindowRect(hWnd, &vRect); + + if (pWidth) + *pWidth = vRect.xRight - vRect.xLeft; + if (pHeight ) + // OS/2 PM is backwards from windows + *pHeight = vRect.yTop - vRect.yBottom; +} // end of wxWindowOS2::DoGetSize + +void wxWindowOS2::DoGetPosition( + int* pX +, int* pY +) const { - // TODO: -} + HWND hWnd = GetHwnd(); + SWP vSwp; + POINTL vPoint; + wxWindow* pParent = GetParent(); + + // + // It would seem that WinQueryWindowRect would be the correlary to + // the WIN32 WinGetRect, but unlike WinGetRect which returns the window + // origin position in screen coordinates, WinQueryWindowRect returns it + // relative to itself, i.e. (0,0). To get the same under PM we must + // us WinQueryWindowPos. This call, unlike the WIN32 call, however, + // returns a position relative to it's parent, so no parent adujstments + // are needed under OS/2. Also, windows should be created using + // wxWindow coordinates, i.e 0,0 is the TOP left so vSwp will already + // reflect that. + // + ::WinQueryWindowPos(hWnd, &vSwp); + + vPoint.x = vSwp.x; + vPoint.y = vSwp.y; + + // + // We may be faking the client origin. So a window that's really at (0, + // 30) may appear (to wxWin apps) to be at (0, 0). + // + if (pParent) + { + wxPoint vPt(pParent->GetClientAreaOrigin()); + + vPoint.x -= vPt.x; + vPoint.y -= vPt.y; + } -void wxWindow::DoScreenToClient( int *x, int *y ) const + if (pX) + *pX = vPoint.x; + if (pY) + *pY = vPoint.y; +} // end of wxWindowOS2::DoGetPosition + +void wxWindowOS2::DoScreenToClient( + int* pX +, int* pY +) const { - // TODO: -} + HWND hWnd = GetHwnd(); + SWP vSwp; + + ::WinQueryWindowPos(hWnd, &vSwp); -void wxWindow::DoClientToScreen( int *x, int *y ) const + if (pX) + *pX += vSwp.x; + if (pY) + *pY += vSwp.y; +} // end of wxWindowOS2::DoScreenToClient + +void wxWindowOS2::DoClientToScreen( + int* pX +, int* pY +) const { - // TODO: -} + HWND hWnd = GetHwnd(); + SWP vSwp; + + ::WinQueryWindowPos(hWnd, &vSwp); + if (pX) + *pX += vSwp.x; + if (pY) + *pY += vSwp.y; +} // end of wxWindowOS2::DoClientToScreen + +// // Get size *available for subwindows* i.e. excluding menu bar etc. -void wxWindow::DoGetClientSize( int *width, int *height ) const +// Must be a frame type window +// +void wxWindowOS2::DoGetClientSize( + int* pWidth +, int* pHeight +) const { - // TODO: -} + HWND hWnd = GetHwnd(); + HWND hWndClient; + RECTL vRect; -void wxWindow::DoMoveWindow(int x, int y, int width, int height) + if (IsKindOf(CLASSINFO(wxFrame))) + hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT); + else + hWndClient = NULLHANDLE; + if( hWndClient == NULLHANDLE) + ::WinQueryWindowRect(GetHwnd(), &vRect); + else + ::WinQueryWindowRect(hWndClient, &vRect); + + if (pWidth) + *pWidth = vRect.xRight; + if (pHeight) + *pHeight = vRect.yTop; +} // end of wxWindowOS2::DoGetClientSize + +void wxWindowOS2::DoMoveWindow( + int nX +, int nY +, int nWidth +, int nHeight +) { - // TODO: -} + RECTL vRect; + HWND hParent; + wxWindow* pParent = GetParent(); -// set the size of the window: if the dimensions are positive, just use them, + if (pParent) + { + hParent = GetWinHwnd(pParent); + if (pParent->IsKindOf(CLASSINFO(wxFrame))) + { + if (IsKindOf(CLASSINFO(wxStatusBar)) || + IsKindOf(CLASSINFO(wxMenuBar)) || + IsKindOf(CLASSINFO(wxToolBar)) + ) + nY = pParent->GetSize().y - (nY + nHeight); + else + nY = pParent->GetClientSize().y - (nY + nHeight); + } + else + nY = pParent->GetSize().y - (nY + nHeight); + } + else + { + RECTL vRect; + + ::WinQueryWindowRect(HWND_DESKTOP, &vRect); + nY = vRect.yTop - (nY + nHeight); + } + ::WinSetWindowPos( GetHwnd() + ,HWND_TOP + ,(LONG)nX + ,(LONG)nY + ,(LONG)nWidth + ,(LONG)nHeight + ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW + ); +} // end of wxWindowOS2::DoMoveWindow + +// +// Set the size of the window: if the dimensions are positive, just use them, // but if any of them is equal to -1, it means that we must find the value for // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in // which case -1 is a valid value for x and y) @@ -807,336 +1561,852 @@ void wxWindow::DoMoveWindow(int x, int y, int width, int height) // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate // the width/height to best suit our contents, otherwise we reuse the current // width/height -void wxWindow::DoSetSize(int x, int y, - int width, int height, - int sizeFlags) +// +void wxWindowOS2::DoSetSize( + int nX +, int nY +, int nWidth +, int nHeight +, int nSizeFlags +) { - // TODO: -} + // + // Get the current size and position... + // + int nCurrentX; + int nCurrentY; + int nCurrentWidth; + int nCurrentHeight; + wxSize vSize(-1, -1); + + GetPosition(&nCurrentX, &nCurrentY); + GetSize(&nCurrentWidth, &nCurrentHeight); + + // ... and don't do anything (avoiding flicker) if it's already ok + if (nX == nCurrentX && nY == nCurrentY && + nWidth == nCurrentWidth && nHeight == nCurrentHeight) + { + return; + } -void wxWindow::DoSetClientSize(int width, int height) -{ - // TODO: -} + if (nX == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + nX = nCurrentX; + if (nY == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + nY = nCurrentY; -wxPoint wxWindow::GetClientAreaOrigin() const + AdjustForParentClientOrigin(nX, nY, nSizeFlags); + + if (nWidth == -1) + { + if (nSizeFlags & wxSIZE_AUTO_WIDTH) + { + vSize = DoGetBestSize(); + nWidth = vSize.x; + } + else + { + // + // Just take the current one + // + nWidth = nCurrentWidth; + } + } + + if (nHeight == -1) + { + if (nSizeFlags & wxSIZE_AUTO_HEIGHT) + { + if (vSize.x == -1) + { + vSize = DoGetBestSize(); + } + nHeight = vSize.y; + } + else + { + // just take the current one + nHeight = nCurrentHeight; + } + } + + DoMoveWindow( nX + ,nY + ,nWidth + ,nHeight + ); +} // end of wxWindowOS2::DoSetSize + +void wxWindowOS2::DoSetClientSize( + int nWidth +, int nHeight +) { - return wxPoint(0, 0); -} + wxWindow* pParent = GetParent(); + HWND hWnd = GetHwnd(); + HWND hParentWnd = (HWND)0; + POINTL vPoint; + RECTL vRect; + RECTL vRect2; + RECTL vRect3; + HWND hClientWnd = (HWND)0; -void wxWindow::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags) + hClientWnd = ::WinWindowFromID(hWnd, FID_CLIENT); + ::WinQueryWindowRect(hClientWnd, &vRect2); + ::WinQueryWindowRect(hWnd, &vRect); + ::WinQueryWindowRect(hParentWnd, &vRect3); + + int nActualWidth = vRect2.xRight - vRect2.xLeft - vRect.xRight + nWidth; + int nActualHeight = vRect2.yTop - vRect2.yBottom - vRect.yTop + nHeight; + + vPoint.x = vRect2.xLeft; + vPoint.y = vRect2.yBottom; + if (pParent) + { + vPoint.x -= vRect3.xLeft; + vPoint.y -= vRect3.yBottom; + } + + DoMoveWindow(vPoint.x, vPoint.y, nActualWidth, nActualHeight); + + wxSizeEvent vEvent(wxSize(nWidth, nHeight), m_windowId); + vEvent.SetEventObject(this); + GetEventHandler()->ProcessEvent(vEvent); +} // end of wxWindowOS2::DoSetClientSize + +wxPoint wxWindowOS2::GetClientAreaOrigin() const { - // TODO: -} + return wxPoint(0, 0); +} // end of wxWindowOS2::GetClientAreaOrigin // --------------------------------------------------------------------------- // text metrics // --------------------------------------------------------------------------- -int wxWindow::GetCharHeight() const +int wxWindowOS2::GetCharHeight() const { - // TODO: - return(1); -} + HPS hPs; + FONTMETRICS vFontMetrics; + + hPs = ::WinGetPS(GetHwnd()); + + if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics)) + { + ::WinReleasePS(hPs); + return (0); + } + ::WinReleasePS(hPs); + return(vFontMetrics.lMaxAscender + vFontMetrics.lMaxDescender); +} // end of wxWindowOS2::GetCharHeight -int wxWindow::GetCharWidth() const +int wxWindowOS2::GetCharWidth() const { - // TODO: - return(1); -} + HPS hPs; + FONTMETRICS vFontMetrics; + + hPs = ::WinGetPS(GetHwnd()); -void wxWindow::GetTextExtent( const wxString& string - ,int* x - ,int* y - ,int* descent - ,int* externalLeading - ,const wxFont* theFont - ) const + if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics)) + { + ::WinReleasePS(hPs); + return (0); + } + ::WinReleasePS(hPs); + return(vFontMetrics.lAveCharWidth); +} // end of wxWindowOS2::GetCharWidth + +void wxWindowOS2::GetTextExtent( + const wxString& rString +, int* pX +, int* pY +, int* pDescent +, int* pExternalLeading +, const wxFont* pTheFont +) const { - // TODO: -} + POINTL avPoint[TXTBOX_COUNT]; + POINTL vPtMin; + POINTL vPtMax; + int i; + int l; + FONTMETRICS vFM; // metrics structure + BOOL bRc; + char* pStr; + ERRORID vErrorCode; // last error id code + HPS hPS; + + + hPS = ::WinGetPS(GetHwnd()); + + l = rString.Length(); + if (l > 0L) + { + pStr = (PCH)rString.c_str(); + + // + // In world coordinates. + // + bRc = ::GpiQueryTextBox( hPS + ,l + ,pStr + ,TXTBOX_COUNT // return maximum information + ,avPoint // array of coordinates points + ); + if (bRc) + { + vPtMin.x = avPoint[0].x; + vPtMax.x = avPoint[0].x; + vPtMin.y = avPoint[0].y; + vPtMax.y = avPoint[0].y; + for (i = 1; i < 4; i++) + { + if(vPtMin.x > avPoint[i].x) vPtMin.x = avPoint[i].x; + if(vPtMin.y > avPoint[i].y) vPtMin.y = avPoint[i].y; + if(vPtMax.x < avPoint[i].x) vPtMax.x = avPoint[i].x; + if(vPtMax.y < avPoint[i].y) vPtMax.y = avPoint[i].y; + } + bRc = ::GpiQueryFontMetrics( hPS + ,sizeof(FONTMETRICS) + ,&vFM + ); + if (!bRc) + { + vPtMin.x = 0; + vPtMin.y = 0; + vPtMax.x = 0; + vPtMax.y = 0; + } + } + else + { + vPtMin.x = 0; + vPtMin.y = 0; + vPtMax.x = 0; + vPtMax.y = 0; + } + } + else + { + vPtMin.x = 0; + vPtMin.y = 0; + vPtMax.x = 0; + vPtMax.y = 0; + } + if (pX) + *pX = (vPtMax.x - vPtMin.x + 1); + if (pY) + *pY = (vPtMax.y - vPtMin.y + 1); + if (pDescent) + { + if (bRc) + *pDescent = vFM.lMaxDescender; + else + *pDescent = 0; + } + if (pExternalLeading) + { + if (bRc) + *pExternalLeading = vFM.lExternalLeading; + else + *pExternalLeading = 0; + } + ::WinReleasePS(hPS); +} // end of wxWindow::GetTextExtent #if wxUSE_CARET && WXWIN_COMPATIBILITY // --------------------------------------------------------------------------- // Caret manipulation // --------------------------------------------------------------------------- -void wxWindow::CreateCaret(int w, int h) +void wxWindowOS2::CreateCaret( + int nWidth +, int nHeight +) { - // TODO: -} + SetCaret(new wxCaret( this + ,nWidth + ,nHeight + )); +} // end of wxWindowOS2::CreateCaret -void wxWindow::CreateCaret(const wxBitmap *bitmap) +void wxWindowOS2::CreateCaret( + const wxBitmap* pBitmap +) { - // TODO: -} + wxFAIL_MSG("not implemented"); +} // end of wxWindowOS2::CreateCaret -void wxWindow::ShowCaret(bool show) +void wxWindowOS2::ShowCaret( + bool bShow +) { - // TODO: -} + wxCHECK_RET( m_caret, "no caret to show" ); -void wxWindow::DestroyCaret() + m_caret->Show(bShow); +} // end of wxWindowOS2::ShowCaret + +void wxWindowOS2::DestroyCaret() { - // TODO: -} + SetCaret(NULL); +} // end of wxWindowOS2::DestroyCaret -void wxWindow::SetCaretPos(int x, int y) +void wxWindowOS2::SetCaretPos( + int nX +, int nY) { - // TODO: -} + wxCHECK_RET( m_caret, "no caret to move" ); + + m_caret->Move( nX + ,nY + ); +} // end of wxWindowOS2::SetCaretPos -void wxWindow::GetCaretPos(int *x, int *y) const +void wxWindowOS2::GetCaretPos( + int* pX +, int* pY +) const { - // TODO: -} + wxCHECK_RET( m_caret, "no caret to get position of" ); + + m_caret->GetPosition( pX + ,pY + ); +} // end of wxWindowOS2::GetCaretPos #endif //wxUSE_CARET // --------------------------------------------------------------------------- // popup menu // --------------------------------------------------------------------------- - -bool wxWindow::DoPopupMenu( wxMenu *menu, int x, int y ) +// +#if wxUSE_MENUS_NATIVE +static void wxYieldForCommandsOnly() { - // TODO: - return(TRUE); + // + // Peek all WM_COMMANDs (it will always return WM_QUIT too but we don't + // want to process it here) + // + QMSG vMsg; + + while (::WinPeekMsg(vHabmain, &vMsg, (HWND)0, WM_COMMAND, + WM_COMMAND,PM_REMOVE) && vMsg.msg != WM_QUIT) + { + wxTheApp->DoMessage((WXMSG*)&vMsg); + } } +#endif // wxUSE_MENUS_NATIVE + +#if wxUSE_MENUS_NATIVE +bool wxWindowOS2::DoPopupMenu( + wxMenu* pMenu +, int nX +, int nY +) +{ + HWND hWnd = GetHwnd(); + HWND hWndParent = GetParent() ? GetWinHwnd(GetParent()) : (HWND)0; + HWND hMenu = GetHmenuOf(pMenu); + + pMenu->SetInvokingWindow(this); + pMenu->UpdateUI(); + + DoClientToScreen( &nX + ,&nY + ); + wxCurrentPopupMenu = pMenu; + + ::WinPopupMenu( hWndParent + ,hWnd + ,hMenu + ,nX + ,nY + ,0L + ,PU_MOUSEBUTTON2DOWN | PU_MOUSEBUTTON2 | PU_KEYBOARD + ); + // we need to do it righ now as otherwise the events are never going to be + // sent to wxCurrentPopupMenu from ;() + // + // note that even eliminating (ugly) wxCurrentPopupMenu global wouldn't + // help and we'd still need wxYieldForCommandsOnly() as the menu may be + // destroyed as soon as we return (it can be a local variable in the caller + // for example) and so we do need to process the event immediately + wxYieldForCommandsOnly(); + wxCurrentPopupMenu = NULL; + + pMenu->SetInvokingWindow(NULL); + return TRUE; +} // end of wxWindowOS2::DoPopupMenu +#endif // wxUSE_MENUS_NATIVE // =========================================================================== // pre/post message processing // =========================================================================== -MRESULT wxWindow::OS2DefWindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) +MRESULT wxWindowOS2::OS2DefWindowProc( + WXUINT uMsg +, WXWPARAM wParam +, WXLPARAM lParam +) { - // TODO: - return (MRESULT)0; -} + if (m_fnOldWndProc) + return (MRESULT)m_fnOldWndProc(GetHWND(), uMsg, (MPARAM)wParam, (MPARAM)lParam); + else + return ::WinDefWindowProc(GetHWND(), uMsg, (MPARAM)wParam, (MPARAM)lParam); +} // end of wxWindowOS2::OS2DefWindowProc -bool wxWindow::OS2ProcessMessage(WXMSG* pMsg) +bool wxWindowOS2::OS2ProcessMessage( + WXMSG* pMsg +) { - // TODO: +// wxUniversal implements tab traversal itself +#ifndef __WXUNIVERSAL__ + QMSG* pQMsg = (QMSG*)pMsg; + + if (m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL)) + { + // + // Intercept dialog navigation keys + // + bool bProcess = TRUE; + USHORT uKeyFlags = SHORT1FROMMP(pQMsg->mp1); + + if (uKeyFlags & KC_KEYUP) + bProcess = FALSE; + + if (uKeyFlags & KC_ALT) + bProcess = FALSE; + + if (!(uKeyFlags & KC_VIRTUALKEY)) + bProcess = FALSE; + + if (bProcess) + { + bool bCtrlDown = IsCtrlDown(); + bool bShiftDown = IsShiftDown(); + + // + // WM_QUERYDLGCODE: ask the control if it wants the key for itself, + // don't process it if it's the case (except for Ctrl-Tab/Enter + // combinations which are always processed) + // + ULONG ulDlgCode = 0; + + if (!bCtrlDown) + { + ulDlgCode = (ULONG)::WinSendMsg(pQMsg->hwnd, WM_QUERYDLGCODE, pQMsg, 0); + } + + bool bForward = TRUE; + bool bWindowChange = FALSE; + + switch (SHORT2FROMMP(pQMsg->mp2)) + { + // + // Going to make certain assumptions about specific types of controls + // here, so we may have to alter some things later if they prove invalid + // + case VK_TAB: + // + // Shift tabl will always be a nav-key but tabs may be wanted + // + if (!bShiftDown) + { + bProcess = FALSE; + } + else + { + // + // Entry Fields want tabs for themselve usually + // + switch (ulDlgCode) + { + case DLGC_ENTRYFIELD: + case DLGC_MLE: + bProcess = TRUE; + break; + + default: + bProcess = FALSE; + } + + // + // Ctrl-Tab cycles thru notebook pages + // + bWindowChange = bCtrlDown; + bForward = !bShiftDown; + } + break; + + case VK_UP: + case VK_LEFT: + if (bCtrlDown) + bProcess = FALSE; + else + bForward = FALSE; + break; + + case VK_DOWN: + case VK_RIGHT: + if (bCtrlDown) + bProcess = FALSE; + break; + + case VK_ENTER: + { + if (bCtrlDown) + { + // + // ctrl-enter is not processed + // + return FALSE; + } + else if (ulDlgCode & DLGC_BUTTON) + { + // + // buttons want process Enter themselevs + // + bProcess = FALSE; + } + else + { + wxButton* pBtn = wxDynamicCast( GetDefaultItem() + ,wxButton + ); + + if (pBtn && pBtn->IsEnabled()) + { + // + // If we do have a default button, do press it + // + pBtn->OS2Command(BN_CLICKED, 0 /* unused */); + return TRUE; + } + // else: but if it does not it makes sense to make + // it work like a TAB - and that's what we do. + // Note that Ctrl-Enter always works this way. + } + } + break; + + default: + bProcess = FALSE; + } + + if (bProcess) + { + wxNavigationKeyEvent vEvent; + + vEvent.SetDirection(bForward); + vEvent.SetWindowChange(bWindowChange); + vEvent.SetEventObject(this); + + if (GetEventHandler()->ProcessEvent(vEvent)) + { + wxButton* pBtn = wxDynamicCast(FindFocus(), wxButton); + + if (pBtn) + { + // + // The button which has focus should be default + // + pBtn->SetDefault(); + } + return TRUE; + } + } + } + // + // Let Dialogs process + // + if (::WinSendMsg(pQMsg->hwnd, WM_QUERYDLGCODE, pQMsg, 0)); + return TRUE; + } +#else + pMsg = pMsg; // just shut up the compiler +#endif // __WXUNIVERSAL__ + +#if wxUSE_TOOLTIPS + if ( m_tooltip ) + { + // relay mouse move events to the tooltip control + QMSG* pQMsg = (QMSG*)pMsg; + + if (pQMsg->msg == WM_MOUSEMOVE ) + m_tooltip->RelayEvent(pMsg); + } +#endif // wxUSE_TOOLTIPS + return FALSE; -} +} // end of wxWindowOS2::OS2ProcessMessage -bool wxWindow::OS2TranslateMessage(WXMSG* pMsg) +bool wxWindowOS2::OS2TranslateMessage( + WXMSG* pMsg +) { - return m_acceleratorTable.Translate(this, pMsg); -} +#if wxUSE_ACCEL && !defined(__WXUNIVERSAL__) + return m_acceleratorTable.Translate(m_hWnd, pMsg); +#else + pMsg = pMsg; + return FALSE; +#endif //wxUSE_ACCEL +} // end of wxWindowOS2::OS2TranslateMessage // --------------------------------------------------------------------------- -// message params unpackers (different for Win16 and Win32) +// message params unpackers // --------------------------------------------------------------------------- -void wxWindow::UnpackCommand(WXWPARAM wParam, WXLPARAM lParam, - WORD *id, WXHWND *hwnd, WORD *cmd) +void wxWindowOS2::UnpackCommand( + WXWPARAM wParam +, WXLPARAM lParam +, WORD* pId +, WXHWND* phWnd +, WORD* pCmd +) { - *id = LOWORD(wParam); - *hwnd = (WXHWND)lParam; - *cmd = HIWORD(wParam); -} + *pId = LOWORD(wParam); + *phWnd = NULL; // or may be GetHWND() ? + *pCmd = LOWORD(lParam); +} // end of wxWindowOS2::UnpackCommand -void wxWindow::UnpackActivate(WXWPARAM wParam, WXLPARAM lParam, - WXWORD *state, WXWORD *minimized, WXHWND *hwnd) -{ - *state = LOWORD(wParam); - *minimized = HIWORD(wParam); - *hwnd = (WXHWND)lParam; -} - -void wxWindow::UnpackScroll(WXWPARAM wParam, WXLPARAM lParam, - WXWORD *code, WXWORD *pos, WXHWND *hwnd) +void wxWindowOS2::UnpackActivate( + WXWPARAM wParam +, WXLPARAM lParam +, WXWORD* pState +, WXHWND* phWnd +) { - *code = LOWORD(wParam); - *pos = HIWORD(wParam); - *hwnd = (WXHWND)lParam; -} + *pState = LOWORD(wParam); + *phWnd = (WXHWND)lParam; +} // end of wxWindowOS2::UnpackActivate -void wxWindow::UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam, - WXWORD *nCtlColor, WXHDC *hdc, WXHWND *hwnd) +void wxWindowOS2::UnpackScroll( + WXWPARAM wParam +, WXLPARAM lParam +, WXWORD* pCode +, WXWORD* pPos +, WXHWND* phWnd +) { - *nCtlColor = 0; // TODO: CTLCOLOR_BTN; - *hwnd = (WXHWND)lParam; - *hdc = (WXHDC)wParam; -} + ULONG ulId; + HWND hWnd; -void wxWindow::UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam, - WXWORD *item, WXWORD *flags, WXHMENU *hmenu) + ulId = (ULONG)LONGFROMMP(wParam); + hWnd = ::WinWindowFromID(GetHwnd(), ulId); + if (hWnd == m_hWndScrollBarHorz || hWnd == m_hWndScrollBarVert) + *phWnd = NULLHANDLE; + else + *phWnd = hWnd; + + *pPos = SHORT1FROMMP(lParam); + *pCode = SHORT2FROMMP(lParam); +} // end of wxWindowOS2::UnpackScroll + +void wxWindowOS2::UnpackMenuSelect( + WXWPARAM wParam +, WXLPARAM lParam +, WXWORD* pItem +, WXWORD* pFlags +, WXHMENU* phMenu +) { - *item = (WXWORD)LOWORD(wParam); - *flags = HIWORD(wParam); - *hmenu = (WXHMENU)lParam; -} + *pItem = (WXWORD)LOWORD(wParam); + *pFlags = HIWORD(wParam); + *phMenu = (WXHMENU)lParam; +} // end of wxWindowOS2::UnpackMenuSelect // --------------------------------------------------------------------------- // Main wxWindows window proc and the window proc for wxWindow // --------------------------------------------------------------------------- +// // Hook for new window just as it's being created, when the window isn't yet // associated with the handle -wxWindow *wxWndHook = NULL; +// +wxWindowOS2* wxWndHook = NULL; +// // Main window proc -MRESULT wxWndProc(HWND hWnd, ULONG message, MPARAM wParam, MPARAM lParam) +// +MRESULT EXPENTRY wxWndProc( + HWND hWnd +, ULONG ulMsg +, MPARAM wParam +, MPARAM lParam +) { - // trace all messages - useful for the debugging + // + // Trace all ulMsgs - useful for the debugging + // #ifdef __WXDEBUG__ wxLogTrace(wxTraceMessages, wxT("Processing %s(wParam=%8lx, lParam=%8lx)"), - wxGetMessageName(message), wParam, lParam); + wxGetMessageName(ulMsg), wParam, lParam); #endif // __WXDEBUG__ - wxWindow *wnd = wxFindWinFromHandle((WXHWND) hWnd); + wxWindowOS2* pWnd = wxFindWinFromHandle((WXHWND)hWnd); - // when we get the first message for the HWND we just created, we associate + // + // When we get the first message for the HWND we just created, we associate // it with wxWindow stored in wxWndHook - if ( !wnd && wxWndHook ) + // + if (!pWnd && wxWndHook) { -#if 0 // def __WXDEBUG__ - char buf[512]; - ::GetClassNameA((HWND) hWnd, buf, 512); - wxString className(buf); -#endif - wxAssociateWinWithHandle(hWnd, wxWndHook); - wnd = wxWndHook; + pWnd = wxWndHook; wxWndHook = NULL; - wnd->SetHWND((WXHWND)hWnd); + pWnd->SetHWND((WXHWND)hWnd); } - MRESULT rc; + MRESULT rc = (MRESULT)0; + + // // Stop right here if we don't have a valid handle in our wxWindow object. - if ( wnd && !wnd->GetHWND() ) + // + if (pWnd && !pWnd->GetHWND()) { - // FIXME: why do we do this? - wnd->SetHWND((WXHWND) hWnd); - rc = wnd->OS2DefWindowProc(hWnd, message, wParam, lParam ); - wnd->SetHWND(0); + pWnd->SetHWND((WXHWND) hWnd); + rc = pWnd->OS2DefWindowProc(ulMsg, wParam, lParam ); + pWnd->SetHWND(0); } else { - if ( wnd ) - rc = wnd->OS2WindowProc(hWnd, message, wParam, lParam); + if (pWnd) + rc = pWnd->OS2WindowProc(ulMsg, wParam, lParam); else - rc = 0; //TODO: DefWindowProc( hWnd, message, wParam, lParam ); + rc = ::WinDefWindowProc(hWnd, ulMsg, wParam, lParam); } return rc; -} +} // end of wxWndProc -MRESULT wxWindow::OS2WindowProc(HWND hWnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam) +// +// We will add (or delete) messages we need to handle at this default +// level as we go +// +MRESULT wxWindowOS2::OS2WindowProc( + WXUINT uMsg +, WXWPARAM wParam +, WXLPARAM lParam +) { - // did we process the message? - bool processed = FALSE; + // + // Did we process the uMsg? + // + bool bProcessed = FALSE; + MRESULT mResult; - // the return value - union - { - bool allow; - long result; - WXHICON hIcon; - WXHBRUSH hBrush; - } rc; + // + // For most messages we should return 0 when we do process the message + // + mResult = (MRESULT)0; - // for most messages we should return 0 when we do process the message - rc.result = 0; - // TODO: -/* - switch ( message ) + switch (uMsg) { case WM_CREATE: { - bool mayCreate; - processed = HandleCreate((WXLPCREATESTRUCT)lParam, &mayCreate); - if ( processed ) + bool bMayCreate; + + bProcessed = HandleCreate( (WXLPCREATESTRUCT)lParam + ,&bMayCreate + ); + if (bProcessed) { - // return 0 to allow window creation - rc.result = mayCreate ? 0 : -1; + // + // Return 0 to bAllow window creation + // + mResult = (MRESULT)(bMayCreate ? 0 : -1); } } break; case WM_DESTROY: - processed = HandleDestroy(); - break; + HandleDestroy(); + bProcessed = TRUE; + break; case WM_MOVE: - processed = HandleMove(LOWORD(lParam), HIWORD(lParam)); + bProcessed = HandleMove( LOWORD(lParam) + ,HIWORD(lParam) + ); break; case WM_SIZE: - processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam); + bProcessed = HandleSize( LOWORD(lParam) + ,HIWORD(lParam) + ,(WXUINT)wParam + ); break; case WM_ACTIVATE: { - WXWORD state, minimized; - WXHWND hwnd; - UnpackActivate(wParam, lParam, &state, &minimized, &hwnd); - - processed = HandleActivate(state, minimized != 0, (WXHWND)hwnd); + WXWORD wState; + WXHWND hWnd; + + UnpackActivate( wParam + ,lParam + ,&wState + ,&hWnd + ); + + bProcessed = HandleActivate( wState + ,(WXHWND)hWnd + ); + bProcessed = FALSE; } break; case WM_SETFOCUS: - processed = HandleSetFocus((WXHWND)(HWND)wParam); - break; - - case WM_KILLFOCUS: - processed = HandleKillFocus((WXHWND)(HWND)wParam); + if (SHORT1FROMMP((MPARAM)lParam) == TRUE) + bProcessed = HandleSetFocus((WXHWND)(HWND)wParam); + else + bProcessed = HandleKillFocus((WXHWND)(HWND)wParam); break; case WM_PAINT: - processed = HandlePaint(); + bProcessed = HandlePaint(); break; case WM_CLOSE: - // don't let the DefWindowProc() destroy our window - we'll do it + // + // Don't let the DefWindowProc() destroy our window - we'll do it // ourselves in ~wxWindow - processed = TRUE; - rc.result = TRUE; + // + bProcessed = TRUE; + mResult = (MRESULT)TRUE; break; - case WM_SHOWWINDOW: - processed = HandleShow(wParam != 0, (int)lParam); + case WM_SHOW: + bProcessed = HandleShow(wParam != 0, (int)lParam); break; + // + // Under OS2 PM Joysticks are treated just like mouse events + // The "Motion" events will be prevelent in joysticks + // case WM_MOUSEMOVE: - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_LBUTTONDBLCLK: - case WM_RBUTTONDOWN: - case WM_RBUTTONUP: - case WM_RBUTTONDBLCLK: - case WM_MBUTTONDOWN: - case WM_MBUTTONUP: - case WM_MBUTTONDBLCLK: + case WM_BUTTON1DOWN: + case WM_BUTTON1UP: + case WM_BUTTON1DBLCLK: + case WM_BUTTON1MOTIONEND: + case WM_BUTTON1MOTIONSTART: + case WM_BUTTON2DOWN: + case WM_BUTTON2UP: + case WM_BUTTON2DBLCLK: + case WM_BUTTON2MOTIONEND: + case WM_BUTTON2MOTIONSTART: + case WM_BUTTON3DOWN: + case WM_BUTTON3UP: + case WM_BUTTON3DBLCLK: + case WM_BUTTON3MOTIONEND: + case WM_BUTTON3MOTIONSTART: { short x = LOWORD(lParam); short y = HIWORD(lParam); - processed = HandleMouseEvent(message, x, y, wParam); - } - break; - - case MM_JOY1MOVE: - case MM_JOY2MOVE: - case MM_JOY1ZMOVE: - case MM_JOY2ZMOVE: - case MM_JOY1BUTTONDOWN: - case MM_JOY2BUTTONDOWN: - case MM_JOY1BUTTONUP: - case MM_JOY2BUTTONUP: - { - int x = LOWORD(lParam); - int y = HIWORD(lParam); - - processed = HandleJoystickEvent(message, x, y, wParam); + bProcessed = HandleMouseEvent(uMsg, x, y, (WXUINT)wParam); } break; - case WM_SYSCOMMAND: - processed = HandleSysCommand(wParam, lParam); + bProcessed = HandleSysCommand(wParam, lParam); break; case WM_COMMAND: @@ -1145,756 +2415,846 @@ MRESULT wxWindow::OS2WindowProc(HWND hWnd, WXUINT message, WXWPARAM wParam, WXLP WXHWND hwnd; UnpackCommand(wParam, lParam, &id, &hwnd, &cmd); - processed = HandleCommand(id, cmd, hwnd); + bProcessed = HandleCommand(id, cmd, hwnd); } break; -#ifdef __WIN95__ - case WM_NOTIFY: - processed = HandleNotify((int)wParam, lParam, &rc.result); - break; -#endif // Win95 - - // for these messages we must return TRUE if process the message + // + // For these messages we must return TRUE if process the message + // case WM_DRAWITEM: case WM_MEASUREITEM: { - int idCtrl = (UINT)wParam; - if ( message == WM_DRAWITEM ) + int nIdCtrl = (UINT)wParam; + + if ( uMsg == WM_DRAWITEM ) { - processed = MSWOnDrawItem(idCtrl, + bProcessed = OS2OnDrawItem(nIdCtrl, (WXDRAWITEMSTRUCT *)lParam); } else { - processed = MSWOnMeasureItem(idCtrl, + bProcessed = OS2OnMeasureItem(nIdCtrl, (WXMEASUREITEMSTRUCT *)lParam); } - if ( processed ) - rc.result = TRUE; + if ( bProcessed ) + mResult = (MRESULT)TRUE; } break; - case WM_GETDLGCODE: + case WM_QUERYDLGCODE: if ( m_lDlgCode ) { - rc.result = m_lDlgCode; - processed = TRUE; + mResult = (MRESULT)m_lDlgCode; + bProcessed = TRUE; } + // //else: get the dlg code from the DefWindowProc() + // break; - case WM_KEYDOWN: - // If this has been processed by an event handler, - // return 0 now (we've handled it). - if ( HandleKeyDown((WORD) wParam, lParam) ) - { - processed = TRUE; - - break; - } - - // we consider these message "not interesting" to OnChar - if ( wParam == VK_SHIFT || wParam == VK_CONTROL ) - { - processed = TRUE; - - break; - } - - switch ( wParam ) + // + // In OS/2 PM all keyboard events are of the WM_CHAR type. Virtual key and key-up + // and key-down events are obtained from the WM_CHAR params. + // + case WM_CHAR: { - // avoid duplicate messages to OnChar for these ASCII keys: they - // will be translated by TranslateMessage() and received in WM_CHAR - case VK_ESCAPE: - case VK_SPACE: - case VK_RETURN: - case VK_BACK: - case VK_TAB: - // but set processed to FALSE, not TRUE to still pass them to - // the control's default window proc - otherwise built-in - // keyboard handling won't work - processed = FALSE; + USHORT uKeyFlags = SHORT1FROMMP((MPARAM)wParam); + if (uKeyFlags & KC_KEYUP) + { + //TODO: check if the cast to WXWORD isn't causing trouble + bProcessed = HandleKeyUp((WXDWORD)wParam, lParam); break; - -#ifdef VK_APPS - // special case of VK_APPS: treat it the same as right mouse - // click because both usually pop up a context menu - case VK_APPS: + } + else // keydown event + { + // + // If this has been processed by an event handler, + // return 0 now (we've handled it). DON't RETURN + // we still need to process further + // + HandleKeyDown((WXDWORD)wParam, lParam); + if (uKeyFlags & KC_VIRTUALKEY) { - // construct the key mask - WPARAM fwKeys = MK_RBUTTON; - if ( (::GetKeyState(VK_CONTROL) & 0x100) != 0 ) - fwKeys |= MK_CONTROL; - if ( (::GetKeyState(VK_SHIFT) & 0x100) != 0 ) - fwKeys |= MK_SHIFT; - - // simulate right mouse button click - DWORD dwPos = ::GetMessagePos(); - int x = GET_X_LPARAM(dwPos), - y = GET_Y_LPARAM(dwPos); - - ScreenToClient(&x, &y); - processed = HandleMouseEvent(WM_RBUTTONDOWN, x, y, fwKeys); + USHORT uVk = SHORT2FROMMP((MPARAM)lParam); + + // + // We consider these message "not interesting" to OnChar + // + if (uVk == VK_SHIFT || uVk == VK_CTRL ) + { + bProcessed = TRUE; + break; + } + switch(uVk) + { + // + // Avoid duplicate messages to OnChar for these ASCII keys: they + // will be translated by TranslateMessage() and received in WM_CHAR + case VK_ESC: + case VK_SPACE: + case VK_ENTER: + case VK_BACKSPACE: + case VK_TAB: + // But set processed to FALSE, not TRUE to still pass them to + // the control's default window proc - otherwise built-in + // keyboard handling won't work + bProcessed = FALSE; + break; + + case VK_LEFT: + case VK_RIGHT: + case VK_DOWN: + case VK_UP: + default: + bProcessed = HandleChar((WXDWORD)wParam, lParam); + } + break; } - break; -#endif // VK_APPS - - case VK_LEFT: - case VK_RIGHT: - case VK_DOWN: - case VK_UP: - default: - processed = HandleChar((WORD)wParam, lParam); + else // WM_CHAR -- Always an ASCII character + { + bProcessed = HandleChar((WXDWORD)wParam, lParam, TRUE); + break; + } + } } - break; - - case WM_KEYUP: - processed = HandleKeyUp((WORD) wParam, lParam); - break; - - case WM_CHAR: // Always an ASCII character - processed = HandleChar((WORD)wParam, lParam, TRUE); - break; case WM_HSCROLL: case WM_VSCROLL: { - WXWORD code, pos; - WXHWND hwnd; - UnpackScroll(wParam, lParam, &code, &pos, &hwnd); - - processed = MSWOnScroll(message == WM_HSCROLL ? wxHORIZONTAL - : wxVERTICAL, - code, pos, hwnd); + WXWORD wCode; + WXWORD wPos; + WXHWND hWnd; + UnpackScroll( wParam + ,lParam + ,&wCode + ,&wPos + ,&hWnd + ); + + bProcessed = OS2OnScroll( uMsg == WM_HSCROLL ? wxHORIZONTAL + : wxVERTICAL + ,wCode + ,wPos + ,hWnd + ); } break; - // CTLCOLOR messages are sent by children to query the parent for their - // colors -#ifdef __WIN32__ - case WM_CTLCOLORMSGBOX: - case WM_CTLCOLOREDIT: - case WM_CTLCOLORLISTBOX: - case WM_CTLCOLORBTN: - case WM_CTLCOLORDLG: - case WM_CTLCOLORSCROLLBAR: - case WM_CTLCOLORSTATIC: -#else // Win16 - case WM_CTLCOLOR: -#endif // Win32/16 +#if defined(__VISAGECPP__) && (__IBMCPP__ >= 400) + case WM_CTLCOLORCHANGE: { - WXWORD nCtlColor; - WXHDC hdc; - WXHWND hwnd; - UnpackCtlColor(wParam, lParam, &nCtlColor, &hdc, &hwnd); - - processed = HandleCtlColor(&rc.hBrush, - (WXHDC)hdc, - (WXHWND)hwnd, - nCtlColor, - message, - wParam, - lParam); + bProcessed = HandleCtlColor(&hBrush); } break; +#endif + case WM_ERASEBACKGROUND: + // + // Returning TRUE to requestw PM to paint the window background + // in SYSCLR_WINDOW. We don't really want that + // + bProcessed = HandleEraseBkgnd((WXHDC)(HPS)wParam); + mResult = (MRESULT)(FALSE); + break; // the return value for this message is ignored case WM_SYSCOLORCHANGE: - processed = HandleSysColorChange(); - break; - - case WM_PALETTECHANGED: - processed = HandlePaletteChanged((WXHWND) (HWND) wParam); - break; - - case WM_QUERYNEWPALETTE: - processed = HandleQueryNewPalette(); + bProcessed = HandleSysColorChange(); break; - case WM_ERASEBKGND: - processed = HandleEraseBkgnd((WXHDC)(HDC)wParam); - if ( processed ) - { - // we processed the message, i.e. erased the background - rc.result = TRUE; - } + case WM_REALIZEPALETTE: + bProcessed = HandlePaletteChanged(); break; - case WM_DROPFILES: - processed = HandleDropFiles(wParam); + // move all drag and drops to wxDrg + case WM_ENDDRAG: + bProcessed = HandleEndDrag(wParam); break; - case WM_INITDIALOG: - processed = HandleInitDialog((WXHWND)(HWND)wParam); + case WM_INITDLG: + bProcessed = HandleInitDialog((WXHWND)(HWND)wParam); - if ( processed ) + if ( bProcessed ) { // we never set focus from here - rc.result = FALSE; + mResult = FALSE; } break; - case WM_QUERYENDSESSION: - processed = HandleQueryEndSession(lParam, &rc.allow); - break; - - case WM_ENDSESSION: - processed = HandleEndSession(wParam != 0, lParam); + // wxFrame specific message + case WM_MINMAXFRAME: + bProcessed = HandleGetMinMaxInfo((PSWP)wParam); break; - case WM_GETMINMAXINFO: - processed = HandleGetMinMaxInfo((MINMAXINFO*)lParam); + case WM_SYSVALUECHANGED: + // TODO: do something + mResult = (MRESULT)TRUE; break; - case WM_SETCURSOR: - processed = HandleSetCursor((WXHWND)(HWND)wParam, - LOWORD(lParam), // hit test - HIWORD(lParam)); // mouse msg - - if ( processed ) + // + // Comparable to WM_SETPOINTER for windows, only for just controls + // + case WM_CONTROLPOINTER: + bProcessed = HandleSetCursor( SHORT1FROMMP(wParam) // Control ID + ,(HWND)lParam // Cursor Handle + ); + if (bProcessed ) { - // returning TRUE stops the DefWindowProc() from further + // + // Returning TRUE stops the DefWindowProc() from further // processing this message - exactly what we need because we've // just set the cursor. - rc.result = TRUE; + // + mResult = (MRESULT)TRUE; } break; } - - if ( !processed ) + if (!bProcessed) { #ifdef __WXDEBUG__ wxLogTrace(wxTraceMessages, wxT("Forwarding %s to DefWindowProc."), - wxGetMessageName(message)); + wxGetMessageName(uMsg)); #endif // __WXDEBUG__ - rc.result = MSWDefWindowProc(message, wParam, lParam); + if (IsKindOf(CLASSINFO(wxFrame))) + mResult = ::WinDefWindowProc(m_hWnd, uMsg, wParam, lParam); + else + mResult = OS2DefWindowProc(uMsg, wParam, lParam); } -*/ - return (MRESULT)0; -} + return mResult; +} // end of wxWindowOS2::OS2WindowProc +// // Dialog window proc -MRESULT wxDlgProc(HWND hWnd, UINT message, MPARAM wParam, MPARAM lParam) +// +MRESULT wxDlgProc( + HWND WXUNUSED(hWnd) +, UINT uMsg +, MPARAM WXUNUSED(wParam) +, MPARAM WXUNUSED(lParam)) { - // TODO: -/* - if ( message == WM_INITDIALOG ) + if (uMsg == WM_INITDLG) { - // for this message, returning TRUE tells system to set focus to the + // + // For this message, returning TRUE tells system to set focus to the // first control in the dialog box - return TRUE; + // + return (MRESULT)TRUE; } else { - // for all the other ones, FALSE means that we didn't process the + // + // For all the other ones, FALSE means that we didn't process the // message - return 0; + // + return (MRESULT)0; } -*/ - return (MRESULT)0; -} +} // end of wxDlgProc -wxWindow *wxFindWinFromHandle(WXHWND hWnd) +wxWindow* wxFindWinFromHandle( + WXHWND hWnd +) { - wxNode *node = wxWinHandleList->Find((long)hWnd); - if ( !node ) + wxNode* pNode = wxWinHandleList->Find((long)hWnd); + + if (!pNode) return NULL; - return (wxWindow *)node->Data(); -} + return (wxWindow *)pNode->Data(); +} // end of wxFindWinFromHandle -void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win) +void wxAssociateWinWithHandle( + HWND hWnd +, wxWindowOS2* pWin +) { - // adding NULL hWnd is (first) surely a result of an error and + // + // Adding NULL hWnd is (first) surely a result of an error and // (secondly) breaks menu command processing + // wxCHECK_RET( hWnd != (HWND)NULL, wxT("attempt to add a NULL hWnd to window list ignored") ); - wxWindow *oldWin = wxFindWinFromHandle((WXHWND) hWnd); - if ( oldWin && (oldWin != win) ) + wxWindow* pOldWin = wxFindWinFromHandle((WXHWND) hWnd); + + if (pOldWin && (pOldWin != pWin)) { - wxString str(win->GetClassInfo()->GetClassName()); - wxLogError("Bug! Found existing HWND %X for new window of class %s", (int) hWnd, (const char*) str); + wxString str(pWin->GetClassInfo()->GetClassName()); + wxLogError( "Bug! Found existing HWND %X for new window of class %s" + ,(int)hWnd + ,(const char*)str + ); } - else if (!oldWin) + else if (!pOldWin) { - wxWinHandleList->Append((long)hWnd, win); + wxWinHandleList->Append( (long)hWnd + ,pWin + ); } -} +} // end of wxAssociateWinWithHandle -void wxRemoveHandleAssociation(wxWindow *win) +void wxRemoveHandleAssociation( + wxWindowOS2* pWin +) { - wxWinHandleList->DeleteObject(win); -} + wxWinHandleList->DeleteObject(pWin); +} // end of wxRemoveHandleAssociation +// // Default destroyer - override if you destroy it in some other way // (e.g. with MDI child windows) -void wxWindow::OS2DestroyWindow() +// +void wxWindowOS2::OS2DestroyWindow() { } -void wxWindow::OS2DetachWindowMenu() +void wxWindowOS2::OS2DetachWindowMenu() { - if ( m_hMenu ) +#ifndef __WXUNIVERSAL__ + if (m_hMenu) { - HMENU hMenu = (HMENU)m_hMenu; + HMENU hMenu = (HMENU)m_hMenu; - int N = (int)WinSendMsg(hMenu, MM_QUERYITEMCOUNT, 0, 0); - int i; - for (i = 0; i < N; i++) + int nN = (int)::WinSendMsg(hMenu, MM_QUERYITEMCOUNT, 0, 0); + int i; + + for (i = 0; i < nN; i++) { - wxChar buf[100]; - int chars = (int)WinSendMsg(hMenu, MM_QUERYITEMTEXT, MPFROM2SHORT(i, N), buf); - if ( !chars ) + wxChar zBuf[100]; + int nChars = (int)::WinSendMsg( hMenu + ,MM_QUERYITEMTEXT + ,MPFROM2SHORT(i, nN) + ,zBuf + ); + if (!nChars) { wxLogLastError(wxT("GetMenuString")); - continue; } - if ( wxStrcmp(buf, wxT("&Window")) == 0 ) + if (wxStrcmp(zBuf, wxT("&Window")) == 0) { - WinSendMsg(hMenu, MM_DELETEITEM, MPFROM2SHORT(i, TRUE), 0); + ::WinSendMsg(hMenu, MM_DELETEITEM, MPFROM2SHORT(i, TRUE), 0); break; } } } -} - -bool wxWindow::OS2Create(int id, - wxWindow *parent, - const wxChar *wclass, - wxWindow *wx_win, - const wxChar *title, - int x, - int y, - int width, - int height, - WXDWORD style, - const wxChar *dialog_template, - WXDWORD extendedStyle) -{ - // TODO: -/* - int x1 = CW_USEDEFAULT; - int y1 = 0; - int width1 = CW_USEDEFAULT; - int height1 = 100; - +#endif // __WXUNIVERSAL__ +} // end of wxWindowOS2::OS2DetachWindowMenu + +bool wxWindowOS2::OS2Create( + WXHWND hParent +, PSZ zClass +, const wxChar* zTitle +, WXDWORD dwStyle +, long lX +, long lY +, long lWidth +, long lHeight +, WXHWND hOwner +, WXHWND WXUNUSED(hZOrder) +, unsigned long ulId +, void* pCtlData +, void* pPresParams +, WXDWORD dwExStyle +) +{ + ERRORID vError; + wxString sError; + long lX1 = 0L; + long lY1 = 0L; + long lWidth1 = 20L; + long lHeight1 = 20L; + int nControlId = 0; + int nNeedsubclass = 0; + PCSZ pszClass = zClass; + + // // Find parent's size, if it exists, to set up a possible default // panel size the size of the parent window - RECT parent_rect; - if ( parent ) - { - ::GetClientRect((HWND) parent->GetHWND(), &parent_rect); - - width1 = parent_rect.right - parent_rect.left; - height1 = parent_rect.bottom - parent_rect.top; - } - - if ( x > -1 ) x1 = x; - if ( y > -1 ) y1 = y; - if ( width > -1 ) width1 = width; - if ( height > -1 ) height1 = height; - - HWND hParent = (HWND)NULL; - if ( parent ) - hParent = (HWND) parent->GetHWND(); + // + lX1 = lX; + lY1 = lY; + if (lWidth > -1L) + lWidth1 = lWidth; + if (lHeight > -1L) + lHeight1 = lHeight; wxWndHook = this; - if ( dialog_template ) + // + // check to see if the new window is a standard control + // + if ((ULONG)zClass == (ULONG)WC_BUTTON || + (ULONG)zClass == (ULONG)WC_COMBOBOX || + (ULONG)zClass == (ULONG)WC_CONTAINER || + (ULONG)zClass == (ULONG)WC_ENTRYFIELD || + (ULONG)zClass == (ULONG)WC_FRAME || + (ULONG)zClass == (ULONG)WC_LISTBOX || + (ULONG)zClass == (ULONG)WC_MENU || + (ULONG)zClass == (ULONG)WC_NOTEBOOK || + (ULONG)zClass == (ULONG)WC_SCROLLBAR || + (ULONG)zClass == (ULONG)WC_SPINBUTTON || + (ULONG)zClass == (ULONG)WC_STATIC || + (ULONG)zClass == (ULONG)WC_TITLEBAR || + (ULONG)zClass == (ULONG)WC_VALUESET + ) { - m_hWnd = (WXHWND)::CreateDialog(wxGetInstance(), - dialog_template, - hParent, - (DLGPROC)wxDlgProc); - - if ( m_hWnd == 0 ) - { - wxLogError(_("Can't find dummy dialog template!\n" - "Check resource include path for finding wx.rc.")); - - return FALSE; - } - - // ::SetWindowLong(GWL_EXSTYLE) doesn't work for the dialogs, so try - // to take care of (at least some) extended style flags ourselves - if ( extendedStyle & WS_EX_TOPMOST ) - { - if ( !::SetWindowPos(GetHwnd(), HWND_TOPMOST, 0, 0, 0, 0, - SWP_NOSIZE | SWP_NOMOVE) ) - { - wxLogLastError(wxT("SetWindowPos")); - } - } - - // move the dialog to its initial position without forcing repainting - if ( !::MoveWindow(GetHwnd(), x1, y1, width1, height1, FALSE) ) - { - wxLogLastError(wxT("MoveWindow")); - } + nControlId = ulId; } else { - int controlId = 0; - if ( style & WS_CHILD ) - controlId = id; - - wxString className(wclass); - if ( GetWindowStyleFlag() & wxNO_FULL_REPAINT_ON_RESIZE ) + // no standard controls + if(wxString (wxT("wxFrameClass")) == wxString(zClass) ) { - className += wxT("NR"); + pszClass = WC_FRAME; + nNeedsubclass = 1; } - - m_hWnd = (WXHWND)CreateWindowEx(extendedStyle, - className, - title ? title : wxT(""), - style, - x1, y1, - width1, height1, - hParent, (HMENU)controlId, - wxGetInstance(), - NULL); - - if ( !m_hWnd ) + else { - wxLogError(_("Can't create window of class %s!\n" - "Possible Windows 3.x compatibility problem?"), - wclass); - - return FALSE; + nControlId = ulId; + if(nControlId < 0) + nControlId = FID_CLIENT; } } + HWND parent; + if ( GetWindowStyleFlag() & wxPOPUP_WINDOW ) + { + // popup windows should have desktop as parent because they shouldn't + // be limited to the parents client area as child windows usually are + parent = HWND_DESKTOP; + } + else if ( hParent ) + { + parent = hParent; + } + else + { + // top level window + parent = NULL; + } + + // + // We will either have a registered class via string name or a standard PM Class via a long + // + m_hWnd = (WXHWND)::WinCreateWindow(parent, zClass, + (PSZ)zTitle ? zTitle : wxT(""), + dwStyle, lX1, lY1, lWidth, lHeight, + hOwner, HWND_TOP, (ULONG)nControlId, + pCtlData, pPresParams); + + if (!m_hWnd) + { + vError = ::WinGetLastError(vHabmain); + sError = wxPMErrorToStr(vError); + wxLogError("Can't create window of class %s!. Error: %s\n", zClass, sError); + return FALSE; + } + m_dwExStyle = dwExStyle; + ::WinSetWindowULong(m_hWnd, QWL_USER, (ULONG) this); wxWndHook = NULL; + #ifdef __WXDEBUG__ - wxNode* node = wxWinHandleList->Member(this); - if (node) + wxNode* pNode = wxWinHandleList->Member(this); + + if (pNode) { - HWND hWnd = (HWND) node->GetKeyInteger(); - if (hWnd != (HWND) m_hWnd) + HWND hWnd = (HWND)pNode->GetKeyInteger(); + + if (hWnd != (HWND)m_hWnd) + { wxLogError("A second HWND association is being added for the same window!"); } } #endif -*/ - wxAssociateWinWithHandle((HWND) m_hWnd, this); - - return TRUE; -} - -// =========================================================================== -// OS2 PM message handlers -// =========================================================================== - -// --------------------------------------------------------------------------- -// WM_NOTIFY -// --------------------------------------------------------------------------- - -bool wxWindow::HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) -{ - // TODO: - return FALSE; -} - -bool wxWindow::OS2OnNotify(int WXUNUSED(idCtrl), - WXLPARAM lParam, - WXLPARAM* WXUNUSED(result)) -{ - // TODO: - return FALSE; -} - -// --------------------------------------------------------------------------- -// end session messages -// --------------------------------------------------------------------------- - -bool wxWindow::HandleQueryEndSession(long logOff, bool *mayEnd) -{ - wxCloseEvent event(wxEVT_QUERY_END_SESSION, -1); - event.SetEventObject(wxTheApp); - event.SetCanVeto(TRUE); - event.SetLoggingOff(logOff == ENDSESSION_LOGOFF); - - bool rc = wxTheApp->ProcessEvent(event); - - if ( rc ) + wxAssociateWinWithHandle((HWND)m_hWnd + ,this + ); + // + // Now need to subclass window. + // + if(!nNeedsubclass) { - // we may end only if the app didn't veto session closing (double - // negation...) - *mayEnd = !event.GetVeto(); + wxAssociateWinWithHandle((HWND)m_hWnd,this); } - - return rc; -} - -bool wxWindow::HandleEndSession(bool endSession, long logOff) -{ - // do nothing if the session isn't ending - if ( !endSession ) - return FALSE; - - wxCloseEvent event(wxEVT_END_SESSION, -1); - event.SetEventObject(wxTheApp); - event.SetCanVeto(FALSE); - event.SetLoggingOff( (logOff == ENDSESSION_LOGOFF) ); - if ( (this == wxTheApp->GetTopWindow()) && // Only send once - wxTheApp->ProcessEvent(event)) + else { + SubclassWin(GetHWND()); } return TRUE; -} +} // end of wxWindowOS2::OS2Create + +// =========================================================================== +// OS2 PM message handlers +// =========================================================================== // --------------------------------------------------------------------------- // window creation/destruction // --------------------------------------------------------------------------- -bool wxWindow::HandleCreate(WXLPCREATESTRUCT cs, bool *mayCreate) +bool wxWindowOS2::HandleCreate( + WXLPCREATESTRUCT WXUNUSED(vCs) +, bool* pbMayCreate +) { - // TODO: should generate this event from WM_NCCREATE - wxWindowCreateEvent event(this); - (void)GetEventHandler()->ProcessEvent(event); - - *mayCreate = TRUE; + wxWindowCreateEvent vEvent((wxWindow*)this); + (void)GetEventHandler()->ProcessEvent(vEvent); + *pbMayCreate = TRUE; return TRUE; -} +} // end of wxWindowOS2::HandleCreate -bool wxWindow::HandleDestroy() +bool wxWindowOS2::HandleDestroy() { - wxWindowDestroyEvent event(this); - (void)GetEventHandler()->ProcessEvent(event); + wxWindowDestroyEvent vEvent((wxWindow*)this); + + (void)GetEventHandler()->ProcessEvent(vEvent); - // delete our drop target if we've got one + // + // Delete our drop target if we've got one + // #if wxUSE_DRAG_AND_DROP - if ( m_dropTarget != NULL ) + if (m_dropTarget != NULL) { -// m_dropTarget->Revoke(m_hWnd); - + m_dropTarget->Revoke(m_hWnd); delete m_dropTarget; m_dropTarget = NULL; } #endif // wxUSE_DRAG_AND_DROP + // // WM_DESTROY handled + // return TRUE; -} +} // end of wxWindowOS2::HandleDestroy // --------------------------------------------------------------------------- // activation/focus // --------------------------------------------------------------------------- - -bool wxWindow::HandleActivate(int state, - bool WXUNUSED(minimized), - WXHWND WXUNUSED(activate)) +void wxWindowOS2::OnSetFocus( + wxFocusEvent& rEvent +) { - // TODO: - /* - wxActivateEvent event(wxEVT_ACTIVATE, - (state == WA_ACTIVE) || (state == WA_CLICKACTIVE), - m_windowId); - event.SetEventObject(this); + rEvent.Skip(); +} // end of wxWindowOS2::OnSetFocus - return GetEventHandler()->ProcessEvent(event); - */ - return FALSE; -} +bool wxWindowOS2::HandleActivate( + int nState +, WXHWND WXUNUSED(hActivate) +) +{ + wxActivateEvent vEvent( wxEVT_ACTIVATE + ,(bool)nState + ,m_windowId + ); + vEvent.SetEventObject(this); + return GetEventHandler()->ProcessEvent(vEvent); +} // end of wxWindowOS2::HandleActivate -bool wxWindow::HandleSetFocus(WXHWND WXUNUSED(hwnd)) +bool wxWindowOS2::HandleSetFocus( + WXHWND WXUNUSED(hWnd) +) { #if wxUSE_CARET + // // Deal with caret - if ( m_caret ) + // + if (m_caret) { m_caret->OnSetFocus(); } #endif // wxUSE_CARET - // panel wants to track the window which was the last to have focus in it - wxPanel *panel = wxDynamicCast(GetParent(), wxPanel); - if ( panel ) +#if wxUSE_TEXTCTRL + // If it's a wxTextCtrl don't send the event as it will be done + // after the control gets to process it from EN_FOCUS handler + if ( wxDynamicCastThis(wxTextCtrl) ) { - panel->SetLastFocus(this); + return FALSE; } +#endif // wxUSE_TEXTCTRL - wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId); - event.SetEventObject(this); + wxFocusEvent vEvent(wxEVT_SET_FOCUS, m_windowId); - return GetEventHandler()->ProcessEvent(event); -} + vEvent.SetEventObject(this); + return GetEventHandler()->ProcessEvent(vEvent); +} // end of wxWindowOS2::HandleSetFocus -bool wxWindow::HandleKillFocus(WXHWND WXUNUSED(hwnd)) +bool wxWindowOS2::HandleKillFocus( + WXHWND WXUNUSED(hWnd) +) { #if wxUSE_CARET + // // Deal with caret - if ( m_caret ) + // + if (m_caret) { m_caret->OnKillFocus(); } #endif // wxUSE_CARET - wxFocusEvent event(wxEVT_KILL_FOCUS, m_windowId); - event.SetEventObject(this); + wxFocusEvent vEvent( wxEVT_KILL_FOCUS + ,m_windowId + ); - return GetEventHandler()->ProcessEvent(event); -} + vEvent.SetEventObject(this); + return GetEventHandler()->ProcessEvent(vEvent); +} // end of wxWindowOS2::HandleKillFocus // --------------------------------------------------------------------------- // miscellaneous // --------------------------------------------------------------------------- -bool wxWindow::HandleShow(bool show, int status) +bool wxWindowOS2::HandleShow( + bool bShow +, int WXUNUSED(nStatus) +) { - wxShowEvent event(GetId(), show); - event.m_eventObject = this; + wxShowEvent vEvent(GetId(), bShow); - return GetEventHandler()->ProcessEvent(event); -} + vEvent.m_eventObject = this; + return GetEventHandler()->ProcessEvent(vEvent); +} // end of wxWindowOS2::HandleShow -bool wxWindow::HandleInitDialog(WXHWND WXUNUSED(hWndFocus)) +bool wxWindowOS2::HandleInitDialog( + WXHWND WXUNUSED(hWndFocus) +) { - wxInitDialogEvent event(GetId()); - event.m_eventObject = this; + wxInitDialogEvent vEvent(GetId()); - return GetEventHandler()->ProcessEvent(event); -} + vEvent.m_eventObject = this; + return GetEventHandler()->ProcessEvent(vEvent); +} // end of wxWindowOS2::HandleInitDialog -bool wxWindow::HandleDropFiles(WXWPARAM wParam) +bool wxWindowOS2::HandleEndDrag(WXWPARAM WXUNUSED(wParam)) { - // TODO: + // TODO: We'll handle drag and drop later return FALSE; } -bool wxWindow::HandleSetCursor(WXHWND hWnd, - short nHitTest, - int WXUNUSED(mouseMsg)) +bool wxWindowOS2::HandleSetCursor( + USHORT WXUNUSED(vId) +, WXHWND hPointer +) +{ + // + // Under OS/2 PM this allows the pointer to be changed + // as it passes over a control + // + ::WinSetPointer(HWND_DESKTOP, (HPOINTER)hPointer); + return TRUE; +} // end of wxWindowOS2::HandleSetCursor + +// --------------------------------------------------------------------------- +// owner drawn stuff +// --------------------------------------------------------------------------- +bool wxWindowOS2::OS2OnDrawItem( + int vId +, WXDRAWITEMSTRUCT* pItemStruct +) { - // don't set cursor for other windows, only for this one: this prevents - // children of this window from getting the same cursor as the parent has - // (don't forget that this message is propagated by default up the window - // parent-child hierarchy) - if ( GetHWND() == hWnd ) +#if wxUSE_OWNER_DRAWN + wxDC vDc; + +#if wxUSE_MENUS_NATIVE + // + // Is it a menu item? + // + if (vId == 0) { - // don't set cursor when the mouse is not in the client part -// TODO -/* - if ( nHitTest == HTCLIENT || nHitTest == HTERROR ) + ERRORID vError; + wxString sError; + POWNERITEM pMeasureStruct = (POWNERITEM)pItemStruct; + wxFrame* pFrame = (wxFrame*)this; + wxMenuItem* pMenuItem = pFrame->GetMenuBar()->FindItem(pMeasureStruct->idItem, pMeasureStruct->hItem); + HDC hDC = ::GpiQueryDevice(pMeasureStruct->hps); + wxRect vRect( pMeasureStruct->rclItem.xLeft + ,pMeasureStruct->rclItem.yBottom + ,pMeasureStruct->rclItem.xRight - pMeasureStruct->rclItem.xLeft + ,pMeasureStruct->rclItem.yTop - pMeasureStruct->rclItem.yBottom + ); + vDc.SetHDC( hDC + ,FALSE + ); + vDc.SetHPS(pMeasureStruct->hps); + // + // Load the wxWindows Pallete and set to RGB mode + // + if (!::GpiCreateLogColorTable( pMeasureStruct->hps + ,0L + ,LCOLF_CONSECRGB + ,0L + ,(LONG)wxTheColourDatabase->m_nSize + ,(PLONG)wxTheColourDatabase->m_palTable + )) { - HCURSOR hcursor = 0; - if ( wxIsBusy() ) - { - // from msw\utils.cpp - extern HCURSOR gs_wxBusyCursor; + vError = ::WinGetLastError(vHabmain); + sError = wxPMErrorToStr(vError); + wxLogError("Unable to set current color table. Error: %s\n", sError); + } + // + // Set the color table to RGB mode + // + if (!::GpiCreateLogColorTable( pMeasureStruct->hps + ,0L + ,LCOLF_RGB + ,0L + ,0L + ,NULL + )) + { + vError = ::WinGetLastError(vHabmain); + sError = wxPMErrorToStr(vError); + wxLogError("Unable to set current color table. Error: %s\n", sError); + } - hcursor = gs_wxBusyCursor; - } - else - { - wxCursor *cursor = NULL; + wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE ); - if ( m_cursor.Ok() ) - { - cursor = &m_cursor; - } - else - { - // from msw\data.cpp - extern wxCursor *g_globalCursor; - if ( g_globalCursor && g_globalCursor->Ok() ) - cursor = g_globalCursor; - } + int eAction = 0; + int eStatus = 0; - if ( cursor ) - hcursor = (HCURSOR)cursor->GetHCURSOR(); - } + if (pMeasureStruct->fsAttribute == pMeasureStruct->fsAttributeOld) + { + // + // Entire Item needs to be redrawn (either it has reappeared from + // behind another window or is being displayed for the first time + // + eAction = wxOwnerDrawn::wxODDrawAll; - if ( hcursor ) + if (pMeasureStruct->fsAttribute & MIA_HILITED) { -// ::SetCursor(hcursor); - + // + // If it is currently selected we let the system handle it + // + eStatus |= wxOwnerDrawn::wxODSelected; + } + if (pMeasureStruct->fsAttribute & MIA_CHECKED) + { + // + // If it is currently checked we draw our own + // + eStatus |= wxOwnerDrawn::wxODChecked; + pMeasureStruct->fsAttributeOld = pMeasureStruct->fsAttribute &= ~MIA_CHECKED; + } + if (pMeasureStruct->fsAttribute & MIA_DISABLED) + { + // + // If it is currently disabled we let the system handle it + // + eStatus |= wxOwnerDrawn::wxODDisabled; + } + // + // Don't really care about framed (indicationg focus) or NoDismiss + // + } + else + { + if (pMeasureStruct->fsAttribute & MIA_HILITED) + { + eAction = wxOwnerDrawn::wxODDrawAll; + eStatus |= wxOwnerDrawn::wxODSelected; + // + // Keep the system from trying to highlight with its bogus colors + // + pMeasureStruct->fsAttributeOld = pMeasureStruct->fsAttribute &= ~MIA_HILITED; + } + else if (!(pMeasureStruct->fsAttribute & MIA_HILITED)) + { + eAction = wxOwnerDrawn::wxODDrawAll; + eStatus = 0; + // + // Keep the system from trying to highlight with its bogus colors + // + pMeasureStruct->fsAttribute = pMeasureStruct->fsAttributeOld &= ~MIA_HILITED; + } + else + { + // + // For now we don't care about anything else + // just ignore the entire message! + // return TRUE; } } -*/ + // + // Now redraw the item + // + return(pMenuItem->OnDrawItem( vDc + ,vRect + ,(wxOwnerDrawn::wxODAction)eAction + ,(wxOwnerDrawn::wxODStatus)eStatus + )); + // + // leave the fsAttribute and fsOldAttribute unchanged. If different, + // the system will do the highlight or fraeming or disabling for us, + // otherwise, we'd have to do it ourselves. + // } +#endif // wxUSE_MENUS_NATIVE - return FALSE; -} - -// --------------------------------------------------------------------------- -// owner drawn stuff -// --------------------------------------------------------------------------- - -bool wxWindow::OS2OnDrawItem(int id, WXDRAWITEMSTRUCT *itemStruct) -{ - // TODO: -/* -#if wxUSE_OWNER_DRAWN - // is it a menu item? - if ( id == 0 ) - { - DRAWITEMSTRUCT *pDrawStruct = (DRAWITEMSTRUCT *)itemStruct; - wxMenuItem *pMenuItem = (wxMenuItem *)(pDrawStruct->itemData); - - wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE ); - - // prepare to call OnDrawItem() - wxDC dc; - dc.SetHDC((WXHDC)pDrawStruct->hDC, FALSE); - wxRect rect(pDrawStruct->rcItem.left, pDrawStruct->rcItem.top, - pDrawStruct->rcItem.right - pDrawStruct->rcItem.left, - pDrawStruct->rcItem.bottom - pDrawStruct->rcItem.top); - - return pMenuItem->OnDrawItem - ( - dc, rect, - (wxOwnerDrawn::wxODAction)pDrawStruct->itemAction, - (wxOwnerDrawn::wxODStatus)pDrawStruct->itemState - ); - } + wxWindow* pItem = FindItem(vId); - wxWindow *item = FindItem(id); - if ( item && item->IsKindOf(CLASSINFO(wxControl)) ) + if (pItem && pItem->IsKindOf(CLASSINFO(wxControl))) { - return ((wxControl *)item)->MSWOnDraw(itemStruct); + return ((wxControl *)pItem)->OS2OnDraw(pItemStruct); } - else +#else + vId = vId; + pItemStruct = pItemStruct; #endif - return FALSE; -*/ return FALSE; -} +} // end of wxWindowOS2::OS2OnDrawItem -bool wxWindow::OS2OnMeasureItem(int id, WXMEASUREITEMSTRUCT *itemStruct) +bool wxWindowOS2::OS2OnMeasureItem( + int lId +, WXMEASUREITEMSTRUCT* pItemStruct +) { - // TODO: -/* -#if wxUSE_OWNER_DRAWN - // is it a menu item? - if ( id == 0 ) - { - MEASUREITEMSTRUCT *pMeasureStruct = (MEASUREITEMSTRUCT *)itemStruct; - wxMenuItem *pMenuItem = (wxMenuItem *)(pMeasureStruct->itemData); - - wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE ); - - return pMenuItem->OnMeasureItem(&pMeasureStruct->itemWidth, - &pMeasureStruct->itemHeight); +#if wxUSE_OWNER_DRAWN + // + // Is it a menu item? + // + if (lId == 65536) // I really don't like this...has to be a better indicator + { + if (IsKindOf(CLASSINFO(wxFrame))) // we'll assume if Frame then a menu + { + size_t nWidth; + size_t nHeight; + POWNERITEM pMeasureStruct = (POWNERITEM)pItemStruct; + wxFrame* pFrame = (wxFrame*)this; + wxMenuItem* pMenuItem = pFrame->GetMenuBar()->FindItem(pMeasureStruct->idItem, pMeasureStruct->hItem); + + wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE ); + nWidth = 0L; + nHeight = 0L; + if (pMenuItem->OnMeasureItem( &nWidth + ,&nHeight + )) + { + pMeasureStruct->rclItem.xRight = nWidth; + pMeasureStruct->rclItem.xLeft = 0L; + pMeasureStruct->rclItem.yTop = nHeight; + pMeasureStruct->rclItem.yBottom = 0L; + return TRUE; + } + return FALSE; + } } + wxWindow* pItem = FindItem(lId); - wxWindow *item = FindItem(id); - if ( item && item->IsKindOf(CLASSINFO(wxControl)) ) + if (pItem && pItem->IsKindOf(CLASSINFO(wxControl))) { - return ((wxControl *)item)->MSWOnMeasure(itemStruct); + return ((wxControl *)pItem)->OS2OnMeasure(pItemStruct); } -#endif // owner-drawn menus -*/ +#else + lId = lId; + pItemStruct = pItemStruct; +#endif // wxUSE_OWNER_DRAWN return FALSE; } @@ -1902,266 +3262,310 @@ bool wxWindow::OS2OnMeasureItem(int id, WXMEASUREITEMSTRUCT *itemStruct) // colours and palettes // --------------------------------------------------------------------------- -bool wxWindow::HandleSysColorChange() +bool wxWindowOS2::HandleSysColorChange() { - wxSysColourChangedEvent event; - event.SetEventObject(this); + wxSysColourChangedEvent vEvent; - return GetEventHandler()->ProcessEvent(event); -} + vEvent.SetEventObject(this); + return GetEventHandler()->ProcessEvent(vEvent); +} // end of wxWindowOS2::HandleSysColorChange -bool wxWindow::HandleCtlColor(WXHBRUSH *brush, - WXHDC pDC, - WXHWND pWnd, - WXUINT nCtlColor, - WXUINT message, - WXWPARAM wParam, - WXLPARAM lParam) +bool wxWindowOS2::HandleCtlColor( + WXHBRUSH* WXUNUSED(phBrush) +) { - WXHBRUSH hBrush = 0; -// TODO: -/* - if ( nCtlColor == CTLCOLOR_DLG ) - { - hBrush = OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam); - } - else - { - wxControl *item = (wxControl *)FindItemByHWND(pWnd, TRUE); - if ( item ) - hBrush = item->OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam); - } - - if ( hBrush ) - *brush = hBrush; + // + // Not much provided with message. So not sure I can do anything with it + // + return TRUE; +} // end of wxWindowOS2::HandleCtlColor - return hBrush != 0; -*/ - return FALSE; -} // Define for each class of dialog and control -WXHBRUSH wxWindow::OnCtlColor(WXHDC hDC, - WXHWND hWnd, - WXUINT nCtlColor, - WXUINT message, - WXWPARAM wParam, - WXLPARAM lParam) +WXHBRUSH wxWindowOS2::OnCtlColor(WXHDC WXUNUSED(hDC), + WXHWND WXUNUSED(hWnd), + WXUINT WXUNUSED(nCtlColor), + WXUINT WXUNUSED(message), + WXWPARAM WXUNUSED(wParam), + WXLPARAM WXUNUSED(lParam)) { return (WXHBRUSH)0; } -bool wxWindow::HandlePaletteChanged(WXHWND hWndPalChange) +bool wxWindowOS2::HandlePaletteChanged() { - wxPaletteChangedEvent event(GetId()); - event.SetEventObject(this); - event.SetChangedWindow(wxFindWinFromHandle(hWndPalChange)); + // need to set this to something first + WXHWND hWndPalChange = NULLHANDLE; - return GetEventHandler()->ProcessEvent(event); -} + wxPaletteChangedEvent vEvent(GetId()); -bool wxWindow::HandleQueryNewPalette() -{ - wxQueryNewPaletteEvent event(GetId()); - event.SetEventObject(this); + vEvent.SetEventObject(this); + vEvent.SetChangedWindow(wxFindWinFromHandle(hWndPalChange)); - return GetEventHandler()->ProcessEvent(event) && event.GetPaletteRealized(); -} + return GetEventHandler()->ProcessEvent(vEvent); +} // end of wxWindowOS2::HandlePaletteChanged +// // Responds to colour changes: passes event on to children. -void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event) +// +void wxWindowOS2::OnSysColourChanged( + wxSysColourChangedEvent& rEvent +) { - wxNode *node = GetChildren().First(); - while ( node ) + wxNode* pNode = GetChildren().First(); + + while (pNode) { + // // Only propagate to non-top-level windows - wxWindow *win = (wxWindow *)node->Data(); - if ( win->GetParent() ) + // + wxWindow* pWin = (wxWindow *)pNode->Data(); + + if (pWin->GetParent()) { - wxSysColourChangedEvent event2; - event.m_eventObject = win; - win->GetEventHandler()->ProcessEvent(event2); - } + wxSysColourChangedEvent vEvent; - node = node->Next(); + rEvent.m_eventObject = pWin; + pWin->GetEventHandler()->ProcessEvent(vEvent); + } + pNode = pNode->Next(); } -} +} // end of wxWindowOS2::OnSysColourChanged // --------------------------------------------------------------------------- // painting // --------------------------------------------------------------------------- -bool wxWindow::HandlePaint() +bool wxWindowOS2::HandlePaint() { - // TODO: - return FALSE; -} + HRGN hRgn; + wxPaintEvent vEvent(m_windowId); + HPS hPS; + RECTL vRect; + bool bProcessed; + + // Create empty region + // TODO: get HPS somewhere else if possible + hPS = ::WinGetPS(GetHwnd()); + hRgn = ::GpiCreateRegion(hPS, 0, NULL); + + if (::WinQueryUpdateRegion(GetHwnd(), hRgn) == RGN_ERROR) + { + wxLogLastError("CreateRectRgn"); + return FALSE; + } + + m_updateRegion = wxRegion(hRgn, hPS); + + vEvent.SetEventObject(this); + bProcessed = GetEventHandler()->ProcessEvent(vEvent); -bool wxWindow::HandleEraseBkgnd(WXHDC hdc) + return GetEventHandler()->ProcessEvent(vEvent); //bProcessed; +} // end of wxWindowOS2::HandlePaint + +bool wxWindowOS2::HandleEraseBkgnd( + WXHDC hDC +) { - // Prevents flicker when dragging -// if ( ::IsIconic(GetHwnd()) ) -// return TRUE; + SWP vSwp; + bool rc; - wxDC dc; + ::WinQueryWindowPos(GetHwnd(), &vSwp); + if (vSwp.fl & SWP_MINIMIZE) + return TRUE; - dc.SetHDC(hdc); - dc.SetWindow(this); - dc.BeginDrawing(); + wxDC vDC; - wxEraseEvent event(m_windowId, &dc); - event.SetEventObject(this); - bool rc = GetEventHandler()->ProcessEvent(event); + vDC.m_hPS = (HPS)hDC; // this is really a PS + vDC.SetWindow((wxWindow*)this); + vDC.BeginDrawing(); - dc.EndDrawing(); - dc.SelectOldObjects(hdc); - dc.SetHDC((WXHDC) NULL); + wxEraseEvent vEvent(m_windowId, &vDC); - return rc; -} + vEvent.SetEventObject(this); + + rc = GetEventHandler()->ProcessEvent(vEvent); + + vDC.EndDrawing(); + vDC.m_hPS = NULLHANDLE; + return TRUE; +} // end of wxWindowOS2::HandleEraseBkgnd -void wxWindow::OnEraseBackground(wxEraseEvent& event) +void wxWindowOS2::OnEraseBackground( + wxEraseEvent& rEvent +) { - // TODO: -} + RECTL vRect; + HPS hPS = rEvent.m_dc->m_hPS; + APIRET rc; + LONG lColor = m_backgroundColour.GetPixel(); + + rc = ::WinQueryWindowRect(GetHwnd(), &vRect); + rc = ::WinFillRect(hPS, &vRect, lColor); +} // end of wxWindowOS2::OnEraseBackground // --------------------------------------------------------------------------- // moving and resizing // --------------------------------------------------------------------------- -bool wxWindow::HandleMinimize() +bool wxWindowOS2::HandleMinimize() { - wxIconizeEvent event(m_windowId); - event.SetEventObject(this); + wxIconizeEvent vEvent(m_windowId); - return GetEventHandler()->ProcessEvent(event); -} + vEvent.SetEventObject(this); + return GetEventHandler()->ProcessEvent(vEvent); +} // end of wxWindowOS2::HandleMinimize -bool wxWindow::HandleMaximize() +bool wxWindowOS2::HandleMaximize() { - wxMaximizeEvent event(m_windowId); - event.SetEventObject(this); + wxMaximizeEvent vEvent(m_windowId); - return GetEventHandler()->ProcessEvent(event); -} + vEvent.SetEventObject(this); + return GetEventHandler()->ProcessEvent(vEvent); +} // end of wxWindowOS2::HandleMaximize -bool wxWindow::HandleMove(int x, int y) +bool wxWindowOS2::HandleMove( + int nX +, int nY +) { - wxMoveEvent event(wxPoint(x, y), m_windowId); - event.SetEventObject(this); + wxMoveEvent vEvent(wxPoint(nX, nY), m_windowId); - return GetEventHandler()->ProcessEvent(event); -} + vEvent.SetEventObject(this); + return GetEventHandler()->ProcessEvent(vEvent); +} // end of wxWindowOS2::HandleMove -bool wxWindow::HandleSize(int w, int h, WXUINT WXUNUSED(flag)) +bool wxWindowOS2::HandleSize( + int nWidth +, int nHeight +, WXUINT WXUNUSED(nFlag) +) { - wxSizeEvent event(wxSize(w, h), m_windowId); - event.SetEventObject(this); + wxSizeEvent vEvent(wxSize(nWidth, nHeight), m_windowId); - return GetEventHandler()->ProcessEvent(event); -} + vEvent.SetEventObject(this); + return GetEventHandler()->ProcessEvent(vEvent); +} // end of wxWindowOS2::HandleSize -bool wxWindow::HandleGetMinMaxInfo(void *mmInfo) +bool wxWindowOS2::HandleGetMinMaxInfo( + PSWP pSwp +) { -// TODO: -/* - MINMAXINFO *info = (MINMAXINFO *)mmInfo; - - bool rc = FALSE; - - if ( m_minWidth != -1 ) - { - info->ptMinTrackSize.x = m_minWidth; - rc = TRUE; - } + bool bRc = FALSE; + POINTL vPoint; - if ( m_minHeight != -1 ) + switch(pSwp->fl) { - info->ptMinTrackSize.y = m_minHeight; - rc = TRUE; - } + case SWP_MAXIMIZE: + ::WinGetMaxPosition(GetHwnd(), pSwp); + m_maxWidth = pSwp->cx; + m_maxHeight = pSwp->cy; + break; - if ( m_maxWidth != -1 ) - { - info->ptMaxTrackSize.x = m_maxWidth; - rc = TRUE; - } + case SWP_MINIMIZE: + ::WinGetMinPosition(GetHwnd(), pSwp, &vPoint); + m_minWidth = pSwp->cx; + m_minHeight = pSwp->cy; + break; - if ( m_maxHeight != -1 ) - { - info->ptMaxTrackSize.y = m_maxHeight; - rc = TRUE; + default: + return FALSE; } - - return rc; -*/ - return FALSE; -} + return TRUE; +} // end of wxWindowOS2::HandleGetMinMaxInfo // --------------------------------------------------------------------------- // command messages // --------------------------------------------------------------------------- - -bool wxWindow::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control) +bool wxWindowOS2::HandleCommand( + WXWORD wId +, WXWORD wCmd +, WXHWND hControl +) { - if ( wxCurrentPopupMenu ) +#if wxUSE_MENUS_NATIVE + if (wxCurrentPopupMenu) { - wxMenu *popupMenu = wxCurrentPopupMenu; - wxCurrentPopupMenu = NULL; + wxMenu* pPopupMenu = wxCurrentPopupMenu; - return popupMenu->OS2Command(cmd, id); + wxCurrentPopupMenu = NULL; + return pPopupMenu->OS2Command(wCmd, wId); } +#endif // wxUSE_MENUS_NATIVE + + wxWindow* pWin = FindItem(wId); - wxWindow *win = FindItem(id); - if ( !win ) + if (!pWin) { - win = wxFindWinFromHandle(control); + pWin = wxFindWinFromHandle(hControl); } - if ( win ) - return win->OS2Command(cmd, id); + if (pWin) + return pWin->OS2Command(wCmd, wId); return FALSE; -} +} // end of wxWindowOS2::HandleCommand -bool wxWindow::HandleSysCommand(WXWPARAM wParam, WXLPARAM lParam) +bool wxWindowOS2::HandleSysCommand( + WXWPARAM wParam +, WXLPARAM WXUNUSED(lParam) +) { - // TODO: + // + // 4 bits are reserved + // + switch (SHORT1FROMMP(wParam)) + { + case SC_MAXIMIZE: + return HandleMaximize(); + + case SC_MINIMIZE: + return HandleMinimize(); + } return FALSE; -} +} // end of wxWindowOS2::HandleSysCommand // --------------------------------------------------------------------------- // mouse events // --------------------------------------------------------------------------- - -void wxWindow::InitMouseEvent(wxMouseEvent& event, int x, int y, WXUINT flags) +//TODO!!! check against MSW +void wxWindowOS2::InitMouseEvent( + wxMouseEvent& rEvent +, int nX +, int nY +, WXUINT uFlags +) { -// TODO: -/* - event.m_x = x; - event.m_y = y; - event.m_shiftDown = ((flags & MK_SHIFT) != 0); - event.m_controlDown = ((flags & MK_CONTROL) != 0); - event.m_leftDown = ((flags & MK_LBUTTON) != 0); - event.m_middleDown = ((flags & MK_MBUTTON) != 0); - event.m_rightDown = ((flags & MK_RBUTTON) != 0); - event.SetTimestamp(s_currentMsg.time); - event.m_eventObject = this; + rEvent.m_x = nX; + rEvent.m_y = nY; + rEvent.m_shiftDown = ((uFlags & VK_SHIFT) != 0); + rEvent.m_controlDown = ((uFlags & VK_CTRL) != 0); + rEvent.m_leftDown = ((uFlags & VK_BUTTON1) != 0); + rEvent.m_middleDown = ((uFlags & VK_BUTTON3) != 0); + rEvent.m_rightDown = ((uFlags & VK_BUTTON2) != 0); + rEvent.SetTimestamp(s_currentMsg.time); + rEvent.m_eventObject = this; #if wxUSE_MOUSEEVENT_HACK - m_lastMouseX = x; - m_lastMouseY = y; - m_lastMouseEvent = event.GetEventType(); + m_lastMouseX = nX; + m_lastMouseY = nY; + m_lastMouseEvent = rEvent.GetEventType(); #endif // wxUSE_MOUSEEVENT_HACK -*/ -} +} // end of wxWindowOS2::InitMouseEvent -bool wxWindow::HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags) +bool wxWindowOS2::HandleMouseEvent( + WXUINT uMsg +, int nX +, int nY +, WXUINT uFlags +) { - // the mouse events take consecutive IDs from WM_MOUSEFIRST to + // + // The mouse events take consecutive IDs from WM_MOUSEFIRST to // WM_MOUSELAST, so it's enough to substract WM_MOUSEMOVE == WM_MOUSEFIRST // from the message id and take the value in the table to get wxWin event // id + // static const wxEventType eventsMouse[] = { wxEVT_MOTION, @@ -2176,491 +3580,692 @@ bool wxWindow::HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags) wxEVT_MIDDLE_DCLICK }; - wxMouseEvent event(eventsMouse[msg - WM_MOUSEMOVE]); - InitMouseEvent(event, x, y, flags); + wxMouseEvent vEvent(eventsMouse[uMsg - WM_MOUSEMOVE]); - return GetEventHandler()->ProcessEvent(event); -} + InitMouseEvent( vEvent + ,nX + ,nY + ,uFlags + ); + + return GetEventHandler()->ProcessEvent(vEvent); +} // end of wxWindowOS2::HandleMouseEvent -bool wxWindow::HandleMouseMove(int x, int y, WXUINT flags) +bool wxWindowOS2::HandleMouseMove( + int nX +, int nY +, WXUINT uFlags +) { - if ( !m_bMouseInWindow ) + if (!m_bMouseInWindow) { + // // Generate an ENTER event + // m_bMouseInWindow = TRUE; - wxMouseEvent event(wxEVT_ENTER_WINDOW); - InitMouseEvent(event, x, y, flags); - - (void)GetEventHandler()->ProcessEvent(event); - } + wxMouseEvent vEvent(wxEVT_ENTER_WINDOW); -#if wxUSE_MOUSEEVENT_HACK - // Window gets a click down message followed by a mouse move message even - // if position isn't changed! We want to discard the trailing move event - // if x and y are the same. - if ( (m_lastMouseEvent == wxEVT_RIGHT_DOWN || - m_lastMouseEvent == wxEVT_LEFT_DOWN || - m_lastMouseEvent == wxEVT_MIDDLE_DOWN) && - (m_lastMouseX == event.m_x && m_lastMouseY == event.m_y) ) - { - m_lastMouseEvent = wxEVT_MOTION; + InitMouseEvent( vEvent + ,nX + ,nY + ,uFlags + ); - return FALSE; + (void)GetEventHandler()->ProcessEvent(vEvent); } -#endif // wxUSE_MOUSEEVENT_HACK - - return HandleMouseEvent(WM_MOUSEMOVE, x, y, flags); -} + return HandleMouseEvent( WM_MOUSEMOVE + ,nX + ,nY + ,uFlags + ); +} // end of wxWindowOS2::HandleMouseMove // --------------------------------------------------------------------------- // keyboard handling // --------------------------------------------------------------------------- +// +// Create the key event of the given type for the given key - used by +// HandleChar and HandleKeyDown/Up +// +wxKeyEvent wxWindowOS2::CreateKeyEvent( + wxEventType eType +, int nId +, WXLPARAM lParam +) const +{ + wxKeyEvent vEvent(eType); + + vEvent.SetId(GetId()); + vEvent.m_shiftDown = IsShiftDown(); + vEvent.m_controlDown = IsCtrlDown(); + vEvent.m_altDown = (HIWORD(lParam) & KC_ALT) == KC_ALT; + + vEvent.m_eventObject = (wxWindow *)this; // const_cast + vEvent.m_keyCode = nId; + vEvent.SetTimestamp(s_currentMsg.time); + + // + // Translate the position to client coords + // + POINTL vPoint; + RECTL vRect; + + ::WinQueryPointerPos(HWND_DESKTOP, &vPoint); + ::WinQueryWindowRect( GetHwnd() + ,&vRect + ); + + vPoint.x -= vRect.xLeft; + vPoint.y -= vRect.yBottom; + + vEvent.m_x = vPoint.x; + vEvent.m_y = vPoint.y; + + return vEvent; +} // end of wxWindowOS2::CreateKeyEvent + +// // isASCII is TRUE only when we're called from WM_CHAR handler and not from // WM_KEYDOWN one -bool wxWindow::HandleChar(WXWORD wParam, WXLPARAM lParam, bool isASCII) +// +bool wxWindowOS2::HandleChar( + WXDWORD wParam +, WXLPARAM lParam +, bool isASCII +) { - // TODO: - return FALSE; + bool bCtrlDown = FALSE; + int vId; + + if (isASCII) + { + // + // If 1 -> 26, translate to CTRL plus a letter. + // + vId = wParam; + if ((vId > 0) && (vId < 27)) + { + switch (vId) + { + case 13: + vId = WXK_RETURN; + break; + + case 8: + vId = WXK_BACK; + break; + + case 9: + vId = WXK_TAB; + break; + + default: + bCtrlDown = TRUE; + vId = vId + 96; + } + } + } + else if ( (vId = wxCharCodeOS2ToWX(wParam)) == 0) + { + // + // It's ASCII and will be processed here only when called from + // WM_CHAR (i.e. when isASCII = TRUE), don't process it now + // + vId = -1; + } + + if (vId != -1) + { + wxKeyEvent vEvent(CreateKeyEvent( wxEVT_CHAR + ,vId + ,lParam + )); + + if (bCtrlDown) + { + vEvent.m_controlDown = TRUE; + } + + if (GetEventHandler()->ProcessEvent(vEvent)) + return TRUE; + } + return FALSE; } -bool wxWindow::HandleKeyDown(WXWORD wParam, WXLPARAM lParam) +bool wxWindowOS2::HandleKeyDown( + WXWORD wParam +, WXLPARAM lParam +) { - // TODO: - return FALSE; -} + int nId = wxCharCodeOS2ToWX(wParam); + + if (!nId) + { + // + // Normal ASCII char + // + nId = wParam; + } + + if (nId != -1) + { + wxKeyEvent vEvent(CreateKeyEvent( wxEVT_KEY_DOWN + ,nId + ,lParam + )); -bool wxWindow::HandleKeyUp(WXWORD wParam, WXLPARAM lParam) + if (GetEventHandler()->ProcessEvent(vEvent)) + { + return TRUE; + } + } + return FALSE; +} // end of wxWindowOS2::HandleKeyDown + +bool wxWindowOS2::HandleKeyUp( + WXDWORD wParam +, WXLPARAM lParam +) { - // TODO: - return FALSE; -} + int nId = wxCharCodeOS2ToWX(wParam); + + if (!nId) + { + // + // Normal ASCII char + // + nId = wParam; + } + + if (nId != -1) + { + wxKeyEvent vEvent(CreateKeyEvent( wxEVT_KEY_UP + ,nId + ,lParam + )); + + if (GetEventHandler()->ProcessEvent(vEvent)) + return TRUE; + } + return FALSE; +} // end of wxWindowOS2::HandleKeyUp // --------------------------------------------------------------------------- // joystick // --------------------------------------------------------------------------- -bool wxWindow::HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags) -{ - // TODO: - return FALSE; -} - // --------------------------------------------------------------------------- // scrolling // --------------------------------------------------------------------------- -bool wxWindow::OS2OnScroll(int orientation, WXWORD wParam, - WXWORD pos, WXHWND control) +bool wxWindowOS2::OS2OnScroll( + int nOrientation +, WXWORD wParam +, WXWORD wPos +, WXHWND hControl +) { - if ( control ) + if (hControl) { - wxWindow *child = wxFindWinFromHandle(control); - if ( child ) - return child->OS2OnScroll(orientation, wParam, pos, control); + wxWindow* pChild = wxFindWinFromHandle(hControl); + + if (pChild ) + return pChild->OS2OnScroll( nOrientation + ,wParam + ,wPos + ,hControl + ); } - wxScrollWinEvent event; - event.SetPosition(pos); - event.SetOrientation(orientation); - event.m_eventObject = this; - // TODO: - return FALSE; -} + wxScrollWinEvent vEvent; + + vEvent.SetPosition(wPos); + vEvent.SetOrientation(nOrientation); + vEvent.m_eventObject = this; + + switch (wParam) + { + case SB_LINEUP: + vEvent.m_eventType = wxEVT_SCROLLWIN_LINEUP; + break; + + case SB_LINEDOWN: + vEvent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN; + break; + + case SB_PAGEUP: + vEvent.m_eventType = wxEVT_SCROLLWIN_PAGEUP; + break; + + case SB_PAGEDOWN: + vEvent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN; + break; + + case SB_SLIDERPOSITION: + vEvent.m_eventType = wxEVT_SCROLLWIN_THUMBRELEASE; + break; + + case SB_SLIDERTRACK: + vEvent.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK; + break; + + default: + return FALSE; + } + return GetEventHandler()->ProcessEvent(vEvent); +} // end of wxWindowOS2::OS2OnScroll // =========================================================================== // global functions // =========================================================================== -void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font) +void wxGetCharSize( + WXHWND hWnd +, int* pX +, int* pY +,wxFont* WXUNUSED(pTheFont) +) { - // TODO: -} + FONTMETRICS vFM; + HPS hPS; + BOOL rc; + + hPS =::WinGetPS(hWnd); + + rc = ::GpiQueryFontMetrics(hPS, sizeof(FONTMETRICS), &vFM); + if (rc) + { + if (pX) + *pX = vFM.lAveCharWidth; + if (pY) + *pY = vFM.lEmHeight + vFM.lExternalLeading; + } + else + { + if (pX) + *pX = 10; + if (pY) + *pY = 15; + } + ::WinReleasePS(hPS); +} // end of wxGetCharSize +// // Returns 0 if was a normal ASCII value, not a special key. This indicates that // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead. -int wxCharCodeOS2ToWX(int keySym) -{ - int id = 0; - // TODO: -/* - switch (keySym) - { - case VK_CANCEL: id = WXK_CANCEL; break; - case VK_BACK: id = WXK_BACK; break; - case VK_TAB: id = WXK_TAB; break; - case VK_CLEAR: id = WXK_CLEAR; break; - case VK_RETURN: id = WXK_RETURN; break; - case VK_SHIFT: id = WXK_SHIFT; break; - case VK_CONTROL: id = WXK_CONTROL; break; - case VK_MENU : id = WXK_MENU; break; - case VK_PAUSE: id = WXK_PAUSE; break; - case VK_SPACE: id = WXK_SPACE; break; - case VK_ESCAPE: id = WXK_ESCAPE; break; - case VK_PRIOR: id = WXK_PRIOR; break; - case VK_NEXT : id = WXK_NEXT; break; - case VK_END: id = WXK_END; break; - case VK_HOME : id = WXK_HOME; break; - case VK_LEFT : id = WXK_LEFT; break; - case VK_UP: id = WXK_UP; break; - case VK_RIGHT: id = WXK_RIGHT; break; - case VK_DOWN : id = WXK_DOWN; break; - case VK_SELECT: id = WXK_SELECT; break; - case VK_PRINT: id = WXK_PRINT; break; - case VK_EXECUTE: id = WXK_EXECUTE; break; - case VK_INSERT: id = WXK_INSERT; break; - case VK_DELETE: id = WXK_DELETE; break; - case VK_HELP : id = WXK_HELP; break; - case VK_NUMPAD0: id = WXK_NUMPAD0; break; - case VK_NUMPAD1: id = WXK_NUMPAD1; break; - case VK_NUMPAD2: id = WXK_NUMPAD2; break; - case VK_NUMPAD3: id = WXK_NUMPAD3; break; - case VK_NUMPAD4: id = WXK_NUMPAD4; break; - case VK_NUMPAD5: id = WXK_NUMPAD5; break; - case VK_NUMPAD6: id = WXK_NUMPAD6; break; - case VK_NUMPAD7: id = WXK_NUMPAD7; break; - case VK_NUMPAD8: id = WXK_NUMPAD8; break; - case VK_NUMPAD9: id = WXK_NUMPAD9; break; - case VK_MULTIPLY: id = WXK_MULTIPLY; break; - case VK_ADD: id = WXK_ADD; break; - case VK_SUBTRACT: id = WXK_SUBTRACT; break; - case VK_DECIMAL: id = WXK_DECIMAL; break; - case VK_DIVIDE: id = WXK_DIVIDE; break; - case VK_F1: id = WXK_F1; break; - case VK_F2: id = WXK_F2; break; - case VK_F3: id = WXK_F3; break; - case VK_F4: id = WXK_F4; break; - case VK_F5: id = WXK_F5; break; - case VK_F6: id = WXK_F6; break; - case VK_F7: id = WXK_F7; break; - case VK_F8: id = WXK_F8; break; - case VK_F9: id = WXK_F9; break; - case VK_F10: id = WXK_F10; break; - case VK_F11: id = WXK_F11; break; - case VK_F12: id = WXK_F12; break; - case VK_F13: id = WXK_F13; break; - case VK_F14: id = WXK_F14; break; - case VK_F15: id = WXK_F15; break; - case VK_F16: id = WXK_F16; break; - case VK_F17: id = WXK_F17; break; - case VK_F18: id = WXK_F18; break; - case VK_F19: id = WXK_F19; break; - case VK_F20: id = WXK_F20; break; - case VK_F21: id = WXK_F21; break; - case VK_F22: id = WXK_F22; break; - case VK_F23: id = WXK_F23; break; - case VK_F24: id = WXK_F24; break; - case VK_NUMLOCK: id = WXK_NUMLOCK; break; - case VK_SCROLL: id = WXK_SCROLL; break; - default: +// +int wxCharCodeOS2ToWX( + int nKeySym +) +{ + int nId = 0; + + switch (nKeySym) + { + case VK_BACKTAB: nId = WXK_BACK; break; + case VK_TAB: nId = WXK_TAB; break; + case VK_CLEAR: nId = WXK_CLEAR; break; + case VK_ENTER: nId = WXK_RETURN; break; + case VK_SHIFT: nId = WXK_SHIFT; break; + case VK_CTRL: nId = WXK_CONTROL; break; + case VK_PAUSE: nId = WXK_PAUSE; break; + case VK_SPACE: nId = WXK_SPACE; break; + case VK_ESC: nId = WXK_ESCAPE; break; + case VK_END: nId = WXK_END; break; + case VK_HOME : nId = WXK_HOME; break; + case VK_LEFT : nId = WXK_LEFT; break; + case VK_UP: nId = WXK_UP; break; + case VK_RIGHT: nId = WXK_RIGHT; break; + case VK_DOWN : nId = WXK_DOWN; break; + case VK_PRINTSCRN: nId = WXK_PRINT; break; + case VK_INSERT: nId = WXK_INSERT; break; + case VK_DELETE: nId = WXK_DELETE; break; + case VK_F1: nId = WXK_F1; break; + case VK_F2: nId = WXK_F2; break; + case VK_F3: nId = WXK_F3; break; + case VK_F4: nId = WXK_F4; break; + case VK_F5: nId = WXK_F5; break; + case VK_F6: nId = WXK_F6; break; + case VK_F7: nId = WXK_F7; break; + case VK_F8: nId = WXK_F8; break; + case VK_F9: nId = WXK_F9; break; + case VK_F10: nId = WXK_F10; break; + case VK_F11: nId = WXK_F11; break; + case VK_F12: nId = WXK_F12; break; + case VK_F13: nId = WXK_F13; break; + case VK_F14: nId = WXK_F14; break; + case VK_F15: nId = WXK_F15; break; + case VK_F16: nId = WXK_F16; break; + case VK_F17: nId = WXK_F17; break; + case VK_F18: nId = WXK_F18; break; + case VK_F19: nId = WXK_F19; break; + case VK_F20: nId = WXK_F20; break; + case VK_F21: nId = WXK_F21; break; + case VK_F22: nId = WXK_F22; break; + case VK_F23: nId = WXK_F23; break; + case VK_F24: nId = WXK_F24; break; + case VK_NUMLOCK: nId = WXK_NUMLOCK; break; + case VK_SCRLLOCK: nId = WXK_SCROLL; break; + default: { return 0; } } -*/ - return id; -} + return nId; +} // end of wxCharCodeOS2ToWX + +int wxCharCodeWXToOS2( + int nId +, bool* bIsVirtual +) +{ + int nKeySym = 0; -int wxCharCodeWXToOS2(int id, bool *isVirtual) -{ - *isVirtual = TRUE; - int keySym = 0; - // TODO -/* - switch (id) - { - case WXK_CANCEL: keySym = VK_CANCEL; break; - case WXK_CLEAR: keySym = VK_CLEAR; break; - case WXK_SHIFT: keySym = VK_SHIFT; break; - case WXK_CONTROL: keySym = VK_CONTROL; break; - case WXK_MENU : keySym = VK_MENU; break; - case WXK_PAUSE: keySym = VK_PAUSE; break; - case WXK_PRIOR: keySym = VK_PRIOR; break; - case WXK_NEXT : keySym = VK_NEXT; break; - case WXK_END: keySym = VK_END; break; - case WXK_HOME : keySym = VK_HOME; break; - case WXK_LEFT : keySym = VK_LEFT; break; - case WXK_UP: keySym = VK_UP; break; - case WXK_RIGHT: keySym = VK_RIGHT; break; - case WXK_DOWN : keySym = VK_DOWN; break; - case WXK_SELECT: keySym = VK_SELECT; break; - case WXK_PRINT: keySym = VK_PRINT; break; - case WXK_EXECUTE: keySym = VK_EXECUTE; break; - case WXK_INSERT: keySym = VK_INSERT; break; - case WXK_DELETE: keySym = VK_DELETE; break; - case WXK_HELP : keySym = VK_HELP; break; - case WXK_NUMPAD0: keySym = VK_NUMPAD0; break; - case WXK_NUMPAD1: keySym = VK_NUMPAD1; break; - case WXK_NUMPAD2: keySym = VK_NUMPAD2; break; - case WXK_NUMPAD3: keySym = VK_NUMPAD3; break; - case WXK_NUMPAD4: keySym = VK_NUMPAD4; break; - case WXK_NUMPAD5: keySym = VK_NUMPAD5; break; - case WXK_NUMPAD6: keySym = VK_NUMPAD6; break; - case WXK_NUMPAD7: keySym = VK_NUMPAD7; break; - case WXK_NUMPAD8: keySym = VK_NUMPAD8; break; - case WXK_NUMPAD9: keySym = VK_NUMPAD9; break; - case WXK_MULTIPLY: keySym = VK_MULTIPLY; break; - case WXK_ADD: keySym = VK_ADD; break; - case WXK_SUBTRACT: keySym = VK_SUBTRACT; break; - case WXK_DECIMAL: keySym = VK_DECIMAL; break; - case WXK_DIVIDE: keySym = VK_DIVIDE; break; - case WXK_F1: keySym = VK_F1; break; - case WXK_F2: keySym = VK_F2; break; - case WXK_F3: keySym = VK_F3; break; - case WXK_F4: keySym = VK_F4; break; - case WXK_F5: keySym = VK_F5; break; - case WXK_F6: keySym = VK_F6; break; - case WXK_F7: keySym = VK_F7; break; - case WXK_F8: keySym = VK_F8; break; - case WXK_F9: keySym = VK_F9; break; - case WXK_F10: keySym = VK_F10; break; - case WXK_F11: keySym = VK_F11; break; - case WXK_F12: keySym = VK_F12; break; - case WXK_F13: keySym = VK_F13; break; - case WXK_F14: keySym = VK_F14; break; - case WXK_F15: keySym = VK_F15; break; - case WXK_F16: keySym = VK_F16; break; - case WXK_F17: keySym = VK_F17; break; - case WXK_F18: keySym = VK_F18; break; - case WXK_F19: keySym = VK_F19; break; - case WXK_F20: keySym = VK_F20; break; - case WXK_F21: keySym = VK_F21; break; - case WXK_F22: keySym = VK_F22; break; - case WXK_F23: keySym = VK_F23; break; - case WXK_F24: keySym = VK_F24; break; - case WXK_NUMLOCK: keySym = VK_NUMLOCK; break; - case WXK_SCROLL: keySym = VK_SCROLL; break; - default: + *bIsVirtual = TRUE; + switch (nId) + { + case WXK_CLEAR: nKeySym = VK_CLEAR; break; + case WXK_SHIFT: nKeySym = VK_SHIFT; break; + case WXK_CONTROL: nKeySym = VK_CTRL; break; + case WXK_PAUSE: nKeySym = VK_PAUSE; break; + case WXK_END: nKeySym = VK_END; break; + case WXK_HOME : nKeySym = VK_HOME; break; + case WXK_LEFT : nKeySym = VK_LEFT; break; + case WXK_UP: nKeySym = VK_UP; break; + case WXK_RIGHT: nKeySym = VK_RIGHT; break; + case WXK_DOWN : nKeySym = VK_DOWN; break; + case WXK_PRINT: nKeySym = VK_PRINTSCRN; break; + case WXK_INSERT: nKeySym = VK_INSERT; break; + case WXK_DELETE: nKeySym = VK_DELETE; break; + case WXK_F1: nKeySym = VK_F1; break; + case WXK_F2: nKeySym = VK_F2; break; + case WXK_F3: nKeySym = VK_F3; break; + case WXK_F4: nKeySym = VK_F4; break; + case WXK_F5: nKeySym = VK_F5; break; + case WXK_F6: nKeySym = VK_F6; break; + case WXK_F7: nKeySym = VK_F7; break; + case WXK_F8: nKeySym = VK_F8; break; + case WXK_F9: nKeySym = VK_F9; break; + case WXK_F10: nKeySym = VK_F10; break; + case WXK_F11: nKeySym = VK_F11; break; + case WXK_F12: nKeySym = VK_F12; break; + case WXK_F13: nKeySym = VK_F13; break; + case WXK_F14: nKeySym = VK_F14; break; + case WXK_F15: nKeySym = VK_F15; break; + case WXK_F16: nKeySym = VK_F16; break; + case WXK_F17: nKeySym = VK_F17; break; + case WXK_F18: nKeySym = VK_F18; break; + case WXK_F19: nKeySym = VK_F19; break; + case WXK_F20: nKeySym = VK_F20; break; + case WXK_F21: nKeySym = VK_F21; break; + case WXK_F22: nKeySym = VK_F22; break; + case WXK_F23: nKeySym = VK_F23; break; + case WXK_F24: nKeySym = VK_F24; break; + case WXK_NUMLOCK: nKeySym = VK_NUMLOCK; break; + case WXK_SCROLL: nKeySym = VK_SCRLLOCK; break; + default: { - *isVirtual = FALSE; - keySym = id; + *bIsVirtual = FALSE; + nKeySym = nId; break; } } -*/ - return keySym; -} - -wxWindow *wxGetActiveWindow() -{ - // TODO - return NULL; -} - -// Windows keyboard hook. Allows interception of e.g. F1, ESCAPE -// in active frames and dialogs, regardless of where the focus is. -//static HHOOK wxTheKeyboardHook = 0; -//static FARPROC wxTheKeyboardHookProc = 0; -int wxKeyboardHook(int nCode, WORD wParam, DWORD lParam); + return nKeySym; +} // end of wxCharCodeWXToOS2 -void wxSetKeyboardHook(bool doIt) +wxWindow* wxGetActiveWindow() { - // TODO: -} - -int wxKeyboardHook(int nCode, WORD wParam, DWORD lParam) -{ - // TODO: + HWND hWnd = ::WinQueryActiveWindow(HWND_DESKTOP); - return 0; -} + if (hWnd != 0) + { + return wxFindWinFromHandle((WXHWND)hWnd); + } + return NULL; +} // end of wxGetActiveWindow #ifdef __WXDEBUG__ -const char *wxGetMessageName(int message) +const char* wxGetMessageName( + int nMessage) { - // TODO -/* - switch ( message ) + switch (nMessage) { case 0x0000: return "WM_NULL"; case 0x0001: return "WM_CREATE"; case 0x0002: return "WM_DESTROY"; - case 0x0003: return "WM_MOVE"; - case 0x0005: return "WM_SIZE"; - case 0x0006: return "WM_ACTIVATE"; - case 0x0007: return "WM_SETFOCUS"; - case 0x0008: return "WM_KILLFOCUS"; - case 0x000A: return "WM_ENABLE"; - case 0x000B: return "WM_SETREDRAW"; - case 0x000C: return "WM_SETTEXT"; - case 0x000D: return "WM_GETTEXT"; - case 0x000E: return "WM_GETTEXTLENGTH"; - case 0x000F: return "WM_PAINT"; - case 0x0010: return "WM_CLOSE"; - case 0x0011: return "WM_QUERYENDSESSION"; - case 0x0012: return "WM_QUIT"; - case 0x0013: return "WM_QUERYOPEN"; - case 0x0014: return "WM_ERASEBKGND"; - case 0x0015: return "WM_SYSCOLORCHANGE"; - case 0x0016: return "WM_ENDSESSION"; - case 0x0017: return "WM_SYSTEMERROR"; - case 0x0018: return "WM_SHOWWINDOW"; - case 0x0019: return "WM_CTLCOLOR"; - case 0x001A: return "WM_WININICHANGE"; - case 0x001B: return "WM_DEVMODECHANGE"; - case 0x001C: return "WM_ACTIVATEAPP"; - case 0x001D: return "WM_FONTCHANGE"; - case 0x001E: return "WM_TIMECHANGE"; - case 0x001F: return "WM_CANCELMODE"; - case 0x0020: return "WM_SETCURSOR"; - case 0x0021: return "WM_MOUSEACTIVATE"; - case 0x0022: return "WM_CHILDACTIVATE"; - case 0x0023: return "WM_QUEUESYNC"; - case 0x0024: return "WM_GETMINMAXINFO"; - case 0x0026: return "WM_PAINTICON"; - case 0x0027: return "WM_ICONERASEBKGND"; - case 0x0028: return "WM_NEXTDLGCTL"; - case 0x002A: return "WM_SPOOLERSTATUS"; - case 0x002B: return "WM_DRAWITEM"; - case 0x002C: return "WM_MEASUREITEM"; - case 0x002D: return "WM_DELETEITEM"; - case 0x002E: return "WM_VKEYTOITEM"; - case 0x002F: return "WM_CHARTOITEM"; - case 0x0030: return "WM_SETFONT"; - case 0x0031: return "WM_GETFONT"; - case 0x0037: return "WM_QUERYDRAGICON"; - case 0x0039: return "WM_COMPAREITEM"; - case 0x0041: return "WM_COMPACTING"; - case 0x0044: return "WM_COMMNOTIFY"; - case 0x0046: return "WM_WINDOWPOSCHANGING"; - case 0x0047: return "WM_WINDOWPOSCHANGED"; - case 0x0048: return "WM_POWER"; - -#ifdef __WIN32__ - case 0x004A: return "WM_COPYDATA"; - case 0x004B: return "WM_CANCELJOURNAL"; - case 0x004E: return "WM_NOTIFY"; - case 0x0050: return "WM_INPUTLANGCHANGEREQUEST"; - case 0x0051: return "WM_INPUTLANGCHANGE"; - case 0x0052: return "WM_TCARD"; - case 0x0053: return "WM_HELP"; - case 0x0054: return "WM_USERCHANGED"; - case 0x0055: return "WM_NOTIFYFORMAT"; - case 0x007B: return "WM_CONTEXTMENU"; - case 0x007C: return "WM_STYLECHANGING"; - case 0x007D: return "WM_STYLECHANGED"; - case 0x007E: return "WM_DISPLAYCHANGE"; - case 0x007F: return "WM_GETICON"; - case 0x0080: return "WM_SETICON"; -#endif //WIN32 - - case 0x0081: return "WM_NCCREATE"; - case 0x0082: return "WM_NCDESTROY"; - case 0x0083: return "WM_NCCALCSIZE"; - case 0x0084: return "WM_NCHITTEST"; - case 0x0085: return "WM_NCPAINT"; - case 0x0086: return "WM_NCACTIVATE"; - case 0x0087: return "WM_GETDLGCODE"; - case 0x00A0: return "WM_NCMOUSEMOVE"; - case 0x00A1: return "WM_NCLBUTTONDOWN"; - case 0x00A2: return "WM_NCLBUTTONUP"; - case 0x00A3: return "WM_NCLBUTTONDBLCLK"; - case 0x00A4: return "WM_NCRBUTTONDOWN"; - case 0x00A5: return "WM_NCRBUTTONUP"; - case 0x00A6: return "WM_NCRBUTTONDBLCLK"; - case 0x00A7: return "WM_NCMBUTTONDOWN"; - case 0x00A8: return "WM_NCMBUTTONUP"; - case 0x00A9: return "WM_NCMBUTTONDBLCLK"; - case 0x0100: return "WM_KEYDOWN"; - case 0x0101: return "WM_KEYUP"; - case 0x0102: return "WM_CHAR"; - case 0x0103: return "WM_DEADCHAR"; - case 0x0104: return "WM_SYSKEYDOWN"; - case 0x0105: return "WM_SYSKEYUP"; - case 0x0106: return "WM_SYSCHAR"; - case 0x0107: return "WM_SYSDEADCHAR"; - case 0x0108: return "WM_KEYLAST"; - -#ifdef __WIN32__ - case 0x010D: return "WM_IME_STARTCOMPOSITION"; - case 0x010E: return "WM_IME_ENDCOMPOSITION"; - case 0x010F: return "WM_IME_COMPOSITION"; -#endif //WIN32 - - case 0x0110: return "WM_INITDIALOG"; - case 0x0111: return "WM_COMMAND"; - case 0x0112: return "WM_SYSCOMMAND"; - case 0x0113: return "WM_TIMER"; - case 0x0114: return "WM_HSCROLL"; - case 0x0115: return "WM_VSCROLL"; - case 0x0116: return "WM_INITMENU"; - case 0x0117: return "WM_INITMENUPOPUP"; - case 0x011F: return "WM_MENUSELECT"; - case 0x0120: return "WM_MENUCHAR"; - case 0x0121: return "WM_ENTERIDLE"; - case 0x0200: return "WM_MOUSEMOVE"; - case 0x0201: return "WM_LBUTTONDOWN"; - case 0x0202: return "WM_LBUTTONUP"; - case 0x0203: return "WM_LBUTTONDBLCLK"; - case 0x0204: return "WM_RBUTTONDOWN"; - case 0x0205: return "WM_RBUTTONUP"; - case 0x0206: return "WM_RBUTTONDBLCLK"; - case 0x0207: return "WM_MBUTTONDOWN"; - case 0x0208: return "WM_MBUTTONUP"; - case 0x0209: return "WM_MBUTTONDBLCLK"; - case 0x0210: return "WM_PARENTNOTIFY"; - case 0x0211: return "WM_ENTERMENULOOP"; - case 0x0212: return "WM_EXITMENULOOP"; - -#ifdef __WIN32__ - case 0x0213: return "WM_NEXTMENU"; - case 0x0214: return "WM_SIZING"; - case 0x0215: return "WM_CAPTURECHANGED"; - case 0x0216: return "WM_MOVING"; - case 0x0218: return "WM_POWERBROADCAST"; - case 0x0219: return "WM_DEVICECHANGE"; -#endif //WIN32 - - case 0x0220: return "WM_MDICREATE"; - case 0x0221: return "WM_MDIDESTROY"; - case 0x0222: return "WM_MDIACTIVATE"; - case 0x0223: return "WM_MDIRESTORE"; - case 0x0224: return "WM_MDINEXT"; - case 0x0225: return "WM_MDIMAXIMIZE"; - case 0x0226: return "WM_MDITILE"; - case 0x0227: return "WM_MDICASCADE"; - case 0x0228: return "WM_MDIICONARRANGE"; - case 0x0229: return "WM_MDIGETACTIVE"; - case 0x0230: return "WM_MDISETMENU"; - case 0x0233: return "WM_DROPFILES"; - -#ifdef __WIN32__ - case 0x0281: return "WM_IME_SETCONTEXT"; - case 0x0282: return "WM_IME_NOTIFY"; - case 0x0283: return "WM_IME_CONTROL"; - case 0x0284: return "WM_IME_COMPOSITIONFULL"; - case 0x0285: return "WM_IME_SELECT"; - case 0x0286: return "WM_IME_CHAR"; - case 0x0290: return "WM_IME_KEYDOWN"; - case 0x0291: return "WM_IME_KEYUP"; -#endif //WIN32 - - case 0x0300: return "WM_CUT"; - case 0x0301: return "WM_COPY"; - case 0x0302: return "WM_PASTE"; - case 0x0303: return "WM_CLEAR"; - case 0x0304: return "WM_UNDO"; - case 0x0305: return "WM_RENDERFORMAT"; - case 0x0306: return "WM_RENDERALLFORMATS"; - case 0x0307: return "WM_DESTROYCLIPBOARD"; - case 0x0308: return "WM_DRAWCLIPBOARD"; - case 0x0309: return "WM_PAINTCLIPBOARD"; - case 0x030A: return "WM_VSCROLLCLIPBOARD"; - case 0x030B: return "WM_SIZECLIPBOARD"; - case 0x030C: return "WM_ASKCBFORMATNAME"; - case 0x030D: return "WM_CHANGECBCHAIN"; - case 0x030E: return "WM_HSCROLLCLIPBOARD"; - case 0x030F: return "WM_QUERYNEWPALETTE"; - case 0x0310: return "WM_PALETTEISCHANGING"; - case 0x0311: return "WM_PALETTECHANGED"; - -#ifdef __WIN32__ - // common controls messages - although they're not strictly speaking - // standard, it's nice to decode them nevertheless + case 0x0004: return "WM_ENABLE"; + case 0x0005: return "WM_SHOW"; + case 0x0006: return "WM_MOVE"; + case 0x0007: return "WM_SIZE"; + case 0x0008: return "WM_ADJUSTWINDOWPOS"; + case 0x0009: return "WM_CALCVALIDRECTS"; + case 0x000A: return "WM_SETWINDOWPARAMS"; + case 0x000B: return "WM_QUERYWINDOWPARAMS"; + case 0x000C: return "WM_HITTEST"; + case 0x000D: return "WM_ACTIVATE"; + case 0x000F: return "WM_SETFOCUS"; + case 0x0010: return "WM_SETSELECTION"; + case 0x0011: return "WM_PPAINT"; + case 0x0012: return "WM_PSETFOCUS"; + case 0x0013: return "WM_PSYSCOLORCHANGE"; + case 0x0014: return "WM_PSIZE"; + case 0x0015: return "WM_PACTIVATE"; + case 0x0016: return "WM_PCONTROL"; + case 0x0020: return "WM_COMMAND"; + case 0x0021: return "WM_SYSCOMMAND"; + case 0x0022: return "WM_HELP"; + case 0x0023: return "WM_PAINT"; + case 0x0024: return "WM_TIMER"; + case 0x0025: return "WM_SEM1"; + case 0x0026: return "WM_SEM2"; + case 0x0027: return "WM_SEM3"; + case 0x0028: return "WM_SEM4"; + case 0x0029: return "WM_CLOSE"; + case 0x002A: return "WM_QUIT"; + case 0x002B: return "WM_SYSCOLORCHANGE"; + case 0x002D: return "WM_SYSVALUECHANGE"; + case 0x002E: return "WM_APPTERMINATENOTIFY"; + case 0x002F: return "WM_PRESPARAMCHANGED"; + // Control notification messages + case 0x0030: return "WM_CONTROL"; + case 0x0031: return "WM_VSCROLL"; + case 0x0032: return "WM_HSCROLL"; + case 0x0033: return "WM_INITMENU"; + case 0x0034: return "WM_MENUSELECT"; + case 0x0035: return "WM_MENUSEND"; + case 0x0036: return "WM_DRAWITEM"; + case 0x0037: return "WM_MEASUREITEM"; + case 0x0038: return "WM_CONTROLPOINTER"; + case 0x003A: return "WM_QUERYDLGCODE"; + case 0x003B: return "WM_INITDLG"; + case 0x003C: return "WM_SUBSTITUTESTRING"; + case 0x003D: return "WM_MATCHMNEMONIC"; + case 0x003E: return "WM_SAVEAPPLICATION"; + case 0x0129: return "WM_CTLCOLORCHANGE"; + case 0x0130: return "WM_QUERYCTLTYPE"; + // Frame messages + case 0x0040: return "WM_FLASHWINDOW"; + case 0x0041: return "WM_FORMATFRAME"; + case 0x0042: return "WM_UPDATEFRAME"; + case 0x0043: return "WM_FOCUSCHANGE"; + case 0x0044: return "WM_SETBORDERSIZE"; + case 0x0045: return "WM_TRACKFRAME"; + case 0x0046: return "WM_MINMAXFRAME"; + case 0x0047: return "WM_SETICON"; + case 0x0048: return "WM_QUERYICON"; + case 0x0049: return "WM_SETACCELTABLE"; + case 0x004A: return "WM_QUERYACCELTABLE"; + case 0x004B: return "WM_TRANSLATEACCEL"; + case 0x004C: return "WM_QUERYTRACKINFO"; + case 0x004D: return "WM_QUERYBORDERSIZE"; + case 0x004E: return "WM_NEXTMENU"; + case 0x004F: return "WM_ERASEBACKGROUND"; + case 0x0050: return "WM_QUERYFRAMEINFO"; + case 0x0051: return "WM_QUERYFOCUSCHAIN"; + case 0x0052: return "WM_OWNERPOSCHANGE"; + case 0x0053: return "WM_CACLFRAMERECT"; + case 0x0055: return "WM_WINDOWPOSCHANGED"; + case 0x0056: return "WM_ADJUSTFRAMEPOS"; + case 0x0059: return "WM_QUERYFRAMECTLCOUNT"; + case 0x005B: return "WM_QUERYHELPINFO"; + case 0x005C: return "WM_SETHELPINFO"; + case 0x005D: return "WM_ERROR"; + case 0x005E: return "WM_REALIZEPALETTE"; + // Clipboard messages + case 0x0060: return "WM_RENDERFMT"; + case 0x0061: return "WM_RENDERALLFMTS"; + case 0x0062: return "WM_DESTROYCLIPBOARD"; + case 0x0063: return "WM_PAINTCLIPBOARD"; + case 0x0064: return "WM_SIZECLIPBOARD"; + case 0x0065: return "WM_HSCROLLCLIPBOARD"; + case 0x0066: return "WM_VSCROLLCLIPBOARD"; + case 0x0067: return "WM_DRAWCLIPBOARD"; + // mouse messages + case 0x0070: return "WM_MOUSEMOVE"; + case 0x0071: return "WM_BUTTON1DOWN"; + case 0x0072: return "WM_BUTTON1UP"; + case 0x0073: return "WM_BUTTON1DBLCLK"; + case 0x0074: return "WM_BUTTON2DOWN"; + case 0x0075: return "WM_BUTTON2UP"; + case 0x0076: return "WM_BUTTON2DBLCLK"; + case 0x0077: return "WM_BUTTON3DOWN"; + case 0x0078: return "WM_BUTTON3UP"; + case 0x0079: return "WM_BUTTON3DBLCLK"; + case 0x007D: return "WM_MOUSEMAP"; + case 0x007E: return "WM_VRNDISABLED"; + case 0x007F: return "WM_VRNENABLED"; + case 0x0410: return "WM_CHORD"; + case 0x0411: return "WM_BUTTON1MOTIONSTART"; + case 0x0412: return "WM_BUTTON1MOTIONEND"; + case 0x0413: return "WM_BUTTON1CLICK"; + case 0x0414: return "WM_BUTTON2MOTIONSTART"; + case 0x0415: return "WM_BUTTON2MOTIONEND"; + case 0x0416: return "WM_BUTTON2CLICK"; + case 0x0417: return "WM_BUTTON3MOTIONSTART"; + case 0x0418: return "WM_BUTTON3MOTIONEND"; + case 0x0419: return "WM_BUTTON3CLICK"; + case 0x0420: return "WM_BEGINDRAG"; + case 0x0421: return "WM_ENDDRAG"; + case 0x0422: return "WM_SINGLESELECT"; + case 0x0423: return "WM_OPEN"; + case 0x0424: return "WM_CONTEXTMENU"; + case 0x0425: return "WM_CONTEXTHELP"; + case 0x0426: return "WM_TEXTEDIT"; + case 0x0427: return "WM_BEGINSELECT"; + case 0x0228: return "WM_ENDSELECT"; + case 0x0429: return "WM_PICKUP"; + case 0x04C0: return "WM_PENFIRST"; + case 0x04FF: return "WM_PENLAST"; + case 0x0500: return "WM_MMPMFIRST"; + case 0x05FF: return "WM_MMPMLAST"; + case 0x0600: return "WM_STDDLGFIRST"; + case 0x06FF: return "WM_STDDLGLAST"; + case 0x0BD0: return "WM_BIDI_FIRST"; + case 0x0BFF: return "WM_BIDI_LAST"; + // keyboard input + case 0x007A: return "WM_CHAR"; + case 0x007B: return "WM_VIOCHAR"; + // DDE messages + case 0x00A0: return "WM_DDE_INITIATE"; + case 0x00A1: return "WM_DDE_REQUEST"; + case 0x00A2: return "WM_DDE_ACK"; + case 0x00A3: return "WM_DDE_DATA"; + case 0x00A4: return "WM_DDE_ADVISE"; + case 0x00A5: return "WM_DDE_UNADVISE"; + case 0x00A6: return "WM_DDE_POKE"; + case 0x00A7: return "WM_DDE_EXECUTE"; + case 0x00A8: return "WM_DDE_TERMINATE"; + case 0x00A9: return "WM_DDE_INITIATEACK"; + case 0x00AF: return "WM_DDE_LAST"; + // Buttons + case 0x0120: return "BM_CLICK"; + case 0x0121: return "BM_QUERYCHECKINDEX"; + case 0x0122: return "BM_QUERYHILITE"; + case 0x0123: return "BM_SETHILITE"; + case 0x0124: return "BM_QUERYCHECK"; + case 0x0125: return "BM_SETCHECK"; + case 0x0126: return "BM_SETDEFAULT"; + case 0x0128: return "BM_AUTOSIZE"; + // Combo boxes + case 0x029A: return "CBID_LIST"; + case 0x029B: return "CBID_EDIT"; + case 0x0170: return "CBM_SHOWLIST"; + case 0x0171: return "CBM_HILITE"; + case 0x0172: return "CBM_ISLISTSHOWING"; + // Edit fields + case 0x0140: return "EM_QUERYCHANGED"; + case 0x0141: return "EM_QUERYSEL"; + case 0x0142: return "EM_SETSEL"; + case 0x0143: return "EM_SETTEXTLIMIT"; + case 0x0144: return "EM_CUT"; + case 0x0145: return "EM_COPY"; + case 0x0146: return "EM_CLEAR"; + case 0x0147: return "EM_PASTE"; + case 0x0148: return "EM_QUERYFIRSTCHAR"; + case 0x0149: return "EM_SETFIRSTCHAR"; + case 0x014A: return "EM_QUERYREADONLY"; + case 0x014B: return "EM_SETREADONLY"; + case 0x014C: return "EM_SETINSERTMODE"; + // Listboxes + case 0x0160: return "LM_QUERYITEMCOUNT"; + case 0x0161: return "LM_INSERTITEM"; + case 0x0162: return "LM_SETOPENINDEX"; + case 0x0163: return "LM_DELETEITEM"; + case 0x0164: return "LM_SELECTITEM"; + case 0x0165: return "LM_QUERYSELECTION"; + case 0x0166: return "LM_SETITEMTEXT"; + case 0x0167: return "LM_QUERYITEMTEXTLENGTH"; + case 0x0168: return "LM_QUERYITEMTEXT"; + case 0x0169: return "LM_SETITEMHANDLE"; + case 0x016A: return "LM_QUERYITEMHANDLE"; + case 0x016B: return "LM_SEARCHSTRING"; + case 0x016C: return "LM_SETITEMHEIGHT"; + case 0x016D: return "LM_QUERYTOPINDEX"; + case 0x016E: return "LM_DELETEALL"; + case 0x016F: return "LM_INSERTMULITEMS"; + case 0x0660: return "LM_SETITEMWIDTH"; + // Menus + case 0x0180: return "MM_INSERTITEM"; + case 0x0181: return "MM_DELETEITEM"; + case 0x0182: return "MM_QUERYITEM"; + case 0x0183: return "MM_SETITEM"; + case 0x0184: return "MM_QUERYITEMCOUNT"; + case 0x0185: return "MM_STARTMENUMODE"; + case 0x0186: return "MM_ENDMENUMODE"; + case 0x0188: return "MM_REMOVEITEM"; + case 0x0189: return "MM_SELECTITEM"; + case 0x018A: return "MM_QUERYSELITEMID"; + case 0x018B: return "MM_QUERYITEMTEXT"; + case 0x018C: return "MM_QUERYITEMTEXTLENGTH"; + case 0x018D: return "MM_SETITEMHANDLE"; + case 0x018E: return "MM_SETITEMTEXT"; + case 0x018F: return "MM_ITEMPOSITIONFROMID"; + case 0x0190: return "MM_ITEMIDFROMPOSITION"; + case 0x0191: return "MM_QUERYITEMATTR"; + case 0x0192: return "MM_SETITEMATTR"; + case 0x0193: return "MM_ISITEMVALID"; + case 0x0194: return "MM_QUERYITEMRECT"; + case 0x0431: return "MM_QUERYDEFAULTITEMID"; + case 0x0432: return "MM_SETDEFAULTITEMID"; + // Scrollbars + case 0x01A0: return "SBM_SETSCROLLBAR"; + case 0x01A1: return "SBM_SETPOS"; + case 0x01A2: return "SBM_QUERYPOS"; + case 0x01A3: return "SBM_QUERYRANGE"; + case 0x01A6: return "SBM_SETTHUMBSIZE"; + + // Help messages + case 0x0F00: return "WM_HELPBASE"; + case 0x0FFF: return "WM_HELPTOP"; + // Beginning of user defined messages + case 0x1000: return "WM_USER"; + + // wxWindows user defined types // listview - case 0x1000 + 0: return "LVM_GETBKCOLOR"; + // case 0x1000 + 0: return "LVM_GETBKCOLOR"; case 0x1000 + 1: return "LVM_SETBKCOLOR"; case 0x1000 + 2: return "LVM_GETIMAGELIST"; case 0x1000 + 3: return "LVM_SETIMAGELIST"; @@ -2820,73 +4425,144 @@ const char *wxGetMessageName(int message) case 0x1300 + 50: return "TCM_DESELECTALL"; // toolbar - case WM_USER+1: return "TB_ENABLEBUTTON"; - case WM_USER+2: return "TB_CHECKBUTTON"; - case WM_USER+3: return "TB_PRESSBUTTON"; - case WM_USER+4: return "TB_HIDEBUTTON"; - case WM_USER+5: return "TB_INDETERMINATE"; - case WM_USER+9: return "TB_ISBUTTONENABLED"; - case WM_USER+10: return "TB_ISBUTTONCHECKED"; - case WM_USER+11: return "TB_ISBUTTONPRESSED"; - case WM_USER+12: return "TB_ISBUTTONHIDDEN"; - case WM_USER+13: return "TB_ISBUTTONINDETERMINATE"; - case WM_USER+17: return "TB_SETSTATE"; - case WM_USER+18: return "TB_GETSTATE"; - case WM_USER+19: return "TB_ADDBITMAP"; - case WM_USER+20: return "TB_ADDBUTTONS"; - case WM_USER+21: return "TB_INSERTBUTTON"; - case WM_USER+22: return "TB_DELETEBUTTON"; - case WM_USER+23: return "TB_GETBUTTON"; - case WM_USER+24: return "TB_BUTTONCOUNT"; - case WM_USER+25: return "TB_COMMANDTOINDEX"; - case WM_USER+26: return "TB_SAVERESTOREA"; - case WM_USER+76: return "TB_SAVERESTOREW"; - case WM_USER+27: return "TB_CUSTOMIZE"; - case WM_USER+28: return "TB_ADDSTRINGA"; - case WM_USER+77: return "TB_ADDSTRINGW"; - case WM_USER+29: return "TB_GETITEMRECT"; - case WM_USER+30: return "TB_BUTTONSTRUCTSIZE"; - case WM_USER+31: return "TB_SETBUTTONSIZE"; - case WM_USER+32: return "TB_SETBITMAPSIZE"; - case WM_USER+33: return "TB_AUTOSIZE"; - case WM_USER+35: return "TB_GETTOOLTIPS"; - case WM_USER+36: return "TB_SETTOOLTIPS"; - case WM_USER+37: return "TB_SETPARENT"; - case WM_USER+39: return "TB_SETROWS"; - case WM_USER+40: return "TB_GETROWS"; - case WM_USER+42: return "TB_SETCMDID"; - case WM_USER+43: return "TB_CHANGEBITMAP"; - case WM_USER+44: return "TB_GETBITMAP"; - case WM_USER+45: return "TB_GETBUTTONTEXTA"; - case WM_USER+75: return "TB_GETBUTTONTEXTW"; - case WM_USER+46: return "TB_REPLACEBITMAP"; - case WM_USER+47: return "TB_SETINDENT"; - case WM_USER+48: return "TB_SETIMAGELIST"; - case WM_USER+49: return "TB_GETIMAGELIST"; - case WM_USER+50: return "TB_LOADIMAGES"; - case WM_USER+51: return "TB_GETRECT"; - case WM_USER+52: return "TB_SETHOTIMAGELIST"; - case WM_USER+53: return "TB_GETHOTIMAGELIST"; - case WM_USER+54: return "TB_SETDISABLEDIMAGELIST"; - case WM_USER+55: return "TB_GETDISABLEDIMAGELIST"; - case WM_USER+56: return "TB_SETSTYLE"; - case WM_USER+57: return "TB_GETSTYLE"; - case WM_USER+58: return "TB_GETBUTTONSIZE"; - case WM_USER+59: return "TB_SETBUTTONWIDTH"; - case WM_USER+60: return "TB_SETMAXTEXTROWS"; - case WM_USER+61: return "TB_GETTEXTROWS"; - case WM_USER+41: return "TB_GETBITMAPFLAGS"; - -#endif //WIN32 + case WM_USER+1000+1: return "TB_ENABLEBUTTON"; + case WM_USER+1000+2: return "TB_CHECKBUTTON"; + case WM_USER+1000+3: return "TB_PRESSBUTTON"; + case WM_USER+1000+4: return "TB_HIDEBUTTON"; + case WM_USER+1000+5: return "TB_INDETERMINATE"; + case WM_USER+1000+9: return "TB_ISBUTTONENABLED"; + case WM_USER+1000+10: return "TB_ISBUTTONCHECKED"; + case WM_USER+1000+11: return "TB_ISBUTTONPRESSED"; + case WM_USER+1000+12: return "TB_ISBUTTONHIDDEN"; + case WM_USER+1000+13: return "TB_ISBUTTONINDETERMINATE"; + case WM_USER+1000+17: return "TB_SETSTATE"; + case WM_USER+1000+18: return "TB_GETSTATE"; + case WM_USER+1000+19: return "TB_ADDBITMAP"; + case WM_USER+1000+20: return "TB_ADDBUTTONS"; + case WM_USER+1000+21: return "TB_INSERTBUTTON"; + case WM_USER+1000+22: return "TB_DELETEBUTTON"; + case WM_USER+1000+23: return "TB_GETBUTTON"; + case WM_USER+1000+24: return "TB_BUTTONCOUNT"; + case WM_USER+1000+25: return "TB_COMMANDTOINDEX"; + case WM_USER+1000+26: return "TB_SAVERESTOREA"; + case WM_USER+1000+76: return "TB_SAVERESTOREW"; + case WM_USER+1000+27: return "TB_CUSTOMIZE"; + case WM_USER+1000+28: return "TB_ADDSTRINGA"; + case WM_USER+1000+77: return "TB_ADDSTRINGW"; + case WM_USER+1000+29: return "TB_GETITEMRECT"; + case WM_USER+1000+30: return "TB_BUTTONSTRUCTSIZE"; + case WM_USER+1000+31: return "TB_SETBUTTONSIZE"; + case WM_USER+1000+32: return "TB_SETBITMAPSIZE"; + case WM_USER+1000+33: return "TB_AUTOSIZE"; + case WM_USER+1000+35: return "TB_GETTOOLTIPS"; + case WM_USER+1000+36: return "TB_SETTOOLTIPS"; + case WM_USER+1000+37: return "TB_SETPARENT"; + case WM_USER+1000+39: return "TB_SETROWS"; + case WM_USER+1000+40: return "TB_GETROWS"; + case WM_USER+1000+42: return "TB_SETCMDID"; + case WM_USER+1000+43: return "TB_CHANGEBITMAP"; + case WM_USER+1000+44: return "TB_GETBITMAP"; + case WM_USER+1000+45: return "TB_GETBUTTONTEXTA"; + case WM_USER+1000+75: return "TB_GETBUTTONTEXTW"; + case WM_USER+1000+46: return "TB_REPLACEBITMAP"; + case WM_USER+1000+47: return "TB_SETINDENT"; + case WM_USER+1000+48: return "TB_SETIMAGELIST"; + case WM_USER+1000+49: return "TB_GETIMAGELIST"; + case WM_USER+1000+50: return "TB_LOADIMAGES"; + case WM_USER+1000+51: return "TB_GETRECT"; + case WM_USER+1000+52: return "TB_SETHOTIMAGELIST"; + case WM_USER+1000+53: return "TB_GETHOTIMAGELIST"; + case WM_USER+1000+54: return "TB_SETDISABLEDIMAGELIST"; + case WM_USER+1000+55: return "TB_GETDISABLEDIMAGELIST"; + case WM_USER+1000+56: return "TB_SETSTYLE"; + case WM_USER+1000+57: return "TB_GETSTYLE"; + case WM_USER+1000+58: return "TB_GETBUTTONSIZE"; + case WM_USER+1000+59: return "TB_SETBUTTONWIDTH"; + case WM_USER+1000+60: return "TB_SETMAXTEXTROWS"; + case WM_USER+1000+61: return "TB_GETTEXTROWS"; + case WM_USER+1000+41: return "TB_GETBITMAPFLAGS"; default: static char s_szBuf[128]; - sprintf(s_szBuf, "", message); + sprintf(s_szBuf, "", nMessage); return s_szBuf; } -*/ return NULL; -} +} // end of wxGetMessageName #endif // __WXDEBUG__ +// Unused? +#if 0 +static void TranslateKbdEventToMouse( + wxWindow* pWin +, int* pX +, int* pY +, ULONG* pFlags +) +{ + // + // Construct the key mask + ULONG& fwKeys = *pFlags; + + fwKeys = VK_BUTTON2; + if ((::WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x100) != 0) + fwKeys |= VK_CTRL; + if ((::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x100) != 0) + fwKeys |= VK_SHIFT; + + // + // Simulate right mouse button click + // + POINTL vPoint; + + ::WinQueryMsgPos(vHabmain, &vPoint); + *pX = vPoint.x; + *pY = vPoint.y; + + pWin->ScreenToClient(pX, pY); +} // end of TranslateKbdEventToMouse +#endif + +// Find the wxWindow at the current mouse position, returning the mouse +// position. +wxWindow* wxFindWindowAtPointer( + wxPoint& WXUNUSED(rPt) +) +{ + return wxFindWindowAtPoint(wxGetMousePosition()); +} + +wxWindow* wxFindWindowAtPoint( + const wxPoint& rPt +) +{ + POINTL vPt2; + + vPt2.x = rPt.x; + vPt2.y = rPt.y; + + HWND hWndHit = ::WinWindowFromPoint(HWND_DESKTOP, &vPt2, FALSE); + wxWindow* pWin = wxFindWinFromHandle((WXHWND)hWndHit) ; + HWND hWnd = hWndHit; + + // + // Try to find a window with a wxWindow associated with it + // + while (!pWin && (hWnd != 0)) + { + hWnd = ::WinQueryWindow(hWnd, QW_PARENT); + pWin = wxFindWinFromHandle((WXHWND)hWnd) ; + } + return pWin; +} + +// Get the current mouse position. +wxPoint wxGetMousePosition() +{ + POINTL vPt; + + ::WinQueryPointerPos(HWND_DESKTOP, &vPt); + return wxPoint(vPt.x, vPt.y); +} +