No BSD License  

Highlights from
Tab and subtabs

image thumbnail
from Tab and subtabs by Micha³ Steuden
Tab with subtabs and deeper

tabandsubtabs(varargin)
function varargout = tabandsubtabs(varargin)
% TABANDSUBTABS M-file for tabandsubtabs.fig
%      TABANDSUBTABS, by itself, creates a new TABANDSUBTABS or raises the existing
%      singleton*.
%
%      H = TABANDSUBTABS returns the handle to a new TABANDSUBTABS or the handle to
%      the existing singleton*.
%
%      TABANDSUBTABS('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in TABANDSUBTABS.M with the given input arguments.
%
%      TABANDSUBTABS('Property','Value',...) creates a new TABANDSUBTABS or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before tabandsubtabs_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to tabandsubtabs_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help tabandsubtabs

% Last Modified by GUIDE v2.5 06-Mar-2006 17:52:17

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @tabandsubtabs_OpeningFcn, ...
                   'gui_OutputFcn',  @tabandsubtabs_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin & isstr(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before tabandsubtabs is made visible.
function tabandsubtabs_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to tabandsubtabs (see VARARGIN)


% Choose default command line output for tabandsubtabs
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes tabandsubtabs wait for user response (see UIRESUME)
 %uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = tabandsubtabs_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


hideorshowcontrols([1 2],'off');

% --- Executes on button press in togglebutton1.
function togglebutton1_Callback(hObject, eventdata, handles)
% hObject    handle to togglebutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of togglebutton1
 hideorshowcontrols([10 93],'on');
 hideorshowcontrols(2,'off');

% --- Executes on button press in togglebutton2.
function togglebutton2_Callback(hObject, eventdata, handles)
% hObject    handle to togglebutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of togglebutton2
 hideorshowcontrols(2,'on');
 hideorshowcontrols(1,'off');

% --- Executes on button press in togglebutton4.
function togglebutton4_Callback(hObject, eventdata, handles)
% hObject    handle to togglebutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of togglebutton4
 hideorshowcontrols([91 92 1 2],'off');
 hideorshowcontrols(94,'on');

% --- Executes on button press in togglebutton5.
function togglebutton5_Callback(hObject, eventdata, handles)
% hObject    handle to togglebutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of togglebutton5


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 hideorshowcontrols(11,'on');
 

% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
hideorshowcontrols(12,'on');

% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu1
Menu =get(hObject, 'Value');
if Menu<=1
   hideorshowcontrols(13,'off'); 
else
   hideorshowcontrols(13,'on'); 
end



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                   author-Micha Steuden                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function hideorshowcontrols(value,turn);
%This function turns on or turns off controls with the specified
%value in the 'UserData'.
%Place his function in your figure.m and insert the numbers in 
%uicontrols section ('Userdata') which will indicate connections
%between tabs. Click on uicontrol>>Property Inspector>>Userdata>>number
%EXAMPLE:
%to turn off desired controls with the 'UserData'=[22; 213 ;25 ;214; 217; 2]
%turn off all uicontrols with '2' :        hideorshowcontrols(2,'off');  
%turn off all uicontrols with '21':        hideorshowcontrols(21,'off');
%turn off only uicontrol '213'    :        hideorshowcontrols(213,'off');
%turn on only '2'                 :        hideorshowcontrols(20,'on');
%turn on all except '22' and '2'  :        hideorshowcontrols([21 25],'on');
    
    
    controlfind=findall(gcf,'Type','uicontrol');
    controluserdata=get(controlfind,'Userdata');
    for r=1:length(controluserdata)
        if ~isempty(controluserdata{r})
            controluserdatatodouble(r,1)=controluserdata{r};
        else
            controluserdatatodouble(r,1)=NaN;
        end
    end
    controlfound=controlfind(istherethisvalue(value,controluserdatatodouble));
    set(controlfound,'Visible',turn);

%find values (designed up to vectors)
function logicval=istherethisvalue(value,where)
for r=1:length(value)
    magnitudediff=whatmagnitude(where)/whatmagnitude(value(r));
    where=fix(where./magnitudediff);
    logicval(:,r)=(value(r)==where);
end
if ~(r==1) logicval=(any(logicval'))'; end;

%return the  digit magnification of 10 
function numbermagnitude=whatmagnitude(value)
    value=abs(value);
    tens=ones(length(value),1)*10;
    value(value==0)=NaN;
    numbermagnitude=tens.^(fix(log10(value)));



% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 hideorshowcontrols([91 92],'on');
 hideorshowcontrols([93 94],'off');

Contact us at files@mathworks.com