]> git.saurik.com Git - wxWidgets.git/blame - src/os2/brush.cpp
added SpinCtrl,
[wxWidgets.git] / src / os2 / brush.cpp
CommitLineData
0e320a79
DW
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
20#if !USE_SHARED_LIBRARIES
21IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
22#endif
23
24wxBrushRefData::wxBrushRefData()
25{
26 m_style = wxSOLID;
27// TODO: null data
28}
29
30wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
31{
32 m_style = data.m_style;
33 m_stipple = data.m_stipple;
34 m_colour = data.m_colour;
35/* TODO: null data
36 m_hBrush = 0;
37*/
38}
39
40wxBrushRefData::~wxBrushRefData()
41{
42// TODO: delete data
43}
44
45// Brushes
46wxBrush::wxBrush()
47{
48 if ( wxTheBrushList )
49 wxTheBrushList->AddBrush(this);
50}
51
52wxBrush::~wxBrush()
53{
54 if ( wxTheBrushList )
55 wxTheBrushList->RemoveBrush(this);
56}
57
58wxBrush::wxBrush(const wxColour& col, int Style)
59{
60 m_refData = new wxBrushRefData;
61
62 M_BRUSHDATA->m_colour = col;
63 M_BRUSHDATA->m_style = Style;
64
65 RealizeResource();
66
67 if ( wxTheBrushList )
68 wxTheBrushList->AddBrush(this);
69}
70
71wxBrush::wxBrush(const wxBitmap& stipple)
72{
73 m_refData = new wxBrushRefData;
74
75 M_BRUSHDATA->m_style = wxSTIPPLE;
76 M_BRUSHDATA->m_stipple = stipple;
77
78 RealizeResource();
79
80 if ( wxTheBrushList )
81 wxTheBrushList->AddBrush(this);
82}
83
0e320a79
DW
84
85void wxBrush::SetColour(const wxColour& col)
86{
87 Unshare();
88
89 M_BRUSHDATA->m_colour = col;
90
91 RealizeResource();
92}
93
94void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
95{
96 Unshare();
97
98 M_BRUSHDATA->m_colour.Set(r, g, b);
99
100 RealizeResource();
101}
102
103void wxBrush::SetStyle(int Style)
104{
105 Unshare();
106
107 M_BRUSHDATA->m_style = Style;
108
109 RealizeResource();
110}
111
112void wxBrush::SetStipple(const wxBitmap& Stipple)
113{
114 Unshare();
115
116 M_BRUSHDATA->m_stipple = Stipple;
117
118 RealizeResource();
119}
120
121bool wxBrush::RealizeResource()
122{
123// TODO: create the brush
124 return FALSE;
125}
126
fb9010ed
DW
127WXHANDLE wxBrush::GetResourceHandle(void)
128{
129 return (WXHANDLE) M_BRUSHDATA->m_hBrush;
130}
131
132bool wxBrush::FreeResource(bool WXUNUSED(force))
133{
134 if (M_BRUSHDATA && (M_BRUSHDATA->m_hBrush != 0))
135 {
136// TODO DeleteObject((HBRUSH) M_BRUSHDATA->m_hBrush);
137 M_BRUSHDATA->m_hBrush = 0;
138 return TRUE;
139 }
140 else return FALSE;
141}
142
143bool wxBrush::IsFree() const
144{
145 return (M_BRUSHDATA && (M_BRUSHDATA->m_hBrush == 0));
146}
147
148void wxBrush::Unshare()
149{
150 // Don't change shared data
151 if (!m_refData)
152 {
153 m_refData = new wxBrushRefData();
154 }
155 else
156 {
157 wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
158 UnRef();
159 m_refData = ref;
160 }
161}
162