A common feature needed by an application is to have a number of objects displayed in a window and to make events affect the object underneath the cursor. The CAPI provides the ability to create graphical objects, to place them into a window at a specified size and position, and to display them as necessary. Also a function is provided to determine which object is under any given point so that events can be dispatched correctly.
These graphical objects are called
, as they can only be displayed if they are contained within a
. To define a pinboard-object, you define a subclass of
and specify a drawing routine for it (and you can also specify constraints on the size of your object). You can then make instances of these objects and place them into layouts just as if they were ordinary panes. You can also place these objects inside layouts as long as there is a
higher up the layout hierarchy that contains the panes.
s are implement as graphics on a native window. Compare this with
and its subclasses, where each instance is itself a native window. A consequence of this is that
s do not work well within a
, since they always appear above the
s. For example, to put labels on a pinboard, use
Here is an example of the built-in pinboard object class
which displays its text like a
. Note that the function
always creates a
as part of the wrapper for the object to be contained, and so it is possible to test the display of
s in just the same way as you can test other classes of CAPI object.
;; CONTAIN makes a pinboard-layout if needed, so we don't
;; need one explicitly in this example.
;; You will need an explicit pinboard-layout if you define
;; your own interface class.
:text "Hello world"))
Figure 12.4 A pinboard object
There is another example illustrating
in the file
CAPI User Guide (Unix version) - 30 Aug 2011