Minor fixes to comments.
[AROS.git] / rom / intuition / activategadget.c
blob97b9aba18133cea73b4bad5623fde9b8af2ebd2b
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
7 #include "intuition_intern.h"
8 #include "inputhandler_actions.h"
9 #include "inputhandler.h"
10 #include "gadgets.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;
20 BOOL success;
23 #define DEBUG_ACTIVATEGADGET(x) ;
25 static VOID int_activategadget(struct ActivateGadgetActionMsg *msg,
26 struct IntuitionBase *IntuitionBase);
28 /*****************************************************************************
30 NAME */
31 #include <proto/intuition.h>
33 AROS_LH3(BOOL, ActivateGadget,
35 /* SYNOPSIS */
36 AROS_LHA(struct Gadget * , gadget, A0),
37 AROS_LHA(struct Window * , window, A1),
38 AROS_LHA(struct Requester *, requester, A2),
40 /* LOCATION */
41 struct IntuitionBase *, IntuitionBase, 77, Intuition)
43 /* FUNCTION
44 Activates the specified gadget.
46 INPUTS
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
52 RESULT
54 NOTES
56 EXAMPLE
58 BUGS
60 SEE ALSO
62 INTERNALS
64 HISTORY
66 *****************************************************************************/
68 AROS_LIBFUNC_INIT
70 BOOL success = FALSE;
72 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: Gadget 0x%lx Window 0x%lx Req 0x%lx\n",
73 gadget, window, requester));
75 if (gadget && (window || requester))
77 if (1)
79 if ((((gadget->GadgetType & GTYP_GTYPEMASK) == GTYP_CUSTOMGADGET) && (!(gadget->Activation & GACT_ACTIVEGADGET))) ||
80 ((gadget->GadgetType & GTYP_GTYPEMASK) == GTYP_STRGADGET))
82 struct ActivateGadgetActionMsg msg;
84 msg.window = window;
85 msg.requester = requester;
86 msg.gadget = gadget;
88 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: send gadget activation msg\n"));
90 DoSyncAction((APTR)int_activategadget, &msg.msg, IntuitionBase);
92 success = msg.success;
94 else
96 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: no Custom/Stringgadget\n"));
99 } /* if (!(gadget->Activation & GACT_ACTIVEGADGET)) */
100 else
102 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: Gadget Activation bit already set\n"));
103 success = TRUE;
106 } /* if (gadget && (window || requester)) */
107 else
109 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: No Gadget/Window/Requester\n"));
111 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: Success %d\n",
112 success));
114 return success;
116 AROS_LIBFUNC_EXIT
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",
130 gadget,
131 window,
132 req));
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);