]> git.saurik.com Git - wxWidgets.git/blob - src/osx/stattext_osx.cpp
Fixed wxPropertyGridManager::CreatePropertyGrid(), corrected documentation about...
[wxWidgets.git] / src / osx / stattext_osx.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/stattext.cpp
3 // Purpose: wxStaticText
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id: stattext.cpp 54845 2008-07-30 14:52:41Z SC $
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #if wxUSE_STATTEXT
15
16 #include "wx/stattext.h"
17
18 #ifndef WX_PRECOMP
19 #include "wx/app.h"
20 #include "wx/utils.h"
21 #include "wx/dc.h"
22 #include "wx/dcclient.h"
23 #include "wx/settings.h"
24 #endif // WX_PRECOMP
25
26 #include "wx/osx/private.h"
27
28 #include <stdio.h>
29
30 IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
31
32
33 bool wxStaticText::Create( wxWindow *parent,
34 wxWindowID id,
35 const wxString& label,
36 const wxPoint& pos,
37 const wxSize& size,
38 long style,
39 const wxString& name )
40 {
41 m_macIsUserPane = false;
42
43 if ( !wxControl::Create( parent, id, pos, size, style, wxDefaultValidator, name ) )
44 return false;
45
46 m_peer = wxWidgetImpl::CreateStaticText( this, parent, id, label, pos, size, style, GetExtraStyle() );
47
48 MacPostControlCreate( pos, size );
49
50 SetLabel(label);
51
52 return true;
53 }
54
55 void wxStaticText::SetLabel(const wxString& label)
56 {
57 m_labelOrig = label;
58
59 // middle/end ellipsization is handled by the OS:
60 if ( HasFlag(wxST_ELLIPSIZE_END) || HasFlag(wxST_ELLIPSIZE_MIDDLE) )
61 {
62 // remove markup
63 wxString str(label);
64 if (HasFlag(wxST_MARKUP))
65 str = RemoveMarkup(label);
66
67 // and leave ellipsization to the OS
68 DoSetLabel(str);
69 }
70 else // not supported natively
71 {
72 DoSetLabel(GetEllipsizedLabelWithoutMarkup());
73 }
74
75 if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) &&
76 !IsEllipsized() ) // don't resize if we adjust to current size
77 {
78 InvalidateBestSize();
79 SetSize( GetBestSize() );
80 }
81
82 Refresh();
83
84 // we shouldn't need forced updates
85 // Update();
86 }
87
88 bool wxStaticText::SetFont(const wxFont& font)
89 {
90 bool ret = wxControl::SetFont( font );
91
92 if ( ret )
93 {
94 if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
95 {
96 InvalidateBestSize();
97 SetSize( GetBestSize() );
98 }
99 }
100
101 return ret;
102 }
103
104 void wxStaticText::DoSetLabel(const wxString& label)
105 {
106 m_labelOrig = label;
107 m_label = RemoveMnemonics(label);
108 m_peer->SetLabel(m_label , GetFont().GetEncoding() );
109 }
110
111 wxString wxStaticText::DoGetLabel() const
112 {
113 return m_label;
114 }
115
116 /*
117 FIXME: UpdateLabel() should be called on size events when wxST_ELLIPSIZE_START is set
118 to allow correct dynamic ellipsizing of the label
119 */
120
121 #endif //if wxUSE_STATTEXT