1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/univ/stattext.cpp
3 // Purpose: wxStaticText
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 14.08.00
7 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 // ============================================================================
12 // declarations
13 // ============================================================================
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 #include "wx/wxprec.h"
20
21
22 #if wxUSE_STATTEXT
23
24 #include "wx/stattext.h"
25
26 #ifndef WX_PRECOMP
27 #include "wx/dcclient.h"
28 #include "wx/validate.h"
29 #endif
30
31 #include "wx/univ/renderer.h"
32 #include "wx/univ/theme.h"
33
34 // ============================================================================
35 // implementation
36 // ============================================================================
37
38 // ----------------------------------------------------------------------------
39 // creation
40 // ----------------------------------------------------------------------------
41
Create(wxWindow * parent,wxWindowID id,const wxString & label,const wxPoint & pos,const wxSize & size,long style,const wxString & name)42 bool wxStaticText::Create(wxWindow *parent,
43 wxWindowID id,
44 const wxString &label,
45 const wxPoint &pos,
46 const wxSize &size,
47 long style,
48 const wxString &name)
49 {
50 if ( !wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name) )
51 return false;
52
53 SetLabel(label);
54 SetInitialSize(size);
55
56 return true;
57 }
58
59 // ----------------------------------------------------------------------------
60 // drawing
61 // ----------------------------------------------------------------------------
62
DoDraw(wxControlRenderer * renderer)63 void wxStaticText::DoDraw(wxControlRenderer *renderer)
64 {
65 renderer->DrawLabel();
66 }
67
SetLabel(const wxString & str)68 void wxStaticText::SetLabel(const wxString& str)
69 {
70 if ( str == m_labelOrig )
71 return;
72
73 // save original label
74 m_labelOrig = str;
75
76 // draw as real label the abbreviated version of it
77 WXSetVisibleLabel(GetEllipsizedLabel());
78 }
79
WXSetVisibleLabel(const wxString & str)80 void wxStaticText::WXSetVisibleLabel(const wxString& str)
81 {
82 UnivDoSetLabel(str);
83 }
84
WXGetVisibleLabel() const85 wxString wxStaticText::WXGetVisibleLabel() const
86 {
87 return wxControl::GetLabel();
88 }
89
90 /*
91 FIXME: UpdateLabel() should be called on size events to allow correct
92 dynamic ellipsizing of the label
93 */
94
95 #endif // wxUSE_STATTEXT
96