source: an2_inputdlg.m @ 45

Last change on this file since 45 was 45, checked in by tjniskan, 11 years ago
  • Changed a small thing in license notices

M an2_export_gui.m
M an2_cellsprintf.m
M an2_getfilefilter.m
M an2_calc_wait.m
M an2_smiswrite.m
M misclib/spectrsum.m
M misclib/shiftind.m
M misclib/nifti4dto3d.m
M misclib/nifti3dto4d.m
M misclib/dcm_info.m
M misclib/addicon.m
M misclib/makelcmraw.m
M an2_check_file_exist.m
M an2_iseven.m
M an2_cellwrite.m
M an2_wbar.m
M an2_rot3d.m
M an2_readfdf.m
M an2_revision.m
M an2_viewprocpar.m
M an2_checkcthdr.m
M an2_readprocpar.m
M an2_fitmaps.m
M an2_read_nifti.m
M an2_data_read.m
M an2_smisread.m
M an2_resviewer.m
M an2_maptool.m
M aedes.m
M an2_helpabout.m
M an2_res2table.m
M an2_copy_roi.m
M plugins/save_roi_as_mask.m
M plugins/write_difference_images.m
M plugins/plot_profile.m
M plugins/calculate_t2_map.m
M plugins/calculate_t1r_map.m
M plugins/view_kspace.m
M plugins/copy_data_to_workspace.m
M plugins/take_snapshot.m
M an2_inputdlg.m
M an2_roi_copy_gui.m
M an2_readctdata.m
M an2_readfid.m
M an2_readfidprefs.m
M an2_readtab.m
M an2_check_updates.m
M an2_killfigs.m
M an2_roi_stats.m
M an2_saveres.m
M an2_rotateflip.m
M an2_juigetfiles.m
M an2_gui_defaults.m
M an2_editstack.m
M an2_errordump.m
M an2_update.m
M an2_write_nifti.m

File size: 3.6 KB
RevLine 
[36]1function Resp=an2_inputdlg(prompt_str,title_str,default_answer)
2% AN2_INPUTDLG - Input dialog box
3%   
[15]4%
[36]5% Synopsis:
6%        Resp=an2_inputdlg(prompt_str,title_str,default_answer)
[15]7%
[36]8% Description:
[15]9%
[2]10%
[36]11% Examples:
[2]12%
[36]13% See also:
[37]14%        AEDES
[36]15
[37]16% This function is a part of Aedes - A graphical tool for analyzing
[36]17% medical images
[2]18%
[36]19% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
20%
[45]21% Department of Physics, Department of Neurobiology
[39]22% University of Kuopio, FINLAND
[2]23%
[36]24% This program may be used under the terms of the GNU General Public
25% License version 2.0 as published by the Free Software Foundation
26% and appearing in the file LICENSE.TXT included in the packaging of
27% this program.
[2]28%
[36]29% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
30% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
[2]31
32
[36]33if nargin==0
34  prompt_str = 'Input:';
35  title_str = '';
36  default_answer = '';
37elseif nargin==1
38  title_str = '';
39  default_answer = '';
40elseif nargin==2
41  default_answer = '';
42elseif nargin>3
43  error('Too many input arguments!')
[2]44end
45
[36]46if iscell(default_answer)
47  default_answer = default_answer{1};
[2]48end
49
[36]50Resp = {};
[2]51
[36]52%% Dialog figure -------------------
53GD = an2_gui_defaults;
54scrsz = get(0,'screensize');
55fig_w=175;
56fig_h=85;
57fig_pos = [scrsz(3)/2-fig_w/2 scrsz(4)/2-fig_h/2 fig_w fig_h];
[2]58
59
[36]60fh=dialog('position',fig_pos,...
61  'Visible','on', ...
62  'KeyPressFcn',@l_KeyPressFcn, ...
63  'Name',title_str, ...
64  'Pointer','arrow', ...
65  'Units','pixels', ...
66  'HandleVisibility','callback', ...
67  'Color',GD.col.frame, ...
68  'WindowStyle','modal', ...
69  'DoubleBuffer','on',...
70  'userdata',false,...
71  'resize','off');
[2]72
73
[36]74%% Title ---------------------------
75title_h = uicontrol('parent',fh,...
76  'units','pixels',...
77  'position',[5 fig_h-20 fig_w-10 15],...
78  'string',prompt_str,...
79  'backgroundcolor',GD.col.frame,...
80  'style','text',...
81  'KeyPressFcn',@l_KeyPressFcn, ...
82  'horizontalalign','left');
[2]83
84
[36]85%% Edit box ------------------------
86tmp = get(title_h,'position');
87edit_h = uicontrol('parent',fh,...
88  'units','pixels',...
89  'position',[tmp(1) tmp(2)-25 tmp(3) 25],...
90  'string',default_answer,...
91  'style','edit',...
92  'horizontalalign','left',...
93  'KeyPressFcn',@l_KeyPressFcn, ...
94  'backgroundcolor','w');
[2]95
[36]96%% Cancel button -------------------
97tmp = get(edit_h,'position');
98cancelbtn_h = uicontrol('parent',fh,...
99  'units','pixels',...
100  'position',[tmp(1)+tmp(3)-60 tmp(2)-35 60 30],...
101  'String','Cancel',...
102  'KeyPressFcn',@l_KeyPressFcn, ...
103  'Callback',@l_CancelButtonPressed);
[2]104
105
[36]106%% OK-button -----------------------
107tmp = get(cancelbtn_h,'position');
108okbtn_h = uicontrol('parent',fh,...
109  'units','pixels',...
110  'position',[tmp(1)-60-5 tmp(2) tmp(3:4)],...
111  'String','OK',...
112  'KeyPressFcn',@l_KeyPressFcn, ...
113  'Callback',@l_OKButtonPressed);
[2]114
115
116
117
[36]118%% Wait for dialog figure
119uiwait(fh);
[2]120
[36]121if ishandle(fh)
122    Resp={};
123    if get(fh,'UserData')
124          Resp={get(edit_h,'string')};
[2]125    end
[36]126    delete(fh);
127else
128    Resp={};
[2]129end
130
131
[36]132%%%%%%%%%%%%%%%%%%%%%%%%%%%%
133% Subfunctions
134%%%%%%%%%%%%%%%%%%%%%%%%%%%%
135function l_KeyPressFcn(h,evd)
[2]136switch(evd.Key)
[36]137 case {'return'}
138   % Make sure that text visible in the editbox is registered
139   uicontrol(findall(gcbf,'style','text'))
140   uicontrol(findall(gcbf,'style','edit'))
141   set(gcbf,'userdata',true);
142   uiresume(gcbf);
[2]143 case {'escape'}
144  delete(gcbf);
145end
146
147
[36]148function l_OKButtonPressed(h,evd)
[2]149
[36]150set(gcbf,'userdata',true)
151uiresume(gcbf)
[2]152
[36]153function l_CancelButtonPressed(h,evd)
[2]154
[36]155delete(gcbf)
[2]156
157
Note: See TracBrowser for help on using the repository browser.

Powered by Trac 1.0.9.Copyright © Juha-Pekka Niskanen 2008