📄 helpwin2.m
字号:
str = ['01234567890123456789012345678901234567890123456789012345678901234567890123456789']; t = uicontrol('Parent',fig, ... 'Units','points', ... 'FontName',fname, ... 'FontSize',fsize, ... 'String',str); figwidth = get(t,'extent'); figwidth = figwidth(3); delete(t); pos = get(fig,'position'); % Gets default figure position in points. bdr = bdr * get(0,'ScreenPixelsPerInch') / 72; % Convert Pixels to Points. figpos = [(2*pos(1) + pos(3) - figwidth)/2 pos(2) figwidth pos(4)] + ... [-bdr 0 bdr 0]; % Set the best figure position. set(fig,'Position',figpos); % Create the rest of the UIs. if (useListboxFlag) ListBox = uicontrol('Parent',fig, ... 'BackgroundColor',[1 1 1], ... 'CallBack','helpwin2(''HelpwinOpen'');', ... 'FontName',fname, ... 'FontSize',fsize, ... 'Max',2, ... 'Units','Points', ... 'Position',[bdr 0 figwidth pos(4)-frmht], ... 'String',' ', ... 'Style','listbox', ... 'Tag','ListBox', ... 'Value',[]); else %set(gca,'Parent',fig, ... %set(gca,... ListAxis = axes('Parent',fig, ... 'FontName',fname, ... 'FontSize',fsize, ... 'Units','Points', ... 'Position',[bdr 0 figwidth pos(4)-frmht], ... 'Tag','ListAxis', ... 'YDir', 'reverse',... 'Box','off'); ListText = text('Parent',ListAxis, ... 'Units','Normalized', ... 'Position', [0 0.92 0],... 'Tag','ListText'); % end%if (useListboxFlag) CurHelpEdit = uicontrol('Parent',fig, ... 'BackgroundColor',[1 1 1], ... 'Units','Points', ... 'Position',[spc pos(4)-frmht+ht+8 2*wid2+spc ht], ... 'Style','edit', ... 'HorizontalAlignment','left', ... 'Tag','CurHelpEdit', ... 'Callback','helpwin2(get(gcbo,''string''));'); SeeAlsoPop = uicontrol('Parent',fig, ... 'BackgroundColor',[1 1 1], ... 'CallBack','helpwin2(''HelpwinSeealso'');', ... 'Min',1, ... 'Units','Points', ... 'Position',[2*wid2+3*spc pos(4)-frmht+ht+8 2*wid2+spc ht], ... 'String','See also', ... 'Style','popupmenu', ... 'HorizontalAlignment','left', ... 'Tag','SeeAlsoPop', ... 'Value',1); HomeBtn = uicontrol('Parent',fig, ... 'CallBack','helpwin2(''HelpwinHome'');', ... 'Units','Points', ... 'Position',[2*wid2+3*spc pos(4)-frmht+4 wid2 ht], ... 'String','Home', ... 'Tag','HomeBtn'); Help21Radio = uicontrol('Parent',fig, ... 'Style','radiobutton',... 'CallBack','helpwin2(''HelpwinHelp12'');', ... 'Units','Points', ... 'Position',[3*wid2+4*spc pos(4)-frmht+4 wid2 ht], ... 'String','Help 2 (1)', ... 'Value', 1,... 'Tag','Help21Radio'); BackBtn = uicontrol('Parent',fig, ... 'CallBack','helpwin2(''HelpwinBack'');', ... 'Units','Points', ... 'Position',[spc pos(4)-frmht+4 wid2 ht], ... 'String','Back', ... 'UserData',0, ... 'Tag','BackBtn'); ForwardBtn = uicontrol('Parent',fig, ... 'CallBack','helpwin2(''HelpwinForward'');', ... 'Units','Points', ... 'Position',[wid2+2*spc pos(4)-frmht+4 wid2 ht], ... 'String','Forward', ... 'Tag','ForwardBtn'); HelpDeskBtn = uicontrol('Parent',fig, ... 'Units','Points', ... 'Position',[figwidth-2*(wid2+spc) pos(4)-frmht+ht+8 2*wid2+spc ht], ... 'Style','Pushbutton', ... 'HorizontalAlignment','center', ... 'String','Go to Help Desk', ... 'Tag','HelpDeskBtn', ... 'Callback','helpwin2(''HelpwinHelpDesk'');'); HelpBtn = uicontrol('Parent',fig, ... 'CallBack','helpwin2(''helpwin2info'');', ... 'Units','Points', ... 'Position',[figwidth-2*(wid2+spc) pos(4)-frmht+4 wid2 ht], ... 'String','Tips', ... 'Tag','HelpBtn'); CloseBtn = uicontrol('Parent',fig, ... 'CallBack','set(gcbf,''visible'',''off'')', ... 'Units','Points', ... 'Position',[figwidth-(wid2+spc) pos(4)-frmht+4 wid2 ht], ... 'String','Close', ... 'Tag','CloseBtn'); % Set 'Busy Action, Queue' and 'Interruptible, Off' on all objects. set(findobj(fig),'BusyAction','queue','Interruptible','off'); else figure(fig); 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'); end % Turn on figure visiblity. set(fig,'visible','on'); % Create Page popup if not necessary and non-existent. Otherwise, simply % load up the help string with the help text for the requested topic. if multi_page_text % Get the help text for the requested topic from the cell array. if nargin < 2 pagetitle = topic{1,1}; elseif isempty(pagetitle) pagetitle = topic{1,1}; end ind = strmatch(pagetitle,topic(:,1),'exact'); if isempty(ind), ind = 1; end helpstr = char(topic{ind,2}); slash_n = find(helpstr==CR); if slash_n % Replace pipes with '!' for display if necessary, % replace the carriage returns in the help string with pipes % so that the list box can correctly interpret them. % Add one extra line to top of display. helpstr(find(helpstr == '|')) = '!'; helpstr(slash_n) = '|'; helpstr = ['|' helpstr]; else % Add one extra line to top of display. helpstr = str2mat('',helpstr); end % Set the popup string. ref = [{'Topics'}; topic(:,1)]; if length(ref) < 2 set(SeeAlsoPop,'string',ref,... 'enable','off'); else set(SeeAlsoPop,'string',ref, ... 'callback','helpwin2(''HelpwinPage'');', ... 'enable','on',... 'value',1,... 'userdata',topic); end % Set the current topic. pgtitle = topic{ind,1}; elseif (iscell(topic) | any(find(topic==32)) | ... size(topic,1) > 1 | any(find(topic==CR))) helpstr = char(topic); slash_n = find(helpstr==CR); if slash_n % Replace pipes with '!' for display if necessary, % replace the carriage returns in the help string with pipes % so that the list box can correctly interpret them. % Add one extra line to top of display. helpstr(find(helpstr == '|')) = '!'; helpstr(slash_n) = '|'; helpstr = ['|' helpstr]; else % Add one extra line to top of display. helpstr = str2mat('',helpstr); end if nargin < 2 pgtitle = 'MATLAB Help'; else if isempty(pagetitle) pgtitle = 'MATLAB Help'; else pgtitle = pagetitle; end end else % Get the help text for the requested topic. if exist(topic)==4, helpstr = sprintf(' ''%s'' is a Simulink model.',topic); else fig = gcbf; Help21Radio = findobj(fig,'tag','Help21Radio'); if (get(Help21Radio,'value')) helpstr = help2(topic); else helpstr = help(topic); end%if end slash_n = 1; pgtitle = topic; % Error handling. If topic not found, send an error message to the window. if isempty(helpstr) helpstr = [CR ' Topic ''' pgtitle ''' was not found.']; end % Replace pipes with '!' for display if necessary, % replace the carriage returns in the help string with pipes % so that the list box can correctly interpret them. % Add one extra line to top of display. helpstr(find(helpstr == '|')) = '!'; if (useListboxFlag) helpstr(find(helpstr==CR)) = '|'; end%if (useListboxFlag) helpstr = ['|' helpstr]; end % Store the arguments in the userdata of the figure. This is a stack % which enables the Back button to work for the last few selections. fig = findobj(allchild(0),'tag','MiniHelPWin2FigurE'); % Added line to get the right figure. "gcbf" probably get the wrong when helpwin2 is called from a callback function of another window. fud = get(fig,'UserData'); curArg = struct('topic',{[]},'pagetitle',{[]},'helptitle',{[]}); curArg.topic = topic; curArg.pagetitle = pgtitle; if nargin >= 3 curArg.helptitle = helptitle; end if isempty(fud) fud = curArg; % protects for first time through code. else backflag = get(BackBtn,'UserData'); % flag to indicate that Back/Forw button was if backflag == 0 % pressed. str = get(CurHelpEdit,'string'); if str(1) == ' ', str(1) = []; end; % remove first char is space match = strmatch(str,{fud.pagetitle},'exact'); if ~isempty(match) fud(1:match(1)-1) = []; % eliminate the items 'above' the selected items end fud = [curArg fud]; if length(fud) >= 7 % limits stack to 6 elements fud(7) = []; % or 5 Back button presses end else set(BackBtn,'UserData',0); % clear backflag end end set(fig,'UserData',fud); % Check to see whether the Back and Forward buttons should be disabled. match = strmatch(pgtitle,{fud.pagetitle},'exact'); if max(match) == length(fud) set(BackBtn,'enable','off'); else set(BackBtn,'enable','on'); end if min(match) == 1 set(ForwardBtn,'enable','off'); else set(ForwardBtn,'enable','on'); end % Replace all tabs with single spaces. helpstr(find(helpstr==9)) = ' '; % Set the listbox string to the help string and set the topic name in the % edit box. set(CurHelpEdit,'string',[' ' pgtitle]); % extra space for better display. if (useListboxFlag) set(ListBox,'value',[],'string',helpstr,'ListBoxTop',1); else %figure() %text(0,0,'helpstr') set(ListText,'String',helpstr) end%if (useListboxFlag) if any(slash_n) & ~multi_page_text % Set up the string for the See Also pop-up cnt=1; ref={'See also'}; if ~(any(find(pgtitle==filesep)) | ... any(find(pgtitle=='/')) | ... any(find(pgtitle(2:end)==' '))) ref = {'See also' sprintf('More %s help (HTML)',pgtitle)}; cnt = cnt + 1; end % Enable links to the related topics found after the 'See Also'. seealso1=max(findstr(helpstr,xlate('See also'))); %Finds LAST 'See Also'. seealso2=max(findstr(helpstr,xlate('See Also'))); %Finds LAST 'See Also'. seealso3=max(findstr(helpstr,xlate('Se ocks
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -