source: aedes_inputdlg.m @ 131

Last change on this file since 131 was 83, checked in by tjniskan, 10 years ago
  • A small bug fix to misclib/fmri_analysis.m
  • Made the figure a bit larger in aedes_inputdlg.m
  • Added a plugin for fat/water analysis
  • Added support for the fat/water measurements in aedes_readfid.m

M misclib/fmri_analysis.m
M aedes_inputdlg.m
A plugins/fat_analysis.m
M aedes_readfid.m
M aedes_revision.m

File size: 3.6 KB
Line 
1function Resp=aedes_inputdlg(prompt_str,title_str,default_answer)
2% AEDES_INPUTDLG - Input dialog box
3%   
4%
5% Synopsis:
6%        Resp=aedes_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 = aedes_gui_defaults;
54scrsz = get(0,'screensize');
55fig_w=215;
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