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