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