This is a layout manager for axes and controls in a MATLAB figure, designed for graphical user interfaces in which, during resizing of the figure, some controls (e.g. buttons) are to remain the same size while others (e.g. axes, text fields, list boxes) are to change size.
To achieve this, the figure is split into a grid with a border and with spacing between each cell. Some rows and columns (at least one of each) are variable in size and the rest are fixed. When the figure is resized, the available space (i.e. that not required by the fixed-size rows and columns) is distributed among the variable-sized ones according to a specified ratio. If there is not enough space for the fixed-size rows or columns, these (and the spacing between them) will be made smaller too.
Controls can be merged across multiple rows and/or columns and can overlap (making it possible to put a frame round other controls).
Example code is provided. The basic sequence is:
* Create figure (using the supplied function "resizable_figure")
* Create controls (axes, uicontrols, ActiveX controls, java components)
* Create an "elements" cell-matrix to specify top-right positions for controls.
* Create a "mergeblocks" matrix giving sizes for components which span more than one cell in the grid
* Specify row and column sizes (positive sizes are specify fixed sizes in pixels, negative ones give the ratios for resizable rows and columns)
* Set the initial size for the figure and show it
The code has been tested with MATLAB 6.1 (R12.1) through MATLAB 7.1 (R14sp3).
I hacked a solution that may be of use for others:
The offending command looks for the matlab version to see if it is 7 or greater so it can use active-X. However, in the run-time compiled environment no version number is returned from the "ver" command. So my hack is to edit the "resize.m" file inside the "@resizable_layout" folder. At the very bottom I changed the function "i_ismatlab7" such that
s = ver('matlab');
v = s.Version;
%s = ver('matlab');
%v = s.Version;
with comments noting the hack, of course. This forces version 7 (which is ok with the compiler I'm working with).
All works great -
This is an excellent and very usable package for resizable windows in Matlab. I only have one problem with it, and it only seems to pop up since I upgraded to Matlab 7.4.0 and I try executing a compiled application that uses it. Regardless of PC or mac platforms, using the runtime environment I get the error below. Any insight would be mightily appreciated, as I'd hate to have to take remove this great package.
[BS:~/Desktop/Downloads/resizable_figures Folder] bsanii% ./resize_example2??? Too many outputs requested. Most likely cause is missing  aroundleft hand side that has a comma separated list expansion.Error in ==> resizable_layout.resize>i_ismatlab7 at 142
Error in ==> resizable_layout.resize>i_isactivex at 157
Error in ==> resizable_layout.resize at 49
Error in ==> resizable_layout.setelements at 38
Error in ==> resize_example2 at 18
Warning: 1 invisible figure(s) exist at MCR termination.
If your application has terminated unexpectedly, please note that
applications generated by the MATLAB Compiler terminate when there are no
visible figure windows. See the documentation for WaitForFiguresToDie and
WAITFORCALLBACKS for more information.
Warning: The following classes still have existing instances that cannot be cleared:
resizable_layout (1 instance)
Added copyright statements, and eliminated the need for a P-coded file.