fixed a harmless warning (patch 595096) and added a comment

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16519 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2002-08-15 17:47:13 +00:00
parent 2fca5a0004
commit 1e023926ec

View File

@ -134,29 +134,33 @@ WXDWORD wxButton::MSWGetStyle(long style, WXDWORD *exstyle) const
wxSize wxButton::DoGetBestSize() const
{
wxString label = wxGetWindowText(GetHWND());
int wBtn;
GetTextExtent(label, &wBtn, NULL);
GetTextExtent(wxGetWindowText(GetHWND()), &wBtn, NULL);
int wChar, hChar;
wxGetCharSize(GetHWND(), &wChar, &hChar, &GetFont());
// add a margin - the button is wider than just its label
// add a margin -- the button is wider than just its label
wBtn += 3*wChar;
// the button height is proportional to the height of the font used
int hBtn = BUTTON_HEIGHT_FROM_CHAR_HEIGHT(hChar);
if (!HasFlag(wxBU_EXACTFIT))
// all buttons have at least the standard size unless the user explicitly
// wants them to be of smaller size and used wxBU_EXACTFIT style when
// creating the button
if ( !HasFlag(wxBU_EXACTFIT) )
{
wxSize sz = GetDefaultSize();
if (wBtn > sz.x) sz.x = wBtn;
if (hBtn > sz.y) sz.y = hBtn;
if (wBtn > sz.x)
sz.x = wBtn;
if (hBtn > sz.y)
sz.y = hBtn;
return sz;
}
else
return wxSize(wBtn, hBtn);
return wxSize(wBtn, hBtn);
}
/* static */