Changeset 611 for trunk/src/uigetfile_uvmat.m
- Timestamp:
- Apr 18, 2013, 9:02:03 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/uigetfile_uvmat.m
r610 r611 45 45 Bottom=ScreenSize(4)-Height-40; %put fig at top right 46 46 hfig=figure('name',option,'tag',option,'MenuBar','none','NumberTitle','off','Unit','points','Position',[Left,Bottom,Width,Height],'UserData',InputDir); 47 uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @(src,event)view_file(option,src,event),'tag','list',... 47 BackgroundColor=get(hfig,'Color'); 48 uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.97 0.5 0.03],'BackgroundColor',BackgroundColor,... 49 'String','path:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left'); 50 uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.89 0.9 0.08],'tag','titlebox','Max',2,'BackgroundColor',[1 1 1],... 51 'String',InputDir,'FontUnits','points','FontSize',12,'FontWeight','bold'); 52 % uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.85 0.5 0.03],'BackgroundColor',BackgroundColor,... 53 % 'String','first modified:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','right'); 54 % uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.82 0.5 0.03],'BackgroundColor',BackgroundColor,... 55 % 'String','last modified:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','right'); 56 uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.08 0.9 0.66], 'Callback', @(src,event)view_file(option,src,event),'tag','list',... 48 57 'FontUnits','points','FontSize',12); 49 uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','titlebox','Max',2,... 50 'String',InputDir,'FontUnits','points','FontSize',12,'FontWeight','bold'); 51 uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'Callback',@(src,event)close(option,src,event),... 58 uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.005 0.2 0.07],'Callback',@(src,event)close(option,src,event),... 52 59 'String','Close','FontWeight','bold','FontUnits','points','FontSize',12); 53 uicontrol('Style','pushbutton','Tag','refresh','Units','normalized','Position', [0.1 0.0 10.2 0.07],'Callback',@refresh_GUI,...60 uicontrol('Style','pushbutton','Tag','refresh','Units','normalized','Position', [0.1 0.005 0.2 0.07],'Callback',@refresh_GUI,... 54 61 'String','Refresh','FontWeight','bold','FontUnits','points','FontSize',12); 55 62 %set(hrefresh,'UserData',StatusData) … … 59 66 uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); 60 67 else %put a title and additional pushbuttons 61 uicontrol('Style','text','Units','normalized', 'Position', [0.15 0. 81 0.8 0.03],...68 uicontrol('Style','text','Units','normalized', 'Position', [0.15 0.75 0.8 0.03],'BackgroundColor',BackgroundColor,... 62 69 'String',title,'FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left'); 63 uicontrol('Style','pushbutton','Tag','backward','Units','normalized','Position',[0.05 0. 80.1 0.07],...70 uicontrol('Style','pushbutton','Tag','backward','Units','normalized','Position',[0.05 0.75 0.1 0.07],... 64 71 'String','<--','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@backward); 65 uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.4 0.0 10.2 0.07],...72 uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.4 0.005 0.2 0.07],... 66 73 'String','Home','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@home_dir); 67 74 end … … 71 78 if ~strcmp(option,'status_display') 72 79 uiwait(hfig) 73 fileinput=get(hfig,'UserData');% retrieve the input file selection 80 htitlebox=findobj(hfig,'Tag','titlebox'); 81 fileinput=get(htitlebox,'String');% retrieve the input file selection 74 82 delete(hfig) 75 83 end … … 85 93 end 86 94 hfig=get(hObject,'parent'); 87 DirName=get(hfig,'UserData'); 95 htitlebox=findobj(hfig,'tag','titlebox'); 96 DirName=get(htitlebox,'String'); 88 97 ListFiles=list_files(DirName);% list the directory content 89 98 hlist=findobj(hfig,'tag','list');% find the list object … … 109 118 110 119 111 htitlebox=findobj(hfig,'tag','titlebox'); 120 112 121 hlist=findobj(hfig,'tag','list'); 113 OutputDir=get(hfig,'UserData');122 % OutputDir=get(hfig,'UserData'); 114 123 115 124 testrecent=0; … … 168 177 index=get(hObject,'Value'); 169 178 hfig=get(hObject,'parent');%handle of the fig 170 DirName=get(hfig,'UserData'); 179 htitlebox=findobj(hfig,'tag','titlebox'); % display the new dir name 180 DirName=get(htitlebox,'String'); 171 181 SelectName=regexprep(list{index},'^\+/','');% remove the +/ used to mark dir 172 182 if strcmp(SelectName,'..')% the upward dir option has been selected … … 195 205 set(hObject,'Value',1) 196 206 set(hObject,'String',ListFiles) 197 set(hfig,'UserData',FullSelectName)% record the new dir name 198 htitlebox=findobj(hfig,'tag','titlebox'); % display the new dir name 199 set(htitlebox,'String',FullSelectName) 207 set(htitlebox,'String',FullSelectName)% record the new dir name 200 208 elseif exist(FullSelectName,'file')%visualise the field if it exists 201 209 FileType=get_file_type(FullSelectName); … … 210 218 switch option 211 219 case 'browser' 212 hfig=get(hObject,'parent'); 213 set(hfig,'UserData',FullSelectName); 220 set(htitlebox,'String',FullSelectName); 214 221 uiresume(hfig) 215 222 case 'status_display' 216 223 uvmat(FullSelectName); 217 224 end 218 set(gcbo,'Value',1)219 225 end 220 226 end … … 222 228 %------------------------------------------------------------------------- 223 229 % list the content of a directory 224 function ListFiles=list_files(DirName)230 function [ListFiles,ListDates]=list_files(DirName) 225 231 %------------------------------------------------------------------------- 226 232 ListStruct=dir(DirName);% get structure of the current directory 227 if numel(ListStruct)<1 233 if numel(ListStruct)<1 % case of empty dir 228 234 ListFiles={}; 235 ListDates={}; 229 236 return 230 237 end 231 if strcmp(ListStruct(1).name,'.')232 ListStruct(1)=[];%removes the first line ='.'233 end238 % if strcmp(ListStruct(1).name,'.') 239 % ListStruct(1)=[];%removes the first line ='.' 240 % end 234 241 ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray 235 242 ListFiles=ListCells(1,:);%list of file names 236 check_dir=cell2mat(ListCells(4,:));% check directories 243 check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files 244 ListDates=cell2mat(ListCells(5,:));%list of numerical dates 237 245 ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display 238 [tild,index_sort]=sort(check_dir,2,'descend');% sort 246 ListDates(check_dir)=0; % we set the dir dates to 0 247 [tild,index_sort]=sort(check_dir,2,'descend');% put the dir first in the list 239 248 ListFiles=ListFiles(index_sort);% list of names sorted by alaphabetical order and dir and file 249 ListDates=ListDates(index_sort);% sort the corresponding dates 240 250 cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) 241 251 check_keep=cellfun('isempty', cell_remove); 242 252 ListFiles=[{'+/..'} ListFiles(check_keep)]; 253 ListDates=[0 ListDates(check_keep)]; 243 254 244 255 %------------------------------------------------------------------------ … … 249 260 ListFiles=list_files(DirName);% list the directory content 250 261 hfig=get(hObject,'parent'); 251 set(hfig,'UserData',DirName)% record the new dir name 252 htitlebox=findobj(hfig,'tag','titlebox'); % display the new dir name 253 set(htitlebox,'String',DirName) 254 hlist=findobj(hfig,'tag','list');% find the list object 262 htitlebox=findobj(hfig,'Tag','titlebox'); 263 set(htitlebox,'String',DirName)% record the new dir name 264 hlist=findobj(hfig,'tag','list');% find the list object 255 265 set(hlist,'String',ListFiles) 256 266 %------------------------------------------------------------------------ … … 263 273 if ~isempty(PrevDir) 264 274 hfig=get(hObject,'parent'); 265 set(hfig,'UserData',PrevDir)266 275 htitlebox=findobj(hfig,'tag','titlebox'); % display the new dir name 267 276 set(htitlebox,'String',PrevDir)
Note: See TracChangeset
for help on using the changeset viewer.