]>
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
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
);
53 void wxStaticText::SetLabel(const wxString
& label
)
57 // middle/end ellipsization is handled by the OS:
58 if ( HasFlag(wxST_ELLIPSIZE_END
) || HasFlag(wxST_ELLIPSIZE_MIDDLE
)
59 #if wxOSX_USE_COCOA // Cocoa has all three modes
60 || HasFlag(wxST_ELLIPSIZE_START
)
64 // leave ellipsization to the OS
65 DoSetLabel(GetLabel());
67 else // not supported natively
69 DoSetLabel(GetEllipsizedLabel());
72 if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE
) &&
73 !IsEllipsized() ) // don't resize if we adjust to current size
76 SetSize( GetBestSize() );
81 // we shouldn't need forced updates
85 bool wxStaticText::SetFont(const wxFont
& font
)
87 bool ret
= wxControl::SetFont( font
);
91 if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE
) )
94 SetSize( GetBestSize() );
101 void wxStaticText::DoSetLabel(const wxString
& label
)
103 m_label
= RemoveMnemonics(label
);
104 GetPeer()->SetLabel(m_label
, GetFont().GetEncoding() );
107 #if wxUSE_MARKUP && wxOSX_USE_COCOA
109 bool wxStaticText::DoSetLabelMarkup(const wxString
& markup
)
111 if ( !wxStaticTextBase::DoSetLabelMarkup(markup
) )
114 GetPeer()->SetLabelMarkup(markup
);
119 #endif // wxUSE_MARKUP && wxOSX_USE_COCOA
121 wxString
wxStaticText::DoGetLabel() const
127 FIXME: UpdateLabel() should be called on size events when wxST_ELLIPSIZE_START is set
128 to allow correct dynamic ellipsizing of the label
131 #endif //if wxUSE_STATTEXT