
Icon Editor
12-43
Background Color. The default component background color is the standard
system background color on which the GUI is running. This color varies on
different computer systems, e.g., the standard shade of gray on the PC differs
from that on UNIX, and may not match the default GUI background color.
The
prepareLayout function sets the background color of the GUI to be the
same as the default component background color. This provides a consistent
look within the GUI, as well as with other application GUIs.
It first retrieves the default component background color from the root object.
Then sets the GUI background color using the figure’s
Color property.
defaultColor = get(0,'defaultuicontrolbackgroundcolor');
if isa(handle(topContainer),'figure')
...
% Make figure color match that of GUI objects
set(topContainer, 'Color',defaultColor);
end
Selecting Units.
The prepareLayout function decides what units to use based on
the GUI’s resizability. It uses
strcmpi to determine the value of the GUI’s
Resize property. Depending on the outcome, it sets the
Units properties of all
the objects to either
Normalized or Characters.
% Make the GUI run properly across multiple platforms by using
% the proper units
if strcmpi(get(topContainer, 'Resize'),'on')
set(allObjects(isprop(allObjects,'Units')),...
'Units','Normalized');
else
set(allObjects(isprop(allObjects,'Units')),...
'Units','Characters');
end
For a resizable figure, normalized units map the lower-left corner of the figure
and of each component to (0,0) and the upper-right corner to (1.0,1.0). Because
of this, component size is automatically adjusted to its parent’s size when the
GUI is displayed.
For a nonresizable figure, character units automatically adjusts the size and
relative spacing of components as the GUI displays on different computers.
Comentarios a estos manuales