2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #include <exec/memory.h>
8 #include <intuition/classusr.h>
9 #include <intuition/gadgetclass.h>
10 #include <intuition/cghooks.h>
11 #include <proto/alib.h>
12 #include <proto/exec.h>
13 #include <proto/graphics.h>
14 #include <proto/layers.h>
15 #include <proto/intuition.h>
16 #include "intuition_intern.h"
19 /*****************************************************************************
22 #include <intuition/intuition.h>
23 #include <proto/intuition.h>
25 AROS_LH4(IPTR
, DoGadgetMethodA
,
28 AROS_LHA(struct Gadget
*, gad
, A0
),
29 AROS_LHA(struct Window
*, win
, A1
),
30 AROS_LHA(struct Requester
*, req
, A2
),
31 AROS_LHA(Msg
, msg
, A3
),
34 struct IntuitionBase
*, IntuitionBase
, 135, Intuition
)
37 Invokes a boopsi method on a object with a GadgetInfo derived from
38 the supplied window or requester parameter.
41 gad - The gadget to work on
42 win - The window which contains the gadget or the requester with
44 req - If the gadget is in a requester, you must specify that one,
46 message - Send this message to the gadget.
49 The result depends on the contents of the message sent to the
61 I have derived from a simular function from ClassAct where I have
62 to "fake" the function which is not implemented under OS 2.04.
63 There are likely a few differences between this routine and the
64 real code, but this gets the job done.
66 One thing to note, the Amiga Rom routinecauses some form of
67 (layer?) locking. I presume the point of the lock is to avoid
68 removing the gadget from the window durring a refresh, or to avoid
69 resizing the window durring refresh, etc.
71 This locking is fairly obvious within Workbench itself. When
72 refreshing most any boopsi gadget(s) via RefreshGList() and you try
73 to drag a Workbench icon you will get stuck in a layer lock.
74 Workbench has a deadlock timer and is smart enough to release the
75 lock and abort the drag. With this routine below this locking does
76 not occur. Some might call it a good thing, however the issue
77 should be revisited once more of Intuition has been implemented -
78 if it hasn't been already?!. :)
81 29-10-95 digulla automatically created from
82 intuition_lib.fd and clib/intuition_protos.h
83 25-10-96 calid submitted the code
85 *****************************************************************************/
88 AROS_LIBBASE_EXT_DECL(struct IntuitionBase
*,IntuitionBase
)
90 struct GadgetInfo
*gi
= &GetPrivIBase(IntuitionBase
)->DoGadgetMethodGI
;
91 struct RastPort
*rp
= &GetPrivIBase(IntuitionBase
)->DoGadgetMethodRP
;
94 DEBUG_DOGADGETMETHOD(dprintf("DoGadgetMethod[%x]: Gad %p Win %p Req %p Method %ld (0x%lx)\n",
95 gi
, gad
, win
, req
, msg
->MethodID
, msg
->MethodID
));
97 if (!win
&& req
) win
= req
->RWindow
;
99 if (gad
&& (((gad
->GadgetType
& GTYP_GTYPEMASK
) == GTYP_CUSTOMGADGET
) || (gad
->GadgetType
& 0x100))) /* OS routines work with NULL objects */
102 /* Protect DoMethodA against race conditions between app task
103 and input.device task (which executes Intuitions Inputhandler) */
105 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->GadgetLock
);
107 //jDc: SetupGInfo fails when there's no window (but it also clears gadgetinfo!)
108 SetupGInfo(gi
, win
, req
, gad
, IntuitionBase
);
113 rp
->Layer
= gi
->gi_RastPort
->Layer
;
114 rp
->BitMap
= gi
->gi_RastPort
->BitMap
;
115 gi
->gi_RastPort
= rp
;
116 SetFont(rp
, gi
->gi_DrInfo
->dri_Font
);
119 switch (msg
->MethodID
)
125 ((struct opSet
*)msg
)->ops_GInfo
= gi
;
126 ret
= Custom_DoMethodA(gad
, msg
);
130 ((struct gpLayout
*)msg
)->gpl_GInfo
= gi
;
131 ret
= Custom_DoMethodA(gad
, msg
);
136 struct RastPort
*rport
;
138 /* Allocate a clone rastport derived from the GadgetInfo
139 * whose layer clipping information has been nulled out...
141 rport
= ObtainGIRPort(gi
);
145 #if 0 /* stegerg: CHECKME!!!! */
146 //init intuition's global dogadmethod rp with obtained data
147 CopyMem(rport
,rp
,sizeof (struct RastPort
));
151 SetFont(rp
, gi
->gi_DrInfo
->dri_Font
);
154 ((struct gpRender
*)msg
)->gpr_RPort
= rp
;
155 ((struct gpRender
*)msg
)->gpr_GInfo
= gi
;
159 SetFont(rport
, gi
->gi_DrInfo
->dri_Font
);
162 ((struct gpRender
*)msg
)->gpr_RPort
= rport
;
163 ((struct gpRender
*)msg
)->gpr_GInfo
= gi
;
167 ret
= Custom_DoMethodA(gad
, msg
);
169 ReleaseGIRPort(rport
);
175 ((struct gpRender
*)msg
)->gpr_GInfo
= gi
;
176 ret
= Custom_DoMethodA (gad
, msg
);
179 } /* switch (msg->MethodID) */
181 if (gi
->gi_DrInfo
) FreeScreenDrawInfo (gi
->gi_Screen
, gi
->gi_DrInfo
);
183 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->GadgetLock
);
187 DEBUG_DOGADGETMETHOD(dprintf("DoGadgetMethod[%x]: Return 0x%lx\n", gi
, ret
));
189 return( (ULONG
)ret
);
193 } /* DoGadgetMethodA */