]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk1/brush.cpp
added wxTextEntry::AutoComplete() and implemented it for wxGTK
[wxWidgets.git] / src / gtk1 / brush.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/gtk1/brush.cpp
3// Purpose:
4// Author: Robert Roebling
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
13#include "wx/brush.h"
14
15#ifndef WX_PRECOMP
16 #include "wx/colour.h"
17#endif
18
19#include <gdk/gdk.h>
20
21//-----------------------------------------------------------------------------
22// wxBrush
23//-----------------------------------------------------------------------------
24
25class wxBrushRefData: public wxObjectRefData
26{
27public:
28 wxBrushRefData()
29 {
30 m_style = 0;
31 }
32
33 wxBrushRefData( const wxBrushRefData& data )
34 : wxObjectRefData()
35 {
36 m_style = data.m_style;
37 m_stipple = data.m_stipple;
38 m_colour = data.m_colour;
39 }
40
41 bool operator == (const wxBrushRefData& data) const
42 {
43 return (m_style == data.m_style &&
44 m_stipple.IsSameAs(data.m_stipple) &&
45 m_colour == data.m_colour);
46 }
47
48 int m_style;
49 wxColour m_colour;
50 wxBitmap m_stipple;
51};
52
53//-----------------------------------------------------------------------------
54
55#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
56
57IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject)
58
59wxBrush::wxBrush( const wxColour &colour, int style )
60{
61 m_refData = new wxBrushRefData();
62 M_BRUSHDATA->m_style = style;
63 M_BRUSHDATA->m_colour = colour;
64}
65
66wxBrush::wxBrush( const wxBitmap &stippleBitmap )
67{
68 m_refData = new wxBrushRefData();
69 M_BRUSHDATA->m_colour = *wxBLACK;
70
71 M_BRUSHDATA->m_stipple = stippleBitmap;
72
73 if (M_BRUSHDATA->m_stipple.GetMask())
74 M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
75 else
76 M_BRUSHDATA->m_style = wxSTIPPLE;
77}
78
79wxBrush::~wxBrush()
80{
81 // m_refData unrefed in ~wxObject
82}
83
84wxObjectRefData *wxBrush::CreateRefData() const
85{
86 return new wxBrushRefData;
87}
88
89wxObjectRefData *wxBrush::CloneRefData(const wxObjectRefData *data) const
90{
91 return new wxBrushRefData(*(wxBrushRefData *)data);
92}
93
94bool wxBrush::operator == ( const wxBrush& brush ) const
95{
96 if (m_refData == brush.m_refData) return true;
97
98 if (!m_refData || !brush.m_refData) return false;
99
100 return ( *(wxBrushRefData*)m_refData == *(wxBrushRefData*)brush.m_refData );
101}
102
103int wxBrush::GetStyle() const
104{
105 if (m_refData == NULL)
106 {
107 wxFAIL_MSG( wxT("invalid brush") );
108 return 0;
109 }
110
111 return M_BRUSHDATA->m_style;
112}
113
114wxColour &wxBrush::GetColour() const
115{
116 if (m_refData == NULL)
117 {
118 wxFAIL_MSG( wxT("invalid brush") );
119 return wxNullColour;
120 }
121
122 return M_BRUSHDATA->m_colour;
123}
124
125wxBitmap *wxBrush::GetStipple() const
126{
127 if (m_refData == NULL)
128 {
129 wxFAIL_MSG( wxT("invalid brush") );
130 return &wxNullBitmap;
131 }
132
133 return &M_BRUSHDATA->m_stipple;
134}
135
136void wxBrush::SetColour( const wxColour& col )
137{
138 AllocExclusive();
139
140 M_BRUSHDATA->m_colour = col;
141}
142
143void wxBrush::SetColour( unsigned char r, unsigned char g, unsigned char b )
144{
145 AllocExclusive();
146
147 M_BRUSHDATA->m_colour.Set( r, g, b );
148}
149
150void wxBrush::SetStyle( int style )
151{
152 AllocExclusive();
153
154 M_BRUSHDATA->m_style = style;
155}
156
157void wxBrush::SetStipple( const wxBitmap& stipple )
158{
159 AllocExclusive();
160
161 M_BRUSHDATA->m_stipple = stipple;
162 if (M_BRUSHDATA->m_stipple.GetMask())
163 {
164 M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
165 }
166 else
167 {
168 M_BRUSHDATA->m_style = wxSTIPPLE;
169 }
170}