]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/motif/brush.cpp
Mac-ify wxTreeCtrl further.
[wxWidgets.git] / src / motif / brush.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: brush.cpp
3// Purpose: wxBrush
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
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}
26
27wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
28{
29 m_style = data.m_style;
30 m_stipple = data.m_stipple;
31 m_colour = data.m_colour;
32}
33
34wxBrushRefData::~wxBrushRefData()
35{
36}
37
38// Brushes
39wxBrush::wxBrush()
40{
41 if ( wxTheBrushList )
42 wxTheBrushList->AddBrush(this);
43}
44
45wxBrush::~wxBrush()
46{
47 if ( wxTheBrushList )
48 wxTheBrushList->RemoveBrush(this);
49}
50
51wxBrush::wxBrush(const wxColour& col, int Style)
52{
53 m_refData = new wxBrushRefData;
54
55 M_BRUSHDATA->m_colour = col;
56 M_BRUSHDATA->m_style = Style;
57
58 RealizeResource();
59
60 if ( wxTheBrushList )
61 wxTheBrushList->AddBrush(this);
62}
63
64wxBrush::wxBrush(const wxBitmap& stipple)
65{
66 m_refData = new wxBrushRefData;
67
68 M_BRUSHDATA->m_style = wxSTIPPLE;
69 M_BRUSHDATA->m_stipple = stipple;
70
71 RealizeResource();
72
73 if ( wxTheBrushList )
74 wxTheBrushList->AddBrush(this);
75}
76
77void wxBrush::Unshare()
78{
79 // Don't change shared data
80 if (!m_refData)
81 {
82 m_refData = new wxBrushRefData();
83 }
84 else
85 {
86 wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
87 UnRef();
88 m_refData = ref;
89 }
90}
91
92void wxBrush::SetColour(const wxColour& col)
93{
94 Unshare();
95
96 M_BRUSHDATA->m_colour = col;
97
98 RealizeResource();
99}
100
101void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
102{
103 Unshare();
104
105 M_BRUSHDATA->m_colour.Set(r, g, b);
106
107 RealizeResource();
108}
109
110void wxBrush::SetStyle(int Style)
111{
112 Unshare();
113
114 M_BRUSHDATA->m_style = Style;
115
116 RealizeResource();
117}
118
119void wxBrush::SetStipple(const wxBitmap& Stipple)
120{
121 Unshare();
122
123 M_BRUSHDATA->m_stipple = Stipple;
124
125 RealizeResource();
126}
127
128bool wxBrush::RealizeResource()
129{
130 // Nothing more to do
131 return TRUE;
132}
133