]>
Commit | Line | Data |
---|---|---|
1e6feb95 | 1 | ///////////////////////////////////////////////////////////////////////////// |
ccdc11bb | 2 | // Name: src/univ/stattext.cpp |
1e6feb95 VZ |
3 | // Purpose: wxStaticText |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 14.08.00 | |
7 | // RCS-ID: $Id$ | |
442b35b5 | 8 | // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com) |
65571936 | 9 | // Licence: wxWindows licence |
1e6feb95 VZ |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
1e6feb95 VZ |
20 | #include "wx/wxprec.h" |
21 | ||
22 | #ifdef __BORLANDC__ | |
23 | #pragma hdrstop | |
24 | #endif | |
25 | ||
26 | #if wxUSE_STATTEXT | |
27 | ||
ccdc11bb WS |
28 | #include "wx/stattext.h" |
29 | ||
1e6feb95 VZ |
30 | #ifndef WX_PRECOMP |
31 | #include "wx/dcclient.h" | |
1e6feb95 VZ |
32 | #include "wx/validate.h" |
33 | #endif | |
34 | ||
35 | #include "wx/univ/renderer.h" | |
36 | #include "wx/univ/theme.h" | |
37 | ||
38 | // ============================================================================ | |
39 | // implementation | |
40 | // ============================================================================ | |
41 | ||
3379ed37 VZ |
42 | IMPLEMENT_ABSTRACT_CLASS(wxStaticText, wxControl) |
43 | ||
1e6feb95 VZ |
44 | // ---------------------------------------------------------------------------- |
45 | // creation | |
46 | // ---------------------------------------------------------------------------- | |
47 | ||
48 | bool wxStaticText::Create(wxWindow *parent, | |
49 | wxWindowID id, | |
50 | const wxString &label, | |
51 | const wxPoint &pos, | |
52 | const wxSize &size, | |
53 | long style, | |
54 | const wxString &name) | |
55 | { | |
56 | if ( !wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name) ) | |
a290fa5a | 57 | return false; |
ccdc11bb | 58 | |
1e6feb95 | 59 | SetLabel(label); |
170acdc9 | 60 | SetInitialSize(size); |
1e6feb95 | 61 | |
a290fa5a | 62 | return true; |
1e6feb95 VZ |
63 | } |
64 | ||
65 | // ---------------------------------------------------------------------------- | |
66 | // size management | |
67 | // ---------------------------------------------------------------------------- | |
68 | ||
1e6feb95 VZ |
69 | wxSize wxStaticText::DoGetBestClientSize() const |
70 | { | |
71 | wxStaticText *self = wxConstCast(this, wxStaticText); | |
72 | wxClientDC dc(self); | |
73 | dc.SetFont(GetFont()); | |
74 | wxCoord width, height; | |
75 | dc.GetMultiLineTextExtent(GetLabel(), &width, &height); | |
76 | ||
77 | return wxSize(width, height); | |
78 | } | |
79 | ||
80 | // ---------------------------------------------------------------------------- | |
81 | // drawing | |
82 | // ---------------------------------------------------------------------------- | |
83 | ||
84 | void wxStaticText::DoDraw(wxControlRenderer *renderer) | |
85 | { | |
9c5fd8a3 VZ |
86 | if ( UseBgCol() ) |
87 | { | |
88 | wxDC& dc = renderer->GetDC(); | |
89 | dc.SetBrush(GetBackgroundColour()); | |
90 | dc.SetPen(*wxTRANSPARENT_PEN); | |
91 | dc.DrawRectangle(renderer->GetRect()); | |
92 | } | |
93 | ||
1e6feb95 VZ |
94 | renderer->DrawLabel(); |
95 | } | |
96 | ||
39bc0347 VZ |
97 | void wxStaticText::SetLabel(const wxString& str) |
98 | { | |
99 | // save original label | |
100 | m_labelOrig = str; | |
101 | ||
102 | // draw as real label the result of GetEllipsizedLabelWithoutMarkup: | |
103 | DoSetLabel(GetEllipsizedLabelWithoutMarkup()); | |
104 | } | |
105 | ||
106 | void wxStaticText::DoSetLabel(const wxString& str) | |
107 | { | |
108 | UnivDoSetLabel(str); | |
109 | } | |
110 | ||
111 | wxString wxStaticText::DoGetLabel() const | |
112 | { | |
113 | return wxControl::GetLabel(); | |
114 | } | |
115 | ||
116 | /* | |
117 | FIXME: UpdateLabel() should be called on size events to allow correct | |
118 | dynamic ellipsizing of the label | |
119 | */ | |
120 | ||
1e6feb95 | 121 | #endif // wxUSE_STATTEXT |