]> git.saurik.com Git - wxWidgets.git/blob - src/dfb/brush.cpp
Don't set even try to set focus to wxPopupWindow itself in wxMSW.
[wxWidgets.git] / src / dfb / brush.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/brush.cpp
3 // Purpose: wxBrush class implementation
4 // Author: Vaclav Slavik
5 // Created: 2006-08-04
6 // Copyright: (c) 2006 REA Elektronik GmbH
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
12
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16
17 #include "wx/brush.h"
18
19 #ifndef WX_PRECOMP
20 #include "wx/colour.h"
21 #endif
22
23
24 //-----------------------------------------------------------------------------
25 // wxBrush
26 //-----------------------------------------------------------------------------
27
28 class wxBrushRefData : public wxGDIRefData
29 {
30 public:
31 wxBrushRefData(const wxColour& clr = wxNullColour, wxBrushStyle style = wxBRUSHSTYLE_SOLID)
32 {
33 m_colour = clr;
34 SetStyle(style);
35 }
36
37 wxBrushRefData(const wxBrushRefData& data)
38 {
39 m_colour = data.m_colour;
40 m_style = data.m_style;
41 }
42
43 virtual bool IsOk() const { return m_colour.IsOk(); }
44
45 void SetStyle(wxBrushStyle style)
46 {
47 if ( style != wxSOLID && style != wxTRANSPARENT )
48 {
49 wxFAIL_MSG( wxT("only wxSOLID and wxTRANSPARENT styles are supported") );
50 style = wxBRUSHSTYLE_SOLID;
51 }
52
53 m_style = style;
54 }
55
56 wxColour m_colour;
57 wxBrushStyle m_style;
58 };
59
60 //-----------------------------------------------------------------------------
61
62 #define M_BRUSHDATA ((wxBrushRefData *)m_refData)
63
64 IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
65
66 wxBrush::wxBrush(const wxColour &colour, wxBrushStyle style)
67 {
68 m_refData = new wxBrushRefData(colour, style);
69 }
70
71 #if FUTURE_WXWIN_COMPATIBILITY_3_0
72 wxBrush::wxBrush(const wxColour& col, int style)
73 {
74 m_refData = new wxBrushRefData(col, (wxBrushStyle)style);
75 }
76 #endif
77
78 wxBrush::wxBrush(const wxBitmap &stippleBitmap)
79 {
80 wxFAIL_MSG( wxT("brushes with stipple bitmaps not implemented") );
81
82 m_refData = new wxBrushRefData(*wxBLACK);
83 }
84
85 bool wxBrush::operator==(const wxBrush& brush) const
86 {
87 #warning "this is incorrect"
88 return m_refData == brush.m_refData;
89 }
90
91 wxBrushStyle wxBrush::GetStyle() const
92 {
93 wxCHECK_MSG( IsOk(), wxBRUSHSTYLE_INVALID, wxT("invalid brush") );
94
95 return M_BRUSHDATA->m_style;
96 }
97
98 wxColour wxBrush::GetColour() const
99 {
100 wxCHECK_MSG( IsOk(), wxNullColour, wxT("invalid brush") );
101
102 return M_BRUSHDATA->m_colour;
103 }
104
105 wxBitmap *wxBrush::GetStipple() const
106 {
107 wxFAIL_MSG( wxT("brushes with stipple bitmaps not implemented") );
108 return &wxNullBitmap;
109 }
110
111 void wxBrush::SetColour(const wxColour& col)
112 {
113 AllocExclusive();
114 M_BRUSHDATA->m_colour = col;
115 }
116
117 void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
118 {
119 AllocExclusive();
120 M_BRUSHDATA->m_colour.Set(r, g, b);
121 }
122
123 void wxBrush::SetStyle(wxBrushStyle style)
124 {
125 AllocExclusive();
126 M_BRUSHDATA->SetStyle(style);
127 }
128
129 void wxBrush::SetStipple(const wxBitmap& WXUNUSED(stipple))
130 {
131 wxFAIL_MSG( wxT("brushes with stipple bitmaps not implemented") );
132 }
133
134 wxGDIRefData *wxBrush::CreateGDIRefData() const
135 {
136 return new wxBrushRefData;
137 }
138
139 wxGDIRefData *wxBrush::CloneGDIRefData(const wxGDIRefData *data) const
140 {
141 return new wxBrushRefData(*(wxBrushRefData *)data);
142 }