+    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 ) )
+    {
+        wxSize def = GetDefaultSize();
+        int margin =  highlight * 2 +
+            ( defThickness ? ( shadow * 4 + defThickness * 4 ) : 0 );
+        def.x += margin;
+        def.y += margin;
+
+        if( def.x > best.x )
+            best.x = def.x;
+        if( def.y > best.y )
+            best.y = def.y;
+    }
+
+    return best;