2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #include <proto/layers.h>
8 #include "intuition_intern.h"
9 #include "inputhandler_actions.h"
10 #include "inputhandler.h"
11 #include <intuition/gadgetclass.h>
13 struct RemoveGListActionMsg
15 struct IntuiActionMsg msg
;
16 struct Window
*window
;
17 struct Gadget
*gadget
;
23 static VOID
int_removeglist(struct RemoveGListActionMsg
*msg
,
24 struct IntuitionBase
*IntuitionBase
);
26 /*****************************************************************************
29 #include <intuition/intuition.h>
30 #include <proto/intuition.h>
32 AROS_LH3(UWORD
, RemoveGList
,
35 AROS_LHA(struct Window
*, remPtr
, A0
),
36 AROS_LHA(struct Gadget
*, gadget
, A1
),
37 AROS_LHA(LONG
, numGad
, D0
),
40 struct IntuitionBase
*, IntuitionBase
, 74, Intuition
)
60 *****************************************************************************/
63 AROS_LIBBASE_EXT_DECL(struct IntuitionBase
*,IntuitionBase
)
67 struct IIHData
*iihdata
;
74 DEBUG_REMOVEGLIST(dprintf("RemoveGList: Window 0x%lx Gadgets 0x%lx Num %ld\n",
75 remPtr
, gadget
, numGad
));
77 if (!numGad
) return ~0;
78 if (!gadget
) return ~0;
79 if (!remPtr
) return ~0;
84 LOCKWINDOWLAYERS(remPtr
);
87 iihdata
= (struct IIHData
*)GetPrivIBase(IntuitionBase
)->InputHandler
->is_Data
;
88 pred
= (struct Gadget
*)&remPtr
->FirstGadget
;
92 while (pred
->NextGadget
&& pred
->NextGadget
!= gadget
)
94 pred
= pred
->NextGadget
;
100 /* Check if one of the gadgets to be removed is the active gadget.
101 If it is, then make it inactive! */
104 for (last
= gadget
; last
&& numGad2
--; last
= last
->NextGadget
)
106 if ((iihdata
->ActiveGadget
== last
) || (iihdata
->ActiveSysGadget
== last
))
115 for (last
= gadget
; last
->NextGadget
&& --numGad
; last
= last
->NextGadget
) ;
117 pred
->NextGadget
= last
->NextGadget
;
119 /* stegerg: don't do this. DOpus for example relies on gadget->NextGadget
121 /* Emm: but the autodocs say it is done for V36 ??? */
123 last
->NextGadget
= NULL
;
128 } /* if (pred->NextGadget) */
137 UNLOCKWINDOWLAYERS(remPtr
);
140 /* We tried to remove the active gadget. This must be delayed until LMB
145 struct RemoveGListActionMsg msg
;
153 DEBUG_REMOVEGLIST(dprintf("RemoveGList: trying to remove the active gadget.\n"));
154 DoSyncAction((APTR
)int_removeglist
, &msg
.msg
, IntuitionBase
);
156 while (!msg
.success
);
161 DEBUG_REMOVEGLIST(dprintf("RemoveGList: removed %ld gadgets\n",count
));
169 static VOID
int_removeglist(struct RemoveGListActionMsg
*msg
,
170 struct IntuitionBase
*IntuitionBase
)
172 struct Window
*remPtr
= msg
->window
;
173 struct Gadget
*gadget
= msg
->gadget
;
174 LONG numGad
= msg
->numGad
;
177 struct IIHData
*iihdata
;
181 DEBUG_REMOVEGLIST(dprintf("IntRemoveGList: Window 0x%lx Gadgets 0x%lx Num %ld\n",
182 remPtr
, gadget
, numGad
));
184 iihdata
= (struct IIHData
*)GetPrivIBase(IntuitionBase
)->InputHandler
->is_Data
;
186 /* Don't remove the gadget until the LMB is released. */
187 if (iihdata
->ActQualifier
& IEQUALIFIER_LEFTBUTTON
)
189 DEBUG_REMOVEGLIST(dprintf("IntRemoveGList: LMB down\n"));
190 msg
->success
= FALSE
;
197 LOCKWINDOWLAYERS(remPtr
);
200 pred
= (struct Gadget
*)&remPtr
->FirstGadget
;
205 while (pred
->NextGadget
&& pred
->NextGadget
!= gadget
)
207 pred
= pred
->NextGadget
;
211 if (pred
->NextGadget
)
213 /* Check if one of the gadgets to be removed is the active gadget.
214 If it is, then make it inactive! If we got here, one of them was
215 the active gadget at the time of RemoveGList, but this may have
218 for (last
= gadget
; last
&& numGad2
--; last
= last
->NextGadget
)
220 if ((iihdata
->ActiveGadget
== last
) || (iihdata
->ActiveSysGadget
== last
))
222 switch(last
->GadgetType
& GTYP_GTYPEMASK
)
224 case GTYP_CUSTOMGADGET
:
226 struct gpGoInactive gpgi
;
228 gpgi
.MethodID
= GM_GOINACTIVE
;
229 gpgi
.gpgi_GInfo
= NULL
;
232 DoGadgetMethodA(last
, remPtr
, NULL
, (Msg
)&gpgi
);
234 if (SYSGADGET_ACTIVE
)
236 if (IS_BOOPSI_GADGET(iihdata
->ActiveSysGadget
))
238 DoGadgetMethodA(iihdata
->ActiveSysGadget
, remPtr
, NULL
, (Msg
)&gpgi
);
240 iihdata
->ActiveSysGadget
= NULL
;
247 last
->Activation
&= ~GACT_ACTIVEGADGET
;
248 iihdata
->ActiveGadget
= NULL
;
252 for (last
= gadget
; last
->NextGadget
&& --numGad
; last
= last
->NextGadget
) ;
254 pred
->NextGadget
= last
->NextGadget
;
256 /* stegerg: don't do this. DOpus for example relies on gadget->NextGadget
258 /* Emm: but the autodocs say it is done for V36 ??? */
260 last
->NextGadget
= NULL
;
263 } /* if (pred->NextGadget) */
272 UNLOCKWINDOWLAYERS(remPtr
);
275 DEBUG_REMOVEGLIST(dprintf("IntRemoveGList: done\n"));