create a Graphic User Interface object
h = uicontrol(PropertyName,PropertyValue,...)
h = uicontrol(parent,PropertyName,PropertyValue,...)
h = uicontrol(uich)
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 corresponding 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(). 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.
h= uicontrol(PropertyName, PropertyValue,...) creates an uicontrol and assigns the specified properties and values to it. It assigns the default values to any properties you do not specify. The default uicontrol style is a “Pushbutton”. The default parent is the current figure. See the Properties section for information about these and other properties.
h= uicontrol(parent, PropertyName, PropertyValue,...) creates a uicontrol in the object specified by the handle, parent. If you also specify a different value for the Parent property, the value of the Parent property takes precedence. parent is the handle of a figure.
h= uicontrol(uich) gives focus to the uicontrol specified by uich.
: :Callback_Type Integer The type of callback transmitted to the uicontrol.
- -1 none (callback desactivated)
- 0 a Scilab instruction
- 1 a C or a Fortran function
- 2 a Scilab function
: :Max Scalar Specifies the largest value the “Value” property can be set to. It has however different meaning on each uicontrol:
- CheckBoxes: Max is the value the “Value” property take when control is checked.
- Sliders: Maximum value of the slider.
- ListBoxes: if (Max-Min)>1 the list allows multiple selection, Otherwise not.
: :Min Scalar Specifies the lowest value the “Value” property can be set to. It has however different meaning on each uicontrol:
- CheckBoxes: Min is the value the “Value” property take when control is unchecked.
- Sliders: Minimum value of the slider.
- ListBoxes: if (Max-Min)>1 the list allows multiple selection, Otherwise not.
: :Path This property is no more supported. : :Position [1,4] real vector or string. This property is used to set
or get the geometrical configuration of a control. It is a 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 or a character string where each value is separated by a “|”, ie “x|y|w|h”. The units are determined by the “Units” property. The width and height values determine the orientation of sliders. If width is greater than height, then the slider is oriented horizontally, otherwise the slider is oriented vertically.
: :Relief flat | groove | raised | ridge | solid | sunken Appearance of the border of the uicontrol:
- PushButtons: the default value for “Relief” property is “raised”.
- Edits: the default value for “Relief” property is “sunken”.
- Other styles: the default value for “Relief” property is “flat”.
: :Style {pushbutton} | radiobutton | checkbox | edit | text | slider | frame | listbox | popupmenu | image | table Style of the uicontrol. This property has to be set at creation time and can not be changed once the uicontrol is created. Here is a short description of each one:
- Pushbutton: a rectangular button generally used to run a callback.
- Radiobutton: a button with to states. RadioButtons are intended to be mutually exclusive (Your code must implement mutually exclusive behavior).
- Checkbox: a button with to states (Used for multiple independent choices).
- Edit: an editable string zone.
- Text: a text control (generally static).
- Slider: a scale control, that is a scrollbar use to set values between in range with the mouse.
- Frame: a control representing a zone used to group related controls.
- Listbox: a control representing a list of items that can be scrolled. The items can be selected with the mouse.
- Popupmenu: a button which make a menu appear when clicked.
- Image: a sub-window where the image specified is displayed.
- Table: an editable table.
: :Value Scalar or vector Value of the uicontrol. The exact meaning depends on the style of the uicontrol:
- CheckBoxes, Radio buttons: value is set to Max (see above) when on and Min when off.
- ListBoxes, PopupMenus: value is a vector of indexes corresponding to the indexes of the selected entries in the list. 1 is the first item of the list.
- Sliders: value indicated by the slider bar.
- Images: value is used to set some image properties [X-Scale Y-Scale X-Shear Y-Shear RotationAngle]
:
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`_(f);
// close the figure
uicontrol function can be overloaded
// create a mlist
mymlist = `mlist`_(['objid','A','B'],[],[]);
// overload set / get for objid
function result=%objid_uicontrol(varargin)
// res = uicontrol(mymlist,'A');
obj_tmp = varargin(1);
field_tmp = varargin(2);
`mprintf`_('uicontrol on an object of type %s, field = %s\n', `typeof`_(obj_tmp), field_tmp);
result = %t;
endfunction
res = uicontrol(mymlist,'property');
Pushbuttons or Text can have LaTeX or MathML label
// LaTeX
f=`figure`_();
h=uicontrol(f,"style","pushbutton","string","$x^2$");
// MathML
hh=uicontrol(f,"style","pushbutton","string","<msup><mi>x</mi><mn>2</mn></msup>");
hh.Position = h.Position + [50, 0, 0, 0];
// Text
h=uicontrol(f,"Style","text","string","$\Gamma(s)=\int_0^\infty t^{s-1}\mathrm{e}^{-t}\,\mathrm{d}t$");
// If it is too little
h.fontsize=20