Skip to content

Basic uitable support #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Nov 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ slprj/
*.mlapp

# MATLAB figure files
*.fig
*.fig

# Custom filters
TMP*.m
106 changes: 106 additions & 0 deletions Demo/TableDemo.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
classdef TableDemo < matlab.apps.AppBase

% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
UITable matlab.ui.control.Table
Button matlab.ui.control.Button
end

methods (Access = private)

% Button pushed function: Button
function ButtonPushed(app, ~)
% Return all registered widgets:
[~,w] = mlapptools.getWidgetList(app.UIFigure);
% Filter list:
w = w(~cellfun(@isempty,w.id) & ...
cellfun(@(x)~isempty(strfind(x,'uniq')),w.id),:); %#ok<STREMP>
% Apply random styles:
for ind1 = 1:4:size(w,1)
mlapptools.setStyle(...
app.UIFigure,...
'border',...
'2px solid red',...
w{ind1,'id'}{1});
end

for ind2 = 2:4:size(w,1)
mlapptools.setStyle(...
app.UIFigure,...
'background-image',...
'url(http://lorempixel.com/40/120/)',...
w{ind2,'id'}{1});
end

for ind3 = 3:4:size(w,1)
mlapptools.setStyle(...
app.UIFigure,...
'background-color',...
['rgb(' num2str(randi(255)) ',' num2str(randi(255)) ',' ...
num2str(randi(255)) +')'],...
w{ind3,'id'}{1});
end

for ind4 = 4:4:size(w,1)
mlapptools.setStyle(...
app.UIFigure,...
'padding',...
'0cm 1cm 0cm 0cm',...
w{ind4,'id'}{1});
end

end
end

% App initialization and construction
methods (Access = private)

% Create UIFigure and components
function createComponents(app)

% Create UIFigure
app.UIFigure = uifigure;
app.UIFigure.Position = [600 600 300 150];
app.UIFigure.Name = 'UI Figure';
setAutoResize(app, app.UIFigure, true)

% Create UITable
app.UITable = uitable(app.UIFigure);
app.UITable.ColumnName = {'Column 1'; 'Column 2'; 'Column 3'};
app.UITable.Data = rand(3);
app.UITable.RowName = {};
app.UITable.Position = [25 40 250 100];

% Create Button
app.Button = uibutton(app.UIFigure, 'push');
app.Button.ButtonPushedFcn = createCallbackFcn(app, @ButtonPushed, true);
app.Button.Position = [90 10 120 25];
app.Button.Text = 'Modify!';
end
end

methods (Access = public)

% Construct app
function app = TableDemo()

% Create and configure components
createComponents(app)

% Register the app with App Designer
registerApp(app, app.UIFigure)

if nargout == 0
clear app
end
end

% Code that executes before app deletion
function delete(app)

% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Code of StackOverflow MATLAB Chat

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading