7 * (C) Copyright 1998 Manuel Lemos.
8 * (C) Copyright 1996-1997 Ian J. Einman.
9 * (C) Copyright 1993-1996 Jaba Development.
10 * (C) Copyright 1993-1996 Jan van den Baard.
11 * All Rights Reserved.
14 * Revision 42.7 2004/06/16 20:16:48 verhaegs
15 * Use METHODPROTO, METHOD_END and REGFUNCPROTOn where needed.
17 * Revision 42.6 2003/01/18 19:10:03 chodorowski
18 * Instead of using the _AROS or __AROS preprocessor symbols, use __AROS__.
20 * Revision 42.5 2000/08/08 20:57:26 chodorowski
21 * Minor fixes to build on Amiga.
23 * Revision 42.4 2000/05/29 15:42:49 stegerg
24 * fixed some "comparison is always 1 due to limited range of data type"
27 * Revision 42.3 2000/05/29 00:40:24 bergers
28 * Update to compile with AROS now. Should also still compile with SASC etc since I only made changes that test the define __AROS__. The compilation is still very noisy but it does the trick for the main directory. Maybe members of the BGUI team should also have a look at the compiler warnings because some could also cause problems on other systems... (Comparison always TRUE due to datatype (or something like that)). And please compile it on an Amiga to see whether it still works... Thanks.
30 * Revision 42.2 2000/05/15 19:27:02 stegerg
31 * another hundreds of REG() macro replacements in func headers/protos.
33 * Revision 42.1 2000/05/14 23:32:48 stegerg
34 * changed over 200 function headers which all use register
35 * parameters (oh boy ...), because the simple REG() macro
36 * doesn't work with AROS. And there are still hundreds
37 * of headers left to be fixed :(
39 * Many of these functions would also work with stack
40 * params, but since i have fixed every single one
41 * I encountered up to now, I guess will have to do
42 * the same for the rest.
44 * Revision 42.0 2000/05/09 22:10:34 mlemos
45 * Bumped to revision 42.0 before handing BGUI to AROS team
47 * Revision 41.11 2000/05/09 19:55:23 mlemos
48 * Merged with the branch Manuel_Lemos_fixes.
50 * Revision 41.10.2.1 1998/11/16 20:01:56 mlemos
51 * Replaced AllocVec and FreeVec calls by BGUI_AllocPoolMem and
52 * BGUI_FreePoolMem calls respectively.
53 * Restored prior RastPort AreaInfo and TmpRas after rendering.
55 * Revision 41.10 1998/02/25 21:13:26 mlemos
58 * Revision 1.1 1998/02/25 17:10:00 mlemos
64 /// Class definitions.
66 #include "include/classdefs.h"
69 * Object instance data.
72 struct TmpRas vd_TmpRas
; /* TmpRas for areafill's. */
73 struct AreaInfo vd_AreaInfo
; /* AreaInfo for areafill's. */
74 UWORD vd_SizeX
; /* Design width. */
75 UWORD vd_SizeY
; /* Design height. */
76 UWORD vd_MinWidth
; /* Minimum width. */
77 UWORD vd_MinHeight
; /* Minimum height. */
78 UWORD vd_BuiltInType
; /* Built-in type. */
79 UWORD vd_Flags
; /* Flags (see below). */
80 UWORD vd_Pen
; /* Pen to use for drawing. */
81 UWORD vd_DriPen
; /* DriPen to use for drawing. */
82 struct VectorItem
*vd_VectorArray
; /* The vector elements. */
83 PLANEPTR vd_AreaPlane
; /* Bit-plane for areafills. */
84 WORD
*vd_VertexBuffer
; /* Buffer for areafills. */
85 UWORD vd_PlaneWidth
; /* Width of area-plane. */
86 UWORD vd_PlaneHeight
; /* Height of area-plane. */
87 UWORD vd_ErasePen
; /* Pen to erase with. */
88 struct TmpRas
*vd_OldTmpRas
; /* TmpRas before rendering. */
89 struct AreaInfo
*vd_OldAreaInfo
; /* AreaInfo before rendering. */
92 #define VDATF_AREA (1<<0) /* We are area filling. */
98 * Built-in GETPATH image.
100 STATIC
struct VectorItem BuiltinGetPath
[] = {
101 { 20, 14, VIF_SCALE
},
102 { 4, 4, VIF_MOVE
| VIF_AREASTART
},
106 { 5, 2, VIF_DRAW
| VIF_YRELBOTTOM
},
107 { 4, 2, VIF_DRAW
| VIF_YRELBOTTOM
},
108 { 4, 4, VIF_AREAEND
},
110 { 9, 2, VIF_DRAW
| VIF_XRELRIGHT
},
111 { 6, 2, VIF_DRAW
| VIF_XRELRIGHT
},
112 { 4, 4, VIF_DRAW
| VIF_XRELRIGHT
},
113 { 4, 2, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
114 { 4, 2, VIF_DRAW
| VIF_YRELBOTTOM
},
116 { 8, 6, VIF_DRAW
| VIF_XRELRIGHT
},
117 { 4, 6, VIF_DRAW
| VIF_XRELRIGHT
| VIF_LASTITEM
},
121 * Built-in GETFILE image.
123 STATIC
struct VectorItem BuiltinGetFile
[] = {
124 { 20, 14, VIF_SCALE
},
125 { 4, 2, VIF_MOVE
| VIF_AREASTART
},
127 { 5, 2, VIF_DRAW
| VIF_YRELBOTTOM
},
128 { 4, 2, VIF_DRAW
| VIF_YRELBOTTOM
},
129 { 4, 2, VIF_AREAEND
},
131 { 8, 2, VIF_DRAW
| VIF_XRELRIGHT
},
132 { 4, 6, VIF_DRAW
| VIF_XRELRIGHT
},
133 { 8, 6, VIF_DRAW
| VIF_XRELRIGHT
},
134 { 8, 2, VIF_DRAW
| VIF_XRELRIGHT
},
135 { 4, 2, VIF_MOVE
| VIF_YRELBOTTOM
},
136 { 4, 2, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
137 { 5, 6, VIF_MOVE
| VIF_XRELRIGHT
| VIF_AREASTART
},
138 { 4, 6, VIF_DRAW
| VIF_XRELRIGHT
},
139 { 4, 2, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
140 { 5, 2, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
141 { 5, 6, VIF_LASTITEM
| VIF_XRELRIGHT
},
145 * Built-in CheckMark image.
147 STATIC
struct VectorItem BuiltinCheckMark
[] = {
148 { 24, 11, VIF_SCALE
},
149 { 6, 5, VIF_MOVE
| VIF_AREASTART
},
152 { 6, 2, VIF_DRAW
| VIF_XRELRIGHT
},
153 { 5, 2, VIF_DRAW
| VIF_XRELRIGHT
},
154 { 7, 2, VIF_DRAW
| VIF_XRELRIGHT
},
158 { 6, 5, VIF_LASTITEM
},
162 * Built-in RadioButton image.
164 STATIC
struct VectorItem BuiltinRadioButton
[] = {
165 { 16, 8, VIF_SCALE
},
166 { 4, 3, VIF_MOVE
| VIF_AREASTART
},
168 { 6, 2, VIF_DRAW
| VIF_XRELRIGHT
},
169 { 4, 3, VIF_DRAW
| VIF_XRELRIGHT
},
170 { 4, 3, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
171 { 6, 2, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
172 { 6, 2, VIF_DRAW
| VIF_YRELBOTTOM
},
173 { 4, 3, VIF_DRAW
| VIF_YRELBOTTOM
},
174 { 4, 3, VIF_LASTITEM
},
179 * Built-in PopUp image.
181 STATIC
struct VectorItem BuiltInPopUp
[] = {
182 { 44, 20, VIF_MOVE
| VIF_AREASTART
},
183 { 56, 20, VIF_DRAW
},
184 { 56, 35, VIF_DRAW
},
185 { 73, 35, VIF_DRAW
},
186 { 50, 55, VIF_DRAW
},
187 { 27, 35, VIF_DRAW
},
188 { 44, 35, VIF_DRAW
},
189 { 44, 20, VIF_DRAW
| VIF_AREAEND
},
190 { 27, 70, VIF_MOVE
| VIF_AREASTART
},
191 { 73, 70, VIF_DRAW
},
192 { 73, 77, VIF_DRAW
},
193 { 27, 77, VIF_DRAW
| VIF_AREAEND
},
194 { 18, 14, VIF_MINSIZE
},
195 { 100, 100, VIF_SCALE
| VIF_LASTITEM
},
199 * Built-in Cycle image.
201 STATIC
struct VectorItem BuiltInCycle
[] = {
202 { 18, 14, VIF_SCALE
},
203 { 5, 3, VIF_MOVE
| VIF_AREASTART
| VIF_YRELBOTTOM
},
204 { 6, 3, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
205 { 5, 4, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
206 { 5, 4, VIF_DRAW
| VIF_YRELBOTTOM
},
208 { 6, 4, VIF_DRAW
| VIF_XRELRIGHT
},
209 { 6, 6, VIF_DRAW
| VIF_XRELRIGHT
},
210 { 8, 6, VIF_DRAW
| VIF_XRELRIGHT
},
211 { 6, 8, VIF_DRAW
| VIF_XRELRIGHT
},
212 { 5, 8, VIF_DRAW
| VIF_XRELRIGHT
},
213 { 3, 6, VIF_DRAW
| VIF_XRELRIGHT
},
214 { 5, 6, VIF_DRAW
| VIF_XRELRIGHT
},
215 { 5, 4, VIF_DRAW
| VIF_XRELRIGHT
},
216 { 6, 3, VIF_DRAW
| VIF_XRELRIGHT
},
219 { 4, 4, VIF_DRAW
| VIF_AREAEND
| VIF_YRELBOTTOM
| VIF_LASTITEM
},
223 * Built-in Cycle image - selected.
225 STATIC
struct VectorItem BuiltInCycle2
[] = {
226 { 18, 14, VIF_SCALE
},
227 { 5, 3, VIF_MOVE
| VIF_XRELRIGHT
| VIF_AREASTART
},
230 { 5, 4, VIF_DRAW
| VIF_XRELRIGHT
},
231 { 5, 4, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
232 { 6, 4, VIF_DRAW
| VIF_YRELBOTTOM
},
233 { 6, 6, VIF_DRAW
| VIF_YRELBOTTOM
},
234 { 8, 6, VIF_DRAW
| VIF_YRELBOTTOM
},
235 { 6, 8, VIF_DRAW
| VIF_YRELBOTTOM
},
236 { 5, 8, VIF_DRAW
| VIF_YRELBOTTOM
},
237 { 3, 6, VIF_DRAW
| VIF_YRELBOTTOM
},
238 { 5, 6, VIF_DRAW
| VIF_YRELBOTTOM
},
239 { 5, 4, VIF_DRAW
| VIF_YRELBOTTOM
},
240 { 6, 3, VIF_DRAW
| VIF_YRELBOTTOM
},
241 { 5, 3, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
242 { 4, 4, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
243 { 4, 4, VIF_DRAW
| VIF_XRELRIGHT
| VIF_AREAEND
| VIF_LASTITEM
},
248 * Built-in PopUp image.
250 STATIC
struct VectorItem BuiltInPopUp
[] = {
251 { 15, 13, VIF_SCALE
},
252 { 6, 2, VIF_MOVE
| VIF_AREASTART
},
259 { 6, 2, VIF_DRAW
| VIF_AREAEND
},
260 { 4, 9, VIF_MOVE
| VIF_AREASTART
},
262 { 10, 10, VIF_DRAW
},
263 { 4, 10, VIF_DRAW
| VIF_AREAEND
| VIF_LASTITEM
},
267 * Built-in Cycle image.
269 STATIC
struct VectorItem BuiltInCycle
[] = {
270 { 17, 13, VIF_SCALE
},
271 { 4, 10, VIF_MOVE
| VIF_AREASTART
},
272 { 10, 10, VIF_DRAW
},
287 { 3, 9, VIF_DRAW
| VIF_AREAEND
| VIF_LASTITEM
},
291 * Built-in Cycle image - selected.
293 STATIC
struct VectorItem BuiltInCycle2
[] = {
294 { 17, 13, VIF_SCALE
},
295 { 11, 2, VIF_MOVE
| VIF_AREASTART
},
309 { 11, 10, VIF_DRAW
},
311 { 12, 3, VIF_DRAW
| VIF_AREAEND
| VIF_LASTITEM
},
315 * Built-in arrow up image.
317 STATIC
struct VectorItem BuiltInArrowUp
[] = {
318 { 16, 9, VIF_SCALE
},
319 { 3, 6, VIF_MOVE
| VIF_AREASTART
},
320 { 8, 2, VIF_DRAW
| VIF_XRELRIGHT
},
322 { 3, 6, VIF_DRAW
| VIF_XRELRIGHT
},
323 { 4, 6, VIF_DRAW
| VIF_XRELRIGHT
},
325 { 8, 3, VIF_DRAW
| VIF_XRELRIGHT
},
326 { 4, 6, VIF_DRAW
| VIF_LASTITEM
},
330 * Built-in arrow DOWN vector image.
332 STATIC
struct VectorItem BuiltInArrowDown
[] = {
333 { 16, 9, VIF_SCALE
},
334 { 3, 6, VIF_MOVE
| VIF_AREASTART
| VIF_YRELBOTTOM
},
335 { 8, 2, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
336 { 8, 2, VIF_DRAW
| VIF_YRELBOTTOM
},
337 { 3, 6, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
338 { 4, 6, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
339 { 8, 3, VIF_DRAW
| VIF_YRELBOTTOM
},
340 { 8, 3, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
341 { 4, 6, VIF_DRAW
| VIF_LASTITEM
| VIF_YRELBOTTOM
},
345 * Built-in arrow LEFT vector image.
347 STATIC
struct VectorItem BuiltInArrowLeft
[] = {
348 { 10, 12, VIF_SCALE
},
349 { 6, 2, VIF_MOVE
| VIF_AREASTART
},
350 { 3, 6, VIF_DRAW
| VIF_YRELBOTTOM
},
352 { 6, 2, VIF_DRAW
| VIF_YRELBOTTOM
},
353 { 6, 3, VIF_DRAW
| VIF_YRELBOTTOM
},
355 { 4, 6, VIF_DRAW
| VIF_YRELBOTTOM
},
356 { 6, 3, VIF_DRAW
| VIF_LASTITEM
},
360 * Built-in arrow RIGHT vector image.
362 STATIC
struct VectorItem BuiltInArrowRight
[] = {
363 { 10, 12, VIF_SCALE
},
364 { 6, 2, VIF_MOVE
| VIF_AREASTART
| VIF_XRELRIGHT
},
365 { 3, 6, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
366 { 3, 6, VIF_DRAW
| VIF_XRELRIGHT
},
367 { 6, 2, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
368 { 6, 3, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
369 { 4, 6, VIF_DRAW
| VIF_XRELRIGHT
},
370 { 4, 6, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
371 { 6, 3, VIF_DRAW
| VIF_LASTITEM
| VIF_XRELRIGHT
},
375 * Built-in GETFONT image.
377 STATIC
struct VectorItem BuiltInGetFont
[] = {
378 { 8, 4, VIF_MOVE
| VIF_AREASTART
},
380 { 10, 4, VIF_DRAW
| VIF_YRELBOTTOM
},
381 { 8, 4, VIF_DRAW
| VIF_YRELBOTTOM
},
382 { 8, 4, VIF_AREAEND
},
383 { 8, 4, VIF_MOVE
| VIF_AREASTART
},
386 { 20, 12, VIF_DRAW
},
387 { 18, 14, VIF_DRAW
},
388 { 20, 12, VIF_DRAW
| VIF_YRELBOTTOM
},
389 { 20, 6, VIF_DRAW
| VIF_YRELBOTTOM
},
390 { 18, 4, VIF_DRAW
| VIF_YRELBOTTOM
},
391 { 9, 4, VIF_DRAW
| VIF_YRELBOTTOM
},
392 { 9, 6, VIF_DRAW
| VIF_YRELBOTTOM
},
393 { 17, 6, VIF_DRAW
| VIF_YRELBOTTOM
},
394 { 18, 7, VIF_DRAW
| VIF_YRELBOTTOM
},
395 { 18, 12, VIF_DRAW
| VIF_YRELBOTTOM
},
396 { 17, 13, VIF_DRAW
| VIF_YRELBOTTOM
},
397 { 9, 13, VIF_DRAW
| VIF_YRELBOTTOM
},
399 { 17, 13, VIF_DRAW
},
400 { 18, 12, VIF_DRAW
},
403 { 9, 6, VIF_DRAW
| VIF_AREAEND
},
405 { 24, 4, VIF_MOVE
| VIF_AREASTART
},
407 { 26, 4, VIF_DRAW
| VIF_YRELBOTTOM
},
408 { 24, 4, VIF_DRAW
| VIF_YRELBOTTOM
},
409 { 24, 4, VIF_DRAW
| VIF_AREAEND
},
410 { 25, 13, VIF_MOVE
| VIF_AREASTART
},
411 { 30, 13, VIF_DRAW
},
412 { 32, 13, VIF_DRAW
| VIF_YRELBOTTOM
},
413 { 32, 6, VIF_DRAW
| VIF_YRELBOTTOM
},
414 { 30, 4, VIF_DRAW
| VIF_YRELBOTTOM
},
415 { 25, 4, VIF_DRAW
| VIF_YRELBOTTOM
},
416 { 25, 6, VIF_DRAW
| VIF_YRELBOTTOM
},
417 { 29, 6, VIF_DRAW
| VIF_YRELBOTTOM
},
418 { 30, 7, VIF_DRAW
| VIF_YRELBOTTOM
},
419 { 30, 12, VIF_DRAW
| VIF_YRELBOTTOM
},
420 { 29, 13, VIF_DRAW
| VIF_YRELBOTTOM
},
421 { 25, 13, VIF_DRAW
| VIF_YRELBOTTOM
| VIF_AREAEND
},
423 { 20, 14, VIF_MINSIZE
},
424 { 40, 28, VIF_SCALE
| VIF_LASTITEM
},
428 * Built-in GETSCREEN image.
430 STATIC
struct VectorItem BuiltInGetScreen
[] = {
431 { 20, 14, VIF_SCALE
},
432 { 4, 2, VIF_MOVE
| VIF_AREASTART
},
434 { 5, 2, VIF_DRAW
| VIF_YRELBOTTOM
},
435 { 4, 2, VIF_DRAW
| VIF_YRELBOTTOM
},
436 { 4, 2, VIF_AREAEND
},
438 { 8, 2, VIF_DRAW
| VIF_XRELRIGHT
},
439 { 4, 6, VIF_DRAW
| VIF_XRELRIGHT
},
440 { 8, 6, VIF_DRAW
| VIF_XRELRIGHT
},
441 { 8, 2, VIF_DRAW
| VIF_XRELRIGHT
},
442 { 4, 2, VIF_MOVE
| VIF_YRELBOTTOM
},
443 { 4, 2, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
444 { 5, 6, VIF_MOVE
| VIF_XRELRIGHT
| VIF_AREASTART
},
445 { 4, 6, VIF_DRAW
| VIF_XRELRIGHT
},
446 { 4, 2, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
447 { 5, 2, VIF_DRAW
| VIF_XRELRIGHT
| VIF_YRELBOTTOM
},
448 { 5, 6, VIF_LASTITEM
| VIF_XRELRIGHT
},
451 static struct VectorItem
*BuiltIn
[] =
471 * Deallocate the AreaFill() stuff.
473 STATIC ASM VOID
CleanUpArea( REG(a0
) struct RastPort
*rp
, REG(a1
) VD
*vd
)
475 if (vd
->vd_Flags
& VDATF_AREA
)
478 * Don't deallocate to soon.
482 rp
->TmpRas
=vd
->vd_OldTmpRas
;
483 rp
->AreaInfo
=vd
->vd_OldAreaInfo
;
486 * Deallocate the buffers.
488 if (vd
->vd_AreaPlane
)
490 FreeRaster( vd
->vd_AreaPlane
, vd
->vd_PlaneWidth
, vd
->vd_PlaneHeight
);
491 vd
->vd_AreaPlane
= NULL
;
494 if (vd
->vd_VertexBuffer
)
496 BGUI_FreePoolMem( vd
->vd_VertexBuffer
);
497 vd
->vd_VertexBuffer
= NULL
;
500 vd
->vd_PlaneWidth
= vd
->vd_PlaneHeight
= 0;
503 * Mark us as not area filling.
505 vd
->vd_Flags
&= ~VDATF_AREA
;
510 * Allocate the necessary stuff
511 * for area filling. If this fails
512 * the image areas are not filled.
514 STATIC ULONG
SetupArea( struct RastPort
*rp
, VD
*vd
, struct VectorItem
*vi
, UWORD w
, UWORD h
)
517 struct VectorItem
*vi2
;
520 * Count the number of vector elements
521 ** in the area fill operation.
523 for (vi2
= vi
; !(vi2
->vi_Flags
& (VIF_AREAEND
|VIF_LASTITEM
)); vi2
++);
528 numelem
= vi2
- vi
+ 2;
534 * Allocate and setup the buffers etc.
536 if ((vd
->vd_VertexBuffer
= (UWORD
*)BGUI_AllocPoolMem(numelem
* 5)))
538 memset(vd
->vd_VertexBuffer
,'\0',numelem
* 5);
539 if ((vd
->vd_AreaPlane
= AllocRaster(w
, h
))) {
541 * Initialize structures.
543 InitTmpRas( &vd
->vd_TmpRas
, vd
->vd_AreaPlane
, RASSIZE( w
, h
));
544 InitArea( &vd
->vd_AreaInfo
, vd
->vd_VertexBuffer
, numelem
);
548 vd
->vd_OldTmpRas
= rp
->TmpRas
;
549 rp
->TmpRas
= &vd
->vd_TmpRas
;
550 vd
->vd_OldAreaInfo
= rp
->AreaInfo
;
551 rp
->AreaInfo
= &vd
->vd_AreaInfo
;
555 vd
->vd_PlaneWidth
= w
;
556 vd
->vd_PlaneHeight
= h
;
558 * Mark us as area filling.
560 vd
->vd_Flags
|= VDATF_AREA
;
566 * Oops. Screw up somewhere.
575 * Create a shiny new object.
577 METHOD(VectorClassNew
, struct opSet
*, ops
)
583 * First we let the superclass
584 * create a new object.
586 if ((rc
= AsmDoSuperMethodA(cl
, obj
, (Msg
)ops
)))
589 * Get us the instance data.
591 vd
= INST_DATA(cl
, rc
);
596 vd
->vd_Pen
= vd
->vd_DriPen
= (UWORD
)~0;
601 AsmCoerceMethod(cl
, (Object
*)rc
, OM_SET
, ops
->ops_AttrList
, NULL
);
609 * Change one or more attrubutes.
611 METHOD(VectorClassSet
, struct opSet
*, ops
)
613 VD
*vd
= INST_DATA(cl
, obj
);
616 struct TagItem
*tstate
= ops
->ops_AttrList
;
618 struct VectorItem
*vi
;
622 * First we let the superclass
623 * change the attributes it
626 rc
= AsmDoSuperMethodA(cl
, obj
, (Msg
)ops
);
629 * Get the attributes.
631 while ((tag
= NextTagItem(&tstate
)))
636 case VIT_VectorArray
:
637 vd
->vd_VectorArray
= (struct VectorItem
*)data
;
642 vd
->vd_VectorArray
= BuiltIn
[data
];
643 vd
->vd_BuiltInType
= data
;
652 vd
->vd_DriPen
= data
;
656 vd
->vd_ErasePen
= data
;
664 * Setup the default minimums.
667 vd
->vd_MinHeight
= 0;
669 for (vi
= vd
->vd_VectorArray
; resize
; vi
++)
671 if (vi
->vi_Flags
& VIF_SCALE
)
674 * Setup the design size.
676 vd
->vd_SizeX
= vi
->vi_x
;
677 vd
->vd_SizeY
= vi
->vi_y
;
679 if (vi
->vi_Flags
& VIF_MINSIZE
)
682 * Setup the design size.
684 vd
->vd_MinWidth
= vi
->vi_x
;
685 vd
->vd_MinHeight
= vi
->vi_y
;
687 if (vi
->vi_Flags
& VIF_LASTITEM
) resize
= FALSE
;
689 if (!vd
->vd_MinWidth
) vd
->vd_MinWidth
= vd
->vd_SizeX
;
690 if (!vd
->vd_MinHeight
) vd
->vd_MinHeight
= vd
->vd_SizeY
;
698 * Give an attribute value.
700 METHOD(VectorClassGet
, struct opGet
*, opg
)
702 VD
*vd
= INST_DATA( cl
, obj
);
704 IPTR
*store
= opg
->opg_Storage
;
707 * Firts we see if the attribute
708 * they want is know to us. If not
709 * we pass it onto the superclass.
711 switch (opg
->opg_AttrID
)
713 case VIT_VectorArray
: STORE vd
->vd_VectorArray
; break;
714 case VIT_BuiltIn
: STORE vd
->vd_BuiltInType
; break;
715 case VIT_Pen
: STORE vd
->vd_Pen
; break;
716 case VIT_DriPen
: STORE vd
->vd_DriPen
; break;
717 case VIT_MinWidth
: STORE vd
->vd_MinWidth
; break;
718 case VIT_MinHeight
: STORE vd
->vd_MinHeight
; break;
720 rc
= AsmDoSuperMethodA(cl
, obj
, (Msg
)opg
);
730 * Render the vector image.
732 METHOD(VectorClassRender
, struct bmRender
*, bmr
)
734 VD
*vd
= INST_DATA(cl
, obj
);
735 struct VectorItem
*vi
= vd
->vd_VectorArray
;
736 struct BaseInfo
*bi
= bmr
->bmr_BInfo
;
737 struct RastPort
*rp
= bi
->bi_RPort
;
739 int l
, t
, r
, b
, w
, h
, x
, y
;
743 * Only render if there are vector
744 * elements to render.
749 * Get image position and dimensions.
751 l
= IMAGE(obj
)->LeftEdge
;
752 t
= IMAGE(obj
)->TopEdge
;
753 w
= IMAGE(obj
)->Width
;
754 h
= IMAGE(obj
)->Height
;
757 * Get image right and bottom edge coordinates.
763 * Setup the correct startup-pen.
765 if (vd
->vd_DriPen
!= (UWORD
)~0)
766 BSetDPenA(bi
, vd
->vd_DriPen
);
767 else if (vd
->vd_Pen
!= (UWORD
)~0)
768 BSetPenA(bi
, vd
->vd_Pen
);
771 switch (bmr
->bmr_Flags
)
774 BSetDPenA(bi
, FILLTEXTPEN
);
777 case IDS_INACTIVESELECTED
:
779 BSetDPenA(bi
, TEXTPEN
);
785 * Jam only only color.
796 * Loop through the vector elements.
804 go
= !(f
& VIF_LASTITEM
);
806 if (f
& (VIF_SCALE
|VIF_MINSIZE
))
812 if (f
& VIF_BPEN
) BSetPenB(bi
, y
);
818 if (f
& VIF_BPEN
) BSetDPenB(bi
, y
);
821 if (f
& VIF_DRAWMODE
)
827 if (f
& VIF_LINEPATTERN
)
834 if (f
& VIF_AOLPEN
) SetOPen(rp
, x
);
835 else if (f
& VIF_ENDOPEN
) BNDRYOFF(rp
);
837 if (f
& VIF_SHADOWPEN
) BSetDPenA(bi
, SHADOWPEN
);
838 else if (f
& VIF_SHINEPEN
) BSetDPenA(bi
, SHINEPEN
);
839 else if (f
& VIF_FILLPEN
) BSetDPenA(bi
, FILLPEN
);
840 else if (f
& VIF_TEXTPEN
) BSetDPenA(bi
, TEXTPEN
);
843 * Do we need to setup an areafill?
845 if (f
& VIF_AREASTART
) SetupArea(rp
, vd
, vi
, w
, h
);
848 * Calculate the X and Y coordinates.
850 if (vd
->vd_SizeX
) x
= (x
* w
) / vd
->vd_SizeX
;
851 if (vd
->vd_SizeY
) y
= (y
* h
) / vd
->vd_SizeY
;
854 * Calculate X from the correct edge.
856 if (f
& VIF_XRELRIGHT
) x
= r
- x
;
860 * Calculate Y from the correct edge.
862 if (f
& VIF_YRELBOTTOM
) y
= b
- y
;
866 * Check that the coordinates do
867 * not go outside the bounding box.
870 else if (x
> r
) x
= r
;
873 else if (y
> b
) y
= b
;
876 * (Area)Move or (Area)Draw to the
881 if (vd
->vd_Flags
& VDATF_AREA
) AreaMove(rp
, x
, y
);
884 else if (f
& VIF_DRAW
)
886 if (vd
->vd_Flags
& VDATF_AREA
) AreaDraw(rp
, x
, y
);
891 * Are we done area filling?
893 if (f
& (VIF_AREAEND
|VIF_LASTITEM
))
895 if (vd
->vd_Flags
& VDATF_AREA
)
903 * In case a color change or something unexpected gave us a VIF_AREAEND.
912 /// Class initialization.
914 * Class function array.
916 STATIC DPFUNC ClassFunc
[] = {
917 { BASE_RENDER
, VectorClassRender
, },
918 { OM_NEW
, VectorClassNew
, },
919 { OM_SET
, VectorClassSet
, },
920 { OM_GET
, VectorClassGet
, },
925 * Simple class initialization.
927 makeproto Class
*InitVectorClass(void)
929 return BGUI_MakeClass(CLASS_SuperClassBGUI
, BGUI_IMAGE_OBJECT
,
930 CLASS_ObjectSize
, sizeof(VD
),
931 CLASS_DFTable
, ClassFunc
,