X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/42440b08eadbc14cde1b1f7bffe268c69e5e12be..8a31648287be0ef976f133de2786b137f1e98340:/src/msw/anybutton.cpp?ds=inline diff --git a/src/msw/anybutton.cpp b/src/msw/anybutton.cpp index 2603cdfdf3..0e3da82ea3 100644 --- a/src/msw/anybutton.cpp +++ b/src/msw/anybutton.cpp @@ -387,11 +387,21 @@ wxSize wxMSWButton::GetFittingSize(wxWindow *win, const wxSize& sizeLabel, int flags) { - // FIXME: this is pure guesswork, need to retrieve the real button margins wxSize sizeBtn = sizeLabel; - sizeBtn.x += 3*win->GetCharWidth(); - sizeBtn.y += win->GetCharHeight()/2; + // FIXME: The numbers here are pure guesswork, no idea how should the + // button margins be really calculated. + if ( flags & Size_ExactFit ) + { + // We still need some margin or the text would be overwritten, just + // make it as small as possible. + sizeBtn.x += (3*win->GetCharWidth())/2; + } + else + { + sizeBtn.x += 3*win->GetCharWidth(); + sizeBtn.y += win->GetCharHeight()/2; + } // account for the shield UAC icon if we have it if ( flags & Size_AuthNeeded ) @@ -555,6 +565,8 @@ wxSize wxAnyButton::DoGetBestSize() const if ( ShowsLabel() ) { int flags = 0; + if ( HasFlag(wxBU_EXACTFIT) ) + flags |= wxMSWButton::Size_ExactFit; if ( DoGetAuthNeeded() ) flags |= wxMSWButton::Size_AuthNeeded; @@ -807,9 +819,9 @@ void DrawButtonText(HDC hdc, // now center this rect inside the entire button area const LONG w = rc.right - rc.left; const LONG h = rc.bottom - rc.top; - rc.left = (pRect->right - pRect->left)/2 - w/2; + rc.left = pRect->left + (pRect->right - pRect->left)/2 - w/2; rc.right = rc.left+w; - rc.top = (pRect->bottom - pRect->top)/2 - h/2; + rc.top = pRect->top + (pRect->bottom - pRect->top)/2 - h/2; rc.bottom = rc.top+h; ::DrawText(hdc, text.wx_str(), text.length(), &rc, flags);