1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxStaticText
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "stattext.h"
16 #include "wx/wxprec.h"
19 #include "wx/stattext.h"
20 #include "wx/notebook.h"
21 #include "wx/tabctrl.h"
23 #include "wx/dcclient.h"
25 #include "wx/settings.h"
29 #if !USE_SHARED_LIBRARY
30 IMPLEMENT_DYNAMIC_CLASS(wxStaticText
, wxControl
)
33 #include "wx/mac/uma.h"
35 bool wxStaticText::Create(wxWindow
*parent
, wxWindowID id
,
36 const wxString
& label
,
42 m_macIsUserPane
= FALSE
;
44 m_label
= wxStripMenuCodes(label
) ;
46 if ( !wxControl::Create( parent
, id
, pos
, size
, style
,
47 wxDefaultValidator
, name
) )
52 Rect bounds
= wxMacGetBoundsForControl( this , pos
, size
) ;
53 wxMacCFStringHolder
str(m_label
,m_font
.GetEncoding() ) ;
54 m_peer
= new wxMacControl() ;
55 verify_noerr(CreateStaticTextControl(MAC_WXHWND(parent
->MacGetTopLevelWindowRef()),&bounds
, str
,
56 NULL
, m_peer
->GetControlRefAddr() ) ) ;
58 MacPostControlCreate(pos
,size
) ;
63 wxSize
wxStaticText::DoGetBestSize() const
65 ControlFontStyleRec controlFont
;
66 verify_noerr( m_peer
->GetData
<ControlFontStyleRec
>(kControlEntireControl
, kControlFontStyleTag
, &controlFont
) ) ;
70 wxMacCFStringHolder
str(m_label
, m_font
.GetEncoding() ) ;
71 if ( m_font
.MacGetThemeFontID() != kThemeCurrentPortFont
)
72 verify_noerr( GetThemeTextDimensions( (m_label
.Length() > 0 ? ((CFStringRef
) str
) : CFSTR(" ") ) , m_font
.MacGetThemeFontID() , kThemeStateActive
, false , &bounds
, &baseline
) ) ;
75 wxMacWindowStateSaver
sv( this ) ;
76 ::TextFont( m_font
.MacGetFontNum() ) ;
77 ::TextSize( (short)( m_font
.MacGetFontSize()) ) ;
78 ::TextFace( m_font
.MacGetFontStyle() ) ;
79 verify_noerr( GetThemeTextDimensions( (m_label
.Length() > 0 ? ((CFStringRef
) str
) : CFSTR(" ") ) , kThemeCurrentPortFont
, kThemeStateActive
, false , &bounds
, &baseline
) ) ;
81 if ( m_label
.Length() == 0 )
84 bounds
.h
+= MacGetLeftBorderSize() + MacGetRightBorderSize() ;
85 bounds
.v
+= MacGetTopBorderSize() + MacGetBottomBorderSize() ;
86 return wxSize(bounds
.h
, bounds
.v
);
89 void wxStaticText::SetLabel(const wxString
& st
)
92 m_label
= wxStripMenuCodes(st
) ;
94 wxMacCFStringHolder
str(m_label
,m_font
.GetEncoding() ) ;
95 CFStringRef ref
= str
;
96 verify_noerr( m_peer
->SetData
<CFStringRef
>(kControlEntireControl
, kControlStaticTextCFStringTag
, ref
) ) ;
98 if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE
) )
100 InvalidateBestSize();
101 SetSize( GetBestSize() ) ;
107 bool wxStaticText::SetFont(const wxFont
& font
)
109 bool ret
= wxControl::SetFont(font
);
113 if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE
) )
115 InvalidateBestSize();
116 SetSize( GetBestSize() );