Name

uicontrol — create a Graphic User Interface object

Calling Sequence

    h = uicontrol(PropertyName,PropertyValue,...)
    h = uicontrol(parent,PropertyName,PropertyValue,...)
    h = uicontrol(uich)
    

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 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(). This is particularly true concerning the "Style" property. 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 set(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.

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.

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".

Callback

String

Instruction evaluated by the Scilab interpreter when an uicontrol is activated. (for example when you click on a button).

Enable

{on} | off

Enable or disable the uicontrol. If this property is set to "on" (default), the uicontrol is operational, but if this property is set to "off", the uicontrol will not respond to the mouse actions and will be grayed out.

FontAngle

{normal} | italic | oblique

For a control containing some text, this property sets the slant of the font.

FontSize

Scalar

For a control containing some text, this property sets the size of the font in FontUnits.

FontUnits

{points} | pixels | normalized

For a control containing some text, this property sets the units with which the FontSize is specified.

FontWeight

light | {normal} | demi | bold

For a control containing some text, this property sets the weight of the used font.

FontName

String

Used to choose the name of the font selected to display the text of the control.

ForegroundColor

[1,3] real vector or string

Foreground 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".

HorizontAlalignment

left | {center} | right

Set text horizontal alignment in the uicontrol. This property has only effect with Text, Edit and Check Boxes.

ListboxTop

Scalar

For a ListBox, this property tells which item of the list appears on the first line of the visible area of the list.

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.

Parent

Handle

Handle of the uicontrol parent. Changing this property allows to move a control from a figure to another.

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".

SliderStep

[1,2] real vector

[small big], the small step represents the movement achieved when clicking on the slider trough or tapping on the keyboard arrows (when the slider has focus); the big step is the amount moved when using Ctrl-keyboard-arrows. If the big step is omitted, it is defaulted to 1/10 of the scale.

String

String.

This property represents the text appearing in a uicontrol (Except for Frame and Slider styles). For ListBoxes and PopupMenus, the value can be a vector of string or a string where the items are separated by a "|". For Text uicontrols, this string can contain HTML code to format the text.

Style

{pushbutton} | radiobutton | checkbox | edit | text | slider | frame | listbox | popupmenu

Style of the uicontrol. 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.

Tag

String

This property is generally used to identify the control. It allows to give it a "name". Mainly used in conjunction with findobj().

Units

{points} | pixels | normalized

Set the units used to specify the "Position" property.

Userdata

Scilab data

This can be used to associate some Scilab objects (string,string matrix, matrix mxn) to an uicontrol.

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.

Verticalalignment

top | {middle} | bottom

Set text vertical alignment in the uicontrol. This property has only effect with Text and CheckBoxes styles.

Visible

{on} | off

Set the visibility of the uicontrol. If this property is set to "on" (default), the uicontrol is visible, but if this property is set to "off", the uicontrol will not appear in its parent figure.

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(f);
// close the figure
 

See Also

figure, set, get, uimenu

Authors

Bertrand Guiheneuf

Vincent Couvert