12.07.2015 Views

MATLAB Function Reference (Volume 2: Graphics)

MATLAB Function Reference (Volume 2: Graphics)

MATLAB Function Reference (Volume 2: Graphics)

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Figure PropertiesResize{on} | offWindow resize mode. This property determines if you can resize the figurewindow with the mouse. on means you can resize the window, off means youcannot. When Resize is off, the figure window does not display any resizingcontrols (such as boxes at the corners) to indicate that it cannot be resized.ResizeFcnstringWindow resize callback routine. <strong>MATLAB</strong> executes the specified callbackroutine whenever you resize the figure window. You can query the figure’sPosition property to determine the new size and position of the figure window.During execution of the callback routine, the handle to the figure being resizedis accessible only through the root CallbackObject property, which you canquery using gcbo.You can use ResizeFcn to maintain a GUI layout that is not directly supportedby <strong>MATLAB</strong>’s Position/Units paradigm.For example, consider a GUI layout that maintains an object at a constantheight in pixels and attached to the top of the figure, but always matches thewidth of the figure. The following ResizeFcn accomplishes this; it keeps theuicontrol whose Tag is 'StatusBar' 20 pixels high, as wide as the figure, andattached to the top of the figure. Note the use of the Tag property to retrieve theuicontrol handle, and the gcbo function to retrieve the figure handle. Also notethe defensive programming regarding figure Units, which the callbackrequires to be in pixels in order to work correctly, but which the callback alsorestores to their previous value afterwards.u = findobj('Tag','StatusBar');fig = gcbo;old_units = get(fig,'Units');set(fig,'Units','pixels');figpos = get(fig,'Position');upos = [0, figpos(4) - 20, figpos(3), 20];set(u,'Position',upos);set(fig,'Units',old_units);You can change the figure Position from within the ResizeFcn callback;however the ResizeFcn is not called again as a result.Note that the print command can cause the ResizeFcn to be called if thePaperPositionMode property is set to manual and you have defined a resize2-185

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!