source: aedes_inputdlg.m @ 162

Last change on this file since 162 was 155, checked in by tjniskan, 8 years ago
  • Added support for multiple monitor systems

M aedes_inputdlg.m
M aedes_roi_copy_gui.m
A aedes_dialoglocation.m
M aedes_readfidprefs.m
M aedes_rotateflip.m
M aedes_resviewer.m
M aedes.m
M aedes_helpabout.m
M plugins/fat_analysis.m
M plugins/copy_data_to_workspace.m
M aedes_export_gui.m
M aedes_headerbrowser.m
M aedes_revision.m
M aedes_juigetfiles.m
M aedes_editstack.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  '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% Set focus to editbox
117uicontrol(edit_h);
118
119%% Wait for dialog figure
120uiwait(fh);
121
122if ishandle(fh)
123    Resp={};
124    if get(fh,'UserData')
125          Resp={get(edit_h,'string')};
126    end
127    delete(fh);
128else
129    Resp={};
130end
131
132
133%%%%%%%%%%%%%%%%%%%%%%%%%%%%
134% Subfunctions
135%%%%%%%%%%%%%%%%%%%%%%%%%%%%
136function l_KeyPressFcn(h,evd)
137switch(evd.Key)
138 case {'return'}
139   % Make sure that text visible in the editbox is registered
140   uicontrol(findall(gcbf,'style','text'))
141   uicontrol(findall(gcbf,'style','edit'))
142   set(gcbf,'userdata',true);
143   uiresume(gcbf);
144 case {'escape'}
145  delete(gcbf);
146end
147
148
149function l_OKButtonPressed(h,evd)
150
151set(gcbf,'userdata',true)
152uiresume(gcbf)
153
154function l_CancelButtonPressed(h,evd)
155
156delete(gcbf)
157
158
Note: See TracBrowser for help on using the repository browser.

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