- Rect bounds ;
- Str255 title ;
-
- MacPreControlCreate( parent , id , label , pos , size ,style, *((wxValidator*)NULL) , name , &bounds , title ) ;
-
- m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1,
- kControlStaticTextProc , (long) this ) ;
- ::UMASetControlData( m_macControl, kControlLabelPart, kControlStaticTextTextTag , (long) title[0] , (char*) &title[1] ) ;
-
- MacPostControlCreate() ;
-
- return TRUE;
+ m_macIsUserPane = FALSE ;
+
+ m_label = wxStripMenuCodes(label) ;
+
+ if ( !wxControl::Create( parent, id, pos, size, style,
+ wxDefaultValidator , name ) )
+ {
+ return false;
+ }
+
+ Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
+ wxMacCFStringHolder str(m_label,m_font.GetEncoding() ) ;
+ m_peer = new wxMacControl(this) ;
+ verify_noerr(CreateStaticTextControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, str ,
+ NULL , m_peer->GetControlRefAddr() ) ) ;
+
+ MacPostControlCreate(pos,size) ;
+
+ return true;
+}
+
+wxSize wxStaticText::DoGetBestSize() const
+{
+ ControlFontStyleRec controlFont ;
+ verify_noerr( m_peer->GetData<ControlFontStyleRec>(kControlEntireControl , kControlFontStyleTag , &controlFont ) ) ;
+
+ Point bounds ;
+ SInt16 baseline ;
+ wxMacCFStringHolder str(m_label , m_font.GetEncoding() ) ;
+ if ( m_font.MacGetThemeFontID() != kThemeCurrentPortFont )
+ verify_noerr( GetThemeTextDimensions( (m_label.Length() > 0 ? ((CFStringRef) str ) : CFSTR(" ") ) , m_font.MacGetThemeFontID() , kThemeStateActive , false , &bounds , &baseline ) ) ;
+ else
+ {
+ wxMacWindowStateSaver sv( this ) ;
+ ::TextFont( m_font.MacGetFontNum() ) ;
+ ::TextSize( (short)( m_font.MacGetFontSize()) ) ;
+ ::TextFace( m_font.MacGetFontStyle() ) ;
+ verify_noerr( GetThemeTextDimensions( (m_label.Length() > 0 ? ((CFStringRef) str ) : CFSTR(" ") ) , kThemeCurrentPortFont , kThemeStateActive , false , &bounds , &baseline ) ) ;
+ }
+ if ( m_label.Length() == 0 )
+ bounds.h = 0 ;
+
+ bounds.h += MacGetLeftBorderSize() + MacGetRightBorderSize() ;
+ bounds.v += MacGetTopBorderSize() + MacGetBottomBorderSize() ;
+ return wxSize(bounds.h, bounds.v);