]> git.saurik.com Git - wxWidgets.git/blame - src/qt/brush.cpp
small fix for mingw32 compilation
[wxWidgets.git] / src / qt / brush.cpp
CommitLineData
7c78e7c7
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: brush.cpp
01b2eeec
KB
3// Purpose: wxBrush
4// Author: AUTHOR
5// Modified by:
6// Created: ??/??/98
7// RCS-ID: $Id$
8// Copyright: (c) AUTHOR
7c78e7c7
RR
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "brush.h"
14#endif
15
01b2eeec
KB
16#include "wx/setup.h"
17#include "wx/utils.h"
7c78e7c7
RR
18#include "wx/brush.h"
19
01b2eeec
KB
20#if !USE_SHARED_LIBRARIES
21IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
22#endif
7c78e7c7 23
01b2eeec 24wxBrushRefData::wxBrushRefData()
7c78e7c7 25{
01b2eeec
KB
26 m_style = wxSOLID;
27// TODO: null data
28}
7c78e7c7 29
01b2eeec 30wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
7c78e7c7 31{
01b2eeec
KB
32 m_style = data.m_style;
33 m_stipple = data.m_stipple;
34 m_colour = data.m_colour;
35/* TODO: null data
36 m_hBrush = 0;
37*/
38}
7c78e7c7 39
01b2eeec 40wxBrushRefData::~wxBrushRefData()
7c78e7c7 41{
01b2eeec
KB
42// TODO: delete data
43}
44
45// Brushes
46wxBrush::wxBrush()
7c78e7c7 47{
01b2eeec
KB
48 if ( wxTheBrushList )
49 wxTheBrushList->AddBrush(this);
50}
51
52wxBrush::~wxBrush()
7c78e7c7 53{
01b2eeec
KB
54 if ( wxTheBrushList )
55 wxTheBrushList->RemoveBrush(this);
56}
7c78e7c7 57
01b2eeec 58wxBrush::wxBrush(const wxColour& col, int Style)
7c78e7c7 59{
01b2eeec 60 m_refData = new wxBrushRefData;
7c78e7c7 61
01b2eeec
KB
62 M_BRUSHDATA->m_colour = col;
63 M_BRUSHDATA->m_style = Style;
64
65 RealizeResource();
66
67 if ( wxTheBrushList )
68 wxTheBrushList->AddBrush(this);
69}
70
71wxBrush::wxBrush(const wxString& col, int Style)
7c78e7c7 72{
01b2eeec
KB
73 m_refData = new wxBrushRefData;
74
75 // Implicit conversion from string to wxColour via colour database
76 M_BRUSHDATA->m_colour = col;
77 M_BRUSHDATA->m_style = Style;
7c78e7c7 78
01b2eeec
KB
79 RealizeResource();
80
81 if ( wxTheBrushList )
82 wxTheBrushList->AddBrush(this);
83}
84
85wxBrush::wxBrush(const wxBitmap& stipple)
7c78e7c7 86{
01b2eeec
KB
87 m_refData = new wxBrushRefData;
88
89 M_BRUSHDATA->m_style = wxSTIPPLE;
90 M_BRUSHDATA->m_stipple = stipple;
91
92 RealizeResource();
93
94 if ( wxTheBrushList )
95 wxTheBrushList->AddBrush(this);
96}
97
98void wxBrush::Unshare()
7c78e7c7 99{
01b2eeec
KB
100 // Don't change shared data
101 if (!m_refData)
102 {
103 m_refData = new wxBrushRefData();
104 }
105 else
106 {
107 wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
108 UnRef();
109 m_refData = ref;
110 }
111}
7c78e7c7 112
01b2eeec 113void wxBrush::SetColour(const wxColour& col)
7c78e7c7 114{
01b2eeec
KB
115 Unshare();
116
117 M_BRUSHDATA->m_colour = col;
7c78e7c7 118
01b2eeec
KB
119 RealizeResource();
120}
121
122void wxBrush::SetColour(const wxString& col)
7c78e7c7 123{
01b2eeec
KB
124 Unshare();
125
126 M_BRUSHDATA->m_colour = col;
127
128 RealizeResource();
129}
7c78e7c7 130
01b2eeec 131void wxBrush::SetColour(const unsigned char r, const unsigned char g, const unsigned char b)
7c78e7c7 132{
01b2eeec 133 Unshare();
7c78e7c7 134
01b2eeec
KB
135 M_BRUSHDATA->m_colour.Set(r, g, b);
136
137 RealizeResource();
138}
139
140void wxBrush::SetStyle(int Style)
7c78e7c7 141{
01b2eeec
KB
142 Unshare();
143
144 M_BRUSHDATA->m_style = Style;
145
146 RealizeResource();
147}
7c78e7c7 148
01b2eeec 149void wxBrush::SetStipple(const wxBitmap& Stipple)
7c78e7c7 150{
01b2eeec 151 Unshare();
7c78e7c7 152
01b2eeec
KB
153 M_BRUSHDATA->m_stipple = Stipple;
154
155 RealizeResource();
156}
157
158void wxBrush::RealizeResource()
159{
160// TODO: create the brush
161}
7c78e7c7 162