0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 function varargout = msgbox_uvmat(varargin)
0017
0018
0019
0020
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
0038
0039
0040 function msgbox_uvmat_OpeningFcn(hObject, eventdata, handles,title,display,default_answer)
0041
0042
0043
0044 handles.output = 'Cancel';
0045
0046
0047 guidata(hObject, handles);
0048 testNo=0;
0049 testCancel=1;
0050 testinputstring=0;
0051 icontype='quest';
0052 if exist('title','var')
0053 set(hObject, 'Name', title);
0054 if isequal (title,'CONFIRMATION')
0055 icontype='';
0056 testCancel=0;
0057 elseif isequal (title,'ERROR')
0058 icontype='error';
0059 testCancel=0;
0060 elseif isequal (title,'WARNING')
0061 icontype='warn';
0062 testCancel=0;
0063 elseif isequal (title,'INPUT_Y-N')
0064 icontype='quest';
0065 testNo=1;
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
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
0100
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
0131
0132
0133 set(handles.figure1,'WindowStyle','modal')
0134
0135 uiwait(handles.figure1);
0136
0137
0138
0139
0140
0141
0142
0143 function varargout = msgbox_uvmat_OutputFcn(hObject, eventdata, handles)
0144
0145
0146
0147
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
0162
0163
0164 delete(handles.figure1);
0165
0166
0167 function OK_Callback(hObject, eventdata, handles)
0168 handles.output = get(hObject,'String');
0169 guidata(hObject, handles);
0170 uiresume(handles.figure1);
0171
0172
0173 function No_Callback(hObject, eventdata, handles)
0174 handles.output='No';
0175 guidata(hObject, handles);
0176 uiresume(handles.figure1);
0177
0178
0179 function Cancel_Callback(hObject, eventdata, handles)
0180 handles.output = get(hObject,'String');
0181
0182 guidata(hObject, handles);
0183
0184
0185 uiresume(handles.figure1);
0186
0187
0188 function edit_box_Callback(hObject, eventdata, handles)
0189
0190
0191
0192 function figure1_CloseRequestFcn(hObject, eventdata, handles)
0193 if isequal(get(handles.figure1, 'waitstatus'), 'waiting')
0194
0195 uiresume(handles.figure1);
0196 else
0197
0198 delete(handles.figure1);
0199 end
0200
0201
0202 function figure1_KeyPressFcn(hObject, eventdata, handles)
0203
0204 if isequal(get(hObject,'CurrentKey'),'escape')
0205
0206 handles.output = 'No';
0207
0208
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