User`s guide
12 Code a Programmatic GUI
Examples
If you are readin
g this in the MATLAB Help Browser, use the following links
to view the compl
ete code files for th e se initialization examples in the Editor:
• Color Palette
• Icon Editor
Declare Variables for Input and Output Arguments
These are typ
ical declarations for input and output arguments. They are
taken from ex
ample “Icon Editor” on page 15-63.
mInputArgs = varargin; % Comma nd line arguments w hen invoking
%theGUI
mOutputArgs = {}; % Variable for storing output when GUI
% returns
See the va
rargin
reference page and the Icon E ditor file for more information.
Define Custom Property/Value Pairs
The exam
ple “Icon Editor” on page 15-63 defines property value pairs to be
used as i
nput arguments.
The exa
mple defines the properties in a cell array,
mPropertyDefs,andthen
initia
lizes the properties.
mPropertyDefs = {...
'iconwidth', @localValidateInput, 'mIconWidth';
'iconheight', @localValid ateInput, 'mIconHeight';
'iconfile', @localValidateInput, 'mIconFile'};
mIconWidth = 16; % Use input property 'ic onwidth' to initialize
mIconHeight = 16; % Use input property 'ic onheight' to initialize
mIconFile = fullfile(matlabroot,'toolbox/matlab/icons/');
% Use input property 'iconfile' to initialize
Eac
h row of the cell array defines one property. It specifie s, in order, the
nam
e of the property, the routine that is called to validate the input, and the
na
me of the variable that holds the property value.
12-4