]> git.saurik.com Git - wxWidgets.git/blob - src/univ/statbox.cpp
Moved Nano-X specific code from univ to x11
[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 SetLabel(label);
62
63 return TRUE;
64 }
65
66 void wxStaticBox::DoDraw(wxControlRenderer *renderer)
67 {
68 // we never have a border, so don't call the base class version which draws
69 // it
70 renderer->DrawFrame();
71 }
72
73 // ----------------------------------------------------------------------------
74 // geometry
75 // ----------------------------------------------------------------------------
76
77 wxRect wxStaticBox::GetBorderGeometry() const
78 {
79 // FIXME should use the renderer here
80 wxRect rect;
81 rect.width =
82 rect.x = GetCharWidth() / 2 + 1;
83 rect.y = GetCharHeight() + 1;
84 rect.height = rect.y / 2;
85
86 return rect;
87 }
88
89 wxPoint wxStaticBox::GetBoxAreaOrigin() const
90 {
91 wxPoint pt = wxControl::GetClientAreaOrigin();
92 wxRect rect = GetBorderGeometry();
93 pt.x += rect.x;
94 pt.y += rect.y;
95
96 return pt;
97 }
98
99 #if 0
100 void wxStaticBox::DoSetClientSize(int width, int height)
101 {
102 wxRect rect = GetBorderGeometry();
103
104 wxControl::DoSetClientSize(width + rect.x + rect.width,
105 height + rect.y + rect.height);
106 }
107
108 void wxStaticBox::DoGetClientSize(int *width, int *height) const
109 {
110 wxControl::DoGetClientSize(width, height);
111
112 wxRect rect = GetBorderGeometry();
113 if ( width )
114 *width -= rect.x + rect.width;
115 if ( height )
116 *height -= rect.y + rect.height;
117 }
118
119 #endif // 0
120
121 #endif // wxUSE_STATBOX
122