Table of Contents
Chapter 1: Introduction .................................1
1.1 Why Develop GUIs Using
MATLAB? .................... 2
1.1.1 High-Level Script Based
Development..................................... 2
1.1.2 Seamless Integration
with Existing MATLAB Computational Power 2
1.1.3 Operating System Independent GUI Applications....................
3
1.1.4 User Interactivity and
Real-time Measurements....................... 3
1.2 MATLAB Capabilities For
GUI Development ....... 5
1.2.1 Handle Graphics Objects..........................................................
5
1.2.2 Figures, Axes, and UIControls..................................................
5
1.2.3 GUIDE, Graphical User
Interface Development Environment.. 6
1.2.4 Event Handling: Callback Functions, Timers, and Mouse/Keyboard
Input .........................................................................
7
1.2.5 Global Variables .......................................................................
8
1.2.6 Stand-alone Executable
GUIs .................................................. 8
1.3 Where To Download M-files.................................
8
Chapter 2: Handle Graphics
Programming ...9
2.1 Introduction To Handle Graphics Objects .......... 9
2.1.1 HG Object Hierarchy ................................................................
9
2.1.2 The Root Object .....................................................................
11
2.2 Handle Graphics Objects
and Properties.......... 14
2.2.1 Retrieving and Storing
Properties Using set( ) and get( )....... 14
2.2.2 Common HG Object Properties..............................................
17
2.3 Figure Object Properties
................................... 20
2.3.1 Figure Properties....................................................................
20
2.3.2 Settings ..................................................................................
23
2.3.3 Callback Functions .................................................................
27
2.4 Axes Properties .................................................
30
2.4.1 Axes Object Settings
..............................................................
33
2.4.1.1 Axes Properties For
2D Plot Applications............................... 34
2.4.1.2 Axes Properties For
3D Plot Applications............................... 37
2.4.1.3 Axes Properties For
Imaging Applications.............................. 43
2.4.2 Axes Object Callback
Functions............................................. 50
2.5 Axes Child Object Properties
............................ 50
2.5.1 Core Objects ..........................................................................
50
2.5.1.1 Image Objects .........................................................................
50
2.5.1.2 Light Objects ...........................................................................
52
2.5.1.3 Line Objects ............................................................................
52
2.5.1.4 Patch Objects..........................................................................
54
2.5.1.5 Rectangle Objects...................................................................
57
2.5.1.6 Surface Objects.......................................................................
59
2.5.1.7 Text Objects ............................................................................
61
2.5.2 Plot Objects.............................................................................67
2.5.3 Group Objects .........................................................................69
2.5.4 Annotation Objects..................................................................73
2.6 UI Object Properties..........................................
76
2.6.1 UIControls ...............................................................................77
2.6.1.1 Check Boxes ...........................................................................
83
2.6.1.2 Radio Buttons..........................................................................
84
2.6.1.3 Edit Text Boxes .......................................................................
90
2.6.1.4 Static Text Labels....................................................................
93
2.6.1.5 List Boxes................................................................................
94
2.6.1.6 Push Buttons...........................................................................
99
2.6.1.7 Toggle Buttons ......................................................................
104
2.6.1.8 Sliders ...................................................................................
107
2.6.1.9 Popup Menus ........................................................................
111
2.6.2 UIMenu..................................................................................114
2.6.3 UIContextMenu .....................................................................121
2.6.4 UIButtonGroup ......................................................................127
2.6.5 UIPanel .................................................................................130
2.6.6 UIToolbar, UIPushTool,
and UIToggleTool ...........................132
Chapter 3: MATLAB GUIDE: GUI
Development Environment...........................138
3.1 Introduction To GUIDE,
Graphical User Interface Development Environment .......................................
138
3.1.1 Advantages of Using
GUIDE.................................................139
3.1.2 Getting Started With
GUIDE .................................................140
3.2 GUIDE Options and Setup................................
143
3.2.1 GUI Options ..........................................................................144
3.2.2 Grids and Rulers ...................................................................147
3.2.3 GUI Figure Size.....................................................................147
3.3 Property Inspector and
Object Browser ......... 148
3.3.1 Property Inspector.................................................................148
3.3.2 Object Browser......................................................................149
3.4 Generating Callback Functions.......................
151
3.4.1 Callback Naming Conventions
..............................................151
3.5 Creating User Interface
Menus ....................... 153
3.5.1 Menu Bars.............................................................................154
3.5.2 Context Menus ......................................................................155
VII
3.6 Automatic M-file Code Generation and Structure 158
3.6.1 Auto-generated M-file Structure ...........................................
158
3.6.2 Main Function.......................................................................
158
3.6.3 Main Function Initialization
................................................... 160
3.6.4 Renaming GUI Projects........................................................
161
3.6.5 Removing GUI Objects
and Associated Callback Functions 161
Chapter 4: Structure of MATLAB GUIs......163
4.1 GUI Design Style, Layout, and Program Flow . 163
4.1.1 Defining The GUI..................................................................
163
4.1.2 GUI Design Styles and
Layout ............................................. 164
4.1.3 Program Flow .......................................................................
164
4.1.4 Example of Defining A
GUI: FigView.................................... 165
4.2 Handles Data Structure
Organization ............. 167
4.2.1 Handles Data Structures
...................................................... 167
4.2.2 Initializing GUI Properties
and Variables.............................. 170
4.2.3 Handles and Callback
Function Examples........................... 172
4.2.4 Limitations of Handles
.......................................................... 179
4.3 Event Handling ................................................
180
4.3.1 The Event Queue .................................................................
180
4.3.2 Mouse Events.......................................................................
184
4.3.3 Key Press Events .................................................................
192
4.3.4 Timer Events ........................................................................
198
4.4 Dialog Boxes....................................................
204
4.4.1 MATLAB Built-in Dialog
Boxes............................................. 204
4.4.2 Custom Dialog Boxes...........................................................
216
Chapter 5: Advanced GUI Designs
............227
5.1 Multiple Figure GUIs........................................
227
5.1.1 Global Variables ...................................................................
227
5.1.2 Interactive Multiple
Control GUIs.......................................... 231
5.1.3 EquationAnimator: Multiple
Figure GUI Design Example..... 235
5.2 Real-time GUIs and Animation ........................ 243
5.2.1 Using Timers For Loops
....................................................... 243
5.2.2 Animating HG Objects..........................................................
244
5.2.3 Real-time Controls................................................................
247
5.3 Custom GUI Control Styles..............................
281
5.3.1 Image Mapped Controls,
IMCs............................................. 281
5.3.2 Image Mapped GUI Layouts.................................................
283
5.3.3 IMC Callbacks ......................................................................
283
VIII
5.3.4 Highlighting IMCs Based On Mouse Pointer.........................284
5.4 Creating Stand-Alone Executable
GUIs .......... 295
5.4.1 Requirements and Limitations...............................................295
5.4.2 M-file Only Executable
Generation .......................................296
5.4.3 Command Window................................................................297
5.4.4 Deploying Your GUI Application............................................297
Bibliography ..............................................299
Index..........................................................301