2 Copyright 1999, David Le Corfec.
3 Copyright 2002, The AROS Development Team.
9 #include <exec/types.h>
10 #include <cybergraphx/cybergraphics.h>
12 #include <proto/graphics.h>
13 #include <proto/cybergraphics.h>
14 #include <proto/layers.h>
18 #include "muimaster_intern.h"
19 #include "datatypescache.h"
25 extern struct Library
*MUIMasterBase
;
27 /**************************************************************************
29 **************************************************************************/
31 void DrawPartToImage(struct NewImage
*src
, struct NewImage
*dest
, UWORD sx
,
32 UWORD sy
, UWORD sw
, UWORD sh
, UWORD dx
, UWORD dy
)
40 for (y
= 0; y
< sh
; y
++)
42 s
= &src
->data
[sx
+ ((sy
+ y
) * src
->w
)];
43 d
= &dest
->data
[dx
+ ((dy
+ y
) * dest
->w
)];
45 for (x
= 0; x
< sw
; x
++)
53 static void DrawTileToImage(BOOL alpha
, BOOL tc
, struct RastPort
*rp
,
54 struct NewImage
*ni
, struct NewImage
*dest
, UWORD _sx
, UWORD _sy
,
55 UWORD _sw
, UWORD _sh
, UWORD _dx
, UWORD _dy
, UWORD _dw
, UWORD _dh
,
56 UWORD posx
, UWORD posy
)
60 LONG dh
, height
, dw
, width
;
65 if ((_sh
== 0) || (_dh
== 0) || (_sw
== 0) || (_dw
== 0))
73 if ((height
- dh
) < 0)
90 DrawPartToImage(ni
, dest
, _sx
, _sy
, dw
, dh
, dx
, dy
);
95 WritePixelArrayAlpha(ni
->data
, _sx
, _sy
, ni
->w
* 4,
96 rp
, dx
+ posx
, dy
+ posy
, dw
, dh
, 0xffffffff);
98 WritePixelArray(ni
->data
, _sx
, _sy
, ni
->w
* 4, rp
,
99 dx
+ posx
, dy
+ posy
, dw
, dh
, RECTFMT_ARGB
);
104 if (ni
->bitmap
!= NULL
)
109 BltMaskBitMapRastPort(ni
->bitmap
, _sx
, _sy
, rp
,
110 dx
+ posx
, dy
+ posy
, dw
, dh
, 0xe0,
111 (PLANEPTR
) ni
->mask
);
113 BltBitMapRastPort(ni
->bitmap
, _sx
, _sy
, rp
,
114 dx
+ posx
, dy
+ posy
, dw
, dh
, 0xc0);
118 BltBitMapRastPort(ni
->bitmap
, _sx
, _sy
, rp
,
119 dx
+ posx
, dy
+ posy
, dw
, dh
, 0xc0);
129 static void draw_tile_frame(struct RastPort
*rport
, BOOL tc
, BOOL direct
,
130 BOOL alpha
, struct dt_frame_image
*fi
, struct NewImage
*src
,
131 struct NewImage
*dest
, int gl
, int gt
, int gw
, int gh
, int left
,
132 int top
, int width
, int height
)
134 int lw
, rw
, th
, bh
, right
, bottom
, gr
, gb
, lp
, tp
, rp
, bp
, mw
, mh
;
137 right
= left
+ width
;
138 bottom
= top
+ height
;
143 /* calculate the left width of the frame */
146 if (lw
> fi
->tile_left
)
148 lw
= fi
->tile_left
- lw
;
150 /* calculate the top height of the frame */
153 if (th
> fi
->tile_top
)
155 th
= fi
->tile_top
- th
;
157 lp
= fi
->tile_left
- lw
; // left position
158 tp
= fi
->tile_top
- th
;
160 if (right
< (fi
->tile_left
+ gl
))
161 lw
-= ((fi
->tile_left
+ gl
) - right
);
162 if (bottom
< (fi
->tile_top
+ gt
))
163 th
-= ((fi
->tile_top
+ gt
) - bottom
);
165 bp
= src
->h
- fi
->tile_bottom
;
166 bh
= fi
->tile_bottom
;
168 if (top
> (gb
- fi
->tile_bottom
))
170 bp
+= (top
- (gb
- fi
->tile_bottom
));
171 bh
-= (top
- (gb
- fi
->tile_bottom
));
178 if (bottom
< (gb
- fi
->tile_bottom
))
184 rp
= src
->w
- fi
->tile_right
;
187 if (left
> (gr
- fi
->tile_right
))
189 rp
+= (left
- (gr
- fi
->tile_right
));
190 rw
-= (left
- (gr
- fi
->tile_right
));
197 if (right
< (gr
- fi
->tile_right
))
203 mw
= width
- lw
- rw
;
204 mh
= height
- th
- bh
;
213 DrawTileToImage(alpha
, tc
, rport
, src
, d
, lp
, tp
, lw
, th
, 0, 0, lw
, th
,
215 DrawTileToImage(alpha
, tc
, rport
, src
, d
, lp
, bp
, lw
, bh
, 0,
216 height
- bh
, lw
, bh
, left
, top
);
217 DrawTileToImage(alpha
, tc
, rport
, src
, d
, rp
, tp
, rw
, th
, width
- rw
, 0,
219 DrawTileToImage(alpha
, tc
, rport
, src
, d
, rp
, bp
, rw
, bh
, width
- rw
,
220 height
- bh
, rw
, bh
, left
, top
);
222 DrawTileToImage(alpha
, tc
, rport
, src
, d
, fi
->tile_left
, tp
,
223 src
->w
- fi
->tile_left
- fi
->tile_right
, th
, lw
, 0, mw
, th
, left
,
225 DrawTileToImage(alpha
, tc
, rport
, src
, d
, fi
->tile_left
, bp
,
226 src
->w
- fi
->tile_left
- fi
->tile_right
, bh
, lw
, height
- bh
, mw
,
229 DrawTileToImage(alpha
, tc
, rport
, src
, d
, lp
, fi
->tile_top
, lw
,
230 src
->h
- fi
->tile_bottom
- fi
->tile_top
, 0, th
, lw
, mh
, left
, top
);
232 DrawTileToImage(alpha
, tc
, rport
, src
, d
, rp
, fi
->tile_top
, rw
,
233 src
->h
- fi
->tile_bottom
- fi
->tile_top
, width
- rw
, th
, rw
, mh
,
235 DrawTileToImage(alpha
, tc
, rport
, src
, d
, fi
->tile_left
, fi
->tile_top
,
236 src
->w
- fi
->tile_left
- fi
->tile_right
,
237 src
->h
- fi
->tile_bottom
- fi
->tile_top
, lw
, th
, mw
, mh
, left
, top
);
243 struct dt_frame_image
*fi
;
245 WORD gl
, gt
, gw
, gh
, left
, top
, width
, height
, ox
, oy
;
250 STACKED
struct Layer
*Layer
;
251 STACKED
struct Rectangle Bounds
;
252 STACKED LONG OffsetX
;
253 STACKED LONG OffsetY
;
256 AROS_UFH3S(void, WindowPatternBackFillFunc
,
257 AROS_UFHA(struct Hook
*, Hook
, A0
),
258 AROS_UFHA(struct RastPort
*, RP
, A2
),
259 AROS_UFHA(struct BackFillMsg
*, BFM
, A1
))
263 // get the data for our backfillhook
264 struct FrameFillInfo
*FFI
= (struct FrameFillInfo
*)Hook
;
266 ULONG depth
= (ULONG
) GetBitMapAttr(RP
->BitMap
, BMA_DEPTH
);
268 BOOL truecolor
= TRUE
;
273 int left
= BFM
->Bounds
.MinX
;
274 int top
= BFM
->Bounds
.MinY
;
275 int width
= BFM
->Bounds
.MaxX
- left
+ 1;
276 int height
= BFM
->Bounds
.MaxY
- top
+ 1;
281 BOOL alpha
= !FFI
->fi
->noalpha
;
289 struct NewImage
*dest
= NewImageContainer(width
, height
);
292 draw_tile_frame(NULL
, truecolor
, FALSE
, alpha
, FFI
->fi
, FFI
->ni
,
293 dest
, FFI
->gl
, FFI
->gt
, FFI
->gw
, FFI
->gh
, left
, top
, width
,
295 if (FFI
->fi
->noalpha
)
296 WritePixelArray(dest
->data
, 0, 0, dest
->w
* 4, RP
, left
, top
,
297 width
, height
, RECTFMT_ARGB
);
299 WritePixelArrayAlpha(dest
->data
, 0, 0, dest
->w
* 4, RP
, left
,
300 top
, width
, height
, 0xffffffff);
302 DisposeImageContainer(dest
);
310 draw_tile_frame(RP
, truecolor
, FALSE
, alpha
, FFI
->fi
, FFI
->ni
, NULL
,
311 FFI
->gl
, FFI
->gt
, FFI
->gw
, FFI
->gh
, left
, top
, width
, height
);
317 void dt_do_frame_rects(struct RastPort
*rp
, struct dt_frame_image
*fi
,
318 struct NewImage
*ni
, int gl
, int gt
, int gw
, int gh
, int left
, int top
,
319 int width
, int height
)
321 struct Rectangle rect
;
322 struct FrameFillInfo ffi
;
326 rect
.MaxX
= left
+ width
- 1;
327 rect
.MaxY
= top
+ height
- 1;
346 ffi
.Hook
.h_Entry
= (HOOKFUNC
) WindowPatternBackFillFunc
;
350 LockLayer(0, rp
->Layer
);
351 ffi
.ox
= rp
->Layer
->bounds
.MinX
;
352 ffi
.oy
= rp
->Layer
->bounds
.MinY
;
355 DoHookClipRects((struct Hook
*)&ffi
, rp
, &rect
);
359 UnlockLayer(rp
->Layer
);
365 static void frame_custom(struct dt_frame_image
*fi
, BOOL state
,
366 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
367 int top
, int width
, int height
)
369 struct RastPort
*rp
= mri
->mri_RastPort
;
380 if ((fi
->tile_left
+ fi
->tile_right
) > gw
)
382 if ((fi
->tile_top
+ fi
->tile_bottom
) > gh
)
388 dt_do_frame_rects(rp
, fi
, ni
, gl
, gt
, gw
, gh
, left
, top
, width
,
394 static void frame_custom_up(struct dt_frame_image
*fi
,
395 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
396 int top
, int width
, int height
)
398 frame_custom(fi
, FALSE
, mri
, gl
, gt
, gw
, gh
, left
, top
, width
, height
);
401 static void frame_custom_down(struct dt_frame_image
*fi
,
402 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
403 int top
, int width
, int height
)
405 frame_custom(fi
, TRUE
, mri
, gl
, gt
, gw
, gh
, left
, top
, width
, height
);
407 /**************************************************************************
409 **************************************************************************/
410 static void frame_none_draw(struct dt_frame_image
*fi
,
411 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
412 int top
, int width
, int height
)
416 /**************************************************************************
418 **************************************************************************/
419 static void rect_draw(struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
420 int left
, int top
, int width
, int height
, MPen preset_color
)
422 struct RastPort
*rp
= mri
->mri_RastPort
;
424 SetAPen(rp
, mri
->mri_Pens
[preset_color
]);
426 /* FIXME: usually RectFill() is faster */
428 Draw(rp
, left
+ width
- 1, top
);
429 Draw(rp
, left
+ width
- 1, top
+ height
- 1);
430 Draw(rp
, left
, top
+ height
- 1);
435 /**************************************************************************
437 **************************************************************************/
438 static void frame_white_rect_draw(struct dt_frame_image
*fi
,
439 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
440 int top
, int width
, int height
)
442 rect_draw(fi
, mri
, left
, top
, width
, height
, MPEN_SHINE
);
445 /**************************************************************************
447 **************************************************************************/
448 static void frame_black_rect_draw(struct dt_frame_image
*fi
,
449 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
450 int top
, int width
, int height
)
452 rect_draw(fi
, mri
, left
, top
, width
, height
, MPEN_SHADOW
);
455 /**************************************************************************
458 Draw a bicolor rectangle
459 **************************************************************************/
460 static void button_draw(struct dt_frame_image
*fi
,
461 struct MUI_RenderInfo
*mri
, int left
, int top
, int width
, int height
,
462 MPen ul_preset
, MPen lr_preset
)
464 struct RastPort
*rp
= mri
->mri_RastPort
;
466 SetAPen(rp
, mri
->mri_Pens
[ul_preset
]);
467 Move(rp
, left
, top
+ height
- 2);
469 Draw(rp
, left
+ width
- 2, top
);
471 SetAPen(rp
, mri
->mri_Pens
[lr_preset
]);
472 Move(rp
, left
+ width
- 1, top
);
473 Draw(rp
, left
+ width
- 1, top
+ height
- 1);
474 Draw(rp
, left
, top
+ height
- 1);
476 SetAPen(rp
, mri
->mri_Pens
[MPEN_BACKGROUND
]);
477 WritePixel(rp
, left
, top
+ height
- 1);
478 WritePixel(rp
, left
+ width
- 1, top
);
481 /**************************************************************************
483 **************************************************************************/
484 static void frame_bevelled_draw(struct dt_frame_image
*fi
,
485 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
486 int top
, int width
, int height
)
488 button_draw(fi
, mri
, left
, top
, width
, height
, MPEN_SHINE
, MPEN_SHADOW
);
491 /**************************************************************************
492 classic pressed button
493 **************************************************************************/
494 static void frame_recessed_draw(struct dt_frame_image
*fi
,
495 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
496 int top
, int width
, int height
)
498 button_draw(fi
, mri
, left
, top
, width
, height
, MPEN_SHADOW
, MPEN_SHINE
);
501 /**************************************************************************
503 Draw a thin relief border
504 **************************************************************************/
505 static void thinborder_draw(struct dt_frame_image
*fi
,
506 struct MUI_RenderInfo
*mri
, int left
, int top
, int width
, int height
,
507 MPen ul_preset
, MPen lr_preset
)
509 struct RastPort
*rp
= mri
->mri_RastPort
;
511 SetAPen(rp
, mri
->mri_Pens
[ul_preset
]);
512 Move(rp
, left
, top
+ height
- 1);
514 Draw(rp
, left
+ width
- 1, top
);
516 Move(rp
, left
+ width
- 2, top
+ 2);
517 Draw(rp
, left
+ width
- 2, top
+ height
- 2);
518 Draw(rp
, left
+ 2, top
+ height
- 2);
520 rect_draw(fi
, mri
, left
+ 1, top
+ 1, width
- 1, height
- 1, lr_preset
);
523 /**************************************************************************
525 **************************************************************************/
526 static void frame_thin_border_up_draw(struct dt_frame_image
*fi
,
527 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
528 int top
, int width
, int height
)
530 thinborder_draw(fi
, mri
, left
, top
, width
, height
, MPEN_SHINE
,
534 /**************************************************************************
536 **************************************************************************/
537 static void frame_thin_border_down_draw(struct dt_frame_image
*fi
,
538 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
539 int top
, int width
, int height
)
541 thinborder_draw(fi
, mri
, left
, top
, width
, height
, MPEN_SHADOW
,
545 /**************************************************************************
547 Draw a thick relief border
548 **************************************************************************/
549 static void thickborder_draw(struct dt_frame_image
*fi
,
550 struct MUI_RenderInfo
*mri
, int left
, int top
, int width
, int height
,
555 button_draw(fi
, mri
, left
, top
, width
, height
, MPEN_SHINE
,
557 button_draw(fi
, mri
, left
+ 2, top
+ 2, width
- 4, height
- 4,
558 MPEN_SHADOW
, MPEN_SHINE
);
562 button_draw(fi
, mri
, left
, top
, width
, height
, MPEN_SHADOW
,
564 button_draw(fi
, mri
, left
+ 2, top
+ 2, width
- 4, height
- 4,
565 MPEN_SHINE
, MPEN_SHADOW
);
568 rect_draw(fi
, mri
, left
+ 1, top
+ 1, width
- 2, height
- 2,
572 /**************************************************************************
574 **************************************************************************/
575 static void frame_thick_border_up_draw(struct dt_frame_image
*fi
,
576 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
577 int top
, int width
, int height
)
579 thickborder_draw(fi
, mri
, left
, top
, width
, height
, TRUE
);
582 /**************************************************************************
583 draw thick border down
584 **************************************************************************/
585 static void frame_thick_border_down_draw(struct dt_frame_image
*fi
,
586 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
587 int top
, int width
, int height
)
589 thickborder_draw(fi
, mri
, left
, top
, width
, height
, FALSE
);
592 /**************************************************************************
594 **************************************************************************/
595 static void round_bevel_draw(struct dt_frame_image
*fi
,
596 struct MUI_RenderInfo
*mri
, int left
, int top
, int width
, int height
,
599 SetAPen(mri
->mri_RastPort
, mri
->mri_Pens
[MPEN_BACKGROUND
]);
600 RectFill(mri
->mri_RastPort
, left
, top
, left
+ 3, top
+ height
- 1);
601 RectFill(mri
->mri_RastPort
,
602 left
+ width
- 4, top
, left
+ width
- 1, top
+ height
- 1);
603 rect_draw(fi
, mri
, left
, top
+ 2, 2, height
- 4, ul
);
604 rect_draw(fi
, mri
, left
+ 1, top
+ 1, 2, 1, ul
);
605 rect_draw(fi
, mri
, left
+ 1, top
+ height
- 2, 2, 1, ul
);
606 rect_draw(fi
, mri
, left
+ 2, top
+ height
- 1, 1, 1, ul
);
607 rect_draw(fi
, mri
, left
+ 2, top
, width
- 5, 1, ul
);
609 rect_draw(fi
, mri
, left
+ width
- 2, top
+ 2, 2, height
- 4, lr
);
610 rect_draw(fi
, mri
, left
+ width
- 3, top
+ 1, 2, 1, lr
);
611 rect_draw(fi
, mri
, left
+ width
- 3, top
+ height
- 2, 2, 1, lr
);
612 rect_draw(fi
, mri
, left
+ 3, top
+ height
- 1, width
- 5, 1, lr
);
613 rect_draw(fi
, mri
, left
+ width
- 3, top
, 1, 1, lr
);
616 /**************************************************************************
618 **************************************************************************/
619 static void frame_round_bevel_up_draw(struct dt_frame_image
*fi
,
620 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
621 int top
, int width
, int height
)
623 round_bevel_draw(fi
, mri
, left
, top
, width
, height
,
624 MPEN_SHINE
, MPEN_SHADOW
);
627 /**************************************************************************
629 **************************************************************************/
630 static void frame_round_bevel_down_draw(struct dt_frame_image
*fi
,
631 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
632 int top
, int width
, int height
)
634 round_bevel_draw(fi
, mri
, left
, top
, width
, height
,
635 MPEN_SHADOW
, MPEN_SHINE
);
638 /**************************************************************************
640 **************************************************************************/
641 static void frame_border_button_up_draw(struct dt_frame_image
*fi
,
642 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
643 int top
, int width
, int height
)
645 rect_draw(fi
, mri
, left
, top
, width
, height
, MPEN_SHADOW
);
646 button_draw(fi
, mri
, left
+ 1, top
+ 1, width
- 2, height
- 2,
647 MPEN_SHINE
, MPEN_HALFSHADOW
);
650 /**************************************************************************
652 **************************************************************************/
653 static void frame_border_button_down_draw(struct dt_frame_image
*fi
,
654 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
655 int top
, int width
, int height
)
657 button_draw(fi
, mri
, left
+ 2, top
+ 2, width
- 2, height
- 2,
658 MPEN_BACKGROUND
, MPEN_SHADOW
);
659 button_draw(fi
, mri
, left
+ 1, top
+ 1, width
- 1, height
- 1,
660 MPEN_HALFSHADOW
, MPEN_SHADOW
);
661 rect_draw(fi
, mri
, left
, top
, width
, height
, MPEN_SHADOW
);
664 /**************************************************************************
665 7 : FST_ROUND_THICK_BORDER
666 **************************************************************************/
667 static void round_thick_border_draw(struct dt_frame_image
*fi
,
668 struct MUI_RenderInfo
*mri
, int left
, int top
, int width
, int height
,
669 MPen pen1
, MPen pen2
, MPen pen3
, MPen pen4
, MPen pen5
)
671 struct RastPort
*rp
= mri
->mri_RastPort
;
673 rect_draw(fi
, mri
, left
, top
, width
- 2, height
- 2, pen1
);
674 rect_draw(fi
, mri
, left
+ 2, top
+ 2, width
- 2, height
- 2, pen5
);
676 rect_draw(fi
, mri
, left
, top
, 2, 2, pen2
);
677 rect_draw(fi
, mri
, left
, top
+ height
- 3, 2, 2, pen2
);
678 rect_draw(fi
, mri
, left
+ width
- 3, top
, 2, 2, pen2
);
680 rect_draw(fi
, mri
, left
+ width
- 2, top
+ height
- 2, 2, 2, pen4
);
681 rect_draw(fi
, mri
, left
+ 1, top
+ height
- 2, 2, 2, pen4
);
682 rect_draw(fi
, mri
, left
+ width
- 2, top
+ 1, 2, 2, pen4
);
684 rect_draw(fi
, mri
, left
+ 1, top
+ 1, width
- 2, height
- 2, pen3
);
686 rect_draw(fi
, mri
, left
+ 2, top
+ 2, 2, 2, pen3
);
687 rect_draw(fi
, mri
, left
+ 2, top
+ height
- 4, 2, 2, pen3
);
688 rect_draw(fi
, mri
, left
+ width
- 4, top
+ height
- 4, 2, 2, pen3
);
689 rect_draw(fi
, mri
, left
+ width
- 4, top
+ 2, 2, 2, pen3
);
691 /* these points were not in the original frame. -dlc */
692 SetAPen(rp
, mri
->mri_Pens
[pen5
]);
693 WritePixel(rp
, left
+ 3, top
+ 3);
695 SetAPen(rp
, mri
->mri_Pens
[pen1
]);
696 WritePixel(rp
, left
+ width
- 4, top
+ height
- 4);
699 /**************************************************************************
701 **************************************************************************/
702 static void frame_round_thick_border_up_draw(struct dt_frame_image
*fi
,
703 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
704 int top
, int width
, int height
)
706 round_thick_border_draw(fi
, mri
, left
, top
, width
, height
,
707 MPEN_SHINE
, MPEN_HALFSHINE
, MPEN_BACKGROUND
,
708 MPEN_HALFSHADOW
, MPEN_SHADOW
);
711 /**************************************************************************
713 **************************************************************************/
714 static void frame_round_thick_border_down_draw(struct dt_frame_image
*fi
,
715 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
716 int top
, int width
, int height
)
718 round_thick_border_draw(fi
, mri
, left
, top
, width
, height
,
719 MPEN_SHADOW
, MPEN_HALFSHADOW
, MPEN_BACKGROUND
,
720 MPEN_HALFSHINE
, MPEN_SHINE
);
723 /**************************************************************************
724 8 : FST_ROUND_THIN_BORDER
725 **************************************************************************/
726 static void round_thin_border_draw(struct dt_frame_image
*fi
,
727 struct MUI_RenderInfo
*mri
, int left
, int top
, int width
, int height
,
728 MPen pen1
, MPen pen2
, MPen pen3
, MPen pen4
, MPen pen5
)
730 struct RastPort
*rp
= mri
->mri_RastPort
;
732 rect_draw(fi
, mri
, left
, top
, width
- 1, height
- 1, pen1
);
733 rect_draw(fi
, mri
, left
+ 1, top
+ 1, width
- 1, height
- 1, pen5
);
735 rect_draw(fi
, mri
, left
, top
, 2, 2, pen2
);
736 rect_draw(fi
, mri
, left
+ width
- 4, top
+ height
- 4, 2, 2, pen2
);
737 rect_draw(fi
, mri
, left
+ 2, top
+ 2, 2, 2, pen4
);
738 rect_draw(fi
, mri
, left
+ width
- 2, top
+ height
- 2, 2, 2, pen4
);
739 rect_draw(fi
, mri
, left
+ 1, top
+ 1, 2, 2, pen3
);
740 rect_draw(fi
, mri
, left
+ width
- 3, top
+ height
- 3, 2, 2, pen3
);
742 rect_draw(fi
, mri
, left
+ 1, top
+ height
- 3, 1, 3, pen4
);
743 rect_draw(fi
, mri
, left
+ width
- 3, top
+ 1, 3, 1, pen4
);
745 WritePixel(rp
, left
+ 2, top
+ height
- 3);
746 WritePixel(rp
, left
+ width
- 3, top
+ 2);
748 SetAPen(rp
, mri
->mri_Pens
[pen2
]);
749 WritePixel(rp
, left
, top
+ height
- 2);
750 WritePixel(rp
, left
+ 2, top
+ height
- 2);
751 WritePixel(rp
, left
+ width
- 2, top
);
752 WritePixel(rp
, left
+ width
- 2, top
+ 2);
755 /**************************************************************************
757 **************************************************************************/
758 static void frame_round_thin_border_up_draw(struct dt_frame_image
*fi
,
759 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
760 int top
, int width
, int height
)
762 round_thin_border_draw(fi
, mri
, left
, top
, width
, height
,
763 MPEN_SHINE
, MPEN_HALFSHINE
, MPEN_BACKGROUND
,
764 MPEN_HALFSHADOW
, MPEN_SHADOW
);
767 /**************************************************************************
769 **************************************************************************/
770 static void frame_round_thin_border_down_draw(struct dt_frame_image
*fi
,
771 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
772 int top
, int width
, int height
)
774 round_thin_border_draw(fi
, mri
, left
, top
, width
, height
,
775 MPEN_SHADOW
, MPEN_HALFSHADOW
, MPEN_BACKGROUND
,
776 MPEN_HALFSHINE
, MPEN_SHINE
);
779 /**************************************************************************
781 **************************************************************************/
782 static void frame_gray_border_up_draw(struct dt_frame_image
*fi
,
783 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
784 int top
, int width
, int height
)
786 thinborder_draw(fi
, mri
, left
, top
, width
, height
,
787 MPEN_HALFSHINE
, MPEN_HALFSHADOW
);
790 /**************************************************************************
792 **************************************************************************/
793 static void frame_gray_border_down_draw(struct dt_frame_image
*fi
,
794 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
795 int top
, int width
, int height
)
797 thinborder_draw(fi
, mri
, left
, top
, width
, height
,
798 MPEN_HALFSHADOW
, MPEN_HALFSHINE
);
801 /**************************************************************************
802 A : FST_SEMIROUND_BEVEL
803 **************************************************************************/
804 static void semiround_bevel_draw(struct dt_frame_image
*fi
,
805 struct MUI_RenderInfo
*mri
, int left
, int top
, int width
, int height
,
806 MPen pen1
, MPen pen2
, MPen pen3
, MPen pen4
, MPen pen5
)
808 struct RastPort
*rp
= mri
->mri_RastPort
;
810 button_draw(fi
, mri
, left
, top
, width
, height
, pen1
, pen5
);
811 button_draw(fi
, mri
, left
+ 1, top
+ 1, width
- 2, height
- 2, pen2
,
814 SetAPen(rp
, mri
->mri_Pens
[pen2
]);
815 WritePixel(rp
, left
, top
);
817 SetAPen(rp
, mri
->mri_Pens
[pen1
]);
818 WritePixel(rp
, left
+ 1, top
+ 1);
820 SetAPen(mri
->mri_RastPort
, mri
->mri_Pens
[pen5
]);
821 WritePixel(rp
, left
+ width
- 2, top
+ height
- 2);
823 SetAPen(mri
->mri_RastPort
, mri
->mri_Pens
[pen4
]);
824 WritePixel(rp
, left
+ width
- 1, top
+ height
- 1);
826 SetAPen(mri
->mri_RastPort
, mri
->mri_Pens
[pen3
]);
827 WritePixel(rp
, left
, top
+ height
- 2);
828 WritePixel(rp
, left
+ 1, top
+ height
- 1);
829 WritePixel(rp
, left
+ width
- 2, top
);
830 WritePixel(rp
, left
+ width
- 1, top
+ 1);
833 /**************************************************************************
835 **************************************************************************/
836 static void frame_semiround_bevel_up_draw(struct dt_frame_image
*fi
,
837 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
838 int top
, int width
, int height
)
840 semiround_bevel_draw(fi
, mri
, left
, top
, width
, height
,
841 MPEN_SHINE
, MPEN_HALFSHINE
, MPEN_BACKGROUND
,
842 MPEN_HALFSHADOW
, MPEN_SHADOW
);
845 /**************************************************************************
847 **************************************************************************/
848 static void frame_semiround_bevel_down_draw(struct dt_frame_image
*fi
,
849 struct MUI_RenderInfo
*mri
, int gl
, int gt
, int gw
, int gh
, int left
,
850 int top
, int width
, int height
)
852 semiround_bevel_draw(fi
, mri
, left
, top
, width
, height
,
853 MPEN_SHADOW
, MPEN_HALFSHADOW
, MPEN_BACKGROUND
,
854 MPEN_HALFSHINE
, MPEN_SHINE
);
857 /**************************************************************************
859 **************************************************************************/
860 static const struct ZuneFrameGfx __builtinFrameGfx
[] = {
861 /* type 0 : FST_NONE */
862 {frame_none_draw
, 0, 0, 0, 0, 0},
863 {frame_none_draw
, 0, 0, 0, 0, 0},
865 /* monochrome border */
867 {frame_white_rect_draw
, 0, 1, 1, 1, 1},
868 {frame_black_rect_draw
, 0, 1, 1, 1, 1},
872 {frame_bevelled_draw
, 0, 1, 1, 1, 1},
873 {frame_recessed_draw
, 0, 1, 1, 1, 1},
875 /* thin relief border */
876 /* 3 : FST_THIN_BORDER */
877 {frame_thin_border_up_draw
, 0, 2, 2, 2, 2},
878 {frame_thin_border_down_draw
, 0, 2, 2, 2, 2},
880 /* thick relief border */
881 /* 4 : FST_THICK_BORDER */
882 {frame_thick_border_up_draw
, 0, 3, 3, 3, 3},
883 {frame_thick_border_down_draw
, 0, 3, 3, 3, 3},
886 /* 5 : FST_ROUND_BEVEL */
887 {frame_round_bevel_up_draw
, 0, 4, 4, 1, 1},
888 {frame_round_bevel_down_draw
, 0, 4, 4, 1, 1},
891 /* 6 : FST_WIN_BEVEL */
892 {frame_border_button_up_draw
, 0, 2, 2, 2, 2},
893 {frame_border_button_down_draw
, 0, 3, 1, 3, 1},
895 /* rounded thick border */
896 /* 7 : FST_ROUND_THICK_BORDER */
897 {frame_round_thick_border_up_draw
, 0, 4, 4, 4, 4},
898 {frame_round_thick_border_down_draw
, 0, 4, 4, 4, 4},
900 /* rounded thin border */
901 /* 8 : FST_ROUND_THIN_BORDER */
902 {frame_round_thin_border_up_draw
, 0, 4, 4, 4, 4},
903 {frame_round_thin_border_down_draw
, 0, 4, 4, 4, 4},
905 /* strange gray border */
906 /* 9 : FST_GRAY_BORDER */
907 {frame_gray_border_up_draw
, 0, 2, 2, 2, 2},
908 {frame_gray_border_down_draw
, 0, 2, 2, 2, 2},
910 /* semi rounded bevel */
911 /* A : FST_SEMIROUND_BEVEL */
912 {frame_semiround_bevel_up_draw
, 0, 2, 2, 2, 2},
913 {frame_semiround_bevel_down_draw
, 0, 2, 2, 2, 2},
917 {frame_custom_up
, 1, 0, 0, 0, 0},
918 {frame_custom_down
, 1, 0, 0, 0, 0},
920 {frame_custom_up
, 2, 0, 0, 0, 0},
921 {frame_custom_down
, 2, 0, 0, 0, 0},
923 {frame_custom_up
, 3, 0, 0, 0, 0},
924 {frame_custom_down
, 3, 0, 0, 0, 0},
926 {frame_custom_up
, 4, 0, 0, 0, 0},
927 {frame_custom_down
, 4, 0, 0, 0, 0},
929 {frame_custom_up
, 5, 0, 0, 0, 0},
930 {frame_custom_down
, 5, 0, 0, 0, 0},
932 {frame_custom_up
, 6, 0, 0, 0, 0},
933 {frame_custom_down
, 6, 0, 0, 0, 0},
935 {frame_custom_up
, 7, 0, 0, 0, 0},
936 {frame_custom_down
, 7, 0, 0, 0, 0},
938 {frame_custom_up
, 8, 0, 0, 0, 0},
939 {frame_custom_down
, 8, 0, 0, 0, 0},
941 {frame_custom_up
, 9, 0, 0, 0, 0},
942 {frame_custom_down
, 9, 0, 0, 0, 0},
944 {frame_custom_up
, 10, 0, 0, 0, 0},
945 {frame_custom_down
, 10, 0, 0, 0, 0},
947 {frame_custom_up
, 11, 0, 0, 0, 0},
948 {frame_custom_down
, 11, 0, 0, 0, 0},
950 {frame_custom_up
, 12, 0, 0, 0, 0},
951 {frame_custom_down
, 12, 0, 0, 0, 0},
953 {frame_custom_up
, 13, 0, 0, 0, 0},
954 {frame_custom_down
, 13, 0, 0, 0, 0},
956 {frame_custom_up
, 14, 0, 0, 0, 0},
957 {frame_custom_down
, 14, 0, 0, 0, 0},
959 {frame_custom_up
, 15, 0, 0, 0, 0},
960 {frame_custom_down
, 15, 0, 0, 0, 0},
962 {frame_custom_up
, 16, 0, 0, 0, 0},
963 {frame_custom_down
, 16, 0, 0, 0, 0},
968 /**************************************************************************
970 **************************************************************************/
971 const struct ZuneFrameGfx
*zune_zframe_get(Object
*obj
,
972 const struct MUI_FrameSpec_intern
*frameSpec
)
974 struct dt_frame_image
*fi
= NULL
;
976 if (frameSpec
->type
>= FST_CUSTOM1
)
978 struct MUI_RenderInfo
*mri
= muiRenderInfo(obj
);
979 if (!(fi
= mri
->mri_FrameImage
[frameSpec
->type
- FST_CUSTOM1
]))
980 return &__builtinFrameGfx
[2 * FST_RECT
];
983 if (frameSpec
->type
>= FST_COUNT
)
984 return &__builtinFrameGfx
[2 * FST_RECT
];
986 return &__builtinFrameGfx
[2 * frameSpec
->type
+ frameSpec
->state
];
989 frame
->customframe
= NULL
;
991 if ((fi
!= NULL
) && (frame
!= NULL
))
993 frame
->customframe
= fi
;
994 frame
->ileft
= fi
->inner_left
;
995 frame
->itop
= fi
->inner_top
;
996 frame
->iright
= fi
->inner_right
;
997 frame
->ibottom
= fi
->inner_bottom
;
998 frame
->noalpha
= fi
->noalpha
;
1006 const struct ZuneFrameGfx
*zune_zframe_get_with_state(Object
*obj
,
1007 const struct MUI_FrameSpec_intern
*frameSpec
, UWORD state
)
1009 struct dt_frame_image
*fi
= NULL
;
1011 if (frameSpec
->type
>= FST_CUSTOM1
)
1013 struct MUI_RenderInfo
*mri
= muiRenderInfo(obj
);
1014 if (!(fi
= mri
->mri_FrameImage
[frameSpec
->type
- FST_CUSTOM1
]))
1015 return &__builtinFrameGfx
[2 * FST_RECT
];
1018 if (frameSpec
->type
>= FST_COUNT
)
1019 return &__builtinFrameGfx
[2 * FST_RECT
];
1021 return &__builtinFrameGfx
[2 * frameSpec
->type
+ state
];
1024 /*------------------------------------------------------------------------*/
1026 BOOL
zune_frame_intern_to_spec(const struct MUI_FrameSpec_intern
*intern
,
1029 if (!intern
|| !spec
)
1034 if (intern
->type
< 10)
1035 sp
= ((char)intern
->type
) + '0';
1037 sp
= ((char)intern
->type
- 10) + 'a';
1039 /* Must cast to LONG because on AmigaOS SNPrintf() is used which is like
1040 * RawDoFmt() 16 bit */
1041 snprintf(&spec
[0], 2, "%c", sp
);
1042 snprintf(&spec
[1], 2, "%lx", (long)intern
->state
);
1043 snprintf(&spec
[2], 2, "%lx", (long)intern
->innerLeft
);
1044 snprintf(&spec
[3], 2, "%lx", (long)intern
->innerRight
);
1045 snprintf(&spec
[4], 2, "%lx", (long)intern
->innerTop
);
1046 snprintf(&spec
[5], 2, "%lx", (long)intern
->innerBottom
);
1047 /* 0 byte is ensured through snprintf */
1051 /*------------------------------------------------------------------------*/
1053 static int xhexasciichar_to_int(char x
)
1055 if (x
>= '0' && x
<= '9')
1057 if (x
>= 'a' && x
<= 'z')
1058 return x
- 'a' + 10;
1059 if (x
>= 'A' && x
<= 'Z')
1060 return x
- 'A' + 10;
1064 BOOL
zune_frame_spec_to_intern(CONST_STRPTR spec
,
1065 struct MUI_FrameSpec_intern
*intern
)
1069 if (!intern
|| !spec
)
1072 val
= xhexasciichar_to_int(spec
[0]);
1077 val
= xhexasciichar_to_int(spec
[1]);
1080 intern
->state
= val
;
1082 val
= xhexasciichar_to_int(spec
[2]);
1085 intern
->innerLeft
= val
;
1087 val
= xhexasciichar_to_int(spec
[3]);
1090 intern
->innerRight
= val
;
1092 val
= xhexasciichar_to_int(spec
[4]);
1095 intern
->innerTop
= val
;
1097 val
= xhexasciichar_to_int(spec
[5]);
1100 intern
->innerBottom
= val
;