Added "metal" theme.
[wxWidgets.git] / src / univ / statbox.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: univ/statbox.cpp
3 // Purpose: wxStaticBox implementation
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 25.08.00
7 // RCS-ID: $Id$
8 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "univstatbox.h"
22 #endif
23
24 #include "wx/wxprec.h"
25
26 #ifdef __BORLANDC__
27 #pragma hdrstop
28 #endif
29
30 #if wxUSE_STATBOX
31
32 #ifndef WX_PRECOMP
33 #include "wx/dc.h"
34 #include "wx/statbox.h"
35 #include "wx/validate.h"
36 #endif
37
38 #include "wx/univ/renderer.h"
39
40 // ============================================================================
41 // implementation
42 // ============================================================================
43
44 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
45
46 // ----------------------------------------------------------------------------
47 // wxStaticBox
48 // ----------------------------------------------------------------------------
49
50 bool wxStaticBox::Create(wxWindow *parent,
51 wxWindowID id,
52 const wxString &label,
53 const wxPoint &pos,
54 const wxSize &size,
55 long style,
56 const wxString &name)
57 {
58 if ( !wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name) )
59 return FALSE;
60
61 m_hasDialogBackground = TRUE;
62
63 SetLabel(label);
64
65 return TRUE;
66 }
67
68 void wxStaticBox::DoDraw(wxControlRenderer *renderer)
69 {
70 // we never have a border, so don't call the base class version which draws
71 // it
72 renderer->DrawFrame();
73 }
74
75 // ----------------------------------------------------------------------------
76 // geometry
77 // ----------------------------------------------------------------------------
78
79 wxRect wxStaticBox::GetBorderGeometry() const
80 {
81 // FIXME should use the renderer here
82 wxRect rect;
83 rect.width =
84 rect.x = GetCharWidth() / 2 + 1;
85 rect.y = GetCharHeight() + 1;
86 rect.height = rect.y / 2;
87
88 return rect;
89 }
90
91 wxPoint wxStaticBox::GetBoxAreaOrigin() const
92 {
93 wxPoint pt = wxControl::GetClientAreaOrigin();
94 wxRect rect = GetBorderGeometry();
95 pt.x += rect.x;
96 pt.y += rect.y;
97
98 return pt;
99 }
100
101 #if 0
102 void wxStaticBox::DoSetClientSize(int width, int height)
103 {
104 wxRect rect = GetBorderGeometry();
105
106 wxControl::DoSetClientSize(width + rect.x + rect.width,
107 height + rect.y + rect.height);
108 }
109
110 void wxStaticBox::DoGetClientSize(int *width, int *height) const
111 {
112 wxControl::DoGetClientSize(width, height);
113
114 wxRect rect = GetBorderGeometry();
115 if ( width )
116 *width -= rect.x + rect.width;
117 if ( height )
118 *height -= rect.y + rect.height;
119 }
120
121 #endif // 0
122
123 #endif // wxUSE_STATBOX
124