]>
git.saurik.com Git - wxWidgets.git/blob - src/osx/stattext_osx.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/stattext.cpp
3 // Purpose: wxStaticText
4 // Author: Stefan Csomor
7 // RCS-ID: $Id: stattext.cpp 54845 2008-07-30 14:52:41Z SC $
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
16 #include "wx/stattext.h"
22 #include "wx/dcclient.h"
23 #include "wx/settings.h"
26 #include "wx/osx/private.h"
30 IMPLEMENT_DYNAMIC_CLASS(wxStaticText
, wxControl
)
33 bool wxStaticText::Create( wxWindow
*parent
,
35 const wxString
& label
,
39 const wxString
& name
)
41 m_macIsUserPane
= false;
43 if ( !wxControl::Create( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
46 m_peer
= wxWidgetImpl::CreateStaticText( this, parent
, id
, label
, pos
, size
, style
, GetExtraStyle() );
48 MacPostControlCreate( pos
, size
);
55 void wxStaticText::SetLabel(const wxString
& label
)
59 // middle/end ellipsization is handled by the OS:
60 if ( HasFlag(wxST_ELLIPSIZE_END
) || HasFlag(wxST_ELLIPSIZE_MIDDLE
)
61 #if wxOSX_USE_COCOA // Cocoa has all three modes
62 || HasFlag(wxST_ELLIPSIZE_START
)
68 if (HasFlag(wxST_MARKUP
))
69 str
= RemoveMarkup(label
);
71 // and leave ellipsization to the OS
74 else // not supported natively
76 DoSetLabel(GetEllipsizedLabelWithoutMarkup());
79 if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE
) &&
80 !IsEllipsized() ) // don't resize if we adjust to current size
83 SetSize( GetBestSize() );
88 // we shouldn't need forced updates
92 bool wxStaticText::SetFont(const wxFont
& font
)
94 bool ret
= wxControl::SetFont( font
);
98 if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE
) )
100 InvalidateBestSize();
101 SetSize( GetBestSize() );
108 void wxStaticText::DoSetLabel(const wxString
& label
)
111 m_label
= RemoveMnemonics(label
);
112 m_peer
->SetLabel(m_label
, GetFont().GetEncoding() );
115 wxString
wxStaticText::DoGetLabel() const
121 FIXME: UpdateLabel() should be called on size events when wxST_ELLIPSIZE_START is set
122 to allow correct dynamic ellipsizing of the label
125 #endif //if wxUSE_STATTEXT