Home > marsbar > @mardo > ui_event_types.m

ui_event_types

PURPOSE ^

ui method for selection / editing of event types

SYNOPSIS ^

function [D, ic, status] = ui_event_types(D)

DESCRIPTION ^

 ui method for selection / editing of event types
 FORMAT [D, ic, status] = ui_event_types(D)
 
 Input
 D          - design object
 
 Returns  
 D          - possibly modified design object
 ic         - indices of selected event types (empty for none)
 status     - 0 for Cancel or window quit
              1 for OK, but no edits to event types
              2 for OK, with edits to event types
 
 The routine sets up the event type window, and waits until that window
 is done, then returns with the modified values.
 
 $Id$

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [D, ic, status] = ui_event_types(D)
0002 % ui method for selection / editing of event types
0003 % FORMAT [D, ic, status] = ui_event_types(D)
0004 %
0005 % Input
0006 % D          - design object
0007 %
0008 % Returns
0009 % D          - possibly modified design object
0010 % ic         - indices of selected event types (empty for none)
0011 % status     - 0 for Cancel or window quit
0012 %              1 for OK, but no edits to event types
0013 %              2 for OK, with edits to event types
0014 %
0015 % The routine sets up the event type window, and waits until that window
0016 % is done, then returns with the modified values.
0017 %
0018 % $Id$
0019   
0020 % Put up window and initialize callbacks
0021 [F hDone hList hEdit] = sf_start_window(D);
0022 
0023 % Wait for OK, Cancel, figure cleared.
0024 waitfor(hDone,'UserData')
0025 
0026 % Get what was pressed, assume cancel if window has died
0027 ic = [];
0028 if ~ishandle(hDone)
0029   status = 0;
0030 else
0031   status = get(hDone, 'UserData');
0032   if status
0033     % Edit control contains info as to whether edits done
0034     status = status + get(hEdit, 'UserData');
0035     D = get(F, 'UserData');
0036     if ~isempty(event_types(D))
0037       ic = get(hList, 'Value');
0038     end
0039   end
0040   close(F);
0041 end
0042 
0043 return
0044 
0045 function [F, hDone, hList, hEdit] = sf_start_window(D)
0046 % Put up window and set up callbacks
0047 
0048 % Window tag
0049 w_tag = 'ui_event_types';
0050   
0051 % Close any event_types windows currently open
0052 close(findobj('Tag', w_tag))
0053   
0054 %-Generic CallBack code to get embedded object
0055 cb = ['et_D = get(findobj(''Tag'', ''' w_tag '''),''UserData''); '];
0056 
0057 %-Create window, compute scaling for screen size
0058 %-----------------------------------------------------------------------
0059 WS = spm('WinScale');                %-Window scaling factors
0060 FS = spm('FontSizes');                %-Scaled font sizes
0061 PF = spm_platform('fonts');            %-Font names (for this platform)
0062 S0 = get(0,'ScreenSize');            %-Screen size
0063 
0064 % Window size, button size, position, in WS units
0065 win_sz      = [400 300];
0066 ratio_dor   = (1 + sqrt(5))/2;
0067 
0068 % Button sizes and positions
0069 n_buttons   = 5;
0070 button_sz_x = 75;
0071 button_border = [12 12]; 
0072 button_sz   = [button_sz_x button_sz_x / ratio_dor];
0073 button_x    = win_sz(1) - button_sz(1) - button_border(1);
0074 l_b         = button_border(2);
0075 h_b         = win_sz(2) - button_border(2) - button_sz(2);
0076 gap_b       = (h_b - l_b) / (n_buttons-1);
0077 buttons_y   = l_b:gap_b:h_b;
0078 
0079 % Event list size, position
0080 elist_border = button_border;
0081 elist_pos    = elist_border;
0082 elist_sz(1)  = button_x - elist_border(1)*2;
0083 elist_sz(2)  = win_sz(2) - elist_border(2)*2;
0084 
0085 F = figure('IntegerHandle','off',...
0086        'Tag', w_tag,...
0087        'UserData', D, ...
0088        'Name','Event type', ...
0089        'NumberTitle','off',...
0090        'Position',[S0(3)/2,S0(4)/2,0,0] + [-250,-200, win_sz].*WS,...
0091        'Resize','off',...
0092        'Color',[1 1 1]*.7,...
0093        'MenuBar','none',...
0094        'DefaultTextColor','k',...
0095        'DefaultTextFontName',PF.helvetica,...
0096        'DefaultTextFontSize',FS(10),...
0097        'DefaultAxesFontName',PF.helvetica,...
0098        'DefaultUicontrolBackgroundColor',[1 1 1]*.7,...
0099        'DefaultUicontrolFontName',PF.helvetica,...
0100        'DefaultUicontrolFontSize',FS(10),...
0101        'DefaultUicontrolInterruptible','on',...
0102        'Colormap',gray(64),...
0103        'Renderer','painters',...
0104        'Visible','on');
0105 
0106 % OK
0107 hDone = uicontrol(F,...
0108           'Style','Pushbutton','String','OK',...
0109           'ToolTipString','OK - press after selecting selected events types',...
0110           'ForegroundColor','k',...
0111           'Tag','Done','UserData',-1,...
0112           'Callback',[cb 'ui_event_types_cb(et_D, ''OK'')'] ,...
0113           'Interruptible','off','BusyAction','Cancel',...
0114           'Position',[button_x buttons_y(1) button_sz].*WS);
0115 
0116 % Cancel
0117 uicontrol(F,...
0118       'Style','Pushbutton','String','Cancel',...
0119       'ToolTipString','Cancel UI and return without changes',...
0120       'ForegroundColor','k',...
0121       'Tag','Cancel','UserData',-1,...
0122       'Callback',[cb 'ui_event_types_cb(et_D, ''Cancel'')'] ,...
0123       'Interruptible','off','BusyAction','Cancel',...
0124       'Position',[button_x buttons_y(2) button_sz].*WS);
0125 
0126 % Delete
0127 uicontrol(F,...
0128       'Style','Pushbutton','String','Delete',...
0129       'ToolTipString','Delete - press after selecting events type(s)',...
0130       'ForegroundColor','k',...
0131       'Tag','Delete','UserData',-1,...
0132       'Callback',[cb 'ui_event_types_cb(et_D, ''Delete'')'] ,...
0133       'Interruptible','off','BusyAction','Cancel',...
0134       'Position',[button_x buttons_y(3) button_sz].*WS);
0135 
0136 % Edit
0137 hEdit = uicontrol(F,...
0138           'Style','Pushbutton','String','Edit',...
0139           'ToolTipString','Edit - press after selecting an event type',...
0140           'ForegroundColor','k',...
0141           'Tag','eEdit','UserData',0,...
0142           'Callback',[cb 'ui_event_types_cb(et_D, ''Edit'')'] ,...
0143           'Interruptible','off','BusyAction','Cancel',...
0144           'Position',[button_x buttons_y(4) button_sz].*WS);
0145 
0146 % New
0147 uicontrol(F,...
0148       'Style','Pushbutton','String','New',...
0149       'ToolTipString','New - create new event type',...
0150       'ForegroundColor','k',...
0151       'Tag','New','UserData',-1,...
0152       'Callback',[cb 'ui_event_types_cb(et_D, ''New'')'] ,...
0153       'Interruptible','off','BusyAction','Cancel',...
0154       'Position',[button_x buttons_y(5) button_sz].*WS);
0155 
0156 % Event type list
0157 et = event_types(D);
0158 if isfield(et, 'name')
0159   eNames = {et(:).name};
0160 else
0161   eNames = {};
0162 end
0163 
0164 hList = uicontrol(F,'Style','ListBox','Tag','eList',...
0165           'ToolTipString',['Select events(s) - drag/shift-click',...
0166             '/ctrl-click to select multiple events'],...
0167           'String',eNames,...
0168           'Max',2,...
0169           'CallBack', '' ,...
0170           'Interruptible','off','BusyAction','Queue',...
0171           'BackgroundColor','w',...
0172           'Position',[elist_pos elist_sz].*WS);
0173 
0174 return

Generated on Wed 11-May-2022 16:26:09 by m2html © 2003-2019