Ignore:
Timestamp:
Apr 18, 2013, 9:02:03 AM (8 years ago)
Author:
sommeria
Message:

problem of time display repaired

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uigetfile_uvmat.m

    r610 r611  
    4545    Bottom=ScreenSize(4)-Height-40; %put fig at top right
    4646    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',...
    4857        '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),...
    5259        'String','Close','FontWeight','bold','FontUnits','points','FontSize',12);
    53     uicontrol('Style','pushbutton','Tag','refresh','Units','normalized','Position', [0.1 0.01 0.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,...
    5461        'String','Refresh','FontWeight','bold','FontUnits','points','FontSize',12);
    5562    %set(hrefresh,'UserData',StatusData)
     
    5966        uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]);
    6067    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,...
    6269            'String',title,'FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left');
    63         uicontrol('Style','pushbutton','Tag','backward','Units','normalized','Position',[0.05 0.8 0.1 0.07],...
     70        uicontrol('Style','pushbutton','Tag','backward','Units','normalized','Position',[0.05 0.75 0.1 0.07],...
    6471            'String','<--','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@backward);
    65         uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.4 0.01 0.2 0.07],...
     72        uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.4 0.005 0.2 0.07],...
    6673            'String','Home','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@home_dir);
    6774    end
     
    7178if ~strcmp(option,'status_display') 
    7279    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
    7482    delete(hfig)
    7583end
     
    8593end
    8694hfig=get(hObject,'parent');
    87 DirName=get(hfig,'UserData');
     95htitlebox=findobj(hfig,'tag','titlebox');
     96DirName=get(htitlebox,'String');
    8897ListFiles=list_files(DirName);% list the directory content
    8998hlist=findobj(hfig,'tag','list');% find the list object
     
    109118   
    110119   
    111     htitlebox=findobj(hfig,'tag','titlebox');
     120
    112121    hlist=findobj(hfig,'tag','list');
    113     OutputDir=get(hfig,'UserData');
     122   % OutputDir=get(hfig,'UserData');
    114123   
    115124    testrecent=0;
     
    168177index=get(hObject,'Value');
    169178hfig=get(hObject,'parent');%handle of the fig
    170 DirName=get(hfig,'UserData');
     179htitlebox=findobj(hfig,'tag','titlebox');  % display the new dir name 
     180DirName=get(htitlebox,'String');
    171181SelectName=regexprep(list{index},'^\+/','');% remove the +/ used to mark dir
    172182if strcmp(SelectName,'..')% the upward dir option has been selected
     
    195205    set(hObject,'Value',1)
    196206    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
    200208elseif exist(FullSelectName,'file')%visualise the field if it exists
    201209    FileType=get_file_type(FullSelectName);
     
    210218        switch option
    211219            case 'browser'
    212         hfig=get(hObject,'parent');
    213         set(hfig,'UserData',FullSelectName);
     220        set(htitlebox,'String',FullSelectName);
    214221        uiresume(hfig)
    215222            case 'status_display'
    216223           uvmat(FullSelectName);
    217224        end
    218         set(gcbo,'Value',1)
    219225    end
    220226end
     
    222228%-------------------------------------------------------------------------   
    223229% list the content of a directory
    224 function ListFiles=list_files(DirName)
     230function [ListFiles,ListDates]=list_files(DirName)
    225231%-------------------------------------------------------------------------
    226232ListStruct=dir(DirName);% get structure of the current directory
    227 if numel(ListStruct)<1
     233if numel(ListStruct)<1  % case of empty dir
    228234    ListFiles={};
     235    ListDates={};
    229236    return
    230237end
    231 if strcmp(ListStruct(1).name,'.')
    232     ListStruct(1)=[];%removes the first line ='.'
    233 end
     238% if strcmp(ListStruct(1).name,'.')
     239%     ListStruct(1)=[];%removes the first line ='.'
     240% end
    234241ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
    235242ListFiles=ListCells(1,:);%list of file names
    236 check_dir=cell2mat(ListCells(4,:));% check directories
     243check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
     244ListDates=cell2mat(ListCells(5,:));%list of numerical dates
    237245ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display
    238 [tild,index_sort]=sort(check_dir,2,'descend');% sort
     246ListDates(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
    239248ListFiles=ListFiles(index_sort);% list of names sorted by alaphabetical order and dir and file
     249ListDates=ListDates(index_sort);% sort the corresponding dates
    240250cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
    241251check_keep=cellfun('isempty', cell_remove);               
    242252ListFiles=[{'+/..'} ListFiles(check_keep)];
     253ListDates=[0 ListDates(check_keep)];
    243254
    244255%------------------------------------------------------------------------   
     
    249260ListFiles=list_files(DirName);% list the directory content
    250261hfig=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
     262htitlebox=findobj(hfig,'Tag','titlebox');
     263set(htitlebox,'String',DirName)% record the new dir name
     264hlist=findobj(hfig,'tag','list');% find the list object
    255265set(hlist,'String',ListFiles)
    256266%------------------------------------------------------------------------
     
    263273if ~isempty(PrevDir)
    264274hfig=get(hObject,'parent');
    265 set(hfig,'UserData',PrevDir)
    266275htitlebox=findobj(hfig,'tag','titlebox');  % display the new dir name
    267276set(htitlebox,'String',PrevDir)
Note: See TracChangeset for help on using the changeset viewer.