uicontrol

uicontrol — create a Graphic User Interface object

Calling sequence

h=uicontrol([prop1,val1] [,prop2, val2] ...)  
h=uicontrol(f,[prop1, val1] [,prop2, val2] ...)  

Parameters

o f : integer handle of the figure which will contain the control
o prop{1, 2 ...} : character string name of a property to set
o val{1, 2 ...} : scilab object value to give to the corresponding property
o h : handle of the created object

Description

this routine creates an object in a figure. If the handle of the figure is given (as the first parameter), the uicontrol is created in this figure. If no handle is given, the uicontrol is created in the current figure ( which may be obtained with a call to gcf() ). If there is no current figure, then one is created before the creation of the uicontrol. Then when the control is created, the properties given as parameters are set with the coresponding values. It is equivalent to create the uicontrol, and then set its properties with the set() command. Nevertheless, it generally more efficient to set the properties in the call to uicontrol(). This is particularly true coincerning the 'style' field. Indeed, the default value for this property is 'pushbutton'. So if you do not set it at creation time, a button will be created, and will be transformed to another uicontrol when you call the get(h,'style', ... ) instruction. Scilab and all the graphic objects communicate through the property mechanism. Thus, to create adapted uicontrol, one has to know the use of the property fields. Those are descibed under:

Properties

BackgroundColor[1,3] real vector or string Background color of the uicontrol. A color is specified as Red, Green and Blue values. Those values are real in [ 0,1]. The color can be given as a real vector, ie [R,G,B] or a string where each value is separated by a |, ie "R|G|B"
callbackstring String evaluated by the scilab interpreter when an usicontrol is activated. (for example when you click on a button).
fontanglestring : {'normal'} | italic | oblique For a control containing some text, this property sets the slant of the font.
fontsizereal For a control containing some text, this property sets the size of the font in FontUnits.
fontunitsstring : {points} | pixels | normalized For a control containing some text, this property sets the units with which the fontsize is specified.
fontweightstring : light | {normal} | demi | bold For a control containing some text, this property sets the weight of the used font
ListboxTopinteger For a ListBox, this property tells which item of the list appears on the first line of the visible area of the list.
Maxscalar Specifies the largest value the 'value' property can be set to. It has however differnet meaning on each uicontrol:
oCheck Boxes : Max is the value the 'value' property take when control is checked
oSilders : Maximinum value of the slider
oList boxes : if (Max-Min)>1 the list allows multiple selection, Otherwise not.
Minscalar Specifies the lowest value the 'value' property can be set to. It has however differnet meaning on each uicontrol:
oCheck Boxes : Min is the value the 'value' property take when control is unchecked
oSilders : Mininum value of the slider
oList boxes : if (Max-Min)>1 the list allows multiple selection, Otherwise not.
Parentinteger Handle of the control parent. Changing this property allows to move a control from a figure to another.
Position[1,4] real vector or string This property is used to set or get the geometrical configuration of a control. It is a real; vector : x y w h where the letters stand for the x location of the left bottom corner, the y location of the left bottom corner, the width and the height of the uicontrol. The unit is determined by the 'Unit' property. One can also set this property by giving a string where the fields are separated by a '|', ie "x|y|w|h".
SliderStep[1,2] real vector or string small big This property represents the step a slider is moved when the user click on the arrow (small step) or on the slide bar (big step).
Stringstring Generally, this property represents the text appearing in a uicontrol. Its exact meaning sometimes depends on the uicontrol style:
oList Boxes, Popup Menu the value can be a vector of string or a string where the items are separated by a '|'.
Stylestring : {pushbutton} | radiobutton | checkbox | edit | text | slider | frame |listbox | popupmenu Style of the uicontrol. Here is a short description of each one:
opushbutton A rectangular button generally used to run a callback.
oradiobutton A button whith to states : on or off.
ocheckbox a small uicontrol that have to state : on or off
oedit an editable string control
otext a text control (generally static).
oslider a scale control, that is a scrollbar use to set values between in range with the mouse.
oframe a control representing a zone used to group of related controls.
olistbox a control representing a list of item that can be scrolled. The item can be selected with the mouse.
opopupmenu a button which make a menu appear when clicked.
Tagstring this property is generally used to identify the control. It allows to give it a "name". Mainly used in conjontion with findobj().
Unitsstring : {points} | pixels | normalized Set the units used to specify the 'position' property.
Userdatascilab object this can be used to associate any scilab object to an uicontrol.
ValueValue of the uicontrol. The eact meaning depends on the style of the uicontrol.
oCheck boxes, Radio buttons value is set to Max (see above) when on and Min when off.
oList Boxes, Popu Menu value is a vector of indexes corresponding to the index of the selected entry in the list. 1 is the first item of the list.
oSliders value indicated by the slider bar.

Examples



f=figure();
// create a figure
h=uicontrol(f,'style','listbox', ...
 'position', [10 10 150 160]);
// create a listbox
set(h, 'string', "item 1|item 2|item3");
// fill the list
set(h, 'value', [1 3]);
// select item 1 and 3 in the list
close();
// close the figure
f=figure();
// create a figure
h=uicontrol(f,'style','listbox', ...
 'position', [10 10 150 160]);
// create a listbox
set(h, 'string', "item 1|item 2|item3");
// fill the list
set(h, 'value', [1 3]);
// select (highlight) the item 1 and 3 in the list
close();
//close the figure
 
  

See also

figure, set, get, uimenu

Author

Bertrand Guiheneuf