ginteractors.h
GInteractor
hierarchy looks like this:
Types | |
This abstract type is the superclass for all graphical interactors. | |
This interactor subtype represents an onscreen button. | |
This interactor subtype represents an onscreen check box. | |
This interactor subtype represents an onscreen slider. | |
This interactor subtype represents a text field for entering short text strings. | |
This interactor subtype represents a selectable list. | |
Functions | |
Sets the action command to the indicated string. | |
Returns the action command associated with the interactor. | |
Creates a GButton with the specified label. | |
Creates a GCheckBox with the specified label. | |
Sets the state of the check box. | |
Returns true if the check box is selected. | |
Creates a horizontal GSlider . | |
Sets the current value of the slider. | |
Returns the current value of the slider. | |
Creates a text field capable of holding nChars characters. | |
Sets the text of the field to the specified string. | |
Returns the contents of the text field. | |
Creates a chooser that initially contains no items, which are added using the addItem function. | |
Adds a new item consisting of the specified string. | |
Sets the chooser so that it shows the specified item. | |
Returns the current item selected in the chooser. |
typedef GObject GInteractor;
GWindow
, but they can
also be placed in specific positions just like any other
GObject
.
typedef GInteractor GButton;
main() { GWindow gw = newGWindow(600, 400); GButton button = newGButton("RED"); addToRegion(gw, button, "SOUTH"); while (true) { GEvent e = waitForEvent(ACTION_EVENT | CLICK_EVENT); if (getEventType(e) == MOUSE_CLICKED) break; printf("Please do not press this button again.\n"); } }
Usage:
cmd = getActionCommand(interactor);
typedef GInteractor GCheckBox;
GCheckBox
has an action command, clicking on the box
generates a GActionEvent
.
The display image of a check box is machine-dependent, but the declaration
GCheckBox *traceBox = new GCheckBox("Trace");typically produces a check box that looks something like this:
Usage:
button = newGButton(label);
typedef GInteractor GSlider;
ActionEvent
if the
slider has a nonempty action command.
The display image of a slider is machine-dependent, but the declaration
GSlider *slider = new GSlider();typically produces a slider that looks something like this:
Usage:
if (isSelected(chkbox)) ...
typedef GInteractor GTextField;
GActionEvent
if the text field has a nonempty
action command.
Usage:
value = getValue(slider);
typedef GInteractor GChooser;
newGChooser
function creates an empty chooser.
Once the chooser has been created, clients can use addItem
to add the options. For example, the following code creates a
GChooser
containing the four strings
"Small"
, "Medium"
, "Large"
,
and "X-Large"
:
GChooser sizeChooser = newGChooser(); addItem(sizeChooser, "Small"); addItem(sizeChooser, "Medium"); addItem(sizeChooser, "Large"); addItem(sizeChooser, "X-Large");
The display image of a GChooser
is machine-dependent,
but the chooser generated by this code typically looks something like this:
Usage:
str = getText(field);
void setActionCommand(GInteractor interactor, string cmd);
GActionEvent
.
Usage:
setActionCommand(interactor, cmd);
string getActionCommand(GInteractor interactor);
Usage:
cmd = getActionCommand(interactor);
GButton newGButton(string label);
GButton
with the specified label. This
function also sets the action command for the button to the
label string.
Usage:
button = newGButton(label);
GCheckBox GCheckBox(string label);
GCheckBox
with the specified label. In contrast
to the GButton
ructor, this function does not automatically
set an action command.
Usage:
chkbox = new GCheckBox(label);
void setSelected(GCheckBox chkbox, bool state);
Usage:
setSelected(chkbox, state);
bool isSelected(GCheckBox chkbox);
true
if the check box is selected.
Usage:
if (isSelected(chkbox)) ...
GSlider GSlider(int min, int max, int value);
GSlider
. The parameters are
the minimum value, maximum value, and current value of the slider.
Assigning an action command to the slider causes the slider to
generate an action event whenever the slider value changes.
Usage:
slider = new GSlider(min, max, value);
void setValue(GSlider slider, int value);
Usage:
setValue(slider, value);
int getValue(GSlider slider);
Usage:
value = getValue(slider);
GTextField GTextField(int nChars);
nChars
characters.
Assigning an action command to the text field causes it to generate an
action event whenever the user types the ENTER key.
Usage:
field = newGTextField(nChars);
void setText(GTextField field, string str);
Usage:
setText(field, str);
string getText(GTextField field);
Usage:
str = getText(field);
GChooser newGChooser(void);
addItem
function. Assigning an action command
to the chooser causes it to generate an action event whenever the
user selects an item.
Usage:
chooser = newGChooser();
void addItem(GChooser chooser, string item);
Usage:
addItem(chooser, item);
void setSelectedItem(GChooser chooser, string item);
Usage:
setSelectedItem(chooser, item);
string getSelectedItem(GChooser chooser);
Usage:
item = getSelectedItem(chooser);