X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d5c21b02b520e862d0daf8667eca0b568b639be7..119a78753d60ee80d2a95323d66bb1c7f2cc0b6b:/src/msw/window.cpp diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 1bc66a85eb..4522e1bfc2 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -829,7 +829,7 @@ void wxWindowMSW::MSWUpdateUIState(int action, int state) if ( s_needToUpdate == -1 ) { int verMaj, verMin; - s_needToUpdate = wxGetOsVersion(&verMaj, &verMin) == wxWINDOWS_NT && + s_needToUpdate = wxGetOsVersion(&verMaj, &verMin) == wxOS_WINDOWS_NT && verMaj >= 5; } @@ -1567,6 +1567,7 @@ bool wxWindowMSW::IsSizeDeferred() const // Get total size void wxWindowMSW::DoGetSize(int *x, int *y) const { +#if USE_DEFERRED_SIZING // if SetSize() had been called at wx level but not realized at Windows // level yet (i.e. EndDeferWindowPos() not called), we still should return // the new and not the old position to the other wx code @@ -1578,6 +1579,7 @@ void wxWindowMSW::DoGetSize(int *x, int *y) const *y = m_pendingSize.y; } else // use current size +#endif // USE_DEFERRED_SIZING { RECT rect = wxGetWindowRect(GetHwnd()); @@ -1592,21 +1594,9 @@ void wxWindowMSW::DoGetSize(int *x, int *y) const void wxWindowMSW::DoGetClientSize(int *x, int *y) const { #if USE_DEFERRED_SIZING - if ( IsTopLevel() || m_pendingSize == wxDefaultSize ) -#endif - { // top level windows resizing is never deferred, so we can safely use - // the current size here - RECT rect = wxGetClientRect(GetHwnd()); - - if ( x ) - *x = rect.right; - if ( y ) - *y = rect.bottom; - } -#if USE_DEFERRED_SIZING - else // non top level and using deferred sizing + if ( m_pendingSize != wxDefaultSize ) { - // we need to calculate the *pending* client size here + // we need to calculate the client size corresponding to pending size RECT rect; rect.left = m_pendingPosition.x; rect.top = m_pendingPosition.y; @@ -1620,7 +1610,16 @@ void wxWindowMSW::DoGetClientSize(int *x, int *y) const if ( y ) *y = rect.bottom - rect.top; } -#endif + else +#endif // USE_DEFERRED_SIZING + { + RECT rect = wxGetClientRect(GetHwnd()); + + if ( x ) + *x = rect.right; + if ( y ) + *y = rect.bottom; + } } void wxWindowMSW::DoGetPosition(int *x, int *y) const @@ -2057,18 +2056,14 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg) // WM_GETDLGCODE: 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) - LONG lDlgCode = 0; - if ( !bCtrlDown ) - { - lDlgCode = ::SendMessage(msg->hwnd, WM_GETDLGCODE, 0, 0); + LONG lDlgCode = ::SendMessage(msg->hwnd, WM_GETDLGCODE, 0, 0); - // surprizingly, DLGC_WANTALLKEYS bit mask doesn't contain the - // DLGC_WANTTAB nor DLGC_WANTARROWS bits although, logically, - // it, of course, implies them - if ( lDlgCode & DLGC_WANTALLKEYS ) - { - lDlgCode |= DLGC_WANTTAB | DLGC_WANTARROWS; - } + // surprizingly, DLGC_WANTALLKEYS bit mask doesn't contain the + // DLGC_WANTTAB nor DLGC_WANTARROWS bits although, logically, + // it, of course, implies them + if ( lDlgCode & DLGC_WANTALLKEYS ) + { + lDlgCode |= DLGC_WANTTAB | DLGC_WANTARROWS; } bool bForward = true, @@ -2105,18 +2100,34 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg) bProcess = false; break; + case VK_PRIOR: + bForward = false; + // fall through + + case VK_NEXT: + // we treat PageUp/Dn as arrows because chances are that + // a control which needs arrows also needs them for + // navigation (e.g. wxTextCtrl, wxListCtrl, ...) + if ( (lDlgCode & DLGC_WANTARROWS) || !bCtrlDown ) + bProcess = false; + else + bWindowChange = true; + break; + case VK_RETURN: { if ( (lDlgCode & DLGC_WANTMESSAGE) && !bCtrlDown ) { // control wants to process Enter itself, don't - // call IsDialogMessage() which would interpret - // it + // call IsDialogMessage() which would consume it return false; } +#if wxUSE_BUTTON // currently active button should get enter press even - // if there is a default button elsewhere + // if there is a default button elsewhere so check if + // this window is a button first + wxWindow *btn = NULL; if ( lDlgCode & DLGC_DEFPUSHBUTTON ) { // let IsDialogMessage() handle this for all @@ -2126,56 +2137,38 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg) if ( (style & BS_OWNERDRAW) == BS_OWNERDRAW ) { // emulate the button click - wxWindow * - btn = wxFindWinFromHandle((WXHWND)msg->hwnd); - if ( btn ) - btn->MSWCommand(BN_CLICKED, 0 /* unused */); + btn = wxFindWinFromHandle((WXHWND)msg->hwnd); } bProcess = false; } - else // not a button itself + else // not a button itself, do we have default button? { -#if wxUSE_BUTTON - wxButton *btn = wxDynamicCast(GetDefaultItem(), - wxButton); - if ( btn && btn->IsEnabled() ) + wxTopLevelWindow * + tlw = wxDynamicCast(wxGetTopLevelParent(this), + wxTopLevelWindow); + if ( tlw ) { - // if we do have a default button, do press it - btn->MSWCommand(BN_CLICKED, 0 /* unused */); - - return true; + btn = wxDynamicCast(tlw->GetDefaultItem(), + wxButton); } - else // no default button + } + + if ( btn && btn->IsEnabled() ) + { + btn->MSWCommand(BN_CLICKED, 0 /* unused */); + return true; + } + #endif // wxUSE_BUTTON - { + #ifdef __WXWINCE__ - wxJoystickEvent event(wxEVT_JOY_BUTTON_DOWN); - event.SetEventObject(this); - if(GetEventHandler()->ProcessEvent(event)) - return true; -#endif - // this is a quick and dirty test for a text - // control - if ( !(lDlgCode & DLGC_HASSETSEL) ) - { - // don't process Enter, the control might - // need it for itself and don't let - // ::IsDialogMessage() have it as it can - // eat the Enter events sometimes - return false; - } - else if (!IsTopLevel()) - { - // if not a top level window, let parent - // handle it - return false; - } - //else: treat Enter as TAB: pass to the next - // control as this is the best thing to do - // if the text doesn't handle Enter itself - } - } + // map Enter presses into button presses on PDAs + wxJoystickEvent event(wxEVT_JOY_BUTTON_DOWN); + event.SetEventObject(this); + if ( GetEventHandler()->ProcessEvent(event) ) + return true; +#endif // __WXWINCE__ } break; @@ -4095,9 +4088,13 @@ bool wxWindowMSW::HandlePaletteChanged(WXHWND hWndPalChange) bool wxWindowMSW::HandleCaptureChanged(WXHWND hWndGainedCapture) { - wxMouseCaptureChangedEvent event(GetId(), wxFindWinFromHandle(hWndGainedCapture)); - event.SetEventObject(this); + // notify windows on the capture stack about lost capture + // (see http://sourceforge.net/tracker/index.php?func=detail&aid=1153662&group_id=9863&atid=109863): + wxWindowBase::NotifyCaptureLost(); + wxWindow *win = wxFindWinFromHandle(hWndGainedCapture); + wxMouseCaptureChangedEvent event(GetId(), win); + event.SetEventObject(this); return GetEventHandler()->ProcessEvent(event); } @@ -4400,37 +4397,11 @@ WXHBRUSH wxWindowMSW::MSWGetBgBrush(WXHDC hDC, WXHWND hWndToPaint) return 0; } -bool wxWindowMSW::HandlePrintClient(WXHDC hDC) +bool wxWindowMSW::HandlePrintClient(WXHDC WXUNUSED(hDC)) { - // we receive this message when DrawThemeParentBackground() is - // called from def window proc of several controls under XP and we - // must draw properly themed background here - // - // note that naively I'd expect filling the client rect with the - // brush returned by MSWGetBgBrush() work -- but for some reason it - // doesn't and we have to call parents MSWPrintChild() which is - // supposed to call DrawThemeBackground() with appropriate params - // - // also note that in this case lParam == PRF_CLIENT but we're - // clearly expected to paint the background and nothing else! - - if ( IsTopLevel() || InheritsBackgroundColour() ) - return false; - - // sometimes we don't want the parent to handle it at all, instead - // return whatever value this window wants - if ( !MSWShouldPropagatePrintChild() ) - return MSWPrintChild(hDC, (wxWindow *)this); - - for ( wxWindow *win = GetParent(); win; win = win->GetParent() ) - { - if ( win->MSWPrintChild(hDC, (wxWindow *)this) ) - return true; - - if ( win->IsTopLevel() || win->InheritsBackgroundColour() ) - break; - } - + // TODO: handle wxBG_STYLE_CUSTOM and/or wxBG_STYLE_COLOUR here so when + // DrawParentThemeBackground() from uxtheme.dll is called we don't get + // the default background e.g. the border when custom drawing buttons return false; } @@ -5406,7 +5377,8 @@ static const struct wxKeyMapping { VK_SELECT, WXK_SELECT }, { VK_PRINT, WXK_PRINT }, { VK_EXECUTE, WXK_EXECUTE }, - { VK_HELP , WXK_HELP }, + { VK_SNAPSHOT, WXK_SNAPSHOT }, + { VK_HELP, WXK_HELP }, { VK_NUMPAD0, WXK_NUMPAD0 }, { VK_NUMPAD1, WXK_NUMPAD1 }, @@ -5558,16 +5530,55 @@ WXWORD wxCharCodeWXToMSW(int wxk, bool *isVirtual) WXWORD vk; switch ( wxk ) { - case WXK_PAGEUP: vk = VK_PRIOR; break; - case WXK_PAGEDOWN: vk = VK_NEXT; break; - case WXK_END: vk = VK_END; break; - case WXK_HOME : vk = VK_HOME; break; - case WXK_LEFT : vk = VK_LEFT; break; - case WXK_UP: vk = VK_UP; break; - case WXK_RIGHT: vk = VK_RIGHT; break; - case WXK_DOWN : vk = VK_DOWN; break; - case WXK_INSERT: vk = VK_INSERT; break; - case WXK_DELETE: vk = VK_DELETE; break; + case WXK_PAGEUP: + case WXK_NUMPAD_PAGEUP: + vk = VK_PRIOR; + break; + + case WXK_PAGEDOWN: + case WXK_NUMPAD_PAGEDOWN: + vk = VK_NEXT; + break; + + case WXK_END: + case WXK_NUMPAD_END: + vk = VK_END; + break; + + case WXK_HOME: + case WXK_NUMPAD_HOME: + vk = VK_HOME; + break; + + case WXK_LEFT: + case WXK_NUMPAD_LEFT: + vk = VK_LEFT; + break; + + case WXK_UP: + case WXK_NUMPAD_UP: + vk = VK_UP; + break; + + case WXK_RIGHT: + case WXK_NUMPAD_RIGHT: + vk = VK_RIGHT; + break; + + case WXK_DOWN: + case WXK_NUMPAD_DOWN: + vk = VK_DOWN; + break; + + case WXK_INSERT: + case WXK_NUMPAD_INSERT: + vk = VK_INSERT; + break; + + case WXK_DELETE: + case WXK_NUMPAD_DELETE: + vk = VK_DELETE; + break; default: if ( isVirtual )