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