]>
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
7 // Copyright: (c) Stefan Csomor
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #include "wx/wxprec.h"
15 #include "wx/stattext.h"
21 #include "wx/dcclient.h"
22 #include "wx/settings.h"
25 #include "wx/osx/private.h"
30 bool wxStaticText::Create( wxWindow
*parent
,
32 const wxString
& label
,
36 const wxString
& name
)
40 if ( !wxControl::Create( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
43 SetPeer(wxWidgetImpl::CreateStaticText( this, parent
, id
, label
, pos
, size
, style
, GetExtraStyle() ));
45 MacPostControlCreate( pos
, size
);
48 if ( HasFlag(wxST_NO_AUTORESIZE
) )
50 // Normally this is done in SetLabel() below but we avoid doing it when
51 // this style is used, so we need to explicitly do it in the ctor in
52 // this case or otherwise the control would retain its initial tiny size.
60 void wxStaticText::SetLabel(const wxString
& label
)
64 // middle/end ellipsization is handled by the OS:
65 if ( HasFlag(wxST_ELLIPSIZE_END
) || HasFlag(wxST_ELLIPSIZE_MIDDLE
)
66 #if wxOSX_USE_COCOA // Cocoa has all three modes
67 || HasFlag(wxST_ELLIPSIZE_START
)
71 // leave ellipsization to the OS
72 DoSetLabel(GetLabel());
74 else // not supported natively
76 DoSetLabel(GetEllipsizedLabel());
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
)
110 m_label
= RemoveMnemonics(label
);
111 GetPeer()->SetLabel(m_label
, GetFont().GetEncoding() );
114 #if wxUSE_MARKUP && wxOSX_USE_COCOA
116 bool wxStaticText::DoSetLabelMarkup(const wxString
& markup
)
118 if ( !wxStaticTextBase::DoSetLabelMarkup(markup
) )
121 GetPeer()->SetLabelMarkup(markup
);
126 #endif // wxUSE_MARKUP && wxOSX_USE_COCOA
128 wxString
wxStaticText::DoGetLabel() const
134 FIXME: UpdateLabel() should be called on size events when wxST_ELLIPSIZE_START is set
135 to allow correct dynamic ellipsizing of the label
138 #endif //if wxUSE_STATTEXT