📄 makeshow.m
字号:
function makeshow(action);
% MAKESHOW Make slideshow demo.
%
% This tool allows you to create your own interactive
% slideshows without building your own graphic interface.
%
% To use, type your MATLAB commands in the command window.
% Use ctrl+return to execute the commands and to view
% the result for the current page. Type your explanatory
% text in the text window. To create a new slide, click "New".
% MAKESHOW will take care of the rest.
%
% When you finish your demo, you can save it to a file with
% the "Save" button. Next time, you can open the file using
% "Open" to view or edit the demo. To play the slideshow,
% call playshow('filename').
%
% MAKESHOW('filename') opens the file filename.
%
% See also PLAYSHOW.
% Kelly Liu, Feb. 96
% Copyright (c) 1984-98 by The MathWorks, Inc.
% $Revision: 1.24 $ $Date: 1997/11/21 23:26:27 $
filename='';
if nargin<1,
action='initialize';
else
if ~strcmp(action(1), '#')
filename=action;
action='initialize';
else
action=action(2:end);
end;
end;
if strcmp(action,'initialize'),
figNumber=figure( ...
'Name','Slideshow Maker', ...
'Units', 'pixels', ...
'Position', [232 118 560 600],...
'NumberTitle','off', ...
'Visible','off');
axes( ...
'Units','normalized', ...
'Position',[0.10 0.63 0.65 0.315]);
%===================================
left=0.05;
right=0.75;
bottom=0.05;
labelHt=0.03;
spacing=0.005;
frmBorder=0.012;
%======Set up the text Window==========
top=0.6;
% First, the Text Window frame
frmPos=[left-frmBorder bottom-frmBorder-.008 ...
(right-left)+2*frmBorder (top-bottom-spacing)];
frmHandle=LocalBuildFrmTxt(frmPos, '', 'frame', '');
% Then the text label
labelPos=[left top-labelHt-2*(frmBorder+spacing) (right-left) labelHt];
lableHndl=LocalBuildFrmTxt(labelPos, 'Text Window', 'text', 'lable2');
% Then the editable text field
mcwPos=[left bottom+(top-bottom-labelHt)/2 (right-left) ((top-bottom)/2-2*labelHt+spacing)];
textHndl=LocalBuildUi(mcwPos, 'edit', 'makeshow #changetext', '', 'Comments');
%========Set up the Command Window ==================
top=0.3;
% The text label
labelPos=[left top-labelHt (right-left) labelHt];
lableHandle=LocalBuildFrmTxt(labelPos, 'Command Window', 'text', 'lable1');
% Then the editable text field
mcwPos=[left bottom (right-left) top-bottom-labelHt-spacing];
mcwHndl=LocalBuildUi(mcwPos, 'edit', 'makeshow #change', '', 'cmds');
%====================================
% Information for all buttons
left=0.80;
btnWid=0.15;
top=.5;
%=========The Panel frame============
frmBorder=0.02;
yPos=0.05-frmBorder;
frmPos=[left-frmBorder yPos btnWid+2*frmBorder 0.9+2*frmBorder];
frmHandle=LocalBuildFrmTxt(frmPos, '', 'frame', '');
%=========The Slide frame=============
frmBorder=0.02;
btnHt=0.05;
yPos=top+.4;
btnPos=[left yPos btnWid btnHt];
slideHandle=LocalBuildFrmTxt(btnPos, 'Slide 1', 'text', 'slide');
%=========The Next button============
btnNumber=1;
labelStr='Next>>';
callbackStr='makeshow #next';
nextHndl=LocalBuildBtns(btnNumber, labelStr, callbackStr, 'next');
%======Back button===================
backHndl=LocalBuildBtns(2, 'Prev<<', 'makeshow #back', 'back');
%======The Reset button==============
resetHndl=LocalBuildBtns(3, 'Reset', 'makeshow #reset', 'reset');
%======The New button================
newHndl=LocalBuildBtns(4, 'New Slide', 'makeshow #new', 'new');
%======The Delete button=============
delHndl=LocalBuildBtns(5, 'Delete Slide', 'makeshow #delete', 'del');
set(delHndl, 'Enable', 'off');
%=======The Open button==============
addHndl=LocalBuildBtns(6, 'Open...', 'makeshow #open', 'open');
%=======The Save button==============
saveHndl=LocalBuildBtns(7, 'Save...', 'makeshow #save', 'save');
%=======The Info button==============
infoHndl=LocalBuildBtns(0, 'Info', 'makeshow #info', 'info');
%=======The Close button=============
closeHndl=LocalBuildBtns(0, 'Close', 'close(gcf)', 'close');
% Now uncover the figure
LocalInitUserData(mcwHndl, nextHndl, backHndl, textHndl, lableHndl, delHndl);
set(figNumber,'Visible','on');
if ~isempty(filename)
slide=eval(filename);
slideData=get(gcf, 'UserData');
slideData.slide=slide;
slideData.index=1;
set(gcf, 'UserData', slideData);
LocalDoCmd(0);
end
elseif strcmp(action,'next'),
LocalDoCmd(1);
elseif strcmp(action,'back'),
LocalDoCmd(-1);
elseif strcmp(action,'reset'),
% reset to the first page
slideData=get(gcf,'UserData');
slideData.index=1;
set(gcf, 'UserData', slideData);
LocalDoCmd(0);
elseif strcmp(action,'new'),
% generate a new slide
cla;
slideData=get(gcf,'UserData');
curindx=slideData.index;
numSlides=size(slideData.slide);
if curindx~=numSlides
disp('Please go to the end of the slide first, then, add new slide');
break;
end
idx=numSlides(2)+1;
slideData.index=idx;
slideData.slide(idx).code={''};
slideData.slide(idx).text={''};
set(gcf, 'UserData', slideData);
LocalDoCmd(0);
elseif strcmp(action,'open'),
% open an existing file
slideData=get(gcf,'UserData');
[fname, fpath]=uigetfile;
if isstr(fname)&isstr(fpath)
cd(fpath(1:(length(fpath)-1)));
filename=fname(1:(length(fname)-2));
slide=eval(filename);
slideData.slide=slide;
slideData.index=1;
set(gcf, 'UserData', slideData);
LocalDoCmd(0);
end
elseif strcmp(action,'save'),
LocalSaveCallBack;
elseif strcmp(action,'change'),
% command window changes
slideData=get(gcf,'UserData');
idx=slideData.index;
LocalCmdChange(idx, slideData);
LocalDoCmd(0);
elseif strcmp(action,'changetext'),
% text window changes
slideData=get(gcf,'UserData');
idx=slideData.index;
LocalTxtChange(idx, slideData);
elseif strcmp(action,'delete'),
% delete a slide
slideData=get(gcf,'UserData');
idx=slideData.index;
slideData.slide(idx)=[];
slideData.param(idx)=[];
slideData.index=idx-1;
set(gcf, 'UserData', slideData);
LocalDoCmd(0);
elseif strcmp(action,'info'),
helpwin(mfilename);
end; % if strcmp(action, ...
% End of function makeshow
%==================================================
function LocalInitUserData(whandle, nextHndl, backHndl, thandle, lblhandle, delhandle)
% Initialize index, slide, param, ...
slideData.index=1;
slideData.cmdHandle=whandle;
slideData.nextHandle=nextHndl;
slideData.backHandle=backHndl;
slideData.txthandle=thandle;
slideData.lblhandle=lblhandle;
slideData.delhandle=delhandle;
slideData.slide(1).code={''};
slideData.slide(1).text={''};
slideData.param(1).vars={};
set(gcf, 'Userdata', slideData);
LocalDoCmd(0);
%==================================================
function LocalDoCmd(ichange)
% execute the command in the command window
% when ichange = 1, go to the next slide;
% when ichange = -1, go to the previous slide;
% when ichange = 0; stay with the current slide;
% retrieve variables from saved UserData workspace
slideData=get(gcf,'UserData');
SlideShowi=slideData.index+ichange;
numSlides=length(slideData.slide);
if SlideShowi>1
SlideShowVars=slideData.param(SlideShowi-1).vars;
for SlideShown=1:size(SlideShowVars,1);
eval([SlideShowVars{SlideShown,1} '=SlideShowVars{SlideShown,2};']);
end;
end;
% make sure the index, SlideShowi, is within the limits
if SlideShowi<=0,
SlideShowi=1;
elseif SlideShowi>numSlides
SlideShowi=numSlidescell;
end
LocalEnableBtns(SlideShowi, slideData);
% get slides, consider the empty case
SlideShowcmdS=slideData.slide(SlideShowi).code;
if length(SlideShowcmdS)>0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -