]>
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
) )
64 if (HasFlag(wxST_MARKUP
))
65 str
= RemoveMarkup(label
);
67 // and leave ellipsization to the OS
70 else // not supported natively
72 DoSetLabel(GetEllipsizedLabelWithoutMarkup());
75 if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE
) &&
76 !IsEllipsized() ) // don't resize if we adjust to current size
79 SetSize( GetBestSize() );
84 // we shouldn't need forced updates
88 bool wxStaticText::SetFont(const wxFont
& font
)
90 bool ret
= wxControl::SetFont( font
);
94 if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE
) )
97 SetSize( GetBestSize() );
104 void wxStaticText::DoSetLabel(const wxString
& label
)
107 m_label
= RemoveMnemonics(label
);
108 m_peer
->SetLabel(m_label
, GetFont().GetEncoding() );
111 wxString
wxStaticText::DoGetLabel() const
117 FIXME: UpdateLabel() should be called on size events when wxST_ELLIPSIZE_START is set
118 to allow correct dynamic ellipsizing of the label
121 #endif //if wxUSE_STATTEXT