#ifndef WX_PRECOMP
#include "wx/panel.h"
#include "wx/toplevel.h"
+ #include "wx/dcclient.h"
#endif
#include "wx/stockitem.h"
if ( !wxButtonBase::Create(parent, id, pos, size, style, validator, name) )
return false;
- m_label = label ;
+ m_labelOrig = m_label = label ;
OSStatus err;
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
}
else if ( label.Find('\n' ) == wxNOT_FOUND && label.Find('\r' ) == wxNOT_FOUND)
{
-#if TARGET_API_MAC_OSX
// Button height is static in Mac, can't be changed, so we need to force it here
if ( GetWindowVariant() == wxWINDOW_VARIANT_NORMAL || GetWindowVariant() == wxWINDOW_VARIANT_LARGE )
{
bounds.bottom = bounds.top + 15 ;
m_maxHeight = 15 ;
}
-#endif
-
err = CreatePushButtonControl(
MAC_WXHWND(parent->MacGetTopLevelWindowRef()),
&bounds, CFSTR(""), m_peer->GetControlRefAddr() );
return wxSize( 20 , 20 ) ;
wxSize sz = GetDefaultSize() ;
- int charspace = 8 ;
switch (GetWindowVariant())
{
case wxWINDOW_VARIANT_NORMAL:
case wxWINDOW_VARIANT_LARGE:
sz.y = 20 ;
- charspace = 10 ;
break;
case wxWINDOW_VARIANT_SMALL:
m_peer->GetBestRect( &bestsize ) ;
int wBtn;
- if ( EmptyRect( &bestsize ) )
+ if ( EmptyRect( &bestsize ) || ( GetWindowStyle() & wxBU_EXACTFIT) )
{
- wBtn = m_label.length() * charspace + 12 ;
+ Point bounds;
+
+ ControlFontStyleRec controlFont;
+ OSStatus err = m_peer->GetData<ControlFontStyleRec>( kControlEntireControl, kControlFontStyleTag, &controlFont );
+ verify_noerr( err );
+
+ SInt16 baseline;
+ wxMacCFStringHolder str( m_label, m_font.GetEncoding() );
+
+#ifndef __LP64__
+ if ( m_font.MacGetThemeFontID() != kThemeCurrentPortFont )
+ {
+ err = GetThemeTextDimensions(
+ (!m_label.empty() ? (CFStringRef)str : CFSTR(" ")),
+ m_font.MacGetThemeFontID(), kThemeStateActive, false, &bounds, &baseline );
+ verify_noerr( err );
+ }
+ else
+#endif
+ {
+ wxClientDC dc(const_cast<wxButton*>(this));
+ wxCoord width, height ;
+ dc.GetTextExtent( m_label , &width, &height);
+ bounds.h = width;
+ bounds.v = height;
+ }
+
+ wBtn = bounds.h + sz.y;
}
else
{
wBtn = bestsize.right - bestsize.left ;
- sz.y = bestsize.bottom - bestsize.top ;
+ // non 'normal' window variants don't return the correct height
+ // sz.y = bestsize.bottom - bestsize.top ;
}
if ((wBtn > sz.x) || ( GetWindowStyle() & wxBU_EXACTFIT))