]> git.saurik.com Git - wxWidgets.git/blame - src/dfb/pen.cpp
remove leading dots from .ini/.conf in AddConfFileExtIfNeeded() as this results in...
[wxWidgets.git] / src / dfb / pen.cpp
CommitLineData
b3c86150
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/dfb/pen.cpp
3// Purpose: wxPen class implementation
4// Author: Vaclav Slavik
5// Created: 2006-08-04
6// RCS-ID: $Id$
7// Copyright: (c) 2006 REA Elektronik GmbH
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11// For compilers that support precompilation, includes "wx.h".
12#include "wx/wxprec.h"
13
14#ifdef __BORLANDC__
15 #pragma hdrstop
16#endif
17
18#include "wx/pen.h"
19
20#ifndef WX_PRECOMP
21 #include "wx/bitmap.h"
22 #include "wx/colour.h"
23#endif
24
25//-----------------------------------------------------------------------------
26// wxPen
27//-----------------------------------------------------------------------------
28
8f884a0d 29class wxPenRefData : public wxGDIRefData
b3c86150
VS
30{
31public:
32 wxPenRefData(const wxColour& clr = wxNullColour, int style = wxSOLID)
33 {
34 m_colour = clr;
35 SetStyle(style);
36 }
37
38 wxPenRefData(const wxPenRefData& data)
39 : m_style(data.m_style), m_colour(data.m_colour) {}
40
8f884a0d
VZ
41 virtual bool IsOk() const { return m_colour.IsOk(); }
42
b3c86150
VS
43 void SetStyle(int style)
44 {
e17cd59f 45 if ( style != wxSOLID && style != wxTRANSPARENT )
b3c86150 46 {
a5001e93 47 wxFAIL_MSG( "only wxSOLID and wxTRANSPARENT styles are supported" );
b3c86150
VS
48 style = wxSOLID;
49 }
50
51 m_style = style;
52 }
53
54 int m_style;
55 wxColour m_colour;
56};
57
58//-----------------------------------------------------------------------------
59
60#define M_PENDATA ((wxPenRefData *)m_refData)
61
62IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
63
64wxPen::wxPen(const wxColour &colour, int width, int style)
65{
a5001e93 66 wxASSERT_MSG( width <= 1, "only width=0,1 are supported" );
b3c86150
VS
67
68 m_refData = new wxPenRefData(colour, style);
69}
70
71wxPen::wxPen(const wxBitmap& WXUNUSED(stipple), int WXUNUSED(width))
72{
a5001e93 73 wxFAIL_MSG( "stipple pens not supported" );
b3c86150
VS
74
75 m_refData = new wxPenRefData();
76}
77
78bool wxPen::operator==(const wxPen& pen) const
79{
80#warning "this is incorrect (MGL too)"
81 return m_refData == pen.m_refData;
82}
83
84void wxPen::SetColour(const wxColour &colour)
85{
86 AllocExclusive();
87 M_PENDATA->m_colour = colour;
88}
89
90void wxPen::SetDashes(int WXUNUSED(number_of_dashes), const wxDash *WXUNUSED(dash))
91{
a5001e93 92 wxFAIL_MSG( "SetDashes not implemented" );
b3c86150
VS
93}
94
95void wxPen::SetColour(unsigned char red, unsigned char green, unsigned char blue)
96{
97 AllocExclusive();
98 M_PENDATA->m_colour.Set(red, green, blue);
99}
100
101void wxPen::SetCap(int WXUNUSED(capStyle))
102{
a5001e93 103 wxFAIL_MSG( "SetCap not implemented" );
b3c86150
VS
104}
105
106void wxPen::SetJoin(int WXUNUSED(joinStyle))
107{
a5001e93 108 wxFAIL_MSG( "SetJoin not implemented" );
b3c86150
VS
109}
110
111void wxPen::SetStyle(int style)
112{
113 AllocExclusive();
114 M_PENDATA->SetStyle(style);
115}
116
117void wxPen::SetStipple(const wxBitmap& WXUNUSED(stipple))
118{
a5001e93 119 wxFAIL_MSG( "SetStipple not implemented" );
b3c86150
VS
120}
121
122void wxPen::SetWidth(int width)
123{
a5001e93 124 wxASSERT_MSG( width <= 1, "only width=0,1 are implemented" );
b3c86150
VS
125}
126
127int wxPen::GetDashes(wxDash **ptr) const
128{
a5001e93 129 wxFAIL_MSG( "GetDashes not implemented" );
b3c86150
VS
130
131 *ptr = NULL;
132 return 0;
133}
134
135int wxPen::GetDashCount() const
136{
a5001e93 137 wxFAIL_MSG( "GetDashCount not implemented" );
b3c86150
VS
138
139 return 0;
140}
141
142wxDash* wxPen::GetDash() const
143{
a5001e93 144 wxFAIL_MSG( "GetDash not implemented" );
b3c86150
VS
145
146 return NULL;
147}
148
149int wxPen::GetCap() const
150{
151 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
152
a5001e93 153 wxFAIL_MSG( "GetCap not implemented" );
b3c86150
VS
154 return -1;
155}
156
157int wxPen::GetJoin() const
158{
159 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
160
a5001e93 161 wxFAIL_MSG( "GetJoin not implemented" );
b3c86150
VS
162 return -1;
163}
164
165int wxPen::GetStyle() const
166{
167 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
168
169 return M_PENDATA->m_style;
170}
171
172int wxPen::GetWidth() const
173{
174 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
175
176 return 1;
177}
178
179wxColour &wxPen::GetColour() const
180{
181 wxCHECK_MSG( Ok(), wxNullColour, wxT("invalid pen") );
182
183 return M_PENDATA->m_colour;
184}
185
186wxBitmap *wxPen::GetStipple() const
187{
188 wxCHECK_MSG( Ok(), NULL, wxT("invalid pen") );
189
a5001e93 190 wxFAIL_MSG( "GetStipple not implemented" );
b3c86150
VS
191 return NULL;
192}
193
8f884a0d 194wxGDIRefData *wxPen::CreateGDIRefData() const
b3c86150
VS
195{
196 return new wxPenRefData;
197}
198
8f884a0d 199wxGDIRefData *wxPen::CloneGDIRefData(const wxGDIRefData *data) const
b3c86150
VS
200{
201 return new wxPenRefData(*(wxPenRefData *)data);
202}