fn_control

Contents

Syntax

X = fn_control(s[,fun][,spec][,hparent] ...

Description

  [,'okbutton|nobutton'][,'ncol',n][,'title',titl])
function fn_control('demo')
cluster of controls representing the structure s (changing the
control changes the values in X, and changing the values in X
automatically updates the control display)
Input:
- s           structure to intialize X; s can also be a 2-element
              structure, standing for [s spec]
- fun         function with prototype @(s)fun, which will be called
              by X
- spec        structure with additional information on the aspect and
              behavior of the controls (see below); it should have
              the same fields as s (though some fields can be
              omitted)
- hp          parent figure or uipanel where to create the controls
              (a new figure is created if not specified)
- 'okbutton' or 'nobutton'
              specifically specify to have an ok button or no button
Output:
- X           a fn_control object, which can be manipulated using
              usual structure syntax
Possible values for the fields of spec:
[]            automatic guess how to display the control
'logical'     check box
'multcheck [n]' array of n check boxes
{'multcheck|multlist' 'str1' 'str2' ...}
              array of n check boxes or list display - specify the
              name of each box/list entry
{'str1' 'str2' ...}
              popup menu with specified string values
{['list|radio|button'] 'str1','str2',...}
              specification of the type of display [default: list]
              for a choice between string values
              if one option is the empty string and style is 'radio'
              or 'button', this option will correspond to no button
              pressed
'char [n [nlin]]'
              input for string, if n is specified, sets the minimal
              length of the input in number of characters, otherwise,
              minimal length is set according to the value in s
              if nlin is specified, control occupies nlin lines
              instead of 1
'double [n]'  input for numerical array
'single [n]'  input for numerical array
'slider min max [step] [format]'
              slider, specify min, max, step (optional) and format of the
              string representation (optional)
'logslider min max [step] [format]'
              logarithmic scale slider (min and max should be the log of
              the effective min and max)
'loglogslider min max [step] [format]'
              logarithmic scale slider, with possibility to select
              also a negative number
'stepper [n [min [max [step [format]]]]]'
              input for n double
              if n>1, it is possible to define n values for min, max,
              step, separated by commas, for example: 0,-Inf,-1
'clip'        input for 2-elements vector (usually, min and max);
              move the mouse in the control area to change the value
'color'       a small color table to select most-common color and
              grayscale values
'xdouble, xsingle, xchar [n], x[log[log]]slider min max [..],
xstepper, xclip, xcolor'
              additional display of a check box: value will be empty
              if the box is not checked
              it is possible to specify a starting value inside
              brackets at the end of the flag, for example:
              'xchar 12 [yes we can]' (here the brackets do not mean
              that this starting value is optional, but they must
              appear in the string)
'file|dir'    button for selecting file name / directory name
Special specifications in spec:
'label'       field name will be displayed (usually labels a new
              section) but does not correspond to any data
'struct' or full specification sub-structure
              button to edit the sub-structure
'hide'        value is not displayed
'readonly [n]'
              read-only display of value as a string
{'push' 'str1','str2',...}
              create array of push buttons that will cause an action
              to be launched
              in this case callback fun will be called with action
              string as an argument (instead of structure s)
One might want to display small sentences rather than simple names
when prompting user. For this, the following syntaxes are allowed:
- the sequence '__' in the field names will be replace by a space in
  the display
- alternatively, spec can be a 2-elements structure (or s a
  3-elements structures), the second element containing the long-name
  version for each field.
See also fn_structedit, fn_input, fn_propcontrol

Source

Thomas Deneux

Copyright 2007-2017