sdt_dialogs#
Purpose Common dialog generation tools
Syntax
ua = sdt_dialogs('uatable',type,name,obj) wd = sdt_dialogs('getdir',RO); [fname,wd] = sdt_dialogs('getfile',RO);
Description
sdt_dialogs gathers interaction utilities through GUI : selection in a list, table filing, file/folder selection ...
getfile,putfile,getdir#
reproduces the behaviour of MATLAB function uigetfile,uiputfile and uigetdir with packaged options. It also handles the update of LastWd (path stored in tab Project) and uses it as default search path.
- FromScript i : by default 2, which requires to display the GUI (dialog windows). If FromScript=1, the path provided in option defname is required and checks are performed for commands getfile (file exists?) and getdir (dir exists?). In both cases, LastWd is refreshed.
- title val : window title
- multi : activate multiple file selection for getfile
- osdic val : Load a file filter from the project osdic. The default file filter list can be found with the command list=d_imw('ff') .
- allfiles i : handles extra "all files" filter
- 0 : just use the file filter list.
- 1 (default) : extra filter "All Files" added at the end of the file filter list.
- 2 : extra filter "All Files" added at the beginning of the file filter list.
- acceptedfiles i : gather all possible file extensions and add extra "accepted files" filter. Accepted values are 0, 1 and 2 (default) with the same logic than allfiles
- relpath : root path. If present, optional input defname can be given as a relative path and found file/folder outputs are given as relative path as well. See sdth fileutil rel2abs and abs2rel for details.
- defname val : default path name.
- : if FromScript=1, this the path used to bypass GUI interaction (it can be given as a relative path to relpath). For getfile and getdir, file and folder existence is checked and the output is empty if not found.
- if FromScript=2, this is the default path to open the search window. For getfile and putfile, it can be either a folder path or a file path which in this case will be proposed as default file name. It must be a folder path for getdir. If not provided, the default folder will be the value of LastWd in the current Project tab.
- UI : provides the project from which LastWd and osdic are retrieved. If not provided, SDT Root project is used by default.
[fname,wd]=sdt_dialogs('getfile'); wd=sdt_dialogs('getdir'); [fname,wd]=sdt_dialogs('putfile');
f0=which('feplot'); RO=struct('title','Select feplot.m file...','osdic','FFImMatScript',... 'defname',f0); [fname,wd]=sdt_dialogs('getfile',RO);% Use relpath to get output in relative format wd0=fileparts(f0); wd0=sdth.fileutil('cffile',fullfile(wd0,'..')); RO.relpath=wd0; [fname,wd]=sdt_dialogs('getfile',RO); % Relative path fname, root wd RO.allfiles=2; [fname,wd]=sdt_dialogs('getfile',RO); % Add All files filter at top RO.title='Select files ...'; RO.defname={f0 which('iiplot')}; RO.multi=1; % Multiselection allowed from GUI [fname,wd]=sdt_dialogs('getfile',RO); % From Script : bypass GUI interaction RO.FromScript=1; [fname,wd]=sdt_dialogs('getfile',RO);
picklist#
packages options forwarded to MATLAB function listdlg to display a picklist from a cell array of char. Options are :
- single : selection of one item only in the list, else multiple item selection in allowed
- initVal i : item(s) selected by default
Next optional inputs provide the figure name and the prompt text above the displayed list.
st={'item1';'item2';'item3'}; % List of items % Selection of one item only with preselection of item 2 i1=sdt_dialogs('picklist-single-initVal2',st,'Select...','Select single item :'); % Selection of multiple items with preselection of items 2 and 3 RO=struct('initVal',2:3); i1=sdt_dialogs('picklist',st,RO,'Select...','Select multiple items :');
dlg#
packages options forwarded to MATLAB function msgbox to display a short text in a window with an exit button.
Default behavior is a modal window named "Message..." with a close button.
The message to display is provided as first argument. Second argument can be provided as a structure of options :
- title: Window title replacing the default one "Message..."
- error: Display error icon if value=1
- warning: Display warning icon if value=1
- info: Display info icon if value=1
- countdown i: A countdown is added at the end of the close button to automatically close the window. Without this option or with countdown=0, the window stay on top until manually closed.
- butstring: Text to display in the end button
- nomodal: The displayed window will not block interaction with other windows
st='This is a message'; % Message to display % Display with info icon, window title "Success !" and a 5s countdown before auto closing sdt_dialogs('dlg-info-countdown5',st,struct('title','Success !'));