]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/statbox.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: msw/statbox.cpp
3 // Purpose: wxStaticBox
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "statbox.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
35 #include "wx/dcclient.h"
38 #include "wx/statbox.h"
39 #include "wx/notebook.h"
41 #include "wx/msw/private.h"
43 // ----------------------------------------------------------------------------
45 // ----------------------------------------------------------------------------
47 #if wxUSE_EXTENDED_RTTI
48 WX_DEFINE_FLAGS( wxStaticBoxStyle
)
50 wxBEGIN_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
)
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
)
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
)
78 wxEND_FLAGS( wxStaticBoxStyle
)
80 IMPLEMENT_DYNAMIC_CLASS_XTI(wxStaticBox
, wxControl
,"wx/statbox.h")
82 wxBEGIN_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
89 wxEND_PROPERTIES_TABLE()
91 wxBEGIN_HANDLERS_TABLE(wxStaticBox
)
92 wxEND_HANDLERS_TABLE()
94 wxCONSTRUCTOR_6( wxStaticBox
, wxWindow
* , Parent
, wxWindowID
, Id
, wxString
, Label
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
96 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox
, wxControl
)
99 // ============================================================================
101 // ============================================================================
103 // ----------------------------------------------------------------------------
105 // ----------------------------------------------------------------------------
107 bool wxStaticBox::Create(wxWindow
*parent
,
109 const wxString
& label
,
113 const wxString
& name
)
115 if ( !CreateControl(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
118 if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX
, pos
, size
, label
, 0) )
124 wxSize
wxStaticBox::DoGetBestSize() const
127 wxGetCharSize(GetHWND(), &cx
, &cy
, GetFont());
130 GetTextExtent(wxGetWindowText(m_hWnd
), &wBox
, &cy
);
133 int hBox
= EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy
);
135 return wxSize(wBox
, hBox
);
139 wxStaticBox::MSWGetBgBrushForSelf(wxWindow
*parent
, WXHDC
WXUNUSED(pDC
))
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
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
149 return parent
->MSWGetSolidBgBrushForChild(this);
152 #endif // wxUSE_STATBOX