2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: Support functions for AROSMutualExcludeClass.
9 /***********************************************************************************/
12 #include <exec/types.h>
13 #include <proto/intuition.h>
14 #include <proto/graphics.h>
15 #include <graphics/rastport.h>
16 #include <graphics/text.h>
17 #include <libraries/gadtools.h>
19 #include "arosmutualexclude_intern.h"
21 /***********************************************************************************/
23 UWORD disabledpattern
[2] = {0x4444, 0x1111};
25 /***********************************************************************************/
27 /* draws a disabled pattern */
28 void drawdisabledpattern(struct RastPort
*rport
, UWORD pen
,
29 WORD left
, WORD top
, UWORD width
, UWORD height
32 SetABPenDrMd(rport
, pen
, 0, JAM1
);
33 rport
->AreaPtrn
= disabledpattern
;
35 RectFill(rport
, left
, top
, left
+width
-1, top
+height
-1);
38 /***********************************************************************************/
40 struct TextFont
*preparefont(struct RastPort
*rport
, struct IntuiText
*itext
,
41 struct TextFont
**oldfont
44 struct TextFont
*font
;
48 *oldfont
= rport
->Font
;
49 font
= OpenFont(itext
->ITextFont
);
53 SetSoftStyle(rport
, itext
->ITextFont
->ta_Style
, 0xffffffff);
61 SetABPenDrMd(rport
, itext
->FrontPen
, itext
->BackPen
, itext
->DrawMode
);
66 /***********************************************************************************/
68 void closefont(struct RastPort
*rport
,
69 struct TextFont
*font
, struct TextFont
*oldfont
74 SetFont(rport
, oldfont
);
79 /***********************************************************************************/
81 BOOL
renderlabel(struct Gadget
*gad
, struct RastPort
*rport
, struct MXData
*data
)
83 struct TextFont
*font
= NULL
, *oldfont
;
91 /* Calculate offsets. */
92 if ((gad
->Flags
& GFLG_LABELSTRING
))
93 text
= (STRPTR
)gad
->GadgetText
;
94 else if ((gad
->Flags
& GFLG_LABELIMAGE
))
99 text
= gad
->GadgetText
->IText
;
100 font
= preparefont(rport
, gad
->GadgetText
, &oldfont
);
108 TextExtent(rport
, text
, len
, &te
);
110 height
= te
.te_Height
;
113 width
= ((struct Image
*)gad
->GadgetText
)->Width
;
114 height
= ((struct Image
*)gad
->GadgetText
)->Height
;
117 if (data
->labelplace
== GV_LabelPlace_Right
)
119 x
= data
->bbox
.MaxX
+ 5;
120 y
= (data
->bbox
.MinY
+ data
->bbox
.MaxY
- height
) / 2;
121 } else if (data
->labelplace
== GV_LabelPlace_Above
)
123 x
= (data
->bbox
.MinX
+ data
->bbox
.MaxX
- width
) / 2;
124 y
= data
->bbox
.MinY
- height
- 2;
125 } else if (data
->labelplace
== GV_LabelPlace_Below
)
127 x
= (data
->bbox
.MinX
+ data
->bbox
.MaxX
- width
) / 2;
128 y
= gad
->TopEdge
+ gad
->Height
+ 3;
129 } else if (data
->labelplace
== GV_LabelPlace_In
)
131 x
= (data
->bbox
.MinX
+ data
->bbox
.MaxX
- width
) / 2;
132 y
= (data
->bbox
.MinY
+ data
->bbox
.MaxY
- height
) / 2;
133 } else /* GV_LabelPlace_Left */
135 x
= data
->bbox
.MinX
- width
- 4;
136 y
= (data
->bbox
.MinY
+ data
->bbox
.MaxY
- height
) / 2;
139 if (gad
->Flags
& GFLG_LABELSTRING
)
141 SetABPenDrMd(rport
, 1, 0, JAM1
);
142 Move(rport
, x
, y
+ rport
->TxBaseline
);
143 Text(rport
, text
, len
);
144 } else if (gad
->Flags
& GFLG_LABELIMAGE
)
145 DrawImage(rport
, (struct Image
*)gad
->GadgetText
, x
, y
);
148 PrintIText(rport
, gad
->GadgetText
, x
, y
);
149 closefont(rport
, font
, oldfont
);
156 /***********************************************************************************/