Code covered by the BSD License  

Highlights from
GridLayout

image thumbnail

GridLayout

by

 

20 Nov 2010 (Updated )

An intuitive and flexible layout manager

GridLayoutDemo6()
% Nested layouts
function GridLayoutDemo6()

Parent = figure( ...
    'MenuBar', 'none', ...
    'NumberTitle', 'off', ...
    'Name', 'GridLayout: nested layouts');

NumPanels = 2;

MainLayout = GridLayout(Parent, ...
    'NumRows', NumPanels, ...
    'NumCols', 1, ...
    'RowHeight', 150, ...
    'ColWidth', '*', ...
    'Gap', 5, ...
    'Margin', 10, ...
    'CellMargin', 5, ...
    'CellColor', 'y', ...
    'CellHAlign', 'Stretch');

for i = 1:NumPanels
    Panel = uipanel( ...
        'Parent', MainLayout.Cell(i,1), ...
        'Title', sprintf('Panel %d',i), ...
        'Units', 'pixels', ...
        'Position', [0 0 200 1]);
    Layout = GridLayout(Panel, ...
        'NumRows', 2, ...
        'NumCols', 2, ...
        'ColWidth', {100, '*'}, ...
        'RowHeight', 40, ...
        'Gap', 4, ...
        'CellColor', 'y', ...
        'CellHAlign', 'Stretch', ...
        'CellMargin', 5);
    
    % Adding children
    UIArgs = {'Style','pushbutton', 'String','Click'};
    uicontrol(Layout.Cell(1,1), UIArgs{:});
    uicontrol(Layout.Cell(1,2), UIArgs{:});
    uicontrol(Layout.Cell(2,1), UIArgs{:});
    uicontrol(Layout.Cell(2,2), UIArgs{:});
end

Update(MainLayout);

Contact us