X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/413553cc60a112af6a0942ebb7ba697ee9d5df7e..7e02be855d14263c996448bdb56c9e1002ad9b53:/src/msw/window.cpp?ds=sidebyside diff --git a/src/msw/window.cpp b/src/msw/window.cpp index d424c7e0f1..286039c640 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -28,7 +28,6 @@ #include "wx/msw/wrapwin.h" #include "wx/window.h" #include "wx/accel.h" - #include "wx/setup.h" #include "wx/menu.h" #include "wx/dc.h" #include "wx/dcclient.h" @@ -941,7 +940,7 @@ void wxWindowMSW::SetScrollbar(int orient, // We have to set the variables here to make them valid in events // triggered by ::SetScrollInfo() *(orient == wxHORIZONTAL ? &m_xThumbSize : &m_yThumbSize) = pageSize; - + ::SetScrollInfo(hWnd, orient == wxHORIZONTAL ? SB_HORZ : SB_VERT, &info, refresh); } @@ -1090,20 +1089,19 @@ void wxWindowMSW::DissociateHandle() bool wxCheckWindowWndProc(WXHWND hWnd, - WXFARPROC WXUNUSED_IN_WINCE(wndProc)) + WXFARPROC WXUNUSED(wndProc)) { - // Unicows note: the code below works, but only because WNDCLASS contains - // original window handler rather that the unicows fake one. This may not - // be on purpose, though; if it stops working with future versions of - // unicows.dll, we can override unicows hooks by setting - // Unicows_{Set,Get}WindowLong and Unicows_RegisterClass to our own - // versions that keep track of fake<->real wnd proc mapping. +// TODO: This list of window class names should be factored out so they can be +// managed in one place and then accessed from here and other places, such as +// wxApp::RegisterWindowClasses() and wxApp::UnregisterWindowClasses() - // On WinCE (at least), the wndproc comparison doesn't work, - // so have to use something like this. #ifdef __WXWINCE__ extern wxChar *wxCanvasClassName; extern wxChar *wxCanvasClassNameNR; +#else + extern const wxChar *wxCanvasClassName; + extern const wxChar *wxCanvasClassNameNR; +#endif extern const wxChar *wxMDIFrameClassName; extern const wxChar *wxMDIFrameClassNameNoRedraw; extern const wxChar *wxMDIChildFrameClassName; @@ -1117,19 +1115,8 @@ bool wxCheckWindowWndProc(WXHWND hWnd, str == wxMDIChildFrameClassNameNoRedraw || str == _T("wxTLWHiddenParent")) return true; // Effectively means don't subclass - - return false; -#else - WNDCLASS cls; - if ( !::GetClassInfo(wxGetInstance(), wxGetWindowClass(hWnd), &cls) ) - { - wxLogLastError(_T("GetClassInfo")); - + else return false; - } - - return wndProc == (WXFARPROC)cls.lpfnWndProc; -#endif } // ---------------------------------------------------------------------------- @@ -1524,12 +1511,21 @@ void wxWindowMSW::DoGetClientSize(int *x, int *y) const if ( y ) *y = rect.bottom; } - else // non top level + else // non top level and using deferred sizing { - // size is the same as client size for non top level windows, so - // forward to GetSize() to take into account deferred sizing (which - // wxGetClientRect() doesn't) - DoGetSize(x, y); + // we need to calculate the *pending* client size here + RECT rect; + rect.left = m_pendingPosition.x; + rect.top = m_pendingPosition.y; + rect.right = rect.left + m_pendingSize.x; + rect.bottom = rect.top + m_pendingSize.y; + + ::SendMessage(GetHwnd(), WM_NCCALCSIZE, FALSE, (LPARAM)&rect); + + if ( x ) + *x = rect.right - rect.left; + if ( y ) + *y = rect.bottom - rect.top; } } @@ -1749,9 +1745,10 @@ void wxWindowMSW::DoSetClientSize(int width, int height) { // setting the client size is less obvious than it could have been // because in the result of changing the total size the window scrollbar - // may [dis]appear and/or its menubar may [un]wrap and so the client size - // will not be correct as the difference between the total and client size - // changes - so we keep changing it until we get it right + // may [dis]appear and/or its menubar may [un]wrap (and AdjustWindowRect() + // doesn't take neither into account) and so the client size will not be + // correct as the difference between the total and client size changes -- + // so we keep changing it until we get it right // // normally this loop shouldn't take more than 3 iterations (usually 1 but // if scrollbars [dis]appear as the result of the first call, then 2 and it @@ -1792,7 +1789,9 @@ void wxWindowMSW::DoSetClientSize(int width, int height) } // don't call DoMoveWindow() because we want to move window immediately - // and not defer it here + // and not defer it here as otherwise the value returned by + // GetClient/WindowRect() wouldn't change as the window wouldn't be + // really resized if ( !::MoveWindow(GetHwnd(), rectWin.left, rectWin.top, @@ -5167,6 +5166,13 @@ void wxGetCharSize(WXHWND wnd, int *x, int *y, const wxFont& the_font) // the_font.ReleaseResource(); } +// use the "extended" bit (24) of lParam to distinguish extended keys +// from normal keys as the same key is sent +static inline int ChooseNormalOrExtended(int lParam, int keyNormal, int keyExtended) +{ + return lParam & (1 << 24) ? keyExtended : keyNormal; +} + // 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 wxCharCodeMSWToWX(int keySym, WXLPARAM lParam) @@ -5251,41 +5257,40 @@ int wxCharCodeMSWToWX(int keySym, WXLPARAM lParam) case VK_APPS: id = WXK_WINDOWS_MENU; break; #endif // VK_APPS defined - // use the "extended" bit (24) of lParam to distinguish extended keys - // from normal keys as the same key is sent + // handle extended keys case VK_PRIOR: - id = lParam & (1 << 24) ? WXK_PRIOR : WXK_NUMPAD_PRIOR; + id = ChooseNormalOrExtended(lParam, WXK_NUMPAD_PRIOR, WXK_PRIOR); break; case VK_NEXT: - id = lParam & (1 << 24) ? WXK_NEXT : WXK_NUMPAD_NEXT; + id = ChooseNormalOrExtended(lParam, WXK_NUMPAD_NEXT, WXK_NEXT); break; case VK_END: - id = lParam & (1 << 24) ? WXK_END : WXK_NUMPAD_END; + id = ChooseNormalOrExtended(lParam, WXK_NUMPAD_END, WXK_END); break; case VK_HOME: - id = lParam & (1 << 24) ? WXK_HOME : WXK_NUMPAD_HOME; + id = ChooseNormalOrExtended(lParam, WXK_NUMPAD_HOME, WXK_HOME); break; case VK_LEFT: - id = lParam & (1 << 24) ? WXK_LEFT : WXK_NUMPAD_LEFT; + id = ChooseNormalOrExtended(lParam, WXK_NUMPAD_LEFT, WXK_LEFT); break; case VK_UP: - id = lParam & (1 << 24) ? WXK_UP : WXK_NUMPAD_UP; + id = ChooseNormalOrExtended(lParam, WXK_NUMPAD_UP, WXK_UP); break; case VK_RIGHT: - id = lParam & (1 << 24) ? WXK_RIGHT : WXK_NUMPAD_RIGHT; + id = ChooseNormalOrExtended(lParam, WXK_NUMPAD_RIGHT, WXK_RIGHT); break; case VK_DOWN: - id = lParam & (1 << 24) ? WXK_DOWN : WXK_NUMPAD_DOWN; + id = ChooseNormalOrExtended(lParam, WXK_NUMPAD_DOWN, WXK_DOWN); break; case VK_INSERT: - id = lParam & (1 << 24) ? WXK_INSERT : WXK_NUMPAD_INSERT; + id = ChooseNormalOrExtended(lParam, WXK_NUMPAD_INSERT, WXK_INSERT); break; case VK_DELETE: - id = lParam & (1 << 24) ? WXK_DELETE : WXK_NUMPAD_DELETE; + id = ChooseNormalOrExtended(lParam, WXK_NUMPAD_DELETE, WXK_DELETE); break; // this order is correct as the numpad enter is the extended key case VK_RETURN: - id = lParam & (1 << 24) ? WXK_NUMPAD_ENTER : WXK_RETURN; + id = ChooseNormalOrExtended(lParam, WXK_RETURN, WXK_NUMPAD_ENTER); break; default: