MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Uživatelský manuál Strana 324

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 330
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 323
12 Examples of GUIs Created Programmatically
12-46
iconEditor calls prepareLayout with the handle of the main figure, in the
initialization section of the M-file.
prepareLayout(hMainFigure);
First, prepareLayout uses findall to retrieve the handles of all objects
contained in the figure. The list of retrieved handles includes the
colorPalette, which is embedded in the iconEditor, and its children. The
figure’s handle is passed to
findall as the input argument topContainer.
function prepareLayout(topContainer)
...
allObjects = findall(topContainer);
Then, prepareLayout uses strcmpi to determine if the GUI is resizable.
Depending on the outcome, it sets the
Units properties of all the objects to
either
Normalized or Characters.
if strcmpi(get(topContainer, 'Resize'),'on')
set(allObjects(isprop(allObjects,'Units')),...
'Units','Normalized');
else
set(allObjects(isprop(allObjects,'Units')),...
'Units','Characters');
end
Note The iconEditor is resizable because it accepts the default value, on, of
the figure Resize property.
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,
when the GUI is resized, component size is automatically changed relative its
parent’s size.
Nonresizable Figure. Character units automatically adjusts the size and relative
spacing of components as the GUI displays on different computers.
Character units are defined by characters from the default system font. The
width of a character unit equals the width of the letter
x in the system font. The
Zobrazit stránku 323

Komentáře k této Příručce

Žádné komentáře