source: an2_inputdlg.m @ 63

Last change on this file since 63 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
Line 
1function Resp=an2_inputdlg(prompt_str,title_str,default_answer)
2% AN2_INPUTDLG - Input dialog box
3%   
4%
5% Synopsis:
6%        Resp=an2_inputdlg(prompt_str,title_str,default_answer)
7%
8% Description:
9%
10%
11% Examples:
12%
13% See also:
14%        AEDES
15
16% This function is a part of Aedes - A graphical tool for analyzing
17% medical images
18%
19% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
20%
21% Department of Physics, Department of Neurobiology
22% University of Kuopio, FINLAND
23%
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.
28%
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.
31
32
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!')
44end
45
46if iscell(default_answer)
47  default_answer = default_answer{1};
48end
49
50Resp = {};
51
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];
58
59
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');
72
73
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');
83
84
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');
95
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);
104
105
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);
114
115
116
117
118%% Wait for dialog figure
119uiwait(fh);
120
121if ishandle(fh)
122    Resp={};
123    if get(fh,'UserData')
124          Resp={get(edit_h,'string')};
125    end
126    delete(fh);
127else
128    Resp={};
129end
130
131
132%%%%%%%%%%%%%%%%%%%%%%%%%%%%
133% Subfunctions
134%%%%%%%%%%%%%%%%%%%%%%%%%%%%
135function l_KeyPressFcn(h,evd)
136switch(evd.Key)
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);
143 case {'escape'}
144  delete(gcbf);
145end
146
147
148function l_OKButtonPressed(h,evd)
149
150set(gcbf,'userdata',true)
151uiresume(gcbf)
152
153function l_CancelButtonPressed(h,evd)
154
155delete(gcbf)
156
157
Note: See TracBrowser for help on using the repository browser.

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