]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/msw/statbox.cpp
wxUniversal fix.
[wxWidgets.git] / src / msw / statbox.cpp
... / ...
CommitLineData
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// ----------------------------------------------------------------------------
44// wxWin macros
45// ----------------------------------------------------------------------------
46
47#if wxUSE_EXTENDED_RTTI
48WX_DEFINE_FLAGS( wxStaticBoxStyle )
49
50wxBEGIN_FLAGS( wxStaticBoxStyle )
51 // new style border flags, we put them first to
52 // use them for streaming out
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)
59
60 // old style border flags
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)
66 wxFLAGS_MEMBER(wxBORDER)
67
68 // standard window styles
69 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
70 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
71 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
72 wxFLAGS_MEMBER(wxWANTS_CHARS)
73 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
74 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
75 wxFLAGS_MEMBER(wxVSCROLL)
76 wxFLAGS_MEMBER(wxHSCROLL)
77
78wxEND_FLAGS( wxStaticBoxStyle )
79
80IMPLEMENT_DYNAMIC_CLASS_XTI(wxStaticBox, wxControl,"wx/statbox.h")
81
82wxBEGIN_PROPERTIES_TABLE(wxStaticBox)
83 wxPROPERTY( Label,wxString, SetLabel, GetLabel, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
84 wxPROPERTY_FLAGS( WindowStyle , wxStaticBoxStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
85/*
86 TODO PROPERTIES :
87 label
88*/
89wxEND_PROPERTIES_TABLE()
90
91wxBEGIN_HANDLERS_TABLE(wxStaticBox)
92wxEND_HANDLERS_TABLE()
93
94wxCONSTRUCTOR_6( wxStaticBox , wxWindow* , Parent , wxWindowID , Id , wxString , Label , wxPoint , Position , wxSize , Size , long , WindowStyle )
95#else
96IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
97#endif
98
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)
114{
115 if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
116 return false;
117
118 if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX, pos, size, label, 0) )
119 return false;
120
121 return true;
122}
123
124wxSize wxStaticBox::DoGetBestSize() const
125{
126 int cx, cy;
127 wxGetCharSize(GetHWND(), &cx, &cy, GetFont());
128
129 int wBox;
130 GetTextExtent(wxGetWindowText(m_hWnd), &wBox, &cy);
131
132 wBox += 3*cx;
133 int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
134
135 return wxSize(wBox, hBox);
136}
137
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
152#endif // wxUSE_STATBOX