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
*mb
)
135 Class
*cl
= NULL
, *cl2
;
137 ForeachNode(&MUIMB(mb
)->BuiltinClasses
, cl2
)
139 if (!strcmp(cl2
->cl_ID
, classid
))
149 static Class
*ZUNE_MakeBuiltinClass(ClassID classid
,
150 struct Library
*MUIMasterBase
)
154 struct Library
*mb
= NULL
;
156 D(bug("Makeing Builtinclass %s\n", classid
));
158 for (i
= 0; i
< sizeof(builtins
) / sizeof(builtins
[0]); i
++)
160 if (!strcmp(builtins
[i
]->name
, classid
))
165 /* This may seem strange, but opening muimaster.library here is
166 done in order to increase muimaster.library's open count, so
167 that it doesn't get expunged while some of its internal
168 classes are still in use. We don't use muimaster.library
169 directly but the name of the library stored inside the base,
170 because the library can be compiled also as zunemaster.library
173 mb
= OpenLibrary(MUIMasterBase
->lib_Node
.ln_Name
, 0);
175 /* It can't possibly fail, but well... */
179 if (strcmp(builtins
[i
]->supername
, ROOTCLASS
) == 0)
181 superclid
= ROOTCLASS
;
187 supercl
= MUI_GetClass(builtins
[i
]->supername
);
193 cl
= MakeClass(builtins
[i
]->name
, superclid
, supercl
,
194 builtins
[i
]->datasize
, 0);
197 #if defined(__MAXON__) || defined(__amigaos4__)
198 cl
->cl_Dispatcher
.h_Entry
= builtins
[i
]->dispatcher
;
200 cl
->cl_Dispatcher
.h_Entry
= (HOOKFUNC
) metaDispatcher
;
201 cl
->cl_Dispatcher
.h_SubEntry
= builtins
[i
]->dispatcher
;
203 /* Use this as a reference counter */
204 cl
->cl_Dispatcher
.h_Data
= 0;
217 Class
*ZUNE_GetBuiltinClass(ClassID classid
, struct Library
* mb
)
221 ObtainSemaphore(&MUIMB(MUIMasterBase
)->ZuneSemaphore
);
223 cl
= ZUNE_FindBuiltinClass(classid
, mb
);
227 cl
= ZUNE_MakeBuiltinClass(classid
, mb
);
231 ZUNE_AddBuiltinClass(cl
, mb
);
233 /* Increase the reference counter */
234 cl
->cl_Dispatcher
.h_Data
++;
238 ReleaseSemaphore(&MUIMB(MUIMasterBase
)->ZuneSemaphore
);
244 * metaDispatcher - puts h_Data in A6 and calls real dispatcher
248 AROS_UFH3(IPTR
, metaDispatcher
,
249 AROS_UFHA(struct IClass
*, cl
, A0
),
250 AROS_UFHA(Object
*, obj
, A2
), AROS_UFHA(Msg
, msg
, A1
))
253 return AROS_UFC4(IPTR
, cl
->cl_Dispatcher
.h_SubEntry
,
254 AROS_UFPA(Class
*, cl
, A0
),
255 AROS_UFPA(Object
*, obj
, A2
),
256 AROS_UFPA(Msg
, msg
, A1
),
257 AROS_UFPA(APTR
, cl
->cl_Dispatcher
.h_Data
, A6
));
263 __asm ULONG
metaDispatcher(register __a0
struct IClass
* cl
,
264 register __a2 Object
* obj
, register __a1 Msg msg
)
266 __asm
ULONG(*entry
) (register __a0
struct IClass
* cl
,
267 register __a2 Object
* obj
, register __a1 Msg msg
) =
268 (__asm
ULONG(*)(register __a0
struct IClass
*,
269 register __a2 Object
*,
270 register __a1 Msg
))cl
->cl_Dispatcher
.h_SubEntry
;
272 putreg(REG_A6
, (long)cl
->cl_Dispatcher
.h_Data
);
273 return entry(cl
, obj
, msg
);