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

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

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

Initial import of Stark code.

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