]>
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"
44 #ifndef WS_EX_TRANSPARENT
45 #define WS_EX_TRANSPARENT 0
48 // ----------------------------------------------------------------------------
50 // ----------------------------------------------------------------------------
52 #if wxUSE_EXTENDED_RTTI
53 WX_DEFINE_FLAGS( wxStaticBoxStyle
)
55 wxBEGIN_FLAGS( wxStaticBoxStyle
)
56 // new style border flags, we put them first to
57 // use them for streaming out
58 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
59 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
60 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
61 wxFLAGS_MEMBER(wxBORDER_RAISED
)
62 wxFLAGS_MEMBER(wxBORDER_STATIC
)
63 wxFLAGS_MEMBER(wxBORDER_NONE
)
65 // old style border flags
66 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
67 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
68 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
69 wxFLAGS_MEMBER(wxRAISED_BORDER
)
70 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
71 wxFLAGS_MEMBER(wxBORDER
)
73 // standard window styles
74 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
75 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
76 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
77 wxFLAGS_MEMBER(wxWANTS_CHARS
)
78 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
79 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
80 wxFLAGS_MEMBER(wxVSCROLL
)
81 wxFLAGS_MEMBER(wxHSCROLL
)
83 wxEND_FLAGS( wxStaticBoxStyle
)
85 IMPLEMENT_DYNAMIC_CLASS_XTI(wxStaticBox
, wxControl
,"wx/statbox.h")
87 wxBEGIN_PROPERTIES_TABLE(wxStaticBox
)
88 wxPROPERTY( Label
,wxString
, SetLabel
, GetLabel
, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
89 wxPROPERTY_FLAGS( WindowStyle
, wxStaticBoxStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
94 wxEND_PROPERTIES_TABLE()
96 wxBEGIN_HANDLERS_TABLE(wxStaticBox
)
97 wxEND_HANDLERS_TABLE()
99 wxCONSTRUCTOR_6( wxStaticBox
, wxWindow
* , Parent
, wxWindowID
, Id
, wxString
, Label
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
101 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox
, wxControl
)
104 // ============================================================================
106 // ============================================================================
108 // ----------------------------------------------------------------------------
110 // ----------------------------------------------------------------------------
112 bool wxStaticBox::Create(wxWindow
*parent
,
114 const wxString
& label
,
118 const wxString
& name
)
120 if ( !CreateControl(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
123 if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX
, pos
, size
, label
,
130 wxSize
wxStaticBox::DoGetBestSize() const
133 wxGetCharSize(GetHWND(), &cx
, &cy
, GetFont());
136 GetTextExtent(wxGetWindowText(m_hWnd
), &wBox
, &cy
);
139 int hBox
= EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy
);
141 return wxSize(wBox
, hBox
);
145 wxStaticBox::MSWGetBgBrushForSelf(wxWindow
*parent
, WXHDC
WXUNUSED(pDC
))
147 // we can't use pattern brushes because, apparently, the window proc of our
148 // class does something which invalidates the brush origin before drawing
149 // with it and so any patetrn brush is used incorrectly as can be seen by
150 // putting a static box inside a (themed) notebook
152 // so always use solid brush for painting the background (note that this
153 // only applies to the background of the box label, not the insides of the
155 return parent
->MSWGetSolidBgBrushForChild(this);
158 #endif // wxUSE_STATBOX