grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / asl / propclass.c
blobdfc6ce69f0a20f0139e47a6df9f506db6a8980d1
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/alib.h>
7 #include <proto/exec.h>
8 #include <proto/dos.h>
9 #include <proto/utility.h>
10 #include <proto/intuition.h>
11 #include <proto/graphics.h>
12 #include <proto/cybergraphics.h>
14 #include <exec/memory.h>
15 #include <intuition/screens.h>
16 #include <intuition/icclass.h>
17 #include <intuition/cghooks.h>
18 #include <intuition/imageclass.h>
19 #include <intuition/gadgetclass.h>
20 #include <graphics/gfx.h>
21 #include <cybergraphx/cybergraphics.h>
23 #include <string.h>
25 #include "asl_intern.h"
26 #include "layout.h"
28 #define SDEBUG 0
29 #define DEBUG 0
31 #include <aros/debug.h>
33 #define CLASS_ASLBASE ((struct AslBase_intern *)cl->cl_UserData)
34 #define HOOK_ASLBASE ((struct AslBase_intern *)hook->h_Data)
36 #define AslBase CLASS_ASLBASE
38 /********************** ASL PROP CLASS **************************************************/
40 IPTR AslProp__OM_NEW(Class * cl, Object * o, struct opSet * msg)
42 struct AslPropData *data;
43 struct TagItem fitags[] =
45 {IA_FrameType, FRAME_BUTTON},
46 {IA_EdgesOnly, TRUE },
47 {TAG_DONE, 0UL}
50 struct ExtGadget *eg = (struct ExtGadget *)DoSuperMethodA(cl, o, (Msg)msg);
51 if (eg)
53 data = INST_DATA(cl, eg);
55 eg->BoundsLeftEdge = eg->LeftEdge;
56 eg->BoundsTopEdge = eg->TopEdge;
57 eg->BoundsWidth = eg->Width;
58 eg->BoundsHeight = eg->Height;
59 eg->MoreFlags |= GMORE_BOUNDS;
61 eg->LeftEdge += BORDERPROPSPACINGX;
62 eg->TopEdge += BORDERPROPSPACINGY;
63 eg->Width -= BORDERPROPSPACINGX * 2;
64 eg->Height -= BORDERPROPSPACINGY * 2;
66 data->deltafactor = 1;
67 data->frame = NewObjectA(NULL, FRAMEICLASS, fitags);
68 if (!data->frame)
70 CoerceMethod(cl, (Object *)eg, OM_DISPOSE);
71 eg = NULL;
75 return (IPTR)eg;
78 /***********************************************************************************/
80 IPTR AslProp__OM_DISPOSE(Class * cl, Object * o, Msg msg)
82 struct AslPropData *data;
83 IPTR retval;
85 data = INST_DATA(cl, o);
86 if (data->frame) DisposeObject(data->frame);
88 retval = DoSuperMethodA(cl, o, msg);
90 return retval;
93 /***********************************************************************************/
95 IPTR AslProp__OM_SET(Class * cl, Object * o, struct opSet * msg)
97 struct AslPropData *data;
98 struct TagItem *tstate = msg->ops_AttrList;
99 struct TagItem *ti;
100 IPTR retval;
101 BOOL rerender = FALSE;
103 data = INST_DATA(cl, o);
105 while((ti = NextTagItem(&tstate)))
107 switch(ti->ti_Tag)
109 case ASLSC_DeltaFactor:
110 data->deltafactor = (LONG)ti->ti_Data;
111 break;
113 case ASLSC_Inc:
114 case ASLSC_Dec:
115 if (((LONG)ti->ti_Data > 0) &&
116 (((struct opUpdate *)msg)->opu_Flags & OPUF_INTERIM))
118 IPTR top, total, visible, newtop;
120 GetAttr(PGA_Top, o, &top);
121 GetAttr(PGA_Total, o, &total);
122 GetAttr(PGA_Visible, o, &visible);
124 newtop = top;
125 if (ti->ti_Data == ID_ARROWDEC)
127 if (newtop < data->deltafactor)
129 newtop = 0;
131 else
133 newtop -= data->deltafactor;
137 else
139 if (top <= total - visible - data->deltafactor)
141 newtop += data->deltafactor;
143 else
145 newtop = total - visible;
149 if (newtop != top)
151 struct TagItem set_tags [] =
153 {PGA_Top, newtop },
154 {TAG_DONE }
156 struct opSet ops;
158 ops.MethodID = OM_SET;
159 ops.ops_AttrList = set_tags;
160 ops.ops_GInfo = msg->ops_GInfo;
162 DoMethodA(o, (Msg)&ops);
164 /* rerender = TRUE; */
167 } /* if ((ti->ti_Data > 0) && (((struct opUpdate *)msg)->opu_Flags & OPUF_INTERIM)) */
169 } /* switch(ti->ti_Tag) */
171 } /* while((ti = NextTagItem(&tstate))) */
173 retval = DoSuperMethodA(cl, o, (Msg) msg);
175 if (rerender)
177 struct RastPort *rp;
179 rp = ObtainGIRPort(msg->ops_GInfo);
180 if (NULL != rp)
182 DoMethod(o, GM_RENDER, (IPTR) msg->ops_GInfo, (IPTR) rp, GREDRAW_UPDATE);
183 ReleaseGIRPort(rp);
187 return retval;
190 /***********************************************************************************/
192 IPTR AslProp__GM_RENDER(Class *cl, struct Gadget *g, struct gpRender *msg)
194 struct AslPropData *data;
195 IPTR retval;
197 data = INST_DATA(cl, g);
199 if (msg->gpr_Redraw == GREDRAW_REDRAW)
201 struct TagItem im_tags[] =
203 {IA_Width , 0 },
204 {IA_Height , 0 },
205 {TAG_DONE }
207 WORD x, y, w, h;
209 getgadgetcoords(g, msg->gpr_GInfo, &x, &y, &w, &h);
211 x -= BORDERPROPSPACINGX;
212 y -= BORDERPROPSPACINGY;
213 w += BORDERPROPSPACINGX * 2;
214 h += BORDERPROPSPACINGY * 2;
216 im_tags[0].ti_Data = w;
217 im_tags[1].ti_Data = h;
219 SetAttrsA(data->frame, im_tags);
221 DrawImageState(msg->gpr_RPort,
222 (struct Image *)data->frame,
225 IDS_NORMAL,
226 msg->gpr_GInfo->gi_DrInfo);
228 #if AVOID_FLICKER
230 struct IBox ibox, fbox;
232 fbox.Left = x;
233 fbox.Top = y;
234 fbox.Width = w;
235 fbox.Height = h;
237 ibox.Left = x + BORDERPROPSPACINGX;
238 ibox.Top = y + BORDERPROPSPACINGY;
239 ibox.Width = w - BORDERPROPSPACINGX * 2;
240 ibox.Height = h - BORDERPROPSPACINGY * 2;
242 PaintInnerFrame(msg->gpr_RPort,
243 msg->gpr_GInfo->gi_DrInfo,
244 data->frame,
245 &fbox,
246 &ibox,
247 msg->gpr_GInfo->gi_DrInfo->dri_Pens[BACKGROUNDPEN],
248 AslBase);
251 #endif
253 } /* if (msg->gpr_Redraw == GREDRAW_REDRAW) */
255 retval = DoSuperMethodA(cl, (Object *)g, (Msg)msg);
257 return retval;
260 /***********************************************************************************/