MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Instrukcja Użytkownika Strona 320

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 330
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 319
12 Examples of GUIs Created Programmatically
12-42
% different platforms
prepareLayout(hMainFigure);
prepareLayout
first 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
prepareLayout as the input argument
topContainer.
allObjects = findall(topContainer);
prepareLayout then sets the HandleVisibility properties of all those objects
that have one to
Callback.
% Make GUI objects available to callbacks so that they cannot
% be changed accidentally by other MATLAB commands
set(allObjects(isprop(allObjects,'HandleVisibility')),...
'HandleVisibility','Callback');
Setting HandleVisibility to Callback causes the GUI handles to be visible
from within callback routines or functions invoked by callback routines, but not
from within functions invoked from the command line. This ensures that
command-line users cannot inadvertently alter the GUI when it is the current
figure.
Running a GUI on Multiple Platforms
The prepareLayout utility function sets various properties of all the GUI
components to enable the GUI to retain the correct look and feel on multiple
platforms. The iconEditor calls
prepareLayout with the handle of the main
figure, in the initialization section of the M-file.
% Make changes needed for proper look and feel and running on
% different platforms
prepareLayout(hMainFigure);
First, prepareLayout uses findall to retrieve the handles of all objects
contained in the figure. The list of retrieved handles also 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);
Przeglądanie stron 319
1 2 ... 315 316 317 318 319 320 321 322 323 324 325 ... 329 330

Komentarze do niniejszej Instrukcji

Brak uwag