Skip to content

Commit f86cace

Browse files
authored
Merge pull request #4 from Dev-iL/feature-uitable-support
Expanded public API, uitable demo, additional functionality.
2 parents 16eeeaa + 80a77bf commit f86cace

File tree

5 files changed

+658
-164
lines changed

5 files changed

+658
-164
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ slprj/
1919
*.mlapp
2020

2121
# MATLAB figure files
22-
*.fig
22+
*.fig
23+
24+
# Custom filters
25+
TMP*.m

Demo/TableDemo.m

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
classdef TableDemo < matlab.apps.AppBase
2+
3+
% Properties that correspond to app components
4+
properties (Access = public)
5+
UIFigure matlab.ui.Figure
6+
UITable matlab.ui.control.Table
7+
Button matlab.ui.control.Button
8+
end
9+
10+
methods (Access = private)
11+
12+
% Button pushed function: Button
13+
function ButtonPushed(app, ~)
14+
% Return all registered widgets:
15+
[~,w] = mlapptools.getWidgetList(app.UIFigure);
16+
% Filter list:
17+
w = w(~cellfun(@isempty,w.id) & ...
18+
cellfun(@(x)~isempty(strfind(x,'uniq')),w.id),:); %#ok<STREMP>
19+
% Apply random styles:
20+
for ind1 = 1:4:size(w,1)
21+
mlapptools.setStyle(...
22+
app.UIFigure,...
23+
'border',...
24+
'2px solid red',...
25+
w{ind1,'id'}{1});
26+
end
27+
28+
for ind2 = 2:4:size(w,1)
29+
mlapptools.setStyle(...
30+
app.UIFigure,...
31+
'background-image',...
32+
'url(http://lorempixel.com/40/120/)',...
33+
w{ind2,'id'}{1});
34+
end
35+
36+
for ind3 = 3:4:size(w,1)
37+
mlapptools.setStyle(...
38+
app.UIFigure,...
39+
'background-color',...
40+
['rgb(' num2str(randi(255)) ',' num2str(randi(255)) ',' ...
41+
num2str(randi(255)) +')'],...
42+
w{ind3,'id'}{1});
43+
end
44+
45+
for ind4 = 4:4:size(w,1)
46+
mlapptools.setStyle(...
47+
app.UIFigure,...
48+
'padding',...
49+
'0cm 1cm 0cm 0cm',...
50+
w{ind4,'id'}{1});
51+
end
52+
53+
end
54+
end
55+
56+
% App initialization and construction
57+
methods (Access = private)
58+
59+
% Create UIFigure and components
60+
function createComponents(app)
61+
62+
% Create UIFigure
63+
app.UIFigure = uifigure;
64+
app.UIFigure.Position = [600 600 300 150];
65+
app.UIFigure.Name = 'UI Figure';
66+
setAutoResize(app, app.UIFigure, true)
67+
68+
% Create UITable
69+
app.UITable = uitable(app.UIFigure);
70+
app.UITable.ColumnName = {'Column 1'; 'Column 2'; 'Column 3'};
71+
app.UITable.Data = rand(3);
72+
app.UITable.RowName = {};
73+
app.UITable.Position = [25 40 250 100];
74+
75+
% Create Button
76+
app.Button = uibutton(app.UIFigure, 'push');
77+
app.Button.ButtonPushedFcn = createCallbackFcn(app, @ButtonPushed, true);
78+
app.Button.Position = [90 10 120 25];
79+
app.Button.Text = 'Modify!';
80+
end
81+
end
82+
83+
methods (Access = public)
84+
85+
% Construct app
86+
function app = TableDemo()
87+
88+
% Create and configure components
89+
createComponents(app)
90+
91+
% Register the app with App Designer
92+
registerApp(app, app.UIFigure)
93+
94+
if nargout == 0
95+
clear app
96+
end
97+
end
98+
99+
% Code that executes before app deletion
100+
function delete(app)
101+
102+
% Delete UIFigure when app is deleted
103+
delete(app.UIFigure)
104+
end
105+
end
106+
end

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Code of StackOverflow MATLAB Chat
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)