Newer
Older
/***********************************************************************
* FXRuby -- the Ruby language bindings for the FOX GUI toolkit.
* Copyright (c) 2001-2009 by Lyle Johnson. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* For further information please contact the author by e-mail
* at "lyle@lylejohnson.name".
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
***********************************************************************/
/// Drawing (BITBLT) functions
enum FXFunction {
BLT_CLR, /// D := 0
BLT_SRC_AND_DST, /// D := S & D
BLT_SRC_AND_NOT_DST, /// D := S & ~D
BLT_SRC, /// D := S
BLT_NOT_SRC_AND_DST, /// D := ~S & D
BLT_DST, /// D := D
BLT_SRC_XOR_DST, /// D := S ^ D
BLT_SRC_OR_DST, /// D := S | D
BLT_NOT_SRC_AND_NOT_DST, /// D := ~S & ~D == D := ~(S | D)
BLT_NOT_SRC_XOR_DST, /// D := ~S ^ D
BLT_NOT_DST, /// D := ~D
BLT_SRC_OR_NOT_DST, /// D := S | ~D
BLT_NOT_SRC, /// D := ~S
BLT_NOT_SRC_OR_DST, /// D := ~S | D
BLT_NOT_SRC_OR_NOT_DST, /// D := ~S | ~D == ~(S & D)
BLT_SET /// D := 1
};
/// Line Styles
enum FXLineStyle {
LINE_SOLID, /// Solid lines
LINE_ONOFF_DASH, /// On-off dashed lines
LINE_DOUBLE_DASH /// Double dashed lines
};
/// Line Cap Styles
enum FXCapStyle {
CAP_NOT_LAST, /// Don't include last end cap
CAP_BUTT, /// Butting line end caps
CAP_ROUND, /// Round line end caps
CAP_PROJECTING /// Projecting line end caps
};
/// Line Join Styles
enum FXJoinStyle {
JOIN_MITER, /// Mitered or pointy joints
JOIN_ROUND, /// Round line joints
JOIN_BEVEL /// Beveled or flat joints
};
/// Fill Styles
enum FXFillStyle {
FILL_SOLID, /// Fill with solid color
FILL_TILED, /// Fill with tiled bitmap
FILL_STIPPLED, /// Fill where stipple mask is 1
FILL_OPAQUESTIPPLED /// Fill with foreground where mask is 1, background otherwise
};
/// Fill Rules
enum FXFillRule {
RULE_EVEN_ODD, /// Even odd polygon filling
RULE_WINDING /// Winding rule polygon filling
};
/// Stipple/dither patterns
enum FXStipplePattern {
STIPPLE_0 = 0,
STIPPLE_NONE = 0,
STIPPLE_BLACK = 0, /// All ones
STIPPLE_1 = 1,
STIPPLE_2 = 2,
STIPPLE_3 = 3,
STIPPLE_4 = 4,
STIPPLE_5 = 5,
STIPPLE_6 = 6,
STIPPLE_7 = 7,
STIPPLE_8 = 8,
STIPPLE_GRAY = 8, /// 50% gray
STIPPLE_9 = 9,
STIPPLE_10 = 10,
STIPPLE_11 = 11,
STIPPLE_12 = 12,
STIPPLE_13 = 13,
STIPPLE_14 = 14,
STIPPLE_15 = 15,
STIPPLE_16 = 16,
STIPPLE_WHITE = 16, /// All zeroes
STIPPLE_HORZ = 17, /// Horizontal hatch pattern
STIPPLE_VERT = 18, /// Vertical hatch pattern
STIPPLE_CROSS = 19, /// Cross-hatch pattern
STIPPLE_DIAG = 20, /// Diagonal // hatch pattern
STIPPLE_REVDIAG = 21, /// Reverse diagonal \\ hatch pattern
STIPPLE_CROSSDIAG = 22 /// Cross-diagonal hatch pattern
};
/// Line segment
struct FXSegment {
%extend {
FXSegment(FXshort x1=0,FXshort y1=0,FXshort x2=0,FXshort y2=0){
FXSegment* seg=new FXSegment;
seg->x1=x1; seg->y1=y1; seg->x2=x2; seg->y2=y2;
return seg;
}
}
FXshort x1,y1,x2,y2;
~FXSegment();
};
/// Arc
struct FXArc {
%extend {
FXArc(FXshort x=0,FXshort y=0,FXshort w=0,FXshort h=0,FXshort a=0,FXshort b=0){
FXArc* arc=new FXArc;
arc->x=x; arc->y=y; arc->w=w; arc->h=h; arc->a=a; arc->b=b;
return arc;
}
}
FXshort x,y,w,h,a,b;
~FXArc();
};
class FXApp;
class FXImage;
class FXBitmap;
class FXIcon;
class FXFont;
class FXDrawable;
%ignore FXDC::context() const;
%ignore FXDC::getDashLength() const;
/**
* Abstract Device Context
*
* A Device Context is used to maintain the state of the graphics drawing system.
* Defining your drawing code in terms of the Abstract Device Context allows the
* drawing commands to be rendered on different types of surfaces, such as windows
* and images (FXDCWindow), or on paper (FXDCPrint).
* WYSYWYG may be obtained by using the same identical drawing code in your
* application regardless of the actual device surface being utilized.
*/
class FXDC {
private:
FXApp *app; // Application
protected:
void *ctx; // Context handle
FXFont *font; // Drawing font
FXStipplePattern pattern; // Stipple pattern
FXBitmap *stipple; // Stipple bitmap
FXImage *tile; // Tile image
FXBitmap *mask; // Mask bitmap
FXRectangle clip; // Clip rectangle
FXColor fg; // Foreground color
FXColor bg; // Background color
FXuint width; // Line width
FXCapStyle cap; // Line cap style
FXJoinStyle join; // Line join style
FXLineStyle style; // Line style
FXFillStyle fill; // Fill style
FXFillRule rule; // Fill rule
FXFunction rop; // RasterOp
FXchar dashpat[32]; // Line dash pattern data
FXuint dashlen; // Line dash pattern length
FXuint dashoff; // Line dash pattern offset
FXint tx; // Tile dx
FXint ty; // Tile dy
FXint cx; // Clip x
FXint cy; // Clip y
public:
%extend {
/// Construct dummy DC
FXDC(FXApp* a){
return new FXRbDC(a);
}
}
/// Get context handle
void* context() const { return ctx; }
/// Get application
FXApp* getApp() const;
/// Get foreground drawing color
FXColor getForeground() const;
/// Get background drawing color
FXColor getBackground() const;
%extend {
/// Get dash pattern
VALUE getDashPattern() const {
return FXRbMakeArray(self->getDashPattern(), self->getDashLength());
}
}
/// Get dash offset
FXuint getDashOffset() const;
/// Get dash length
FXuint getDashLength() const;
/// Get line width
FXuint getLineWidth() const;
/// Get line cap style
FXCapStyle getLineCap() const;
/// Get line join style
FXJoinStyle getLineJoin() const;
/// Get line style
FXLineStyle getLineStyle() const;
/// Get fill style
FXFillStyle getFillStyle() const;
/// Get fill rule
FXFillRule getFillRule() const;
/// Get rasterop function
FXFunction getFunction() const;
/// Get the tile image
FXImage *getTile() const;
/// Get stipple bitmap
FXBitmap *getStippleBitmap() const;
/// Get pattern
FXStipplePattern getStipplePattern() const;
/// Return clip rectangle
const FXRectangle& getClipRectangle() const;
/// Return clip x
FXint getClipX() const;
/// Return clip y
FXint getClipY() const;
/// Return clip width
FXint getClipWidth() const;
/// Return clip height
FXint getClipHeight() const;
/// Get text font
FXFont* getFont() const;
/// Destructor
virtual ~FXDC();
};
DECLARE_FXDC_VIRTUALS(FXDC)