4 ** Copyright (C) 1998 Bernardo Innocenti
6 ** Use 4 chars wide TABs to read this file
8 ** Subclass of the buttongclass specialized for scroll buttons
11 #define USE_BUILTIN_MATH
12 #define INTUI_V36_NAMES_ONLY
14 #define CLIB_ALIB_PROTOS_H /* Avoid dupe defs of boopsi funcs */
17 #include <intuition/gadgetclass.h>
19 #include <proto/intuition.h>
26 #include "CompilerSpecific.h"
28 #include "BoopsiStubs.h"
30 #include "ScrollButtonClass.h"
35 /* Per object instance data */
36 struct ScrollButtonData
38 /* The number of ticks we still have to wait
39 * before sending any notification.
46 /* Dispatcher function prototype (just to keep esigent compilers quiet) */
48 static ULONG HOOKCALL ScrollButtonDispatcher (
50 REG(a2, struct Gadget *g),
51 REG(a1, struct gpInput *gpi));
53 static ULONG HOOKCALL ScrollButtonDispatcher (
55 REG(a2, struct Gadget *g),
56 REG(a1, struct gpInput *gpi))
58 /* ScrollButton Class Dispatcher entrypoint.
59 * Handle boopsi messages.
62 struct ScrollButtonData *bd = (struct ScrollButtonData *) INST_DATA(cl, g);
64 switch (gpi->MethodID)
67 /* May define an attribute to make delay configurable */
70 /* Notify our target that we have initially hit. */
71 NotifyAttrs ((Object *)g, gpi->gpi_GInfo, 0,
81 ULONG retval = GMR_MEACTIVE;
84 /* This also works with classic (non-boopsi) images. */
85 if (PointInImage ((gpi->gpi_Mouse.X << 16) + (gpi->gpi_Mouse.Y), g->GadgetRender))
88 selected = GFLG_SELECTED;
91 if (gpi->gpi_IEvent->ie_Class == IECLASS_RAWMOUSE && gpi->gpi_IEvent->ie_Code == SELECTUP)
93 /* Gadgetup, time to go */
95 /* Unselect the gadget on our way out... */
98 else if (gpi->gpi_IEvent->ie_Class == IECLASS_TIMER)
100 /* We got a tick. Decrement counter, and if 0, send notify. */
105 /* Notify our target that we are still being hit */
106 NotifyAttrs ((Object *)g, gpi->gpi_GInfo, 0,
111 if ((g->Flags & GFLG_SELECTED) != selected)
113 /* Update changes in gadget render */
114 g->Flags ^= GFLG_SELECTED;
115 if (rp = ObtainGIRPort (gpi->gpi_GInfo))
117 DoMethod ((Object *) g, GM_RENDER, gpi->gpi_GInfo, rp, GREDRAW_UPDATE);
125 /* Super class handles everything else */
126 return (DoSuperMethodA (cl, (Object *)g, (Msg) gpi));
132 Class *MakeScrollButtonClass (void)
136 if (class = MakeClass (NULL, BUTTONGCLASS, NULL, sizeof(struct ScrollButtonData), 0))
137 class->cl_Dispatcher.h_Entry = (ULONG (*)()) ScrollButtonDispatcher;
144 BOOL FreeScrollButtonClass (Class *cl)
146 return (FreeClass (cl));