2 Copyright © 1995-2007, 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
)
43 Remove sublist of gadgets from a window.
46 remPtr - window from which gadgets should be removed
47 gadget - pointer gadget to be removed
48 numGad - number of gadgets to remove. Use -1 to remove
49 all gadgets to the end of the list.
52 Ordinal number of the removed gadget or -1 on failure
61 RemoveGadget(), AddGadget(), AddGList()
67 *****************************************************************************/
73 struct IIHData
*iihdata
;
80 DEBUG_REMOVEGLIST(dprintf("RemoveGList: Window 0x%lx Gadgets 0x%lx Num %ld\n",
81 remPtr
, gadget
, numGad
));
83 if (!numGad
) return ~0;
84 if (!gadget
) return ~0;
85 if (!remPtr
) return ~0;
90 LOCKWINDOWLAYERS(remPtr
);
93 iihdata
= (struct IIHData
*)GetPrivIBase(IntuitionBase
)->InputHandler
->is_Data
;
94 pred
= (struct Gadget
*)&remPtr
->FirstGadget
;
98 while (pred
->NextGadget
&& pred
->NextGadget
!= gadget
)
100 pred
= pred
->NextGadget
;
104 if (pred
->NextGadget
)
106 /* Check if one of the gadgets to be removed is the active gadget.
107 If it is, then make it inactive! */
110 for (last
= gadget
; last
&& numGad2
--; last
= last
->NextGadget
)
112 if ((iihdata
->ActiveGadget
== last
) || (iihdata
->ActiveSysGadget
== last
))
121 for (last
= gadget
; last
->NextGadget
&& --numGad
; last
= last
->NextGadget
) ;
123 pred
->NextGadget
= last
->NextGadget
;
125 /* stegerg: don't do this. DOpus for example relies on gadget->NextGadget
127 /* Emm: but the autodocs say it is done for V36 ??? */
129 last
->NextGadget
= NULL
;
134 } /* if (pred->NextGadget) */
143 UNLOCKWINDOWLAYERS(remPtr
);
146 /* We tried to remove the active gadget. This must be delayed until LMB
151 struct RemoveGListActionMsg msg
;
159 DEBUG_REMOVEGLIST(dprintf("RemoveGList: trying to remove the active gadget.\n"));
160 DoSyncAction((APTR
)int_removeglist
, &msg
.msg
, IntuitionBase
);
162 while (!msg
.success
);
167 DEBUG_REMOVEGLIST(dprintf("RemoveGList: removed %ld gadgets\n",count
));
175 static VOID
int_removeglist(struct RemoveGListActionMsg
*msg
,
176 struct IntuitionBase
*IntuitionBase
)
178 struct Window
*remPtr
= msg
->window
;
179 struct Gadget
*gadget
= msg
->gadget
;
180 LONG numGad
= msg
->numGad
;
183 struct IIHData
*iihdata
;
187 DEBUG_REMOVEGLIST(dprintf("IntRemoveGList: Window 0x%lx Gadgets 0x%lx Num %ld\n",
188 remPtr
, gadget
, numGad
));
190 iihdata
= (struct IIHData
*)GetPrivIBase(IntuitionBase
)->InputHandler
->is_Data
;
192 /* Don't remove the gadget until the LMB is released. */
193 if (iihdata
->ActQualifier
& IEQUALIFIER_LEFTBUTTON
)
195 DEBUG_REMOVEGLIST(dprintf("IntRemoveGList: LMB down\n"));
196 msg
->success
= FALSE
;
203 LOCKWINDOWLAYERS(remPtr
);
206 pred
= (struct Gadget
*)&remPtr
->FirstGadget
;
211 while (pred
->NextGadget
&& pred
->NextGadget
!= gadget
)
213 pred
= pred
->NextGadget
;
217 if (pred
->NextGadget
)
219 /* Check if one of the gadgets to be removed is the active gadget.
220 If it is, then make it inactive! If we got here, one of them was
221 the active gadget at the time of RemoveGList, but this may have
224 for (last
= gadget
; last
&& numGad2
--; last
= last
->NextGadget
)
226 if ((iihdata
->ActiveGadget
== last
) || (iihdata
->ActiveSysGadget
== last
))
228 switch(last
->GadgetType
& GTYP_GTYPEMASK
)
230 case GTYP_CUSTOMGADGET
:
232 struct gpGoInactive gpgi
;
234 gpgi
.MethodID
= GM_GOINACTIVE
;
235 gpgi
.gpgi_GInfo
= NULL
;
238 DoGadgetMethodA(last
, remPtr
, NULL
, (Msg
)&gpgi
);
240 if (SYSGADGET_ACTIVE
)
242 if (IS_BOOPSI_GADGET(iihdata
->ActiveSysGadget
))
244 DoGadgetMethodA(iihdata
->ActiveSysGadget
, remPtr
, NULL
, (Msg
)&gpgi
);
246 iihdata
->ActiveSysGadget
= NULL
;
253 last
->Activation
&= ~GACT_ACTIVEGADGET
;
254 iihdata
->ActiveGadget
= NULL
;
258 for (last
= gadget
; last
->NextGadget
&& --numGad
; last
= last
->NextGadget
) ;
260 pred
->NextGadget
= last
->NextGadget
;
262 /* stegerg: don't do this. DOpus for example relies on gadget->NextGadget
264 /* Emm: but the autodocs say it is done for V36 ??? */
266 last
->NextGadget
= NULL
;
269 } /* if (pred->NextGadget) */
278 UNLOCKWINDOWLAYERS(remPtr
);
281 DEBUG_REMOVEGLIST(dprintf("IntRemoveGList: done\n"));