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

Gadgets may be added to a window or requester when the window or requester
is opened, or they may be added later.  To add the gadgets when a window
is opened, use the WA_Gadgets tag with the OpenWindowTagList() call.  This
technique is demonstrated in the example above.  For a requester, set the
ReqGadget field in the Requester structure to point to the first gadget in
the list.

To add or remove gadgets in a window or requester that is already open,
use AddGList() or RemoveGList().  These functions operate on gadgets
arranged in a list.  A gadget list is linked together by the NextGadget
field of the Gadget structure (see the description of the Gadget structure
later in this chapter).

AddGList() adds a gadget list that you specify to the existing gadget list
of a window or requester:

    UWORD AddGList( struct Window *window, struct Gadget *agadget,
                    unsigned long position, long numGad,
                    struct Requester *requester );

Up to numGad gadgets will be added from the gadget list you specify
beginning with agadget.  The position argument determines where your
gadgets will be placed in the existing list of gadgets for the window or
requester.  Use (~0) to add your gadget list to the end of the window or
requester's gadget list.  This function returns the actual position where
your gadgets are added in the existing list.

To remove gadgets from a window or requester use RemoveGList():

    UWORD RemoveGList( struct Window *remPtr, struct Gadget *agadget,
                       long numGad );

This function removes up to numGad gadgets from a window or requester,
beginning with the specified one.  Starting with V37, if one of the
gadgets that is being removed is the active gadget, this routine will wait
for the user to release the mouse button before deactivating and removing
the gadget.  This function returns the former position of the removed
gadget or -1 if the specified gadget was not found.

The Gadget structure should never be directly modified after it has been
added to a window or requester.  To modify a gadget, first remove it with
RemoveGList(), modify the structure as needed, and then add the gadget
back to the system with AddGList().  Finally, refresh the gadget imagery
with RefreshGList(). (See the section on "Gadget Refreshing" below for
more information.)

Some attributes of a gadget may be modified through special Intuition
functions that perform the modification.  When using such functions it is
not necessary to remove, add or refresh the gadget.  These functions, such
as NewModifyProp(), OnGadget() and OffGadget(), are described later in
this chapter.