Changeset 581 for trunk/src/msgbox_uvmat.m
- Timestamp:
- Mar 12, 2013, 12:52:13 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/msgbox_uvmat.m
r507 r581 7 7 %INPUT: 8 8 % title: string indicating the type of message box: 9 % title= 'INPUT_TXT','CONFIMATION' ,'ERROR', 'WARNING', 'INPUT_Y-N', default = 'INPUT_TXT' (the title is displayed in the upper bar of the fig).9 % title= 'INPUT_TXT','CONFIMATION' ,'ERROR', 'WARNING', 'INPUT_Y-N','INPUT_MENU' default = 'INPUT_TXT' (the title is displayed in the upper bar of the fig). 10 10 % if title='INPUT_TXT', input data is asked in an edit box 11 11 % if title='CONFIMATION'', 'ERROR', 'WARNING', the figure remains opened until a button 'OK' is pressed … … 37 37 % End initialization code - DO NOT EDIT 38 38 39 %------------------------------------------------------------------------ 39 40 % --- Executes just before msgbox_uvmat is made visible. 40 41 function msgbox_uvmat_OpeningFcn(hObject, eventdata, handles,title,display_str,default_answer,Position) 42 %------------------------------------------------------------------------ 41 43 % This function has no output args, see OutputFcn. 42 44 … … 89 91 testinputstring=1; 90 92 testCancel=1; %no cancel button 93 case 'INPUT_MENU' 94 testinputstring=2; 95 testCancel=1; %no cancel button 91 96 otherwise 92 97 % testinputstring=1; … … 98 103 set(handles.text1, 'String', display_str); 99 104 end 100 % if testinputstring 101 % set(handles.edit_box, 'Visible', 'on'); 102 % else 103 % set(handles.text1, 'Position', [0.15 0.3 0.85 0.7]); 104 % end 105 if testinputstring 106 % set(handles.figure1,'Position',[40,80,20*length(default_answer),50]) 105 106 if testinputstring==1 107 107 set(handles.edit_box, 'Visible', 'on'); 108 108 if ~exist('default_answer','var'); … … 111 111 set(handles.edit_box, 'String', default_answer); 112 112 if exist('Position','var') 113 if iscell(default_answer) 114 widthstring=max(max(cellfun('length',default_answer)),length(display_str)); 115 heightstring=size(default_answer,1);%nbre of expected lines 116 set(handles.edit_box,'Max',2); 117 else 118 widthstring=max(length(default_answer),length(display_str)); 119 heightstring=1; 120 end 121 widthstring=max(widthstring,length(title)+20); 122 boxsize=[10*widthstring 20*heightstring];%size of the display edit box 123 set(handles.edit_box,'Units','pixels') 124 set(handles.edit_box,'FontUnits','pixels') 125 set(handles.edit_box,'FontSize',12) 126 set(handles.edit_box,'Position',[5,34,boxsize(1),boxsize(2)]) 127 FigPos(3)=10+boxsize(1); 128 FigPos(4)=56+boxsize(2); 129 FigPos(2)=Position(2)-FigPos(4)-25; 130 set(handles.figure1,'Position',FigPos) 131 end 132 % set(handles.figure1,'Position',[40,40,20*length(default_answer),50]) 113 if iscell(default_answer) 114 widthstring=max(max(cellfun('length',default_answer)),length(display_str)); 115 heightstring=size(default_answer,1);%nbre of expected lines 116 set(handles.edit_box,'Max',2); 117 else 118 widthstring=max(length(default_answer),length(display_str)); 119 heightstring=1; 120 end 121 widthstring=max(widthstring,length(title)+20); 122 boxsize=[10*widthstring 20*heightstring];%size of the display edit box 123 set(handles.edit_box,'Units','pixels') 124 set(handles.edit_box,'FontUnits','pixels') 125 set(handles.edit_box,'FontSize',12) 126 set(handles.edit_box,'Position',[5,34,boxsize(1),boxsize(2)]) 127 FigPos(3)=10+boxsize(1); 128 FigPos(4)=56+boxsize(2); 129 FigPos(2)=Position(2)-FigPos(4)-25; 130 set(handles.figure1,'Position',FigPos) 131 end 132 elseif testinputstring==2 133 set(handles.edit_box,'style','listbox') 134 set(handles.edit_box, 'Visible', 'on'); 135 set(handles.edit_box,'String', default_answer) 133 136 else 134 137 set(handles.text1, 'Position', [0.15 0.3 0.85 0.7]); … … 189 192 uiwait(handles.figure1); 190 193 191 194 %------------------------------------------------------------------------ 192 195 % --- Outputs from this function are returned to the command line. 193 196 function varargout = msgbox_uvmat_OutputFcn(hObject, eventdata, handles) 197 %------------------------------------------------------------------------ 194 198 195 199 % Get default command line output from handles structure … … 200 204 varargout{1}='No'; 201 205 else 206 if strcmp(get(handles.edit_box,'Style'),'listbox') 207 varargout{1}=get(handles.edit_box,'Value'); 208 else 202 209 varargout{1}=get(handles.edit_box,'String'); 203 if isempty(varargout{1}) || isequal(varargout{1},'') 210 end 211 if isempty(varargout{1}) 204 212 varargout{1}='Yes'; 205 213 end … … 208 216 end 209 217 delete(handles.figure1); 210 218 219 %------------------------------------------------------------------------ 211 220 % --- Executes on button press in OK. 212 221 function OK_Callback(hObject, eventdata, handles) 222 %------------------------------------------------------------------------ 213 223 handles.output = get(hObject,'String'); 214 224 guidata(hObject, handles);% Update handles structure 215 225 uiresume(handles.figure1); 216 226 227 %------------------------------------------------------------------------ 217 228 % --- Executes on button press in No. 218 229 function No_Callback(hObject, eventdata, handles) 230 %------------------------------------------------------------------------ 219 231 handles.output='No'; 220 232 guidata(hObject, handles); 221 233 uiresume(handles.figure1); 222 234 235 %------------------------------------------------------------------------ 223 236 % --- Executes on button press in Cancel. 224 237 function Cancel_Callback(hObject, eventdata, handles) 238 %------------------------------------------------------------------------ 225 239 handles.output = get(hObject,'String'); 226 240 %handles.output = 'Cancel' … … 230 244 uiresume(handles.figure1); 231 245 232 246 %------------------------------------------------------------------------ 233 247 % --- Executes when user attempts to close figure1. 234 248 function figure1_CloseRequestFcn(hObject, eventdata, handles) 249 %------------------------------------------------------------------------ 235 250 if isequal(get(handles.figure1, 'waitstatus'), 'waiting') 236 251 % The GUI is still in UIWAIT, us UIRESUME … … 241 256 end 242 257 258 %------------------------------------------------------------------------ 243 259 % --- Executes on key press over figure1 with no controls selected. 244 260 function figure1_KeyPressFcn(hObject, eventdata, handles) 261 %------------------------------------------------------------------------ 245 262 % Check for "enter" or "escape" 246 263 if isequal(get(hObject,'CurrentKey'),'escape')
Note: See TracChangeset
for help on using the changeset viewer.