Needs to refresh the affected parts when resized but I think that would involve
[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 licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
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 // FIXME refresh just the right/bottom parts affected in OnSize
59 style |= wxFULL_REPAINT_ON_RESIZE;
60
61 if ( !wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name) )
62 return false;
63
64 SetLabel(label);
65
66 return true;
67 }
68
69 void wxStaticBox::DoDraw(wxControlRenderer *renderer)
70 {
71 // we never have a border, so don't call the base class version which draws
72 // it
73 renderer->DrawFrame();
74 }
75
76 // ----------------------------------------------------------------------------
77 // geometry
78 // ----------------------------------------------------------------------------
79
80 wxRect wxStaticBox::GetBorderGeometry() const
81 {
82 // FIXME should use the renderer here
83 wxRect rect;
84 rect.width =
85 rect.x = GetCharWidth() / 2 + 1;
86 rect.y = GetCharHeight() + 1;
87 rect.height = rect.y / 2;
88
89 return rect;
90 }
91
92 wxPoint wxStaticBox::GetBoxAreaOrigin() const
93 {
94 wxPoint pt = wxControl::GetClientAreaOrigin();
95 wxRect rect = GetBorderGeometry();
96 pt.x += rect.x;
97 pt.y += rect.y;
98
99 return pt;
100 }
101
102 #if 0
103 void wxStaticBox::DoSetClientSize(int width, int height)
104 {
105 wxRect rect = GetBorderGeometry();
106
107 wxControl::DoSetClientSize(width + rect.x + rect.width,
108 height + rect.y + rect.height);
109 }
110
111 void wxStaticBox::DoGetClientSize(int *width, int *height) const
112 {
113 wxControl::DoGetClientSize(width, height);
114
115 wxRect rect = GetBorderGeometry();
116 if ( width )
117 *width -= rect.x + rect.width;
118 if ( height )
119 *height -= rect.y + rect.height;
120 }
121
122 #endif // 0
123
124 #endif // wxUSE_STATBOX
125