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
, UWORD sy
, UWORD sw
, UWORD sh
, UWORD dx
, UWORD dy
)
39 for (y
= 0; y
< sh
; y
++)
41 s
= &src
->data
[sx
+ ((sy
+ y
) * src
->w
)];
42 d
= &dest
->data
[dx
+ ((dy
+ y
) * dest
->w
)];
44 for (x
= 0; x
< sw
; x
++)
52 static void DrawTileToImage(BOOL alpha
, BOOL tc
, struct RastPort
*rp
, struct NewImage
*ni
, struct NewImage
*dest
, UWORD _sx
, UWORD _sy
, UWORD _sw
, UWORD _sh
, UWORD _dx
, UWORD _dy
, UWORD _dw
, UWORD _dh
, UWORD posx
, UWORD posy
)
56 LONG dh
, height
, dw
, width
;
58 if (ni
== NULL
) return;
60 if ((_sh
== 0) || (_dh
== 0) || (_sw
== 0) || (_dw
== 0)) return;
67 if ((height
-dh
)<0) dh
= height
;
75 if ((width
-dw
)<0) dw
= width
;
82 DrawPartToImage(ni
, dest
, _sx
, _sy
, dw
, dh
, dx
, dy
);
86 if (alpha
) WritePixelArrayAlpha(ni
->data
, _sx
, _sy
, ni
->w
*4, rp
, dx
+ posx
, dy
+ posy
, dw
, dh
, 0xffffffff); else WritePixelArray(ni
->data
, _sx
, _sy
, ni
->w
*4, rp
, dx
+ posx
, dy
+ posy
, dw
, dh
, RECTFMT_ARGB
);
91 if (ni
->bitmap
!= NULL
)
94 if (ni
->mask
) BltMaskBitMapRastPort(ni
->bitmap
, _sx
, _sy
, rp
, dx
+ posx
, dy
+ posy
, dw
, dh
, 0xe0, (PLANEPTR
) ni
->mask
); else BltBitMapRastPort(ni
->bitmap
, _sx
, _sy
, rp
, dx
+ posx
, dy
+ posy
, dw
, dh
, 0xc0);
98 BltBitMapRastPort(ni
->bitmap
, _sx
, _sy
, rp
, dx
+ posx
, dy
+ posy
, dw
, dh
, 0xc0);
108 static void draw_tile_frame(struct RastPort
*rport
, BOOL tc
, BOOL direct
, BOOL alpha
, struct dt_frame_image
*fi
, struct NewImage
*src
, struct NewImage
*dest
, int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
110 int lw
, rw
, th
, bh
, right
, bottom
, gr
, gb
, lp
, tp
, rp
, bp
, mw
, mh
;
113 right
= left
+ width
;
114 bottom
= top
+ height
;
119 /* calculate the left width of the frame */
122 if (lw
> fi
->tile_left
) lw
= fi
->tile_left
;
123 lw
= fi
->tile_left
- lw
;
125 /* calculate the top height of the frame */
128 if (th
> fi
->tile_top
) th
= fi
->tile_top
;
129 th
= fi
->tile_top
- th
;
131 lp
= fi
->tile_left
- lw
; // left position
132 tp
= fi
->tile_top
- th
;
134 if (right
< (fi
->tile_left
+ gl
)) lw
-= ((fi
->tile_left
+ gl
) - right
);
135 if (bottom
< (fi
->tile_top
+ gt
)) th
-= ((fi
->tile_top
+ gt
) - bottom
);
137 bp
= src
->h
- fi
->tile_bottom
;
138 bh
= fi
->tile_bottom
;
140 if (top
> (gb
- fi
->tile_bottom
))
142 bp
+= (top
- (gb
-fi
->tile_bottom
));
143 bh
-= (top
- (gb
-fi
->tile_bottom
));
145 if (bottom
< gb
) bh
-= (gb
- bottom
);
149 if (bottom
< (gb
- fi
->tile_bottom
)) bh
= 0; else bh
-= (gb
- bottom
);
152 rp
= src
->w
- fi
->tile_right
;
155 if (left
> (gr
- fi
->tile_right
))
157 rp
+= (left
- (gr
-fi
->tile_right
));
158 rw
-= (left
- (gr
-fi
->tile_right
));
160 if (right
< gr
) rw
-= (gr
- right
);
164 if (right
< (gr
- fi
->tile_right
)) rw
= 0; else rw
-= (gr
- right
);
167 mw
= width
- lw
- rw
;
168 mh
= height
- th
- bh
;
172 if (direct
) d
= NULL
; else d
= dest
;
174 DrawTileToImage(alpha
, tc
, rport
, src
, d
, lp
, tp
, lw
, th
, 0 , 0, lw
, th
, left
, top
);
175 DrawTileToImage(alpha
, tc
, rport
, src
, d
, lp
, bp
, lw
, bh
, 0 , height
- bh
, lw
, bh
, left
, top
);
176 DrawTileToImage(alpha
, tc
, rport
, src
, d
, rp
, tp
, rw
, th
, width
- rw
, 0, rw
, th
, left
, top
);
177 DrawTileToImage(alpha
, tc
, rport
, src
, d
, rp
, bp
, rw
, bh
, width
- rw
, height
- bh
, rw
, bh
, left
, top
);
179 DrawTileToImage(alpha
, tc
, rport
, src
, d
, fi
->tile_left
, tp
, src
->w
- fi
->tile_left
- fi
->tile_right
, th
, lw
, 0, mw
, th
, left
, top
);
180 DrawTileToImage(alpha
, tc
, rport
, src
, d
, fi
->tile_left
, bp
, src
->w
- fi
->tile_left
- fi
->tile_right
, bh
, lw
, height
- bh
, mw
, bh
, left
, top
);
182 DrawTileToImage(alpha
, tc
, rport
, src
, d
, lp
, fi
->tile_top
, lw
, src
->h
- fi
->tile_bottom
- fi
->tile_top
, 0 , th
, lw
, mh
, left
, top
);
184 DrawTileToImage(alpha
, tc
, rport
, src
, d
, rp
, fi
->tile_top
, rw
, src
->h
- fi
->tile_bottom
- fi
->tile_top
, width
- rw
, th
, rw
, mh
, left
, top
);
185 DrawTileToImage(alpha
, tc
, rport
, src
, d
, fi
->tile_left
, fi
->tile_top
, src
->w
- fi
->tile_left
- fi
->tile_right
, src
->h
- fi
->tile_bottom
- fi
->tile_top
, lw
, th
, mw
, mh
, left
, top
);
191 struct dt_frame_image
*fi
;
193 WORD gl
, gt
, gw
, gh
, left
, top
, width
, height
, ox
, oy
;
198 STACKED
struct Layer
*Layer
;
199 STACKED
struct Rectangle Bounds
;
200 STACKED LONG OffsetX
;
201 STACKED LONG OffsetY
;
204 AROS_UFH3S(void, WindowPatternBackFillFunc
,
205 AROS_UFHA(struct Hook
*, Hook
, A0
),
206 AROS_UFHA(struct RastPort
*, RP
, A2
),
207 AROS_UFHA(struct BackFillMsg
*, BFM
, A1
))
211 struct FrameFillInfo
*FFI
= (struct FrameFillInfo
*)Hook
; // get the data for our backfillhook
213 ULONG depth
= (ULONG
) GetBitMapAttr(RP
->BitMap
, BMA_DEPTH
);
215 BOOL truecolor
= TRUE
;
217 if (depth
< 15) truecolor
= FALSE
;
219 int left
= BFM
->Bounds
.MinX
;
220 int top
= BFM
->Bounds
.MinY
;
221 int width
= BFM
->Bounds
.MaxX
- left
+ 1;
222 int height
= BFM
->Bounds
.MaxY
- top
+1;
227 BOOL alpha
= !FFI
->fi
->noalpha
;
230 if (!truecolor
) direct
= TRUE
;
234 struct NewImage
*dest
= NewImageContainer(width
, height
);
237 draw_tile_frame(NULL
, truecolor
, FALSE
, alpha
, FFI
->fi
, FFI
->ni
, dest
, FFI
->gl
, FFI
->gt
, FFI
->gw
, FFI
->gh
, left
, top
, width
, height
);
238 if (FFI
->fi
->noalpha
) WritePixelArray(dest
->data
, 0, 0, dest
->w
*4, RP
, left
, top
, width
, height
, RECTFMT_ARGB
); else WritePixelArrayAlpha(dest
->data
, 0, 0, dest
->w
*4, RP
, left
, top
, width
, height
, 0xffffffff);
240 DisposeImageContainer(dest
);
241 } else direct
= TRUE
;
246 draw_tile_frame(RP
, truecolor
, FALSE
, alpha
, FFI
->fi
, FFI
->ni
, NULL
, FFI
->gl
, FFI
->gt
, FFI
->gw
, FFI
->gh
, left
, top
, width
, height
);
252 void dt_do_frame_rects(struct RastPort
*rp
, struct dt_frame_image
*fi
, struct NewImage
*ni
, int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
254 struct Rectangle rect
;
255 struct FrameFillInfo ffi
;
259 rect
.MaxX
= left
+ width
- 1;
260 rect
.MaxY
= top
+ height
- 1;
279 ffi
.Hook
.h_Entry
= (HOOKFUNC
)WindowPatternBackFillFunc
;
283 LockLayer(0, rp
->Layer
);
284 ffi
.ox
= rp
->Layer
->bounds
.MinX
;
285 ffi
.oy
= rp
->Layer
->bounds
.MinY
;
288 DoHookClipRects((struct Hook
*)&ffi
,rp
,&rect
);
292 UnlockLayer(rp
->Layer
);
298 static void frame_custom (struct dt_frame_image
*fi
, BOOL state
, struct MUI_RenderInfo
*mri
,
299 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
301 struct RastPort
*rp
= mri
->mri_RastPort
;
304 if (fi
== NULL
) return;
306 if (state
) ni
= fi
->img_down
; else ni
= fi
->img_up
;
308 if ((fi
->tile_left
+ fi
->tile_right
) > gw
) return;
309 if ((fi
->tile_top
+ fi
->tile_bottom
) > gh
) return;
314 dt_do_frame_rects(rp
, fi
, ni
, gl
, gt
, gw
, gh
, left
, top
, width
, height
);
319 static void frame_custom_up (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
320 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
322 frame_custom(fi
, FALSE
, mri
, gl
, gt
, gw
, gh
, left
, top
, width
, height
);
325 static void frame_custom_down (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
326 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
328 frame_custom(fi
, TRUE
, mri
, gl
, gt
, gw
, gh
, left
, top
, width
, height
);
330 /**************************************************************************
332 **************************************************************************/
333 static void frame_none_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
334 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
338 /**************************************************************************
340 **************************************************************************/
341 static void rect_draw(struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
342 int left
, int top
, int width
, int height
,
345 struct RastPort
*rp
= mri
->mri_RastPort
;
347 SetAPen(rp
, mri
->mri_Pens
[preset_color
]);
349 /* FIXME: usually RectFill() is faster */
351 Draw(rp
, left
+ width
- 1, top
);
352 Draw(rp
, left
+ width
- 1, top
+ height
- 1);
353 Draw(rp
, left
, top
+ height
- 1);
358 /**************************************************************************
360 **************************************************************************/
361 static void frame_white_rect_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
362 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
364 rect_draw(fi
, mri
, left
, top
, width
, height
, MPEN_SHINE
);
367 /**************************************************************************
369 **************************************************************************/
370 static void frame_black_rect_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
371 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
373 rect_draw(fi
, mri
, left
, top
, width
, height
, MPEN_SHADOW
);
376 /**************************************************************************
379 Draw a bicolor rectangle
380 **************************************************************************/
381 static void button_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
382 int left
, int top
, int width
, int height
,
383 MPen ul_preset
, MPen lr_preset
)
385 struct RastPort
*rp
= mri
->mri_RastPort
;
387 SetAPen(rp
, mri
->mri_Pens
[ul_preset
]);
388 Move(rp
, left
, top
+ height
- 2);
390 Draw(rp
, left
+ width
- 2, top
);
392 SetAPen(rp
, mri
->mri_Pens
[lr_preset
]);
393 Move(rp
, left
+ width
- 1, top
);
394 Draw(rp
, left
+ width
- 1, top
+ height
- 1);
395 Draw(rp
, left
, top
+ height
- 1);
397 SetAPen(rp
, mri
->mri_Pens
[MPEN_BACKGROUND
]);
398 WritePixel(rp
, left
, top
+ height
- 1);
399 WritePixel(rp
, left
+ width
- 1, top
);
402 /**************************************************************************
404 **************************************************************************/
405 static void frame_bevelled_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
406 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
408 button_draw(fi
, mri
, left
, top
, width
, height
, MPEN_SHINE
, MPEN_SHADOW
);
411 /**************************************************************************
412 classic pressed button
413 **************************************************************************/
414 static void frame_recessed_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
415 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
417 button_draw(fi
, mri
, left
, top
, width
, height
, MPEN_SHADOW
, MPEN_SHINE
);
420 /**************************************************************************
422 Draw a thin relief border
423 **************************************************************************/
424 static void thinborder_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
425 int left
, int top
, int width
, int height
,
426 MPen ul_preset
, MPen lr_preset
)
428 struct RastPort
*rp
= mri
->mri_RastPort
;
430 SetAPen(rp
, mri
->mri_Pens
[ul_preset
]);
431 Move(rp
, left
, top
+ height
- 1);
433 Draw(rp
, left
+ width
- 1, top
);
435 Move(rp
, left
+ width
- 2, top
+ 2);
436 Draw(rp
, left
+ width
- 2, top
+ height
- 2);
437 Draw(rp
, left
+ 2, top
+ height
- 2);
439 rect_draw(fi
, mri
, left
+1, top
+1, width
-1, height
-1, lr_preset
);
442 /**************************************************************************
444 **************************************************************************/
445 static void frame_thin_border_up_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
446 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
448 thinborder_draw(fi
, mri
, left
, top
, width
, height
, MPEN_SHINE
, MPEN_SHADOW
);
451 /**************************************************************************
453 **************************************************************************/
454 static void frame_thin_border_down_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
455 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
457 thinborder_draw(fi
, mri
, left
, top
, width
, height
, MPEN_SHADOW
, MPEN_SHINE
);
460 /**************************************************************************
462 Draw a thick relief border
463 **************************************************************************/
464 static void thickborder_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
465 int left
, int top
, int width
, int height
,
471 button_draw(fi
, mri
, left
, top
, width
, height
, MPEN_SHINE
, MPEN_SHADOW
);
472 button_draw(fi
, mri
, left
+2, top
+2, width
-4, height
-4, MPEN_SHADOW
, MPEN_SHINE
);
476 button_draw(fi
, mri
, left
, top
, width
, height
, MPEN_SHADOW
, MPEN_SHINE
);
477 button_draw(fi
, mri
, left
+2, top
+2, width
-4, height
-4, MPEN_SHINE
, MPEN_SHADOW
);
480 rect_draw(fi
, mri
, left
+1, top
+1, width
-2, height
-2, MPEN_BACKGROUND
);
483 /**************************************************************************
485 **************************************************************************/
486 static void frame_thick_border_up_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
487 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
489 thickborder_draw(fi
, mri
, left
, top
, width
, height
, TRUE
);
492 /**************************************************************************
493 draw thick border down
494 **************************************************************************/
495 static void frame_thick_border_down_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
496 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
498 thickborder_draw(fi
, mri
, left
, top
, width
, height
, FALSE
);
501 /**************************************************************************
503 **************************************************************************/
504 static void round_bevel_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
505 int left
, int top
, int width
, int height
,
508 SetAPen(mri
->mri_RastPort
, mri
->mri_Pens
[MPEN_BACKGROUND
]);
509 RectFill(mri
->mri_RastPort
,
510 left
, top
, left
+ 3, top
+ height
- 1);
511 RectFill(mri
->mri_RastPort
,
512 left
+ width
- 4, top
, left
+ width
- 1, top
+ height
- 1);
513 rect_draw(fi
, mri
, left
, top
+2, 2, height
-4, ul
);
514 rect_draw(fi
, mri
, left
+1, top
+1, 2, 1, ul
);
515 rect_draw(fi
, mri
, left
+1, top
+ height
- 2, 2, 1, ul
);
516 rect_draw(fi
, mri
, left
+2, top
+ height
- 1, 1, 1, ul
);
517 rect_draw(fi
, mri
, left
+2, top
, width
- 5, 1, ul
);
519 rect_draw(fi
, mri
, left
+ width
- 2, top
+2, 2, height
-4, lr
);
520 rect_draw(fi
, mri
, left
+ width
- 3, top
+1, 2, 1, lr
);
521 rect_draw(fi
, mri
, left
+ width
- 3, top
+ height
- 2, 2, 1, lr
);
522 rect_draw(fi
, mri
, left
+3, top
+ height
- 1, width
- 5, 1, lr
);
523 rect_draw(fi
, mri
, left
+ width
- 3, top
, 1, 1, lr
);
526 /**************************************************************************
528 **************************************************************************/
529 static void frame_round_bevel_up_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
530 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
532 round_bevel_draw (fi
, mri
, left
, top
, width
, height
,
533 MPEN_SHINE
, MPEN_SHADOW
);
536 /**************************************************************************
538 **************************************************************************/
539 static void frame_round_bevel_down_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
540 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
542 round_bevel_draw (fi
, mri
, left
, top
, width
, height
,
543 MPEN_SHADOW
, MPEN_SHINE
);
546 /**************************************************************************
548 **************************************************************************/
549 static void frame_border_button_up_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
550 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
552 rect_draw(fi
, mri
, left
, top
, width
, height
, MPEN_SHADOW
);
553 button_draw(fi
, mri
, left
+1, top
+1, width
-2, height
-2,
554 MPEN_SHINE
, MPEN_HALFSHADOW
);
557 /**************************************************************************
559 **************************************************************************/
560 static void frame_border_button_down_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
561 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
563 button_draw(fi
, mri
, left
+2, top
+2, width
-2, height
-2,
564 MPEN_BACKGROUND
, MPEN_SHADOW
);
565 button_draw(fi
, mri
, left
+1, top
+1, width
-1, height
-1,
566 MPEN_HALFSHADOW
, MPEN_SHADOW
);
567 rect_draw(fi
, mri
, left
, top
, width
, height
, MPEN_SHADOW
);
570 /**************************************************************************
571 7 : FST_ROUND_THICK_BORDER
572 **************************************************************************/
573 static void round_thick_border_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
574 int left
, int top
, int width
, int height
,
575 MPen pen1
, MPen pen2
, MPen pen3
, MPen pen4
, MPen pen5
)
577 struct RastPort
*rp
= mri
->mri_RastPort
;
579 rect_draw(fi
, mri
, left
, top
, width
- 2, height
- 2, pen1
);
580 rect_draw(fi
, mri
, left
+ 2, top
+ 2, width
- 2, height
- 2, pen5
);
582 rect_draw(fi
, mri
, left
, top
, 2, 2, pen2
);
583 rect_draw(fi
, mri
, left
, top
+ height
- 3, 2, 2, pen2
);
584 rect_draw(fi
, mri
, left
+ width
- 3, top
, 2, 2, pen2
);
586 rect_draw(fi
, mri
, left
+ width
- 2, top
+ height
- 2, 2, 2, pen4
);
587 rect_draw(fi
, mri
, left
+ 1, top
+ height
- 2, 2, 2, pen4
);
588 rect_draw(fi
, mri
, left
+ width
- 2, top
+ 1, 2, 2, pen4
);
590 rect_draw(fi
, mri
, left
+ 1, top
+ 1, width
- 2, height
- 2, pen3
);
592 rect_draw(fi
, mri
, left
+ 2, top
+ 2, 2, 2, pen3
);
593 rect_draw(fi
, mri
, left
+ 2, top
+ height
- 4, 2, 2, pen3
);
594 rect_draw(fi
, mri
, left
+ width
- 4, top
+ height
- 4, 2, 2, pen3
);
595 rect_draw(fi
, mri
, left
+ width
- 4, top
+ 2, 2, 2, pen3
);
597 /* these points were not in the original frame. -dlc */
598 SetAPen(rp
, mri
->mri_Pens
[pen5
]);
599 WritePixel(rp
, left
+ 3, top
+ 3);
601 SetAPen(rp
, mri
->mri_Pens
[pen1
]);
602 WritePixel(rp
, left
+ width
- 4, top
+ height
- 4);
605 /**************************************************************************
607 **************************************************************************/
608 static void frame_round_thick_border_up_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
609 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
611 round_thick_border_draw(fi
, mri
, left
, top
, width
, height
,
612 MPEN_SHINE
, MPEN_HALFSHINE
, MPEN_BACKGROUND
,
613 MPEN_HALFSHADOW
, MPEN_SHADOW
);
616 /**************************************************************************
618 **************************************************************************/
619 static void frame_round_thick_border_down_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
620 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
622 round_thick_border_draw(fi
, mri
, left
, top
, width
, height
,
623 MPEN_SHADOW
, MPEN_HALFSHADOW
, MPEN_BACKGROUND
,
624 MPEN_HALFSHINE
, MPEN_SHINE
);
627 /**************************************************************************
628 8 : FST_ROUND_THIN_BORDER
629 **************************************************************************/
630 static void round_thin_border_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
631 int left
, int top
, int width
, int height
,
632 MPen pen1
, MPen pen2
, MPen pen3
, MPen pen4
, MPen pen5
)
634 struct RastPort
*rp
= mri
->mri_RastPort
;
636 rect_draw(fi
, mri
, left
, top
, width
- 1, height
- 1, pen1
);
637 rect_draw(fi
, mri
, left
+ 1, top
+ 1, width
- 1, height
- 1, pen5
);
639 rect_draw(fi
, mri
, left
, top
, 2, 2, pen2
);
640 rect_draw(fi
, mri
, left
+ width
- 4, top
+ height
- 4, 2, 2, pen2
);
641 rect_draw(fi
, mri
, left
+ 2, top
+ 2, 2, 2, pen4
);
642 rect_draw(fi
, mri
, left
+ width
- 2, top
+ height
- 2, 2, 2, pen4
);
643 rect_draw(fi
, mri
, left
+ 1, top
+ 1, 2, 2, pen3
);
644 rect_draw(fi
, mri
, left
+ width
- 3, top
+ height
- 3, 2, 2, pen3
);
646 rect_draw(fi
, mri
, left
+ 1, top
+ height
- 3, 1, 3, pen4
);
647 rect_draw(fi
, mri
, left
+ width
- 3, top
+ 1, 3, 1, pen4
);
649 WritePixel(rp
, left
+ 2, top
+ height
- 3);
650 WritePixel(rp
, left
+ width
- 3, top
+ 2);
652 SetAPen(rp
, mri
->mri_Pens
[pen2
]);
653 WritePixel(rp
, left
, top
+ height
- 2);
654 WritePixel(rp
, left
+ 2, top
+ height
- 2);
655 WritePixel(rp
, left
+ width
- 2, top
);
656 WritePixel(rp
, left
+ width
- 2, top
+ 2);
659 /**************************************************************************
661 **************************************************************************/
662 static void frame_round_thin_border_up_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
663 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
665 round_thin_border_draw(fi
, mri
, left
, top
, width
, height
,
666 MPEN_SHINE
, MPEN_HALFSHINE
, MPEN_BACKGROUND
,
667 MPEN_HALFSHADOW
, MPEN_SHADOW
);
670 /**************************************************************************
672 **************************************************************************/
673 static void frame_round_thin_border_down_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
674 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
676 round_thin_border_draw(fi
, mri
, left
, top
, width
, height
,
677 MPEN_SHADOW
, MPEN_HALFSHADOW
, MPEN_BACKGROUND
,
678 MPEN_HALFSHINE
, MPEN_SHINE
);
681 /**************************************************************************
683 **************************************************************************/
684 static void frame_gray_border_up_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
685 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
687 thinborder_draw(fi
, mri
, left
, top
, width
, height
,
688 MPEN_HALFSHINE
, MPEN_HALFSHADOW
);
691 /**************************************************************************
693 **************************************************************************/
694 static void frame_gray_border_down_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
695 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
697 thinborder_draw(fi
, mri
, left
, top
, width
, height
,
698 MPEN_HALFSHADOW
, MPEN_HALFSHINE
);
701 /**************************************************************************
702 A : FST_SEMIROUND_BEVEL
703 **************************************************************************/
704 static void semiround_bevel_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
705 int left
, int top
, int width
, int height
,
706 MPen pen1
, MPen pen2
, MPen pen3
, MPen pen4
, MPen pen5
)
708 struct RastPort
*rp
= mri
->mri_RastPort
;
710 button_draw(fi
, mri
, left
, top
, width
, height
, pen1
, pen5
);
711 button_draw(fi
, mri
, left
+1, top
+1, width
-2, height
-2, pen2
, pen4
);
713 SetAPen(rp
, mri
->mri_Pens
[pen2
]);
714 WritePixel(rp
, left
, top
);
716 SetAPen(rp
, mri
->mri_Pens
[pen1
]);
717 WritePixel(rp
, left
+ 1, top
+ 1);
719 SetAPen(mri
->mri_RastPort
, mri
->mri_Pens
[pen5
]);
720 WritePixel(rp
, left
+ width
- 2, top
+ height
- 2);
722 SetAPen(mri
->mri_RastPort
, mri
->mri_Pens
[pen4
]);
723 WritePixel(rp
, left
+ width
- 1, top
+ height
- 1);
725 SetAPen(mri
->mri_RastPort
, mri
->mri_Pens
[pen3
]);
726 WritePixel(rp
, left
, top
+ height
- 2);
727 WritePixel(rp
, left
+ 1, top
+ height
- 1);
728 WritePixel(rp
, left
+ width
- 2, top
);
729 WritePixel(rp
, left
+ width
- 1, top
+ 1);
732 /**************************************************************************
734 **************************************************************************/
735 static void frame_semiround_bevel_up_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
736 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
738 semiround_bevel_draw (fi
, mri
, left
, top
, width
, height
,
739 MPEN_SHINE
, MPEN_HALFSHINE
, MPEN_BACKGROUND
,
740 MPEN_HALFSHADOW
, MPEN_SHADOW
);
743 /**************************************************************************
745 **************************************************************************/
746 static void frame_semiround_bevel_down_draw (struct dt_frame_image
*fi
, struct MUI_RenderInfo
*mri
,
747 int gl
, int gt
, int gw
, int gh
, int left
, int top
, int width
, int height
)
749 semiround_bevel_draw (fi
, mri
, left
, top
, width
, height
,
750 MPEN_SHADOW
, MPEN_HALFSHADOW
, MPEN_BACKGROUND
,
751 MPEN_HALFSHINE
, MPEN_SHINE
);
754 /**************************************************************************
756 **************************************************************************/
757 static const struct ZuneFrameGfx __builtinFrameGfx
[] = {
758 /* type 0 : FST_NONE */
759 {frame_none_draw
, 0, 0, 0, 0, 0},
760 {frame_none_draw
, 0, 0, 0, 0, 0},
762 /* monochrome border */
764 {frame_white_rect_draw
, 0, 1, 1, 1, 1},
765 {frame_black_rect_draw
, 0, 1, 1, 1, 1},
769 {frame_bevelled_draw
, 0, 1, 1, 1, 1},
770 {frame_recessed_draw
, 0, 1, 1, 1, 1},
772 /* thin relief border */
773 /* 3 : FST_THIN_BORDER */
774 {frame_thin_border_up_draw
, 0, 2, 2, 2, 2},
775 {frame_thin_border_down_draw
, 0, 2, 2, 2, 2},
777 /* thick relief border */
778 /* 4 : FST_THICK_BORDER */
779 {frame_thick_border_up_draw
, 0, 3, 3, 3, 3},
780 {frame_thick_border_down_draw
, 0, 3, 3, 3, 3},
783 /* 5 : FST_ROUND_BEVEL */
784 {frame_round_bevel_up_draw
, 0, 4, 4, 1, 1},
785 {frame_round_bevel_down_draw
, 0, 4, 4, 1, 1},
788 /* 6 : FST_WIN_BEVEL */
789 {frame_border_button_up_draw
, 0, 2, 2, 2, 2},
790 {frame_border_button_down_draw
, 0, 3, 1, 3, 1},
792 /* rounded thick border */
793 /* 7 : FST_ROUND_THICK_BORDER */
794 {frame_round_thick_border_up_draw
, 0, 4, 4, 4, 4},
795 {frame_round_thick_border_down_draw
, 0, 4, 4, 4, 4},
797 /* rounded thin border */
798 /* 8 : FST_ROUND_THIN_BORDER */
799 {frame_round_thin_border_up_draw
, 0, 4, 4, 4, 4},
800 {frame_round_thin_border_down_draw
, 0, 4, 4, 4, 4},
802 /* strange gray border */
803 /* 9 : FST_GRAY_BORDER */
804 {frame_gray_border_up_draw
, 0, 2, 2, 2, 2},
805 {frame_gray_border_down_draw
, 0, 2, 2, 2, 2},
807 /* semi rounded bevel */
808 /* A : FST_SEMIROUND_BEVEL */
809 {frame_semiround_bevel_up_draw
, 0, 2, 2, 2, 2},
810 {frame_semiround_bevel_down_draw
, 0, 2, 2, 2, 2},
814 {frame_custom_up
, 1, 0, 0, 0, 0},
815 {frame_custom_down
, 1, 0, 0, 0, 0},
817 {frame_custom_up
, 2, 0, 0, 0, 0},
818 {frame_custom_down
, 2, 0, 0, 0, 0},
820 {frame_custom_up
, 3, 0, 0, 0, 0},
821 {frame_custom_down
, 3, 0, 0, 0, 0},
823 {frame_custom_up
, 4, 0, 0, 0, 0},
824 {frame_custom_down
, 4, 0, 0, 0, 0},
826 {frame_custom_up
, 5, 0, 0, 0, 0},
827 {frame_custom_down
, 5, 0, 0, 0, 0},
829 {frame_custom_up
, 6, 0, 0, 0, 0},
830 {frame_custom_down
, 6, 0, 0, 0, 0},
832 {frame_custom_up
, 7, 0, 0, 0, 0},
833 {frame_custom_down
, 7, 0, 0, 0, 0},
835 {frame_custom_up
, 8, 0, 0, 0, 0},
836 {frame_custom_down
, 8, 0, 0, 0, 0},
838 {frame_custom_up
, 9, 0, 0, 0, 0},
839 {frame_custom_down
, 9, 0, 0, 0, 0},
841 {frame_custom_up
, 10, 0, 0, 0, 0},
842 {frame_custom_down
, 10, 0, 0, 0, 0},
844 {frame_custom_up
, 11, 0, 0, 0, 0},
845 {frame_custom_down
, 11, 0, 0, 0, 0},
847 {frame_custom_up
, 12, 0, 0, 0, 0},
848 {frame_custom_down
, 12, 0, 0, 0, 0},
850 {frame_custom_up
, 13, 0, 0, 0, 0},
851 {frame_custom_down
, 13, 0, 0, 0, 0},
853 {frame_custom_up
, 14, 0, 0, 0, 0},
854 {frame_custom_down
, 14, 0, 0, 0, 0},
856 {frame_custom_up
, 15, 0, 0, 0, 0},
857 {frame_custom_down
, 15, 0, 0, 0, 0},
859 {frame_custom_up
, 16, 0, 0, 0, 0},
860 {frame_custom_down
, 16, 0, 0, 0, 0},
865 /**************************************************************************
867 **************************************************************************/
868 const struct ZuneFrameGfx
*zune_zframe_get (Object
*obj
, const struct MUI_FrameSpec_intern
*frameSpec
)
870 struct dt_frame_image
*fi
= NULL
;
872 if (frameSpec
->type
>= FST_CUSTOM1
)
874 struct MUI_RenderInfo
*mri
= muiRenderInfo(obj
);
875 if (!(fi
= mri
->mri_FrameImage
[frameSpec
->type
- FST_CUSTOM1
]))
876 return &__builtinFrameGfx
[2 * FST_RECT
];
879 if (frameSpec
->type
>= FST_COUNT
)
880 return &__builtinFrameGfx
[2 * FST_RECT
];
882 return &__builtinFrameGfx
[2 * frameSpec
->type
+ frameSpec
->state
];
885 frame
->customframe
= NULL
;
887 if ((fi
!= NULL
) && (frame
!= NULL
))
889 frame
->customframe
= fi
;
890 frame
->ileft
= fi
->inner_left
;
891 frame
->itop
= fi
->inner_top
;
892 frame
->iright
= fi
->inner_right
;
893 frame
->ibottom
= fi
->inner_bottom
;
894 frame
->noalpha
= fi
->noalpha
;
902 const struct ZuneFrameGfx
*zune_zframe_get_with_state (Object
*obj
, const struct MUI_FrameSpec_intern
*frameSpec
,
905 struct dt_frame_image
*fi
= NULL
;
907 if (frameSpec
->type
>= FST_CUSTOM1
)
909 struct MUI_RenderInfo
*mri
= muiRenderInfo(obj
);
910 if (!(fi
= mri
->mri_FrameImage
[frameSpec
->type
- FST_CUSTOM1
]))
911 return &__builtinFrameGfx
[2 * FST_RECT
];
914 if (frameSpec
->type
>= FST_COUNT
)
915 return &__builtinFrameGfx
[2 * FST_RECT
];
917 return &__builtinFrameGfx
[2 * frameSpec
->type
+ state
];
920 /*------------------------------------------------------------------------*/
922 BOOL
zune_frame_intern_to_spec (const struct MUI_FrameSpec_intern
*intern
,
925 if (!intern
|| !spec
)
930 if (intern
->type
< 10) sp
= ((char) intern
->type
) + '0'; else sp
= ((char) intern
->type
- 10 ) + 'a';
932 /* Must cast to LONG because on AmigaOS SNPrintf() is used which is like
933 * RawDoFmt() 16 bit */
934 snprintf(&spec
[0], 2, "%c", sp
);
935 snprintf(&spec
[1], 2, "%lx", (LONG
)intern
->state
);
936 snprintf(&spec
[2], 2, "%lx", (LONG
)intern
->innerLeft
);
937 snprintf(&spec
[3], 2, "%lx", (LONG
)intern
->innerRight
);
938 snprintf(&spec
[4], 2, "%lx", (LONG
)intern
->innerTop
);
939 snprintf(&spec
[5], 2, "%lx", (LONG
)intern
->innerBottom
);
940 /* 0 byte is ensured through snprintf */
944 /*------------------------------------------------------------------------*/
946 static int xhexasciichar_to_int(char x
)
948 if (x
>= '0' && x
<= '9') return x
- '0';
949 if (x
>= 'a' && x
<= 'z') return x
- 'a' + 10;
950 if (x
>= 'A' && x
<= 'Z') return x
- 'A' + 10;
954 BOOL
zune_frame_spec_to_intern(CONST_STRPTR spec
,
955 struct MUI_FrameSpec_intern
*intern
)
959 if (!intern
|| !spec
)
962 val
= xhexasciichar_to_int(spec
[0]);
963 if (val
== -1) return FALSE
;
966 val
= xhexasciichar_to_int(spec
[1]);
967 if (val
== -1) return FALSE
;
970 val
= xhexasciichar_to_int(spec
[2]);
971 if (val
== -1) return FALSE
;
972 intern
->innerLeft
= val
;
974 val
= xhexasciichar_to_int(spec
[3]);
975 if (val
== -1) return FALSE
;
976 intern
->innerRight
= val
;
978 val
= xhexasciichar_to_int(spec
[4]);
979 if (val
== -1) return FALSE
;
980 intern
->innerTop
= val
;
982 val
= xhexasciichar_to_int(spec
[5]);
983 if (val
== -1) return FALSE
;
984 intern
->innerBottom
= val
;