📄 helpgui.m
字号:
function helpgui(titleStr,helpStr1,helpStr2,helpStr3);
%HELPGUI Utility function for displaying help in ADSP GUIs.
% ADSP Toolbox: Version 2.0
% For use with "Analog and Digital Signal Processing", 2nd Ed.
% Published by PWS Publishing Co.
%
% Ashok Ambardar, EE Dept. MTU, Houghton, MI 49931, USA
% http://www.ee.mtu/faculty/akambard.html
% e-mail: akambard@mtu.edu
% Copyright (c) 1998
numPages=nargin-1;
if nargin<4,
helpStr3=' ';
end;
if nargin<3,
helpStr2=' ';
end;
% Find matlab version
%ver_str = version;
ver4=0; %ver4=length(findstr('4.',ver_str));
% First turn on the watch pointer in the old figure
oldFigNumber=watchon;
%Fix mouse motion callback error with cursor or ctcon turned on
if ~isnan(oldFigNumber)
set(oldFigNumber,'windowbuttonmotionfcn','');
end
name_str='ADSP TOOLBOX Help Window';
figNumber = [];
existFlag = 0;
rchi = get(0,'Children');
for i = 1:length(rchi),
if strcmp(get(rchi(i),'type'),'figure'), % If the object is a figure
figureName=get(rchi(i),'Name');
if strcmp(figureName,name_str),
figNumber = [figNumber rchi(i)];
existFlag = 1;
end
end
end
newHelpWindowFlag=~existFlag;
if newHelpWindowFlag,
position=get(0,'DefaultFigurePosition');
position(3:4)=[450 380];
if ver4
figNumber=figure( ...
'Name',name_str, ...
'NumberTitle','off', ...
'NextPlot','new', ...
'Visible','off', ...
'Position',position, ...
'Menubar','none', ...
'Colormap',[]);
else
figNumber=figure( ...
'Name',name_str, ...
'NumberTitle','off', ...
'Visible','off', ...
'Position',position, ...
'Menubar','none', ...
'Colormap',[]);
end
%===================================
% Set up the Help Window
top=0.95;
left=0.05;
right=0.75;
bottom=0.05;
labelHt=0.05;
spacing=0.005;
% First, the Text Window frame
frmBorder=0.02;
frmPos=[left-frmBorder bottom-frmBorder ...
(right-left)+2*frmBorder (top-bottom)+2*frmBorder];
uicontrol( ...
'Style','frame', ...
'Units','normalized', ...
'Position',frmPos, ...
'BackgroundColor',[0.5 0.5 0.5]);
% Then the text label
labelPos=[left top-labelHt (right-left) labelHt];
ttlHndl=uicontrol( ...
'Style','text', ...
'Units','normalized', ...
'Position',labelPos, ...
'BackgroundColor',[0.5 0.5 0.5], ...
'ForegroundColor',[1 1 1], ...
'String',titleStr);
% Then the editable text field (of which there are three)
% Store the text field's handle two places: once in the figure
% UserData and once in the button's UserData.
for count=1:3,
helpStr=eval(['helpStr',num2str(count)]);
txtPos=[left bottom (right-left) top-bottom-labelHt-spacing];
% if ver4
% txtHndlList(count)=uicontrol( ...
% 'Style','edit', ...
% 'HorizontalAlignment','left', ...
% 'Units','normalized', ...
% 'Max',20, ...
% 'String',helpStr, ...
% 'BackgroundColor',[1 1 1], ...
% 'Visible','off', ...
% 'Position',txtPos);
% else
txtHndlList(count)=uicontrol( ...
'Style','edit', ...
'HorizontalAlignment','left', ...
'Units','normalized', ...
'Max',20, ...
'String',helpStr, ...
'BackgroundColor',[1 1 1], ...
'Visible','off', ...
'Position',txtPos);
% end
% if ver4,set(txtHndlList(count),'Style','edit');end
if ~ver4,set(txtHndlList(count),'Fontsize',11);end
end;
set(txtHndlList(1),'Visible','on');
%====================================
% Information for all buttons
labelColor=[0.8 0.8 0.8];
top=0.95;
bottom=0.05;
yInitPos=0.80;
left=0.80;
btnWid=0.15;
btnHt=0.10;
% Spacing between the button and the next command's label
spacing=0.05;
%====================================
% The CONSOLE frame
frmBorder=0.02;
yPos=bottom-frmBorder;
frmPos=[left-frmBorder yPos btnWid+2*frmBorder 0.9+2*frmBorder];
uicontrol( ...
'Style','frame', ...
'Units','normalized', ...
'Position',frmPos, ...
'BackgroundColor',[0.5 0.5 0.5]);
%====================================
% All required BUTTONS
for count=1:3
% The PAGE button
labelStr=['Page ',num2str(count)];
% The callback will turn off ALL text fields and then turn on
% only the one referred to by the button.
callbackStr= ...
['txtHndl=get(gco,''UserData'');' ...
'hndlList=get(gcf,''UserData'');' ...
'set(hndlList(2:4),''Visible'',''off'');' ...
'set(txtHndl,''Visible'',''on'');'];
btnHndlList(count)=uicontrol( ...
'Style','pushbutton', ...
'Units','normalized', ...
'Position',[left top-btnHt-(count-1)*(btnHt+spacing) btnWid btnHt], ...
'String',labelStr, ...
'UserData',txtHndlList(count), ...
'Visible','off', ...
'Callback',callbackStr);
end;
%====================================
% The CLOSE button
% callbackStr= ...
% ['f1=gcf; f2=gpf; set(f1,''Visible'',''off'');', ...
% 'if f1~=f2, figure(f2); end'];
% NEW FIX%%%%%%%%%
callbackStr= ...
['f1=gcf; set(f1,''Visible'',''off'');'];
uicontrol( ...
'Style','pushbutton', ...
'Units','normalized', ...
'Position',[left 0.05 btnWid 0.10], ...
'String','Close', ...
'Callback',callbackStr);
hndlList=[ttlHndl txtHndlList btnHndlList];
set(figNumber,'UserData',hndlList)
end;
% Now that we've determined the figure number, we can install the
% Desired strings.
hndlList=get(figNumber,'UserData');
ttlHndl=hndlList(1);
txtHndlList=hndlList(2:4);
btnHndlList=hndlList(5:7);
set(ttlHndl,'String',titleStr);
set(txtHndlList(2:3),'Visible','off');
set(txtHndlList(1),'Visible','on');
set(txtHndlList(1),'String',helpStr1);
set(txtHndlList(2),'String',helpStr2);
set(txtHndlList(3),'String',helpStr3);
if numPages==1,
set(btnHndlList,'Visible','off');
elseif numPages==2,
set(btnHndlList,'Visible','off');
set(btnHndlList(1:2),'Visible','on');
elseif numPages==3,
set(btnHndlList(1:3),'Visible','on');
end;
set(figNumber,'Visible','on');
% Turn off the watch pointer in the old figure
watchoff(oldFigNumber);
if ~ver4,set(figNumber,'HandleVisibility','callback');end
figure(figNumber);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -