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