7 * (C) Copyright 1998 Manuel Lemos.
8 * (C) Copyright 1996-1997 Ian J. Einman.
9 * (C) Copyright 1993-1996 Jaba Development.
10 * (C) Copyright 1993-1996 Jan van den Baard.
11 * All Rights Reserved.
15 #include "include/classdefs.h"
18 extern struct Library
* AslBase
;
21 /// Class definitions.
23 * Object instance data.
26 APTR ad_Requester
; /* Requester */
27 ULONG ad_Type
; /* Requester type */
28 WORD ad_Left
; /* Requester left */
29 WORD ad_Top
; /* Requester top */
30 UWORD ad_Width
; /* Requester width */
31 UWORD ad_Height
; /* Requester height */
32 struct TagItem
*ad_ASLTags
; /* Copy of ASL tags */
35 #define AD_ENTRY(tag, offset, flags) PACK_ENTRY(ASLREQ_TAGSTART, tag, ad_, offset, flags)
36 #define AD_FLAG(tag, flag) PACK_LONGBIT(ASLREQ_TAGSTART, tag, ad_, ad_Flags, PKCTRL_BIT, flag)
38 static ULONG AslPackTable
[] =
40 PACK_STARTTABLE(ASLREQ_TAGSTART
),
42 AD_ENTRY(ASLREQ_Requester
, ad_Requester
, PKCTRL_ULONG
),
43 AD_ENTRY(ASLREQ_Type
, ad_Type
, PKCTRL_ULONG
),
44 AD_ENTRY(ASLREQ_Left
, ad_Left
, PKCTRL_WORD
),
45 AD_ENTRY(ASLREQ_Top
, ad_Top
, PKCTRL_WORD
),
46 AD_ENTRY(ASLREQ_Width
, ad_Width
, PKCTRL_UWORD
),
47 AD_ENTRY(ASLREQ_Height
, ad_Height
, PKCTRL_UWORD
),
55 * Create a shiny new object.
57 METHOD(AslReqClassNew
, struct opSet
*, ops
)
63 * First we let the superclass
66 if (rc
= AsmDoSuperMethodA(cl
, obj
, (Msg
)ops
))
69 * Get us the instance data.
71 ad
= INST_DATA(cl
, rc
);
80 ad
->ad_ASLTags
= CloneTagItems(NULL
);
83 * Setup user attributes.
85 if (AsmCoerceMethod(cl
, (Object
*)rc
, OM_SET
, ops
, NULL
) != ASLREQ_OK
)
90 AsmCoerceMethod(cl
, (Object
*)rc
, OM_DISPOSE
);
102 METHOD(AslReqClassDispose
, Msg
, msg
)
104 AD
*ad
= INST_DATA(cl
, obj
);
107 * Free requester, if it still exists somehow.
109 FreeAslRequest(ad
->ad_Requester
);
114 FreeTagItems(ad
->ad_ASLTags
);
117 * The superclass does the rest.
119 return AsmDoSuperMethodA(cl
, obj
, msg
);
123 /// OM_SET, OM_UPDATE
125 * Change one or more of the object
128 METHOD(AslReqClassSetUpdate
, struct opSet
*, ops
)
130 AD
*ad
= INST_DATA(cl
, obj
);
131 struct TagItem
*tstate
, *tags
, *tag
;
136 * Filter out values in old taglist that will be replaced,
137 * and values in new taglist that are not ASL tags.
138 * Process the non-ASL tags before disposal.
140 tstate
= tags
= CloneTagItems(ops
->ops_AttrList
);
142 while (tag
= NextTagItem(&tstate
))
147 if ((attr
>= ASL_TB
) && (attr
< ASL_TB
+ 0x10000))
156 *((struct IBox
*)&ad
->ad_Left
) = *((struct IBox
*)data
);
162 BGUI_PackStructureTag((UBYTE
*)ad
, AslPackTable
, attr
, data
);
168 tag
->ti_Tag
= TAG_IGNORE
;
173 * Merge the old with the new.
177 tag
= BGUI_MergeTagItems(ad
->ad_ASLTags
, tags
);
178 FreeTagItems(ad
->ad_ASLTags
);
179 ad
->ad_ASLTags
= BGUI_CleanTagItems(tag
, 1);
190 * Give one of the attributes.
192 METHOD(AslReqClassGet
, struct opGet
*, opg
)
194 AD
*ad
= INST_DATA(cl
, obj
);
196 ULONG rc
, attr
= opg
->opg_AttrID
, *store
= opg
->opg_Storage
;
198 if (tag
= FindTagItem(attr
, ad
->ad_ASLTags
))
200 *store
= tag
->ti_Data
;
205 rc
= BGUI_UnpackStructureTag((UBYTE
*)ad
, AslPackTable
, attr
, store
);
206 if (!rc
) rc
= AsmDoSuperMethodA(cl
, obj
, (Msg
)opg
);
212 /// ASLM_ALLOCREQUEST
214 * Allocate requester.
216 METHOD(AslReqClassAllocRequest
, Msg
, msg
)
218 AD
*ad
= INST_DATA(cl
, obj
);
220 ad
->ad_Requester
= AllocAslRequestTags(ad
->ad_Type
,
221 ASL_LeftEdge
, ad
->ad_Left
, ASL_TopEdge
, ad
->ad_Top
,
222 ASL_Width
, ad
->ad_Width
, ASL_Height
, ad
->ad_Height
,
225 return (ULONG
)ad
->ad_Requester
;
233 METHOD(AslReqClassRequest
, Msg
, msg
)
235 AD
*ad
= INST_DATA(cl
, obj
);
238 if (ad
->ad_Requester
)
240 rc
= AslRequest(ad
->ad_Requester
, ad
->ad_ASLTags
);
250 METHOD(AslReqClassFreeRequest
, Msg
, msg
)
252 AD
*ad
= INST_DATA(cl
, obj
);
254 FreeAslRequest(ad
->ad_Requester
);
255 ad
->ad_Requester
= NULL
;
262 /// Class initialization.
266 STATIC DPFUNC ClassFunc
[] = {
267 OM_NEW
, (FUNCPTR
)AslReqClassNew
,
268 OM_SET
, (FUNCPTR
)AslReqClassSetUpdate
,
269 OM_UPDATE
, (FUNCPTR
)AslReqClassSetUpdate
,
270 OM_GET
, (FUNCPTR
)AslReqClassGet
,
271 OM_DISPOSE
, (FUNCPTR
)AslReqClassDispose
,
272 ASLM_ALLOCREQUEST
, (FUNCPTR
)AslReqClassAllocRequest
,
273 ASLM_REQUEST
, (FUNCPTR
)AslReqClassRequest
,
274 ASLM_FREEREQUEST
, (FUNCPTR
)AslReqClassFreeRequest
,
279 * Simple class initialization.
281 makeproto Class
*InitAslReqClass(void)
283 return BGUI_MakeClass(CLASS_SuperClassBGUI
, BGUI_ROOT_OBJECT
,
284 CLASS_ObjectSize
, sizeof(AD
),
285 CLASS_DFTable
, ClassFunc
,