view arrows/@esender/construct.m @ 0:672052bd81f8

Initial partial import.
author samer
date Wed, 19 Dec 2012 22:38:28 +0000
parents
children
line wrap: on
line source
function u=construct(s,sizes_in)
	fg=fig(s); figure(fg); clf;
	set(gcf,'Name',s.opts.name);
	hpanel = uipanel('title',s.opts.title,'bordertype','line');
	%hpanel = uigridcontainer('v0','GridSize',[1,1]);
	hedit = uicontrol('parent',hpanel,'style','edit','string',s.opts.init,'horizontalalignment','left');
	%hbtn  = uicontrol('parent',hpanel,'style','pushbutton','string','send');
	set(hedit,'BackgroundColor',get(0,'DefaultAxesColor'));
	set(hedit,'units','normalized','position',[0,0,1,1]);
	%set(hedit,'ToolTipString','Enter a MATLAB expression to evaluate a send.');
	%set(hbtn,'ToolTipString','Press to resend the last entered expression.');

	queue = {};
	u=mkunit(s);
	u.process=@proc;
	u.sizes_out = {[1,1]};
	u.dispose  = @dispose;
	u.starting = @starting;
	u.stopping = @stopping;
	u.get_state = @()get(hedit,'string');
	u.set_state = @(s)set(hedit,'string',s);

	function dispose, delete(hpanel); end
	function starting, set(hedit,'Callback',@send); end
	function stopping, set(hedit,'Callback',[]); end
	function x=proc, x=queue; queue={}; end

	function send(varargin), 
		str=get(hedit,'string');
		fprintf('* esender: evaluating %s\n',str);
		try, queue = [queue, {evalin('base',str)}]; 
		catch fprintf('* esender: ERROR evaluating.\n');
		end
	end
end