]> git.saurik.com Git - wxWidgets.git/blob - src/msw/statbox.cpp
Warning fix and source cleaning.
[wxWidgets.git] / src / msw / statbox.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: msw/statbox.cpp
3 // Purpose: wxStaticBox
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
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 "statbox.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 #if wxUSE_STATBOX
32
33 #ifndef WX_PRECOMP
34 #include "wx/app.h"
35 #include "wx/dcclient.h"
36 #endif
37
38 #include "wx/statbox.h"
39 #include "wx/notebook.h"
40
41 #include "wx/msw/private.h"
42
43 // this is for Win CE
44 #ifndef WS_EX_TRANSPARENT
45 #define WS_EX_TRANSPARENT 0
46 #endif
47
48 // ----------------------------------------------------------------------------
49 // wxWin macros
50 // ----------------------------------------------------------------------------
51
52 #if wxUSE_EXTENDED_RTTI
53 WX_DEFINE_FLAGS( wxStaticBoxStyle )
54
55 wxBEGIN_FLAGS( wxStaticBoxStyle )
56 // new style border flags, we put them first to
57 // use them for streaming out
58 wxFLAGS_MEMBER(wxBORDER_SIMPLE)
59 wxFLAGS_MEMBER(wxBORDER_SUNKEN)
60 wxFLAGS_MEMBER(wxBORDER_DOUBLE)
61 wxFLAGS_MEMBER(wxBORDER_RAISED)
62 wxFLAGS_MEMBER(wxBORDER_STATIC)
63 wxFLAGS_MEMBER(wxBORDER_NONE)
64
65 // old style border flags
66 wxFLAGS_MEMBER(wxSIMPLE_BORDER)
67 wxFLAGS_MEMBER(wxSUNKEN_BORDER)
68 wxFLAGS_MEMBER(wxDOUBLE_BORDER)
69 wxFLAGS_MEMBER(wxRAISED_BORDER)
70 wxFLAGS_MEMBER(wxSTATIC_BORDER)
71 wxFLAGS_MEMBER(wxBORDER)
72
73 // standard window styles
74 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
75 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
76 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
77 wxFLAGS_MEMBER(wxWANTS_CHARS)
78 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
79 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
80 wxFLAGS_MEMBER(wxVSCROLL)
81 wxFLAGS_MEMBER(wxHSCROLL)
82
83 wxEND_FLAGS( wxStaticBoxStyle )
84
85 IMPLEMENT_DYNAMIC_CLASS_XTI(wxStaticBox, wxControl,"wx/statbox.h")
86
87 wxBEGIN_PROPERTIES_TABLE(wxStaticBox)
88 wxPROPERTY( Label,wxString, SetLabel, GetLabel, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
89 wxPROPERTY_FLAGS( WindowStyle , wxStaticBoxStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
90 /*
91 TODO PROPERTIES :
92 label
93 */
94 wxEND_PROPERTIES_TABLE()
95
96 wxBEGIN_HANDLERS_TABLE(wxStaticBox)
97 wxEND_HANDLERS_TABLE()
98
99 wxCONSTRUCTOR_6( wxStaticBox , wxWindow* , Parent , wxWindowID , Id , wxString , Label , wxPoint , Position , wxSize , Size , long , WindowStyle )
100 #else
101 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
102 #endif
103
104 // ============================================================================
105 // implementation
106 // ============================================================================
107
108 // ----------------------------------------------------------------------------
109 // wxStaticBox
110 // ----------------------------------------------------------------------------
111
112 bool wxStaticBox::Create(wxWindow *parent,
113 wxWindowID id,
114 const wxString& label,
115 const wxPoint& pos,
116 const wxSize& size,
117 long style,
118 const wxString& name)
119 {
120 if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
121 return false;
122
123 if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX, pos, size, label,
124 WS_EX_TRANSPARENT) )
125 return false;
126
127 return true;
128 }
129
130 wxSize wxStaticBox::DoGetBestSize() const
131 {
132 int cx, cy;
133 wxGetCharSize(GetHWND(), &cx, &cy, GetFont());
134
135 int wBox;
136 GetTextExtent(wxGetWindowText(m_hWnd), &wBox, &cy);
137
138 wBox += 3*cx;
139 int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
140
141 return wxSize(wBox, hBox);
142 }
143
144 WXHBRUSH
145 wxStaticBox::MSWGetBgBrushForSelf(wxWindow *parent, WXHDC WXUNUSED(pDC))
146 {
147 // we can't use pattern brushes because, apparently, the window proc of our
148 // class does something which invalidates the brush origin before drawing
149 // with it and so any patetrn brush is used incorrectly as can be seen by
150 // putting a static box inside a (themed) notebook
151 //
152 // so always use solid brush for painting the background (note that this
153 // only applies to the background of the box label, not the insides of the
154 // box itself)
155 return parent->MSWGetSolidBgBrushForChild(this);
156 }
157
158 #endif // wxUSE_STATBOX