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