source: aedes_inputdlg.m

Last change on this file was 213, checked in by tjniskan, 2 years ago
  • Fixed Aedes for Handle Graphics version 2 (HG2).

M aedes.m
M aedes_createmosaic.m
M aedes_export_gui.m
M aedes_gui_defaults.m
M aedes_headerbrowser.m
M aedes_helpabout.m
M aedes_inputdlg.m
M aedes_juigetfiles.m
M aedes_readfidprefs.m
M aedes_resviewer.m
M aedes_revision.m

File size: 3.7 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 = {};
51callerFig = gcbf;
52
53%% Dialog figure -------------------
54GD = aedes_gui_defaults;
55fig_w=215;
56fig_h=85;
57fig_location = aedes_dialoglocation([fig_w,fig_h]);
58fig_pos = [fig_location(1) fig_location(2) fig_w fig_h];
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  'userdata',false,...
70  'resize','off');
71if ~GD.HG2graphics
72        set(fh,'DoubleBuffer','on')
73end
74
75
76%% Title ---------------------------
77title_h = uicontrol('parent',fh,...
78  'units','pixels',...
79  'position',[5 fig_h-20 fig_w-10 15],...
80  'string',prompt_str,...
81  'backgroundcolor',GD.col.frame,...
82  'style','text',...
83  'KeyPressFcn',@l_KeyPressFcn, ...
84  'horizontalalign','left');
85
86
87%% Edit box ------------------------
88tmp = get(title_h,'position');
89edit_h = uicontrol('parent',fh,...
90  'units','pixels',...
91  'position',[tmp(1) tmp(2)-25 tmp(3) 25],...
92  'string',default_answer,...
93  'style','edit',...
94  'horizontalalign','left',...
95  'KeyPressFcn',@l_KeyPressFcn, ...
96  'backgroundcolor','w');
97
98%% Cancel button -------------------
99tmp = get(edit_h,'position');
100cancelbtn_h = uicontrol('parent',fh,...
101  'units','pixels',...
102  'position',[tmp(1)+tmp(3)-60 tmp(2)-35 60 30],...
103  'String','Cancel',...
104  'KeyPressFcn',@l_KeyPressFcn, ...
105  'Callback',@l_CancelButtonPressed);
106
107
108%% OK-button -----------------------
109tmp = get(cancelbtn_h,'position');
110okbtn_h = uicontrol('parent',fh,...
111  'units','pixels',...
112  'position',[tmp(1)-60-5 tmp(2) tmp(3:4)],...
113  'String','OK',...
114  'KeyPressFcn',@l_KeyPressFcn, ...
115  'Callback',@l_OKButtonPressed);
116
117
118% Set focus to editbox
119uicontrol(edit_h);
120
121%% Wait for dialog figure
122uiwait(fh);
123
124if ishandle(fh)
125    Resp={};
126    if get(fh,'UserData')
127          Resp={get(edit_h,'string')};
128    end
129    delete(fh);
130else
131    Resp={};
132end
133
134
135%%%%%%%%%%%%%%%%%%%%%%%%%%%%
136% Subfunctions
137%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138function l_KeyPressFcn(h,evd)
139switch(evd.Key)
140 case {'return'}
141   % Make sure that text visible in the editbox is registered
142   uicontrol(findall(gcbf,'style','text'))
143   uicontrol(findall(gcbf,'style','edit'))
144   set(gcbf,'userdata',true);
145   uiresume(gcbf);
146 case {'escape'}
147  delete(gcbf);
148end
149
150
151function l_OKButtonPressed(h,evd)
152
153set(gcbf,'userdata',true)
154uiresume(gcbf)
155
156function l_CancelButtonPressed(h,evd)
157
158delete(gcbf)
159
160
Note: See TracBrowser for help on using the repository browser.

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