]> git.saurik.com Git - wxWidgets.git/blob - src/univ/stattext.cpp
2ea90b3ee2daa1e119ad9b18a02f2c2092b80465
[wxWidgets.git] / src / univ / stattext.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: univ/stattext.cpp
3 // Purpose: wxStaticText
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 14.08.00
7 // RCS-ID: $Id$
8 // Copyright: (c) 2000 Vadim Zeitlin
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "univstattext.h"
22 #endif
23
24 #include "wx/wxprec.h"
25
26 #ifdef __BORLANDC__
27 #pragma hdrstop
28 #endif
29
30 #if wxUSE_STATTEXT
31
32 #ifndef WX_PRECOMP
33 #include "wx/dcclient.h"
34 #include "wx/stattext.h"
35 #include "wx/validate.h"
36 #endif
37
38 #include "wx/univ/renderer.h"
39 #include "wx/univ/theme.h"
40
41 // ============================================================================
42 // implementation
43 // ============================================================================
44
45 // ----------------------------------------------------------------------------
46 // creation
47 // ----------------------------------------------------------------------------
48
49 bool wxStaticText::Create(wxWindow *parent,
50 wxWindowID id,
51 const wxString &label,
52 const wxPoint &pos,
53 const wxSize &size,
54 long style,
55 const wxString &name)
56 {
57 if ( !wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name) )
58 return FALSE;
59
60 SetLabel(label);
61 SetBestSize(size);
62
63 return TRUE;
64 }
65
66 // ----------------------------------------------------------------------------
67 // size management
68 // ----------------------------------------------------------------------------
69
70 void wxStaticText::SetLabel(const wxString& label)
71 {
72 wxControl::SetLabel(label);
73 }
74
75 wxSize wxStaticText::DoGetBestClientSize() const
76 {
77 wxStaticText *self = wxConstCast(this, wxStaticText);
78 wxClientDC dc(self);
79 dc.SetFont(GetFont());
80 wxCoord width, height;
81 dc.GetMultiLineTextExtent(GetLabel(), &width, &height);
82
83 return wxSize(width, height);
84 }
85
86 // ----------------------------------------------------------------------------
87 // drawing
88 // ----------------------------------------------------------------------------
89
90 void wxStaticText::DoDraw(wxControlRenderer *renderer)
91 {
92 renderer->DrawLabel();
93 }
94
95 #endif // wxUSE_STATTEXT