1 | %% A Heirarchy of Layouts Example
|
---|
2 | % This example shows how to use layouts within other layouts to achieve
|
---|
3 | % more complex user interface designs with the right mix of variable and
|
---|
4 | % fixed sized components.
|
---|
5 |
|
---|
6 | %% Open the window
|
---|
7 | % Open a new figure window and remove the toolbar and menus
|
---|
8 | window = figure( 'Name', 'A Layout Heirarchy Example', ...
|
---|
9 | 'MenuBar', 'none', ...
|
---|
10 | 'Toolbar', 'none', ...
|
---|
11 | 'NumberTitle', 'off', ...
|
---|
12 | 'Position', 200*ones(1,4) );
|
---|
13 |
|
---|
14 | %% Create the first layout (vertical box)
|
---|
15 | % Inside this vertical box we place the axes
|
---|
16 | vbox = uiextras.VBox( 'Parent', window );
|
---|
17 | axes( 'Parent', vbox );
|
---|
18 |
|
---|
19 | %% Create the second layout (horizontal box)
|
---|
20 | % Inside this horizontal box we place two buttons
|
---|
21 | hbox = uiextras.HButtonBox( 'Parent', vbox, 'Padding', 5 );
|
---|
22 | uicontrol( 'Parent', hbox, ...
|
---|
23 | 'String', 'Button 1' );
|
---|
24 | uicontrol( 'Parent', hbox, ...
|
---|
25 | 'String', 'Button 2' );
|
---|
26 |
|
---|
27 | %% Set the sizes
|
---|
28 | % We want the axes to grow with the window so set the first size to be -1
|
---|
29 | % (which means variable size with wieght 1) and the buttons to stay fixed
|
---|
30 | % height so set the second size to 35 (fixed height of 35 pixels)
|
---|
31 | set( vbox, 'Sizes', [-1 35] )
|
---|