⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scrledit.m

📁 matlab处理图像的一些基本方法。其中有一部分mex程序需要安装编译
💻 M
字号:
function hout=scrledit(cmd,Par1,txt, tit)%SCRLEDIT Multiline edit uicontrol with scroll bar%h=scrledit(cmd,POS,STRING_MAT)% create a scrolling edit window with a slide bar%% INPUT:%	  cmd	- the user should use only cmd='init';%	  POS = [x1 y1 dx dy]	define the location of the edit box + slider%		in nomalized units%	  STRING_MAT - MATLAB String matrix, text to  fill the edit box and to be scrolled%% OUTPUT (optional)%	h - a vector of handles used when closing a specific scrledit%		scrledit('clode',h); % closes the specific scrledit%------------------------------------------------------%  by: I. Bucher (R)    Email : i.bucher@ic.ac.uk  %------------------------------------------------------%% EXAMPLE:%		S=readstr('scrledit.m'); % create a large string%		scrledit('init',[.01 .01 .45 .92],S);% or% EXAMPLE to fit in a window where there is an existing plot%%	figure, subplot(2,1,1), plot(rand(20,1))%	 scrledit('init',[.01 .01 .92 .4],S)%% or %	h1=scrledit('init',[.01 .01 .32 .4],S);%	h2=scrledit('init',[.51 .01 .22 .4],S);%	 scrledit('close',h1); % closes the first scrledit% 	 scrledit('close',h3); % closes the second scrledit%%      scrledit('close') % will close every scrledit(s) in the current figure (gcf)if nargin<1, cmd='init'; figure; Par1=[.1 .1 .8 .8];tit=[]; endif nargin==3, tit=[];endif strcmp(cmd,'init'),    figure(gcf);	P=Par1;  dx=P(3)/50; dy=P(4)/20; dw=P(3)/30;	 MaxLines=40;	[n m]=size(txt);	 h(1)=uicontrol('style','frame',...			'pos',[P(1) P(2) P(3)  P(4)],...			'unit','normal',...			'backgroundcolor',[.5 .5 .5]);	 uicontrol('style','text',...			'pos',[P(1)+dx P(2)+P(4)-dy P(3)-dw dy],...			'unit','normal',...			'string', tit,...			'fore', 'b',...			'backgroundcolor',[.5 .5 .5]);	 h(2)=uicontrol('style','edit',...			'pos',[P(1)+dx P(2)+dy P(3)-dw P(4)-2*dy],...			'unit','normal', ...			'BackgroundColor',[1 1 1],'max',MaxLines,...				'userdata',txt,...			'Callback',  'scrledit(''reset'');' );	 h(3)=uicontrol('style','slider',...			'pos',[P(1)+P(3)  P(2) dw P(4)],...			'unit','normal',...			'value',1,...			'tag', 'SCR_ED',...			'min',n,'max',1,...			 'callback','scrledit(''slide'')');	set(h(3),'userdata',h);	set(gcf, 'CurrentObject',h(3));	scrledit('slide'); 		if nargout>0, hout=h; endelseif strcmp(cmd,'slide'),				hs=gco;	% get slider's handle	h=get(hs,'userdata');	 i1=round(get(h(3),'value')); 		txt=get(h(2),'userdata'); [n m]=size(txt);	i2=i1+get(h(2),'max');	if i2>n, i2=n; end	 set(h(2),'string',txt(i1:i2,:));elseif strcmp(cmd,'reset'),				hs=findobj('tag', 'SCR_ED');	% get slider's handle	h=get(hs,'userdata');	 i1=round(get(h(3),'value')); 		txt=get(h(2),'userdata'); [n m]=size(txt);	i2=i1+get(h(2),'max');	if i2>n, i2=n; end	 set(h(2),'string',txt(i1:i2,:));	 elseif strcmp(cmd,'close'),  if nargin>1,	% handles given	close(Par1);  else,			% close all slider with length(userdata)=3  	hs=findobj(gcf,'style','slider'); % find all sliders	 for q=1:length(hs),		UD=get(hs(q),'userdata');		if length(UD)==3, 			h=get(hs(q),'userdata');			close(h), 		end	end  end	  else	disp(' illegal command in scrledit')end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -