source: aedes_inputdlg.m

Last change on this file was 213, checked in by tjniskan, 4 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
RevLine 
[80]1function Resp=aedes_inputdlg(prompt_str,title_str,default_answer)
2% AEDES_INPUTDLG - Input dialog box
[36]3%   
[15]4%
[36]5% Synopsis:
[80]6%        Resp=aedes_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 = {};
[155]51callerFig = gcbf;
[2]52
[36]53%% Dialog figure -------------------
[80]54GD = aedes_gui_defaults;
[83]55fig_w=215;
[36]56fig_h=85;
[155]57fig_location = aedes_dialoglocation([fig_w,fig_h]);
58fig_pos = [fig_location(1) fig_location(2) fig_w fig_h];
[2]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  'userdata',false,...
70  'resize','off');
[213]71if ~GD.HG2graphics
72        set(fh,'DoubleBuffer','on')
73end
[2]74
75
[36]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');
[2]85
86
[36]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');
[2]97
[36]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);
[2]106
107
[36]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);
[2]116
117
[144]118% Set focus to editbox
119uicontrol(edit_h);
[2]120
[36]121%% Wait for dialog figure
122uiwait(fh);
[2]123
[36]124if ishandle(fh)
125    Resp={};
126    if get(fh,'UserData')
127          Resp={get(edit_h,'string')};
[2]128    end
[36]129    delete(fh);
130else
131    Resp={};
[2]132end
133
134
[36]135%%%%%%%%%%%%%%%%%%%%%%%%%%%%
136% Subfunctions
137%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138function l_KeyPressFcn(h,evd)
[2]139switch(evd.Key)
[36]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);
[2]146 case {'escape'}
147  delete(gcbf);
148end
149
150
[36]151function l_OKButtonPressed(h,evd)
[2]152
[36]153set(gcbf,'userdata',true)
154uiresume(gcbf)
[2]155
[36]156function l_CancelButtonPressed(h,evd)
[2]157
[36]158delete(gcbf)
[2]159
160
Note: See TracBrowser for help on using the repository browser.

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