MATLAB Creating Graphical User Interfaces

(Barry) #1
GUIDE Options

Resize Behavior


You can control whether users can resize the window and how MATLAB handles
resizing. GUIDE provides three options:



  • Non-resizable — Users cannot change the window size (default).

  • Proportional — The software automatically scales the components in the UI in
    proportion to the new figure window size.

  • Other (Use SizeChangedFcn) — Program the UI to behave in a certain way when
    users resize the figure window.


The first two options set figure and component properties appropriately and require no
other action. Other (Use SizeChangedFcn) requires you to write a callback routine
that recalculates sizes and positions of the components based on the new figure size. For
a discussion and examples of using a SizeChangedFcn, see the GUIDE examples “Panel”
on page 8-20 and “UI That Uses Persistent Data” on page 9-7.


Command-Line Accessibility


You can restrict access to a figure window from the command line or from a code file with
the GUIDE Command-line accessibility options.


Unless you explicitly specify a figure handle, many commands, such as plot, alter the
current figure (the figure specified by the root CurrentFigure property and returned by
the gcf command). The current figure is usually the figure that is most recently created,
drawn into, or mouse-clicked. You can programmatically designate a figure h (where h is
its handle) as the current figure in four ways:


1 set(groot,'CurrentFigure',h) — Makes figure h current, but does not change
its visibility or stacking with respect to other figures


2 figure(h) — Makes figure h current, visible, and displayed on top of other figures


3 axes(h) — Makes existing axes h the current axes and displays the figure
containing it on top of other figures


4 plot(h,...), or any plotting function that takes an axes as its first argument, also
makes existing axes h the current axes and displays the figure containing it on top of
other figures


The gcf function returns the handle of the current figure.

Free download pdf