Use TARGET_STRIP instead of STRIP. Needed on OS X.
[AROS.git] / rom / intuition / dogadgetmethoda.c
blobf5d8293fa94dec87cb24707f4f4488465e6d9b68
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
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"
17 #include "gadgets.h"
19 /*****************************************************************************
21 NAME */
22 #include <intuition/intuition.h>
23 #include <proto/intuition.h>
25 AROS_LH4(IPTR, DoGadgetMethodA,
27 /* SYNOPSIS */
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),
33 /* LOCATION */
34 struct IntuitionBase *, IntuitionBase, 135, Intuition)
36 /* FUNCTION
37 Invokes a BOOPSI method on an object with a GadgetInfo derived from
38 the supplied window or requester parameter.
40 INPUTS
41 gad - The gadget to work on
42 win - The window which contains the gadget or the requester with
43 the gadgets.
44 req - If the gadget is in a requester, you must specify that one,
45 too.
46 message - Send this message to the gadget.
48 RESULT
49 The result depends on the contents of the message sent to the
50 gadget.
52 NOTES
54 EXAMPLE
56 BUGS
58 SEE ALSO
60 INTERNALS
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 routine causes some form of
67 (layer?) locking. I presume the point of the lock is to avoid
68 removing the gadget from the window during a refresh, or to avoid
69 resizing the window during 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?!. :)
80 HISTORY
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 *****************************************************************************/
87 AROS_LIBFUNC_INIT
89 struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
90 struct GadgetInfo *gi = &GetPrivIBase(IntuitionBase)->DoGadgetMethodGI;
91 struct RastPort *rp = &GetPrivIBase(IntuitionBase)->DoGadgetMethodRP;
92 IPTR ret = 0;
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);
110 if (gi->gi_RastPort)
112 InitRastPort(rp);
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)
121 case OM_NEW:
122 case OM_SET:
123 case OM_NOTIFY:
124 case OM_UPDATE:
125 ((struct opSet *)msg)->ops_GInfo = gi;
126 ret = Custom_DoMethodA(IntuitionBase, gad, msg);
127 break;
129 case GM_LAYOUT:
130 ((struct gpLayout *)msg)->gpl_GInfo = gi;
131 ret = Custom_DoMethodA(IntuitionBase, gad, msg);
132 break;
134 case GM_RENDER:
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);
143 if (rport)
145 #if 0 /* stegerg: CHECKME!!!! */
146 //init intuition's global dogadmethod rp with obtained data
147 CopyMem(rport,rp,sizeof (struct RastPort));
149 if (gi->gi_DrInfo)
151 SetFont(rp, gi->gi_DrInfo->dri_Font);
154 ((struct gpRender *)msg)->gpr_RPort = rp;
155 ((struct gpRender *)msg)->gpr_GInfo = gi;
156 #else
157 if (gi->gi_DrInfo)
159 SetFont(rport, gi->gi_DrInfo->dri_Font);
162 ((struct gpRender *)msg)->gpr_RPort = rport;
163 ((struct gpRender *)msg)->gpr_GInfo = gi;
165 #endif
167 ret = Custom_DoMethodA(IntuitionBase, gad, msg);
169 ReleaseGIRPort(rport);
172 break;
174 default:
175 ((struct gpRender *)msg)->gpr_GInfo = gi;
176 ret = Custom_DoMethodA (IntuitionBase, gad, msg);
177 break;
179 } /* switch (msg->MethodID) */
181 if (gi->gi_DrInfo) FreeScreenDrawInfo (gi->gi_Screen, gi->gi_DrInfo );
183 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->GadgetLock);
185 } /* if (gad) */
187 DEBUG_DOGADGETMETHOD(dprintf("DoGadgetMethod[%x]: Return 0x%lx\n", gi, ret));
189 return( (ULONG)ret );
191 AROS_LIBFUNC_EXIT
193 } /* DoGadgetMethodA */