2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: Support functions for AROSCheckboxClass.
9 #include <exec/types.h>
10 #include <proto/intuition.h>
11 #include <proto/graphics.h>
12 #include <graphics/rastport.h>
13 #include <graphics/text.h>
14 #include <libraries/gadtools.h>
16 #include "aroscheckbox_intern.h"
19 UWORD disabledpattern
[2] = {0x4444, 0x1111};
21 /* draws a disabled pattern */
22 void drawdisabledpattern(struct RastPort
*rport
, UWORD pen
,
23 WORD left
, WORD top
, UWORD width
, UWORD height
26 SetABPenDrMd(rport
, pen
, 0, JAM1
);
27 rport
->AreaPtrn
= disabledpattern
;
29 RectFill(rport
, left
, top
, left
+width
-1, top
+height
-1);
31 /* FIXME: drawdisabledpattern ??? Fix what? */
32 /*FIXME for (y=0; y<(height-1); y++)
34 for (x=0; x<(width-1); x++)
40 Move(rport, left + x, top + y);
41 Draw(rport, left + x, top + y);
47 Move(rport, left + x, top + y);
48 Draw(rport, left + x, top + y);
56 struct TextFont
*preparefont(struct RastPort
*rport
, struct IntuiText
*itext
,
57 struct TextFont
**oldfont
60 struct TextFont
*font
;
64 *oldfont
= rport
->Font
;
65 font
= OpenFont(itext
->ITextFont
);
69 SetSoftStyle(rport
, itext
->ITextFont
->ta_Style
, 0xffffffff);
80 SetABPenDrMd(rport
, itext
->FrontPen
, itext
->BackPen
, itext
->DrawMode
);
86 void closefont(struct RastPort
*rport
,
87 struct TextFont
*font
, struct TextFont
*oldfont
92 SetFont(rport
, oldfont
);
98 BOOL
renderlabel(struct Gadget
*gad
, struct RastPort
*rport
, LONG labelplace
)
100 struct TextFont
*font
= NULL
, *oldfont
;
101 struct TextExtent te
;
108 /* Calculate offsets. */
109 if ((gad
->Flags
& GFLG_LABELSTRING
))
110 text
= (STRPTR
)gad
->GadgetText
;
111 else if ((gad
->Flags
& GFLG_LABELIMAGE
))
115 /* GFLG_LABELITEXT */
116 text
= gad
->GadgetText
->IText
;
117 font
= preparefont(rport
, gad
->GadgetText
, &oldfont
);
125 TextExtent(rport
, text
, len
, &te
);
127 height
= te
.te_Height
;
130 width
= ((struct Image
*)gad
->GadgetText
)->Width
;
131 height
= ((struct Image
*)gad
->GadgetText
)->Height
;
134 if (labelplace
== GV_LabelPlace_Right
)
136 x
= gad
->LeftEdge
+ gad
->Width
+ 5;
137 y
= gad
->TopEdge
+ (gad
->Height
- height
) / 2 + 1;
138 } else if (labelplace
== GV_LabelPlace_Above
)
140 x
= gad
->LeftEdge
- (width
- gad
->Width
) / 2;
141 y
= gad
->TopEdge
- height
- 2;
142 } else if (labelplace
== GV_LabelPlace_Below
)
144 x
= gad
->LeftEdge
- (width
- gad
->Width
) / 2;
145 y
= gad
->TopEdge
+ gad
->Height
+ 3;
146 } else if (labelplace
== GV_LabelPlace_In
)
148 x
= gad
->LeftEdge
- (width
- gad
->Width
) / 2;
149 y
= gad
->TopEdge
+ (gad
->Height
- height
) / 2 + 1;
150 } else /* GV_LabelPlace_Left */
152 x
= gad
->LeftEdge
- width
- 4;
153 y
= gad
->TopEdge
+ (gad
->Height
- height
) / 2 + 1;
156 if (gad
->Flags
& GFLG_LABELSTRING
)
158 SetABPenDrMd(rport
, 1, 0, JAM1
);
160 Text(rport
, text
, len
);
161 } else if (gad
->Flags
& GFLG_LABELIMAGE
)
162 DrawImage(rport
, (struct Image
*)gad
->GadgetText
, x
, y
);
165 PrintIText(rport
, gad
->GadgetText
, x
, y
);
166 closefont(rport
, font
, oldfont
);