]> git.saurik.com Git - wxWidgets.git/blob - src/msw/statbox.cpp
Ensure the wxVListBox gets the focus when it is clicked upon
[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 // under CE this style is not defined but we don't need to make static boxes
44 // transparent there neither
45 #ifndef WS_EX_TRANSPARENT
46 #define WS_EX_TRANSPARENT 0
47 #endif
48
49 // ----------------------------------------------------------------------------
50 // wxWin macros
51 // ----------------------------------------------------------------------------
52
53 #if wxUSE_EXTENDED_RTTI
54 WX_DEFINE_FLAGS( wxStaticBoxStyle )
55
56 wxBEGIN_FLAGS( wxStaticBoxStyle )
57 // new style border flags, we put them first to
58 // use them for streaming out
59 wxFLAGS_MEMBER(wxBORDER_SIMPLE)
60 wxFLAGS_MEMBER(wxBORDER_SUNKEN)
61 wxFLAGS_MEMBER(wxBORDER_DOUBLE)
62 wxFLAGS_MEMBER(wxBORDER_RAISED)
63 wxFLAGS_MEMBER(wxBORDER_STATIC)
64 wxFLAGS_MEMBER(wxBORDER_NONE)
65
66 // old style border flags
67 wxFLAGS_MEMBER(wxSIMPLE_BORDER)
68 wxFLAGS_MEMBER(wxSUNKEN_BORDER)
69 wxFLAGS_MEMBER(wxDOUBLE_BORDER)
70 wxFLAGS_MEMBER(wxRAISED_BORDER)
71 wxFLAGS_MEMBER(wxSTATIC_BORDER)
72 wxFLAGS_MEMBER(wxBORDER)
73
74 // standard window styles
75 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
76 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
77 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
78 wxFLAGS_MEMBER(wxWANTS_CHARS)
79 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
80 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
81 wxFLAGS_MEMBER(wxVSCROLL)
82 wxFLAGS_MEMBER(wxHSCROLL)
83
84 wxEND_FLAGS( wxStaticBoxStyle )
85
86 IMPLEMENT_DYNAMIC_CLASS_XTI(wxStaticBox, wxControl,"wx/statbox.h")
87
88 wxBEGIN_PROPERTIES_TABLE(wxStaticBox)
89 wxPROPERTY( Label,wxString, SetLabel, GetLabel, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
90 wxPROPERTY_FLAGS( WindowStyle , wxStaticBoxStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
91 /*
92 TODO PROPERTIES :
93 label
94 */
95 wxEND_PROPERTIES_TABLE()
96
97 wxBEGIN_HANDLERS_TABLE(wxStaticBox)
98 wxEND_HANDLERS_TABLE()
99
100 wxCONSTRUCTOR_6( wxStaticBox , wxWindow* , Parent , wxWindowID , Id , wxString , Label , wxPoint , Position , wxSize , Size , long , WindowStyle )
101 #else
102 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
103 #endif
104
105 // ============================================================================
106 // implementation
107 // ============================================================================
108
109 // ----------------------------------------------------------------------------
110 // wxStaticBox
111 // ----------------------------------------------------------------------------
112
113 bool wxStaticBox::Create(wxWindow *parent,
114 wxWindowID id,
115 const wxString& label,
116 const wxPoint& pos,
117 const wxSize& size,
118 long style,
119 const wxString& name)
120 {
121 if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
122 return false;
123
124 if ( !MSWCreateControl(wxT("BUTTON"), label, pos, size) )
125 return false;
126
127 return true;
128 }
129
130 WXDWORD wxStaticBox::MSWGetStyle(long style, WXDWORD *exstyle) const
131 {
132 long styleWin = wxStaticBoxBase::MSWGetStyle(style, exstyle);
133
134 if ( exstyle )
135 *exstyle = WS_EX_TRANSPARENT;
136
137 return styleWin | BS_GROUPBOX;
138 }
139
140 wxSize wxStaticBox::DoGetBestSize() const
141 {
142 int cx, cy;
143 wxGetCharSize(GetHWND(), &cx, &cy, GetFont());
144
145 int wBox;
146 GetTextExtent(wxGetWindowText(m_hWnd), &wBox, &cy);
147
148 wBox += 3*cx;
149 int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
150
151 return wxSize(wBox, hBox);
152 }
153
154 WXHBRUSH
155 wxStaticBox::MSWGetBgBrushForSelf(wxWindow *parent, WXHDC WXUNUSED(pDC))
156 {
157 // we can't use pattern brushes because, apparently, the window proc of our
158 // class does something which invalidates the brush origin before drawing
159 // with it and so any patetrn brush is used incorrectly as can be seen by
160 // putting a static box inside a (themed) notebook
161 //
162 // so always use solid brush for painting the background (note that this
163 // only applies to the background of the box label, not the insides of the
164 // box itself)
165 return parent->MSWGetSolidBgBrushForChild(this);
166 }
167
168 #endif // wxUSE_STATBOX