]>
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
)
39 m_macIsUserPane
= false;
41 if ( !wxControl::Create( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
44 m_peer
= 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(GetLabelWithoutMarkup());
67 else // not supported natively
69 DoSetLabel(GetEllipsizedLabelWithoutMarkup());
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 m_peer
->SetLabel(m_label
, GetFont().GetEncoding() );
107 wxString
wxStaticText::DoGetLabel() const
113 FIXME: UpdateLabel() should be called on size events when wxST_ELLIPSIZE_START is set
114 to allow correct dynamic ellipsizing of the label
117 #endif //if wxUSE_STATTEXT