a b/functions/adminfunc/gettext.m
1
% GETTEXT - This function prints a dialog box on screen and waits for 
2
%             the user to enter a string. There is a cancel button which 
3
%             returns a value of [].
4
% Usage:
5
%   >> out = gettext(label1,label2,...,label7);
6
%
7
% Author: Colin Humphries, CNL / Salk Institute, La Jolla, 1997
8
9
% Copyright (C) 1997 Colin Humphries, Salk Institute 
10
%
11
% This file is part of EEGLAB, see http://www.eeglab.org
12
% for the documentation and details.
13
%
14
% Redistribution and use in source and binary forms, with or without
15
% modification, are permitted provided that the following conditions are met:
16
%
17
% 1. Redistributions of source code must retain the above copyright notice,
18
% this list of conditions and the following disclaimer.
19
%
20
% 2. Redistributions in binary form must reproduce the above copyright notice,
21
% this list of conditions and the following disclaimer in the documentation
22
% and/or other materials provided with the distribution.
23
%
24
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27
% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
28
% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29
% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30
% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31
% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32
% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
34
% THE POSSIBILITY OF SUCH DAMAGE.
35
36
% 01-25-02 reformated help & license -ad 
37
38
function out = gettext(label1,label2,label3,label4,label5,label6,label7);
39
40
global is_text_entered
41
is_text_entered = 0;
42
43
for i = 1:nargin
44
   eval(['leng(i) = length(label',num2str(i),');'])
45
end
46
figurelength = 15*1.0*max(leng);
47
48
if figurelength < 240
49
   figurelength = 290;
50
end
51
52
figureheight = 80+nargin*18;
53
% Set figure
54
55
figure('Position',[302 396 figurelength figureheight],'color',[.6 .6 .6],'NumberTitle','off')
56
f1 = gcf;
57
58
ax = axes('Units','Pixels','Position',[0 0 figurelength figureheight],'Visible','off','XLim',[0 figurelength],'YLim',[0 figureheight]);
59
60
for i = 1:nargin
61
62
   eval(['text(figurelength/2,',num2str(figureheight-(i-1)*18-20),',label',num2str(i),',''color'',''k'',''FontSize'',16,''HorizontalAlignment'',''center'')'])
63
64
end
65
% Set up uicontrols
66
67
TIMESTRING = ['global is_text_entered;is_text_entered = 1;clear is_text_entered'];
68
69
u = uicontrol('Style','Edit','Units','Pixels','Position',[15 20 figurelength-95 25],'HorizontalAlignment','left','Callback',TIMESTRING);
70
71
TIMESTRING = ['global is_text_entered;is_text_entered = 2;clear is_text_entered'];
72
v = uicontrol('Style','Pushbutton','Units','Pixels','Position',[figurelength-70 20 55 25],'String','Cancel','Callback',TIMESTRING);
73
74
75
while(is_text_entered == 0)
76
   drawnow
77
end
78
79
80
if is_text_entered == 1
81
   out = get(u,'string');
82
else
83
   out = [];
84
end
85
86
87
clear is_text_entered
88
delete(f1)
89