2 #include <intuition/classusr.h>
3 #include <intuition/windecorclass.h>
4 #include <intuition/scrdecorclass.h>
5 #include <graphics/rpattr.h>
6 #include <graphics/gfxmacros.h>
7 #include <utility/tagitem.h>
9 #include <proto/exec.h>
10 #include <proto/graphics.h>
11 #include <proto/layers.h>
12 #include <proto/intuition.h>
13 #include <proto/utility.h>
14 #include <proto/cybergraphics.h>
15 #include <clib/alib_protos.h>
19 #include <aros/debug.h>
21 /**************************************************************************************************/
23 struct IClass
*cl
, *scrcl
;
24 Object
*thisdecorobj
, *olddecorobj
;
25 Object
*thisscrdecorobj
, *oldscrdecorobj
;
29 #define ACTIVE_1 0x6c7be9
30 #define ACTIVE_2 0x00006e
31 #define INACTIVE_1 0xeeeeee
32 #define INACTIVE_2 0x888888
34 /**************************************************************************************************/
42 /**************************************************************************************************/
44 static void CheckRectFill(struct RastPort
*rp
, LONG x1
, LONG y1
, LONG x2
, LONG y2
)
50 if ((x2
< x1
) || (y2
< y1
)) return;
52 GetRPAttrs(rp
, RPTAG_FgColor
, &fgcolor
, RPTAG_BgColor
, &bgcolor
, TAG_DONE
);
54 if ((fgcolor
== bgcolor
) || (y1
== y2
))
56 RectFill(rp
, x1
, y1
, x2
, y2
);
60 LONG r1
= (fgcolor
>> 16) & 0xFF;
61 LONG g1
= (fgcolor
>> 8) & 0xFF;
62 LONG b1
= fgcolor
& 0xFF;
63 LONG r2
= (bgcolor
>> 16) & 0xFF;
64 LONG g2
= (bgcolor
>> 8) & 0xFF;
65 LONG b2
= bgcolor
& 0xFF;
67 for(y
= y1
; y
<= y2
; y
++)
73 r
= r1
+ (r2
- r1
) * mul
/ div
;
74 g
= g1
+ (g2
- g1
) * mul
/ div
;
75 b
= b1
+ (b2
- b1
) * mul
/ div
;
77 rgb
= (r
<< 16) + (g
<< 8) + b
;
79 SetRPAttrs(rp
, RPTAG_FgColor
, rgb
, TAG_DONE
);
80 RectFill(rp
, x1
, y
, x2
, y
);
84 SetRPAttrs(rp
, RPTAG_FgColor
, fgcolor
, TAG_DONE
);
89 /**************************************************************************************************/
91 static IPTR
windecor_new(Class
*cl
, Object
*obj
, struct opSet
*msg
)
93 struct windecor_data
*data
;
95 obj
= (Object
*)DoSuperMethodA(cl
, obj
, (Msg
)msg
);
98 data
= INST_DATA(cl
, obj
);
100 data
->dri
= (struct DrawInfo
*)GetTagData(WDA_DrawInfo
, 0, msg
->ops_AttrList
);
101 data
->scr
= (struct Screen
*)GetTagData(WDA_Screen
, 0, msg
->ops_AttrList
);
103 if (!data
->dri
|| !data
->scr
)
105 STACKULONG method
= OM_DISPOSE
;
107 CoerceMethodA(cl
, obj
, (Msg
)&method
);
117 /**************************************************************************************************/
119 static IPTR
windecor_get(Class
*cl
, Object
*obj
, struct opGet
*msg
)
121 //struct windecor_data *data = INST_DATA(cl, obj);
123 switch(msg
->opg_AttrID
)
125 case WDA_TrueColorOnly
:
126 *msg
->opg_Storage
= TRUE
;
130 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
137 /**************************************************************************************************/
141 #define HSPACING_MIDDLE 2
142 #define VSPACING_MIDDLE 2
143 #define HSPACING_SMALL 1
144 #define VSPACING_SMALL 1
146 static void renderimageframe(struct RastPort
*rp
, ULONG which
, ULONG state
, UWORD
*pens
,
147 WORD left
, WORD top
, WORD width
, WORD height
)
149 WORD right
= left
+ width
- 1;
150 WORD bottom
= top
+ height
- 1;
152 SetAPen(rp
, pens
[SHADOWPEN
]);
164 RectFill(rp
, left
+ 1,
169 SetAPen(rp
, pens
[SHINEPEN
]);
178 RectFill(rp
, left
+ 1,
186 SetAPen(rp
, pens
[((state
== IDS_SELECTED
) || (state
== IDS_INACTIVESELECTED
)) ? SHADOWPEN
: SHINEPEN
]);
195 RectFill(rp
, left
+ 1,
200 SetAPen(rp
, pens
[((state
== IDS_SELECTED
) || (state
== IDS_INACTIVESELECTED
)) ? SHINEPEN
: SHADOWPEN
]);
209 RectFill(rp
, left
+ 1,
215 /**************************************************************************************************/
217 static UWORD
getbgpen(ULONG state
, UWORD
*pens
)
229 bg
= pens
[BACKGROUNDPEN
];
236 /**************************************************************************************************/
238 static void drawrect(struct RastPort
*rp
, WORD x1
, WORD y1
, WORD x2
, WORD y2
)
242 /* We RectFill() because it is generally faster than Draw()
243 (Draw() uses Set/GetPixel() while RectFill() can do higherlevel
244 clipping. Also it is MUCH faster in the x11gfx hidd.
247 RectFill(rp
, x1
, y1
, x2
- 1, y1
); /* Top */
248 RectFill(rp
, x2
, y1
, x2
, y2
- 1); /* Right */
249 RectFill(rp
, x1
+ 1, y2
, x2
, y2
); /* Bottom */
250 RectFill(rp
, x1
, y1
+ 1, x1
, y2
); /* Left */
255 /**************************************************************************************************/
257 IPTR
windecor_draw_sysimage(Class
*cl
, Object
*obj
, struct wdpDrawSysImage
*msg
)
259 struct windecor_data
*data
= INST_DATA(cl
, obj
);
260 struct RastPort
*rp
= msg
->wdp_RPort
;
261 UWORD
*pens
= data
->dri
->dri_Pens
;
262 LONG state
= msg
->wdp_State
;
263 LONG left
= msg
->wdp_X
;
264 LONG top
= msg
->wdp_Y
;
265 LONG width
= msg
->wdp_Width
;
266 LONG height
= msg
->wdp_Height
;
267 LONG right
= left
+ width
- 1;
268 LONG bottom
= top
+ height
- 1;
269 LONG h_spacing
, v_spacing
;
273 switch(msg
->wdp_Which
)
278 right
-= 3; bottom
-= 3;
279 width
-= 6; height
-= 6;
281 renderimageframe(rp
, CLOSEIMAGE
, state
, pens
, left
, top
, width
, height
);
287 right
= left
+ width
- 1;
288 bottom
= top
+ height
- 1;
289 h_spacing
= width
* 4 / 10;
290 v_spacing
= height
* 3 / 10;
293 SetAPen(rp
, getbgpen(state
, pens
));
294 RectFill(rp
, left
, top
, right
, bottom
);
301 SetAPen(rp
, pens
[SHADOWPEN
]);
302 RectFill(rp
, left
, top
, right
, bottom
);
309 SetAPen(rp
, pens
[(state
== IDS_NORMAL
) ? SHINEPEN
: BACKGROUNDPEN
]);
310 RectFill(rp
, left
, top
, right
, bottom
);
322 right
-= 3; bottom
-= 3;
323 width
-= 6; height
-= 6;
325 renderimageframe(rp
, ZOOMIMAGE
, state
, pens
,
326 left
, top
, width
, height
);
332 right
= left
+ width
- 1;
333 bottom
= top
+ height
- 1 ;
334 h_spacing
= width
/ 6;
335 v_spacing
= height
/ 6;
337 bg
= getbgpen(state
, pens
);
340 /* Clear background into correct color */
342 RectFill(rp
, left
, top
, right
, bottom
);
350 SetAPen(rp
, pens
[SHADOWPEN
]);
351 RectFill(rp
, left
, top
, right
, bottom
);
353 SetAPen(rp
, pens
[(state
== IDS_SELECTED
) ? SHINEPEN
:
354 (state
== IDS_NORMAL
) ? FILLPEN
: BACKGROUNDPEN
]);
355 RectFill(rp
, left
+ 1, top
+ 1, right
- 1, bottom
- 1);
357 right
= left
+ (right
- left
+ 1) / 2;
358 bottom
= top
+ (bottom
- top
+ 1) / 2;
360 if (right
- left
< 4) right
= left
+ 4;
362 SetAPen(rp
, pens
[SHADOWPEN
]);
363 RectFill(rp
, left
, top
, right
, bottom
);
370 SetAPen(rp
, pens
[(state
== IDS_SELECTED
) ? FILLPEN
:
371 (state
== IDS_NORMAL
) ? SHINEPEN
: BACKGROUNDPEN
]);
372 RectFill(rp
,left
, top
, right
, bottom
);
383 right
-= 3; bottom
-= 3;
384 width
-= 6; height
-= 6;
386 renderimageframe(rp
, DEPTHIMAGE
, state
, pens
,
387 left
, top
, width
, height
);
395 h_spacing
= width
/ 6;
396 v_spacing
= height
/ 6;
398 bg
= getbgpen(state
, pens
);
401 /* Clear background into correct color */
403 RectFill(rp
, left
, top
, right
, bottom
);
406 /* Draw a image of two partly overlapped tiny windows,
412 width
-= h_spacing
* 2;
413 height
-= v_spacing
* 2;
415 right
= left
+ width
- 1;
416 bottom
= top
+ height
- 1;
418 /* Render top left window */
420 SetAPen(rp
, pens
[SHADOWPEN
]);
424 , right
- (width
/ 3 )
425 , bottom
- (height
/ 3));
428 /* Fill top left window (inside of the frame above) */
430 if ((state
!= IDS_INACTIVENORMAL
))
432 SetAPen(rp
, pens
[BACKGROUNDPEN
]);
433 RectFill(rp
, left
+ 1, top
+ 1,
434 right
- (width
/ 3) - 1, bottom
- (height
/ 3) - 1);
438 /* Render bottom right window */
439 SetAPen(rp
, pens
[SHADOWPEN
]);
440 drawrect(rp
, left
+ (width
/ 3), top
+ (height
/ 3),
443 /* Fill bottom right window (inside of the frame above) */
444 SetAPen(rp
, pens
[(state
== IDS_INACTIVENORMAL
) ? BACKGROUNDPEN
: SHINEPEN
]);
445 RectFill(rp
, left
+ (width
/ 3) + 1, top
+ (height
/ 3) + 1,
446 right
- 1, bottom
- 1);
448 if (state
== IDS_SELECTED
)
450 /* Re-Render top left window */
452 SetAPen(rp
, pens
[SHADOWPEN
]);
453 drawrect(rp
, left
, top
,
454 right
- (width
/ 3 ), bottom
- (height
/ 3));
467 renderimageframe(rp
, SIZEIMAGE
, state
, pens
,
468 left
, top
, width
, height
);
477 h_spacing
= width
/ 5;
478 v_spacing
= height
/ 5;
480 bg
= getbgpen(state
, pens
);
483 /* Clear background into correct color */
485 RectFill(rp
, left
, top
, right
, bottom
);
488 /* A triangle image */
493 right
= left
+ width
- 1 - (h_spacing
* 2);
494 bottom
= top
+ height
- 1 - (v_spacing
* 2);
496 width
= right
- left
+ 1;
497 height
= bottom
- top
+ 1;
499 if (state
!= IDS_INACTIVENORMAL
)
501 SetAPen(rp
, pens
[state
== IDS_SELECTED
? BACKGROUNDPEN
: SHINEPEN
]);
503 for(y
= top
; y
<= bottom
; y
++)
505 x
= left
+ (bottom
- y
) * width
/ height
;
506 RectFill(rp
, x
, y
, right
, y
);
510 SetAPen(rp
, pens
[SHADOWPEN
]);
511 /* Draw triangle border */
512 Move(rp
, left
, bottom
);
513 Draw(rp
, right
, top
);
514 Draw(rp
, right
, bottom
);
515 Draw(rp
, left
, bottom
);
522 UWORD hspacing
,vspacing
;
530 hspacing
= HSPACING_MIDDLE
;
535 hspacing
= HSPACING_SMALL
;
540 vspacing
= VSPACING_MIDDLE
;
545 vspacing
= VSPACING_SMALL
;
549 renderimageframe(rp
, LEFTIMAGE
, state
, pens
,
550 left
, top
, width
, height
);
561 SetAPen(rp
, getbgpen(state
, pens
));
562 RectFill(rp
, left
, top
, right
, bottom
);
567 width
-= hspacing
* 2;
568 height
-= vspacing
* 2;
570 right
= left
+ width
- 1;
571 bottom
= top
+ height
- 1;
573 cy
= (height
+ 1) / 2;
575 SetAPen(rp
, pens
[SHADOWPEN
]);
577 for(j
= 0; j
< 2; j
++)
579 for(i
= 0; i
< cy
; i
++)
581 RectFill(rp
, 1 - j
+ left
+ (cy
- i
- 1) * width
/ cy
,
583 1 - j
+ right
- i
* width
/ cy
/ 2,
585 RectFill(rp
, 1 - j
+ left
+ (cy
- i
- 1) * width
/ cy
,
587 1 - j
+ right
- i
* width
/ cy
/ 2,
591 SetAPen(rp
, pens
[state
== IDS_SELECTED
? BACKGROUNDPEN
: SHINEPEN
]);
598 UWORD hspacing
,vspacing
;
606 hspacing
= HSPACING_MIDDLE
;
611 hspacing
= HSPACING_SMALL
;
616 vspacing
= VSPACING_MIDDLE
;
621 vspacing
= VSPACING_SMALL
;
625 renderimageframe(rp
, UPIMAGE
, state
, pens
,
626 left
, top
, width
, height
);
637 SetAPen(rp
, getbgpen(state
, pens
));
638 RectFill(rp
, left
, top
, right
, bottom
);
643 width
-= hspacing
* 2;
644 height
-= vspacing
* 2;
646 right
= left
+ width
- 1;
647 bottom
= top
+ height
- 1;
649 cx
= (width
+ 1) / 2;
651 SetAPen(rp
, pens
[SHADOWPEN
]);
653 for(j
= 0; j
< 2; j
++)
655 for(i
= 0; i
< cx
; i
++)
657 RectFill(rp
, 1 - j
+ left
+ i
,
658 1 - j
+ top
+ (cx
- i
- 1) * height
/ cx
,
660 1 - j
+ bottom
- i
* height
/ cx
/ 2);
661 RectFill(rp
, 1 - j
+ right
- i
,
662 1 - j
+ top
+ (cx
- i
- 1) * height
/ cx
,
664 1 - j
+ bottom
- i
* height
/ cx
/ 2);
666 SetAPen(rp
, pens
[state
== IDS_SELECTED
? BACKGROUNDPEN
: SHINEPEN
]);
673 UWORD hspacing
,vspacing
;
681 hspacing
= HSPACING_MIDDLE
;
686 hspacing
= HSPACING_SMALL
;
691 vspacing
= VSPACING_MIDDLE
;
696 vspacing
= VSPACING_SMALL
;
700 renderimageframe(rp
, RIGHTIMAGE
, state
, pens
,
701 left
, top
, width
, height
);
713 SetAPen(rp
, getbgpen(state
, pens
));
714 RectFill(rp
, left
, top
, right
, bottom
);
719 width
-= hspacing
* 2;
720 height
-= vspacing
* 2;
722 right
= left
+ width
- 1;
723 bottom
= top
+ height
- 1;
725 cy
= (height
+ 1) / 2;
727 SetAPen(rp
, pens
[SHADOWPEN
]);
729 for(j
= 0; j
< 2; j
++)
731 for(i
= 0; i
< cy
; i
++)
733 RectFill(rp
, 1 - j
+ left
+ i
* width
/ cy
/ 2,
735 1 - j
+ right
- (cy
- i
- 1) * width
/ cy
,
737 RectFill(rp
, 1 - j
+ left
+ i
* width
/ cy
/ 2,
739 1 - j
+ right
- (cy
- i
- 1) * width
/ cy
,
742 SetAPen(rp
, pens
[state
== IDS_SELECTED
? BACKGROUNDPEN
: SHINEPEN
]);
749 UWORD hspacing
,vspacing
;
757 hspacing
= HSPACING_MIDDLE
;
762 hspacing
= HSPACING_SMALL
;
767 vspacing
= VSPACING_MIDDLE
;
772 vspacing
= VSPACING_SMALL
;
776 renderimageframe(rp
, DOWNIMAGE
, state
, pens
,
777 left
, top
, width
, height
);
788 SetAPen(rp
, getbgpen(state
, pens
));
789 RectFill(rp
, left
, top
, right
, bottom
);
794 width
-= hspacing
* 2;
795 height
-= vspacing
* 2;
797 right
= left
+ width
- 1;
798 bottom
= top
+ height
- 1;
800 cx
= (width
+ 1) / 2;
802 SetAPen(rp
, pens
[SHADOWPEN
]);
804 for(j
= 0; j
< 2; j
++)
806 for(i
= 0; i
< cx
; i
++)
808 RectFill(rp
, 1 - j
+ left
+ i
,
809 1 - j
+ top
+ i
* height
/ cx
/ 2,
811 1 - j
+ bottom
- (cx
- i
- 1) * height
/ cx
);
812 RectFill(rp
, 1 - j
+ right
- i
,
813 1 - j
+ top
+ i
* height
/ cx
/ 2,
815 1 - j
+ bottom
- (cx
- i
- 1) * height
/ cx
);
818 SetAPen(rp
, pens
[state
== IDS_SELECTED
? BACKGROUNDPEN
: SHINEPEN
]);
825 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
831 /**************************************************************************************************/
833 static void findtitlearea(struct Window
*win
, LONG
*left
, LONG
*right
)
838 *right
= win
->Width
- 1;
840 for (g
= win
->FirstGadget
; g
; g
= g
->NextGadget
)
842 if (g
->Activation
& GACT_TOPBORDER
&&
843 (g
->GadgetType
& GTYP_SYSTYPEMASK
) != GTYP_WDRAGGING
)
845 if (!(g
->Flags
& GFLG_RELRIGHT
))
847 if (g
->LeftEdge
+ g
->Width
> *left
)
848 *left
= g
->LeftEdge
+ g
->Width
;
852 if (g
->LeftEdge
+ win
->Width
- 1 - 1 < *right
)
853 *right
= g
->LeftEdge
+ win
->Width
- 1 - 1;
860 /**************************************************************************************************/
862 IPTR
windecor_draw_winborder(Class
*cl
, Object
*obj
, struct wdpDrawWinBorder
*msg
)
864 //struct windecor_data *data = INST_DATA(cl, obj);
865 struct RastPort
*rp
= msg
->wdp_RPort
;
866 struct Window
*window
= msg
->wdp_Window
;
870 SetRPAttrs(rp
, RPTAG_FgColor
, 0xFFFFFF, RPTAG_BgColor
, 0xFFFFFF, TAG_DONE
);
872 if (window
->BorderTop
> 0)
874 /* Outer shine edge on top side */
876 CheckRectFill(rp
, 0, 0, window
->Width
- 1, 0);
879 if (!(msg
->wdp_Flags
& WDF_DWB_TOP_ONLY
))
881 if (window
->BorderLeft
> 0)
883 /* Outer shine edge on left side */
885 CheckRectFill(rp
, 0, 0, 0, window
->Height
- 1);
888 if (window
->BorderRight
> 1)
890 /* Inner shine edge on right side */
893 window
->Width
- window
->BorderRight
, window
->BorderTop
,
894 window
->Width
- window
->BorderRight
, window
->Height
- window
->BorderBottom
);
897 if (window
->BorderBottom
> 1)
899 /* Inner shine edge on bottom side */
902 window
->BorderLeft
, window
->Height
- window
->BorderBottom
,
903 window
->Width
- window
->BorderRight
, window
->Height
- window
->BorderBottom
);
907 SetRPAttrs(rp
, RPTAG_FgColor
, 0x0, RPTAG_BgColor
, 0x0, TAG_DONE
);
909 if (!(msg
->wdp_Flags
& WDF_DWB_TOP_ONLY
))
911 if (window
->BorderRight
> 0)
913 /* Outer shadow edge on right side */
915 CheckRectFill(rp
, window
->Width
- 1, 1,
916 window
->Width
- 1, window
->Height
- 1);
919 if (window
->BorderBottom
> 0)
921 /* Outer shadow edge on bottom side */
923 CheckRectFill(rp
, 1, window
->Height
- 1,
924 window
->Width
- 1, window
->Height
- 1);
927 if (window
->BorderLeft
> 1)
929 /* Inner shadow edge on left side */
931 CheckRectFill(rp
, window
->BorderLeft
- 1, window
->BorderTop
- 1,
932 window
->BorderLeft
- 1, window
->Height
- window
->BorderBottom
);
937 if (window
->BorderTop
> 1)
939 /* Inner shadow edge on top side */
941 CheckRectFill(rp
, window
->BorderLeft
- 1, window
->BorderTop
- 1,
942 window
->Width
- window
->BorderRight
, window
->BorderTop
- 1);
945 if ((window
->Flags
& WFLG_WINDOWACTIVE
))
947 SetRPAttrs(rp
, RPTAG_FgColor
, ACTIVE_1
, RPTAG_BgColor
, ACTIVE_2
, TAG_DONE
);
951 SetRPAttrs(rp
, RPTAG_FgColor
, INACTIVE_1
, RPTAG_BgColor
, INACTIVE_2
, TAG_DONE
);
954 if (window
->BorderTop
> 2)
956 /* Fill on top side */
958 CheckRectFill(rp
, 1, 1, window
->Width
- 2, window
->BorderTop
- 2);
961 if (!(msg
->wdp_Flags
& WDF_DWB_TOP_ONLY
))
963 if ((window
->Flags
& WFLG_WINDOWACTIVE
))
965 SetRPAttrs(rp
, RPTAG_FgColor
, ACTIVE_2
, RPTAG_BgColor
, ACTIVE_1
, TAG_DONE
);
969 SetRPAttrs(rp
, RPTAG_FgColor
, INACTIVE_2
, RPTAG_BgColor
, INACTIVE_1
, TAG_DONE
);
972 if (window
->BorderLeft
> 2)
974 /* Fill on left side */
976 CheckRectFill(rp
, 1, window
->BorderTop
, window
->BorderLeft
- 2, window
->Height
- 2);
980 if (window
->BorderRight
> 2)
982 /* Fill on right side */
984 CheckRectFill(rp
, window
->Width
- window
->BorderRight
+ 1, window
->BorderTop
,
985 window
->Width
- 2, window
->Height
- 2);
988 if ((window
->Flags
& WFLG_WINDOWACTIVE
))
990 SetRPAttrs(rp
, RPTAG_FgColor
, ACTIVE_1
, RPTAG_BgColor
, ACTIVE_2
, TAG_DONE
);
994 SetRPAttrs(rp
, RPTAG_FgColor
, INACTIVE_1
, RPTAG_BgColor
, INACTIVE_2
, TAG_DONE
);
997 if (window
->BorderBottom
> 2)
999 /* Fill on bottom side */
1001 CheckRectFill(rp
, 1, window
->Height
- window
->BorderBottom
+ 1,
1002 window
->Width
- 2, window
->Height
- 2);
1007 findtitlearea(window
, &left
, &right
);
1011 /* Left edge of title area */
1013 SetAPen(rp
, pens
[SHINEPEN
]);
1015 Draw(rp
, left
, window
->BorderTop
- 2);
1018 if (right
!= window
->Width
- 1)
1020 /* Right edges of title area */
1022 SetAPen(rp
, pens
[SHADOWPEN
]);
1024 Draw(rp
, right
, window
->BorderTop
- 2);
1031 /**************************************************************************************************/
1033 IPTR
windecor_draw_wintitle(Class
*cl
, Object
*obj
, struct wdpDrawWinTitle
*msg
)
1035 struct windecor_data
*data
= INST_DATA(cl
, obj
);
1036 struct RastPort
*rp
= msg
->wdp_RPort
;
1037 struct Window
*window
= msg
->wdp_Window
;
1038 UWORD
*pens
= data
->dri
->dri_Pens
;
1041 findtitlearea(window
, &left
, &right
);
1044 if (window
->Flags
& WFLG_WINDOWACTIVE
)
1046 SetRPAttrs(rp
, RPTAG_FgColor
, ACTIVE_1
, RPTAG_BgColor
, ACTIVE_2
, TAG_DONE
);
1050 SetRPAttrs(rp
, RPTAG_FgColor
, INACTIVE_1
, RPTAG_BgColor
, INACTIVE_2
, TAG_DONE
);
1053 SetAPen(rp
, pens
[(window
->Flags
& WFLG_WINDOWACTIVE
) ? FILLPEN
: BACKGROUNDPEN
]);
1054 CheckRectFill(rp
, left
+ 1, 1, right
- 1, window
->BorderTop
- 2);
1056 if (right
- left
> 6)
1058 ULONG textlen
, titlelen
, textpixellen
;
1059 struct TextExtent te
;
1061 SetFont(rp
, data
->dri
->dri_Font
);
1063 titlelen
= strlen(window
->Title
);
1064 textlen
= TextFit(rp
1071 , window
->BorderTop
- 2);
1074 textpixellen
= te
.te_Extent
.MaxX
- te
.te_Extent
.MinX
+ 1;
1076 switch(msg
->wdp_TitleAlign
)
1078 case WD_DWTA_CENTER
:
1079 if (textlen
== titlelen
)
1081 left
= (left
+ right
+ 1 - textpixellen
) / 2;
1090 if (textlen
== titlelen
)
1092 left
= right
- textpixellen
;
1107 SetAPen(rp
, pens
[(window
->Flags
& WFLG_WINDOWACTIVE
) ? FILLTEXTPEN
: TEXTPEN
]);
1109 SetAPen(rp
, pens
[SHADOWPEN
]);
1110 Move(rp
, left
+ 1, data
->dri
->dri_Font
->tf_Baseline
+ 2 + 1);
1111 Text(rp
, window
->Title
, textlen
);
1113 SetAPen(rp
, pens
[SHINEPEN
]);
1114 Move(rp
, left
, data
->dri
->dri_Font
->tf_Baseline
+ 2);
1115 Text(rp
, window
->Title
, textlen
);
1123 /**************************************************************************************************/
1125 IPTR
windecor_layout_bordergadgets(Class
*cl
, Object
*obj
, struct wdpLayoutBorderGadgets
*msg
)
1127 //struct windecor_data *data = INST_DATA(cl, obj);
1128 struct Window
*window
= msg
->wdp_Window
;
1129 struct Gadget
*gadget
= msg
->wdp_Gadgets
;
1134 DoSuperMethodA(cl
, obj
, (Msg
)msg
);
1136 hasclose
= (window
->Flags
& WFLG_CLOSEGADGET
) ? TRUE
: FALSE
;
1137 hasdepth
= (window
->Flags
& WFLG_DEPTHGADGET
) ? TRUE
: FALSE
;
1138 haszoom
= ((window
->Flags
& WFLG_HASZOOM
) ||
1139 ((window
->Flags
& WFLG_SIZEGADGET
) && hasdepth
)) ? TRUE
: FALSE
;
1143 switch(gadget
->GadgetType
& GTYP_SYSTYPEMASK
)
1146 gadget
->LeftEdge
= -gadget
->Height
+ 1;
1147 gadget
->Width
= gadget
->Height
;
1148 gadget
->Flags
&= ~GFLG_RELWIDTH
;
1149 gadget
->Flags
|= GFLG_RELRIGHT
;
1153 gadget
->LeftEdge
= -gadget
->Height
* (hasclose
? 2 : 1) - hasclose
* 3 + 1;
1154 gadget
->Width
= gadget
->Height
;
1155 gadget
->Flags
&= ~GFLG_RELWIDTH
;
1156 gadget
->Flags
|= GFLG_RELRIGHT
;
1160 gadget
->LeftEdge
= -gadget
->Height
* (hasclose
? 3 : 1) - hasclose
* 3 + 1;
1161 gadget
->Width
= gadget
->Height
;
1162 gadget
->Flags
&= ~GFLG_RELWIDTH
;
1163 gadget
->Flags
|= GFLG_RELRIGHT
;
1168 if (msg
->wdp_Flags
& WDF_LBG_MULTIPLE
)
1170 gadget
= gadget
->NextGadget
;
1181 /**************************************************************************************************/
1183 IPTR
windecor_draw_borderpropback(Class
*cl
, Object
*obj
, struct wdpDrawBorderPropBack
*msg
)
1185 struct windecor_data
*data
= INST_DATA(cl
, obj
);
1186 struct Window
*window
= msg
->wdp_Window
;
1187 struct RastPort
*rp
, *winrp
= msg
->wdp_RPort
;
1188 struct Gadget
*gadget
= msg
->wdp_Gadget
;
1189 struct Rectangle
*r
= msg
->wdp_RenderRect
;
1190 struct PropInfo
*pi
= ((struct PropInfo
*)gadget
->SpecialInfo
);
1191 UWORD
*pens
= data
->dri
->dri_Pens
;
1193 if (!(pi
->Flags
& PROPNEWLOOK
))
1195 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
1198 if ((rp
= CloneRastPort(winrp
)))
1200 struct TagItem rptags
[] =
1202 {RPTAG_ClipRectangle
, (IPTR
)msg
->wdp_RenderRect
},
1203 {RPTAG_ClipRectangleFlags
, 0 },
1204 {RPTAG_DrMd
, JAM2
},
1208 SetRPAttrsA(rp
, rptags
);
1210 r
= msg
->wdp_PropRect
;
1212 SetAPen(rp
, pens
[SHADOWPEN
]);
1213 RectFill(rp
, r
->MinX
, r
->MinY
, r
->MaxX
, r
->MinY
);
1214 RectFill(rp
, r
->MinX
, r
->MinY
+ 1, r
->MinX
, r
->MaxY
);
1215 SetAPen(rp
, pens
[SHINEPEN
]);
1216 RectFill(rp
, r
->MaxX
, r
->MinY
+ 1, r
->MaxX
, r
->MaxY
);
1217 RectFill(rp
, r
->MinX
+ 1, r
->MaxY
, r
->MaxX
- 1, r
->MaxY
);
1219 SetAPen(rp
, pens
[(window
->Flags
& WFLG_WINDOWACTIVE
) ? SHADOWPEN
: BACKGROUNDPEN
]);
1220 RectFill(rp
, r
->MinX
+ 1, r
->MinY
+ 1, r
->MaxX
- 1, r
->MaxY
- 1);
1229 /**************************************************************************************************/
1231 IPTR
windecor_draw_borderpropknob(Class
*cl
, Object
*obj
, struct wdpDrawBorderPropKnob
*msg
)
1233 struct windecor_data
*data
= INST_DATA(cl
, obj
);
1234 struct Window
*window
= msg
->wdp_Window
;
1235 struct RastPort
*rp
= msg
->wdp_RPort
;
1236 struct Gadget
*gadget
= msg
->wdp_Gadget
;
1237 struct Rectangle
*r
= msg
->wdp_RenderRect
;
1238 struct PropInfo
*pi
= ((struct PropInfo
*)gadget
->SpecialInfo
);
1239 UWORD
*pens
= data
->dri
->dri_Pens
;
1240 BOOL hit
= (msg
->wdp_Flags
& WDF_DBPK_HIT
) ? TRUE
: FALSE
;
1242 if (!(pi
->Flags
& PROPBORDERLESS
))
1244 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
1249 SetAPen(rp
, pens
[hit
? SHADOWPEN
: SHINEPEN
]);
1252 RectFill(rp
, r
->MinX
, r
->MinY
, r
->MaxX
- 1, r
->MinY
);
1255 RectFill(rp
, r
->MinX
, r
->MinY
+ 1, r
->MinX
, r
->MaxY
- 1);
1257 SetAPen(rp
, pens
[hit
? SHINEPEN
: SHADOWPEN
]);
1260 RectFill(rp
, r
->MaxX
, r
->MinY
, r
->MaxX
, r
->MaxY
);
1263 RectFill(rp
, r
->MinX
, r
->MaxY
, r
->MaxX
- 1, r
->MaxY
);
1270 if ((window
->Flags
& WFLG_WINDOWACTIVE
))
1272 ULONG col
= hit
? 0xb9b6ff : 0xadaaee;
1274 SetRPAttrs(rp
, RPTAG_FgColor
, col
, TAG_DONE
);
1278 SetAPen(rp
, pens
[BACKGROUNDPEN
]);
1282 RectFill(rp
, r
->MinX
, r
->MinY
, r
->MaxX
, r
->MaxY
);
1287 /**************************************************************************************************/
1289 IPTR
windecor_dispatcher(struct IClass
*cl
, Object
*obj
, Msg msg
)
1293 switch(msg
->MethodID
)
1296 retval
= windecor_new(cl
, obj
, (struct opSet
*)msg
);
1300 retval
= windecor_get(cl
, obj
, (struct opGet
*)msg
);
1303 case WDM_DRAW_SYSIMAGE
:
1304 retval
= windecor_draw_sysimage(cl
, obj
, (struct wdpDrawSysImage
*)msg
);
1307 case WDM_DRAW_WINBORDER
:
1308 retval
= windecor_draw_winborder(cl
, obj
, (struct wdpDrawWinBorder
*)msg
);
1311 case WDM_DRAW_WINTITLE
:
1312 retval
= windecor_draw_wintitle(cl
, obj
, (struct wdpDrawWinTitle
*)msg
);
1315 case WDM_LAYOUT_BORDERGADGETS
:
1316 retval
= windecor_layout_bordergadgets(cl
, obj
, (struct wdpLayoutBorderGadgets
*)msg
);
1319 case WDM_DRAW_BORDERPROPBACK
:
1320 retval
= windecor_draw_borderpropback(cl
, obj
, (struct wdpDrawBorderPropBack
*)msg
);
1323 case WDM_DRAW_BORDERPROPKNOB
:
1324 retval
= windecor_draw_borderpropknob(cl
, obj
, (struct wdpDrawBorderPropKnob
*)msg
);
1328 retval
= DoSuperMethodA(cl
, obj
, msg
);
1336 /**************************************************************************************************/
1338 struct scrdecor_data
1340 struct DrawInfo
*dri
;
1344 /**************************************************************************************************/
1346 static IPTR
scrdecor_new(Class
*cl
, Object
*obj
, struct opSet
*msg
)
1348 struct scrdecor_data
*data
;
1350 obj
= (Object
*)DoSuperMethodA(cl
, obj
, (Msg
)msg
);
1353 data
= INST_DATA(cl
, obj
);
1355 data
->dri
= (struct DrawInfo
*)GetTagData(SDA_DrawInfo
, 0, msg
->ops_AttrList
);
1356 data
->scr
= (struct Screen
*)GetTagData(SDA_Screen
, 0, msg
->ops_AttrList
);
1358 if (!data
->dri
|| !data
->scr
)
1360 STACKULONG method
= OM_DISPOSE
;
1362 CoerceMethodA(cl
, obj
, (Msg
)&method
);
1372 /**************************************************************************************************/
1374 static IPTR
scrdecor_get(Class
*cl
, Object
*obj
, struct opGet
*msg
)
1376 //struct scrdecor_data *data = INST_DATA(cl, obj);
1378 switch(msg
->opg_AttrID
)
1380 case SDA_TrueColorOnly
:
1381 *msg
->opg_Storage
= TRUE
;
1385 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
1391 /**************************************************************************************************/
1393 static void findscrtitlearea(struct Screen
*scr
, LONG
*left
, LONG
*right
)
1398 *right
= scr
->Width
- 1;
1400 for (g
= scr
->FirstGadget
; g
; g
= g
->NextGadget
)
1402 if (!(g
->Flags
& GFLG_RELRIGHT
))
1404 if (g
->LeftEdge
+ g
->Width
> *left
)
1405 *left
= g
->LeftEdge
+ g
->Width
;
1409 if (g
->LeftEdge
+ scr
->Width
- 1 - 1 < *right
)
1410 *right
= g
->LeftEdge
+ scr
->Width
- 1 - 1;
1416 /**************************************************************************************************/
1436 /**************************************************************************************************/
1438 IPTR
scrdecor_draw_screenbar(Class
*cl
, Object
*obj
, struct sdpDrawScreenBar
*msg
)
1440 struct scrdecor_data
*data
= INST_DATA(cl
, obj
);
1441 struct RastPort
*rp
= msg
->sdp_RPort
;
1442 UWORD
*pens
= data
->dri
->dri_Pens
;
1443 LONG left
, right
, y
;
1446 for(y
= 0; y
<= data
->scr
->BarHeight
; y
++)
1450 col
= coltab
[y
* (sizeof(coltab
) / sizeof(coltab
[0])) / data
->scr
->BarHeight
];
1452 FillPixelArray(rp
, 0, y
, data
->scr
->Width
, 1, col
);
1455 findscrtitlearea(data
->scr
, &left
, &right
);
1457 SetAPen(rp
, pens
[SHADOWPEN
]);
1458 RectFill(rp
, right
, 1, right
, data
->scr
->BarHeight
- 1);
1460 FillPixelArray(rp
, data
->scr
->BarHBorder
+ 4, 4,
1461 data
->scr
->BarHeight
- 8, data
->scr
->BarHeight
- 8,
1463 FillPixelArray(rp
, data
->scr
->BarHBorder
+ 4, 4,
1464 data
->scr
->BarHeight
- 8, 1,
1466 FillPixelArray(rp
, data
->scr
->BarHBorder
+ 4, 4,
1467 1, data
->scr
->BarHeight
- 8,
1469 FillPixelArray(rp
, data
->scr
->BarHBorder
+ 5, 5,
1470 data
->scr
->BarHeight
- 9, data
->scr
->BarHeight
- 9,
1476 /**************************************************************************************************/
1478 IPTR
scrdecor_draw_screentitle(Class
*cl
, Object
*obj
, struct sdpDrawScreenTitle
*msg
)
1480 struct scrdecor_data
*data
= INST_DATA(cl
, obj
);
1481 struct RastPort
*rp
= msg
->sdp_RPort
;
1482 LONG right
, left
, y
;
1485 findscrtitlearea(data
->scr
, &left
, &right
);
1488 for(y
= 0; y
<= data
->scr
->BarHeight
; y
++)
1492 col
= coltab
[y
* (sizeof(coltab
) / sizeof(coltab
[0])) / data
->scr
->BarHeight
];
1494 FillPixelArray(rp
, data
->scr
->BarHBorder
+ data
->scr
->BarHeight
, y
,
1495 (right
- 1) - (data
->scr
->BarHBorder
+ data
->scr
->BarHeight
) + 1, 1, col
);
1498 oldspacing
= rp
->TxSpacing
;
1501 Move(rp
, data
->scr
->BarHBorder
+ data
->scr
->BarHeight
+ data
->scr
->BarHBorder
, data
->scr
->BarVBorder
+ rp
->TxBaseline
);
1502 Text(rp
, data
->scr
->Title
, strlen(data
->scr
->Title
));
1503 Move(rp
, data
->scr
->BarHBorder
+ data
->scr
->BarHeight
+ data
->scr
->BarHBorder
+ 1, data
->scr
->BarVBorder
+ rp
->TxBaseline
);
1504 Text(rp
, data
->scr
->Title
, strlen(data
->scr
->Title
));
1506 rp
->TxSpacing
= oldspacing
;
1512 /**************************************************************************************************/
1514 IPTR
scrdecor_dispatcher(struct IClass
*cl
, Object
*obj
, Msg msg
)
1518 switch(msg
->MethodID
)
1521 retval
= scrdecor_new(cl
, obj
, (struct opSet
*)msg
);
1525 retval
= scrdecor_get(cl
, obj
, (struct opGet
*)msg
);
1528 case SDM_DRAW_SCREENBAR
:
1529 retval
= scrdecor_draw_screenbar(cl
, obj
, (struct sdpDrawScreenBar
*)msg
);
1532 case SDM_DRAW_SCREENTITLE
:
1533 retval
= scrdecor_draw_screentitle(cl
, obj
, (struct sdpDrawScreenTitle
*)msg
);
1537 retval
= DoSuperMethodA(cl
, obj
, msg
);
1545 /**************************************************************************************************/
1549 scr
= LockPubScreen(NULL
);
1552 dri
= GetScreenDrawInfo(scr
);
1555 cl
= MakeClass("testwindecor", WINDECORCLASS
, NULL
, sizeof(struct windecor_data
), 0);
1558 cl
->cl_Dispatcher
.h_Entry
= HookEntry
;
1559 cl
->cl_Dispatcher
.h_SubEntry
= (HOOKFUNC
)windecor_dispatcher
;
1563 scrcl
= MakeClass("testscrdecor", SCRDECORCLASS
, NULL
, sizeof(struct scrdecor_data
), 0);
1566 scrcl
->cl_Dispatcher
.h_Entry
= HookEntry
;
1567 scrcl
->cl_Dispatcher
.h_SubEntry
= (HOOKFUNC
)scrdecor_dispatcher
;
1571 olddecorobj
= ChangeDecorationA(DECORATION_WINDOW
, "testwindecor", dri
, NULL
);
1572 if (!olddecorobj
) puts("Coult not change window decoration!\n");
1574 oldscrdecorobj
= ChangeDecorationA(DECORATION_SCREEN
, "testscrdecor", dri
, NULL
);
1575 if (!oldscrdecorobj
) puts("Coult not change screen decoration!\n");
1577 if (olddecorobj
|| oldscrdecorobj
)
1579 puts("Press CTRL-C to quit\n");
1580 Wait(SIGBREAKF_CTRL_C
);
1585 thisdecorobj
= ChangeDecorationA(DECORATION_WINDOW
, OCLASS(olddecorobj
)->cl_ID
, dri
, NULL
);
1587 DisposeObject(olddecorobj
);
1588 DisposeObject(thisdecorobj
);
1593 thisscrdecorobj
= ChangeDecorationA(DECORATION_SCREEN
, OCLASS(oldscrdecorobj
)->cl_ID
, dri
, NULL
);
1595 DisposeObject(oldscrdecorobj
);
1596 DisposeObject(thisscrdecorobj
);
1601 else puts("Could not create testscrdecor class!\n");
1605 else puts("Coult not create testwindecor class!\n");
1607 FreeScreenDrawInfo(scr
, dri
);
1609 else puts("Could not get DrawInfo!\n");
1611 UnlockPubScreen(NULL
, scr
);
1613 else puts("Could not lock pub screen!");