]>
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
)
66 // leave ellipsization to the OS
67 DoSetLabel(GetLabelWithoutMarkup());
69 else // not supported natively
71 DoSetLabel(GetEllipsizedLabelWithoutMarkup());
74 if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE
) &&
75 !IsEllipsized() ) // don't resize if we adjust to current size
78 SetSize( GetBestSize() );
83 // we shouldn't need forced updates
87 bool wxStaticText::SetFont(const wxFont
& font
)
89 bool ret
= wxControl::SetFont( font
);
93 if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE
) )
96 SetSize( GetBestSize() );
103 void wxStaticText::DoSetLabel(const wxString
& label
)
105 m_label
= RemoveMnemonics(label
);
106 m_peer
->SetLabel(m_label
, GetFont().GetEncoding() );
109 wxString
wxStaticText::DoGetLabel() const
115 FIXME: UpdateLabel() should be called on size events when wxST_ELLIPSIZE_START is set
116 to allow correct dynamic ellipsizing of the label
119 #endif //if wxUSE_STATTEXT