Home > vbmeg > functions > gui > vb_input_settings > vb_input_settings.m

vb_input_settings

PURPOSE ^

Launch setting input dialog

SYNOPSIS ^

function [def, cancel] = vb_input_settings(def, dlg_name, save_func)

DESCRIPTION ^

 Launch setting input dialog
 [USAGE]
    [def, cancel] = vb_input_settings(def, dlg_name [,mfile_saver_func]);
 [IN]
          def : definition for input items.
     dlg_name : dialog title [string]
    save_func : (opt)If you want to save the parameter as a m-file,
                     give a function handle to the argument.
                     feval(mfile_save_func, def) will be called when pushing
                     the save button.
                     saver function should process the request properly.
 [OUT]
      def : definition for input items.
   cancel : =  true : closed with x button or cancel button, 
            = false : closed with ok button.
 [example]
   items = {
    {'type', 'directory selection', 'value', pwd, 'title', 'FS SUBJECT directory', 'help', 'The help of FS_SUBJECT directory'},...
    {'type', 'single file selection', 'extension', '.img', 'title', 'Image file', 'help', 'The help of Image file'}, ...
    {'type', 'string input', 'title', 'Subject ID', 'help', 'The help of Subject ID'},
   };
   [items, cancel] = vb_input_settings(items, 'FreeSurfer', @save_func);

 [See]
   vb_input_settings.txt

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [def, cancel] = vb_input_settings(def, dlg_name, save_func)
0002 % Launch setting input dialog
0003 % [USAGE]
0004 %    [def, cancel] = vb_input_settings(def, dlg_name [,mfile_saver_func]);
0005 % [IN]
0006 %          def : definition for input items.
0007 %     dlg_name : dialog title [string]
0008 %    save_func : (opt)If you want to save the parameter as a m-file,
0009 %                     give a function handle to the argument.
0010 %                     feval(mfile_save_func, def) will be called when pushing
0011 %                     the save button.
0012 %                     saver function should process the request properly.
0013 % [OUT]
0014 %      def : definition for input items.
0015 %   cancel : =  true : closed with x button or cancel button,
0016 %            = false : closed with ok button.
0017 % [example]
0018 %   items = {
0019 %    {'type', 'directory selection', 'value', pwd, 'title', 'FS SUBJECT directory', 'help', 'The help of FS_SUBJECT directory'},...
0020 %    {'type', 'single file selection', 'extension', '.img', 'title', 'Image file', 'help', 'The help of Image file'}, ...
0021 %    {'type', 'string input', 'title', 'Subject ID', 'help', 'The help of Subject ID'},
0022 %   };
0023 %   [items, cancel] = vb_input_settings(items, 'FreeSurfer', @save_func);
0024 %
0025 % [See]
0026 %   vb_input_settings.txt
0027 %
0028 % Copyright (C) 2011, ATR All Rights Reserved.
0029 % License : New BSD License(see VBMEG_LICENSE.txt)
0030 
0031 if ~exist('dlg_name', 'var')
0032     dlg_name = '';
0033 end
0034 if ~exist('save_func', 'var')
0035     save_func = [];
0036 end
0037 
0038 % Open figure
0039 pg_path = vb_get_file_parts(which(mfilename));
0040 fig = openfig(fullfile(pg_path, filesep, 'vb_input_settings.fig'));
0041 H = guihandles(fig);
0042 set(fig, 'Name', dlg_name);
0043 %warning('setColorProperty');
0044 %setColorProperty;
0045 
0046 % data difinition
0047 data = struct;
0048 data.H    = H;
0049 data.def = def;
0050 data.org_def = def;
0051 data.save_func = save_func;
0052 
0053 data.cancel = false; % close with x button
0054 try
0055 % Set listbox
0056 Nitem = size(def, 2);
0057 for k=1:Nitem
0058     item = def{k};
0059     name = vb_input_settings_get_prop(item, 'title');
0060     name_list{k} = [num2str(k), '.' name];
0061 end
0062 set(H.name_listbox, 'String', name_list);
0063 catch
0064     error('Error occured!');
0065 end
0066 
0067 % Set visibility of "Save as" button
0068 if isa(data.save_func, 'function_handle')
0069     set(H.saveas_push, 'Visible', 'on');
0070 end
0071 
0072 % Save definition
0073 guidata(fig, data);
0074 % update screen
0075 vb_input_settings_update_gui(data);
0076 
0077 waitfor(fig, 'Visible', 'off');
0078 
0079 % load updated data during waitfor(fig)
0080 if ishandle(fig)
0081     data = guidata(fig);
0082     def = data.def;
0083     delete(fig);
0084 end
0085 
0086 cancel = data.cancel;

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005