User | Revision | Line number | New contents of line |
sca8er |
3:0c3bcea5b4d0
|
1
|
/*
|
sca8er |
3:0c3bcea5b4d0
|
2
|
* gdiplusbrush.h
|
sca8er |
3:0c3bcea5b4d0
|
3
|
*
|
sca8er |
3:0c3bcea5b4d0
|
4
|
* GDI+ brush classes
|
sca8er |
3:0c3bcea5b4d0
|
5
|
*
|
sca8er |
3:0c3bcea5b4d0
|
6
|
* This file is part of the w32api package.
|
sca8er |
3:0c3bcea5b4d0
|
7
|
*
|
sca8er |
3:0c3bcea5b4d0
|
8
|
* Contributors:
|
sca8er |
3:0c3bcea5b4d0
|
9
|
* Created by Markus Koenig <markus@stber-koenig.de>
|
sca8er |
3:0c3bcea5b4d0
|
10
|
*
|
sca8er |
3:0c3bcea5b4d0
|
11
|
* THIS SOFTWARE IS NOT COPYRIGHTED
|
sca8er |
3:0c3bcea5b4d0
|
12
|
*
|
sca8er |
3:0c3bcea5b4d0
|
13
|
* This source code is offered for use in the public domain. You may
|
sca8er |
3:0c3bcea5b4d0
|
14
|
* use, modify or distribute it freely.
|
sca8er |
3:0c3bcea5b4d0
|
15
|
*
|
sca8er |
3:0c3bcea5b4d0
|
16
|
* This code is distributed in the hope that it will be useful but
|
sca8er |
3:0c3bcea5b4d0
|
17
|
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
sca8er |
3:0c3bcea5b4d0
|
18
|
* DISCLAIMED. This includes but is not limited to warranties of
|
sca8er |
3:0c3bcea5b4d0
|
19
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
sca8er |
3:0c3bcea5b4d0
|
20
|
*
|
sca8er |
3:0c3bcea5b4d0
|
21
|
*/
|
sca8er |
3:0c3bcea5b4d0
|
22
|
|
sca8er |
3:0c3bcea5b4d0
|
23
|
#ifndef __GDIPLUS_BRUSH_H
|
sca8er |
3:0c3bcea5b4d0
|
24
|
#define __GDIPLUS_BRUSH_H
|
sca8er |
3:0c3bcea5b4d0
|
25
|
#if __GNUC__ >=3
|
sca8er |
3:0c3bcea5b4d0
|
26
|
#pragma GCC system_header
|
sca8er |
3:0c3bcea5b4d0
|
27
|
#endif
|
sca8er |
3:0c3bcea5b4d0
|
28
|
|
sca8er |
3:0c3bcea5b4d0
|
29
|
#ifndef __cplusplus
|
sca8er |
3:0c3bcea5b4d0
|
30
|
#error "A C++ compiler is required to include gdiplusbrush.h."
|
sca8er |
3:0c3bcea5b4d0
|
31
|
#endif
|
sca8er |
3:0c3bcea5b4d0
|
32
|
|
sca8er |
3:0c3bcea5b4d0
|
33
|
class Brush: public GdiplusBase
|
sca8er |
3:0c3bcea5b4d0
|
34
|
{
|
sca8er |
3:0c3bcea5b4d0
|
35
|
friend class HatchBrush;
|
sca8er |
3:0c3bcea5b4d0
|
36
|
friend class LinearGradientBrush;
|
sca8er |
3:0c3bcea5b4d0
|
37
|
friend class PathGradientBrush;
|
sca8er |
3:0c3bcea5b4d0
|
38
|
friend class SolidBrush;
|
sca8er |
3:0c3bcea5b4d0
|
39
|
friend class TextureBrush;
|
sca8er |
3:0c3bcea5b4d0
|
40
|
friend class Graphics;
|
sca8er |
3:0c3bcea5b4d0
|
41
|
friend class Pen;
|
sca8er |
3:0c3bcea5b4d0
|
42
|
|
sca8er |
3:0c3bcea5b4d0
|
43
|
public:
|
sca8er |
3:0c3bcea5b4d0
|
44
|
virtual ~Brush()
|
sca8er |
3:0c3bcea5b4d0
|
45
|
{
|
sca8er |
3:0c3bcea5b4d0
|
46
|
DllExports::GdipDeleteBrush(nativeBrush);
|
sca8er |
3:0c3bcea5b4d0
|
47
|
}
|
sca8er |
3:0c3bcea5b4d0
|
48
|
virtual Brush* Clone() const // each subclass must implement this
|
sca8er |
3:0c3bcea5b4d0
|
49
|
{
|
sca8er |
3:0c3bcea5b4d0
|
50
|
lastStatus = NotImplemented;
|
sca8er |
3:0c3bcea5b4d0
|
51
|
return NULL;
|
sca8er |
3:0c3bcea5b4d0
|
52
|
}
|
sca8er |
3:0c3bcea5b4d0
|
53
|
|
sca8er |
3:0c3bcea5b4d0
|
54
|
Status GetLastStatus() const
|
sca8er |
3:0c3bcea5b4d0
|
55
|
{
|
sca8er |
3:0c3bcea5b4d0
|
56
|
Status result = lastStatus;
|
sca8er |
3:0c3bcea5b4d0
|
57
|
lastStatus = Ok;
|
sca8er |
3:0c3bcea5b4d0
|
58
|
return result;
|
sca8er |
3:0c3bcea5b4d0
|
59
|
}
|
sca8er |
3:0c3bcea5b4d0
|
60
|
BrushType GetType() const
|
sca8er |
3:0c3bcea5b4d0
|
61
|
{
|
sca8er |
3:0c3bcea5b4d0
|
62
|
BrushType result = BrushTypeSolidColor;
|
sca8er |
3:0c3bcea5b4d0
|
63
|
updateStatus(DllExports::GdipGetBrushType(nativeBrush, &result));
|
sca8er |
3:0c3bcea5b4d0
|
64
|
return result;
|
sca8er |
3:0c3bcea5b4d0
|
65
|
}
|
sca8er |
3:0c3bcea5b4d0
|
66
|
|
sca8er |
3:0c3bcea5b4d0
|
67
|
private:
|
sca8er |
3:0c3bcea5b4d0
|
68
|
Brush(): nativeBrush(NULL), lastStatus(Ok) {}
|
sca8er |
3:0c3bcea5b4d0
|
69
|
Brush(GpBrush *brush, Status status):
|
sca8er |
3:0c3bcea5b4d0
|
70
|
nativeBrush(brush), lastStatus(status) {}
|
sca8er |
3:0c3bcea5b4d0
|
71
|
Brush(const Brush& brush);
|
sca8er |
3:0c3bcea5b4d0
|
72
|
Brush& operator=(const Brush&);
|
sca8er |
3:0c3bcea5b4d0
|
73
|
|
sca8er |
3:0c3bcea5b4d0
|
74
|
Status updateStatus(Status newStatus) const
|
sca8er |
3:0c3bcea5b4d0
|
75
|
{
|
sca8er |
3:0c3bcea5b4d0
|
76
|
if (newStatus != Ok) lastStatus = newStatus;
|
sca8er |
3:0c3bcea5b4d0
|
77
|
return newStatus;
|
sca8er |
3:0c3bcea5b4d0
|
78
|
}
|
sca8er |
3:0c3bcea5b4d0
|
79
|
|
sca8er |
3:0c3bcea5b4d0
|
80
|
GpBrush *nativeBrush;
|
sca8er |
3:0c3bcea5b4d0
|
81
|
mutable Status lastStatus;
|
sca8er |
3:0c3bcea5b4d0
|
82
|
};
|
sca8er |
3:0c3bcea5b4d0
|
83
|
|
sca8er |
3:0c3bcea5b4d0
|
84
|
class HatchBrush: public Brush
|
sca8er |
3:0c3bcea5b4d0
|
85
|
{
|
sca8er |
3:0c3bcea5b4d0
|
86
|
public:
|
sca8er |
3:0c3bcea5b4d0
|
87
|
HatchBrush(HatchStyle hatchStyle,
|
sca8er |
3:0c3bcea5b4d0
|
88
|
const Color& foreColor,
|
sca8er |
3:0c3bcea5b4d0
|
89
|
const Color& backColor = Color())
|
sca8er |
3:0c3bcea5b4d0
|
90
|
{
|
sca8er |
3:0c3bcea5b4d0
|
91
|
GpHatch *nativeHatch = NULL;
|
sca8er |
3:0c3bcea5b4d0
|
92
|
lastStatus = DllExports::GdipCreateHatchBrush(hatchStyle,
|
sca8er |
3:0c3bcea5b4d0
|
93
|
foreColor.GetValue(), backColor.GetValue(),
|
sca8er |
3:0c3bcea5b4d0
|
94
|
&nativeHatch);
|
sca8er |
3:0c3bcea5b4d0
|
95
|
nativeBrush = nativeHatch;
|
sca8er |
3:0c3bcea5b4d0
|
96
|
}
|
sca8er |
3:0c3bcea5b4d0
|
97
|
virtual HatchBrush* Clone() const
|
sca8er |
3:0c3bcea5b4d0
|
98
|
{
|
sca8er |
3:0c3bcea5b4d0
|
99
|
GpBrush *cloneBrush = NULL;
|
sca8er |
3:0c3bcea5b4d0
|
100
|
Status status = updateStatus(DllExports::GdipCloneBrush(
|
sca8er |
3:0c3bcea5b4d0
|
101
|
nativeBrush, &cloneBrush));
|
sca8er |
3:0c3bcea5b4d0
|
102
|
if (status == Ok) {
|
sca8er |
3:0c3bcea5b4d0
|
103
|
HatchBrush *result =
|
sca8er |
3:0c3bcea5b4d0
|
104
|
new HatchBrush(cloneBrush, lastStatus);
|
sca8er |
3:0c3bcea5b4d0
|
105
|
if (!result) {
|
sca8er |
3:0c3bcea5b4d0
|
106
|
DllExports::GdipDeleteBrush(cloneBrush);
|
sca8er |
3:0c3bcea5b4d0
|
107
|
updateStatus(OutOfMemory);
|
sca8er |
3:0c3bcea5b4d0
|
108
|
}
|
sca8er |
3:0c3bcea5b4d0
|
109
|
return result;
|
sca8er |
3:0c3bcea5b4d0
|
110
|
} else {
|
sca8er |
3:0c3bcea5b4d0
|
111
|
return NULL;
|
sca8er |
3:0c3bcea5b4d0
|
112
|
}
|
sca8er |
3:0c3bcea5b4d0
|
113
|
}
|
sca8er |
3:0c3bcea5b4d0
|
114
|
|
sca8er |
3:0c3bcea5b4d0
|
115
|
Status GetBackgroundColor(Color *color) const
|
sca8er |
3:0c3bcea5b4d0
|
116
|
{
|
sca8er |
3:0c3bcea5b4d0
|
117
|
return updateStatus(DllExports::GdipGetHatchBackgroundColor(
|
sca8er |
3:0c3bcea5b4d0
|
118
|
(GpHatch*) nativeBrush,
|
sca8er |
3:0c3bcea5b4d0
|
119
|
color ? &color->Value : NULL));
|
sca8er |
3:0c3bcea5b4d0
|
120
|
}
|
sca8er |
3:0c3bcea5b4d0
|
121
|
Status GetForegroundColor(Color *color) const
|
sca8er |
3:0c3bcea5b4d0
|
122
|
{
|
sca8er |
3:0c3bcea5b4d0
|
123
|
return updateStatus(DllExports::GdipGetHatchForegroundColor(
|
sca8er |
3:0c3bcea5b4d0
|
124
|
(GpHatch*) nativeBrush,
|
sca8er |
3:0c3bcea5b4d0
|
125
|
color ? &color->Value : NULL));
|
sca8er |
3:0c3bcea5b4d0
|
126
|
}
|
sca8er |
3:0c3bcea5b4d0
|
127
|
HatchStyle GetHatchStyle() const
|
sca8er |
3:0c3bcea5b4d0
|
128
|
{
|
sca8er |
3:0c3bcea5b4d0
|
129
|
HatchStyle result;
|
sca8er |
3:0c3bcea5b4d0
|
130
|
updateStatus(DllExports::GdipGetHatchStyle(
|
sca8er |
3:0c3bcea5b4d0
|
131
|
(GpHatch*) nativeBrush, &result));
|
sca8er |
3:0c3bcea5b4d0
|
132
|
return result;
|
sca8er |
3:0c3bcea5b4d0
|
133
|
}
|
sca8er |
3:0c3bcea5b4d0
|
134
|
|
sca8er |
3:0c3bcea5b4d0
|
135
|
private:
|
sca8er |
3:0c3bcea5b4d0
|
136
|
HatchBrush(GpBrush *brush, Status status): Brush(brush, status) {}
|
sca8er |
3:0c3bcea5b4d0
|
137
|
HatchBrush(const HatchBrush& brush);
|
sca8er |
3:0c3bcea5b4d0
|
138
|
HatchBrush& operator=(const HatchBrush&);
|
sca8er |
3:0c3bcea5b4d0
|
139
|
};
|
sca8er |
3:0c3bcea5b4d0
|
140
|
|
sca8er |
3:0c3bcea5b4d0
|
141
|
class LinearGradientBrush: public Brush
|
sca8er |
3:0c3bcea5b4d0
|
142
|
{
|
sca8er |
3:0c3bcea5b4d0
|
143
|
public:
|
sca8er |
3:0c3bcea5b4d0
|
144
|
LinearGradientBrush(const PointF& point1, const PointF& point2,
|
sca8er |
3:0c3bcea5b4d0
|
145
|
const Color& color1, const Color& color2)
|
sca8er |
3:0c3bcea5b4d0
|
146
|
{
|
sca8er |
3:0c3bcea5b4d0
|
147
|
GpLineGradient *nativeLineGradient = NULL;
|
sca8er |
3:0c3bcea5b4d0
|
148
|
lastStatus = DllExports::GdipCreateLineBrush(
|
sca8er |
3:0c3bcea5b4d0
|
149
|
&point1, &point2,
|
sca8er |
3:0c3bcea5b4d0
|
150
|
color1.GetValue(), color2.GetValue(),
|
sca8er |
3:0c3bcea5b4d0
|
151
|
WrapModeTile, &nativeLineGradient);
|
sca8er |
3:0c3bcea5b4d0
|
152
|
nativeBrush = nativeLineGradient;
|
sca8er |
3:0c3bcea5b4d0
|
153
|
}
|
sca8er |
3:0c3bcea5b4d0
|
154
|
LinearGradientBrush(const Point& point1, const Point& point2,
|
sca8er |
3:0c3bcea5b4d0
|
155
|
const Color& color1, const Color& color2)
|
sca8er |
3:0c3bcea5b4d0
|
156
|
{
|
sca8er |
3:0c3bcea5b4d0
|
157
|
GpLineGradient *nativeLineGradient = NULL;
|
sca8er |
3:0c3bcea5b4d0
|
158
|
lastStatus = DllExports::GdipCreateLineBrushI(
|
sca8er |
3:0c3bcea5b4d0
|
159
|
&point1, &point2,
|
sca8er |
3:0c3bcea5b4d0
|
160
|
color1.GetValue(), color2.GetValue(),
|
sca8er |
3:0c3bcea5b4d0
|
161
|
WrapModeTile, &nativeLineGradient);
|
sca8er |
3:0c3bcea5b4d0
|
162
|
nativeBrush = nativeLineGradient;
|
sca8er |
3:0c3bcea5b4d0
|
163
|
}
|
sca8er |
3:0c3bcea5b4d0
|
164
|
LinearGradientBrush(const RectF& rect, const Color& color1,
|
sca8er |
3:0c3bcea5b4d0
|
165
|
const Color& color2, LinearGradientMode mode)
|
sca8er |
3:0c3bcea5b4d0
|
166
|
{
|
sca8er |
3:0c3bcea5b4d0
|
167
|
GpLineGradient *nativeLineGradient = NULL;
|
sca8er |
3:0c3bcea5b4d0
|
168
|
lastStatus = DllExports::GdipCreateLineBrushFromRect(
|
sca8er |
3:0c3bcea5b4d0
|
169
|
&rect, color1.GetValue(), color2.GetValue(),
|
sca8er |
3:0c3bcea5b4d0
|
170
|
mode, WrapModeTile, &nativeLineGradient);
|
sca8er |
3:0c3bcea5b4d0
|
171
|
nativeBrush = nativeLineGradient;
|
sca8er |
3:0c3bcea5b4d0
|
172
|
}
|
sca8er |
3:0c3bcea5b4d0
|
173
|
LinearGradientBrush(const Rect& rect, const Color& color1,
|
sca8er |
3:0c3bcea5b4d0
|
174
|
const Color& color2, LinearGradientMode mode)
|
sca8er |
3:0c3bcea5b4d0
|
175
|
{
|
sca8er |
3:0c3bcea5b4d0
|
176
|
GpLineGradient *nativeLineGradient = NULL;
|
sca8er |
3:0c3bcea5b4d0
|
177
|
lastStatus = DllExports::GdipCreateLineBrushFromRectI(
|
sca8er |
3:0c3bcea5b4d0
|
178
|
&rect, color1.GetValue(), color2.GetValue(),
|
sca8er |
3:0c3bcea5b4d0
|
179
|
mode, WrapModeTile, &nativeLineGradient);
|
sca8er |
3:0c3bcea5b4d0
|
180
|
nativeBrush = nativeLineGradient;
|
sca8er |
3:0c3bcea5b4d0
|
181
|
}
|
sca8er |
3:0c3bcea5b4d0
|
182
|
LinearGradientBrush(const RectF& rect, const Color& color1,
|
sca8er |
3:0c3bcea5b4d0
|
183
|
const Color& color2, REAL angle,
|
sca8er |
3:0c3bcea5b4d0
|
184
|
BOOL isAngleScalable = FALSE)
|
sca8er |
3:0c3bcea5b4d0
|
185
|
{
|
sca8er |
3:0c3bcea5b4d0
|
186
|
GpLineGradient *nativeLineGradient = NULL;
|
sca8er |
3:0c3bcea5b4d0
|
187
|
lastStatus = DllExports::GdipCreateLineBrushFromRectWithAngle(
|
sca8er |
3:0c3bcea5b4d0
|
188
|
&rect, color1.GetValue(), color2.GetValue(),
|
sca8er |
3:0c3bcea5b4d0
|
189
|
angle, isAngleScalable, WrapModeTile,
|
sca8er |
3:0c3bcea5b4d0
|
190
|
&nativeLineGradient);
|
sca8er |
3:0c3bcea5b4d0
|
191
|
nativeBrush = nativeLineGradient;
|
sca8er |
3:0c3bcea5b4d0
|
192
|
}
|
sca8er |
3:0c3bcea5b4d0
|
193
|
LinearGradientBrush(const Rect& rect, const Color& color1,
|
sca8er |
3:0c3bcea5b4d0
|
194
|
const Color& color2, REAL angle,
|
sca8er |
3:0c3bcea5b4d0
|
195
|
BOOL isAngleScalable = FALSE)
|
sca8er |
3:0c3bcea5b4d0
|
196
|
{
|
sca8er |
3:0c3bcea5b4d0
|
197
|
GpLineGradient *nativeLineGradient = NULL;
|
sca8er |
3:0c3bcea5b4d0
|
198
|
lastStatus = DllExports::GdipCreateLineBrushFromRectWithAngleI(
|
sca8er |
3:0c3bcea5b4d0
|
199
|
&rect, color1.GetValue(), color2.GetValue(),
|
sca8er |
3:0c3bcea5b4d0
|
200
|
angle, isAngleScalable, WrapModeTile,
|
sca8er |
3:0c3bcea5b4d0
|
201
|
&nativeLineGradient);
|
sca8er |
3:0c3bcea5b4d0
|
202
|
nativeBrush = nativeLineGradient;
|
sca8er |
3:0c3bcea5b4d0
|
203
|
}
|
sca8er |
3:0c3bcea5b4d0
|
204
|
virtual LinearGradientBrush* Clone() const
|
sca8er |
3:0c3bcea5b4d0
|
205
|
{
|
sca8er |
3:0c3bcea5b4d0
|
206
|
GpBrush *cloneBrush = NULL;
|
sca8er |
3:0c3bcea5b4d0
|
207
|
Status status = updateStatus(DllExports::GdipCloneBrush(
|
sca8er |
3:0c3bcea5b4d0
|
208
|
nativeBrush, &cloneBrush));
|
sca8er |
3:0c3bcea5b4d0
|
209
|
if (status == Ok) {
|
sca8er |
3:0c3bcea5b4d0
|
210
|
LinearGradientBrush *result =
|
sca8er |
3:0c3bcea5b4d0
|
211
|
new LinearGradientBrush(cloneBrush, lastStatus);
|
sca8er |
3:0c3bcea5b4d0
|
212
|
if (!result) {
|
sca8er |
3:0c3bcea5b4d0
|
213
|
DllExports::GdipDeleteBrush(cloneBrush);
|
sca8er |
3:0c3bcea5b4d0
|
214
|
updateStatus(OutOfMemory);
|
sca8er |
3:0c3bcea5b4d0
|
215
|
}
|
sca8er |
3:0c3bcea5b4d0
|
216
|
return result;
|
sca8er |
3:0c3bcea5b4d0
|
217
|
} else {
|
sca8er |
3:0c3bcea5b4d0
|
218
|
return NULL;
|
sca8er |
3:0c3bcea5b4d0
|
219
|
}
|
sca8er |
3:0c3bcea5b4d0
|
220
|
}
|
sca8er |
3:0c3bcea5b4d0
|
221
|
|
sca8er |
3:0c3bcea5b4d0
|
222
|
Status GetBlend(REAL *blendFactors, REAL *blendPositions,
|
sca8er |
3:0c3bcea5b4d0
|
223
|
INT count) const
|
sca8er |
3:0c3bcea5b4d0
|
224
|
{
|
sca8er |
3:0c3bcea5b4d0
|
225
|
return updateStatus(DllExports::GdipGetLineBlend(
|
sca8er |
3:0c3bcea5b4d0
|
226
|
(GpLineGradient*) nativeBrush,
|
sca8er |
3:0c3bcea5b4d0
|
227
|
blendFactors, blendPositions, count));
|
sca8er |
3:0c3bcea5b4d0
|
228
|
}
|
sca8er |
3:0c3bcea5b4d0
|
229
|
INT GetBlendCount() const
|
sca8er |
3:0c3bcea5b4d0
|
230
|
{
|
sca8er |
3:0c3bcea5b4d0
|
231
|
INT result = 0;
|
sca8er |
3:0c3bcea5b4d0
|
232
|
updateStatus(DllExports::GdipGetLineBlendCount(
|
sca8er |
3:0c3bcea5b4d0
|
233
|
(GpLineGradient*) nativeBrush, &result));
|
sca8er |
3:0c3bcea5b4d0
|
234
|
return result;
|
sca8er |
3:0c3bcea5b4d0
|
235
|
}
|
sca8er |
3:0c3bcea5b4d0
|
236
|
BOOL GetGammaCorrection() const
|
sca8er |
3:0c3bcea5b4d0
|
237
|
{
|
sca8er |
3:0c3bcea5b4d0
|
238
|
BOOL result = FALSE;
|
sca8er |
3:0c3bcea5b4d0
|
239
|
updateStatus(DllExports::GdipGetLineGammaCorrection(
|
sca8er |
3:0c3bcea5b4d0
|
240
|
(GpLineGradient*) nativeBrush, &result));
|
sca8er |
3:0c3bcea5b4d0
|
241
|
return result;
|
sca8er |
3:0c3bcea5b4d0
|
242
|
}
|
sca8er |
3:0c3bcea5b4d0
|
243
|
INT GetInterpolationColorCount() const
|
sca8er |
3:0c3bcea5b4d0
|
244
|
{
|
sca8er |
3:0c3bcea5b4d0
|
245
|
INT result = 0;
|
sca8er |
3:0c3bcea5b4d0
|
246
|
updateStatus(DllExports::GdipGetLinePresetBlendCount(
|
sca8er |
3:0c3bcea5b4d0
|
247
|
(GpLineGradient*) nativeBrush, &result));
|
sca8er |
3:0c3bcea5b4d0
|
248
|
return result;
|
sca8er |
3:0c3bcea5b4d0
|
249
|
}
|
sca8er |
3:0c3bcea5b4d0
|
250
|
Status GetInterpolationColors(Color *presetColors,
|
sca8er |
3:0c3bcea5b4d0
|
251
|
REAL *blendPositions, INT count) const
|
sca8er |
3:0c3bcea5b4d0
|
252
|
{
|
sca8er |
3:0c3bcea5b4d0
|
253
|
if (!presetColors || count <= 0)
|
sca8er |
3:0c3bcea5b4d0
|
254
|
return lastStatus = InvalidParameter;
|
sca8er |
3:0c3bcea5b4d0
|
255
|
|
sca8er |
3:0c3bcea5b4d0
|
256
|
ARGB *presetArgb =
|
sca8er |
3:0c3bcea5b4d0
|
257
|
(ARGB*) DllExports::GdipAlloc(count * sizeof(ARGB));
|
sca8er |
3:0c3bcea5b4d0
|
258
|
if (!presetArgb)
|
sca8er |
3:0c3bcea5b4d0
|
259
|
return lastStatus = OutOfMemory;
|
sca8er |
3:0c3bcea5b4d0
|
260
|
|
sca8er |
3:0c3bcea5b4d0
|
261
|
Status status = updateStatus(DllExports::GdipGetLinePresetBlend(
|
sca8er |
3:0c3bcea5b4d0
|
262
|
(GpLineGradient*) nativeBrush, presetArgb,
|
sca8er |
3:0c3bcea5b4d0
|
263
|
blendPositions, count));
|
sca8er |
3:0c3bcea5b4d0
|
264
|
for (INT i = 0; i < count; ++i) {
|
sca8er |
3:0c3bcea5b4d0
|
265
|
presetColors[i].SetValue(presetArgb[i]);
|
sca8er |
3:0c3bcea5b4d0
|
266
|
}
|
sca8er |
3:0c3bcea5b4d0
|
267
|
DllExports::GdipFree((void*) presetArgb);
|
sca8er |
3:0c3bcea5b4d0
|
268
|
return status;
|
sca8er |
3:0c3bcea5b4d0
|
269
|
}
|
sca8er |
3:0c3bcea5b4d0
|
270
|
Status GetLinearColors(Color *colors) const
|
sca8er |
3:0c3bcea5b4d0
|
271
|
{
|
sca8er |
3:0c3bcea5b4d0
|
272
|
if (!colors) return lastStatus = InvalidParameter;
|
sca8er |
3:0c3bcea5b4d0
|
273
|
|
sca8er |
3:0c3bcea5b4d0
|
274
|
ARGB colorsArgb[2];
|
sca8er |
3:0c3bcea5b4d0
|
275
|
Status status = updateStatus(DllExports::GdipGetLineColors(
|
sca8er |
3:0c3bcea5b4d0
|
276
|
(GpLineGradient*) nativeBrush, colorsArgb));
|
sca8er |
3:0c3bcea5b4d0
|
277
|
colors[0].SetValue(colorsArgb[0]);
|
sca8er |
3:0c3bcea5b4d0
|
278
|
colors[1].SetValue(colorsArgb[1]);
|
sca8er |
3:0c3bcea5b4d0
|
279
|
return status;
|
sca8er |
3:0c3bcea5b4d0
|
280
|
}
|
sca8er |
3:0c3bcea5b4d0
|
281
|
Status GetRectangle(RectF *rect) const
|
sca8er |
3:0c3bcea5b4d0
|
282
|
{
|
sca8er |
3:0c3bcea5b4d0
|
283
|
return updateStatus(DllExports::GdipGetLineRect(
|
sca8er |
3:0c3bcea5b4d0
|
284
|
(GpLineGradient*) nativeBrush, rect));
|
sca8er |
3:0c3bcea5b4d0
|
285
|
}
|
sca8er |
3:0c3bcea5b4d0
|
286
|
Status GetRectangle(Rect *rect) const
|
sca8er |
3:0c3bcea5b4d0
|
287
|
{
|
sca8er |
3:0c3bcea5b4d0
|
288
|
return updateStatus(DllExports::GdipGetLineRectI(
|
sca8er |
3:0c3bcea5b4d0
|
289
|
(GpLineGradient*) nativeBrush, rect));
|
sca8er |
3:0c3bcea5b4d0
|
290
|
}
|
sca8er |
3:0c3bcea5b4d0
|
291
|
Status GetTransform(Matrix *matrix) const
|
sca8er |
3:0c3bcea5b4d0
|
292
|
{
|
sca8er |
3:0c3bcea5b4d0
|
293
|
return updateStatus(DllExports::GdipGetLineTransform(
|
sca8er |
3:0c3bcea5b4d0
|
294
|
(GpLineGradient*) nativeBrush,
|
sca8er |
3:0c3bcea5b4d0
|
295
|
matrix ? matrix->nativeMatrix : NULL));
|
sca8er |
3:0c3bcea5b4d0
|
296
|
}
|
sca8er |
3:0c3bcea5b4d0
|
297
|
WrapMode GetWrapMode() const
|
sca8er |
3:0c3bcea5b4d0
|
298
|
{
|
sca8er |
3:0c3bcea5b4d0
|
299
|
WrapMode wrapMode = WrapModeTile;
|
sca8er |
3:0c3bcea5b4d0
|
300
|
updateStatus(DllExports::GdipGetLineWrapMode(
|
sca8er |
3:0c3bcea5b4d0
|
301
|
(GpLineGradient*) nativeBrush, &wrapMode));
|
sca8er |
3:0c3bcea5b4d0
|
302
|
return wrapMode;
|
sca8er |
3:0c3bcea5b4d0
|
303
|
}
|
sca8er |
3:0c3bcea5b4d0
|
304
|
Status MultiplyTransform(const Matrix *matrix,
|
sca8er |
3:0c3bcea5b4d0
|
305
|
MatrixOrder order = MatrixOrderPrepend)
|
sca8er |
3:0c3bcea5b4d0
|
306
|
{
|
sca8er |
3:0c3bcea5b4d0
|
307
|
return updateStatus(DllExports::GdipMultiplyLineTransform(
|
sca8er |
3:0c3bcea5b4d0
|
308
|
(GpLineGradient*) nativeBrush,
|
sca8er |
3:0c3bcea5b4d0
|
309
|
matrix ? matrix->nativeMatrix : NULL, order));
|
sca8er |
3:0c3bcea5b4d0
|
310
|
}
|
sca8er |
3:0c3bcea5b4d0
|
311
|
Status ResetTransform()
|
sca8er |
3:0c3bcea5b4d0
|
312
|
{
|
sca8er |
3:0c3bcea5b4d0
|
313
|
return updateStatus(DllExports::GdipResetLineTransform(
|
sca8er |
3:0c3bcea5b4d0
|
314
|
(GpLineGradient*) nativeBrush));
|
sca8er |
3:0c3bcea5b4d0
|
315
|
}
|
sca8er |
3:0c3bcea5b4d0
|
316
|
Status RotateTranform(REAL angle, MatrixOrder order = MatrixOrderPrepend)
|
sca8er |
3:0c3bcea5b4d0
|
317
|
{
|
sca8er |
3:0c3bcea5b4d0
|
318
|
return updateStatus(DllExports::GdipRotateLineTransform(
|
sca8er |
3:0c3bcea5b4d0
|
319
|
(GpLineGradient*) nativeBrush, angle, order));
|
sca8er |
3:0c3bcea5b4d0
|
320
|
}
|
sca8er |
3:0c3bcea5b4d0
|
321
|
Status ScaleTransform(REAL sx, REAL sy,
|
sca8er |
3:0c3bcea5b4d0
|
322
|
MatrixOrder order = MatrixOrderPrepend)
|
sca8er |
3:0c3bcea5b4d0
|
323
|
{
|
sca8er |
3:0c3bcea5b4d0
|
324
|
return updateStatus(DllExports::GdipScaleLineTransform(
|
sca8er |
3:0c3bcea5b4d0
|
325
|
(GpLineGradient*) nativeBrush, sx, sy, order));
|
sca8er |
3:0c3bcea5b4d0
|
326
|
}
|
sca8er |
3:0c3bcea5b4d0
|
327
|
Status SetBlend(const REAL *blendFactors,
|
sca8er |
3:0c3bcea5b4d0
|
328
|
const REAL *blendPositions, INT count)
|
sca8er |
3:0c3bcea5b4d0
|
329
|
{
|
sca8er |
3:0c3bcea5b4d0
|
330
|
return updateStatus(DllExports::GdipSetLineBlend(
|
sca8er |
3:0c3bcea5b4d0
|
331
|
(GpLineGradient*) nativeBrush,
|
sca8er |
3:0c3bcea5b4d0
|
332
|
blendFactors, blendPositions, count));
|
sca8er |
3:0c3bcea5b4d0
|
333
|
}
|
sca8er |
3:0c3bcea5b4d0
|
334
|
Status SetBlendBellShape(REAL focus, REAL scale = 1.0f)
|
sca8er |
3:0c3bcea5b4d0
|
335
|
{
|
sca8er |
3:0c3bcea5b4d0
|
336
|
return updateStatus(DllExports::GdipSetLineSigmaBlend(
|
sca8er |
3:0c3bcea5b4d0
|
337
|
(GpLineGradient*) nativeBrush,
|
sca8er |
3:0c3bcea5b4d0
|
338
|
focus, scale));
|
sca8er |
3:0c3bcea5b4d0
|
339
|
}
|
sca8er |
3:0c3bcea5b4d0
|
340
|
Status SetBlendTriangularShape(REAL focus, REAL scale = 1.0f)
|
sca8er |
3:0c3bcea5b4d0
|
341
|
{
|
sca8er |
3:0c3bcea5b4d0
|
342
|
return updateStatus(DllExports::GdipSetLineLinearBlend(
|
sca8er |
3:0c3bcea5b4d0
|
343
|
(GpLineGradient*) nativeBrush,
|
sca8er |
3:0c3bcea5b4d0
|
344
|
focus, scale));
|
sca8er |
3:0c3bcea5b4d0
|
345
|
}
|
sca8er |
3:0c3bcea5b4d0
|
346
|
Status SetGammaCorrection(BOOL useGammaCorrection)
|
sca8er |
3:0c3bcea5b4d0
|
347
|
{
|
sca8er |
3:0c3bcea5b4d0
|
348
|
return updateStatus(DllExports::GdipSetLineGammaCorrection(
|
sca8er |
3:0c3bcea5b4d0
|
349
|
(GpLineGradient*) nativeBrush,
|
sca8er |
3:0c3bcea5b4d0
|
350
|
useGammaCorrection));
|
sca8er |
3:0c3bcea5b4d0
|
351
|
}
|
sca8er |
3:0c3bcea5b4d0
|
352
|
Status SetInterpolationColors(const Color *presetColors,
|
sca8er |
3:0c3bcea5b4d0
|
353
|
const REAL *blendPositions, INT count)
|
sca8er |
3:0c3bcea5b4d0
|
354
|
{
|
sca8er |
3:0c3bcea5b4d0
|
355
|
if (!presetColors || count < 0)
|
sca8er |
3:0c3bcea5b4d0
|
356
|
return lastStatus = InvalidParameter;
|
sca8er |
3:0c3bcea5b4d0
|
357
|
|
sca8er |
3:0c3bcea5b4d0
|
358
|
ARGB *presetArgb =
|
sca8er |
3:0c3bcea5b4d0
|
359
|
(ARGB*) DllExports::GdipAlloc(count * sizeof(ARGB));
|
sca8er |
3:0c3bcea5b4d0
|
360
|
if (!presetArgb)
|
sca8er |
3:0c3bcea5b4d0
|
361
|
return lastStatus = OutOfMemory;
|
sca8er |
3:0c3bcea5b4d0
|
362
|
for (INT i = 0; i < count; ++i) {
|
sca8er |
3:0c3bcea5b4d0
|
363
|
presetArgb[i] = presetColors[i].GetValue();
|
sca8er |
3:0c3bcea5b4d0
|
364
|
}
|
sca8er |
3:0c3bcea5b4d0
|
365
|
|
sca8er |
3:0c3bcea5b4d0
|
366
|
Status status = updateStatus(DllExports::GdipSetLinePresetBlend(
|
sca8er |
3:0c3bcea5b4d0
|
367
|
(GpLineGradient*) nativeBrush,
|
sca8er |
3:0c3bcea5b4d0
|
368
|
presetArgb, blendPositions, count));
|
sca8er |
3:0c3bcea5b4d0
|
369
|
DllExports::GdipFree((void*) presetArgb);
|
sca8er |
3:0c3bcea5b4d0
|
370
|
return status;
|
sca8er |
3:0c3bcea5b4d0
|
371
|
}
|
sca8er |
3:0c3bcea5b4d0
|
372
|
Status SetLinearColors(const Color& color1, const Color& color2)
|
sca8er |
3:0c3bcea5b4d0
|
373
|
{
|
sca8er |
3:0c3bcea5b4d0
|
374
|
return updateStatus(DllExports::GdipSetLineColors(
|
sca8er |
3:0c3bcea5b4d0
|
375
|
(GpLineGradient*) nativeBrush,
|
sca8er |
3:0c3bcea5b4d0
|
376
|
color1.GetValue(), color2.GetValue()));
|
sca8er |
3:0c3bcea5b4d0
|
377
|
}
|
sca8er |
3:0c3bcea5b4d0
|
378
|
Status SetTransform(const Matrix *matrix)
|
sca8er |
3:0c3bcea5b4d0
|
379
|
{
|
sca8er |
3:0c3bcea5b4d0
|
380
|
return updateStatus(DllExports::GdipSetLineTransform(
|
sca8er |
3:0c3bcea5b4d0
|
381
|
(GpLineGradient*) nativeBrush,
|
sca8er |
3:0c3bcea5b4d0
|
382
|
matrix ? matrix->nativeMatrix : NULL));
|
sca8er |
3:0c3bcea5b4d0
|
383
|
}
|
sca8er |
3:0c3bcea5b4d0
|
384
|
Status SetWrapMode(WrapMode wrapMode)
|
sca8er |
3:0c3bcea5b4d0
|
385
|
{
|
sca8er |
3:0c3bcea5b4d0
|
386
|
return updateStatus(DllExports::GdipSetLineWrapMode(
|
sca8er |
3:0c3bcea5b4d0
|
387
|
(GpLineGradient*) nativeBrush, wrapMode));
|
sca8er |
3:0c3bcea5b4d0
|
388
|
}
|
sca8er |
3:0c3bcea5b4d0
|
389
|
Status TranslateTransform(REAL dx, REAL dy,
|
sca8er |
3:0c3bcea5b4d0
|
390
|
MatrixOrder order = MatrixOrderPrepend)
|
sca8er |
3:0c3bcea5b4d0
|
391
|
{
|
sca8er |
3:0c3bcea5b4d0
|
392
|
return updateStatus(DllExports::GdipTranslateLineTransform(
|
sca8er |
3:0c3bcea5b4d0
|
393
|
(GpLineGradient*) nativeBrush, dx, dy, order));
|
sca8er |
3:0c3bcea5b4d0
|
394
|
}
|
sca8er |
3:0c3bcea5b4d0
|
395
|
|
sca8er |
3:0c3bcea5b4d0
|
396
|
private:
|
sca8er |
3:0c3bcea5b4d0
|
397
|
LinearGradientBrush(GpBrush *brush, Status status): Brush(brush, status) {}
|
sca8er |
3:0c3bcea5b4d0
|
398
|
LinearGradientBrush(const LinearGradientBrush& brush);
|
sca8er |
3:0c3bcea5b4d0
|
399
|
LinearGradientBrush& operator=(const LinearGradientBrush&);
|
sca8er |
3:0c3bcea5b4d0
|
400
|
};
|
sca8er |
3:0c3bcea5b4d0
|
401
|
|
sca8er |
3:0c3bcea5b4d0
|
402
|
class SolidBrush: public Brush
|
sca8er |
3:0c3bcea5b4d0
|
403
|
{
|
sca8er |
3:0c3bcea5b4d0
|
404
|
public:
|
sca8er |
3:0c3bcea5b4d0
|
405
|
SolidBrush(const Color& color)
|
sca8er |
3:0c3bcea5b4d0
|
406
|
{
|
sca8er |
3:0c3bcea5b4d0
|
407
|
GpSolidFill *nativeSolidFill = NULL;
|
sca8er |
3:0c3bcea5b4d0
|
408
|
lastStatus = DllExports::GdipCreateSolidFill(
|
sca8er |
3:0c3bcea5b4d0
|
409
|
color.GetValue(), &nativeSolidFill);
|
sca8er |
3:0c3bcea5b4d0
|
410
|
nativeBrush = nativeSolidFill;
|
sca8er |
3:0c3bcea5b4d0
|
411
|
}
|
sca8er |
3:0c3bcea5b4d0
|
412
|
virtual SolidBrush* Clone() const
|
sca8er |
3:0c3bcea5b4d0
|
413
|
{
|
sca8er |
3:0c3bcea5b4d0
|
414
|
GpBrush *cloneBrush = NULL;
|
sca8er |
3:0c3bcea5b4d0
|
415
|
Status status = updateStatus(DllExports::GdipCloneBrush(
|
sca8er |
3:0c3bcea5b4d0
|
416
|
nativeBrush, &cloneBrush));
|
sca8er |
3:0c3bcea5b4d0
|
417
|
if (status == Ok) {
|
sca8er |
3:0c3bcea5b4d0
|
418
|
SolidBrush *result =
|
sca8er |
3:0c3bcea5b4d0
|
419
|
new SolidBrush(cloneBrush, lastStatus);
|
sca8er |
3:0c3bcea5b4d0
|
420
|
if (!result) {
|
sca8er |
3:0c3bcea5b4d0
|
421
|
DllExports::GdipDeleteBrush(cloneBrush);
|
sca8er |
3:0c3bcea5b4d0
|
422
|
updateStatus(OutOfMemory);
|
sca8er |
3:0c3bcea5b4d0
|
423
|
}
|
sca8er |
3:0c3bcea5b4d0
|
424
|
return result;
|
sca8er |
3:0c3bcea5b4d0
|
425
|
} else {
|
sca8er |
3:0c3bcea5b4d0
|
426
|
return NULL;
|
sca8er |
3:0c3bcea5b4d0
|
427
|
}
|
sca8er |
3:0c3bcea5b4d0
|
428
|
}
|
sca8er |
3:0c3bcea5b4d0
|
429
|
|
sca8er |
3:0c3bcea5b4d0
|
430
|
Status GetColor(Color *color) const
|
sca8er |
3:0c3bcea5b4d0
|
431
|
{
|
sca8er |
3:0c3bcea5b4d0
|
432
|
return updateStatus(DllExports::GdipGetSolidFillColor(
|
sca8er |
3:0c3bcea5b4d0
|
433
|
(GpSolidFill*) nativeBrush,
|
sca8er |
3:0c3bcea5b4d0
|
434
|
color ? &color->Value : NULL));
|
sca8er |
3:0c3bcea5b4d0
|
435
|
}
|
sca8er |
3:0c3bcea5b4d0
|
436
|
Status SetColor(const Color& color)
|
sca8er |
3:0c3bcea5b4d0
|
437
|
{
|
sca8er |
3:0c3bcea5b4d0
|
438
|
return updateStatus(DllExports::GdipSetSolidFillColor(
|
sca8er |
3:0c3bcea5b4d0
|
439
|
(GpSolidFill*) nativeBrush, color.GetValue()));
|
sca8er |
3:0c3bcea5b4d0
|
440
|
}
|
sca8er |
3:0c3bcea5b4d0
|
441
|
|
sca8er |
3:0c3bcea5b4d0
|
442
|
private:
|
sca8er |
3:0c3bcea5b4d0
|
443
|
SolidBrush(GpBrush *brush, Status status): Brush(brush, status) {}
|
sca8er |
3:0c3bcea5b4d0
|
444
|
SolidBrush(const SolidBrush&);
|
sca8er |
3:0c3bcea5b4d0
|
445
|
SolidBrush& operator=(const SolidBrush&);
|
sca8er |
3:0c3bcea5b4d0
|
446
|
};
|
sca8er |
3:0c3bcea5b4d0
|
447
|
|
sca8er |
3:0c3bcea5b4d0
|
448
|
class TextureBrush: public Brush
|
sca8er |
3:0c3bcea5b4d0
|
449
|
{
|
sca8er |
3:0c3bcea5b4d0
|
450
|
public:
|
sca8er |
3:0c3bcea5b4d0
|
451
|
TextureBrush(Image *image, WrapMode wrapMode = WrapModeTile)
|
sca8er |
3:0c3bcea5b4d0
|
452
|
{
|
sca8er |
3:0c3bcea5b4d0
|
453
|
GpTexture *nativeTexture = NULL;
|
sca8er |
3:0c3bcea5b4d0
|
454
|
lastStatus = DllExports::GdipCreateTexture(
|
sca8er |
3:0c3bcea5b4d0
|
455
|
image ? image->nativeImage : NULL,
|
sca8er |
3:0c3bcea5b4d0
|
456
|
wrapMode, &nativeTexture);
|
sca8er |
3:0c3bcea5b4d0
|
457
|
nativeBrush = nativeTexture;
|
sca8er |
3:0c3bcea5b4d0
|
458
|
}
|
sca8er |
3:0c3bcea5b4d0
|
459
|
TextureBrush(Image *image, WrapMode wrapMode,
|
sca8er |
3:0c3bcea5b4d0
|
460
|
REAL dstX, REAL dstY, REAL dstWidth, REAL dstHeight)
|
sca8er |
3:0c3bcea5b4d0
|
461
|
{
|
sca8er |
3:0c3bcea5b4d0
|
462
|
GpTexture *nativeTexture = NULL;
|
sca8er |
3:0c3bcea5b4d0
|
463
|
lastStatus = DllExports::GdipCreateTexture2(
|
sca8er |
3:0c3bcea5b4d0
|
464
|
image ? image->nativeImage : NULL,
|
sca8er |
3:0c3bcea5b4d0
|
465
|
wrapMode, dstX, dstY, dstWidth, dstHeight,
|
sca8er |
3:0c3bcea5b4d0
|
466
|
&nativeTexture);
|
sca8er |
3:0c3bcea5b4d0
|
467
|
nativeBrush = nativeTexture;
|
sca8er |
3:0c3bcea5b4d0
|
468
|
}
|
sca8er |
3:0c3bcea5b4d0
|
469
|
TextureBrush(Image *image, WrapMode wrapMode,
|
sca8er |
3:0c3bcea5b4d0
|
470
|
INT dstX, INT dstY, INT dstWidth, INT dstHeight)
|
sca8er |
3:0c3bcea5b4d0
|
471
|
{
|
sca8er |
3:0c3bcea5b4d0
|
472
|
GpTexture *nativeTexture = NULL;
|
sca8er |
3:0c3bcea5b4d0
|
473
|
lastStatus = DllExports::GdipCreateTexture2I(
|
sca8er |
3:0c3bcea5b4d0
|
474
|
image ? image->nativeImage : NULL,
|
sca8er |
3:0c3bcea5b4d0
|
475
|
wrapMode, dstX, dstY, dstWidth, dstHeight,
|
sca8er |
3:0c3bcea5b4d0
|
476
|
&nativeTexture);
|
sca8er |
3:0c3bcea5b4d0
|
477
|
nativeBrush = nativeTexture;
|
sca8er |
3:0c3bcea5b4d0
|
478
|
}
|
sca8er |
3:0c3bcea5b4d0
|
479
|
TextureBrush(Image *image, WrapMode wrapMode, const RectF& dstRect)
|
sca8er |
3:0c3bcea5b4d0
|
480
|
{
|
sca8er |
3:0c3bcea5b4d0
|
481
|
GpTexture *nativeTexture = NULL;
|
sca8er |
3:0c3bcea5b4d0
|
482
|
lastStatus = DllExports::GdipCreateTexture2(
|
sca8er |
3:0c3bcea5b4d0
|
483
|
image ? image->nativeImage : NULL, wrapMode,
|
sca8er |
3:0c3bcea5b4d0
|
484
|
dstRect.X, dstRect.Y,
|
sca8er |
3:0c3bcea5b4d0
|
485
|
dstRect.Width, dstRect.Height, &nativeTexture);
|
sca8er |
3:0c3bcea5b4d0
|
486
|
nativeBrush = nativeTexture;
|
sca8er |
3:0c3bcea5b4d0
|
487
|
}
|
sca8er |
3:0c3bcea5b4d0
|
488
|
TextureBrush(Image *image, WrapMode wrapMode, const Rect& dstRect)
|
sca8er |
3:0c3bcea5b4d0
|
489
|
{
|
sca8er |
3:0c3bcea5b4d0
|
490
|
GpTexture *nativeTexture = NULL;
|
sca8er |
3:0c3bcea5b4d0
|
491
|
lastStatus = DllExports::GdipCreateTexture2I(
|
sca8er |
3:0c3bcea5b4d0
|
492
|
image ? image->nativeImage : NULL, wrapMode,
|
sca8er |
3:0c3bcea5b4d0
|
493
|
dstRect.X, dstRect.Y,
|
sca8er |
3:0c3bcea5b4d0
|
494
|
dstRect.Width, dstRect.Height, &nativeTexture);
|
sca8er |
3:0c3bcea5b4d0
|
495
|
nativeBrush = nativeTexture;
|
sca8er |
3:0c3bcea5b4d0
|
496
|
}
|
sca8er |
3:0c3bcea5b4d0
|
497
|
TextureBrush(Image *image, const RectF& dstRect,
|
sca8er |
3:0c3bcea5b4d0
|
498
|
ImageAttributes *imageAttributes = NULL)
|
sca8er |
3:0c3bcea5b4d0
|
499
|
{
|
sca8er |
3:0c3bcea5b4d0
|
500
|
GpTexture *nativeTexture = NULL;
|
sca8er |
3:0c3bcea5b4d0
|
501
|
lastStatus = DllExports::GdipCreateTextureIA(
|
sca8er |
3:0c3bcea5b4d0
|
502
|
image ? image->nativeImage : NULL,
|
sca8er |
3:0c3bcea5b4d0
|
503
|
imageAttributes ? imageAttributes->nativeImageAttributes : NULL,
|
sca8er |
3:0c3bcea5b4d0
|
504
|
dstRect.X, dstRect.Y,
|
sca8er |
3:0c3bcea5b4d0
|
505
|
dstRect.Width, dstRect.Height, &nativeTexture);
|
sca8er |
3:0c3bcea5b4d0
|
506
|
nativeBrush = nativeTexture;
|
sca8er |
3:0c3bcea5b4d0
|
507
|
}
|
sca8er |
3:0c3bcea5b4d0
|
508
|
TextureBrush(Image *image, const Rect& dstRect,
|
sca8er |
3:0c3bcea5b4d0
|
509
|
ImageAttributes *imageAttributes = NULL)
|
sca8er |
3:0c3bcea5b4d0
|
510
|
{
|
sca8er |
3:0c3bcea5b4d0
|
511
|
GpTexture *nativeTexture = NULL;
|
sca8er |
3:0c3bcea5b4d0
|
512
|
lastStatus = DllExports::GdipCreateTextureIAI(
|
sca8er |
3:0c3bcea5b4d0
|
513
|
image ? image->nativeImage : NULL,
|
sca8er |
3:0c3bcea5b4d0
|
514
|
imageAttributes ? imageAttributes->nativeImageAttributes : NULL,
|
sca8er |
3:0c3bcea5b4d0
|
515
|
dstRect.X, dstRect.Y,
|
sca8er |
3:0c3bcea5b4d0
|
516
|
dstRect.Width, dstRect.Height, &nativeTexture);
|
sca8er |
3:0c3bcea5b4d0
|
517
|
nativeBrush = nativeTexture;
|
sca8er |
3:0c3bcea5b4d0
|
518
|
}
|
sca8er |
3:0c3bcea5b4d0
|
519
|
virtual TextureBrush* Clone() const
|
sca8er |
3:0c3bcea5b4d0
|
520
|
{
|
sca8er |
3:0c3bcea5b4d0
|
521
|
GpBrush *cloneBrush = NULL;
|
sca8er |
3:0c3bcea5b4d0
|
522
|
Status status = updateStatus(DllExports::GdipCloneBrush(
|
sca8er |
3:0c3bcea5b4d0
|
523
|
nativeBrush, &cloneBrush));
|
sca8er |
3:0c3bcea5b4d0
|
524
|
if (status == Ok) {
|
sca8er |
3:0c3bcea5b4d0
|
525
|
TextureBrush *result =
|
sca8er |
3:0c3bcea5b4d0
|
526
|
new TextureBrush(cloneBrush, lastStatus);
|
sca8er |
3:0c3bcea5b4d0
|
527
|
if (!result) {
|
sca8er |
3:0c3bcea5b4d0
|
528
|
DllExports::GdipDeleteBrush(cloneBrush);
|
sca8er |
3:0c3bcea5b4d0
|
529
|
updateStatus(OutOfMemory);
|
sca8er |
3:0c3bcea5b4d0
|
530
|
}
|
sca8er |
3:0c3bcea5b4d0
|
531
|
return result;
|
sca8er |
3:0c3bcea5b4d0
|
532
|
} else {
|
sca8er |
3:0c3bcea5b4d0
|
533
|
return NULL;
|
sca8er |
3:0c3bcea5b4d0
|
534
|
}
|
sca8er |
3:0c3bcea5b4d0
|
535
|
}
|
sca8er |
3:0c3bcea5b4d0
|
536
|
|
sca8er |
3:0c3bcea5b4d0
|
537
|
//TODO: implement TextureBrush::GetImage()
|
sca8er |
3:0c3bcea5b4d0
|
538
|
//Image *GetImage() const
|
sca8er |
3:0c3bcea5b4d0
|
539
|
//{
|
sca8er |
3:0c3bcea5b4d0
|
540
|
// // where is the Image allocated (static,member,new,other)?
|
sca8er |
3:0c3bcea5b4d0
|
541
|
// // GdipGetTextureImage just returns a GpImage*
|
sca8er |
3:0c3bcea5b4d0
|
542
|
// updateStatus(NotImplemented);
|
sca8er |
3:0c3bcea5b4d0
|
543
|
// return NULL;
|
sca8er |
3:0c3bcea5b4d0
|
544
|
//}
|
sca8er |
3:0c3bcea5b4d0
|
545
|
Status GetTransfrom(Matrix *matrix) const
|
sca8er |
3:0c3bcea5b4d0
|
546
|
{
|
sca8er |
3:0c3bcea5b4d0
|
547
|
return updateStatus(DllExports::GdipGetTextureTransform(
|
sca8er |
3:0c3bcea5b4d0
|
548
|
(GpTexture*) nativeBrush,
|
sca8er |
3:0c3bcea5b4d0
|
549
|
matrix ? matrix->nativeMatrix : NULL));
|
sca8er |
3:0c3bcea5b4d0
|
550
|
}
|
sca8er |
3:0c3bcea5b4d0
|
551
|
WrapMode GetWrapMode() const
|
sca8er |
3:0c3bcea5b4d0
|
552
|
{
|
sca8er |
3:0c3bcea5b4d0
|
553
|
WrapMode result = WrapModeTile;
|
sca8er |
3:0c3bcea5b4d0
|
554
|
updateStatus(DllExports::GdipGetTextureWrapMode(
|
sca8er |
3:0c3bcea5b4d0
|
555
|
(GpTexture*) nativeBrush, &result));
|
sca8er |
3:0c3bcea5b4d0
|
556
|
return result;
|
sca8er |
3:0c3bcea5b4d0
|
557
|
}
|
sca8er |
3:0c3bcea5b4d0
|
558
|
Status MultiplyTransform(const Matrix *matrix,
|
sca8er |
3:0c3bcea5b4d0
|
559
|
MatrixOrder order = MatrixOrderPrepend)
|
sca8er |
3:0c3bcea5b4d0
|
560
|
{
|
sca8er |
3:0c3bcea5b4d0
|
561
|
return updateStatus(DllExports::GdipMultiplyTextureTransform(
|
sca8er |
3:0c3bcea5b4d0
|
562
|
(GpTexture*) nativeBrush,
|
sca8er |
3:0c3bcea5b4d0
|
563
|
matrix ? matrix->nativeMatrix : NULL, order));
|
sca8er |
3:0c3bcea5b4d0
|
564
|
}
|
sca8er |
3:0c3bcea5b4d0
|
565
|
Status ResetTransform()
|
sca8er |
3:0c3bcea5b4d0
|
566
|
{
|
sca8er |
3:0c3bcea5b4d0
|
567
|
return updateStatus(DllExports::GdipResetTextureTransform(
|
sca8er |
3:0c3bcea5b4d0
|
568
|
(GpTexture*) nativeBrush));
|
sca8er |
3:0c3bcea5b4d0
|
569
|
}
|
sca8er |
3:0c3bcea5b4d0
|
570
|
Status RotateTransform(REAL angle,
|
sca8er |
3:0c3bcea5b4d0
|
571
|
MatrixOrder order = MatrixOrderPrepend)
|
sca8er |
3:0c3bcea5b4d0
|
572
|
{
|
sca8er |
3:0c3bcea5b4d0
|
573
|
return updateStatus(DllExports::GdipRotateTextureTransform(
|
sca8er |
3:0c3bcea5b4d0
|
574
|
(GpTexture*) nativeBrush, angle, order));
|
sca8er |
3:0c3bcea5b4d0
|
575
|
}
|
sca8er |
3:0c3bcea5b4d0
|
576
|
Status ScaleTransform(REAL sx, REAL sy,
|
sca8er |
3:0c3bcea5b4d0
|
577
|
MatrixOrder order = MatrixOrderPrepend)
|
sca8er |
3:0c3bcea5b4d0
|
578
|
{
|
sca8er |
3:0c3bcea5b4d0
|
579
|
return updateStatus(DllExports::GdipScaleTextureTransform(
|
sca8er |
3:0c3bcea5b4d0
|
580
|
(GpTexture*) nativeBrush, sx, sy, order));
|
sca8er |
3:0c3bcea5b4d0
|
581
|
}
|
sca8er |
3:0c3bcea5b4d0
|
582
|
Status SetTransform(const Matrix *matrix)
|
sca8er |
3:0c3bcea5b4d0
|
583
|
{
|
sca8er |
3:0c3bcea5b4d0
|
584
|
return updateStatus(DllExports::GdipSetTextureTransform(
|
sca8er |
3:0c3bcea5b4d0
|
585
|
(GpTexture*) nativeBrush,
|
sca8er |
3:0c3bcea5b4d0
|
586
|
matrix ? matrix->nativeMatrix : NULL));
|
sca8er |
3:0c3bcea5b4d0
|
587
|
}
|
sca8er |
3:0c3bcea5b4d0
|
588
|
Status SetWrapMode(WrapMode wrapMode)
|
sca8er |
3:0c3bcea5b4d0
|
589
|
{
|
sca8er |
3:0c3bcea5b4d0
|
590
|
return updateStatus(DllExports::GdipSetTextureWrapMode(
|
sca8er |
3:0c3bcea5b4d0
|
591
|
(GpTexture*) nativeBrush, wrapMode));
|
sca8er |
3:0c3bcea5b4d0
|
592
|
}
|
sca8er |
3:0c3bcea5b4d0
|
593
|
Status TranslateTransform(REAL dx, REAL dy,
|
sca8er |
3:0c3bcea5b4d0
|
594
|
MatrixOrder order = MatrixOrderPrepend)
|
sca8er |
3:0c3bcea5b4d0
|
595
|
{
|
sca8er |
3:0c3bcea5b4d0
|
596
|
return updateStatus(DllExports::GdipTranslateTextureTransform(
|
sca8er |
3:0c3bcea5b4d0
|
597
|
(GpTexture*) nativeBrush, dx, dy, order));
|
sca8er |
3:0c3bcea5b4d0
|
598
|
}
|
sca8er |
3:0c3bcea5b4d0
|
599
|
|
sca8er |
3:0c3bcea5b4d0
|
600
|
private:
|
sca8er |
3:0c3bcea5b4d0
|
601
|
TextureBrush(GpBrush *brush, Status status): Brush(brush, status) {}
|
sca8er |
3:0c3bcea5b4d0
|
602
|
TextureBrush(const TextureBrush&);
|
sca8er |
3:0c3bcea5b4d0
|
603
|
TextureBrush& operator=(const TextureBrush&);
|
sca8er |
3:0c3bcea5b4d0
|
604
|
};
|
sca8er |
3:0c3bcea5b4d0
|
605
|
|
sca8er |
3:0c3bcea5b4d0
|
606
|
#endif /* __GDIPLUS_BRUSH_H */
|