2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #include "intuition_intern.h"
8 #include "inputhandler_actions.h"
9 #include "inputhandler.h"
12 #include <proto/exec.h>
14 struct ActivateGadgetActionMsg
16 struct IntuiActionMsg msg
;
17 struct Window
*window
;
18 struct Requester
*requester
;
19 struct Gadget
*gadget
;
23 #define DEBUG_ACTIVATEGADGET(x) ;
25 static VOID
int_activategadget(struct ActivateGadgetActionMsg
*msg
,
26 struct IntuitionBase
*IntuitionBase
);
28 /*****************************************************************************
31 #include <proto/intuition.h>
33 AROS_LH3(BOOL
, ActivateGadget
,
36 AROS_LHA(struct Gadget
* , gadget
, A0
),
37 AROS_LHA(struct Window
* , window
, A1
),
38 AROS_LHA(struct Requester
*, requester
, A2
),
41 struct IntuitionBase
*, IntuitionBase
, 77, Intuition
)
44 Activates the specified gadget.
47 gadget - The gadget to activate
48 window - The window which contains the gadget
49 requester - The requester which contains the gadget or
50 NULL if it is not a requester gadget
64 *****************************************************************************/
70 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: Gadget 0x%lx Window 0x%lx Req 0x%lx\n",
71 gadget
, window
, requester
));
73 if (gadget
&& (window
|| requester
))
77 if ((((gadget
->GadgetType
& GTYP_GTYPEMASK
) == GTYP_CUSTOMGADGET
) && (!(gadget
->Activation
& GACT_ACTIVEGADGET
))) ||
78 ((gadget
->GadgetType
& GTYP_GTYPEMASK
) == GTYP_STRGADGET
))
80 struct ActivateGadgetActionMsg msg
;
83 msg
.requester
= requester
;
86 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: send gadget activation msg\n"));
88 DoSyncAction((APTR
)int_activategadget
, &msg
.msg
, IntuitionBase
);
90 success
= msg
.success
;
94 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: no Custom/Stringgadget\n"));
97 } /* if (!(gadget->Activation & GACT_ACTIVEGADGET)) */
100 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: Gadget Activation bit already set\n"));
104 } /* if (gadget && (window || requester)) */
107 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: No Gadget/Window/Requester\n"));
109 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: Success %d\n",
116 } /* ActivateGadget */
119 static VOID
int_activategadget(struct ActivateGadgetActionMsg
*msg
,
120 struct IntuitionBase
*IntuitionBase
)
122 struct IIHData
*iihdata
= (struct IIHData
*)GetPrivIBase(IntuitionBase
)->InputHandler
->is_Data
;
123 struct Window
*window
= msg
->window
;
124 struct Requester
*req
= msg
->requester
;
125 struct Gadget
*gadget
= msg
->gadget
;
127 DEBUG_ACTIVATEGADGET(dprintf("int_ActivateGadget: Gadget 0x%lx Window 0x%lx Req 0x%lx\n",
132 msg
->success
= FALSE
;
134 /* Activate gadget only if no other gadget is
135 actually active and the gadget to be
136 activated is in the actual active window
137 and the gadget is not disabled */
139 DEBUG_ACTIVATEGADGET(dprintf("int_ActivateGadget: activeGadget 0x%lx\n",
140 iihdata
->ActiveGadget
));
142 if ((iihdata
->ActiveGadget
== NULL
) &&
143 (IntuitionBase
->ActiveWindow
== window
) &&
144 ((gadget
->Flags
& GFLG_DISABLED
) == 0))
146 msg
->success
= (DoActivateGadget(window
, req
, gadget
, IntuitionBase
) != NULL
);