1 | <html xmlns:saxon="http://icl.com/saxon"> |
---|
2 | <head> |
---|
3 | <link rel="stylesheet" type="text/css" href="doc.css"/> |
---|
4 | <link rel="stylesheet" type="text/css" href=""/> |
---|
5 | <meta author="The MathWorks Ltd."/> |
---|
6 | <meta copyright="2011 The MathWorks Ltd."/> |
---|
7 | <title>Using layouts inside GUIDE GUIs</title> |
---|
8 | </head> |
---|
9 | |
---|
10 | |
---|
11 | <body> |
---|
12 | <table class="header" width="100%" border="0" cellspacing="0" cellpadding="0"> |
---|
13 | <tr> |
---|
14 | <td bgcolor="#e4f0f8"><A href="User guide.html"><font face="Arial" bgcolor="#e4f0f8" size="+0" underline="0" color="#000000"><b>User guide</b></font></A></td> |
---|
15 | <td width="36" bgcolor="#e4f0f8"><A HREF="User guide5_3.html"><IMG SRC="Images/leftarrow.png" BORDER="0" ALT="previous page"/></A><A HREF="User guide7.html"><IMG SRC="Images/rightarrow.png" BORDER="0" ALT="next page"/></A></td> |
---|
16 | </tr> |
---|
17 | </table> |
---|
18 | |
---|
19 | |
---|
20 | <h2>6: Using layouts inside GUIDE GUIs <A href="User guide.html"><img src="Images/uparrow.png" border="0" align="top" alt="Go back up one level"/></A></h2> |
---|
21 | |
---|
22 | |
---|
23 | <p>Whilst the layouts in this toolbox do not integrate into the |
---|
24 | MATLAB Graphical User Interface Design Environment (<a href="matlab:doc GUIDE"><code class="FUNCTION">GUIDE</code></a>), it |
---|
25 | is possible to insert layouts into a GUIDE-built GUI as follows:</p> |
---|
26 | <h4>Create the GUIDE GUI</h4> |
---|
27 | <p>Create you GUIDE application as usual, placing a panel where you |
---|
28 | want to insert the layout. You can turn the panel border and title |
---|
29 | off if you do not want them.</p> |
---|
30 | <center><img src="Images/guide1.png"/></center> |
---|
31 | |
---|
32 | <h4>Insert the layout</h4> |
---|
33 | <p>Edit the "OpeningFcn" in the GUIDE-created code and insert your |
---|
34 | layout into the panel, making it fill the space. In the example below |
---|
35 | four boxpanels are inserted into a grid, which itself is placed inside |
---|
36 | <code>uipanel1</code>:</p> |
---|
37 | <example> |
---|
38 | <pre style="background-color: #eeeeff; margin-left: 20px; margin-right: 20px"><font color="#000011"><code class="COMMENT">% --- Executes just before guideApp is made visible.</code> |
---|
39 | <a href="matlab:doc function"><code class="FUNCTION">function</code></a> guideApp_OpeningFcn(hObject, eventdata, handles, varargin) |
---|
40 | |
---|
41 | <code class="COMMENT">% Choose default command line output for guideApp</code> |
---|
42 | handles.output = hObject; |
---|
43 | |
---|
44 | <code class="COMMENT">% Update handles structure</code> |
---|
45 | guidata(hObject, handles); |
---|
46 | |
---|
47 | <code class="COMMENT">% Put a layout in the panel</code> |
---|
48 | g = <a href="uiextras.GridFlex.html"><code class="FUNCTION">uiextras.GridFlex</code></a>( <code class="STRING">'Parent'</code>, handles.uipanel1, ... |
---|
49 | <code class="STRING">'Units'</code>, <code class="STRING">'Normalized'</code>, <code class="STRING">'Position'</code>, [0 0 1 1], ... |
---|
50 | <code class="STRING">'Spacing'</code>, 5 ); |
---|
51 | <a href="uiextras.BoxPanel.html"><code class="FUNCTION">uiextras.BoxPanel</code></a>( <code class="STRING">'Parent'</code>, g, <code class="STRING">'Title'</code>, <code class="STRING">'Panel 1'</code> ); |
---|
52 | <a href="uiextras.BoxPanel.html"><code class="FUNCTION">uiextras.BoxPanel</code></a>( <code class="STRING">'Parent'</code>, g, <code class="STRING">'Title'</code>, <code class="STRING">'Panel 2'</code> ); |
---|
53 | <a href="uiextras.BoxPanel.html"><code class="FUNCTION">uiextras.BoxPanel</code></a>( <code class="STRING">'Parent'</code>, g, <code class="STRING">'Title'</code>, <code class="STRING">'Panel 3'</code> ); |
---|
54 | <a href="uiextras.BoxPanel.html"><code class="FUNCTION">uiextras.BoxPanel</code></a>( <code class="STRING">'Parent'</code>, g, <code class="STRING">'Title'</code>, <code class="STRING">'Panel 4'</code> ); |
---|
55 | g.RowSizes = [-1 -1];</font></pre> |
---|
56 | <p style="background-color: #ddddee; margin-left: 20px; margin-right: 20px"><font color="#000022"><center><img src="Images/guide2.png"/></center></font></p> |
---|
57 | </example> |
---|
58 | <p><small>(Full source code for this application is available here: |
---|
59 | [ <a href="Examples/guideApp.m">view</a> |
---|
60 | | <a href="matlab: edit(fullfile(layoutRoot,'layoutHelp','Examples','guideApp.m'))">edit</a> |
---|
61 | | <a href="matlab: p=pwd();cd(fullfile(layoutRoot,'layoutHelp','Examples')); guideApp; cd(p)">run</a> ] |
---|
62 | )</small></p> |
---|
63 | |
---|
64 | |
---|
65 | |
---|
66 | <br clear="ALL"/> |
---|
67 | <table class="footer" width="100%" border="0" cellspacing="0" cellpadding="0"> |
---|
68 | <tr> |
---|
69 | <td width="18" height="15" bgcolor="#e4f0f8" align="left"><a href="User guide5_3.html"><img src="images/leftarrow.png" border="0" alt="previous page"/></a></td> |
---|
70 | <td width="40%" height="15" bgcolor="#e4f0f8" align="left"><a href="User guide5_3.html"><font face="arial" bgcolor="#e4f0f8" size="normal" underline="0" color="#000000">Dock and undock</font></a></td> |
---|
71 | <td width="20%" height="15" bgcolor="#e4f0f8" align="center"><a href="index.html"><font face="arial" bgcolor="#e4f0f8" size="normal" underline="0" color="#000000">[Top]</font></a></td> |
---|
72 | <td width="40%" height="15" bgcolor="#e4f0f8" align="right"><a href="User guide7.html"><font face="arial" bgcolor="#e4f0f8" size="normal" underline="0" color="#000000">Deploying GUIs using the MATLAB Compiler</font></a></td> |
---|
73 | <td width="18" height="15" bgcolor="#e4f0f8" align="right"><a href="User guide7.html"><img src="images/rightarrow.png" border="0" alt="next page"/></a></td> |
---|
74 | </tr> |
---|
75 | </table> |
---|
76 | <font face="Arial" bgcolor="#e4f0f8" size="normal" underline="0" color="#000000">© 2011 The MathWorks Ltd</font> |
---|
77 | <TT>• </TT><a href="matlab: helpview([matlabroot,'/license.txt'])">Terms of Use</a> |
---|
78 | <TT>• </TT><a href="matlab: helpview([matlabroot,'/patents.txt'])">Patents</a> |
---|
79 | <TT>• </TT><a href="matlab: helpview([matlabroot,'/trademarks.txt'])">Trademarks</a> |
---|
80 | |
---|
81 | </body> |
---|
82 | </html> |
---|
83 | |
---|
84 | |
---|