]> git.saurik.com Git - wxWidgets.git/blame - src/msw/statbox.cpp
Events table serves for RTTI too.
[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"
2bda0e17 39
3f2711d5 40#include "wx/msw/private.h"
b04093c9 41#include "wx/msw/notebook.h"
3f2711d5
VZ
42
43// ----------------------------------------------------------------------------
44// wxWin macros
45// ----------------------------------------------------------------------------
46
51741307 47#if wxUSE_EXTENDED_RTTI
bc9fb572
JS
48WX_DEFINE_FLAGS( wxStaticBoxStyle )
49
3ff066a4 50wxBEGIN_FLAGS( wxStaticBoxStyle )
bc9fb572
JS
51 // new style border flags, we put them first to
52 // use them for streaming out
3ff066a4
SC
53 wxFLAGS_MEMBER(wxBORDER_SIMPLE)
54 wxFLAGS_MEMBER(wxBORDER_SUNKEN)
55 wxFLAGS_MEMBER(wxBORDER_DOUBLE)
56 wxFLAGS_MEMBER(wxBORDER_RAISED)
57 wxFLAGS_MEMBER(wxBORDER_STATIC)
58 wxFLAGS_MEMBER(wxBORDER_NONE)
57f4f925 59
bc9fb572 60 // old style border flags
3ff066a4
SC
61 wxFLAGS_MEMBER(wxSIMPLE_BORDER)
62 wxFLAGS_MEMBER(wxSUNKEN_BORDER)
63 wxFLAGS_MEMBER(wxDOUBLE_BORDER)
64 wxFLAGS_MEMBER(wxRAISED_BORDER)
65 wxFLAGS_MEMBER(wxSTATIC_BORDER)
cb0afb26 66 wxFLAGS_MEMBER(wxBORDER)
bc9fb572
JS
67
68 // standard window styles
3ff066a4
SC
69 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
70 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
71 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
72 wxFLAGS_MEMBER(wxWANTS_CHARS)
cb0afb26 73 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
3ff066a4
SC
74 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
75 wxFLAGS_MEMBER(wxVSCROLL)
76 wxFLAGS_MEMBER(wxHSCROLL)
bc9fb572 77
3ff066a4 78wxEND_FLAGS( wxStaticBoxStyle )
bc9fb572 79
51741307
SC
80IMPLEMENT_DYNAMIC_CLASS_XTI(wxStaticBox, wxControl,"wx/statbox.h")
81
3ff066a4 82wxBEGIN_PROPERTIES_TABLE(wxStaticBox)
57f4f925 83 wxPROPERTY( Label,wxString, SetLabel, GetLabel, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
af498247 84 wxPROPERTY_FLAGS( WindowStyle , wxStaticBoxStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
066f1b7a 85/*
57f4f925
WS
86 TODO PROPERTIES :
87 label
066f1b7a 88*/
3ff066a4 89wxEND_PROPERTIES_TABLE()
51741307 90
3ff066a4
SC
91wxBEGIN_HANDLERS_TABLE(wxStaticBox)
92wxEND_HANDLERS_TABLE()
51741307 93
57f4f925 94wxCONSTRUCTOR_6( wxStaticBox , wxWindow* , Parent , wxWindowID , Id , wxString , Label , wxPoint , Position , wxSize , Size , long , WindowStyle )
51741307
SC
95#else
96IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
97#endif
2bda0e17 98
3f2711d5
VZ
99// ============================================================================
100// implementation
101// ============================================================================
102
103// ----------------------------------------------------------------------------
104// wxStaticBox
105// ----------------------------------------------------------------------------
106
107bool wxStaticBox::Create(wxWindow *parent,
108 wxWindowID id,
109 const wxString& label,
110 const wxPoint& pos,
111 const wxSize& size,
112 long style,
113 const wxString& name)
2bda0e17 114{
11b6a93b 115 if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
57f4f925 116 return false;
2bda0e17 117
24181682 118 if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX, pos, size, label, 0) )
57f4f925 119 return false;
2bda0e17 120
57f4f925 121 return true;
2bda0e17
KB
122}
123
f68586e5 124wxSize wxStaticBox::DoGetBestSize() const
2bda0e17 125{
4438caf4 126 int cx, cy;
7a5e53ab 127 wxGetCharSize(GetHWND(), &cx, &cy, GetFont());
2bda0e17 128
4438caf4
VZ
129 int wBox;
130 GetTextExtent(wxGetWindowText(m_hWnd), &wBox, &cy);
2bda0e17 131
4438caf4
VZ
132 wBox += 3*cx;
133 int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
2bda0e17 134
4438caf4
VZ
135 return wxSize(wBox, hBox);
136}
2bda0e17 137
b04093c9
VZ
138WXHBRUSH
139wxStaticBox::MSWGetBgBrushForSelf(wxWindow *parent, WXHDC WXUNUSED(pDC))
140{
141 // we can't use pattern brushes because, apparently, the window proc of our
142 // class does something which invalidates the brush origin before drawing
143 // with it and so any patetrn brush is used incorrectly as can be seen by
144 // putting a static box inside a (themed) notebook
145 //
146 // so always use solid brush for painting the background (note that this
147 // only applies to the background of the box label, not the insides of the
148 // box itself)
149 return parent->MSWGetSolidBgBrushForChild(this);
150}
151
1e6feb95 152#endif // wxUSE_STATBOX