]>
git.saurik.com Git - wxWidgets.git/blob - src/osx/stattext_osx.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/stattext_osx.cpp
3 // Purpose: wxStaticText
4 // Author: Stefan Csomor
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"
31 bool wxStaticText::Create( wxWindow
*parent
,
33 const wxString
& label
,
37 const wxString
& name
)
41 if ( !wxControl::Create( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
44 SetPeer(wxWidgetImpl::CreateStaticText( this, parent
, id
, label
, pos
, size
, style
, GetExtraStyle() ));
46 MacPostControlCreate( pos
, size
);
49 if ( HasFlag(wxST_NO_AUTORESIZE
) )
51 // Normally this is done in SetLabel() below but we avoid doing it when
52 // this style is used, so we need to explicitly do it in the ctor in
53 // this case or otherwise the control would retain its initial tiny size.
61 void wxStaticText::SetLabel(const wxString
& label
)
65 // middle/end ellipsization is handled by the OS:
66 if ( HasFlag(wxST_ELLIPSIZE_END
) || HasFlag(wxST_ELLIPSIZE_MIDDLE
)
67 #if wxOSX_USE_COCOA // Cocoa has all three modes
68 || HasFlag(wxST_ELLIPSIZE_START
)
72 // leave ellipsization to the OS
73 DoSetLabel(GetLabel());
75 else // not supported natively
77 DoSetLabel(GetEllipsizedLabel());
80 if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE
) &&
81 !IsEllipsized() ) // don't resize if we adjust to current size
84 SetSize( GetBestSize() );
89 // we shouldn't need forced updates
93 bool wxStaticText::SetFont(const wxFont
& font
)
95 bool ret
= wxControl::SetFont( font
);
99 if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE
) )
101 InvalidateBestSize();
102 SetSize( GetBestSize() );
109 void wxStaticText::DoSetLabel(const wxString
& label
)
111 m_label
= RemoveMnemonics(label
);
112 GetPeer()->SetLabel(m_label
, GetFont().GetEncoding() );
115 #if wxUSE_MARKUP && wxOSX_USE_COCOA
117 bool wxStaticText::DoSetLabelMarkup(const wxString
& markup
)
119 if ( !wxStaticTextBase::DoSetLabelMarkup(markup
) )
122 GetPeer()->SetLabelMarkup(markup
);
127 #endif // wxUSE_MARKUP && wxOSX_USE_COCOA
129 wxString
wxStaticText::DoGetLabel() const
135 FIXME: UpdateLabel() should be called on size events when wxST_ELLIPSIZE_START is set
136 to allow correct dynamic ellipsizing of the label
139 #endif //if wxUSE_STATTEXT