function[]=demo_fixp;
% function[]=demo_fixp;
% Demonstrace metody pevneho bodu
% Copyleft Jiri Zelinka


fixphndl=figure( ...
	'Visible','on', ...
	'Tag','fixp', ...
	'Name','Demo - pevny bod', ...
        'NumberTitle','off');

axes( ...
        'Units','normalized', ...
        'Position',[0.08 0.08 0.75 0.87]);

% The CONSOLE frame
    uicontrol( ...
        'Style','frame', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[0.86,0,.15,1], ...
        'BackgroundColor',[0.50 0.50 0.50]);



% The run button

  callrunStr1='Ah=findobj(''Tag'',''AHndl'');As=get(Ah,''String'');A=eval(As);x0h=findobj(''Tag'',''x0Hndl'');x0s=get(x0h,''String'');x0=eval(x0s);set(gcbo,''Enable'',''off'');'; 
  callrunStr2='xn=x0;ni=0;konec=0;while ni<100 & konec~=1,ni=ni+1;xo=xn; xn=A*xo*(1-xo),plot([xo,xo,xn],[xo,xn,xn],''r*--'');';
  callrunStr3='pause(1);stophndl=findobj(''Tag'',''StopHndl'');set(stophndl,''Enable'',''On'');drawhndl=findobj(''Tag'',''DrawHndl''); set(drawhndl,''Enable'',''Off'');';
  callrunStr4='konec=get(stophndl,''UserData'');end;set(stophndl,''Enable'',''Off'');set(stophndl,''UserData'',0); set(drawhndl,''Enable'',''On'');set(gcbo,''Enable'',''On'');';
%  callrunStr5='stop=0; while stop==0 && h0<(max(X)-min(X)), h0=h0+step;f_est=K_dest(xx,X,h0,K);figure(ef);plot(xx,f_est);pause(1);stop=get(stophndl,''UserData'');set(h0hndl,''String'',num2str(h0));set(h0hndl,''UserData'',h0);end;';
%  callrunStr6='set(gcbo,''Enable'',''On''); set(stophndl,''Enable'',''Off'');set(stophndl,''UserData'',0); set(righthndl,''Enable'',''On'');set(lefthndl,''Enable'',''On'');set(drawhndl,''Enable'',''On'');end;';
  runHndl=uicontrol( ...
        'Style','push', ...
        'Units','normalized', ...
	'Tag','RunHndl', ...
	'TooltipString','Draws estimates by steps', ...
        'FontUnits','normalized',...
        'Position',[0.88,.59,.05,0.05], ...
        'String','->>', ...
        'Callback',[callrunStr1,callrunStr2,callrunStr3,callrunStr4]);
handles.runHndl=runHndl;

% The stop button
  callstopStr1='set(gcbo,''UserData'',1); ';
  stopHndl=uicontrol( ...
        'Style','push', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[0.94,.59,.05,0.05], ...
        'TooltipString','Stops iterations', ...
    	'Tag','StopHndl', ...
        'String','Stop', ...
        'UserData',0, ...
        'Enable','off',...
        'Callback',callstopStr1);

% The Draw button
  DrawStr1='Ah=findobj(''Tag'',''AHndl'');As=get(Ah,''String'');A=eval(As);set(Ah,''Userdata'',A);x0h=findobj(''Tag'',''x0Hndl'');x0s=get(x0h,''String'');x0=eval(x0s);set(x0h,''Userdata'',x0);x=0:0.01:1;f=A*x.*(1-x);';
  DrawStr2='set(gcbo,''UserData'',1);hold off;plot(x,f,x,x);hold on;plot([x0,x0],[0,x0],''r*--'');axis([0,1,0,1]);';
  DrawHndl=uicontrol( ...
        'Style','push', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[0.885,.70,.1,0.05], ...
	'TooltipString','Draw the iteration', ...
	'Tag','DrawHndl', ...
        'String','Draw', ...
        'UserData',0, ...
        'Enable','on',...
        'Callback',[DrawStr1,DrawStr2]);
    
     
% Then the text label
    uicontrol( ...
        'Style','text', ...
        'Units','normalized', ...
        'Position',[.875,.87,.04,.04], ...
        'BackgroundColor',[0.50 0.50 0.50], ...
        'FontUnits','normalized',...
        'ForegroundColor',[1 1 1], ...
        'String','A = ');

% Then the editable text field
   AHndl=uicontrol( ...
	'Style','edit', ...
        'Units','normalized', ...
        'String',char([]),...%
        'BackgroundColor',[1 1 1], ...
        'UserData',0.1,...
	    'Tag','AHndl', ...
        'Position',[.91,.87,.08,.045], ...
        'HorizontalAlignment','left');
     
% Then the text label
    uicontrol( ...
	'Style','text', ...
        'Units','normalized', ...
        'Position',[.862,.79,.05,.05], ...
        'BackgroundColor',[0.50 0.50 0.50], ...
        'ForegroundColor',[1 1 1], ...
        'UserData',0,...
        'String','x0 =');
     
% Then the editable text field
   x0Hndl=uicontrol( ...
	'Style','edit', ...
        'Units','normalized', ...
        'String',char([]),...%
        'BackgroundColor',[1 1 1], ...
	    'Tag','x0Hndl', ...
        'Position',[.91,.81,.08,.045], ...
        'HorizontalAlignment','left');

     

% button Cancel
       closeStr='set(gcf,''CloseRequestFcn'',''closereq'');delete(gcf);';
       uicontrol('Style','push','Units','normalized', ...
          'FontUnits','normalized',...
          'Position',[0.88,.03,.11,0.07], ...
          'Callback',closeStr, ...
          'BackgroundColor',[.5,0.5,0.5], ...
          'String','Cancel');

     
set(gcf,'Units','normalized','Position',[0.1 0.15 0.8 0.7]);

  
end %function
