1 <?xml version="1.0" encoding="UTF-8"?>
2 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns4="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="uicontrol" xml:lang="en">
4 <refname>uicontrol</refname>
5 <refpurpose>create a Graphic User Interface object</refpurpose>
8 <title>Calling Sequence</title>
10 h = uicontrol(PropertyName,PropertyValue,...)
11 h = uicontrol(parent,PropertyName,PropertyValue,...)
16 <title>Description</title>
17 <para>This routine creates an object in a figure.</para>
18 <para>If the handle of the figure is given (as the first parameter), the
19 uicontrol is created in this figure. If no handle is given, the uicontrol
20 is created in the current figure (which may be obtained with a call to
21 <literal>gcf()</literal>). If there is no current figure, then one is
22 created before the creation of the uicontrol.
24 <para>Then when the control is created, the properties given as parameters
25 are set with the corresponding values. It is equivalent to create the
26 uicontrol, and then set its properties with the <literal>set()</literal>
27 command. Nevertheless, it generally more efficient to set the properties
28 in the call to <literal>uicontrol()</literal>. Scilab
29 and all the graphic objects communicate through the property mechanism.
30 Thus, to create adapted uicontrol, one has to know the use of the property
34 <literal>h= uicontrol(PropertyName, PropertyValue,...)</literal>
35 creates an uicontrol and assigns the specified properties and values to
36 it. It assigns the default values to any properties you do not specify.
37 The default uicontrol style is a "Pushbutton". The default parent is the
38 current figure. See the Properties section for information about these and
42 <literal>h= uicontrol(parent, PropertyName,
45 creates a uicontrol in the object specified
46 by the handle, parent. If you also specify a different value for the
47 Parent property, the value of the Parent property takes precedence. parent
48 is the handle of a figure.
51 <literal>h= uicontrol(uich)</literal> gives focus to the uicontrol
56 <title>Properties</title>
59 <term>BackgroundColor</term>
61 <para>[1,3] real vector or string</para>
62 <para>Background color of the uicontrol. A color is specified as
63 Red, Green and Blue values. Those values are real in [0,1]. The
64 color can be given as a real vector, ie [R,G,B] or a string where
65 each value is separated by a "|", ie "R|G|B".
73 <para>Instruction evaluated by the Scilab interpreter when an
74 uicontrol is activated. (for example when you click on a
80 <term>Callback_Type</term>
83 <para>The type of callback transmitted to the uicontrol.</para>
87 <literal>-1</literal> none (callback desactivated)
92 <literal>0</literal> a Scilab instruction
97 <literal>1</literal> a C or a Fortran function
102 <literal>2</literal> a Scilab function
111 <para>{on} | off</para>
113 Enable or disable the uicontrol. If this property is set to <literal>"on"</literal> (default), the uicontrol is operational,
114 but if this property is set to <literal>"off"</literal>, the uicontrol will not respond to the mouse actions and will be grayed out.
119 <term>FontAngle</term>
121 <para>{normal} | italic | oblique</para>
122 <para>For a control containing some text, this property sets the
128 <term>FontSize</term>
131 <para>For a control containing some text, this property sets the
132 size of the font in FontUnits.
137 <term>FontUnits</term>
139 <para>{points} | pixels | normalized</para>
140 <para>For a control containing some text, this property sets the
141 units with which the FontSize is specified.
146 <term>FontWeight</term>
148 <para>light | {normal} | demi | bold</para>
149 <para>For a control containing some text, this property sets the
150 weight of the used font.
155 <term>FontName</term>
158 <para>Used to choose the name of the font selected to display the
164 <term>ForegroundColor</term>
166 <para>[1,3] real vector or string</para>
167 <para>Foreground color of the uicontrol. A color is specified as
168 Red, Green and Blue values. Those values are real in [0,1]. The
169 color can be given as a real vector, ie [R,G,B] or a string where
170 each value is separated by a "|", ie "R|G|B".
175 <term>HorizontalAlignment</term>
177 <para>left | {center} | right</para>
178 <para>Set text horizontal alignment in the uicontrol. This property
179 has only effect with Text, Edit and Check Boxes.
184 <term>ListboxTop</term>
187 <para>For a ListBox, this property tells which item of the list
188 appears on the first line of the visible area of the list.
196 <para>Specifies the largest value the "Value" property can be set
197 to. It has however different meaning on each uicontrol:
201 <para>CheckBoxes: Max is the value the "Value" property take
202 when control is checked.
206 <para>Sliders: Maximum value of the slider.</para>
209 <para>ListBoxes: if (Max-Min)>1 the list allows multiple
210 selection, Otherwise not.
220 <para>Specifies the lowest value the "Value" property can be set to.
221 It has however different meaning on each uicontrol:
225 <para>CheckBoxes: Min is the value the "Value" property take
226 when control is unchecked.
230 <para>Sliders: Minimum value of the slider.</para>
233 <para>ListBoxes: if (Max-Min)>1 the list allows multiple
234 selection, Otherwise not.
244 <para>Handle of the uicontrol parent. Changing this property allows
245 to move a control from a figure to another.
252 <para>This property is no more supported.</para>
256 <term>Position</term>
258 <para>[1,4] real vector or string.</para>
259 <para>This property is used to set or get the geometrical
260 configuration of a control. It is a vector [x y w h] where the
261 letters stand for the x location of the left bottom corner, the y
262 location of the left bottom corner, the width and the height of the
263 uicontrol or a character string where each value is separated by a
264 "|", ie "x|y|w|h". The units are determined by the "Units"
267 <para>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.</para>
273 <para>flat | groove | raised | ridge | solid | sunken</para>
274 <para>Appearance of the border of the uicontrol:</para>
277 <para>PushButtons: the default value for "Relief" property is
282 <para>Edits: the default value for "Relief" property is
287 <para>Other styles: the default value for "Relief" property is
295 <term>SliderStep</term>
297 <para>[1,2] real vector</para>
298 <para>[small big], the small step represents the movement achieved
299 when clicking on the slider trough or tapping on the keyboard arrows
300 (when the slider has focus); the big step is the amount moved when
301 using Ctrl-keyboard-arrows. If the big step is omitted, it is
302 defaulted to 1/10 of the scale.
311 This property represents the text appearing in a uicontrol
312 (Except for Frame and Slider styles). For tables, the value is a string matrix. For ListBoxes and PopupMenus,
313 the value can be a vector of string or a string where the items are
314 separated by a "|". For Text uicontrols, this string can contain HTML code to format the text.
317 For Pushbutton or Text uicontrols, if the text is enclosed between two $ (dollar sign), then it will be
318 considered as a LaTeX expression, and if it is enclosed between < and >, it will be considered
322 For Image, the value specifies the path of the image file.
325 For Table, the value specifies the whole table data: <literal>[IGNORED COL1-HEADER...COLN-HEADER;ROW1-HEADER, ROW1COL1-DATA, ROW1COLN-DATA;...;ROWM-HEADER, ROWMCOL1-DATA, ROWMCOLN-DATA]</literal>.
330 <term>TooltipString</term>
332 <para>String or String vector</para>
334 This property represents the text of the uicontrol tooltip appearing when the mouse is over the uicontrol.
341 <para>{pushbutton} | radiobutton | checkbox | edit | text | slider |
342 frame | listbox | popupmenu | image | table
344 <para>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
349 <para>Pushbutton: a rectangular button generally used to run a
354 <para>Radiobutton: a button with to states. RadioButtons are
355 intended to be mutually exclusive (Your code must implement
356 mutually exclusive behavior).
360 <para>Checkbox: a button with to states (Used for multiple
361 independent choices).
365 <para>Edit: an editable string zone.</para>
368 <para>Text: a text control (generally static).</para>
371 <para>Slider: a scale control, that is a scrollbar use to set
372 values between in range with the mouse.
376 <para>Frame: a control representing a zone used to group related
381 <para>Listbox: a control representing a list of items that can
382 be scrolled. The items can be selected with the mouse.
386 <para>Popupmenu: a button which make a menu appear when
391 <para>Image: a sub-window where the image specified is displayed.</para>
394 <para>Table: an editable table.</para>
403 <para>This property is generally used to identify the control. It
404 allows to give it a "name". Mainly used in conjunction with
405 <literal>findobj()</literal>.
412 <para>{points} | pixels | normalized</para>
413 <para>Set the units used to specify the "Position" property.</para>
417 <term>Userdata</term>
419 <para>Scilab data</para>
420 <para>This can be used to associate some Scilab objects
421 (string,string matrix, matrix mxn) to an uicontrol.
428 <para>Scalar or vector</para>
429 <para>Value of the uicontrol. The exact meaning depends on the style
434 <para>CheckBoxes, Radio buttons: value is set to Max (see above)
435 when on and Min when off.
439 <para>ListBoxes, PopupMenus: value is a vector of indexes
440 corresponding to the indexes of the selected entries in the
441 list. 1 is the first item of the list.
445 <para>Sliders: value indicated by the slider bar.</para>
449 Images: value is used to set some image properties <literal>[X-Scale Y-Scale X-Shear Y-Shear RotationAngle]</literal>
456 <term>Verticalalignment</term>
458 <para>top | {middle} | bottom</para>
459 <para>Set text vertical alignment in the uicontrol. This property
460 has only effect with Text and CheckBoxes styles.
467 <para>{on} | off</para>
469 Set the visibility of the uicontrol. If this property is set to <literal>"on"</literal> (default), the uicontrol is visible,
470 but if this property is set to <literal>"off"</literal>, the uicontrol will not appear in its parent figure.
477 <title>Examples</title>
478 <programlisting role="example"><![CDATA[
481 h=uicontrol(f,'style','listbox', ...
482 'position', [10 10 150 160]);
484 set(h, 'string', "item 1|item 2|item3");
486 set(h, 'value', [1 3]);
487 // select item 1 and 3 in the list
491 <para>uicontrol function can be overloaded</para>
492 <programlisting role="example"><![CDATA[
494 mymlist = mlist(['objid','A','B'],[],[]);
496 // overload set / get for objid
497 function result = %objid_uicontrol(varargin)
498 // res = uicontrol(mymlist,'A');
499 obj_tmp = varargin(1);
500 field_tmp = varargin(2);
501 mprintf('uicontrol on an object of type %s, field = %s\n', typeof(obj_tmp), field_tmp);
505 res = uicontrol(mymlist,'property');
507 <para>Pushbuttons or Text can have LaTeX or MathML label</para>
508 <programlisting role="example"><![CDATA[
511 h=uicontrol(f,"style","pushbutton","string","$x^2$");
513 hh=uicontrol(f,"style","pushbutton","string","<msup><mi>x</mi><mn>2</mn></msup>");
514 hh.Position = h.Position + [50, 0, 0, 0];
516 h=uicontrol(f,"Style","text","string","$\Gamma(s)=\int_0^\infty t^{s-1}\mathrm{e}^{-t}\,\mathrm{d}t$");
517 // If it is too little
520 <programlisting role="example"><![CDATA[
521 // Include an editable table into a figure:
522 // Building a table of data:
523 params = [" " "Country" "Population [Mh]" "Temp.[°C]" ];
524 towns = ["Mexico" "Paris" "Tokyo" "Singapour"]';
525 country = ["Mexico" "France" "Japan" "Singapour"]';
526 pop = string([22.41 11.77 33.41 4.24]');
527 temp = string([26 19 22 17]');
528 table = [params; [ towns country pop temp ]]
532 as = f.axes_size; // [width height]
534 ut = uicontrol("style","table",..
536 "position",[5 as(2)-100 300 87],.. // => @top left corner of figure
537 "tooltipstring","Data from majors towns")
539 // Modify by hand some values in the table. Then get them back from the ui:
540 matrix(ut.string,size(table))
543 <refsection role="see also">
544 <title>See Also</title>
545 <simplelist type="inline">
547 <link linkend="figure">figure</link>
550 <link linkend="set">set</link>
553 <link linkend="get">get</link>
556 <link linkend="uimenu">uimenu</link>
559 <link linkend="math_rendering_features_in_graphic">LaTeX and MathML</link>