NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/gliderproc/trunk/MATLAB/opnml/basics/helpfun2.m

Revision 495 (checked in by cbc, 11 years ago)

Initial import of Stark code.

Line 
1 function helpfun2(figName,titleStr,helpStr1,helpStr2,helpStr3,helpStr4,helpStr5);
2 % HELPFUN2 Utility function for displaying help text conveniently.
3 %
4 %       Ned Gulley, 6-21-93
5 %       Copyright (c) 1984-94 by The MathWorks, Inc.
6 %
7 % July, 1995, Mod by Brian Blanton to accept generic window name
8 % and upto 5 pages of message text.
9 %
10
11 if nargin<3
12    disp('3 args REQUIRED for helpfun2')
13    return;
14 end
15 numPages=nargin-2;
16 if nargin<7,
17     helpStr5=' ';
18 end
19 if nargin<6,
20     helpStr4=' ';
21 end
22 if nargin<5,
23     helpStr3=' ';
24 end
25 if nargin<4,
26     helpStr2=' ';
27 end
28
29 % If the Help Window has already been created, bring it to the front
30 [existFlag,figNumber]=figflag(figName,1);
31 newHelpWindowFlag=~existFlag;
32
33 if newHelpWindowFlag,
34     position=get(0,'DefaultFigurePosition');
35     position(3:4)=[550 450];
36     figNumber=figure('Name',figName, ...
37                      'NumberTitle','off', ...
38                      'NextPlot','new', ...
39                      'Visible','off', ...
40                      'Position',position, ...
41                      'Colormap',[],...
42                      'Tag',figName);
43
44     %===================================
45     % Set up the Help Window
46     top=0.95;
47     left=0.05;
48     right=0.75;
49     bottom=0.05;
50     labelHt=0.05;
51     spacing=0.005;
52
53     % First, the Text Window frame
54     frmBorder=0.02;
55     frmPos=[left-frmBorder bottom-frmBorder ...
56         (right-left)+2*frmBorder (top-bottom)+2*frmBorder];
57     uicontrol( ...
58         'Style','frame', ...
59         'Units','normalized', ...
60         'Position',frmPos, ...
61         'BackgroundColor',[0.5 0.5 0.5]);
62     % Then the text label
63     labelPos=[left top-labelHt (right-left) labelHt];
64     ttlHndl=uicontrol( ...
65         'Style','text', ...
66         'Units','normalized', ...
67         'Position',labelPos, ...
68         'BackgroundColor',[0.5 0.5 0.5], ...
69         'ForegroundColor',[1 1 1], ...
70         'String',titleStr);
71     % Then the editable text field (of which there are three)
72     % Store the text field's handle two places: once in the figure
73     % UserData and once in the button's UserData.
74     for count=1:5,
75         helpStr=eval(['helpStr',num2str(count)]);
76         txtPos=[left bottom (right-left) top-bottom-labelHt-spacing];
77         txtHndlList(count)=uicontrol( ...
78             'Style','edit', ...
79             'Units','normalized', ...
80             'Max',20, ...
81             'String',helpStr, ...
82             'BackgroundColor',[1 1 1], ...
83             'Visible','off', ...
84             'Position',txtPos);
85     end;
86     set(txtHndlList(1),'Visible','on');
87
88     %====================================
89     % Information for all buttons
90     labelColor=[0.8 0.8 0.8];
91     top=0.95;
92     bottom=0.05;
93     yInitPos=0.80;
94     left=0.80;
95     btnWid=0.15;
96     btnHt=0.10;
97     % Spacing between the button and the next command's label
98     spacing=0.05;
99
100     %====================================
101     % The CONSOLE frame
102     frmBorder=0.02;
103     yPos=bottom-frmBorder;
104     frmPos=[left-frmBorder yPos btnWid+2*frmBorder 0.9+2*frmBorder];
105     uicontrol( ...
106         'Style','frame', ...
107         'Units','normalized', ...
108         'Position',frmPos, ...
109         'BackgroundColor',[0.5 0.5 0.5]);
110
111     %====================================
112     % All required BUTTONS
113     for count=1:5
114         % The PAGE button
115         labelStr=['Page ',num2str(count)];
116         % The callback will turn off ALL text fields and then turn on
117         % only the one referred to by the button.
118         callbackStr= ...
119            ['txtHndl=get(gco,''UserData'');' ...
120             'hndlList=get(gcf,''UserData'');' ...
121             'set(hndlList(2:6),''Visible'',''off'');' ...
122             'set(txtHndl,''Visible'',''on'');'];
123         btnHndlList(count)=uicontrol( ...
124             'Style','pushbutton', ...
125             'Units','normalized', ...
126             'Position',[left top-btnHt-(count-1)*(btnHt+spacing) btnWid btnHt], ...
127             'String',labelStr, ...
128             'UserData',txtHndlList(count), ...
129             'Visible','off', ...
130             'Callback',callbackStr);
131     end;
132
133     %====================================
134     % The CLOSE button ; changed by BOB to terminate the help window
135     callbackStr=['delete(gcf)'];
136 %    callbackStr= ...
137 %       ['f1=gcf; f2=gpf; set(f1,''Visible'',''off'');', ...
138 %        'if f1~=f2, figure(f2); end'];
139     uicontrol( ...
140         'Style','pushbutton', ...
141         'Units','normalized', ...
142         'Position',[left 0.05 btnWid 0.10], ...
143         'String','Close', ...
144         'Callback',callbackStr);
145
146     hndlList=[ttlHndl txtHndlList btnHndlList];
147        
148     set(figNumber,'UserData',hndlList)
149 end;
150
151 % Now that we've determined the figure number, we can install the
152 % Desired strings.
153 hndlList=get(figNumber,'UserData');
154 ttlHndl=hndlList(1);
155 txtHndlList=hndlList(2:6);
156 btnHndlList=hndlList(7:11);
157 set(ttlHndl,'String',titleStr);
158 set(txtHndlList(2:3),'Visible','off');
159 set(txtHndlList(1),'Visible','on');
160 set(txtHndlList(1),'String',helpStr1);
161 set(txtHndlList(2),'String',helpStr2);
162 set(txtHndlList(3),'String',helpStr3);
163 set(txtHndlList(4),'String',helpStr4);
164 set(txtHndlList(5),'String',helpStr5);
165
166 if numPages==1,
167     set(btnHndlList,'Visible','off');
168 elseif numPages==2,
169     set(btnHndlList,'Visible','off');
170     set(btnHndlList(1:2),'Visible','on');
171 elseif numPages==3,
172     set(btnHndlList,'Visible','off');
173     set(btnHndlList(1:3),'Visible','on');
174 elseif numPages==4,
175     set(btnHndlList,'Visible','off');
176     set(btnHndlList(1:4),'Visible','on');
177 elseif numPages==5,
178     set(btnHndlList,'Visible','off');
179     set(btnHndlList(1:5),'Visible','on');
180 end;
181
182 set(figNumber,'Visible','on');
183 figure(figNumber);
Note: See TracBrowser for help on using the browser.