2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
6 Routines for BOOL Gadgets
9 /****************************************************************************************/
11 #include <proto/graphics.h>
12 #include <proto/intuition.h>
13 #include <intuition/cghooks.h>
14 #include <intuition/imageclass.h>
15 #include <graphics/gfxmacros.h>
19 #include "intuition_intern.h"
22 #define DEBUG_REFRESHBOOLGADGET(x) ;
24 /****************************************************************************************/
26 #define RENDERGADGET(win,gad,rend) \
29 if (gad->Flags & GFLG_GADGIMAGE) \
32 , (struct Image *)rend \
42 , (struct Border *)rend \
49 #define GETRENDER(gad) (gad->SelectRender && (gad->Flags & GFLG_SELECTED)) ? \
50 gad->SelectRender : gad->GadgetRender;
55 /****************************************************************************************/
57 static void RenderBoolLabel(struct RastPort
*rp
, struct Gadget
*gadget
, struct BBox
*bbox
,
58 struct DrawInfo
*dri
, struct IntuitionBase
*IntuitionBase
)
60 #warning Amiga handmade (non-boopsi) bool gadgets do not seem to know anything about
61 #warning GFLG_LABELSTRING/GFLG_LABELIMAGE. Instead they always assume GadgetText to
62 #warning point to a struct IntuiText!!!
64 if (gadget
->GadgetText
)
66 SetFont(rp
, dri
->dri_Font
);
68 switch (gadget
->Flags
& GFLG_LABELMASK
)
71 PrintIText (rp
, gadget
->GadgetText
, bbox
->Left
, bbox
->Top
);
74 case GFLG_LABELSTRING
:
76 STRPTR text
= (STRPTR
) gadget
->GadgetText
;
77 int len
, labelwidth
, labelheight
;
81 labelwidth
= LabelWidth (rp
, text
, len
, IntuitionBase
);
82 labelheight
= rp
->Font
->tf_YSize
;
87 Move (rp
, bbox
->Left
+ bbox
->Width
/ 2 - labelwidth
/ 2,
88 bbox
->Top
+ bbox
->Height
/ 2 - labelheight
/ 2 + rp
->Font
->tf_Baseline
);
90 RenderLabel (rp
, text
, len
, IntuitionBase
);
95 DrawImageState (rp
, (struct Image
*)gadget
->GadgetText
,
102 } /* switch (gadget->Flags & GFLG_LABELMASK) */
108 /****************************************************************************************/
110 void RefreshBoolGadget (struct Gadget
* gadget
, struct Window
* window
,
111 struct Requester
* requester
, struct IntuitionBase
* IntuitionBase
)
114 struct GadgetInfo gi
;
115 struct DrawInfo
*dri
;
120 DEBUG_REFRESHBOOLGADGET(dprintf("RefreshBoolGadget: gadget %p window %p req %p\n",
121 gadget
, window
, requester
));
123 CalcBBox (window
, requester
, gadget
, &bbox
);
125 state
= GetGadgetState(window
, gadget
);
127 SetupGInfo(&gi
, window
, requester
, gadget
, IntuitionBase
);
129 rp
= ObtainGIRPort(&gi
);
132 dri
= GetScreenDrawInfo(window
->WScreen
);
136 switch (gadget
->Flags
& GFLG_GADGHIGHBITS
)
138 case GFLG_GADGHIMAGE
:
139 render
= GETRENDER(gadget
);
140 RENDERGADGET(window
,gadget
,render
);
146 render
= gadget
->GadgetRender
;
147 RENDERGADGET(window
,gadget
,render
);
150 } /* switch GadgetHighlightMethod */
152 RenderBoolLabel(rp
, gadget
, &bbox
, dri
, IntuitionBase
);
154 if ((bbox
.Width
>= 1) && (bbox
.Height
>= 1))
156 switch (gadget
->Flags
& GFLG_GADGHIGHBITS
)
159 if (gadget
->Flags
& GFLG_SELECTED
)
161 SetDrMd (rp
, COMPLEMENT
);
163 RectFill (rp
, bbox
.Left
,
165 bbox
.Left
+ bbox
.Width
- 1,
166 bbox
.Top
+ bbox
.Height
- 1);
171 if (gadget
->Flags
& GFLG_SELECTED
)
173 SetDrMd (rp
, COMPLEMENT
);
175 RectFill (rp
, bbox
.Left
- BOXSIZEX
,
177 bbox
.Left
+ bbox
.Width
- 1 + BOXSIZEX
,
178 bbox
.Top
+ bbox
.Height
- 1 + BOXSIZEY
);
180 RectFill (rp
, bbox
.Left
,
182 bbox
.Left
+ bbox
.Width
- 1,
183 bbox
.Top
+ bbox
.Height
- 1);
188 } /* Highlight after contents have been drawn */
190 if ( gadget
->Flags
& GFLG_DISABLED
)
192 RenderDisabledPattern(rp
, dri
, bbox
.Left
,
194 bbox
.Left
+ bbox
.Width
- 1,
195 bbox
.Top
+ bbox
.Height
- 1,
199 } /* if ((bbox.Width >= 1) && (bbox.Height >= 1)) */
201 FreeScreenDrawInfo(window
->WScreen
, dri
);
205 } /* RefreshBoolGadget */
207 /*****************************************************************************************
209 This function is called by Intuition's InputHandler when the GFLG_SELECTED state changed
211 *****************************************************************************************/
213 void RefreshBoolGadgetState(struct Gadget
* gadget
, struct Window
* window
,
214 struct Requester
* requester
, struct IntuitionBase
*IntuitionBase
)
216 struct GadgetInfo gi
;
218 struct DrawInfo
*dri
;
223 DEBUG_REFRESHBOOLGADGET(dprintf("RefreshBoolGadgetState: gadget %p window %p req %p\n",
224 gadget
, window
, requester
));
226 if ((gadget
->Flags
& GFLG_GADGHIGHBITS
) == GFLG_GADGHNONE
) return;
228 CalcBBox (window
, requester
, gadget
, &bbox
);
230 state
= GetGadgetState(window
, gadget
);
232 SetupGInfo(&gi
, window
, requester
, gadget
, IntuitionBase
);
234 rp
= ObtainGIRPort(&gi
);
237 dri
= GetScreenDrawInfo(window
->WScreen
);
241 switch (gadget
->Flags
& GFLG_GADGHIGHBITS
)
243 case GFLG_GADGHIMAGE
:
244 render
= GETRENDER(gadget
);
245 RENDERGADGET(window
,gadget
,render
);
246 RenderBoolLabel(rp
, gadget
, &bbox
, dri
, IntuitionBase
);
249 } /* switch GadgetHighlightMethod */
251 if ((bbox
.Width
>= 1) && (bbox
.Height
>= 1))
253 switch (gadget
->Flags
& GFLG_GADGHIGHBITS
)
256 SetDrMd (rp
, COMPLEMENT
);
258 RectFill (rp
, bbox
.Left
,
260 bbox
.Left
+ bbox
.Width
- 1,
261 bbox
.Top
+ bbox
.Height
- 1);
265 SetDrMd (rp
, COMPLEMENT
);
267 RectFill (rp
, bbox
.Left
- BOXSIZEX
,
269 bbox
.Left
+ bbox
.Width
- 1 + BOXSIZEX
,
270 bbox
.Top
+ bbox
.Height
- 1 + BOXSIZEY
);
272 RectFill (rp
, bbox
.Left
,
274 bbox
.Left
+ bbox
.Width
- 1,
275 bbox
.Top
+ bbox
.Height
- 1);
278 } /* switch (gadget->Flags & GFLG_GADGHIGHBITS) */
280 } /* if ((bbox.Width >= 1) && (bbox.Height >= 1)) */
282 FreeScreenDrawInfo(window
->WScreen
, dri
);
287 /****************************************************************************************/