[Contents] [Index] [Help] [Retrace] [Browse <] [Browse >]

Now all you need to do is implement a dispatcher routine.  When the
dispatcher is in operation, Intuition passes method IDs to it.  The
dispatcher will either execute code corresponding to the a method ID (the
code is usually part of the dispatcher) or delegate processing the method
to the superclass (or it can do a little of both).

The following fragment provides an example of what a dispatcher for a
boopsi class looks like (Note that __saveds (Save DS) is used to insure
that register A4 is set up properly for indirect addressing with the SASC

   ULONG __saveds dispatchmyTextLabel (Class *cl, Object *o, Msg msg)
       struct localObjData *lod;
       Object *newobj;
       ULONG retval;

       switch (msg->MethodID)
           /* Create a new object */
           case OM_NEW:
               /* Have our superclass create it.  DSM() passes on the
                * message to the superclass, where msg is the structure
                * containing the message specific parameters.
               if (newobj = (Object *) DSM (cl, o, msg))
                   /* Set the attributes */
                   setmyTextLabelAttrs(cl, newobj, (struct opSet *) msg);

               retval = (ULONG) newobj;

           /* Obtain information on an attribute */
           case OM_GET:
               retval = getmyTextLabelAttrs (cl, o, (struct opGet *) msg);

           /* Set attributes */
           case OM_UPDATE:
           case OM_SET:
               /* Let the superclass set the attributes that it
                * knows about. */
               retval = DSM (cl, o, msg);

               /* Set the attributes that we care about */
               retval |= setmyTextLabelAttrs (cl, o, (struct opSet *) msg);

           /* Draw the various states that the image supports */
           case IM_DRAW:
           case IM_DRAWFRAME:
               retval = drawmyTextLabel (cl, o, (struct impDraw *) msg);

           /* Let the superclass handle everything else */
               retval = (ULONG) DSM (cl, o, msg);

       return (retval);

[Back to Amiga Developer Docs]