]> git.saurik.com Git - wxWidgets.git/blame - src/motif/brush.cpp
Added GSocket motif (it compiles but I didn't tested it)
[wxWidgets.git] / src / motif / brush.cpp
CommitLineData
4bb6408c
JS
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
20#if !USE_SHARED_LIBRARIES
21IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
22#endif
23
24wxBrushRefData::wxBrushRefData()
25{
26 m_style = wxSOLID;
4bb6408c
JS
27}
28
29wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
30{
2d120f83
JS
31 m_style = data.m_style;
32 m_stipple = data.m_stipple;
33 m_colour = data.m_colour;
4bb6408c
JS
34}
35
36wxBrushRefData::~wxBrushRefData()
37{
4bb6408c
JS
38}
39
40// Brushes
41wxBrush::wxBrush()
42{
43 if ( wxTheBrushList )
44 wxTheBrushList->AddBrush(this);
45}
46
47wxBrush::~wxBrush()
48{
49 if ( wxTheBrushList )
50 wxTheBrushList->RemoveBrush(this);
51}
52
53wxBrush::wxBrush(const wxColour& col, int Style)
54{
55 m_refData = new wxBrushRefData;
2d120f83 56
4bb6408c
JS
57 M_BRUSHDATA->m_colour = col;
58 M_BRUSHDATA->m_style = Style;
2d120f83 59
4bb6408c 60 RealizeResource();
2d120f83 61
4bb6408c
JS
62 if ( wxTheBrushList )
63 wxTheBrushList->AddBrush(this);
64}
65
4bb6408c
JS
66wxBrush::wxBrush(const wxBitmap& stipple)
67{
68 m_refData = new wxBrushRefData;
2d120f83 69
4bb6408c
JS
70 M_BRUSHDATA->m_style = wxSTIPPLE;
71 M_BRUSHDATA->m_stipple = stipple;
2d120f83 72
4bb6408c 73 RealizeResource();
2d120f83 74
4bb6408c
JS
75 if ( wxTheBrushList )
76 wxTheBrushList->AddBrush(this);
77}
78
79void wxBrush::Unshare()
80{
2d120f83
JS
81 // Don't change shared data
82 if (!m_refData)
4bb6408c 83 {
2d120f83
JS
84 m_refData = new wxBrushRefData();
85 }
4bb6408c
JS
86 else
87 {
2d120f83
JS
88 wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
89 UnRef();
90 m_refData = ref;
91 }
4bb6408c
JS
92}
93
94void wxBrush::SetColour(const wxColour& col)
95{
96 Unshare();
2d120f83 97
4bb6408c 98 M_BRUSHDATA->m_colour = col;
2d120f83 99
4bb6408c
JS
100 RealizeResource();
101}
102
e4a81a2e 103void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
4bb6408c
JS
104{
105 Unshare();
2d120f83 106
4bb6408c 107 M_BRUSHDATA->m_colour.Set(r, g, b);
2d120f83 108
4bb6408c
JS
109 RealizeResource();
110}
111
112void wxBrush::SetStyle(int Style)
113{
114 Unshare();
2d120f83 115
4bb6408c 116 M_BRUSHDATA->m_style = Style;
2d120f83 117
4bb6408c
JS
118 RealizeResource();
119}
120
121void wxBrush::SetStipple(const wxBitmap& Stipple)
122{
123 Unshare();
2d120f83 124
4bb6408c 125 M_BRUSHDATA->m_stipple = Stipple;
2d120f83 126
4bb6408c
JS
127 RealizeResource();
128}
129
dfc54541 130bool wxBrush::RealizeResource()
4bb6408c 131{
dfc54541
JS
132 // Nothing more to do
133 return TRUE;
4bb6408c
JS
134}
135