function [hce] = CEbtns(figNumber)
% Function: CEbtns.m
% 
% Usage: hce = CEbtns(figNumber)
% 
% Description:
%    Initializes the Complex Exponential Window
%    Handles and graphics elements.
%    Returns a vector to those elements.
%
% Version SWD970603
%
% Author(s): Erik Straser, estraser@lanl.gov
%	modified by Scott W. Doebling, doebling@lanl.gov
%
% Institution: Los Alamos National Laboratory, ESA-EA
%
% Copyright (c) 1996-1997, The Regents of the University
%     	of California.

%====================================
% General buttons parameters
%====================================
top=.95;
left=.84;
btnwd=.15;
btnht=.06;
spacing=.01;

%====================================
% Set up the console frame
%=====================================
frmborder=0.01;
ypos=.05-frmborder;
frmpos=[left-frmborder ypos btnwd+2*frmborder .9+2*frmborder];
hce(1)=uicontrol(figNumber, ...
        'Style','Frame', ...
        'Position',frmpos, ...
        'BackgroundColor',[.5 .5 .5]);

%====================================
% Set up the axes
%====================================

hce(16) = axes('position',[.1 .2 .7 .7]);

%====================================
% Set up the cursors
%====================================

hce(12) = line([0 0],[0 0]);
hce(13) = text(0,0,'');
hce(14) = line([0 0],[0 0]);
hce(15) = text(0,0,'');

%==================================
% Set up buttons
%==================================
%
% Plot tools button
%
btnnum=1;
ypos=top-(btnnum-1)*(btnht+spacing);
btnpos=[left ypos-btnht btnwd btnht];
hce(2)=uicontrol(figNumber, ...
      'style','push', ...
      'position',btnpos, ...
      'string','Plot Tools', ...
      'callback',['eval(get(hplttl(11),''call'')),',...
		'set(hplttl(1),''visible'',''on''), figure(hplttl(1))']);

%==================================
% Set up buttons
%==================================
%
% Run Complex Exponential Algorithm
%
btnnum=2.5;
ypos=top-(btnnum-1)*(btnht);
btnpos=[left ypos-btnht btnwd btnht];
hce(3)=uicontrol(figNumber, ...
 	'style','push', ...
	'unit','normalized', ...
	'position',btnpos, ...
	'visible','off', ...      
	'string','Run Comp Exp', ...
	'callback',[ ...
		'm=str2num(get(onHndlVector(5),''string''));', ...
                'delta_f = sp / (nlines-1);',...
                '[Y, this_lambda, freq_t, damp_t, fs_out,err] = ',...
                '       compexp(G,nlines,delta_f,f1,f2,fs,m,iref,iresp);', ...
                'if err==0,',...
                '  fprintf(1,''\n\nFreq (Hz):\n'');',...
                '  fprintf(1,''%10.5f\n'',freq_t);', ...
                '  fprintf(1,''\n\nDamp (%%):\n'');',...
                '  fprintf(1,''%10.5f\n'',damp_t*100);', ...
                'end']);

%
%  Order
%
btnnum=3.5;
ypos=top-(btnnum-1)*(btnht);
btnpos=[left ypos-btnht btnwd*.6 btnht];
hce(4)=uicontrol(figNumber, ...
      'style','text', ...
      'unit','normalized', ...
      'position',btnpos, ...
      'visible','off', ...      
      'string','Order');
btnpos=[left+.6*btnwd ypos-btnht btnwd*.4 btnht];
hce(5)=uicontrol(figNumber, ...
      'style','edit', ...
      'unit','normalized', ...
      'position',btnpos, ...
      'visible','off', ...      
      'string','?');

%
%  sliders
%

