📄 helpwin2.m
字号:
function helpwin2(topic,pagetitle,helptitle,varargin)%HELPWIN2 On-line second help text, separate window for navigation.% HELPWIN2 TOPIC opens a help window and displays the second help text for the% given TOPIC. Links are created to functions referenced in the 'See Also'% line of the help text.%% The second help text of an M-file is the second consecutive block of% lines beginning with the '%' character.%% HELPWIN2(HELP_STR,TITLE) displays the string HELP_STR in the help% window. HELP_STR may be passed in as a string with each line separated% by carriage returns, a column vector cell array of strings with each cell% (row) representing a line or as a string matrix with each row representing% a line. The optional string TITLE will appear in the title edit box.%% HELPWIN2({TITLE1 HELP_STR1;TITLE2 HELP_STR2;...},PAGE) displays one page% of multi-page help text. The multi-page help text is passed in as a% cell array of strings or cells containing TITLE and HELP_STR pairs.% Each row of the multi-page help text cell array (dimensioned number of% pages by 2) consists of a title string paired with a string, cell array% or string matrix of help text. The second argument PAGE is a string % which must match one of the TITLE entries in the multi-page help text.% The matching TITLE represents the page that is to be displayed first.% If no second argument is given, the first page is displayed.%% A third argument may be passed to HELPWIN2 which is a string that becomes% the title of the help window figure.%% Additional arguments, after the window title, will be interpreted as% Handle Graphics parameter-value pairs to be applied to the text displayed% in the help window.%% Examples.% helpwin2 plot% helpwin2('Help String','title')% helpwin2(['Help text for' sprintf('\n') 'my m-file.'],'title')% helpwin2({'Help String for';'my m-file'},'title')% helpwin2(str,'Topic 2','My Title')% where,% str = { 'Topic 1' 'Help string for Topic 1';% 'Topic 2' 'Help string for Topic 2';% 'Topic 3' 'Help string for Topic 3' }%% This function is a modified version of the matlab function "helpwin".% To set up "See also" links, Use the string "See also" followed by the % reference function names on the same line or the next line. The string% "See also" must be the last among all such strings in the help text.% The reference function names can consist of letters, either all lower% case or all upper case, underscore and digits.%% See also DOC, DOCOPT, HELP, WEB.% Copyright (c) 1984-98 by The MathWorks, Inc.% $Revision: 1.4 $useListboxFlag = 1; % The original use is useListboxFlag = 1, a list box. When choosing useListboxFlag = 0, you can experiment with a axis where you can display Tex characters (not finnished).% If no arguments are given, load up the Home help page.if nargin==0 topic = 'HelpwinHome';end% Switchyard on 'topic'. It is either a command or a help entry.if iscell(topic), cmd = char(topic(1,1));else cmd = char(topic(1,:));endswitch cmd%-----------------------------------------------------------------------case 'HelpwinPage' % This case is used to link a page to others pages in the text entry. TopicPop = gcbo; val = get(TopicPop,'value'); if val~=1 refstr = get(TopicPop,'string'); ref = deblank(refstr{val}); topic = get(TopicPop,'userdata'); helpwin2(topic,ref); end%-----------------------------------------------------------------------case 'HelpwinSeealso' % This case is used to link a page to others referenced in the % See Also text. SeeAlsoPop = gcbo; val = get(SeeAlsoPop,'value'); if val~=1 set(SeeAlsoPop,'value',1); refstr = get(SeeAlsoPop,'string'); ref = deblank(refstr{val}); str = sscanf(ref,xlate('More %s help (HTML)')); if ~isempty(str) doc(str); else helpwin2(ref); end end %-----------------------------------------------------------------------case 'HelpwinBack' % This case is used to go back one page in the stack. BackBtn = gcbo; fig = gcbf; fud = get(fig,'UserData'); pgtitle = get(findobj(fig,'tag','CurHelpEdit'),'string'); if pgtitle(1) == ' ', pgtitle(1) = []; end % remove first char if space match = max(strmatch(pgtitle,{fud.pagetitle},'exact')); ref = fud(match+1); set(BackBtn,'UserData',1); % set flag to indicate Back call helpwin2(ref.topic,ref.pagetitle,ref.helptitle); %-----------------------------------------------------------------------case 'HelpwinForward' % This case is used to go forward one page in the stack. fig = gcbf; BackBtn = findobj(fig,'Tag','BackBtn'); fud = get(fig,'UserData'); pgtitle = get(findobj(fig,'tag','CurHelpEdit'),'string'); if pgtitle(1) == ' ', pgtitle(1) = []; end % remove first char if space match = min(strmatch(pgtitle,{fud.pagetitle},'exact')); ref = fud(match-1); set(BackBtn,'UserData',1); % set flag to indicate Back/Forw call to helpwin2(ref.topic,ref.pagetitle,ref.helptitle); %-----------------------------------------------------------------------case 'HelpwinHome' % This case is used to go to the Home help screen. str = help; helpwin2({str},'MATLAB Help Topics');%-----------------------------------------------------------------------case 'HelpwinHelp12' % Toggle between first and second help text. %fig = gcbf; %Help21Radio = findobj(fig,'tag','Help21Radio'); %disp(get(Help21Radio,'value')); %-----------------------------------------------------------------------case 'HelpwinOpen' % This case is used to open another link from a double-click in % the list box. if (useListboxFlag) % Determine whether this is a double click. fig = gcbf; if strcmp(get(fig,'SelectionType'),'open') ListBox = findobj(fig,'Tag','ListBox'); SeeAlsoPop = findobj(fig,'tag','SeeAlsoPop'); ln = get(ListBox,'value'); helpstr = get(ListBox,'string'); % Check to see if we are looking at a MATLAB Tour help file if strmatch(' MATLAB Tour Partial Function Help: ',helpstr(2,:)) istour=1; tourfile=deblank(helpstr(2,38:end)); else istour=0; end % Find the function link index or the See Also index. hstr = helpstr'; hstr = lower(hstr(:)'); cols = size(helpstr,2); seealso = floor((findstr(xlate('see also'),hstr)/cols) + 1); if isempty(seealso) seealso = floor((findstr('see also',hstr)/cols) + 1); end dash = floor((findstr(' - ',hstr)/cols) + 1); % If there is a 'See Also', follow the 'See also' index if ~isempty(seealso) if ln == seealso % Determine which item in the list is a the first in the % 'See also' text list. poplist = get(SeeAlsoPop,'string'); str = sscanf(poplist{2},xlate('More %s help (HTML)')); if ~isempty(str) val = 3; else val = 2; end helpwin2(poplist{val}); % gets first reference in 'See also' list. end end % If there are dashes follow the function link. if ~isempty(dash) if any(ln == dash) loc = min(findstr('-',helpstr(ln,:))); ref = deblank(helpstr(ln,1:loc-1)); ind = min(find(isletter(ref))); ref = ref(ind:end); % Redirect links within a tour file to subfunctions if istour ref=strrep(ref,'/','_'); ref=strrep(ref,'\','_'); ref=[tourfile '/' ref]; end % Process a 'Readme' tag. if strcmp(ref,'Readme') CurHelpEdit = findobj(fig,'Tag','CurHelpEdit'); pre = deblank(get(CurHelpEdit,'string')); if (pre(1)==' '), pre(1) = []; end helpwin2([pre filesep ref]); % Else, just follow the link. else helpwin2(ref); end end end end end%if (useListboxFlag)%-----------------------------------------------------------------------case 'HelpwinHelpDesk' % This case is used to link HTML-based documentaion. doc; %-----------------------------------------------------------------------case 'HelpwinMoreHelp' % This case is used to link HTML-based documentaion. nexttopic = get(findobj(gcbf,'tag','CurHelpEdit'),'string'); if nexttopic(1) == ' ', nexttopic(1) = []; end % remove first char if space doc(nexttopic);%-----------------------------------------------------------------------case 'HelpwinResize' % This case is used to reset the position of the buttons and the % frames is the helpwin2 figure is resized. % Get the new figure position in points. fig = gcbf; pos = get(fig,'Position'); figwidth = pos(3); % Get all of the necessary handles. if (useListboxFlag) ListBox = findobj(fig,'tag','ListBox'); else ListAxis = findobj(fig,'tag','ListAxis'); ListText = findobj(fig,'tag','ListText'); end%if (UseListboxFlag) CurHelpEdit = findobj(fig,'tag','CurHelpEdit'); SeeAlsoPop = findobj(fig,'tag','SeeAlsoPop'); HomeBtn = findobj(fig,'tag','HomeBtn'); Help21Radio = findobj(fig,'tag','Help21Radio'); BackBtn = findobj(fig,'tag','BackBtn'); ForwardBtn = findobj(fig,'tag','ForwardBtn'); HelpDeskBtn = findobj(fig,'tag','HelpDeskBtn'); HelpBtn = findobj(fig,'tag','HelpBtn'); CloseBtn = findobj(fig,'tag','CloseBtn'); % Set the top frame and buttons to their correct positions. wid = 170; wid2 = 60; spc = 8; ht = 21; frmht = 54; [fname,fsize,bdr] = goodfonts(computer); set(CurHelpEdit,'Position',[spc pos(4)-frmht+ht+8 2*wid2+spc ht]); set(SeeAlsoPop,'Position',[2*wid2+3*spc pos(4)-frmht+ht+8 2*wid2+spc ht]); set(HomeBtn,'Position',[2*wid2+3*spc pos(4)-frmht+4 wid2 ht]); set(Help21Radio,'Position',[3*wid2+4*spc pos(4)-frmht+4 wid2 ht]); set(BackBtn,'Position',[spc pos(4)-frmht+4 wid2 ht]); set(ForwardBtn,'Position',[wid2+2*spc pos(4)-frmht+4 wid2 ht]); set(HelpDeskBtn,'Position',[figwidth-2*(wid2+spc) pos(4)-frmht+ht+8 2*wid2+spc ht]); set(HelpBtn,'Position',[figwidth-2*(wid2+spc) pos(4)-frmht+4 wid2 ht]); set(CloseBtn,'Position',[figwidth-(wid2+spc) pos(4)-frmht+4 wid2 ht]); % Set the list box to fill the rest of the figure. if (useListboxFlag) set(ListBox,'Position',[bdr 0 pos(3) pos(4)-frmht]); else set(ListAxis,'Position',[bdr 0 pos(3) pos(4)-frmht]); %set(ListText,'Units','Normalized', 'Extent', [0 0 1 1]); end%if (useListboxFlag) %-----------------------------------------------------------------------otherwise % Try to find the figure. Note the awkward spelling of the tag to prevent % others from accidentally grabing this hidden figure. The tag name is different from the one in the function "helpwin" to avoid the windows of these two functions to clash. fig = findobj(allchild(0),'tag','MiniHelPWin2FigurE'); CR = sprintf('\n'); % Determine if the input consists of a cell array or paged help text. topic_is_cell = iscell(topic); multi_page_text = topic_is_cell & (size(topic,2) > 1); % Strip off the first character if it is a space. The space is inserted % on purpose for better display in the edit box. if ~topic_is_cell & size(topic,1) == 1 & topic(1)==' ' , topic(1) = []; end % Create the figure if it doesn't exist. if isempty(fig), % Params. wid = 170; wid2 = 60; spc = 8; ht = 21; frmht = 54; % Get a good font and figure size for this platform. [fname,fsize,bdr] = goodfonts(computer); % Create the figure. fig = figure( ... 'Visible','off', ... 'HandleVisibility','off', ... 'MenuBar','none', ... 'Name','DBT Help Window', ... 'Color',get(0,'defaultuicontrolbackgroundcolor'), ... 'NumberTitle','off', ... 'IntegerHandle','off', ... 'Units','Points', ... 'ResizeFcn','helpwin2(''HelpwinResize'')', ... 'CreateFcn','', ... 'Tag','MiniHelPWin2FigurE'); % Test the chosen font to get the best figure width.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -