[Contents] [index] [Help] [Retrace] [browse <] [Browse >]

The attributes of a gadget are set up when the gadget is created.  Some of
these attributes can be changed later by using the gt_setgadgetattrs()
function:

    void GT_SetGadgetAttrs (struct Gadget *gad, struct Window *win,
                            struct Requester *req, Tag tag1, ... )
    void GT_SetGadgetAttrsA(struct Gadget *gad, struct Window *win,
                            struct Requester *req, struct TagItem *taglist)

The gad argument specifies the gadget to be changed while the win argument
specifies the window the gadget is in.  Currently, the req argument is
unused and must be set to NULL.

The gadget attributes are changed by passing tag arguments to these
functions.  The tag arguments can be either a set of tagitems on the stack
for gt_setgadgetattrs(), or a pointer to an array of tagitems for
gt_setgadgetattrsa().  the tag items specify the attributes that are to be
changed for the gadget.  Keep in mind though that not every gadget
attribute can be modified this way.

For example, in the slider gadget presented earlier, the level-formatting
string may not be changed after the gadget is created.  However, the
slider's level may be changed to 5 as follows:

    GT_SetGadgetAttrs(slidergad, win, req,
        GTSL_Level, 5,
        TAG_END);

Here are some other example uses of gt_setgadgetattrs() to change gadget
attributes after it is created.

    /* Disable a button gadget */
    GT_SetGadgetAttrs(buttongad, win, NULL,
                            GA_Disabled, TRUE,
                            TAG_END);

    /* Change a slider's range to be 1 to 100, currently at 50 */
    GT_SetGadgetAttrs(slidergad, win, NULL,
                            GTSL_Min, 1,
                            GTSL_Max, 100,
                            GTSL_Level, 50,
                            TAG_END);

    /* Add a node to the head of listview's list, and make it */
    /* the selected one */
    GT_SetGadgetAttrs(listviewgad, win, NULL,
                            /* detach list before modifying */
                            GTLV_Labels, ~0,
                            TAG_END);
    AddHead(&lvlabels, &newnode);
    GT_SetGadgetAttrs(listviewgad, win, NULL,
                            /* re-attach list */
                            GTLV_Labels, &lvlabels,
                            GTLV_Selected, 0,
                            TAG_END);

When changing a gadget using these functions, the gadget will
automatically update its visuals.  No refresh is required, nor should any
refresh call be performed.

    Warning:
    --------
    The gt_setgadgetattrs() functions may not be called inside of a
    gt_beginrefresh()/gt_endrefresh() pair.  this is true of intuition
    gadget functions generally, including those discussed in the
    "intuition gadgets" chapter.

In the sections that follow all the possible attributes for each kind of
gadget are discussed.  The tags are also described in the Autodocs for
gt_setgadgetattrs() in the amiga rom kernel reference manual: includes and
Autodocs.

    Important:
    ----------
    Tags that can only be sent to creategadget() and not to
    gt_setgadgetattrs() will be marked as create only in the
    discussion that follows.  Those that are valid parameters to both
    functions will be marked as create and set.