]>
Commit | Line | Data |
---|---|---|
e53b3d16 | 1 | ///////////////////////////////////////////////////////////////////////////// |
524c47aa | 2 | // Name: src/osx/carbon/stattext.cpp |
e53b3d16 SC |
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 | ||
e53b3d16 SC |
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: | |
03647350 | 60 | if ( HasFlag(wxST_ELLIPSIZE_END) || HasFlag(wxST_ELLIPSIZE_MIDDLE) |
f1c40652 | 61 | #if wxOSX_USE_COCOA // Cocoa has all three modes |
03647350 | 62 | || HasFlag(wxST_ELLIPSIZE_START) |
f1c40652 SC |
63 | #endif |
64 | ) | |
e53b3d16 SC |
65 | { |
66 | // remove markup | |
67 | wxString str(label); | |
68 | if (HasFlag(wxST_MARKUP)) | |
69 | str = RemoveMarkup(label); | |
70 | ||
71 | // and leave ellipsization to the OS | |
72 | DoSetLabel(str); | |
73 | } | |
74 | else // not supported natively | |
75 | { | |
76 | DoSetLabel(GetEllipsizedLabelWithoutMarkup()); | |
77 | } | |
78 | ||
79 | if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) && | |
80 | !IsEllipsized() ) // don't resize if we adjust to current size | |
81 | { | |
82 | InvalidateBestSize(); | |
83 | SetSize( GetBestSize() ); | |
84 | } | |
85 | ||
86 | Refresh(); | |
87 | ||
88 | // we shouldn't need forced updates | |
89 | // Update(); | |
90 | } | |
91 | ||
92 | bool wxStaticText::SetFont(const wxFont& font) | |
93 | { | |
94 | bool ret = wxControl::SetFont( font ); | |
95 | ||
96 | if ( ret ) | |
97 | { | |
98 | if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) ) | |
99 | { | |
100 | InvalidateBestSize(); | |
101 | SetSize( GetBestSize() ); | |
102 | } | |
103 | } | |
104 | ||
105 | return ret; | |
106 | } | |
107 | ||
108 | void wxStaticText::DoSetLabel(const wxString& label) | |
109 | { | |
110 | m_labelOrig = label; | |
111 | m_label = RemoveMnemonics(label); | |
112 | m_peer->SetLabel(m_label , GetFont().GetEncoding() ); | |
113 | } | |
114 | ||
115 | wxString wxStaticText::DoGetLabel() const | |
116 | { | |
117 | return m_label; | |
118 | } | |
119 | ||
120 | /* | |
121 | FIXME: UpdateLabel() should be called on size events when wxST_ELLIPSIZE_START is set | |
122 | to allow correct dynamic ellipsizing of the label | |
123 | */ | |
124 | ||
125 | #endif //if wxUSE_STATTEXT |