supporting wxBU_EXACTFIT
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@48895 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -123,14 +123,12 @@ wxSize wxButton::DoGetBestSize() const
|
|||||||
return wxSize( 20 , 20 ) ;
|
return wxSize( 20 , 20 ) ;
|
||||||
|
|
||||||
wxSize sz = GetDefaultSize() ;
|
wxSize sz = GetDefaultSize() ;
|
||||||
int charspace = 8 ;
|
|
||||||
|
|
||||||
switch (GetWindowVariant())
|
switch (GetWindowVariant())
|
||||||
{
|
{
|
||||||
case wxWINDOW_VARIANT_NORMAL:
|
case wxWINDOW_VARIANT_NORMAL:
|
||||||
case wxWINDOW_VARIANT_LARGE:
|
case wxWINDOW_VARIANT_LARGE:
|
||||||
sz.y = 20 ;
|
sz.y = 20 ;
|
||||||
charspace = 10 ;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxWINDOW_VARIANT_SMALL:
|
case wxWINDOW_VARIANT_SMALL:
|
||||||
@@ -149,9 +147,48 @@ wxSize wxButton::DoGetBestSize() const
|
|||||||
m_peer->GetBestRect( &bestsize ) ;
|
m_peer->GetBestRect( &bestsize ) ;
|
||||||
|
|
||||||
int wBtn;
|
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
|
||||||
|
{
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
wxClientDC dc(const_cast<wxButton*>(this));
|
||||||
|
wxCoord width, height ;
|
||||||
|
dc.GetTextExtent( m_label , &width, &height);
|
||||||
|
bounds.h = width;
|
||||||
|
bounds.v = height;
|
||||||
|
#else
|
||||||
|
wxMacWindowStateSaver sv( this );
|
||||||
|
::TextFont( m_font.MacGetFontNum() );
|
||||||
|
::TextSize( (short)(m_font.MacGetFontSize()) );
|
||||||
|
::TextFace( m_font.MacGetFontStyle() );
|
||||||
|
|
||||||
|
err = GetThemeTextDimensions(
|
||||||
|
(!m_label.empty() ? (CFStringRef)str : CFSTR(" ")),
|
||||||
|
kThemeCurrentPortFont, kThemeStateActive, false, &bounds, &baseline );
|
||||||
|
verify_noerr( err );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
wBtn = bounds.h + sz.y;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user