1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxStaticText
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "stattext.h"
17 #include "wx/stattext.h"
18 #include "wx/notebook.h"
19 #include "wx/tabctrl.h"
21 #include "wx/dcclient.h"
23 #include "wx/settings.h"
27 #if !USE_SHARED_LIBRARY
28 IMPLEMENT_DYNAMIC_CLASS(wxStaticText
, wxControl
)
31 #include "wx/mac/uma.h"
33 bool wxStaticText::Create(wxWindow
*parent
, wxWindowID id
,
34 const wxString
& label
,
40 m_macIsUserPane
= FALSE
;
42 m_label
= wxStripMenuCodes(label
) ;
44 if ( !wxControl::Create( parent
, id
, pos
, size
, style
,
45 wxDefaultValidator
, name
) )
50 Rect bounds
= wxMacGetBoundsForControl( this , pos
, size
) ;
51 wxMacCFStringHolder
str(m_label
,m_font
.GetEncoding() ) ;
52 verify_noerr(CreateStaticTextControl(MAC_WXHWND(parent
->MacGetTopLevelWindowRef()),&bounds
, str
,
53 NULL
, (ControlRef
*)&m_macControl
) ) ;
55 MacPostControlCreate(pos
,size
) ;
60 wxSize
wxStaticText::DoGetBestSize() const
62 ControlFontStyleRec controlFont
;
64 verify_noerr( GetControlData( (ControlRef
) m_macControl
, kControlEntireControl
, kControlFontStyleTag
, sizeof(controlFont
) , &controlFont
, &outSize
) ) ;
68 wxMacCFStringHolder
str(m_label
, m_font
.GetEncoding() ) ;
69 if ( m_font
.MacGetThemeFontID() != kThemeCurrentPortFont
)
70 verify_noerr( GetThemeTextDimensions( (m_label
.Length() > 0 ? ((CFStringRef
) str
) : CFSTR(" ") ) , m_font
.MacGetThemeFontID() , kThemeStateActive
, false , &bounds
, &baseline
) ) ;
73 wxMacWindowStateSaver
sv( this ) ;
74 ::TextFont( m_font
.MacGetFontNum() ) ;
75 ::TextSize( (short)( m_font
.MacGetFontSize()) ) ;
76 ::TextFace( m_font
.MacGetFontStyle() ) ;
77 verify_noerr( GetThemeTextDimensions( (m_label
.Length() > 0 ? ((CFStringRef
) str
) : CFSTR(" ") ) , kThemeCurrentPortFont
, kThemeStateActive
, false , &bounds
, &baseline
) ) ;
79 if ( m_label
.Length() == 0 )
81 return wxSize(bounds
.h
, bounds
.v
);
84 void wxStaticText::SetLabel(const wxString
& st
)
87 m_label
= wxStripMenuCodes(st
) ;
89 wxMacCFStringHolder
str(m_label
,m_font
.GetEncoding() ) ;
90 CFStringRef ref
= str
;
91 SetControlData( (ControlRef
) m_macControl
, kControlEntireControl
, kControlStaticTextCFStringTag
, sizeof( CFStringRef
),
94 if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE
) )
95 SetSize( GetBestSize() ) ;
100 bool wxStaticText::SetFont(const wxFont
& font
)
102 bool ret
= wxControl::SetFont(font
);
106 if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE
) )
107 SetSize( GetBestSize() );