%
% Lower frequency
%
hce(6) = uicontrol(figNumber, ...
        'style','slider', ...
        'pos',[.13 .01 .2 0.04], ...
        'back','w', ...
	'value',1, ...	
	'max',100, ...
	'min',0, ...
   'userdata',1, ...
   'call',['f1_t=get(onHndlVector(6),''value'');',...
      '[f1,onHndlVector(12:13)] = slidfreq(f1_t,onHndlVector(6),',...
      'onHndlVector(12:13),onHndlVector(16),ymaxm,yminm,lnst(2,:),lnco(2,:));',...    
      'set(onHndlVector(8),''string'',num2str(f1));',...
      ' hline(2) = onHndlVector(12);']);
    
hce(7)=uicontrol(figNumber, ...
        'style','text', ...
        'pos',[.13 .05 .1 .04], ...
        'string','Lower');
hce(8)=uicontrol(figNumber, ...
	'style','edit', ...
	'pos',[.23 .05 .1 .04], ...
	'string','fminm', ...
	'back','w', ...
   'callback',['f1_t=str2num(get(onHndlVector(8),''string''));', ...
      '[f1,onHndlVector(12:13)] = slidfreq(f1_t,onHndlVector(6),',...
		    'onHndlVector(12:13),onHndlVector(16),ymaxm,yminm,lnst(2,:),lnco(2,:));',...    
       'set(onHndlVector(8),''string'',num2str(f1));',...
		' hline(2) = onHndlVector(12);']);

%
% Upper frequency
%
hce(9) = uicontrol(figNumber, ...
        'style','slider', ...
        'pos',[.55 .01 .2 0.04], ...
	'value',1, ...
	'max',100, ...
	'min',0, ...
	'userdata',1, ...
        'back','w', ...
        'call',['f2_t=get(onHndlVector(9),''value'');',...
           '[f2,onHndlVector(14:15)] = slidfreq(f2_t,onHndlVector(9),',...
           'onHndlVector(14:15),onHndlVector(16),ymaxm,yminm,lnst(3,:),lnco(3,:));',...    
           'set(onHndlVector(11),''string'',num2str(f2));',...
           'hline(3) = onHndlVector(14);']);

hce(10)=uicontrol(figNumber, ...
        'style','text', ...
        'pos',[.55 .05 .1 .04], ...
        'string','upper');
hce(11)=uicontrol(figNumber, ...
	'style','edit', ...
	'back','w', ...
	'pos',[.65 .05 .1 .04], ...
	'string','temp', ...
   'callback',['f2_t=str2num(get(onHndlVector(11),''string''));', ...
           '[f2,onHndlVector(14:15)] = slidfreq(f2_t,onHndlVector(9),',...
           'onHndlVector(14:15),onHndlVector(16),ymaxm,yminm,lnst(3,:),lnco(3,:));',...    
           'set(onHndlVector(11),''string'',num2str(f2));',...
           'hline(3) = onHndlVector(14);']);


%
%  Mouse-based cursor position
%

%  Lower Freq.

hce(17)=uicontrol(figNumber, ...
        'style','pushbutton', ...
        'pos',[.13 .10 .2 .04], ...
        'string','Use Mouse', ...
        'callback',['[f1_t,temp] = ginput(1);',...
           '[f1,onHndlVector(12:13)] = slidfreq(f1_t,onHndlVector(6),',...
		     'onHndlVector(12:13),onHndlVector(16),ymaxm,yminm,lnst(2,:),lnco(2,:));',...    
           'set(onHndlVector(8),''string'',num2str(f1));',...
		     'hline(2) = onHndlVector(12);']);

%  Upper Freq.

hce(18)=uicontrol(figNumber, ...
        'style','pushbutton', ...
        'pos',[.55 .10 .2 .04], ...
        'string','Use Mouse', ...
        'callback',['[f2_t,temp] = ginput(1);',...
           '[f2,onHndlVector(14:15)] = slidfreq(f2_t,onHndlVector(9),',...
           'onHndlVector(14:15),onHndlVector(16),ymaxm,yminm,lnst(3,:),lnco(3,:));',...    
           'set(onHndlVector(11),''string'',num2str(f2));',...
           'hline(3) = onHndlVector(14);']);
      
set(hce,'visible','off')

return
