|
Hello Yari,
first of all i have to take some time to congratulate and thank you to/for your great work on your website. I know it since a couple of weeks and as far as i think it is the most useful page in the web dealing with matlab and matlab code and real problems trying to get some great solutions and workarounds instead of handling all the basic stuff like many other sites do. ( For those problems its seems to be better getting known of the great MATLAB Help Documentation - in my opinion one of the greatest Documentation of commercial developing tools ). Enough! :)
You are right, i could decide working with the uitabgroup and uitab commands.
But please consider the following code snippet:
___________________________________________________________________
function easyTab()
handles.form1 = [];
handles.toolbar1 = [];
handles.toolbutton1 = [];
handles.tabgroup1 = [];
handles.tabs = zeros(1,21);
handles.panels = zeros(1,21);
handles.form1 = figure('name','easyTab','toolbar','none',...
'menubar','none','NumberTitle','off');
handles.toolbar1 = uitoolbar('parent',handles.form1);
handles.toolbutton1 = uipushtool('parent',handles.toolbar1,...
'cdata',rand(16,16,3));
warning off MATLAB:uitabgroup:OldVersion
handles.tabgroup1 = uitabgroup('parent',handles.form1,...
'units','normalized','position',[0 0 1 1]);
handles.tabs(1) = uitab('parent',handles.tabgroup1,'title','Tab 1');
handles.panels(1) = uipanel('parent',handles.tabs(1),...
'units','normalized',...
'position',[0 0 1 1],...
'BackgroundColor','white');
handles.tabs(1,21) = 1; %Number of tabs already added
handles.panels(1,21) = 1; %Number of panels already added
%Not necessary at all ( always add a panel on a
%tab -> number of panels = number of tabs )
guidata(handles.form1,handles);
set(handles.toolbutton1,'ClickedCallback',{@ClickedCallback_toolbutton1,handles});
%--------------------------------------------------------------------------
function ClickedCallback_toolbutton1(hObject, eventdata, handles)
%This function creates every time toolbutton1 is pressed a new tab with
%panel until the max number of tabs/panels ( 20 ) has been reached!
handles = guidata(handles.form1);
tabcount = handles.tabs(1,21);
tabcount_max = 20;
if tabcount >= tabcount_max, return;end
startTime = tic;
handles.tabs(1,tabcount+1) = uitab('parent',handles.tabgroup1,...
'title',['Tab ' num2str(tabcount+1)]);
handles.panels(1,tabcount+1) = uipanel('parent',handles.tabs(1,tabcount+1),...
'units','normalized',...
'position',[0 0 1 1],...
'BackgroundColor','white');
handles.tabs(1,21) = tabcount + 1;
handles.panels(1,21) = tabcount + 1;
guidata(handles.form1, handles);
elapsedTime = toc(startTime);
set(handles.form1,'name',['easyTab | time elapsed adding new tab: '...
num2str(elapsedTime) ' s']);
___________________________________________________________________
When running the code adding some new tabs by clicking the toolbutton the figure appears very very slowely to be updated.
Even more in deployed applications by using the >>mcc -m easyTab
command.
If anyone has the time and passion to run the code or even more to run the deployable application outside Matlab i would be very very happy.
Thx
|