2 Copyright © 2002-2003, The AROS Development Team. All rights reserved.
9 #include <intuition/classes.h>
10 #include <clib/alib_protos.h>
11 #include <proto/exec.h>
12 #include <proto/intuition.h>
13 #include <proto/utility.h>
14 #include <proto/muimaster.h>
19 #include "support_classes.h"
20 #include "muimaster_intern.h"
25 static const struct __MUIBuiltinClass
*const builtins
[] = {
28 &_MUI_Application_desc
,
34 &_MUI_Configdata_desc
,
39 ZUNE_BOOPSI_DESC
& _MUI_Prop_desc
,
45 ZUNE_VIRTGROUP_DESC ZUNE_SCROLLGROUP_DESC
& _MUI_Scrollbutton_desc
,
50 &_MUI_ChunkyImage_desc
,
55 ZUNE_POPASL_DESC
& _MUI_Popobject_desc
,
58 ZUNE_SETTINGSGROUP_DESC
63 ZUNE_ICONLISTVIEW_DESC
67 ZUNE_IMAGEDISPLAY_DESC
69 ZUNE_PENADJUST_DESC ZUNE_POPPEN_DESC
& _MUI_Mccprefs_desc
,
70 ZUNE_FRAMEDISPLAY_DESC
75 ZUNE_NUMERICBUTTON_DESC
80 ZUNE_KNOB_DESC ZUNE_DTPIC_DESC ZUNE_PALETTE_DESC
83 Class
*ZUNE_GetExternalClass(ClassID classname
,
84 struct Library
*MUIMasterBase
)
86 struct Library
*mcclib
= NULL
;
87 struct MUI_CustomClass
*mcc
= NULL
;
88 CONST_STRPTR
const *pathptr
;
91 static CONST_STRPTR
const searchpaths
[] = {
98 for (pathptr
= searchpaths
; *pathptr
; pathptr
++)
100 snprintf(s
, 255, *pathptr
, classname
);
102 D(bug("Trying opening of %s\n", s
));
104 if ((mcclib
= OpenLibrary(s
, 0)))
106 D(bug("Calling MCC Query. Librarybase at 0x%lx\n", mcclib
));
110 mcc
= MCC_Query(1); /* MCP? */
116 mcc
->mcc_Module
= mcclib
;
117 D(bug("Successfully opened %s as external class\n",
120 return mcc
->mcc_Class
;
124 CloseLibrary(mcclib
);
128 D(bug("Failed to open external class %s\n", classname
));
132 /**************************************************************************/
133 static Class
*ZUNE_FindBuiltinClass(ClassID classid
, struct Library
*MUIMasterBase
)
135 struct MUIMasterBase_intern
*intZuneBase
= (struct MUIMasterBase_intern
*)MUIMasterBase
;
136 Class
*cl
= NULL
, *cl2
;
138 ForeachNode(&intZuneBase
->BuiltinClasses
, cl2
)
140 if (!strcmp(cl2
->cl_ID
, classid
))
150 static Class
*ZUNE_MakeBuiltinClass(ClassID classid
,
151 struct Library
*MUIMasterBase
)
155 struct Library
*mb
= NULL
;
157 D(bug("Makeing Builtinclass %s\n", classid
));
159 for (i
= 0; i
< sizeof(builtins
) / sizeof(builtins
[0]); i
++)
161 if (!strcmp(builtins
[i
]->name
, classid
))
166 /* This may seem strange, but opening muimaster.library here is
167 done in order to increase muimaster.library's open count, so
168 that it doesn't get expunged while some of its internal
169 classes are still in use. We don't use muimaster.library
170 directly but the name of the library stored inside the base,
171 because the library can be compiled also as zunemaster.library
174 mb
= OpenLibrary(MUIMasterBase
->lib_Node
.ln_Name
, 0);
176 /* It can't possibly fail, but well... */
180 if (strcmp(builtins
[i
]->supername
, ROOTCLASS
) == 0)
182 superclid
= ROOTCLASS
;
188 supercl
= MUI_GetClass(builtins
[i
]->supername
);
194 cl
= MakeClass(builtins
[i
]->name
, superclid
, supercl
,
195 builtins
[i
]->datasize
, 0);
198 #if defined(__MAXON__) || defined(__amigaos4__)
199 cl
->cl_Dispatcher
.h_Entry
= builtins
[i
]->dispatcher
;
201 cl
->cl_Dispatcher
.h_Entry
= (HOOKFUNC
) metaDispatcher
;
202 cl
->cl_Dispatcher
.h_SubEntry
= builtins
[i
]->dispatcher
;
204 /* Use this as a reference counter */
205 cl
->cl_Dispatcher
.h_Data
= 0;
218 Class
*ZUNE_GetBuiltinClass(ClassID classid
, struct Library
* mb
)
222 ObtainSemaphore(&MUIMB(MUIMasterBase
)->ZuneSemaphore
);
224 cl
= ZUNE_FindBuiltinClass(classid
, mb
);
228 cl
= ZUNE_MakeBuiltinClass(classid
, mb
);
232 ZUNE_AddBuiltinClass(cl
, mb
);
234 /* Increase the reference counter */
235 char *count
= cl
->cl_Dispatcher
.h_Data
;
237 cl
->cl_Dispatcher
.h_Data
= count
;
241 ReleaseSemaphore(&MUIMB(MUIMasterBase
)->ZuneSemaphore
);
247 * metaDispatcher - puts h_Data in A6 and calls real dispatcher
251 AROS_UFH3(IPTR
, metaDispatcher
,
252 AROS_UFHA(struct IClass
*, cl
, A0
),
253 AROS_UFHA(Object
*, obj
, A2
), AROS_UFHA(Msg
, msg
, A1
))
256 return AROS_UFC4(IPTR
, cl
->cl_Dispatcher
.h_SubEntry
,
257 AROS_UFPA(Class
*, cl
, A0
),
258 AROS_UFPA(Object
*, obj
, A2
),
259 AROS_UFPA(Msg
, msg
, A1
),
260 AROS_UFPA(APTR
, cl
->cl_Dispatcher
.h_Data
, A6
));
266 __asm ULONG
metaDispatcher(register __a0
struct IClass
* cl
,
267 register __a2 Object
* obj
, register __a1 Msg msg
)
269 __asm
ULONG(*entry
) (register __a0
struct IClass
* cl
,
270 register __a2 Object
* obj
, register __a1 Msg msg
) =
271 (__asm
ULONG(*)(register __a0
struct IClass
*,
272 register __a2 Object
*,
273 register __a1 Msg
))cl
->cl_Dispatcher
.h_SubEntry
;
275 putreg(REG_A6
, (long)cl
->cl_Dispatcher
.h_Data
);
276 return entry(cl
, obj
, msg
);