www.gusucode.com > demos工具箱matlab源码程序 > demos/xppage.m
function xppage(ttlStr,txtStr1,txtStr2,txtStr3,txtStr4) %XPPAGE A function for setting up a page of text. % Ned Gulley, 6-21-93 % Copyright 1984-2014 The MathWorks, Inc. numPages = nargin-1; figNumber = figure( ... 'Name',getString(message('MATLAB:demos:shared:TitleInformation')), ... 'NumberTitle','off'); % =================================== % Set up the Comment Window top = 0.95; left = 0.05; right = 0.75; bottom = 0.05; labelHt = 0.05; spacing = 0.005; % First, the 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]; uicontrol( ... 'Style','text', ... 'fontsize',12, ... 'Units','normalized', ... 'Position',labelPos, ... 'BackgroundColor',[0.5 0.5 0.5], ... 'ForegroundColor',[1 1 1], ... 'String',ttlStr); % Then the editable text field (of which there might be several) % Store the text field's handle two places: once in the figure % UserData and once in the button's UserData. for count = 1:numPages, txtStr = eval(['txtStr',num2str(count)]); txtPos = [left bottom (right-left) top-bottom-labelHt-spacing]; txtHndl = uicontrol( ... 'Style','text', ... 'fontsize',10, ... 'HorizontalAlignment','left', ... 'Units','normalized', ... 'Max',20, ... 'String',txtStr, ... 'BackgroundColor',[1 1 1], ... 'Visible','off', ... 'Position',txtPos); hndlList = [get(figNumber,'UserData') txtHndl]; set(gcf,'UserData',hndlList); end; set(hndlList(1),'Visible','on'); % ==================================== % Information for all buttons labelColor = [0.8 0.8 0.8]; yInitPos = 0.90; top = 0.95; left = 0.80; btnWid = 0.15; btnHt = 0.10; % Spacing between the button and the next command's label spacing = 0.04; % ==================================== % The CONSOLE frame frmBorder = 0.02; yPos = 0.05-frmBorder; frmPos = [left-frmBorder yPos btnWid+2*frmBorder 0.9+2*frmBorder]; h = uicontrol( ... 'Style','frame', ... 'Units','normalized', ... 'Position',frmPos, ... 'BackgroundColor',[0.5 0.5 0.5]); if numPages > 1 for count = 1:numPages % ==================================== % The PAGE button labelStr = getString(message('MATLAB:demos:shared:LabelPage',num2str(count))); callbackStr = ... ['txtHndl = get(gco,''UserData'');' ... 'hndlList = get(gcf,''UserData'');' ... 'set(hndlList,''Visible'',''off'');' ... 'set(txtHndl,''Visible'',''on'');']; uicontrol( ... 'Style','pushbutton', ... 'Units','normalized', ... 'Position',[left top-btnHt-(count-1)*(btnHt+spacing) btnWid btnHt], ... 'String',labelStr, ... 'UserData',hndlList(count), ... 'Callback',callbackStr); end; end; % ==================================== % The CLOSE button labelStr = getString(message('MATLAB:demos:shared:LabelClose')); callbackStr = 'close(gcf)'; closeHndl = uicontrol( ... 'Style','pushbutton', ... 'Units','normalized', ... 'Position',[left bottom btnWid btnHt], ... 'String',labelStr, ... 'Callback',callbackStr);