Home > . > prt_text_input.m

prt_text_input

PURPOSE ^

PRT_TEXT_INPUT M-file for prt_text_input.fig

SYNOPSIS ^

function varargout = prt_text_input(varargin)

DESCRIPTION ^

 PRT_TEXT_INPUT M-file for prt_text_input.fig
 
 PRT_TEXT_INPUT, by itself, creates a new PRT_TEXT_INPUT or raises the 
 existing singleton*.

 H = PRT_TEXT_INPUT returns the handle to a new PRT_TEXT_INPUT or the 
 handle to the existing singleton*.

 PRT_TEXT_INPUT('CALLBACK',hObject,eventData,handles,...) calls the local
 function named CALLBACK in PRT_TEXT_INPUT.M with the given input arguments.

 PRT_TEXT_INPUT('Property','Value',...) creates a new PRT_TEXT_INPUT or 
 raises the existing singleton*.  Starting from the left, property value 
 pairs are applied to the GUI before prt_text_input_OpeningFcn gets called.
 An unrecognized property name or invalid value makes property application
 stop.  All inputs are passed to prt_text_input_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
__________________________________________________________________________
 Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = prt_text_input(varargin)
0002 % PRT_TEXT_INPUT M-file for prt_text_input.fig
0003 %
0004 % PRT_TEXT_INPUT, by itself, creates a new PRT_TEXT_INPUT or raises the
0005 % existing singleton*.
0006 %
0007 % H = PRT_TEXT_INPUT returns the handle to a new PRT_TEXT_INPUT or the
0008 % handle to the existing singleton*.
0009 %
0010 % PRT_TEXT_INPUT('CALLBACK',hObject,eventData,handles,...) calls the local
0011 % function named CALLBACK in PRT_TEXT_INPUT.M with the given input arguments.
0012 %
0013 % PRT_TEXT_INPUT('Property','Value',...) creates a new PRT_TEXT_INPUT or
0014 % raises the existing singleton*.  Starting from the left, property value
0015 % pairs are applied to the GUI before prt_text_input_OpeningFcn gets called.
0016 % An unrecognized property name or invalid value makes property application
0017 % stop.  All inputs are passed to prt_text_input_OpeningFcn via varargin.
0018 %
0019 % *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
0020 %  instance to run (singleton)".
0021 %
0022 % See also: GUIDE, GUIDATA, GUIHANDLES
0023 %__________________________________________________________________________
0024 % Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory
0025 
0026 % Written by J.Schrouff
0027 % $Id: prt_text_input.m 523 2012-05-09 11:43:36Z jrichiar $
0028 
0029 % Edit the above text to modify the response to help prt_text_input
0030 
0031 % Last Modified by GUIDE v2.5 24-Aug-2011 15:32:46
0032 
0033 % Begin initialization code - DO NOT EDIT
0034 gui_Singleton = 1;
0035 gui_State = struct('gui_Name',       mfilename, ...
0036                    'gui_Singleton',  gui_Singleton, ...
0037                    'gui_OpeningFcn', @prt_text_input_OpeningFcn, ...
0038                    'gui_OutputFcn',  @prt_text_input_OutputFcn, ...
0039                    'gui_LayoutFcn',  [] , ...
0040                    'gui_Callback',   []);
0041 if nargin && ischar(varargin{1})
0042     gui_State.gui_Callback = str2func(varargin{1});
0043 end
0044 
0045 if nargout
0046     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0047 else
0048     gui_mainfcn(gui_State, varargin{:});
0049 end
0050 % End initialization code - DO NOT EDIT
0051 
0052 
0053 % --- Executes just before prt_text_input is made visible.
0054 function prt_text_input_OpeningFcn(hObject, eventdata, handles, varargin)
0055 % This function has no output args, see OutputFcn.
0056 % hObject    handle to figure
0057 % eventdata  reserved - to be defined in a future version of MATLAB
0058 % handles    structure with handles and user data (see GUIDATA)
0059 % varargin   command line arguments to prt_text_input (see VARARGIN)
0060 
0061 %if window already exists, just put it as the current figure
0062 Tag='text_input';
0063 F = findall(allchild(0),'Flat','Tag',Tag);
0064 if length(F) > 1
0065     % Multiple Graphics windows - close all but most recent
0066     close(F(2:end))
0067     F = F(1);
0068     uistack(F,'top')
0069 elseif length(F)==1
0070     uistack(F,'top')
0071 else
0072     set(handles.figure1,'Tag',Tag)
0073     
0074 %set size of the window, taking screen resolution and platform into account
0075 S0= spm('WinSize','0',1);   %-Screen size (of the current monitor)
0076 if ispc
0077     PF='MS Sans Serif';
0078 else
0079     PF= spm_platform('fonts');     %-Font names (for this platform)
0080     PF=PF.helvetica;
0081 end
0082 tmp  = [S0(3)/1280 (S0(4))/800];
0083 ratio=min(tmp)*[1 1 1 1];
0084 FS = 1 + 0.85*(min(ratio)-1);  %factor to scale the fonts
0085 x=get(handles.figure1,'Position');
0086 set(handles.figure1,'DefaultTextFontSize',FS*12,...
0087     'DefaultUicontrolFontSize',FS*12,...
0088     'DefaultTextFontName',PF,...
0089     'DefaultAxesFontName',PF,...
0090     'DefaultUicontrolFontName',PF)
0091 set(handles.figure1,'Position',ratio.*x)
0092 set(handles.figure1,'Resize','on')
0093 
0094 % Choose the color of the different backgrounds and figure parameters
0095 color=prt_get_defaults('color');
0096 set(handles.figure1,'Color',color.bg1)
0097 aa=get(handles.figure1,'children');
0098 for i=1:length(aa)
0099     if strcmpi(get(aa(i),'type'),'uipanel')
0100         set(aa(i),'BackgroundColor',color.bg2)
0101         bb=get(aa(i),'children');
0102         if ~isempty(bb)
0103             for j=1:length(bb)
0104                 if ~isempty(find(strcmpi(get(bb(j),'Style'),{'text',...
0105                         'radiobutton','checkbox'}))) 
0106                     set(bb(j),'BackgroundColor',color.bg2)
0107                 elseif ~isempty(find(strcmpi(get(bb(j),'Style'),'pushbutton')))
0108                     set(bb(j),'BackgroundColor',color.fr)
0109                 end
0110                 set(bb(j),'FontUnits','pixel')
0111                 xf=get(bb(j),'FontSize');
0112                 set(bb(j),'FontSize',ceil(FS*xf),'FontName',PF,...
0113                     'FontUnits','normalized','Units','normalized')
0114             end
0115         end
0116     elseif strcmpi(get(aa(i),'type'),'uicontrol')
0117         if ~isempty(find(strcmpi(get(aa(i),'Style'),{'text',...
0118                 'radiobutton','checkbox','listbox'})))
0119             set(aa(i),'BackgroundColor',color.bg1)
0120         elseif ~isempty(find(strcmpi(get(aa(i),'Style'),'pushbutton')))
0121             set(aa(i),'BackgroundColor',color.fr)
0122         end
0123     end
0124     set(aa(i),'FontUnits','pixel')
0125     xf=get(aa(i),'FontSize');
0126     if ispc
0127         set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0128             'FontUnits','normalized','Units','normalized')
0129     else
0130         set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0131             'Units','normalized')
0132     end
0133 end
0134 
0135 
0136 % Choose default command line output for prt_text_input
0137 handles.output = hObject;
0138 
0139 % Update handles structure
0140 guidata(hObject, handles);
0141 
0142 if ~isempty(varargin) && strcmpi(varargin{1},'Title')
0143     set(gcf,'Name',varargin{2});
0144     if length(varargin)>3 && strcmpi(varargin{3},'UserData')
0145         set(handles.edit1,'String',varargin{4})
0146         handles.output = get(handles.edit1,'String');
0147     end
0148 end
0149 end
0150 % Update handles structure
0151 guidata(hObject, handles);
0152 
0153 %UIWAIT makes prt_text_input wait for user response (see UIRESUME)
0154 uiwait(handles.figure1);
0155 
0156 
0157 % --- Outputs from this function are returned to the command line.
0158 function varargout = prt_text_input_OutputFcn(hObject, eventdata, handles) 
0159 % varargout  cell array for returning output args (see VARARGOUT);
0160 % hObject    handle to figure
0161 % eventdata  reserved - to be defined in a future version of MATLAB
0162 % handles    structure with handles and user data (see GUIDATA)
0163 
0164 % Get default command line output from handles structure
0165 if isfield(handles,'output') && ~isempty(handles.output)
0166     varargout{1} = handles.output;
0167 else
0168     varargout{1}=[];
0169 end
0170 
0171 % The figure can be deleted now
0172 if isfield(handles,'figure1')
0173     delete(handles.figure1);
0174 end
0175 
0176 
0177 function edit1_Callback(hObject, eventdata, handles)
0178 % hObject    handle to edit1 (see GCBO)
0179 % eventdata  reserved - to be defined in a future version of MATLAB
0180 % handles    structure with handles and user data (see GUIDATA)
0181 
0182 % Hints: get(hObject,'String') returns contents of edit1 as text
0183 %        str2double(get(hObject,'String')) returns contents of edit1 as a double
0184 handles.output = get(hObject,'String');
0185 
0186 % Update handles structure
0187 guidata(hObject, handles);
0188 
0189 
0190 
0191 
0192 % --- Executes during object creation, after setting all properties.
0193 function edit1_CreateFcn(hObject, eventdata, handles)
0194 % hObject    handle to edit1 (see GCBO)
0195 % eventdata  reserved - to be defined in a future version of MATLAB
0196 % handles    empty - handles not created until after all CreateFcns called
0197 
0198 % Hint: edit controls usually have a white background on Windows.
0199 %       See ISPC and COMPUTER.
0200 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0201     set(hObject,'BackgroundColor','white');
0202 end
0203 
0204 
0205 % --- Executes on button press in okbutton.
0206 function okbutton_Callback(hObject, eventdata, handles)
0207 % hObject    handle to okbutton (see GCBO)
0208 % eventdata  reserved - to be defined in a future version of MATLAB
0209 % handles    structure with handles and user data (see GUIDATA)
0210 
0211 % Use UIRESUME instead of delete because the OutputFcn needs
0212 % to get the updated handles structure.
0213 uiresume(handles.figure1);
0214 
0215 % --- Executes on button press in cancelbutton.
0216 function cancelbutton_Callback(hObject, eventdata, handles)
0217 % hObject    handle to cancelbutton (see GCBO)
0218 % eventdata  reserved - to be defined in a future version of MATLAB
0219 % handles    structure with handles and user data (see GUIDATA)
0220 % Use UIRESUME instead of delete because the OutputFcn needs
0221 % to get the updated handles structure.
0222 handles.output=[];
0223 % Update handles structure
0224 guidata(hObject, handles);
0225 
0226 uiresume(handles.figure1);

Generated on Mon 03-Sep-2012 18:07:18 by m2html © 2005