class WXDLLEXPORT wxDCPenChanger
{
public:
- wxDCPenChanger(wxDC& dc) : m_dc(dc), m_penOld() { }
+ wxDCPenChanger(wxDC& dc, const wxPen& pen) : m_dc(dc), m_penOld(dc.GetPen())
+ {
+ m_dc.SetPen(pen);
+ }
~wxDCPenChanger()
{
m_dc.SetPen(m_penOld);
}
- void Set(const wxPen& pen)
- {
- if ( !m_penOld.Ok() )
- m_penOld = m_dc.GetPen();
- m_dc.SetPen(pen);
- }
-
private:
wxDC& m_dc;
class WXDLLEXPORT wxDCBrushChanger
{
public:
- wxDCBrushChanger(wxDC& dc) : m_dc(dc), m_brushOld() { }
+ wxDCBrushChanger(wxDC& dc, const wxBrush& brush) : m_dc(dc), m_brushOld(dc.GetBrush())
+ {
+ m_dc.SetBrush(brush);
+ }
~wxDCBrushChanger()
{
m_dc.SetBrush(m_brushOld);
}
- void Set(const wxBrush& brush)
- {
- if ( !m_brushOld.Ok() )
- m_brushOld = m_dc.GetBrush();
- m_dc.SetBrush(brush);
- }
-
private:
wxDC& m_dc;
int flags)
{
// store settings
- wxDCPenChanger penChanger(dc);
- wxDCBrushChanger brushChanger(dc);
-
- // white background
- penChanger.Set(*wxGREY_PEN);
- brushChanger.Set(*wxWHITE_BRUSH);
+ wxDCPenChanger penChanger(dc, *wxGREY_PEN);
+ wxDCBrushChanger brushChanger(dc, *wxWHITE_BRUSH);
dc.DrawRectangle(rect);