grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / muimaster / imspec_vector.c
blob9d3274d60df60459df380f14d809149be9c20fe9
1 /*
2 Copyright © 2003, The AROS Development Team.
3 All rights reserved.
5 $Id$
6 */
8 #include <intuition/imageclass.h>
9 #include <proto/graphics.h>
10 #include <proto/exec.h>
12 #include "debug.h"
13 #include "mui.h"
14 #include "imspec_intern.h"
15 #include "support.h"
17 extern struct Library *MUIMasterBase;
19 static void draw_thick_line(struct RastPort *rp, int x1, int y1, int x2,
20 int y2)
22 Move(rp, x1, y1);
23 Draw(rp, x2, y2);
24 Move(rp, x1 + 1, y1);
25 Draw(rp, x2 + 1, y2);
28 //#define SPACING 1
29 #define HSPACING 0
30 #define VSPACING 0
32 #define ARROW_SPACING 1
33 #define ARROW_VSPACING ARROW_SPACING
34 #define ARROW_HSPACING ARROW_SPACING
35 #define VERTARROW_VSPACING ARROW_VSPACING
36 #define HORIZARROW_HSPACING ARROW_HSPACING
38 void arrowup_draw(struct MUI_RenderInfo *mri, LONG left, LONG top,
39 LONG width, LONG height, LONG state)
41 int cx;
42 struct RastPort *rport = mri->mri_RastPort;
44 SetAPen(rport, mri->mri_Pens[MPEN_TEXT]);
46 cx = width / 2;
48 if ((width > 8 + ARROW_SPACING) && (height > 8 + ARROW_SPACING))
50 Move(rport, left + ARROW_HSPACING + 1,
51 top + height - 1 - VERTARROW_VSPACING);
52 Draw(rport, left + width - cx, top + VERTARROW_VSPACING);
54 Move(rport, left + ARROW_HSPACING,
55 top + height - 1 - VERTARROW_VSPACING);
56 Draw(rport, left + width - cx - 1, top + VERTARROW_VSPACING);
57 if ((width > 8 + ARROW_SPACING) && (height > 8 + ARROW_SPACING))
59 Move(rport, left + width - 1 - ARROW_HSPACING - 1,
60 top + height - 1 - VERTARROW_VSPACING);
61 Draw(rport, left + cx - 1, top + VERTARROW_VSPACING);
63 Move(rport, left + width - 1 - ARROW_HSPACING,
64 top + height - 1 - VERTARROW_VSPACING);
65 Draw(rport, left + cx, top + VERTARROW_VSPACING);
68 void arrowdown_draw(struct MUI_RenderInfo *mri, LONG left, LONG top,
69 LONG width, LONG height, LONG state)
71 int cx;
72 struct RastPort *rport = mri->mri_RastPort;
74 SetAPen(rport, mri->mri_Pens[MPEN_TEXT]);
76 cx = width / 2;
78 if ((width > 8 + ARROW_SPACING) && (height > 8 + ARROW_SPACING))
80 Move(rport, left + ARROW_HSPACING + 1, top + VERTARROW_VSPACING);
81 Draw(rport, left + width - cx,
82 top + height - 1 - VERTARROW_VSPACING);
84 Move(rport, left + ARROW_HSPACING, top + VERTARROW_VSPACING);
85 Draw(rport, left + width - cx - 1,
86 top + height - 1 - VERTARROW_VSPACING);
87 if ((width > 8 + ARROW_SPACING) && (height > 8 + ARROW_SPACING))
89 Move(rport, left + width - 1 - ARROW_HSPACING - 1,
90 top + VERTARROW_VSPACING);
91 Draw(rport, left + cx - 1, top + height - 1 - VERTARROW_VSPACING);
93 Move(rport, left + width - 1 - ARROW_HSPACING,
94 top + VERTARROW_VSPACING);
95 Draw(rport, left + cx, top + height - 1 - VERTARROW_VSPACING);
98 void arrowleft_draw(struct MUI_RenderInfo *mri, LONG left, LONG top,
99 LONG width, LONG height, LONG state)
101 int cy;
102 struct RastPort *rport = mri->mri_RastPort;
104 SetAPen(rport, mri->mri_Pens[MPEN_TEXT]);
106 cy = height / 2;
108 if ((height > 8 + ARROW_SPACING) && (width > 8 + ARROW_SPACING))
110 Move(rport, left + width - 1 - HORIZARROW_HSPACING,
111 top + ARROW_VSPACING + 1);
112 Draw(rport, left + HORIZARROW_HSPACING, top + height - cy);
114 Move(rport, left + width - 1 - HORIZARROW_HSPACING,
115 top + ARROW_VSPACING);
116 Draw(rport, left + HORIZARROW_HSPACING, top + height - cy - 1);
117 if ((height > 8 + ARROW_SPACING) && (width > 8 + ARROW_SPACING))
119 Move(rport, left + width - 1 - HORIZARROW_HSPACING,
120 top + height - 1 - ARROW_VSPACING - 1);
121 Draw(rport, left + HORIZARROW_HSPACING, top + cy - 1);
123 Move(rport, left + width - 1 - HORIZARROW_HSPACING,
124 top + height - 1 - ARROW_VSPACING);
125 Draw(rport, left + HORIZARROW_HSPACING, top + cy);
128 void arrowright_draw(struct MUI_RenderInfo *mri, LONG left, LONG top,
129 LONG width, LONG height, LONG state)
131 int cy;
132 struct RastPort *rport = mri->mri_RastPort;
134 SetAPen(rport, mri->mri_Pens[MPEN_TEXT]);
136 cy = height / 2;
138 if ((height > 8 + ARROW_SPACING) && (width > 8 + ARROW_SPACING))
140 Move(rport, left + HORIZARROW_HSPACING, top + ARROW_VSPACING + 1);
141 Draw(rport, left + width - 1 - HORIZARROW_HSPACING,
142 top + height - cy);
144 Move(rport, left + HORIZARROW_HSPACING, top + ARROW_VSPACING);
145 Draw(rport, left + width - 1 - HORIZARROW_HSPACING,
146 top + height - cy - 1);
147 if ((height > 8 + ARROW_SPACING) && (width > 8 + ARROW_SPACING))
149 Move(rport, left + HORIZARROW_HSPACING,
150 top + height - 1 - ARROW_VSPACING - 1);
151 Draw(rport, left + width - 1 - HORIZARROW_HSPACING, top + cy - 1);
153 Move(rport, left + HORIZARROW_HSPACING,
154 top + height - 1 - ARROW_VSPACING);
155 Draw(rport, left + width - 1 - HORIZARROW_HSPACING, top + cy);
158 void checkbox_draw(struct MUI_RenderInfo *mri, LONG left, LONG top,
159 LONG width, LONG height, LONG state)
161 int h_spacing = width / 4;
162 int v_spacing = height / 4;
163 int bottom = top + height - 1;
164 int right = left + width - 1;
166 /* Draw checkmark (only if image is in selected state) */
168 if (state == IDS_SELECTED)
170 left += h_spacing;
171 right -= h_spacing;
172 width -= h_spacing * 2;
173 top += v_spacing;
174 bottom -= v_spacing;
175 height -= v_spacing * 2;
177 SetAPen(mri->mri_RastPort, mri->mri_Pens[MPEN_TEXT]);
179 draw_thick_line(mri->mri_RastPort, left, top + height / 3, left,
180 bottom);
181 draw_thick_line(mri->mri_RastPort, left + 1, bottom, right - 1,
182 top);
186 void mx_draw(struct MUI_RenderInfo *mri, LONG left, LONG top, LONG width,
187 LONG height, LONG state)
189 struct RastPort *rport = mri->mri_RastPort;
190 int bottom = top + height - 1;
191 int right = left + width - 1;
192 int col1;
193 int col2;
195 if (state == IDS_SELECTED)
197 col1 = MPEN_SHADOW;
198 col2 = MPEN_SHINE;
200 else
202 col1 = MPEN_SHINE;
203 col2 = MPEN_SHADOW;
206 SetAPen(rport, mri->mri_Pens[col1]);
207 RectFill(rport, left + 3, top, right - 3, top);
208 WritePixel(rport, left + 2, top + 1);
209 WritePixel(rport, left + 1, top + 2);
210 RectFill(rport, left, top + 3, left, bottom - 3);
211 WritePixel(rport, left + 1, bottom - 2);
212 WritePixel(rport, left + 2, bottom - 1);
214 SetAPen(rport, mri->mri_Pens[col2]);
215 WritePixel(rport, right - 2, top + 1);
216 WritePixel(rport, right - 1, top + 2);
217 RectFill(rport, right, top + 3, right, bottom - 3);
218 WritePixel(rport, right - 1, bottom - 2);
219 WritePixel(rport, right - 2, bottom - 1);
220 RectFill(rport, left + 3, bottom, right - 3, bottom);
222 SetAPen(rport, mri->mri_DrawInfo->dri_Pens[BACKGROUNDPEN]);
223 RectFill(rport, left + 3, top + 1, right - 3, bottom - 1);
224 RectFill(rport, left + 2, top + 2, right - 2, bottom - 2);
225 RectFill(rport, left + 1, top + 3, right - 1, bottom - 3);
227 if (state == IDS_SELECTED)
229 left += 3;
230 right -= 3;
231 width -= 6;
232 top += 3;
233 bottom -= 3;
234 height -= 6;
236 SetAPen(rport, mri->mri_Pens[MPEN_FILL]);
237 if ((width >= 5) && (height >= 5))
239 RectFill(rport, left, top + 2, left, bottom - 2);
240 RectFill(rport, left + 1, top + 1, left + 1, bottom - 1);
241 RectFill(rport, left + 2, top, right - 2, bottom);
242 RectFill(rport, right - 1, top + 1, right - 1, bottom - 1);
243 RectFill(rport, right, top + 2, right, bottom - 2);
245 else
247 RectFill(rport, left, top, right, bottom);
248 RectFill(rport, left - 1, top + 1, right + 1, bottom - 1);
249 RectFill(rport, left + 1, top - 1, right - 1, bottom + 1);
254 void cycle_draw(struct MUI_RenderInfo *mri, LONG left, LONG top, LONG width,
255 LONG height, LONG state)
257 struct RastPort *rport = mri->mri_RastPort;
258 int bottom = top + height - 1;
259 int right = left + width - 1;
260 #if BIGGER_ARROW
261 int arrow_top;
262 #endif
264 SetAPen(rport, mri->mri_Pens[MPEN_TEXT]);
266 Move(rport, left, top + 1);
267 Draw(rport, left, bottom - 1);
268 Move(rport, left + 1, top);
269 Draw(rport, left + 1, bottom);
270 Draw(rport, right - 7, bottom);
271 Move(rport, right - 7, bottom - 1);
272 Draw(rport, right - 6, bottom - 1);
273 Move(rport, left + 2, top);
274 Draw(rport, right - 7, top);
275 Move(rport, right - 7, top + 1);
276 Draw(rport, right - 6, top + 1);
278 #if BIGGER_ARROW
279 arrow_top = top + (3 * height / 4) - 3;
280 /* prevent arrow touching bottom */
281 if (arrow_top + 4 >= bottom - 1)
282 arrow_top = bottom - 5;
284 RectFill(rport, right - 7, top + 1, right - 6, arrow_top - 1);
285 #endif
286 /* The small arrow */
287 Move(rport, right - 6 - 3, top + 2);
288 Draw(rport, right - 7 + 3, top + 2);
289 Move(rport, right - 6 - 2, top + 3);
290 Draw(rport, right - 7 + 2, top + 3);
291 Move(rport, right - 6 - 1, top + 4);
292 Draw(rport, right - 7 + 1, top + 4);
293 #if BIGGER_ARROW
294 /* makes arrow bigger */
295 if (arrow_top - top - 2 >= 4)
297 Move(rport, right - 6 - 3, arrow_top - 1);
298 Draw(rport, right - 7 + 3, arrow_top - 1);
299 Move(rport, right - 6 - 2, arrow_top);
300 Draw(rport, right - 7 + 2, arrow_top);
301 Move(rport, right - 6 - 2, arrow_top + 1);
302 Draw(rport, right - 7 + 2, arrow_top + 1);
303 Move(rport, right - 6 - 1, arrow_top + 2);
304 Draw(rport, right - 7 7 + 1, arrow_top + 2);
306 else
308 Move(rport, right - 6 - 3, arrow_top);
309 Draw(rport, right - 7 + 3, arrow_top);
310 Move(rport, right - 6 - 2, arrow_top + 1);
311 Draw(rport, right - 7 + 2, arrow_top + 1);
312 Move(rport, right - 6 - 1, arrow_top + 2);
313 Draw(rport, right - 7 + 1, arrow_top + 2);
315 #endif
317 /* The right bar */
318 SetAPen(rport, mri->mri_Pens[MPEN_SHADOW]);
319 Move(rport, right - 1, top);
320 Draw(rport, right - 1, bottom);
321 SetAPen(rport, mri->mri_Pens[MPEN_SHINE]);
322 Move(rport, right, top);
323 Draw(rport, right, bottom);
326 void popup_draw(struct MUI_RenderInfo *mri, LONG left, LONG top, LONG width,
327 LONG height, LONG state)
329 int right, bottom, cx;
330 struct RastPort *rport = mri->mri_RastPort;
332 height -= 3;
334 SetAPen(rport, mri->mri_Pens[MPEN_TEXT]);
336 cx = width / 2;
338 Move(rport, left + HSPACING + 1, top + VSPACING);
339 Draw(rport, left + width - cx, top + height - 1 - VSPACING);
340 Move(rport, left + HSPACING, top + VSPACING);
341 Draw(rport, left + width - cx - 1, top + height - 1 - VSPACING);
343 Move(rport, left + width - 1 - HSPACING - 1, top + VSPACING);
344 Draw(rport, left + cx - 1, top + height - 1 - VSPACING);
345 Move(rport, left + width - 1 - HSPACING, top + VSPACING);
346 Draw(rport, left + cx, top + height - 1 - VSPACING);
348 bottom = top + height - 1 + 3;
349 right = left + width - 1;
350 Move(rport, left, bottom - 2);
351 Draw(rport, right, bottom - 2);
352 Move(rport, left, bottom - 1);
353 Draw(rport, right, bottom - 1);
356 void popfile_draw(struct MUI_RenderInfo *mri, LONG left, LONG top,
357 LONG width, LONG height, LONG state)
359 int right, bottom;
360 int edgex, edgey;
361 struct RastPort *rport = mri->mri_RastPort;
363 right = left + width - 1;
364 bottom = top + height - 1;
366 edgex = left + width * 5 / 8;
367 edgey = top + height * 5 / 8;
369 SetAPen(rport, mri->mri_Pens[MPEN_TEXT]);
370 Move(rport, left, top);
371 Draw(rport, left, bottom);
372 Move(rport, left + 1, top);
373 Draw(rport, left + 1, bottom);
375 Move(rport, left, bottom);
376 Draw(rport, right, bottom);
377 Move(rport, left, bottom - 1);
378 Draw(rport, right, bottom - 1);
380 Move(rport, right, bottom - 1);
381 Draw(rport, right, edgey);
382 Move(rport, right - 1, bottom - 1);
383 Draw(rport, right - 1, edgey);
385 Move(rport, right, edgey - 1);
386 Draw(rport, edgex, edgey - 1);
387 Draw(rport, edgex, top);
388 Draw(rport, left + 2, top);
389 Move(rport, left + 2, top + 1);
390 Draw(rport, edgex - 1, top + 1);
392 Move(rport, edgex + 1, top);
393 Draw(rport, right, edgey - 1);
397 void popdrawer_draw(struct MUI_RenderInfo *mri, LONG left, LONG top,
398 LONG width, LONG height, LONG state)
400 int right, bottom;
401 int halfx, halfy, quartery;
402 struct RastPort *rport = mri->mri_RastPort;
404 right = left + width - 1;
405 bottom = top + height - 1;
407 halfx = (left + right) / 2;
408 halfy = (top + bottom) / 2;
409 quartery = top + height / 4;
411 SetAPen(rport, mri->mri_Pens[MPEN_TEXT]);
412 Move(rport, left, quartery);
413 Draw(rport, left, bottom);
414 Move(rport, left + 1, quartery);
415 Draw(rport, left + 1, bottom);
416 Draw(rport, right, bottom);
417 Draw(rport, right, halfy);
418 Draw(rport, halfx, halfy);
419 Draw(rport, halfx, quartery);
420 Draw(rport, left + 1, quartery);
422 Move(rport, halfx, quartery - 1);
423 Draw(rport, halfx + 2, top);
424 Draw(rport, right - 2, top);
425 Draw(rport, right, quartery - 1);
426 Draw(rport, right, halfy);
429 static void stddrawer_draw(struct MUI_RenderInfo *mri, LONG left, LONG top,
430 LONG width, LONG height)
432 struct RastPort *rport = mri->mri_RastPort;
433 int right = left + width - 1;
434 int bottom = top + height - 1;
435 int x, y;
437 #define XX(x) (x * (width - 1) / 100)
438 #define YY(y) (y * (height - 1) / 100)
439 #define YOFF 45
440 #define XOFF 24
442 for (y = 0; y < YY(YOFF); y++)
444 x = (YY(XOFF) > 1) ? XX(XOFF) * y / (YY(YOFF) - 1) : 1;
445 SetAPen(rport, mri->mri_Pens[MPEN_SHINE]);
446 RectFill(rport, left + XX(XOFF) - x, top + y, right - XX(XOFF) + x,
447 top + y);
448 SetAPen(rport, mri->mri_Pens[MPEN_SHADOW]);
449 WritePixel(rport, left + XX(XOFF) - x, top + y);
450 WritePixel(rport, right - XX(XOFF) + x, top + y);
454 SetAPen(rport, mri->mri_Pens[MPEN_SHINE]);
455 RectFill(rport, left, top + YY(YOFF), right, bottom);
457 SetAPen(rport, mri->mri_Pens[MPEN_SHADOW]);
458 Move(rport, left + XX(XOFF), top);
459 Draw(rport, right - XX(XOFF), top);
461 Move(rport, left, top + YY(YOFF));
462 Draw(rport, left, bottom);
463 Draw(rport, right, bottom);
464 Draw(rport, right, top + YY(YOFF));
465 Draw(rport, left, top + YY(YOFF));
467 #undef XX
468 #undef YY
469 #undef YOFF
470 #undef XOFF
474 void drawer_draw(struct MUI_RenderInfo *mri, LONG left, LONG top,
475 LONG width, LONG height, LONG state)
477 struct RastPort *rport = mri->mri_RastPort;
478 int right = left + width - 1;
480 stddrawer_draw(mri, left, top, width, height);
482 #define XX(x) x * (width - 1) / 100
483 #define YY(y) y * (height - 1) / 100
485 SetAPen(rport, mri->mri_Pens[MPEN_SHADOW]);
486 Move(rport, left + XX(40), top + YY(75));
487 Draw(rport, right - XX(40), top + YY(75));
489 #undef XX
490 #undef YY
494 void harddisk_draw(struct MUI_RenderInfo *mri, LONG left, LONG top,
495 LONG width, LONG height, LONG state)
497 struct RastPort *rport = mri->mri_RastPort;
499 stddrawer_draw(mri, left, top, width, height);
501 #define XX(x) x * (width - 1) / 100
502 #define YY(y) y * (height - 1) / 100
504 SetAPen(rport, mri->mri_Pens[MPEN_SHADOW]);
505 Move(rport, left + XX(20), top + YY(75));
506 Draw(rport, left + XX(30), top + YY(75));
508 #undef XX
509 #undef YY
512 void disk_draw(struct MUI_RenderInfo *mri, LONG left, LONG top, LONG width,
513 LONG height, LONG state)
515 struct RastPort *rport = mri->mri_RastPort;
516 int right = left + width - 1;
517 int bottom = top + height - 1;
518 int x, y;
520 #define XX(x) (x * (width - 1) / 100)
521 #define YY(y) (y * (height - 1) / 100)
522 #define YOFF 29
523 #define XOFF 25
525 SetAPen(rport, mri->mri_Pens[MPEN_SHADOW]);
526 for (y = 0; y < YY(YOFF); y++)
528 x = (YY(YOFF) > 1) ? XX(XOFF) * y / (YY(YOFF) - 1) : 1;
529 RectFill(rport, left, top + y, right - XX(XOFF) + x, top + y);
531 RectFill(rport, left, top + YY(YOFF), right, bottom);
533 SetAPen(rport, mri->mri_Pens[MPEN_SHINE]);
534 RectFill(rport, left + XX(33), top, right - XX(33), top + YY(YOFF));
535 RectFill(rport, left + XX(25), top + YY(60), right - XX(25), bottom);
537 #undef XX
538 #undef YY
539 #undef YOFF
540 #undef XOFF
543 void ram_draw(struct MUI_RenderInfo *mri, LONG left, LONG top, LONG width,
544 LONG height, LONG state)
546 struct RastPort *rport = mri->mri_RastPort;
547 int right, bottom;
549 #define XX(x) left + x * (width - 1) / 100
550 #define YY(y) top + y * (height - 1) / 100
552 right = left + width - 1;
553 bottom = top + height - 1;
555 SetAPen(rport, mri->mri_Pens[MPEN_SHADOW]);
556 RectFill(rport, left, top, right, bottom);
558 SetAPen(rport, mri->mri_Pens[MPEN_SHINE]);
559 Move(rport, XX(33), YY(20));
560 Draw(rport, XX(33), YY(80));
562 Move(rport, XX(71), YY(20));
563 Draw(rport, XX(61), YY(20));
564 Draw(rport, XX(61), YY(80));
565 Draw(rport, XX(71), YY(80));
567 #undef XX
568 #undef YY
571 void volume_draw(struct MUI_RenderInfo *mri, LONG left, LONG top,
572 LONG width, LONG height, LONG state)
574 struct RastPort *rport = mri->mri_RastPort;
575 int right, bottom;
577 #define XX(x) left + x * (width - 1) / 100
578 #define YY(y) top + y * (height - 1) / 100
580 right = left + width - 1;
581 bottom = top + height - 1;
583 SetAPen(rport, mri->mri_Pens[MPEN_SHADOW]);
584 RectFill(rport, left, top, right, bottom);
586 SetAPen(rport, mri->mri_Pens[MPEN_SHINE]);
587 Move(rport, XX(8), YY(20));
588 Draw(rport, XX(8), YY(60));
589 Draw(rport, XX(16), YY(80));
590 Draw(rport, XX(24), YY(60));
591 Draw(rport, XX(24), YY(20));
593 Move(rport, XX(40), YY(20));
594 Draw(rport, XX(60), YY(20));
595 Draw(rport, XX(60), YY(80));
596 Draw(rport, XX(40), YY(80));
597 Draw(rport, XX(40), YY(20));
599 Move(rport, XX(80), YY(20));
600 Draw(rport, XX(80), YY(80));
601 Draw(rport, XX(92), YY(80));
603 #undef XX
604 #undef YY
607 void network_draw(struct MUI_RenderInfo *mri, LONG left, LONG top,
608 LONG width, LONG height, LONG state)
610 struct RastPort *rport = mri->mri_RastPort;
611 int right = left + width - 1;
613 stddrawer_draw(mri, left, top, width, height);
615 #define XX(x) x * (width - 1) / 100
616 #define YY(y) y * (height - 1) / 100
618 SetAPen(rport, mri->mri_Pens[MPEN_SHADOW]);
619 Move(rport, left + XX(40), top + YY(75));
620 Draw(rport, right - XX(40), top + YY(75));
622 #undef XX
623 #undef YY
626 void assign_draw(struct MUI_RenderInfo *mri, LONG left, LONG top,
627 LONG width, LONG height, LONG state)
629 struct RastPort *rport = mri->mri_RastPort;
630 int right = left + width - 1;
632 stddrawer_draw(mri, left, top, width, height);
634 #define XX(x) x * (width - 1) / 100
635 #define YY(y) y * (height - 1) / 100
637 SetAPen(rport, mri->mri_Pens[MPEN_SHADOW]);
638 Move(rport, left + XX(40), top + YY(75));
639 Draw(rport, right - XX(40), top + YY(75));
641 #undef XX
642 #undef YY
645 void tape_play_draw(struct MUI_RenderInfo *mri, LONG left, LONG top,
646 LONG width, LONG height, LONG state)
648 struct RastPort *rport = mri->mri_RastPort;
649 int x, half = height / 2;
651 SetAPen(rport, mri->mri_Pens[MPEN_SHADOW]);
653 for (x = 0; x < width; x++)
655 int y = (width > 1) ? half * x / (width - 1) : 1;
657 RectFill(rport, left + width - 1 - x, top + half - y,
658 left + width - 1 - x, top + half + y);
662 void tape_playback_draw(struct MUI_RenderInfo *mri, LONG left, LONG top,
663 LONG width, LONG height, LONG state)
665 struct RastPort *rport = mri->mri_RastPort;
666 int x, half = height / 2;
668 SetAPen(rport, mri->mri_Pens[MPEN_SHADOW]);
670 for (x = 0; x < width; x++)
672 int y = (width > 1) ? half * x / (width - 1) : 1;
674 RectFill(rport, left + x, top + half - y, left + x, top + half + y);
678 void tape_pause_draw(struct MUI_RenderInfo *mri, LONG left, LONG top,
679 LONG width, LONG height, LONG state)
681 struct RastPort *rport = mri->mri_RastPort;
683 SetAPen(rport, mri->mri_Pens[MPEN_SHADOW]);
684 RectFill(rport, left, top, left + width / 4, top + height - 1);
685 RectFill(rport, left + width - 1 - width / 4, top, left + width - 1,
686 top + height - 1);
689 void tape_stop_draw(struct MUI_RenderInfo *mri, LONG left, LONG top,
690 LONG width, LONG height, LONG state)
692 struct RastPort *rport = mri->mri_RastPort;
694 SetAPen(rport, mri->mri_Pens[MPEN_TEXT]);
695 RectFill(rport, left, top, left + width - 1, top + height - 1);
698 void tape_record_draw(struct MUI_RenderInfo *mri, LONG left, LONG top,
699 LONG width, LONG height, LONG state)
701 struct RastPort *rport = mri->mri_RastPort;
702 int rx = (width - 1) / 2;
703 int ry = (height - 1) / 2;
704 int x = rx, y = 0; /* ellipse points */
706 /* intermediate terms to speed up loop */
707 int t1 = rx * rx, t2 = t1 << 1, t3 = t2 << 1;
708 int t4 = ry * ry, t5 = t4 << 1, t6 = t5 << 1;
709 int t7 = rx * t5, t8 = t7 << 1, t9 = 0L;
710 int d1 = t2 - t7 + (t4 >> 1); /* error terms */
711 int d2 = (t1 >> 1) - t8 + t5;
713 SetAPen(rport, mri->mri_Pens[MPEN_SHADOW]);
715 while (d2 < 0) /* til slope = -1 */
718 /* draw 4 points using symmetry */
719 RectFill(rport, left + rx - x, top + ry + y, left + rx + x,
720 top + ry + y);
721 RectFill(rport, left + rx - x, top + ry - y, left + rx + x,
722 top + ry - y);
724 y++; /* always move up here */
725 t9 = t9 + t3;
726 if (d1 < 0) /* move straight up */
728 d1 = d1 + t9 + t2;
729 d2 = d2 + t9;
731 else /* move up and left */
733 x--;
734 t8 = t8 - t6;
735 d1 = d1 + t9 + t2 - t8;
736 d2 = d2 + t9 + t5 - t8;
740 do /* rest of top right quadrant */
742 /* draw 4 points using symmetry */
743 RectFill(rport, left + rx - x, top + ry + y, left + rx + x,
744 top + ry + y);
745 RectFill(rport, left + rx - x, top + ry - y, left + rx + x,
746 top + ry - y);
748 x--; /* always move left here */
749 t8 = t8 - t6;
750 if (d2 < 0) /* move up and left */
752 y++;
753 t9 = t9 + t3;
754 d2 = d2 + t9 + t5 - t8;
756 else /* move straight left */
758 d2 = d2 + t5 - t8;
762 while (x >= 0);
766 void tape_up_draw(struct MUI_RenderInfo *mri, LONG left, LONG top,
767 LONG width, LONG height, LONG state)
769 struct RastPort *rport = mri->mri_RastPort;
770 int y, half = width / 2;
772 SetAPen(rport, mri->mri_Pens[MPEN_SHADOW]);
774 for (y = 0; y < height; y++)
776 int x = (height > 1) ? half * y / (height - 1) : 1;
778 RectFill(rport, left + half - x, top + y, left + half + x, top + y);
782 void tape_down_draw(struct MUI_RenderInfo *mri, LONG left, LONG top,
783 LONG width, LONG height, LONG state)
785 struct RastPort *rport = mri->mri_RastPort;
786 int y, half = width / 2;
788 SetAPen(rport, mri->mri_Pens[MPEN_SHADOW]);
790 for (y = 0; y < height; y++)
792 int x = (height > 1) ? half * y / (height - 1) : 1;
794 RectFill(rport, left + half - x, top + height - 1 - y,
795 left + half + x, top + height - 1 - y);
799 struct vector_image
801 int minwidth;
802 int minheight;
803 VECTOR_DRAW_FUNC draw_func;
806 static const struct vector_image vector_table[] = {
807 {8 + 2 * ARROW_SPACING, 8 + 2 * ARROW_SPACING, arrowup_draw},
808 {8 + 2 * ARROW_SPACING, 8 + 2 * ARROW_SPACING, arrowdown_draw},
809 {8 + 2 * ARROW_SPACING, 8 + 2 * ARROW_SPACING, arrowleft_draw},
810 {8 + 2 * ARROW_SPACING, 8 + 2 * ARROW_SPACING, arrowright_draw},
811 {16, 10, checkbox_draw},
812 {10, 10, mx_draw},
813 {15, 8, cycle_draw},
814 {10, 11, popup_draw},
815 {10, 11, popfile_draw},
816 {10, 11, popdrawer_draw},
818 {13, 8, drawer_draw},
819 {13, 8, harddisk_draw},
820 {12, 8, disk_draw},
821 {14, 6, ram_draw},
822 {14, 6, volume_draw},
823 {13, 8, network_draw},
824 {13, 8, assign_draw},
826 {4, 7, tape_play_draw},
827 {4, 7, tape_playback_draw},
828 {6, 7, tape_pause_draw},
829 {6, 7, tape_stop_draw},
830 {7, 7, tape_record_draw},
831 {7, 4, tape_up_draw},
832 {7, 4, tape_down_draw},
835 #define VECTOR_TABLE_ENTRIES (sizeof(vector_table)/sizeof(vector_table[0]))
837 struct MUI_ImageSpec_intern *zune_imspec_create_vector(LONG vect)
839 struct MUI_ImageSpec_intern *spec;
841 if (!(vect >= 0 && vect < VECTOR_TABLE_ENTRIES))
842 return NULL;
844 if ((spec = mui_alloc_struct(struct MUI_ImageSpec_intern)))
846 spec->type = IST_VECTOR;
847 spec->u.vect.type = vect;
848 spec->u.vect.draw = vector_table[vect].draw_func;
850 return spec;
853 BOOL zune_imspec_vector_get_minmax(struct MUI_ImageSpec_intern *spec,
854 struct MUI_MinMax *minmax)
856 if (!spec || spec->type != IST_VECTOR)
857 return FALSE;
858 if ((spec->u.vect.type >= 0)
859 && (spec->u.vect.type < VECTOR_TABLE_ENTRIES))
861 minmax->MinWidth = vector_table[spec->u.vect.type].minwidth;
862 minmax->MinHeight = vector_table[spec->u.vect.type].minheight;
863 minmax->DefWidth = minmax->MinWidth;
864 minmax->DefHeight = minmax->MinHeight;
865 minmax->MaxWidth = MUI_MAXMAX;
866 minmax->MaxHeight = MUI_MAXMAX;
868 else
870 return FALSE;
872 return TRUE;