2 Copyright © 1995-2005, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id: imageclass.c 20651 2004-01-17 20:57:12Z chodorowski $
9 #include <dos/dosextens.h>
11 #include <intuition/intuition.h>
12 #include <intuition/intuitionbase.h>
13 #include <intuition/classes.h>
14 #include <intuition/classusr.h>
15 #include <intuition/windecorclass.h>
16 #include <intuition/cghooks.h>
17 #include <intuition/icclass.h>
18 #include <intuition/extensions.h>
20 #include <graphics/gfxbase.h>
21 #include <graphics/gfxmacros.h>
23 #include <utility/tagitem.h>
24 #include <utility/hooks.h>
26 #include <clib/macros.h>
30 #include <proto/exec.h>
31 #include <proto/intuition.h>
32 #include <proto/graphics.h>
33 #include <proto/utility.h>
35 #include <proto/alib.h>
37 #include "intuition_intern.h"
40 /**************************************************************************************************/
43 #define USE_AROS_DEFSIZE 1
45 #define USE_AROS_DEFSIZE 0
48 #define DEFSIZE_WIDTH 14
49 #define DEFSIZE_HEIGHT 14
54 * heuristics for smaller arrows used in apps
57 #define HSPACING_MIDDLE 2
58 #define VSPACING_MIDDLE 2
59 #define HSPACING_SMALL 1
60 #define VSPACING_SMALL 1
62 #define DRI(dri) ((struct DrawInfo *)(dri))
64 /**************************************************************************************************/
66 static void renderimageframe(struct RastPort
*rp
, ULONG which
, ULONG state
, UWORD
*pens
,
67 WORD left
, WORD top
, WORD width
, WORD height
,
68 struct IntuitionBase
*IntuitionBase
)
70 WORD right
= left
+ width
- 1;
71 WORD bottom
= top
+ height
- 1;
72 BOOL leftedgegodown
= FALSE
;
73 BOOL topedgegoright
= FALSE
;
79 /* draw separator line at the right side */
80 SetAPen(rp
, pens
[SHINEPEN
]);
81 RectFill(rp
, right
, top
, right
, bottom
- 1);
82 SetAPen(rp
, pens
[SHADOWPEN
]);
83 WritePixel(rp
, right
, bottom
);
91 /* draw separator line at the left side */
92 SetAPen(rp
, pens
[SHINEPEN
]);
93 WritePixel(rp
, left
, top
);
94 SetAPen(rp
, pens
[SHADOWPEN
]);
95 RectFill(rp
, left
, top
+ 1, left
, bottom
);
103 leftedgegodown
= TRUE
;
108 topedgegoright
= TRUE
;
112 if (left
== 0) leftedgegodown
= TRUE
;
113 if (top
== 0) topedgegoright
= TRUE
;
115 SetAPen(rp
, pens
[((state
== IDS_SELECTED
) || (state
== IDS_INACTIVESELECTED
)) ? SHADOWPEN
: SHINEPEN
]);
121 bottom
- (leftedgegodown
? 0 : 1));
124 RectFill(rp
, left
+ 1,
126 right
- (topedgegoright
? 0 : 1),
129 SetAPen(rp
, pens
[((state
== IDS_SELECTED
) || (state
== IDS_INACTIVESELECTED
)) ? SHINEPEN
: SHADOWPEN
]);
133 top
+ (topedgegoright
? 1 : 0),
138 RectFill(rp
, left
+ (leftedgegodown
? 1 : 0),
144 /**************************************************************************************************/
146 static UWORD
getbgpen(ULONG state
, UWORD
*pens
)
158 bg
= pens
[BACKGROUNDPEN
];
166 /**************************************************************************************************/
169 #define IntuitionBase ((struct IntuitionBase *)(cl->cl_UserData))
171 /**************************************************************************************************/
173 IPTR
WinDecorClass__OM_NEW(Class
*cl
, Object
*obj
, struct opSet
*msg
)
175 struct windecor_data
*data
;
177 obj
= (Object
*)DoSuperMethodA(cl
, obj
, (Msg
)msg
);
180 data
= INST_DATA(cl
, obj
);
182 data
->dri
= (struct IntDrawInfo
*)GetTagData(WDA_DrawInfo
, 0, msg
->ops_AttrList
);
183 data
->scr
= (struct Screen
*)GetTagData(WDA_Screen
, 0, msg
->ops_AttrList
);
185 if (!data
->dri
|| !data
->scr
)
187 STACKULONG method
= OM_DISPOSE
;
189 CoerceMethodA(cl
, obj
, (Msg
)&method
);
199 /**************************************************************************************************/
201 IPTR
WinDecorClass__OM_GET(Class
*cl
, Object
*obj
, struct opGet
*msg
)
203 struct windecor_data
*data
= INST_DATA(cl
, obj
);
205 switch(msg
->opg_AttrID
)
208 *msg
->opg_Storage
= (IPTR
)data
->dri
;
212 *msg
->opg_Storage
= (IPTR
)data
->scr
;
215 case WDA_TrueColorOnly
:
216 *msg
->opg_Storage
= FALSE
;
220 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
227 /**************************************************************************************************/
229 IPTR
WinDecorClass__WDM_GETDEFSIZE_SYSIMAGE(Class
*cl
, Object
*obj
, struct wdpGetDefSizeSysImage
*msg
)
231 ULONG def_low_width
= DEFSIZE_WIDTH
, def_low_height
= DEFSIZE_HEIGHT
;
232 ULONG def_med_width
= DEFSIZE_WIDTH
, def_med_height
= DEFSIZE_HEIGHT
;
233 ULONG def_high_width
= DEFSIZE_WIDTH
, def_high_height
= DEFSIZE_HEIGHT
;
235 #define REFHEIGHT (msg->wdp_ReferenceFont->tf_YSize)
236 #define REFWIDTH REFHEIGHT
238 switch(msg
->wdp_Which
)
243 def_low_width
= def_med_width
= def_high_width
= DEFSIZE_WIDTH
;
244 def_low_height
= def_med_height
= def_high_height
= DEFSIZE_HEIGHT
;
251 def_high_height
= 22;
258 def_low_width
= def_med_width
= def_high_width
= DEFSIZE_WIDTH
;
259 def_low_height
= def_med_height
= def_high_height
= DEFSIZE_HEIGHT
;
266 def_high_height
= 22;
279 def_low_width
= def_med_width
= def_high_width
= DEFSIZE_WIDTH
;
280 def_low_height
= def_med_height
= def_high_height
= DEFSIZE_HEIGHT
;
290 def_low_width
= def_med_width
= def_high_width
= DEFSIZE_WIDTH
;
291 def_low_height
= def_med_height
= def_high_height
= DEFSIZE_HEIGHT
;
301 def_low_width
= def_med_width
= def_high_width
= DEFSIZE_WIDTH
;
302 def_low_height
= def_med_height
= def_high_height
= DEFSIZE_HEIGHT
;
312 def_low_width
= def_med_width
= def_high_width
= DEFSIZE_WIDTH
;
313 def_low_height
= def_med_height
= def_high_height
= DEFSIZE_HEIGHT
;
320 def_high_height
= 10;
327 def_high_width
= REFWIDTH
/ 2 + 4; // reffont->tf_XSize * 3 / 2;
330 def_high_height
= REFHEIGHT
;
336 def_high_width
= (REFWIDTH
+ 1) * 2; // reffont->tf_XSize * 3 - 1;
339 def_high_height
= REFHEIGHT
+ 1;
343 def_low_width
= (REFWIDTH
+ 3) * 2;//reffont->tf_XSize * 2;
344 def_low_height
= REFHEIGHT
+ 3;
351 switch(msg
->wdp_SysiSize
)
353 case SYSISIZE_LOWRES
:
354 *msg
->wdp_Width
= def_low_width
;
355 *msg
->wdp_Height
= def_low_height
;
358 case SYSISIZE_MEDRES
:
359 *msg
->wdp_Width
= def_med_width
;
360 *msg
->wdp_Height
= def_med_height
;
365 *msg
->wdp_Width
= def_high_width
;
366 *msg
->wdp_Height
= def_high_height
;
373 /**************************************************************************************************/
375 IPTR
WinDecorClass__WDM_DRAW_SYSIMAGE(Class
*cl
, Object
*obj
, struct wdpDrawSysImage
*msg
)
377 struct windecor_data
*data
= INST_DATA(cl
, obj
);
378 struct RastPort
*rp
= msg
->wdp_RPort
;
379 UWORD
*pens
= DRI(data
->dri
)->dri_Pens
;
380 LONG state
= msg
->wdp_State
;
381 LONG left
= msg
->wdp_X
;
382 LONG top
= msg
->wdp_Y
;
383 LONG width
= msg
->wdp_Width
;
384 LONG height
= msg
->wdp_Height
;
385 LONG right
= left
+ width
- 1;
386 LONG bottom
= top
+ height
- 1;
387 LONG h_spacing
, v_spacing
;
391 switch(msg
->wdp_Which
)
395 renderimageframe(rp
, CLOSEIMAGE
, state
, pens
, left
, top
, width
, height
, IntuitionBase
);
401 right
= left
+ width
- 1;
402 bottom
= top
+ height
- 1;
403 h_spacing
= width
* 4 / 10;
404 v_spacing
= height
* 3 / 10;
406 SetAPen(rp
, getbgpen(state
, pens
));
407 RectFill(rp
, left
, top
, right
, bottom
);
414 SetAPen(rp
, pens
[SHADOWPEN
]);
415 RectFill(rp
, left
, top
, right
, bottom
);
422 SetAPen(rp
, pens
[(state
== IDS_NORMAL
) ? SHINEPEN
: BACKGROUNDPEN
]);
423 RectFill(rp
, left
, top
, right
, bottom
);
434 renderimageframe(rp
, ZOOMIMAGE
, state
, pens
,
435 left
, top
, width
, height
, IntuitionBase
);
441 right
= left
+ width
- 1;
442 bottom
= top
+ height
- 1 ;
443 h_spacing
= width
/ 6;
444 v_spacing
= height
/ 6;
446 bg
= getbgpen(state
, pens
);
448 /* Clear background into correct color */
450 RectFill(rp
, left
, top
, right
, bottom
);
457 SetAPen(rp
, pens
[SHADOWPEN
]);
458 RectFill(rp
, left
, top
, right
, bottom
);
460 SetAPen(rp
, pens
[(state
== IDS_SELECTED
) ? SHINEPEN
:
461 (state
== IDS_NORMAL
) ? FILLPEN
: BACKGROUNDPEN
]);
462 RectFill(rp
, left
+ 1, top
+ 1, right
- 1, bottom
- 1);
464 right
= left
+ (right
- left
+ 1) / 2;
465 bottom
= top
+ (bottom
- top
+ 1) / 2;
467 if (right
- left
< 4) right
= left
+ 4;
469 SetAPen(rp
, pens
[SHADOWPEN
]);
470 RectFill(rp
, left
, top
, right
, bottom
);
477 SetAPen(rp
, pens
[(state
== IDS_SELECTED
) ? FILLPEN
:
478 (state
== IDS_NORMAL
) ? SHINEPEN
: BACKGROUNDPEN
]);
479 RectFill(rp
,left
, top
, right
, bottom
);
489 renderimageframe(rp
, DEPTHIMAGE
, state
, pens
,
490 left
, top
, width
, height
, IntuitionBase
);
498 h_spacing
= width
/ 6;
499 v_spacing
= height
/ 6;
501 bg
= getbgpen(state
, pens
);
503 /* Clear background into correct color */
505 RectFill(rp
, left
, top
, right
, bottom
);
507 /* Draw a image of two partly overlapped tiny windows,
513 width
-= h_spacing
* 2;
514 height
-= v_spacing
* 2;
516 right
= left
+ width
- 1;
517 bottom
= top
+ height
- 1;
519 /* Render top left window */
521 SetAPen(rp
, pens
[SHADOWPEN
]);
525 , right
- (width
/ 3 )
526 , bottom
- (height
/ 3)
530 /* Fill top left window (inside of the frame above) */
532 if ((state
!= IDS_INACTIVENORMAL
))
534 SetAPen(rp
, pens
[BACKGROUNDPEN
]);
535 RectFill(rp
, left
+ 1, top
+ 1,
536 right
- (width
/ 3) - 1, bottom
- (height
/ 3) - 1);
540 /* Render bottom right window */
541 SetAPen(rp
, pens
[SHADOWPEN
]);
542 drawrect(rp
, left
+ (width
/ 3), top
+ (height
/ 3),
543 right
, bottom
, IntuitionBase
);
545 /* Fill bottom right window (inside of the frame above) */
546 SetAPen(rp
, pens
[(state
== IDS_INACTIVENORMAL
) ? BACKGROUNDPEN
: SHINEPEN
]);
547 RectFill(rp
, left
+ (width
/ 3) + 1, top
+ (height
/ 3) + 1,
548 right
- 1, bottom
- 1);
550 if (state
== IDS_SELECTED
)
552 /* Re-Render top left window */
554 SetAPen(rp
, pens
[SHADOWPEN
]);
555 drawrect(rp
, left
, top
,
556 right
- (width
/ 3 ), bottom
- (height
/ 3), IntuitionBase
);
568 renderimageframe(rp
, SIZEIMAGE
, state
, pens
,
569 left
, top
, width
, height
, IntuitionBase
);
577 h_spacing
= width
/ 5;
578 v_spacing
= height
/ 5;
580 bg
= getbgpen(state
, pens
);
582 /* Clear background into correct color */
584 RectFill(rp
, left
, top
, right
, bottom
);
586 /* A triangle image */
591 right
= left
+ width
- 1 - (h_spacing
* 2);
592 bottom
= top
+ height
- 1 - (v_spacing
* 2);
594 width
= right
- left
+ 1;
595 height
= bottom
- top
+ 1;
597 if (state
!= IDS_INACTIVENORMAL
)
599 SetAPen(rp
, pens
[SHINEPEN
]);
601 for(y
= top
; y
<= bottom
; y
++)
603 x
= left
+ (bottom
- y
) * width
/ height
;
604 RectFill(rp
, x
, y
, right
, y
);
608 SetAPen(rp
, pens
[SHADOWPEN
]);
609 /* Draw triangle border */
610 Move(rp
, left
, bottom
);
611 Draw(rp
, right
, top
);
612 Draw(rp
, right
, bottom
);
613 Draw(rp
, left
, bottom
);
620 UWORD hspacing
,vspacing
;
628 hspacing
= HSPACING_MIDDLE
;
633 hspacing
= HSPACING_SMALL
;
638 vspacing
= VSPACING_MIDDLE
;
643 vspacing
= VSPACING_SMALL
;
646 renderimageframe(rp
, LEFTIMAGE
, state
, pens
,
647 left
, top
, width
, height
, IntuitionBase
);
655 SetAPen(rp
, getbgpen(state
, pens
));
656 RectFill(rp
, left
, top
, right
, bottom
);
660 width
-= hspacing
* 2;
661 height
-= vspacing
* 2;
663 right
= left
+ width
- 1;
664 bottom
= top
+ height
- 1;
666 cy
= (height
+ 1) / 2;
668 SetAPen(rp
, pens
[SHADOWPEN
]);
670 for(i
= 0; i
< cy
; i
++)
672 RectFill(rp
, left
+ (cy
- i
- 1) * width
/ cy
,
674 right
- i
* width
/ cy
/ 2,
676 RectFill(rp
, left
+ (cy
- i
- 1) * width
/ cy
,
678 right
- i
* width
/ cy
/ 2,
686 UWORD hspacing
,vspacing
;
694 hspacing
= HSPACING_MIDDLE
;
699 hspacing
= HSPACING_SMALL
;
704 vspacing
= VSPACING_MIDDLE
;
709 vspacing
= VSPACING_SMALL
;
712 renderimageframe(rp
, UPIMAGE
, state
, pens
,
713 left
, top
, width
, height
, IntuitionBase
);
721 SetAPen(rp
, getbgpen(state
, pens
));
722 RectFill(rp
, left
, top
, right
, bottom
);
726 width
-= hspacing
* 2;
727 height
-= vspacing
* 2;
729 right
= left
+ width
- 1;
730 bottom
= top
+ height
- 1;
732 cx
= (width
+ 1) / 2;
734 SetAPen(rp
, pens
[SHADOWPEN
]);
736 for(i
= 0; i
< cx
; i
++)
738 RectFill(rp
, left
+ i
,
739 top
+ (cx
- i
- 1) * height
/ cx
,
741 bottom
- i
* height
/ cx
/ 2);
742 RectFill(rp
, right
- i
,
743 top
+ (cx
- i
- 1) * height
/ cx
,
745 bottom
- i
* height
/ cx
/ 2);
753 UWORD hspacing
,vspacing
;
761 hspacing
= HSPACING_MIDDLE
;
766 hspacing
= HSPACING_SMALL
;
771 vspacing
= VSPACING_MIDDLE
;
776 vspacing
= VSPACING_SMALL
;
779 renderimageframe(rp
, RIGHTIMAGE
, state
, pens
,
780 left
, top
, width
, height
, IntuitionBase
);
789 SetAPen(rp
, getbgpen(state
, pens
));
790 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 cy
= (height
+ 1) / 2;
802 SetAPen(rp
, pens
[SHADOWPEN
]);
804 for(i
= 0; i
< cy
; i
++)
806 RectFill(rp
, left
+ i
* width
/ cy
/ 2,
808 right
- (cy
- i
- 1) * width
/ cy
,
810 RectFill(rp
, left
+ i
* width
/ cy
/ 2,
812 right
- (cy
- i
- 1) * width
/ cy
,
820 UWORD hspacing
,vspacing
;
828 hspacing
= HSPACING_MIDDLE
;
833 hspacing
= HSPACING_SMALL
;
838 vspacing
= VSPACING_MIDDLE
;
843 vspacing
= VSPACING_SMALL
;
846 renderimageframe(rp
, DOWNIMAGE
, state
, pens
,
847 left
, top
, width
, height
, IntuitionBase
);
855 SetAPen(rp
, getbgpen(state
, pens
));
856 RectFill(rp
, left
, top
, right
, bottom
);
860 width
-= hspacing
* 2;
861 height
-= vspacing
* 2;
863 right
= left
+ width
- 1;
864 bottom
= top
+ height
- 1;
866 cx
= (width
+ 1) / 2;
868 SetAPen(rp
, pens
[SHADOWPEN
]);
870 for(i
= 0; i
< cx
; i
++)
872 RectFill(rp
, left
+ i
,
873 top
+ i
* height
/ cx
/ 2,
875 bottom
- (cx
- i
- 1) * height
/ cx
);
876 RectFill(rp
, right
- i
,
877 top
+ i
* height
/ cx
/ 2,
879 bottom
- (cx
- i
- 1) * height
/ cx
);
893 /**************************************************************************************************/
895 static void findtitlearea(struct Window
*win
, LONG
*left
, LONG
*right
)
900 *right
= win
->Width
- 1;
902 for (g
= win
->FirstGadget
; g
; g
= g
->NextGadget
)
904 if (g
->Activation
& GACT_TOPBORDER
&& g
!= (struct Gadget
*)IW(win
)->sysgads
[DRAGBAR
])
906 if (!(g
->Flags
& GFLG_RELRIGHT
))
908 if (g
->LeftEdge
+ g
->Width
> *left
)
909 *left
= g
->LeftEdge
+ g
->Width
;
913 if (g
->LeftEdge
+ win
->Width
- 1 - 1 < *right
)
914 *right
= g
->LeftEdge
+ win
->Width
- 1 - 1;
921 /**************************************************************************************************/
923 IPTR
WinDecorClass__WDM_DRAW_WINBORDER(Class
*cl
, Object
*obj
, struct wdpDrawWinBorder
*msg
)
925 struct windecor_data
*data
= INST_DATA(cl
, obj
);
926 struct RastPort
*rp
= msg
->wdp_RPort
;
927 struct Window
*window
= msg
->wdp_Window
;
928 UWORD
*pens
= DRI(data
->dri
)->dri_Pens
;
932 SetAPen(rp
, pens
[SHINEPEN
]);
934 if (window
->BorderTop
> 0)
936 /* Outer shine edge on top side */
938 CheckRectFill(rp
, 0, 0, window
->Width
- 1, 0, IntuitionBase
);
941 if (!(msg
->wdp_Flags
& WDF_DWB_TOP_ONLY
))
943 if (window
->BorderLeft
> 0)
945 /* Outer shine edge on left side */
947 CheckRectFill(rp
, 0, 0, 0, window
->Height
- 1, IntuitionBase
);
950 if (window
->BorderRight
> 1)
952 /* Inner shine edge on right side */
955 window
->Width
- window
->BorderRight
, window
->BorderTop
,
956 window
->Width
- window
->BorderRight
, window
->Height
- window
->BorderBottom
,
960 if (window
->BorderBottom
> 1)
962 /* Inner shine edge on bottom side */
965 window
->BorderLeft
, window
->Height
- window
->BorderBottom
,
966 window
->Width
- window
->BorderRight
, window
->Height
- window
->BorderBottom
,
971 SetAPen(rp
, pens
[SHADOWPEN
]);
973 if (!(msg
->wdp_Flags
& WDF_DWB_TOP_ONLY
))
975 if (window
->BorderRight
> 0)
977 /* Outer shadow edge on right side */
979 CheckRectFill(rp
, window
->Width
- 1, 1,
980 window
->Width
- 1, window
->Height
- 1, IntuitionBase
);
983 if (window
->BorderBottom
> 0)
985 /* Outer shadow edge on bottom side */
987 CheckRectFill(rp
, 1, window
->Height
- 1,
988 window
->Width
- 1, window
->Height
- 1, IntuitionBase
);
991 if (window
->BorderLeft
> 1)
993 /* Inner shadow edge on left side */
995 CheckRectFill(rp
, window
->BorderLeft
- 1, window
->BorderTop
- 1,
996 window
->BorderLeft
- 1, window
->Height
- window
->BorderBottom
,
1002 if (window
->BorderTop
> 1)
1004 /* Inner shadow edge on top side */
1006 CheckRectFill(rp
, window
->BorderLeft
- 1, window
->BorderTop
- 1,
1007 window
->Width
- window
->BorderRight
, window
->BorderTop
- 1,
1011 SetAPen(rp
, pens
[(window
->Flags
& WFLG_WINDOWACTIVE
) ? FILLPEN
: BACKGROUNDPEN
]);
1013 if (window
->BorderTop
> 2)
1015 /* Fill on top side */
1017 CheckRectFill(rp
, 1, 1, window
->Width
- 2, window
->BorderTop
- 2, IntuitionBase
);
1020 if (!(msg
->wdp_Flags
& WDF_DWB_TOP_ONLY
))
1022 if (window
->BorderLeft
> 2)
1024 /* Fill on left side */
1026 CheckRectFill(rp
, 1, 1, window
->BorderLeft
- 2, window
->Height
- 2, IntuitionBase
);
1030 if (window
->BorderRight
> 2)
1032 /* Fill on right side */
1034 CheckRectFill(rp
, window
->Width
- window
->BorderRight
+ 1, 1,
1035 window
->Width
- 2, window
->Height
- 2, IntuitionBase
);
1038 if (window
->BorderBottom
> 2)
1040 /* Fill on bottom side */
1042 CheckRectFill(rp
, 1, window
->Height
- window
->BorderBottom
+ 1,
1043 window
->Width
- 2, window
->Height
- 2, IntuitionBase
);
1047 findtitlearea(window
, &left
, &right
);
1051 /* Left edge of title area */
1053 SetAPen(rp
, pens
[SHINEPEN
]);
1055 Draw(rp
, left
, window
->BorderTop
- 2);
1058 if (right
!= window
->Width
- 1)
1060 /* Right edges of title area */
1062 SetAPen(rp
, pens
[SHADOWPEN
]);
1064 Draw(rp
, right
, window
->BorderTop
- 2);
1070 /**************************************************************************************************/
1072 IPTR
WinDecorClass__WDM_DRAW_WINTITLE(Class
*cl
, Object
*obj
, struct wdpDrawWinTitle
*msg
)
1074 struct windecor_data
*data
= INST_DATA(cl
, obj
);
1075 struct RastPort
*rp
= msg
->wdp_RPort
;
1076 struct Window
*window
= msg
->wdp_Window
;
1077 UWORD
*pens
= DRI(data
->dri
)->dri_Pens
;
1080 findtitlearea(window
, &left
, &right
);
1083 SetAPen(rp
, pens
[(window
->Flags
& WFLG_WINDOWACTIVE
) ? FILLPEN
: BACKGROUNDPEN
]);
1084 CheckRectFill(rp
, left
+ 1, 1, right
- 1, window
->BorderTop
- 2, IntuitionBase
);
1086 if (right
- left
> 6)
1088 ULONG textlen
, titlelen
, textpixellen
;
1089 struct TextExtent te
;
1091 SetFont(rp
, DRI(data
->dri
)->dri_Font
);
1093 titlelen
= strlen(window
->Title
);
1094 textlen
= TextFit(rp
1101 , window
->BorderTop
- 2);
1104 textpixellen
= te
.te_Extent
.MaxX
- te
.te_Extent
.MinX
+ 1;
1106 switch(msg
->wdp_TitleAlign
)
1108 case WD_DWTA_CENTER
:
1109 if (textlen
== titlelen
)
1111 left
= (left
+ right
+ 1 - textpixellen
) / 2;
1120 if (textlen
== titlelen
)
1122 left
= right
- textpixellen
;
1137 SetAPen(rp
, pens
[(window
->Flags
& WFLG_WINDOWACTIVE
) ? FILLTEXTPEN
: TEXTPEN
]);
1139 Move(rp
, left
, DRI(data
->dri
)->dri_Font
->tf_Baseline
+ 2);
1140 Text(rp
, window
->Title
, textlen
);
1147 /**************************************************************************************************/
1149 IPTR
WinDecorClass__WDM_LAYOUT_BORDERGADGETS(Class
*cl
, Object
*obj
, struct wdpLayoutBorderGadgets
*msg
)
1151 //struct windecor_data *data = INST_DATA(cl, obj);
1152 //struct Window *window = msg->wdp_Window;
1153 struct Gadget
*gadget
= msg
->wdp_Gadgets
;
1157 switch(gadget
->GadgetType
& GTYP_SYSTYPEMASK
)
1160 gadget
->LeftEdge
= 0;
1161 gadget
->Width
= gadget
->Height
;
1162 gadget
->Flags
&= ~(GFLG_RELRIGHT
| GFLG_RELWIDTH
);
1166 gadget
->LeftEdge
= -gadget
->Height
+ 1;
1167 gadget
->Width
= gadget
->Height
;
1168 gadget
->Flags
&= ~GFLG_RELWIDTH
;
1169 gadget
->Flags
|= GFLG_RELRIGHT
;
1173 gadget
->LeftEdge
= -gadget
->Height
* 2 + 1;
1174 gadget
->Width
= gadget
->Height
;
1175 gadget
->Flags
&= ~GFLG_RELWIDTH
;
1176 gadget
->Flags
|= GFLG_RELRIGHT
;
1179 case GTYP_WDRAGGING
:
1180 gadget
->LeftEdge
= 0;
1182 gadget
->Flags
&= ~GFLG_RELRIGHT
;
1183 gadget
->Flags
|= GFLG_RELWIDTH
;
1187 if (msg
->wdp_Flags
& WDF_LBG_MULTIPLE
)
1189 gadget
= gadget
->NextGadget
;
1200 /**************************************************************************************************/
1202 IPTR
WinDecorClass__WDM_DRAW_BORDERPROPBACK(Class
*cl
, Object
*obj
, struct wdpDrawBorderPropBack
*msg
)
1204 struct windecor_data
*data
= INST_DATA(cl
, obj
);
1205 struct Window
*window
= msg
->wdp_Window
;
1206 struct RastPort
*rp
= msg
->wdp_RPort
;
1207 struct Gadget
*gadget
= msg
->wdp_Gadget
;
1208 struct Rectangle
*r
= msg
->wdp_RenderRect
;
1209 struct PropInfo
*pi
= ((struct PropInfo
*)gadget
->SpecialInfo
);
1210 UWORD
*pens
= DRI(data
->dri
)->dri_Pens
;
1214 if (pi
->Flags
& PROPNEWLOOK
)
1216 static UWORD pattern
[] = {0x5555,0xAAAA};
1218 SetAfPt(rp
, pattern
, 1);
1219 SetAPen(rp
, pens
[SHADOWPEN
]);
1220 SetBPen(rp
, pens
[(window
->Flags
& WFLG_WINDOWACTIVE
) ? FILLPEN
: BACKGROUNDPEN
]);
1221 RectFill(rp
, r
->MinX
, r
->MinY
, r
->MaxX
, r
->MaxY
);
1222 SetAfPt(rp
, NULL
, 0);
1226 SetAPen(rp
, pens
[BACKGROUNDPEN
]);
1227 RectFill(rp
, r
->MinX
, r
->MinY
, r
->MaxX
, r
->MaxY
);
1233 /**************************************************************************************************/
1235 IPTR
WinDecorClass__WDM_DRAW_BORDERPROPKNOB(Class
*cl
, Object
*obj
, struct wdpDrawBorderPropKnob
*msg
)
1237 struct windecor_data
*data
= INST_DATA(cl
, obj
);
1238 struct Window
*window
= msg
->wdp_Window
;
1239 struct RastPort
*rp
= msg
->wdp_RPort
;
1240 struct Gadget
*gadget
= msg
->wdp_Gadget
;
1241 struct Rectangle
*r
= msg
->wdp_RenderRect
;
1242 struct PropInfo
*pi
= ((struct PropInfo
*)gadget
->SpecialInfo
);
1243 UWORD
*pens
= DRI(data
->dri
)->dri_Pens
;
1247 if (pi
->Flags
& PROPBORDERLESS
)
1249 SetAPen(rp
, pens
[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
[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 } /* PROPBORDERLESS */
1273 SetAPen(rp
, pens
[SHADOWPEN
]);
1275 if (pi
->Flags
& FREEHORIZ
)
1277 /* black line at the left and at the right */
1279 RectFill(rp
, r
->MinX
, r
->MinY
, r
->MinX
, r
->MaxY
);
1280 RectFill(rp
, r
->MaxX
, r
->MinY
, r
->MaxX
, r
->MaxY
);
1287 if (pi
->Flags
& FREEVERT
)
1289 /* black line at the top and at the bottom */
1291 RectFill(rp
, r
->MinX
, r
->MinY
, r
->MaxX
, r
->MinY
);
1292 RectFill(rp
, r
->MinX
, r
->MaxY
, r
->MaxX
, r
->MaxY
);
1299 } /* not PROPBORDERLESS */
1302 SetAPen(rp
, pens
[(window
->Flags
& WFLG_WINDOWACTIVE
) ? FILLPEN
: BACKGROUNDPEN
]);
1305 RectFill(rp
, r
->MinX
, r
->MinY
, r
->MaxX
, r
->MaxY
);
1311 /**************************************************************************************************/