Updated to latest source.
[AROS-Contrib.git] / bgui / miscc.c
blob4e1838f453ffc0ee77a7045192d2856b2ef4e1e5
1 #include "include/classdefs.h"
2 #include <utility/hooks.h>
3 #include <intuition/classes.h>
4 #include <intuition/cghooks.h>
5 #include <proto/alib.h>
6 #include <proto/exec.h>
7 #include <proto/utility.h>
8 #include <proto/graphics.h>
9 #include <proto/intuition.h>
10 #include <libraries/locale.h>
12 #ifndef BGUI_COMPILERSPECIFIC_H
13 #include <bgui/bgui_compilerspecific.h>
14 #endif
16 #ifndef __AROS__
17 BOOL DisplayAGuideInfo(struct NewAmigaGuide *nag, struct TagItem * tags)
19 BOOL success = FALSE;
20 struct Library * AmigaGuideBase;
21 AmigaGuideBase = OpenLibrary("amigaguide.library",0);
23 if (NULL != AmigaGuideBase)
25 AMIGAGUIDECONTEXT handle = OpenAmigaGuideA(nag, tags);
26 if (0 != handle)
28 success = TRUE;
29 CloseAmigaGuide(handle);
31 CloseLibrary(AmigaGuideBase);
33 else
34 return FALSE;
36 #endif
38 //ASM ULONG ScaleWeight(REG(d2) ULONG e, REG(d3) ULONG f, REG(d4) ULONG a)
39 ASM REGFUNC3(ULONG, ScaleWeight,
40 REGPARAM(D2, ULONG, e),
41 REGPARAM(D3, ULONG, f),
42 REGPARAM(D4, ULONG, a))
44 ULONG r = UMult32(a,e);
45 return UDivMod32((f >> 1) + r, f);
47 REGFUNC_END
51 //void MyPutChProc_StrLenfA(REG(d0) BYTE c, REG(a3) ULONG * putChData)
52 REGFUNC2(void, MyPutChProc_StrLenfA,
53 REGPARAM(D0, BYTE, c),
54 REGPARAM(A3, ULONG *, putChData))
56 (*putChData)++;
58 REGFUNC_END
60 //ASM ULONG StrLenfA(REG(a0) UBYTE * FormatString, REG(a1) ULONG * DataStream)
61 ASM REGFUNC2(ULONG, StrLenfA,
62 REGPARAM(A0, UBYTE *, FormatString),
63 REGPARAM(A1, ULONG *, DataStream))
65 ULONG c = 0;
66 RawDoFmt(FormatString, DataStream, ((APTR)MyPutChProc_StrLenfA), &c);
67 return c;
69 REGFUNC_END
73 //void MyPutChProc_SPrintfA(REG(d0) char c, REG(a3) char **PutChData)
74 REGFUNC2(void, MyPutChProc_SPrintfA,
75 REGPARAM(D0, char, c),
76 REGPARAM(A3, char **, PutChData))
78 **PutChData = c;
79 *PutChData++;
81 REGFUNC_END
83 //ASM VOID SPrintfA(REG(a3) UBYTE * buffer, REG(a0) UBYTE * format, REG(a1) ULONG * args)
84 ASM REGFUNC3(VOID, SPrintfA,
85 REGPARAM(A3, UBYTE *, buffer),
86 REGPARAM(A0, UBYTE *, format),
87 REGPARAM(A1, ULONG *, args))
89 RawDoFmt(format, args, ((APTR)MyPutChProc_SPrintfA), &buffer);
91 REGFUNC_END
94 //ASM VOID LHook_Count(REG(a0) struct Hook * hook, REG(a1) ULONG chr, REG(a2) struct Locale * loc)
95 ASM REGFUNC3(VOID, LHook_Count,
96 REGPARAM(A0, struct Hook *, hook),
97 REGPARAM(A2, struct Locale *, loc),
98 REGPARAM(A1, ULONG, chr))
100 hook->h_Data++;
102 REGFUNC_END
105 //ASM VOID LHook_Format(REG(a0) struct Hook * hook, REG(a1) ULONG chr, REG(a2) struct Locale *loc)
106 ASM REGFUNC3(VOID, LHook_Format,
107 REGPARAM(A0, struct Hook *, hook),
108 REGPARAM(A2, struct Locale *, loc),
109 REGPARAM(A1, ULONG, chr))
111 char * cptr = (char *)hook->h_Data;
112 *cptr++ = (char)chr;
113 hook->h_Data = cptr;
115 REGFUNC_END
118 //ASM struct RastPort *BGUI_ObtainGIRPort(REG(a0) struct GadgetInfo * gi)
119 ASM REGFUNC1(struct RastPort *, BGUI_ObtainGIRPort,
120 REGPARAM(A0, struct GadgetInfo *, gi))
122 struct RastPort * rp;
123 BYTE * userdata = NULL;
125 if (NULL != gi)
127 if (NULL != gi->gi_Window)
128 userdata = gi->gi_Window->UserData;
130 if (NULL != gi->gi_Layer)
132 /* Does this make sense?? */
133 LockLayerRom(gi->gi_Layer); // this function returns void!!
134 UnlockLayerRom(gi->gi_Layer);
137 rp = ObtainGIRPort(gi);
138 if (NULL != rp)
139 rp->RP_User = (APTR)userdata;
141 return rp;
143 REGFUNC_END
146 ULONG AsmDoMethod(Object * obj, ULONG MethodID, ...)
148 AROS_SLOWSTACKMETHODS_PRE(MethodID)
149 #if 0
150 ASSERT_VALID_PTR(obj);
151 ASSERT_VALID_PTR(OCLASS(obj));
152 #endif
153 if (!obj)
154 retval = 0L;
155 else
156 retval = CallHookPkt ((struct Hook *)OCLASS(obj)
157 , obj
158 , AROS_SLOWSTACKMETHODS_ARG(MethodID)
160 AROS_SLOWSTACKMETHODS_POST
163 //ULONG AsmDoMethodA(REG(a2) Object * obj, REG(a1) Msg message)
164 REGFUNC2(ULONG, AsmDoMethodA,
165 REGPARAM(A2, Object *, obj),
166 REGPARAM(A1, Msg, message))
168 DoMethodA(obj, message);
170 REGFUNC_END
172 ULONG AsmDoSuperMethod( Class * cl, Object * obj, ULONG MethodID, ...)
174 AROS_SLOWSTACKMETHODS_PRE(MethodID)
175 if ((!obj) || (!cl))
176 retval = 0L;
177 else
178 retval = CallHookPkt ((struct Hook *)cl->cl_Super
179 , obj
180 , AROS_SLOWSTACKMETHODS_ARG(MethodID)
182 AROS_SLOWSTACKMETHODS_POST
185 //ULONG AsmDoSuperMethodA( REG(a0) Class * cl, REG(a2) Object * obj, REG(a1) Msg message)
186 REGFUNC3(ULONG, AsmDoSuperMethodA,
187 REGPARAM(A0, Class *, cl),
188 REGPARAM(A2, Object *, obj),
189 REGPARAM(A1, Msg, message))
191 DoSuperMethodA(cl,obj,message);
193 REGFUNC_END
195 ULONG AsmCoerceMethod( Class * cl, Object * obj, ULONG MethodID, ...)
197 AROS_SLOWSTACKMETHODS_PRE(MethodID)
198 if ((!obj) || (!cl))
199 retval = 0L;
200 else
201 retval = CallHookPkt ((struct Hook *)cl
202 , obj
203 , AROS_SLOWSTACKMETHODS_ARG(MethodID)
205 AROS_SLOWSTACKMETHODS_POST
208 //ULONG AsmCoerceMethodA( REG(a0) Class * cl, REG(a2) Object * obj, REG(a1) Msg message)
209 REGFUNC3(ULONG, AsmCoerceMethodA,
210 REGPARAM(A0, Class *, cl),
211 REGPARAM(A2, Object *, obj),
212 REGPARAM(A1, Msg, message))
214 CoerceMethodA(cl, obj, message);
216 REGFUNC_END