Page 319 Table of Contents Index Page 321
Chapters
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
A, B, C, D, E



CHAPTER 30. GADGETS

gadget class.

At pane creation time (that is, make-pane), the frame manager resolves the abstract class into
a specific implementation class; the implementation classes specify the detailed look and feel of
the gadget. Each frame manager will keep a mapping from abstract gadgets to an implemen-
tation class; if the frame manager does not implement its own gadget for the abstract gadget
classes in the following sections, it should use the portable class provided by CLIM. Since every
implementation of an abstract gadget class is a subclass of the abstract class, they all share the
same programmer interface.

30.2.1 Using Gadgets

Every gadget has a client that is specified when the gadget is created. The client is notified via the
callback mechanism when any important user interaction takes place. Typically, a gadget's client
will be an application frame or a composite pane. Each callback generic function is invoked on
the gadget, its client, the gadget id (described below), and other arguments that vary depending
on the callback.

For example, the argument list for activate-callback looks like (gadget client gadget-id).
Assuming the programmer has defined an application frame called button-test that has a
CLIM stream pane in the slot output-pane, he could write the following method:
 
 (defmethod activate-callback
            ((button push-button) (client button-test) gadget-id)
   (with-slots (output-pane) client
     (format output-pane "The button ~S was pressed, client ~S, id ~S."
             button client gadget-id)))

One problem with this example is that it differentiates on the class of the gadget, not on the
particular gadget instance. That is, the same method will run for every push button that has
the button-test frame as its client.

One way to distinguish between the various gadgets is via the gadget id, which is also specified
when the gadget is created. The value of the gadget id is passed as the third argument to each
callback generic function. In this case, if we have two buttons, we might install start and stop
as the respective gadget ids and then use eql specializers on the gadget ids. We could then
refine the above as:
 
 (defmethod activate-callback
            ((button push-button) (client button-test) (gadget-id (eql 'start)))
   (start-test client))

 (defmethod activate-callback
            ((button push-button) (client button-test) (gadget-id (eql 'stop)))
 (stop-test client))


Page 319 Table of Contents Index Page 321
Chapters
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
A, B, C, D, E