@style{wxBU_BOTTOM}
Aligns the label to the bottom of the button. Windows and GTK+ only.
@style{wxBU_EXACTFIT}
- Creates the button as small as possible instead of making it of the
- standard size (which is the default behaviour ).
+ By default, all buttons are made of at least the standard button size,
+ even if their contents is small enough to fit into a smaller size. This
+ is done for consistency as most platforms use buttons of the same size
+ in the native dialogs, but can be overridden by specifying this flag.
+ If it is given, the button will be made just big enough for its
+ contents. Notice that under MSW the button will still have at least the
+ standard height, even with this style, if it has a non-empty label.
@style{wxBU_NOTEXT}
Disables the display of the text label in the button even if it has one
or its id is one of the standard stock ids with an associated label:
{
wxSize sizeBtn(size);
- // All buttons have at least the standard height and, unless the user
- // explicitly wants them to be as small as possible and used wxBU_EXACTFIT
- // style to indicate this, of at least the standard width too.
- //
- // Notice that we really want to make all buttons equally high, otherwise
- // they look ugly and the existing code using wxBU_EXACTFIT only uses it to
- // control width and not height.
-
// The 50x14 button size is documented in the "Recommended sizing and
// spacing" section of MSDN layout article.
//
// Note that we intentionally don't use GetDefaultSize() here, because
// it's inexact -- dialog units depend on this dialog's font.
const wxSize sizeDef = btn->ConvertDialogToPixels(wxSize(50, 14));
- if ( !btn->HasFlag(wxBU_EXACTFIT) )
+
+ // All buttons should have at least the standard size, unless the user
+ // explicitly wants them to be as small as possible and used wxBU_EXACTFIT
+ // style to indicate this.
+ const bool incToStdSize = !btn->HasFlag(wxBU_EXACTFIT);
+ if ( incToStdSize )
{
if ( sizeBtn.x < sizeDef.x )
sizeBtn.x = sizeDef.x;
}
- if ( sizeBtn.y < sizeDef.y )
- sizeBtn.y = sizeDef.y;
+
+ // Notice that we really want to make all buttons with text label equally
+ // high, otherwise they look ugly and the existing code using wxBU_EXACTFIT
+ // only uses it to control width and not height.
+ if ( incToStdSize || !btn->GetLabel().empty() )
+ {
+ if ( sizeBtn.y < sizeDef.y )
+ sizeBtn.y = sizeDef.y;
+ }
btn->CacheBestSize(sizeBtn);