2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
6 #include <proto/alib.h>
7 #include <proto/exec.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>
25 #include "asl_intern.h"
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
},
50 struct ExtGadget
*eg
= (struct ExtGadget
*)DoSuperMethodA(cl
, o
, (Msg
)msg
);
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
);
70 CoerceMethod(cl
, (Object
*)eg
, OM_DISPOSE
);
78 /***********************************************************************************/
80 IPTR
AslProp__OM_DISPOSE(Class
* cl
, Object
* o
, Msg msg
)
82 struct AslPropData
*data
;
85 data
= INST_DATA(cl
, o
);
86 if (data
->frame
) DisposeObject(data
->frame
);
88 retval
= DoSuperMethodA(cl
, o
, msg
);
93 /***********************************************************************************/
95 IPTR
AslProp__OM_SET(Class
* cl
, Object
* o
, struct opSet
* msg
)
97 struct AslPropData
*data
;
98 struct TagItem
*tstate
= msg
->ops_AttrList
;
101 BOOL rerender
= FALSE
;
103 data
= INST_DATA(cl
, o
);
105 while((ti
= NextTagItem(&tstate
)))
109 case ASLSC_DeltaFactor
:
110 data
->deltafactor
= (LONG
)ti
->ti_Data
;
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
);
125 if (ti
->ti_Data
== ID_ARROWDEC
)
127 if (newtop
< data
->deltafactor
)
133 newtop
-= data
->deltafactor
;
139 if (top
<= total
- visible
- data
->deltafactor
)
141 newtop
+= data
->deltafactor
;
145 newtop
= total
- visible
;
151 struct TagItem set_tags
[] =
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
);
179 rp
= ObtainGIRPort(msg
->ops_GInfo
);
182 DoMethod(o
, GM_RENDER
, (IPTR
) msg
->ops_GInfo
, (IPTR
) rp
, GREDRAW_UPDATE
);
190 /***********************************************************************************/
192 IPTR
AslProp__GM_RENDER(Class
*cl
, struct Gadget
*g
, struct gpRender
*msg
)
194 struct AslPropData
*data
;
197 data
= INST_DATA(cl
, g
);
199 if (msg
->gpr_Redraw
== GREDRAW_REDRAW
)
201 struct TagItem im_tags
[] =
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
,
226 msg
->gpr_GInfo
->gi_DrInfo
);
230 struct IBox ibox
, fbox
;
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
,
247 msg
->gpr_GInfo
->gi_DrInfo
->dri_Pens
[BACKGROUNDPEN
],
253 } /* if (msg->gpr_Redraw == GREDRAW_REDRAW) */
255 retval
= DoSuperMethodA(cl
, (Object
*)g
, (Msg
)msg
);
260 /***********************************************************************************/