]> git.saurik.com Git - wxWidgets.git/blob - src/msw/statbox.cpp
guard for 10.2
[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 #include "wx/sysopt.h"
41
42 #include "wx/msw/private.h"
43
44 // under CE this style is not defined but we don't need to make static boxes
45 // transparent there neither
46 #ifndef WS_EX_TRANSPARENT
47 #define WS_EX_TRANSPARENT 0
48 #endif
49
50 // ----------------------------------------------------------------------------
51 // wxWin macros
52 // ----------------------------------------------------------------------------
53
54 #if wxUSE_EXTENDED_RTTI
55 WX_DEFINE_FLAGS( wxStaticBoxStyle )
56
57 wxBEGIN_FLAGS( wxStaticBoxStyle )
58 // new style border flags, we put them first to
59 // use them for streaming out
60 wxFLAGS_MEMBER(wxBORDER_SIMPLE)
61 wxFLAGS_MEMBER(wxBORDER_SUNKEN)
62 wxFLAGS_MEMBER(wxBORDER_DOUBLE)
63 wxFLAGS_MEMBER(wxBORDER_RAISED)
64 wxFLAGS_MEMBER(wxBORDER_STATIC)
65 wxFLAGS_MEMBER(wxBORDER_NONE)
66
67 // old style border flags
68 wxFLAGS_MEMBER(wxSIMPLE_BORDER)
69 wxFLAGS_MEMBER(wxSUNKEN_BORDER)
70 wxFLAGS_MEMBER(wxDOUBLE_BORDER)
71 wxFLAGS_MEMBER(wxRAISED_BORDER)
72 wxFLAGS_MEMBER(wxSTATIC_BORDER)
73 wxFLAGS_MEMBER(wxBORDER)
74
75 // standard window styles
76 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
77 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
78 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
79 wxFLAGS_MEMBER(wxWANTS_CHARS)
80 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
81 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
82 wxFLAGS_MEMBER(wxVSCROLL)
83 wxFLAGS_MEMBER(wxHSCROLL)
84
85 wxEND_FLAGS( wxStaticBoxStyle )
86
87 IMPLEMENT_DYNAMIC_CLASS_XTI(wxStaticBox, wxControl,"wx/statbox.h")
88
89 wxBEGIN_PROPERTIES_TABLE(wxStaticBox)
90 wxPROPERTY( Label,wxString, SetLabel, GetLabel, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
91 wxPROPERTY_FLAGS( WindowStyle , wxStaticBoxStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
92 /*
93 TODO PROPERTIES :
94 label
95 */
96 wxEND_PROPERTIES_TABLE()
97
98 wxBEGIN_HANDLERS_TABLE(wxStaticBox)
99 wxEND_HANDLERS_TABLE()
100
101 wxCONSTRUCTOR_6( wxStaticBox , wxWindow* , Parent , wxWindowID , Id , wxString , Label , wxPoint , Position , wxSize , Size , long , WindowStyle )
102 #else
103 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
104 #endif
105
106 // ============================================================================
107 // implementation
108 // ============================================================================
109
110 // ----------------------------------------------------------------------------
111 // wxStaticBox
112 // ----------------------------------------------------------------------------
113
114 bool wxStaticBox::Create(wxWindow *parent,
115 wxWindowID id,
116 const wxString& label,
117 const wxPoint& pos,
118 const wxSize& size,
119 long style,
120 const wxString& name)
121 {
122 if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
123 return false;
124
125 if ( !MSWCreateControl(wxT("BUTTON"), label, pos, size) )
126 return false;
127
128 return true;
129 }
130
131 WXDWORD wxStaticBox::MSWGetStyle(long style, WXDWORD *exstyle) const
132 {
133 long styleWin = wxStaticBoxBase::MSWGetStyle(style, exstyle);
134
135 if ( exstyle )
136 *exstyle = WS_EX_TRANSPARENT;
137
138 return styleWin | BS_GROUPBOX;
139 }
140
141 wxSize wxStaticBox::DoGetBestSize() const
142 {
143 int cx, cy;
144 wxGetCharSize(GetHWND(), &cx, &cy, GetFont());
145
146 int wBox;
147 GetTextExtent(wxGetWindowText(m_hWnd), &wBox, &cy);
148
149 wBox += 3*cx;
150 int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
151
152 return wxSize(wBox, hBox);
153 }
154
155 WXLRESULT wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
156 {
157 switch ( nMsg )
158 {
159 #ifndef __WXWINCE__
160 case WM_NCHITTEST:
161 {
162 // This code breaks some other processing such as enter/leave tracking
163 // so it's off by default.
164
165 static int s_useHTClient = -1;
166 if (s_useHTClient == -1)
167 s_useHTClient = wxSystemOptions::GetOptionInt(wxT("msw.staticbox.htclient"));
168 if (s_useHTClient == 1)
169 {
170 int xPos = LOWORD(lParam); // horizontal position of cursor
171 int yPos = HIWORD(lParam); // vertical position of cursor
172
173 ScreenToClient(&xPos, &yPos);
174
175 // Make sure you can drag by the top of the groupbox, but let
176 // other (enclosed) controls get mouse events also
177 if ( yPos < 10 )
178 return (long)HTCLIENT;
179 }
180 }
181 break;
182 #endif
183 }
184
185 return wxControl::MSWWindowProc(nMsg, wParam, lParam);
186 }
187
188 #endif // wxUSE_STATBOX
189