Make wxBU_EXACTFIT fir the button text more exactly.

Too big margins were added for the buttons with wxBU_EXACTFIT style making
them larger than strictly necessary. Reduce the margins to make them really
as small as possible.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68922 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2011-08-27 14:11:28 +00:00
parent 75bc8b3454
commit b18ebec956
2 changed files with 17 additions and 4 deletions

View File

@ -44,7 +44,8 @@ void UpdateMultilineStyle(HWND hwnd, const wxString& label);
// flags for ComputeBestSize() and GetFittingSize()
enum
{
Size_AuthNeeded = 1
Size_AuthNeeded = 1,
Size_ExactFit = 2
};
// NB: All the functions below are implemented in src/msw/button.cpp

View File

@ -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;