- // 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 ())
+ // 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 (wxWindowList::Node * node = parent->GetChildren().GetFirst ();
+ node; node = node->GetNext ())
+ {
+ wxWindow *win = node->GetData ();
+ wxButton *item = wxDynamicCast(win, wxButton);
+ if (item)
+ item->SetDefaultShadowThicknessAndResize();
+ }
+
+ XtVaSetValues ((Widget) parent->GetMainWidget(),
+ XmNdefaultButton, (Widget) GetMainWidget(),
+ NULL);
+}
+
+/* static */
+wxSize wxButton::GetDefaultSize()
+{
+ // TODO: check font size as in wxMSW ? MB
+ // Note: this is the button size (text + margin + shadow + defaultBorder)
+ return wxSize(78,30);
+}
+
+wxSize wxButton::DoGetBestSize() 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 ) )