2 Copyright © 1995-2007, 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
66 *****************************************************************************/
72 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: Gadget 0x%lx Window 0x%lx Req 0x%lx\n",
73 gadget
, window
, requester
));
75 if (gadget
&& (window
|| requester
))
79 if ((((gadget
->GadgetType
& GTYP_GTYPEMASK
) == GTYP_CUSTOMGADGET
) && (!(gadget
->Activation
& GACT_ACTIVEGADGET
))) ||
80 ((gadget
->GadgetType
& GTYP_GTYPEMASK
) == GTYP_STRGADGET
))
82 struct ActivateGadgetActionMsg msg
;
85 msg
.requester
= requester
;
88 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: send gadget activation msg\n"));
90 DoSyncAction((APTR
)int_activategadget
, &msg
.msg
, IntuitionBase
);
92 success
= msg
.success
;
96 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: no Custom/Stringgadget\n"));
99 } /* if (!(gadget->Activation & GACT_ACTIVEGADGET)) */
102 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: Gadget Activation bit already set\n"));
106 } /* if (gadget && (window || requester)) */
109 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: No Gadget/Window/Requester\n"));
111 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: Success %d\n",
118 } /* ActivateGadget */
121 static VOID
int_activategadget(struct ActivateGadgetActionMsg
*msg
,
122 struct IntuitionBase
*IntuitionBase
)
124 struct IIHData
*iihdata
= (struct IIHData
*)GetPrivIBase(IntuitionBase
)->InputHandler
->is_Data
;
125 struct Window
*window
= msg
->window
;
126 struct Requester
*req
= msg
->requester
;
127 struct Gadget
*gadget
= msg
->gadget
;
129 DEBUG_ACTIVATEGADGET(dprintf("int_ActivateGadget: Gadget 0x%lx Window 0x%lx Req 0x%lx\n",
134 msg
->success
= FALSE
;
136 /* Activate gadget only if no other gadget is
137 actually active and the gadget to be
138 activated is in the actual active window
139 and the gadget is not disabled */
141 DEBUG_ACTIVATEGADGET(dprintf("int_ActivateGadget: activeGadget 0x%lx\n",
142 iihdata
->ActiveGadget
));
144 if ((iihdata
->ActiveGadget
== NULL
) &&
145 (IntuitionBase
->ActiveWindow
== window
) &&
146 ((gadget
->Flags
& GFLG_DISABLED
) == 0))
148 msg
->success
= (DoActivateGadget(window
, req
, gadget
, IntuitionBase
) != NULL
);