Mercurial > hg > ishara
comparison arrows/@esender/construct.m @ 0:672052bd81f8
Initial partial import.
author | samer |
---|---|
date | Wed, 19 Dec 2012 22:38:28 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:672052bd81f8 |
---|---|
1 function u=construct(s,sizes_in) | |
2 fg=fig(s); figure(fg); clf; | |
3 set(gcf,'Name',s.opts.name); | |
4 hpanel = uipanel('title',s.opts.title,'bordertype','line'); | |
5 %hpanel = uigridcontainer('v0','GridSize',[1,1]); | |
6 hedit = uicontrol('parent',hpanel,'style','edit','string',s.opts.init,'horizontalalignment','left'); | |
7 %hbtn = uicontrol('parent',hpanel,'style','pushbutton','string','send'); | |
8 set(hedit,'BackgroundColor',get(0,'DefaultAxesColor')); | |
9 set(hedit,'units','normalized','position',[0,0,1,1]); | |
10 %set(hedit,'ToolTipString','Enter a MATLAB expression to evaluate a send.'); | |
11 %set(hbtn,'ToolTipString','Press to resend the last entered expression.'); | |
12 | |
13 queue = {}; | |
14 u=mkunit(s); | |
15 u.process=@proc; | |
16 u.sizes_out = {[1,1]}; | |
17 u.dispose = @dispose; | |
18 u.starting = @starting; | |
19 u.stopping = @stopping; | |
20 u.get_state = @()get(hedit,'string'); | |
21 u.set_state = @(s)set(hedit,'string',s); | |
22 | |
23 function dispose, delete(hpanel); end | |
24 function starting, set(hedit,'Callback',@send); end | |
25 function stopping, set(hedit,'Callback',[]); end | |
26 function x=proc, x=queue; queue={}; end | |
27 | |
28 function send(varargin), | |
29 str=get(hedit,'string'); | |
30 fprintf('* esender: evaluating %s\n',str); | |
31 try, queue = [queue, {evalin('base',str)}]; | |
32 catch fprintf('* esender: ERROR evaluating.\n'); | |
33 end | |
34 end | |
35 end |