X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cd0b170911637899ac3c126367ee5821f357c185..37b8e6798782278fdfe4f3c1291aaff55cdbb8c9:/src/msw/button.cpp diff --git a/src/msw/button.cpp b/src/msw/button.cpp index e913563260..a7df197b6c 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -198,17 +198,26 @@ void wxButton::SetDefault() // don't do it with the owner drawn buttons because it will reset // BS_OWNERDRAW style bit too (BS_OWNERDRAW & BS_DEFPUSHBUTTON != 0)! - if ( !(style & BS_OWNERDRAW) ) + if ( (style & BS_OWNERDRAW) != BS_OWNERDRAW ) { style &= ~BS_DEFPUSHBUTTON; SendMessage(GetHwndOf(btnOldDefault), BM_SETSTYLE, style, 1L); } + else + { + // redraw the button - it will notice itself that it's not the + // default one any longer + btnOldDefault->Refresh(); + } } // set this button as the default long style = GetWindowLong(GetHwnd(), GWL_STYLE); - style |= BS_DEFPUSHBUTTON; - SendMessage(GetHwnd(), BM_SETSTYLE, style, 1L); + if ( (style & BS_OWNERDRAW) != BS_OWNERDRAW ) + { + style |= BS_DEFPUSHBUTTON; + SendMessage(GetHwnd(), BM_SETSTYLE, style, 1L); + } } // ---------------------------------------------------------------------------- @@ -248,24 +257,13 @@ bool wxButton::MSWCommand(WXUINT param, WXWORD id) long wxButton::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { - // make sure that we won't have BS_DEFPUSHBUTTON style any more if the - // focus is being transfered to another button with the same parent - - // otherwise, we could finish with 2 default buttons inside one panel - if ( (nMsg == WM_KILLFOCUS) && - (GetWindowLong(GetHwnd(), GWL_STYLE) & BS_DEFPUSHBUTTON) ) + // when we receive focus, we want to become the default button in our + // parent panel + if ( nMsg == WM_SETFOCUS ) { - wxWindow *parent = GetParent(); - wxWindow *win = wxFindWinFromHandle((WXHWND)wParam); - if ( win && win->GetParent() == parent ) - { - wxPanel *panel = wxDynamicCast(parent, wxPanel); - if ( panel ) - { - panel->SetDefaultItem(this); - } - // else: I don't know what to do - we'll still have the problem - // with multiple default buttons in a dialog... - } + SetDefault(); + + // let the default processign take place too } // let the base class do all real processing @@ -307,7 +305,7 @@ static void DrawRect(HDC hdc, const RECT& r) void wxButton::MakeOwnerDrawn() { long style = GetWindowLong(GetHwnd(), GWL_STYLE); - if ( !(style & BS_OWNERDRAW) ) + if ( (style & BS_OWNERDRAW) != BS_OWNERDRAW ) { // make it so style |= BS_OWNERDRAW; @@ -477,23 +475,18 @@ bool wxButton::MSWOnDraw(WXDRAWITEMSTRUCT *wxdis) DrawFocusRect(hdc, &rectFocus); } + if ( pushed ) + { + // the label is shifted by 1 pixel to create "pushed" effect + OffsetRect(&rectBtn, 1, 1); + } + DrawButtonText(hdc, &rectBtn, GetLabel(), state & ODS_DISABLED ? GetSysColor(COLOR_GRAYTEXT) : colFg); ::DeleteObject(hbrushBackground); -#if 0 - wxString s = "button state: "; - if ( selected ) - s += "selected "; - if ( pushed ) - s += "pushed "; - if ( state & ODS_FOCUS ) - s += "focused "; - wxLogStatus(s); -#endif - return TRUE; }