Home > . > msgbox_uvmat.m

msgbox_uvmat

PURPOSE ^

'msgbox_uvmat': associated with GUI msgbox_uvmat.fig to display message boxes, for error, warning or input calls

SYNOPSIS ^

function varargout = msgbox_uvmat(varargin)

DESCRIPTION ^

'msgbox_uvmat': associated with GUI msgbox_uvmat.fig to display message boxes, for error, warning or input calls
 msgbox_uvmat(title,display)

 OUTPUT:
 answer  (text string)= 'yes', 'No', 'cancel', or the text string introduced as input

INPUT:
 title: string indicating the type of message box:
          title= 'INPUT_TXT','CONFIMATION' ,'ERROR', 'WARNING', 'INPUT_Y-N', default = 'INPUT_TXT' (the title is displayed in the upper bar of the fig). 
          if title='INPUT_TXT', input data is asked in an edit box
          if title='CONFIMATION'', 'ERROR', 'WARNING', the figure remains  opened until a button 'OK' is pressed
          if title='INPUT_Y-N', an answer Yes/No is requested
 display, displayed text
 default_answer: default answer in the edit box (only used with title='INPUT_TXT')

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 %'msgbox_uvmat': associated with GUI msgbox_uvmat.fig to display message boxes, for error, warning or input calls
0002 % msgbox_uvmat(title,display)
0003 %
0004 % OUTPUT:
0005 % answer  (text string)= 'yes', 'No', 'cancel', or the text string introduced as input
0006 %
0007 %INPUT:
0008 % title: string indicating the type of message box:
0009 %          title= 'INPUT_TXT','CONFIMATION' ,'ERROR', 'WARNING', 'INPUT_Y-N', default = 'INPUT_TXT' (the title is displayed in the upper bar of the fig).
0010 %          if title='INPUT_TXT', input data is asked in an edit box
0011 %          if title='CONFIMATION'', 'ERROR', 'WARNING', the figure remains  opened until a button 'OK' is pressed
0012 %          if title='INPUT_Y-N', an answer Yes/No is requested
0013 % display, displayed text
0014 % default_answer: default answer in the edit box (only used with title='INPUT_TXT')
0015 
0016 function varargout = msgbox_uvmat(varargin)
0017 
0018 % Last Modified by GUIDE v2.5 24-Oct-2009 21:55:17
0019 
0020 % Begin initialization code - DO NOT EDIT
0021 gui_Singleton = 1;
0022 gui_State = struct('gui_Name',       mfilename, ...
0023                    'gui_Singleton',  gui_Singleton, ...
0024                    'gui_OpeningFcn', @msgbox_uvmat_OpeningFcn, ...
0025                    'gui_OutputFcn',  @msgbox_uvmat_OutputFcn, ...
0026                    'gui_LayoutFcn',  [] , ...
0027                    'gui_Callback',   []);
0028 if nargin && ischar(varargin{1})
0029     gui_State.gui_Callback = str2func(varargin{1});
0030 end
0031 
0032 if nargout
0033     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0034 else
0035     gui_mainfcn(gui_State, varargin{:});
0036 end
0037 % End initialization code - DO NOT EDIT
0038 
0039 % --- Executes just before msgbox_uvmat is made visible.
0040 function msgbox_uvmat_OpeningFcn(hObject, eventdata, handles,title,display,default_answer)
0041 % This function has no output args, see OutputFcn.
0042 
0043 % Choose default command line output for msgbox_uvmat
0044 handles.output = 'Cancel';
0045 
0046 % Update handles structure
0047 guidata(hObject, handles);
0048 testNo=0;
0049 testCancel=1;
0050 testinputstring=0;
0051 icontype='quest';%default question icon (text input asked)
0052 if exist('title','var')
0053       set(hObject, 'Name', title); 
0054       if isequal (title,'CONFIRMATION')
0055          icontype='';
0056          testCancel=0; %no cancel button
0057       elseif isequal (title,'ERROR')
0058          icontype='error';
0059          testCancel=0; %no cancel button
0060       elseif isequal (title,'WARNING')
0061          icontype='warn';
0062          testCancel=0; %no cancel button
0063       elseif isequal (title,'INPUT_Y-N')
0064          icontype='quest'; 
0065          testNo=1; % button No activated
0066       else
0067           testinputstring=1;
0068       end
0069 end
0070 if exist('display','var')
0071     set(handles.text1, 'String', display);
0072 end
0073 if testinputstring
0074     set(handles.edit_box, 'Visible', 'on');
0075 else
0076     set(handles.text1, 'Position', [0.15 0.3 0.85 0.7]);
0077 end
0078 if exist('default_answer','var') &&  testinputstring
0079     set(handles.edit_box, 'String', default_answer);
0080 end
0081 % Determine the position of the dialog - centered on the screen
0082 FigPos=get(0,'DefaultFigurePosition');
0083 OldUnits = get(hObject, 'Units');
0084 set(hObject, 'Units', 'pixels');
0085 OldPos = get(hObject,'Position');
0086 FigWidth = OldPos(3);
0087 FigHeight = OldPos(4);
0088 ScreenUnits=get(0,'Units');
0089 set(0,'Units','pixels');
0090 ScreenSize=get(0,'ScreenSize');
0091 set(0,'Units',ScreenUnits);
0092 
0093 FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
0094 FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
0095 FigPos(3:4)=[FigWidth FigHeight];
0096 set(hObject, 'Position', FigPos);
0097 set(hObject, 'Units', OldUnits);
0098 
0099 % Show a question icon from dialogicons.mat - variables questIconData
0100 % and questIconMap
0101 if isequal(icontype,'')
0102     hima=findobj(handles.axes1,'Type','image');
0103     if ~isempty(hima)
0104         delete(hima)
0105     end
0106 else
0107     load dialogicons.mat
0108     eval(['IconData=' icontype 'IconData;'])
0109     eval(['IconCMap=' icontype 'IconMap;'])
0110     questIconMap(256,:) = get(handles.figure1, 'Color');
0111     Img=image(IconData, 'Parent', handles.axes1);
0112     set(handles.figure1, 'Colormap', IconCMap);
0113     set(handles.axes1, ...
0114         'Visible', 'off', ...
0115         'YDir'   , 'reverse'       , ...
0116         'XLim'   , get(Img,'XData'), ...
0117         'YLim'   , get(Img,'YData')  ...
0118         );
0119 end 
0120 if testCancel
0121      set(handles.Cancel,'Visible','on')
0122 else
0123     set(handles.Cancel,'Visible','off')
0124 end
0125 if testNo
0126      set(handles.No,'Visible','on')
0127 else
0128     set(handles.No,'Visible','off')
0129 end
0130 % if testOK % request an answer to proceed
0131 %     set(handles.OK,'Visible','on')
0132     % Make the GUI modal
0133 set(handles.figure1,'WindowStyle','modal')
0134 % UIWAIT makes msgbox_uvmat wait for user response (see UIRESUME)
0135 uiwait(handles.figure1);
0136 % else
0137 %     set(handles.OK,'Visible','off')
0138 %     set(handles.Cancel,'Visible','off')
0139 % end
0140 % delete(hObject)
0141 
0142 % --- Outputs from this function are returned to the command line.
0143 function varargout = msgbox_uvmat_OutputFcn(hObject, eventdata, handles)
0144 
0145 % Get default command line output from handles structure
0146 
0147 % varargout{1} = hObject;
0148 handles.output
0149 if isequal(handles.output,'Cancel')
0150     varargout{1}='Cancel';
0151 elseif isequal(handles.output,'No')
0152     varargout{1}='No';
0153 else
0154     varargout{1}=get(handles.edit_box,'String');
0155     isequal(varargout{1},'')
0156     if isempty(varargout{1}) || isequal(varargout{1},'')
0157         varargout{1}='Yes';
0158     end
0159 end
0160     
0161 %varargout{2} = handles.output;
0162 
0163 % The figure can be deleted now
0164 delete(handles.figure1);
0165 
0166 % --- Executes on button press in OK.
0167 function OK_Callback(hObject, eventdata, handles)
0168 handles.output = get(hObject,'String');
0169 guidata(hObject, handles);% Update handles structure
0170 uiresume(handles.figure1);
0171 
0172 % --- Executes on button press in No.
0173 function No_Callback(hObject, eventdata, handles)
0174 handles.output='No';
0175 guidata(hObject, handles);
0176 uiresume(handles.figure1);
0177 
0178 % --- Executes on button press in Cancel.
0179 function Cancel_Callback(hObject, eventdata, handles)
0180 handles.output = get(hObject,'String');
0181 %handles.output = 'Cancel'
0182 guidata(hObject, handles); % Update handles structure
0183 % Use UIRESUME instead of delete because the OutputFcn needs
0184 % to get the updated handles structure.
0185 uiresume(handles.figure1);
0186 
0187 % --- Executes on activation of edit_box.
0188 function edit_box_Callback(hObject, eventdata, handles)
0189 
0190 
0191 % --- Executes when user attempts to close figure1.
0192 function figure1_CloseRequestFcn(hObject, eventdata, handles)
0193 if isequal(get(handles.figure1, 'waitstatus'), 'waiting')
0194     % The GUI is still in UIWAIT, us UIRESUME
0195     uiresume(handles.figure1);
0196 else
0197     % The GUI is no longer waiting, just close it
0198     delete(handles.figure1);
0199 end
0200 
0201 % --- Executes on key press over figure1 with no controls selected.
0202 function figure1_KeyPressFcn(hObject, eventdata, handles)
0203 % Check for "enter" or "escape"
0204 if isequal(get(hObject,'CurrentKey'),'escape')
0205     % User said no by hitting escape
0206     handles.output = 'No';
0207     
0208     % Update handles structure
0209     guidata(hObject, handles);
0210     
0211     uiresume(handles.figure1);
0212 end
0213 if isequal(get(hObject,'CurrentKey'),'return')
0214     uiresume(handles.figure1);
0215 end    
0216 
0217 
0218 
0219 
0220

Generated on Fri 13-Nov-2009 11:17:03 by m2html © 2003