The button class
Buttons come in a number of varieties,
such as ordinary (push) buttons, that simply invoke
an action, checkbuttons, that toggle between
an on and off state, and radiobuttons, that
may be used to constrain buttons to
allow the selection of only a single alternative.
Checkbuttons and radiobuttons are implemented as
subclasses of the class button, and will not
be discussed further here.
}
interface button : widget { \c{\fbox{button}}
button(char* p, char* options = "");
button(widget* w, char* p, char* options = "");
void text(char* s); \c{// to display text}
void bitmap(char* s); \c{// to display a bitmap}
void state(char *s); \c{// to change the buttons state}
void flash();
char* invoke();
protected:
install(action&,char* args);
};
slide: The button class
In addition to the constructors, which have the same
format for each widget class,
the button class offers the function text
to define the text displayed by the button and the
function bitmap, which takes as its argument
the name of a file containing a bitmap,
to have a bitmap displayed instead.
The function state may be used to change the state of the button.
Legal arguments are either normal, active or disabled.
Further, the button class defines the functions
flash and invoke that
result, respectively, in flashing the button and in invoking
the action associated with the button by means of
the function.
(Note that is defined, albeit protected.)