- wxWindow *parent = (wxWindow *)GetParent();
- if (parent)
- parent->SetDefaultItem(this);
-
- // We initially do not set XmNdefaultShadowThickness, to have small buttons.
- // Unfortunately, buttons are now mis-aligned. We try to correct this
- // now -- setting this ressource to 1 for each button in the same row.
- // Because it's very hard to find wxButton in the same row,
- // correction is straighforward: we set resource for all wxButton
- // in this parent (but not sub panels)
- for (wxNode * node = parent->GetChildren ()->First (); node; node = node->Next ())
+ if( wxMotifLargeButtons() )
+ return OldGetBestSize();
+
+ wxSize best = wxControl::DoGetBestSize();
+
+ if( HasFlag( wxBU_EXACTFIT ) )
+ return best;
+ else if( best.x < MIN_WIDTH )
+ best.x = MIN_WIDTH;
+
+ return best;
+}
+
+wxSize wxButton::GetMinSize() const
+{
+ if( wxMotifLargeButtons() )
+ return OldGetMinSize();
+
+ return DoGetBestSize();
+}
+
+wxSize wxButton::OldGetMinSize() const
+{
+ return OldGetBestSize();
+}
+
+wxSize wxButton::OldGetBestSize() const
+{
+ Dimension xmargin, ymargin, highlight, shadow, defThickness;
+
+ XtVaGetValues( (Widget)m_mainWidget,
+ XmNmarginWidth, &xmargin,
+ XmNmarginHeight, &ymargin,
+ XmNhighlightThickness, &highlight,
+ XmNshadowThickness, &shadow,
+ XmNdefaultButtonShadowThickness, &defThickness,
+ NULL );
+
+ int x = 0; int y = 0;
+ GetTextExtent( GetLabel(), &x, &y );
+
+ int margin = highlight * 2 +
+ ( defThickness ? ( ( shadow + defThickness ) * 4 ) : ( shadow * 2 ) );
+
+ wxSize best( x + xmargin * 2 + margin,
+ y + ymargin * 2 + margin );
+
+ // 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 ) )