Matlab GUI
Matlab GUI
http://UndocumentedMatlab.com/files/OpenDay.zip
Yair Altman www.UndocumentedMatlab.com 1
Yair Altman
www.UndocumentedMatlab.com
Yair Altman
www.UndocumentedMatlab.com
Available uicontrols
Push-button Slider (scrollbar) Radio button Checkbox Editbox Text label Popup menu (combobox, drop-down) Listbox
Yair Altman
Toggle button Uitable (R2008a+) Plot axes Panel Button group ActiveX control
www.UndocumentedMatlab.com
Using HTML
All Matlab GUI is based on Java Swing
o Java Swing supports HTML labels + extensive CSS subset
Combo-box
uicontrol('Style','popup', 'Position',[10,10,150,100], 'String', ... {'<HTML><BODY bgcolor="green">green background</BODY></HTML>', ... '<HTML><FONT color="red" size="+2">Large red font</FONT></HTML>', ... '<HTML><BODY bgcolor="#FF00FF"><PRE>fixed-width font'});
Yair Altman
www.UndocumentedMatlab.com
Yair Altman
www.UndocumentedMatlab.com
>> iconsFolder = fullfile(matlabroot,'/toolbox/matlab/icons/'); >> iconUrl = strrep(['file:/' iconsFolder 'matlabicon.gif'],'\','/'); >> str = ['<Html><img src="' iconUrl '">']
str = <Html><img src="file:/C:/Program Files/MATLAB/.../icons/matlabicon.gif">
Yair Altman
www.UndocumentedMatlab.com
filePath = 'C:\Yair\Undocumented Matlab\Images\family.jpg'; filePath = strrep(['file:/' filePath],'\','/'); str = ['<html><center><img src="' filePath '"><br>' ... '<b><font color="blue">' filePath]; set(hButton,'tooltipString',str);
Yair Altman
www.UndocumentedMatlab.com
10
Hidden properties
Most Matlab graphics components (GUI, plots, ) have hidden unsupported/undocumented properties These properties behave exactly like regular properties, except that they are not displayed by default in get/set To display these properties:
o set(0,'HideUndocumented','off'); % default='on' o HideUndocumented is itself a hidden property o Or use the FEX: getundoc utility (32934)
Hidden properties are unsupported and may be removed in any future Matlab release without prior notice
Yair Altman www.UndocumentedMatlab.com 11
www.mathworks.com/matlabcentral/fileexchange/20979-Myaa
Yair Altman
www.UndocumentedMatlab.com
12
Yair Altman
www.UndocumentedMatlab.com
13
Yair Altman
www.UndocumentedMatlab.com
14
HTML support
>> data{2,2} = '<html><b><i><font color="red" size=+1>big red' data = [6.125] [ 456.3457] [1] [ 6.75] '<html><b><i><font color="red" size=+1>big red' [0] [ 7] [ 658.2] [0] >> set(h,'Data',data)
Yair Altman
www.UndocumentedMatlab.com
15
Yair Altman
www.UndocumentedMatlab.com
16
Yair Altman
www.UndocumentedMatlab.com
17
The standard Matlab slider uicontrol is actually a scrollbar with Windows-95 look-and-feel:
jScrollbar = javaObjectEDT(javax.swing.JScrollBar); jScrollbar.setOrientation(jScrollbar.HORIZONTAL); javacomponent(jScrollbar,[10,40,200,20]); uicontrol('style','slider', 'position',[10,10,200,20]);
JScrollBar uicontrol('slider')
Yair Altman
www.UndocumentedMatlab.com
20
Yair Altman
www.UndocumentedMatlab.com
21
Color-selection combo-boxes
com.mathworks.mlwidgets.graphics.ColorPicker:
com.jidesoft.combobox.ColorComboBox:
com.mathworks.mwswing.MJColorComboBox (R2010a-):
Yair Altman
www.UndocumentedMatlab.com
22
DateChooserPanel
MonthChooserPanel CalendarViewer
DateComboBox
Yair Altman
DateSpinnerComboBox
www.UndocumentedMatlab.com
MonthComboBox
23
Yair Altman
www.UndocumentedMatlab.com
24
Yair Altman
www.UndocumentedMatlab.com
25
Yair Altman
www.UndocumentedMatlab.com
26
Yair Altman
www.UndocumentedMatlab.com
27
Conclusion
Standard Matlab GUI is easy to set-up but limited However, extremely easy to customize & extend Multiple undocumented properties, functions enable nice customizations, even without Java Entire power of Java is also directly available, and can be combined with regular Matlab GUI Matlab GUI is limited by our design imagination more than by actual technical limitations
Yair Altman www.UndocumentedMatlab.com 28