]> git.saurik.com Git - wxWidgets.git/blame - src/msw/statbox.cpp
fixed wrong use of = instead of == (patch 1159289)
[wxWidgets.git] / src / msw / statbox.cpp
CommitLineData
2bda0e17 1/////////////////////////////////////////////////////////////////////////////
3f2711d5 2// Name: msw/statbox.cpp
2bda0e17
KB
3// Purpose: wxStaticBox
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
6c9a19aa 8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
3f2711d5
VZ
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
14f355c2 20#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
3f2711d5 21 #pragma implementation "statbox.h"
2bda0e17
KB
22#endif
23
24// For compilers that support precompilation, includes "wx.h".
25#include "wx/wxprec.h"
26
27#ifdef __BORLANDC__
3f2711d5 28 #pragma hdrstop
2bda0e17
KB
29#endif
30
1e6feb95
VZ
31#if wxUSE_STATBOX
32
2bda0e17 33#ifndef WX_PRECOMP
3f2711d5
VZ
34 #include "wx/app.h"
35 #include "wx/dcclient.h"
2bda0e17
KB
36#endif
37
38#include "wx/statbox.h"
3ad70d31 39#include "wx/notebook.h"
9dabade2 40#include "wx/sysopt.h"
2bda0e17 41
3f2711d5
VZ
42#include "wx/msw/private.h"
43
e31e6ea7
VZ
44// under CE this style is not defined but we don't need to make static boxes
45// transparent there neither
301e257b
VZ
46#ifndef WS_EX_TRANSPARENT
47 #define WS_EX_TRANSPARENT 0
48#endif
49
3f2711d5
VZ
50// ----------------------------------------------------------------------------
51// wxWin macros
52// ----------------------------------------------------------------------------
53
51741307 54#if wxUSE_EXTENDED_RTTI
bc9fb572
JS
55WX_DEFINE_FLAGS( wxStaticBoxStyle )
56
3ff066a4 57wxBEGIN_FLAGS( wxStaticBoxStyle )
bc9fb572
JS
58 // new style border flags, we put them first to
59 // use them for streaming out
3ff066a4
SC
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)
57f4f925 66
bc9fb572 67 // old style border flags
3ff066a4
SC
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)
cb0afb26 73 wxFLAGS_MEMBER(wxBORDER)
bc9fb572
JS
74
75 // standard window styles
3ff066a4
SC
76 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
77 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
78 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
79 wxFLAGS_MEMBER(wxWANTS_CHARS)
cb0afb26 80 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
3ff066a4
SC
81 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
82 wxFLAGS_MEMBER(wxVSCROLL)
83 wxFLAGS_MEMBER(wxHSCROLL)
bc9fb572 84
3ff066a4 85wxEND_FLAGS( wxStaticBoxStyle )
bc9fb572 86
51741307
SC
87IMPLEMENT_DYNAMIC_CLASS_XTI(wxStaticBox, wxControl,"wx/statbox.h")
88
3ff066a4 89wxBEGIN_PROPERTIES_TABLE(wxStaticBox)
57f4f925 90 wxPROPERTY( Label,wxString, SetLabel, GetLabel, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
af498247 91 wxPROPERTY_FLAGS( WindowStyle , wxStaticBoxStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
066f1b7a 92/*
57f4f925
WS
93 TODO PROPERTIES :
94 label
066f1b7a 95*/
3ff066a4 96wxEND_PROPERTIES_TABLE()
51741307 97
3ff066a4
SC
98wxBEGIN_HANDLERS_TABLE(wxStaticBox)
99wxEND_HANDLERS_TABLE()
51741307 100
57f4f925 101wxCONSTRUCTOR_6( wxStaticBox , wxWindow* , Parent , wxWindowID , Id , wxString , Label , wxPoint , Position , wxSize , Size , long , WindowStyle )
51741307
SC
102#else
103IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
104#endif
2bda0e17 105
3f2711d5
VZ
106// ============================================================================
107// implementation
108// ============================================================================
109
110// ----------------------------------------------------------------------------
111// wxStaticBox
112// ----------------------------------------------------------------------------
113
114bool 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)
2bda0e17 121{
11b6a93b 122 if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
57f4f925 123 return false;
2bda0e17 124
e31e6ea7 125 if ( !MSWCreateControl(wxT("BUTTON"), label, pos, size) )
57f4f925 126 return false;
2bda0e17 127
57f4f925 128 return true;
2bda0e17
KB
129}
130
e31e6ea7
VZ
131WXDWORD 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
f68586e5 141wxSize wxStaticBox::DoGetBestSize() const
2bda0e17 142{
4438caf4 143 int cx, cy;
7a5e53ab 144 wxGetCharSize(GetHWND(), &cx, &cy, GetFont());
2bda0e17 145
4438caf4
VZ
146 int wBox;
147 GetTextExtent(wxGetWindowText(m_hWnd), &wBox, &cy);
2bda0e17 148
4438caf4
VZ
149 wBox += 3*cx;
150 int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
2bda0e17 151
4438caf4
VZ
152 return wxSize(wBox, hBox);
153}
2bda0e17 154
6aa01033
JS
155WXLRESULT wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
156{
abf912c5 157#ifndef __WXWINCE__
58385af0 158 if ( nMsg == WM_NCHITTEST )
6aa01033 159 {
58385af0
VZ
160 // This code breaks some other processing such as enter/leave tracking
161 // so it's off by default.
162
163 static int s_useHTClient = -1;
164 if (s_useHTClient == -1)
165 s_useHTClient = wxSystemOptions::GetOptionInt(wxT("msw.staticbox.htclient"));
166 if (s_useHTClient == 1)
167 {
168 int xPos = LOWORD(lParam); // horizontal position of cursor
169 int yPos = HIWORD(lParam); // vertical position of cursor
170
171 ScreenToClient(&xPos, &yPos);
172
173 // Make sure you can drag by the top of the groupbox, but let
174 // other (enclosed) controls get mouse events also
175 if ( yPos < 10 )
176 return (long)HTCLIENT;
177 }
6aa01033 178 }
abf912c5 179#endif // !__WXWINCE__
6aa01033
JS
180
181 return wxControl::MSWWindowProc(nMsg, wParam, lParam);
182}
183
58385af0
VZ
184void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
185{
186 wxStaticBoxBase::GetBordersForSizer(borderTop, borderOther);
187
188 // if not using correct (but backwards cojmpatible) text metrics
189 // calculations, we need to add some extra margin or otherwise static box
190 // title is clipped
191#if !wxDIALOG_UNIT_COMPATIBILITY
192 if ( !GetLabel().empty() )
193 *borderTop += GetCharHeight()/3;
194#endif // !wxDIALOG_UNIT_COMPATIBILITY
195}
196
1e6feb95 197#endif // wxUSE_STATBOX
6aa01033 198