Panel Items
A panel item consists of a string
label and an associated variable of a certain type. The value of
this variable is visualized by the appearance in the window,
e.g., the position of a slider, and can be manipulated through the
item, e.g., by dragging the slider.
Panel buttons are special
panel items.
Remark: Panel items have to be created before the window
is displayed for the first time.
|
Item Types
LEDA provides the following item types: Simple Items, Choice
Items, Multiple Choice Items, Slider Items, Boolean
Items
On the right you see a screenshot of the example
of panel item types .
|
Example
for Panel Item Types
|
Associating a Function with a Panel Item
It is possible to associate a function of type
void (*action) (T x)
with a panel item where T is the type of the item.
The action function is called after each item manipulation, e.g.,
dragging a slider or pressing a button,
with the new value of the item as its argument.
The example for color shows
how action functions can be associated with slider items to define
the background color of a window.
|
Example Color Definition
Panel
|
Remark: The value of the variable is only changed after
the return of the action function. In this way, both the old and
the new value of the variable are available in the action function.
The values of item variables may also be changed in the program.
This has no effect on the display until the panel is actively
redrawn for the next time.
|
The redraw_panel() operation redraws the panel area. The Example
Progress Indicator uses a slider item to visualize the increasing
value of a counter.
|
Example
Progress Indicator
|