Using IlvSpinBox
For text fields, you can define a list of predefined string values which the user can spin through using the buttons. For number fields, you can define a set of numeric values, within the specified value range, which the user can increment or decrement using the buttons.
You can also add graphic objects to a spin box.
A Spin Box
See Using IlvNumberField and Using IlvTextField.
This section covers the following topics:
Adding and Removing Fields to a Spin Box
Adding Fields
To add a field to a spin box, you can use either one of these two member functions, depending on the type of values you want to display (character strings or numbers).
const char** values,
IlUShort count,
IlUShort pos,
IlBoolean loop,
IlUShort at = 0,
IlBoolean redraw = IlFalse);
The values parameter holds the string values that you will spin through. The count parameter specifies the number of strings in values.
void addField(IlvNumberField* field,
IlDouble value,
IlDouble increment,
IlBoolean loop,
IlUShort at = 0,
IlBoolean redraw = IlFalse);
When you add a numeric field to a spin box, the buttons allow you to change the value of the numeric field within the value range specified by the numeric field itself (see Using IlvNumberField).
The value parameter is the initial value of the field. The increment parameter specifies the value that is added to or removed from the value of the numeric field when the user clicks the Increment or Decrement buttons.
If the loop parameter is set to IlTrue, the spin box returns to the first value when the user tries to increment the last value, and to the last value when the user tries to decrement the first value.
The at parameter lets you insert the field at a specific location in the spin box.
Here is a short example (spinbox is a pointer to an IlvSpinBox object):
const char* values[7] = {"Monday", "Tuesday", "Wednesday",
"Thursday","Friday","Saturday","Sunday"};
spinbox->addField(new IlvTextField(display,"",IlvRect(0,0,10,10)),
values, 7, 0, IlTrue);
The rectangle used for creating the IlvTextField has no meaning here. Also, you do not need to add the IlvTextField to a container because now it is managed by the spin box.
Removing Fields
Adding Graphic Objects
Working with Text Fields
You can add a predefined string to a text field
You can set or retrieve the contents of a text field with these member functions:
const char* getLabel(IlvTextField*) const;
void setLabel(IlvTextField* field,
const char* label,
IlBoolean redraw = IlFalse);
void setLabel(IlvTextField* field,
IlUShort index,
IlBoolean redraw = IlFalse);
Working with Numeric Fields
The increment is the value that is added to or retrieved from the field value when the user clicks the spin box buttons.
You can set and retrieve the numeric value of a field with these member functions:
IlBoolean& error)const;
IlDouble value);
Event Handling and Callbacks
These callbacks are invoked when the user clicks the Increment and Decrement buttons. The active field, if any, is incremented/decremented just before the callback is invoked. The Main callback is called in both cases.