function initcontrol
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% init_control.m
%
% initialize Control Window GUI:
%   push buttons, sliders, radio buttons, editable text boxes, info text display
%
% ripped off from triton v1.50 
% smw 050117
%
% modified 060210 - 060227 smw for triton v1.60
%
% 060612 smw v1.61
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
global HANDLES PARAMS

% 33 rows, 4 columns, except for motion control buttons
r = 36; % rows
c = 4;  % columns
h = 1/r;
w = 1/c;
%
% make x and y locations in plot control window (relative units)
for ci = 1:c
    x(:,ci) = ((ci-1)/c) .* ones(r,1);
    y(:,ci) = h .* [r-1:-1:0]';
end
%
% offset y to provide space between control sections

dy = h * 0.25;
ri = 1;
y(ri,:) = y(ri,:) - dy;
%
% rows 2-3,4-5,6-7,8-9,
for ri = 2:5
    y(2*ri-2,:) = y(2*ri-2,:) - ri * dy;
    y(2*ri-1,:) = y(2*ri-1,:) - ri * dy;
end
% rows 10-15
for ri = 5:10
    y(ri+5,:) = y(ri+5,:) - (ri+1) * dy;
end

% rows 16-17, 18-19, 20-21, 22-23, 24-25, 26-27
shift = 2 * h;
for ri = 8:14               %Sean - do you intend for this indexing to start at y(14)? mss  (14+15 don't get used, so it doesn't affect anything - just unneccessary calculations)
   y(2*ri-2,:) = y(2*ri-2,:) - (ri+1)*dy + shift;
   y(2*ri-1,:) = y(2*ri-1,:) - (ri+1)*dy + shift;
end
% row 28-40
for ri = 14: r-14
    y(ri+14,:) = y(ri+14,:) - (ri+2) * dy + shift;
end

% y = y + 0.5;

bgColor = [1 1 1];  % white

bgColor2 = [.75 1 .875]; % light green for LTSA
bgColor3 = [.75 .875 1]; % light blue for XWAV
bgColor4 = [.80 .80 .80]; % gray for other buttons
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% radio buttons for plot type
%
% row 1
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%*********************************
% long-term spectral averaging button setup
%*********************************
% labelStr='PSDS';
labelStr='LTSA';
btnPos=[x(1,1) y(1,1) w h];
HANDLES.display.ltsa = uicontrol(HANDLES.fig.ctrl, ...
    'Style','radiobutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor2,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Callback','displaybut(''ltsa'')'); 
%*********************************
% spectrogram button setup
%*********************************
labelStr='Spectrogram';
btnPos=[x(1,2) y(1,2) w h];
% btnPos=[x(1,3) y(1,3) w h];
HANDLES.display.specgram = uicontrol(HANDLES.fig.ctrl, ...
    'Style','radiobutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Callback','displaybut(''specgram'')'); 
%*********************************
% timeseries button setup
%*********************************
labelStr='Timeseries';
btnPos=[x(1,3) y(1,3) w h];
% btnPos=[x(1,1) y(1,1) w h];
HANDLES.display.timeseries = uicontrol(HANDLES.fig.ctrl, ...
    'Style','radiobutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Value',0,...
    'Callback','displaybut(''timeseries'')'); 
%*********************************
% spectra button setup
%*********************************
labelStr='Spectra';
btnPos=[x(1,4) y(1,4) w h];
% btnPos=[x(1,2) y(1,2) w h];
HANDLES.display.spectra = uicontrol(HANDLES.fig.ctrl, ...
    'Style','radiobutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Callback','displaybut(''spectra'')'); 
%
HANDLES.displaycontrol = [ ...
        HANDLES.display.timeseries HANDLES.display.spectra ...
        HANDLES.display.specgram];
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% LTSA control
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Plot Time Control
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%***********************************
% Display Start  Text
%***********************************
lStr(1) = {'Plot'};
lStr(2) = {'Start Time'};
btnPos=[x(3,1) y(3,1) w 2*h];
HANDLES.ltsa.time.txt = uicontrol(HANDLES.fig.ctrl,...
   'Style','text',...
   'Units','normalized',...
   'Position',btnPos,...
   'BackgroundColor',bgColor2,...
   'String',lStr,...
   'FontUnits','normalized', ...
   'Visible','off');
%***********************************
% help text mm/dd/yyyy
%***********************************
labelStr = 'mm/dd/yyyy';
btnPos=[x(2,2) y(2,2) w h];
HANDLES.ltsa.time.txt1 = uicontrol(HANDLES.fig.ctrl,...
    'Style','text',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor2,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off');
%***********************************
% Display Start Time Editable Text
% mm/dd/yyy HH:MM:SS
%***********************************
% labelStr=[num2str(PARAMS.start.yr),':',PARAMS.start.str];
labelStr=timestr(PARAMS.ltsa.start.dnum,6);
btnPos=[x(3,2) y(3,2) 2*w h];
HANDLES.ltsa.time.edtxt1 = uicontrol(HANDLES.fig.ctrl,...
    'Style','edit',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Callback','control_ltsa(''newtime1'')');
%***********************************
% help text HH:MM:SS
%***********************************
labelStr = 'HH:MM:SS';
btnPos=[x(2,3) y(2,3) w h];
HANDLES.ltsa.time.txt2 = uicontrol(HANDLES.fig.ctrl,...
    'Style','text',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor2,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off');

%***********************************
% Display Duration  Text
%***********************************
labelStr='Plot Length (hr)';
btnPos=[x(4,1) y(4,1) w h];
HANDLES.ltsa.time.txt3 = uicontrol(HANDLES.fig.ctrl,...
   'Style','text',...
   'Units','normalized',...
   'Position',btnPos,...
   'BackgroundColor',bgColor2,...
   'String',labelStr,...
   'FontUnits','normalized', ...
   'Visible','off');
%***********************************
% Display Time Segment Editable Text
%***********************************
labelStr=[num2str(PARAMS.ltsa.tseg.hr)];
btnPos=[x(5,1) y(5,1) w h];
HANDLES.ltsa.time.edtxt3 = uicontrol(HANDLES.fig.ctrl,...
   'Style','edit',...
   'Units','normalized',...
   'Position',btnPos,...
   'BackgroundColor',bgColor,...
   'String',labelStr,...
   'FontUnits','normalized', ...
   'Visible','off',...
   'Callback','control_ltsa(''newtseg'')');
%***********************************
% Display Step  Text
%***********************************
labelStr='Time Step (hr)';
btnPos=[x(4,2) y(4,2) w h];
HANDLES.ltsa.time.txt4 = uicontrol(HANDLES.fig.ctrl,...
   'Style','text',...
   'Units','normalized',...
   'Position',btnPos,...
   'BackgroundColor',bgColor2,...
   'String',labelStr,...
   'FontUnits','normalized', ...
   'Visible','off');
%***********************************
% Display Step Size Editable Text
%***********************************
labelStr=[num2str(PARAMS.ltsa.tseg.step)];
btnPos=[x(5,2) y(5,2) w h];
HANDLES.ltsa.time.edtxt4 = uicontrol(HANDLES.fig.ctrl,...
   'Style','edit',...
   'Units','normalized',...
   'Position',btnPos,...
   'BackgroundColor',bgColor,...
   'String',labelStr,...
   'FontUnits','normalized', ...
   'Visible','off',...
   'Callback','control_ltsa(''newtstep'')');
%***********************************
% Delay  Text
%***********************************
labelStr='Auto Time Delay';
btnPos=[x(4,3) y(4,3) w h];
HANDLES.ltsa.time.txt6 = uicontrol(HANDLES.fig.ctrl,...
    'Style','text',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor2,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off');
%***********************************
% Display Step Size Editable Text
%***********************************
labelStr=num2str(PARAMS.ltsa.aptime);
btnPos=[x(5,3) y(5,3) w h];
HANDLES.ltsa.time.edtxt6 = uicontrol(HANDLES.fig.ctrl,...
    'Style','edit',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Callback','control_ltsa(''delay'')');
%
HANDLES.ltsa.timecontrols = ...
   [
      HANDLES.ltsa.time.txt...
      HANDLES.ltsa.time.edtxt1 HANDLES.ltsa.time.txt1...
                                HANDLES.ltsa.time.txt2...
      HANDLES.ltsa.time.edtxt3 HANDLES.ltsa.time.txt3...
      HANDLES.ltsa.time.edtxt4 HANDLES.ltsa.time.txt4...
      HANDLES.ltsa.time.edtxt6 HANDLES.ltsa.time.txt6...
      ];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Detection controls
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%***********************************
%***********************************
% Enable/disable detection
%***********************************
% labelStr = 'Detector';
% btnPos = [x(4,4) y(4,4) w h];
% HANDLES.ltsa.dt.Enabled = uicontrol(HANDLES.fig.ctrl, ...
%     'Style','radiobutton', ...
%     'Units','normalized', ...
%     'Position',btnPos, ...
%     'BackgroundColor',bgColor2,...
%     'String',labelStr, ...
%     'FontUnits','normalized', ...
%     'Visible','off',...
%     'Value', 0,...
%     'Callback','control_ltsa(''detection_toggle'')'); 
%***********************************
% Enable/disable noise selection
%***********************************
% labelStr = 'Pick noise';
% btnPos = [x(5,4) y(5,4) w h];
% HANDLES.ltsa.dt.NoiseEst = uicontrol(HANDLES.fig.ctrl, ...
%     'Style','radiobutton', ...
%     'Units','normalized', ...
%     'Position',btnPos, ...
%     'BackgroundColor',bgColor2,...
%     'String',labelStr, ...
%     'FontUnits','normalized', ...
%     'Visible','off',...
%     'Enable', 'off',   ...              % Turn off for now - in detector control instead
%     'Value', 0,...
%     'Callback','control_ltsa(''detection_noise'')'); 

%***********************************
% Detection controls group
%***********************************
% HANDLES.ltsa.dt.controls = [ ...
%     HANDLES.ltsa.dt.Enabled HANDLES.ltsa.dt.NoiseEst];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Plot Frequency Control
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%***********************************
% Plot Frequency Control Header Text
%***********************************
lStr(1) = {'Plot'};
lStr(2) = {'Frequency'};
btnPos=[x(7,1) y(7,1) w 2*h];
HANDLES.ltsa.plotfreq.txt = uicontrol(HANDLES.fig.ctrl,...
   'Style','text',...
   'Units','normalized',...
   'Position',btnPos,...
   'BackgroundColor',bgColor2,...
   'String',lStr,...
   'FontUnits','normalized', ...
   'HorizontalAlignment','center',...
   'Visible','off');
%***********************************
% Display Start Frequency Text
%***********************************
labelStr=' Start [Hz]';
btnPos=[x(6,2) y(6,2) w h];
HANDLES.ltsa.stfreq.txt = uicontrol(HANDLES.fig.ctrl,...
   'Style','text',...
   'Units','normalized',...
   'Position',btnPos,...
   'BackgroundColor',bgColor2,...
   'String',labelStr,...
   'FontUnits','normalized', ...
   'Visible','off');
%***********************************
% Display Start Frequency Editable Text
%***********************************
labelStr=num2str(PARAMS.ltsa.freq0);
btnPos=[x(7,2) y(7,2) w h];
HANDLES.ltsa.stfreq.edtxt = uicontrol(HANDLES.fig.ctrl,...
   'Style','edit',...
   'Units','normalized',...
   'Position',btnPos,...
   'BackgroundColor',bgColor,...
   'String',labelStr,...
   'FontUnits','normalized', ...
   'Visible','off',...
   'Callback','control_ltsa(''newstfreq'')');
%***********************************
% Display End Frequency Text
%***********************************
labelStr=' End [Hz]';
btnPos=[x(6,3) y(6,3) w h];
HANDLES.ltsa.endfreq.txt = uicontrol(HANDLES.fig.ctrl,...
   'Style','text',...
   'Units','normalized',...
   'Position',btnPos,...
   'BackgroundColor',bgColor2,...
   'String',labelStr,...
   'FontUnits','normalized', ...
   'Visible','off');
%***********************************
% Display End Frequency Editable Text
%***********************************
labelStr=num2str(PARAMS.ltsa.freq1);
btnPos=[x(7,3) y(7,3) w h];
HANDLES.ltsa.endfreq.edtxt = uicontrol(HANDLES.fig.ctrl,...
   'Style','edit',...
   'Units','normalized',...
   'Position',btnPos,...
   'BackgroundColor',bgColor,...
   'String',labelStr,...
   'FontUnits','normalized', ...
   'Visible','off',...
   'Callback','control_ltsa(''newendfreq'')');
%***********************************
% Linear Freq. Axis
%***********************************
labelStr='Linear Axis';
btnPos=[x(6,4) y(6,4) w h];
HANDLES.ltsa.fax.linear = uicontrol(HANDLES.fig.ctrl,...
    'Style','radiobutton',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor2,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Value',1,...
    'Callback','control_ltsa(''faxlinear'')');
%***********************************
% Log Freq. Axis
%***********************************
labelStr='Log Axis';
btnPos=[x(7,4) y(7,4) w h];
HANDLES.ltsa.fax.log = uicontrol(HANDLES.fig.ctrl,...
    'Style','radiobutton',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor2,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Value',0,...
    'Callback','control_ltsa(''faxlog'')');

HANDLES.ltsa.faxcontrol = [HANDLES.ltsa.fax.linear HANDLES.ltsa.fax.log];
HANDLES.ltsa.freqcontrols = ...
    [HANDLES.ltsa.plotfreq.txt ...
        HANDLES.ltsa.stfreq.txt HANDLES.ltsa.stfreq.edtxt ...
        HANDLES.ltsa.endfreq.txt HANDLES.ltsa.endfreq.edtxt];
%        HANDLES.ltsa.faxcontrol];    
        
%*********************************************************
%
% figure window brightness and contrast sliders
%
%*********************************************************

%*********************************
%  Brightness slider text
%*********************************
labStr(1)={'Brightness (dB)'};
btnPos=[x(8,1) y(8,1) w h];
HANDLES.ltsa.amp.brtxt = uicontrol(HANDLES.fig.ctrl, ...
   'Style','text', ...
   'Units','normalized', ...
   'Position',btnPos, ...
   'BackgroundColor',bgColor2,...
   'String',labStr, ...
   'FontUnits','normalized', ...
   'Visible','off'); 

%*********************************
%  Brightness slider setup
%*********************************
btnPos=[x(8,2) y(8,2) 2*w h];
HANDLES.ltsa.amp.brsld = uicontrol(HANDLES.fig.ctrl, ...
   'Style','slider', ...
   'SliderStep',[2/600,5/600], ...
   'Units','normalized', ...
   'FontUnits','normalized', ...
   'Position',btnPos, ...
   'BackgroundColor',bgColor2,...
   'Visible','off',...
   'Min',-300,...
   'Max',300,...
   'Value',PARAMS.ltsa.bright,...
   'Callback','control_ltsa(''ampadj'')'); 
%*********************************
%  Brightness slider value
%*********************************
btnPos=[x(8,4) y(8,4) w h];
HANDLES.ltsa.amp.bredt = uicontrol(HANDLES.fig.ctrl, ...
   'Style','edit', ...
   'Units','normalized', ...
   'Position',btnPos, ...
   'BackgroundColor',bgColor2,...
   'String',num2str(PARAMS.ltsa.bright), ...
   'FontUnits','normalized', ...
   'Visible','off',...
   'Callback','control_ltsa(''ampadj'')'); 
%*********************************
%  Contrast slider text
%*********************************
labStr(1)={'Contrast (%dB)'};
btnPos=[x(9,1) y(9,1) w h];
HANDLES.ltsa.amp.contxt = uicontrol(HANDLES.fig.ctrl, ...
   'Style','text', ...
   'Units','normalized', ...
   'Position',btnPos, ...
   'BackgroundColor',bgColor2,...
   'String',labStr, ...
   'FontUnits','normalized', ...
   'Visible','off'); 
%*********************************
%  Contrast slider setup
%*********************************
btnPos=[x(9,2) y(9,2) 2*w h];
HANDLES.ltsa.amp.consld = uicontrol(HANDLES.fig.ctrl, ...
   'Style','slider', ...
   'SliderStep',[2/600,5/600], ...
   'Units','normalized', ...
   'FontUnits','normalized', ...
   'Position',btnPos, ...
   'BackgroundColor',bgColor2,...
   'Visible','off',...
   'Min',0,...
   'Max',1000,...
   'Value',PARAMS.ltsa.contrast,...
   'Callback','control_ltsa(''ampadj'')'); 
%*********************************
%  Contrast slider value
%*********************************
btnPos=[x(9,4) y(9,4) w h];
HANDLES.ltsa.amp.conedt = uicontrol(HANDLES.fig.ctrl, ...
   'Style','edit', ...
   'Units','normalized', ...
   'Position',btnPos, ...
   'BackgroundColor',bgColor2,...
   'String',num2str(PARAMS.ltsa.contrast), ...
   'FontUnits','normalized', ...
   'Visible','off',...
   'Callback','control_ltsa(''ampadj'')');
%*********************************
% cmap jet button setup
%*********************************
labelStr='Jet';
btnPos=[x(10,1) y(10,1) w h];
HANDLES.ltsa.amp.cmapjet = uicontrol(HANDLES.fig.ctrl, ...
    'Style','radiobutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor2,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Value',1,...
    'Callback','control_ltsa(''setcmapjet'')'); 
%*********************************
% cmap gray button setup
%*********************************
labelStr='Gray';
btnPos=[x(10,2) y(10,2) w h];
HANDLES.ltsa.amp.cmapgray = uicontrol(HANDLES.fig.ctrl, ...
    'Style','radiobutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor2,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Value',0,...
    'Callback','control_ltsa(''setcmapgray'')'); 
%*********************************
% cmap cool button setup
%*********************************
labelStr='Cool';
btnPos=[x(10,3) y(10,3) w h];
HANDLES.ltsa.amp.cmapcool = uicontrol(HANDLES.fig.ctrl, ...
    'Style','radiobutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor2,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Value',0,...
    'Callback','control_ltsa(''setcmapcool'')'); 
%*********************************
% cmap hot button setup
%*********************************
labelStr='Hot';
btnPos=[x(10,4) y(10,4) w h];
HANDLES.ltsa.amp.cmaphot = uicontrol(HANDLES.fig.ctrl, ...
    'Style','radiobutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor2,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Value',0,...
    'Callback','control_ltsa(''setcmaphot'')'); 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ltsa equalization toggle Row 11
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%*********************************
%  Specgram Equalization text
%*********************************
labelStr='Equalization';
btnPos=[x(11,1) y(11,1) w h];
HANDLES.ltsa.eq.txt = uicontrol(HANDLES.fig.ctrl, ...
    'Style','text', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor2,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off'); 

%***********************************
% Toggle Button On/Off
%***********************************
labelStr='OFF';
btnPos=[x(11,2) y(11,2) w h];
HANDLES.ltsa.eq.tog = uicontrol(HANDLES.fig.ctrl,...
    'Style','toggle',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Value',0,...
    'Visible','off',...
    'Callback','control_ltsa(''toggleEqual'')');
%***********************************
% Toggle Button Pick/Full
%***********************************
labelStr='Full';
btnPos=[x(11,3) y(11,3) w h];
HANDLES.ltsa.eq.tog2 = uicontrol(HANDLES.fig.ctrl,...
    'Style','toggle',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Value',0,...
    'Visible','off',...
    'Callback','control_ltsa(''toggleMean'')');

%*********************************
% Expand toggle radio button setup
%*********************************
labelStr='Expand';
btnPos=[x(11,4) y(11,4) w h];
HANDLES.ltsa.expand.button = uicontrol(HANDLES.fig.ctrl, ...
    'Style','radiobutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor2,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Value',PARAMS.expand.button.value,...
    'Callback', {@pickxyz, true}); 


HANDLES.ltsa.equal = [...
    HANDLES.ltsa.eq.txt HANDLES.ltsa.eq.tog HANDLES.ltsa.eq.tog2];


%
HANDLES.ltsa.amp.cmapcontrol = ...
    [HANDLES.ltsa.amp.cmapjet HANDLES.ltsa.amp.cmapgray ...
        HANDLES.ltsa.amp.cmapcool HANDLES.ltsa.amp.cmaphot]; 

%
HANDLES.ltsa.ampcontrols = ...
   [HANDLES.ltsa.amp.brsld HANDLES.ltsa.amp.brtxt HANDLES.ltsa.amp.bredt...
      HANDLES.ltsa.amp.consld HANDLES.ltsa.amp.contxt HANDLES.ltsa.amp.conedt...
      HANDLES.ltsa.amp.cmapcontrol]; 


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Display (plot) Frequency parameters, including spectra parameters
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
%*********************************************************
%
% figure window motion
%
%**********************************************************
%button layout

btm = y(13,1);
gap = .01;
btnWid=0.15;
mid = .5 - btnWid/2;
sbtnWid=btnWid/3;
btnHt = 2 * h;
% vertical Spacing between the button and	the next command's label
spacing=0.01;
%*********************************
% The FORWARD button setup
%*********************************
labelStr='>';
btnPos=[mid+btnWid+gap btm btnWid btnHt];
HANDLES.ltsa.motion.fwd = uicontrol(HANDLES.fig.ctrl, ...
   'Style','pushbutton', ...
   'Units','normalized', ...
   'Position',btnPos, ...
   'BackgroundColor',bgColor2,...
   'Enable','off',...
   'String',labelStr, ...     
   'FontUnits','normalized', ...
   'Callback','motion_ltsa(''forward'')'); 
%*********************************
% The BACK button setup
%*********************************
labelStr='<';
btnPos=[mid-btnWid-gap btm btnWid btnHt];
HANDLES.ltsa.motion.back = uicontrol(HANDLES.fig.ctrl, ...
   'Style','pushbutton', ...
   'Units','normalized', ...
   'Position',btnPos, ...
   'BackgroundColor',bgColor2,...
   'Enable','off',...
   'String',labelStr, ...
   'FontUnits','normalized', ...
   'Callback','motion_ltsa(''back'')'); 
%*********************************
% The AutoRun Forward button setup
%*********************************
labelStr='>>';
btnPos=[mid+2*(btnWid+gap) btm btnWid btnHt];
HANDLES.ltsa.motion.autofwd = uicontrol(HANDLES.fig.ctrl, ...
   'Style','pushbutton', ...
   'Units','normalized', ...
   'Position',btnPos, ...
   'BackgroundColor',bgColor2,...
   'Interruptible','on',...
   'Enable','off',...
   'Value',0,...
	'String',labelStr, ...
    'FontUnits','normalized', ...
   'Callback','motion_ltsa(''autof'')');     	  
%*********************************
% The Seek to End button setup
%*********************************
labelStr='>|';
btnPos=[mid+3*(btnWid+gap) btm sbtnWid btnHt];
HANDLES.ltsa.motion.seekeof = uicontrol(HANDLES.fig.ctrl, ...
   'Style','pushbutton', ...
   'Units','normalized', ...
   'Position',btnPos, ...
   'BackgroundColor',bgColor2,...
   'Interruptible','on',...
   'Enable','off',...
   'Value',0,...
	'String',labelStr, ...
    'FontUnits','normalized', ...
   'Callback','motion_ltsa(''seekeof'')');
%*********************************
% The Seek to Begin button setup
%*********************************
labelStr='|<';
btnPos=[mid-2*(btnWid+gap)-(sbtnWid+gap) btm sbtnWid btnHt];
HANDLES.ltsa.motion.seekbof = uicontrol(HANDLES.fig.ctrl, ...
   'Style','pushbutton', ...
   'Units','normalized', ...
   'Position',btnPos, ...
   'BackgroundColor',bgColor2,...
   'Interruptible','on',...
   'Enable','off',...
   'Value',0,...
	'String',labelStr, ...
    'FontUnits','normalized', ...
   'Callback','motion_ltsa(''seekbof'')');
%*********************************
% The AutoRun backward button setup
%*********************************
labelStr='<<';
btnPos=[mid-2*(btnWid+gap) btm btnWid btnHt];
HANDLES.ltsa.motion.autoback = uicontrol(HANDLES.fig.ctrl, ...
   'Style','pushbutton', ...
   'Units','normalized', ...
   'Position',btnPos, ...
   'BackgroundColor',bgColor2,...
   'Interruptible','on',...
   'Enable','off',...
   'Value',0,...
   'String',labelStr, ...
   'FontUnits','normalized', ...
   'Callback','motion_ltsa(''autob'')');   
%*********************************
% The STOP Auto button setup
%*********************************
labelStr='Stop';
btnPos=[mid btm btnWid btnHt];
HANDLES.ltsa.motion.stop = uicontrol(HANDLES.fig.ctrl, ...
   'Style','pushbutton', ...
   'Units','normalized', ...
   'Position',btnPos, ...
   'BackgroundColor',bgColor2,...
   'String',labelStr, ...
   'FontUnits','normalized', ...
   'Interruptible','on',...
   'Enable','off',...
   'Userdata',-1,...
   'Callback','motion_ltsa(''stop'')');
%
HANDLES.ltsa.motioncontrols = ...
   [HANDLES.ltsa.motion.fwd HANDLES.ltsa.motion.back ...
      HANDLES.ltsa.motion.autofwd HANDLES.ltsa.motion.autoback HANDLES.ltsa.motion.stop...
      HANDLES.ltsa.motion.seekbof HANDLES.ltsa.motion.seekeof];

        set(HANDLES.ltsa.motioncontrols,'Visible','off')

% HANDLES.ltsa.allcontrol = [...
%     HANDLES.ltsa.motioncontrols HANDLES.ltsa.ampcontrols ...
%     HANDLES.ltsa.dt.controls ...
%     HANDLES.ltsa.zoomin.button ...
%     HANDLES.ltsa.freqcontrols HANDLES.ltsa.timecontrols HANDLES.ltsa.equal];
%     

%*********************************
% LTSA Delimit toggle radio button setup
%*********************************
labelStr='Delimiter';
btnPos=[x(7,4) y(7,4) w h];
HANDLES.ltsa.delimit.but = uicontrol(HANDLES.fig.ctrl, ...
    'Style','radiobutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor2,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Value',PARAMS.ltsa.delimit.value,...
    'Callback','control_ltsa(''delimit'')'); 

HANDLES.ltsa.allcontrol = [...
    HANDLES.ltsa.motioncontrols HANDLES.ltsa.ampcontrols ...
    HANDLES.ltsa.expand.button ...
    HANDLES.ltsa.freqcontrols HANDLES.ltsa.timecontrols HANDLES.ltsa.equal...
    HANDLES.ltsa.delimit.but];
    
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
%  XWAV control
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%function initcontrol
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% initcontrol.m
%
% initialize Control Window GUI:
%   push buttons, sliders, radio buttons, editable text boxes, info text display
%
% 5/5/04 smw
%
% 050512 smw major redesign/layout
%
% 060210 smw updated for v1.60
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Plot Time Control
% 
% rows 2 & 3
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% location and size of time, freq/amp, start time, dur info
%
%***********************************
% Display Start  Text
%***********************************
lStr(1) = {'Plot'};
lStr(2) = {'Start Time'};
btnPos=[x(17,1) y(17,1) w 2*h];
HANDLES.time.txt = uicontrol(HANDLES.fig.ctrl,...
    'Style','text',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',lStr,...
    'FontUnits','normalized', ...
    'Visible','off');
%***********************************
% help text mm/dd/yyyy
%***********************************
labelStr = 'mm/dd/yyyy';
btnPos=[x(16,2) y(16,2) w h];
HANDLES.time.txt1 = uicontrol(HANDLES.fig.ctrl,...
    'Style','text',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off');
%***********************************
% Display Start Time Editable Text
% mm/dd/yyy
%***********************************
% labelStr=[num2str(PARAMS.start.yr),':',PARAMS.start.str];
labelStr=timestr(PARAMS.start.dnum,3);
btnPos=[x(17,2) y(17,2) w h];
HANDLES.time.edtxt1 = uicontrol(HANDLES.fig.ctrl,...
    'Style','edit',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Callback','control(''newtime1'')');
%***********************************
% help text HH:MM:SS
%***********************************
labelStr = 'HH:MM:SS';
btnPos=[x(16,3) y(16,3) w h];
HANDLES.time.txt2 = uicontrol(HANDLES.fig.ctrl,...
    'Style','text',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off');
%***********************************
% Display Start Time Editable Text
% HH:MM:SS
%***********************************
% labelStr=[num2str(PARAMS.start.yr),':',PARAMS.start.str];
labelStr=timestr(PARAMS.start.dnum,4);
btnPos=[x(17,3) y(17,3) w h];
HANDLES.time.edtxt2 = uicontrol(HANDLES.fig.ctrl,...
    'Style','edit',...
    'Units','normalized',...
    'Position',btnPos,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'BackgroundColor',bgColor,...
    'Visible','off',...
    'Callback','control(''newtime2'')');
%***********************************
% help text mmm.uuu
%***********************************
labelStr = 'mmm.uuu';
btnPos=[x(16,4) y(16,4) w h];
HANDLES.time.txt3 = uicontrol(HANDLES.fig.ctrl,...
    'Style','text',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off');
%***********************************
% Display Start Time Editable Text
% mmm.uuu
%***********************************
% labelStr=[num2str(PARAMS.start.yr),':',PARAMS.start.str];
labelStr=timestr(PARAMS.start.dnum,5);
btnPos=[x(17,4) y(17,4) w h];
HANDLES.time.edtxt3 = uicontrol(HANDLES.fig.ctrl,...
    'Style','edit',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Callback','control(''newtime3'')');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Plot Time Control part 2
% 
% rows 4 & 5
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%***********************************
% Display Window Length  Text
%***********************************
labelStr='Plot Length (s)';
btnPos=[x(18,1) y(18,1) w h];
HANDLES.time.txt4 = uicontrol(HANDLES.fig.ctrl,...
    'Style','text',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off');
%***********************************
% Display Time Segment Editable Text
%***********************************
labelStr=num2str(PARAMS.tseg.sec);
btnPos=[x(19,1) y(19,1) w h];
HANDLES.time.edtxt4 = uicontrol(HANDLES.fig.ctrl,...
    'Style','edit',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Callback','control(''newtseg'')');
%***********************************
% Display Step  Text
%***********************************
labelStr='Time Step (s)';
btnPos=[x(18,2) y(18,2) w h];
HANDLES.time.txt5 = uicontrol(HANDLES.fig.ctrl,...
    'Style','text',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off');
%***********************************
% Display Step Size Editable Text
%***********************************
labelStr=[num2str(PARAMS.tseg.step)];
btnPos=[x(19,2) y(19,2) w h];
HANDLES.time.edtxt5 = uicontrol(HANDLES.fig.ctrl,...
    'Style','edit',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Callback','control(''newtstep'')');
%***********************************
% Delay  Text
%***********************************
labelStr='Auto Time Delay';
btnPos=[x(18,3) y(18,3) w h];
HANDLES.time.txt6 = uicontrol(HANDLES.fig.ctrl,...
    'Style','text',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off');
%***********************************
% Display Step Size Editable Text
%***********************************
labelStr=num2str(PARAMS.aptime);
btnPos=[x(19,3) y(19,3) w h];
HANDLES.time.edtxt6 = uicontrol(HANDLES.fig.ctrl,...
    'Style','edit',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Callback','control(''delay'')');
%
HANDLES.timecontrols = ...
    [HANDLES.time.txt ...
        HANDLES.time.edtxt1 HANDLES.time.txt1...
        HANDLES.time.edtxt2 HANDLES.time.txt2...
        HANDLES.time.edtxt3 HANDLES.time.txt3...
        HANDLES.time.edtxt4 HANDLES.time.txt4...
        HANDLES.time.edtxt5 HANDLES.time.txt5...
        HANDLES.time.edtxt6 HANDLES.time.txt6];
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Channel Selector
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
labelStr='Channel';
btnPos=[x(18,4) y(18,4) w h];
HANDLES.ch.txt = uicontrol(HANDLES.fig.ctrl,...
    'Style','text',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off');
%*********************************
%  Channel popup setup
%*********************************
labelStr = PARAMS.ch;
btnPos=[x(19,4) y(19,4) w h];
HANDLES.ch.pop = uicontrol(HANDLES.fig.ctrl, ...
    'Style','popup', ...
    'Units','normalized', ...
    'Position',btnPos, ... 
    'BackgroundColor',bgColor,...
    'HorizontalAlignment','center',...
    'Visible','off',...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Callback','control(''setchan'')'); 
%
HANDLES.chan = [HANDLES.ch.txt HANDLES.ch.pop];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Filter
% 
% rows 6 & 7
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Bandpass Filter toggle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lStr(1) = {'Band Pass'};
lStr(2) = {'Filter'};
btnPos=[x(21,1) y(21,1) w 2*h];
HANDLES.filt.txt = uicontrol(HANDLES.fig.ctrl,...
    'Style','text',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',lStr,...
    'FontUnits','normalized', ...
    'Visible','off');
%***********************************
% BandPass Low Text
%***********************************
labelStr='Low End [Hz]';
btnPos=[x(20,2) y(20,2) w h];
HANDLES.filtlow.txt = uicontrol(HANDLES.fig.ctrl,...
    'Style','text',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Low end of Bandpass Filter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
labelStr=num2str(PARAMS.ff1);
btnPos=[x(21,2) y(21,2) w h];
HANDLES.filt.edtxt1 = uicontrol(HANDLES.fig.ctrl,...
    'Style','edit',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Callback','control(''filtdata'')');
%***********************************
% BandPass High Text
%***********************************
labelStr='High End [Hz]';
btnPos=[x(20,3) y(20,3) w h];
HANDLES.filthigh.txt = uicontrol(HANDLES.fig.ctrl,...
    'Style','text',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% High end of Bandpass Filter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
labelStr=num2str(PARAMS.ff2);
btnPos=[x(21,3) y(21,3) w h];
HANDLES.filt.edtxt2 = uicontrol(HANDLES.fig.ctrl,...
    'Style','edit',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Callback','control(''filtdata'')');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Bandpass Filter toggle ON
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
labelStr = 'ON';
btnPos=[x(20,4) y(20,4) w/2 h];
HANDLES.filt.rad1 = uicontrol(HANDLES.fig.ctrl,...
    'Style','radiobutton',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Value',0,...
    'Callback','control(''filton'')');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Bandpass Filter toggle OFF
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
labelStr = 'OFF';
btnPos=[x(21,4) y(21,4) w/2 h];
HANDLES.filt.rad2 = uicontrol(HANDLES.fig.ctrl,...
    'Style','radiobutton',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Value',1,...
    'Callback','control(''filtoff'')');
%
HANDLES.filtradios = [HANDLES.filt.rad1 HANDLES.filt.rad2];
%
HANDLES.filtcontrol = [...
        HANDLES.filt.txt ...
        HANDLES.filtlow.txt HANDLES.filthigh.txt ...
        HANDLES.filt.edtxt1 HANDLES.filt.edtxt2 ...
        HANDLES.filtradios];
%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Transfer Function
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Bandpass Filter toggle ON
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
labelStr = 'TFon';
btnPos=[x(20,4)+w/2 y(20,4) w/2 h];
HANDLES.tf.rad1 = uicontrol(HANDLES.fig.ctrl,...
    'Style','radiobutton',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Value',0,...
    'Callback','control(''TFon'')');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Bandpass Filter toggle OFF
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
labelStr = 'TFoff';
btnPos=[x(21,4)+w/2 y(21,4) w/2 h];
HANDLES.tf.rad2 = uicontrol(HANDLES.fig.ctrl,...
    'Style','radiobutton',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Value',1,...
    'Callback','control(''TFoff'')');
  %
HANDLES.tfradios = [HANDLES.tf.rad1 HANDLES.tf.rad2];      
               
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Plot Frequency Control
%
% Rows 8 & 9
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%***********************************
% Plot Frequency Control Header Text
%***********************************
lStr(1) = {'Plot'};
lStr(2) = {'Frequency'};
btnPos=[x(23,1) y(23,1) w 2*h];
HANDLES.plotfreq.txt = uicontrol(HANDLES.fig.ctrl,...
    'Style','text',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',lStr,...
    'FontUnits','normalized', ...
    'HorizontalAlignment','center',...
    'Visible','off');
%***********************************
% Display Start Frequency Text
%***********************************
labelStr='Start [Hz]';
btnPos=[x(22,2) y(22,2) w h];
HANDLES.stfreq.txt = uicontrol(HANDLES.fig.ctrl,...
    'Style','text',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off');
%***********************************
% Display Start Frequency Editable Text
%***********************************
labelStr=num2str(PARAMS.freq0);
btnPos=[x(23,2) y(23,2) w h];
HANDLES.stfreq.edtxt = uicontrol(HANDLES.fig.ctrl,...
    'Style','edit',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Callback','control(''newstfreq'')');
%***********************************
% Display End Frequency Text
%***********************************
labelStr='End [Hz]';
btnPos=[x(22,3) y(22,3) w h];
HANDLES.endfreq.txt = uicontrol(HANDLES.fig.ctrl,...
    'Style','text',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off');
%***********************************
% Display End Frequency Editable Text
%***********************************
labelStr=num2str(PARAMS.freq1);
btnPos=[x(23,3) y(23,3) w h];
HANDLES.endfreq.edtxt = uicontrol(HANDLES.fig.ctrl,...
    'Style','edit',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Callback','control(''newendfreq'')');
%***********************************
% Linear Freq. Axis
%***********************************
labelStr='Linear Axis';
btnPos=[x(22,4) y(22,4) w h];
HANDLES.fax.linear = uicontrol(HANDLES.fig.ctrl,...
    'Style','radiobutton',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Value',1,...
    'Callback','control(''faxlinear'')');
%***********************************
% Log Freq. Axis
%***********************************
labelStr='Log Axis';
btnPos=[x(23,4) y(23,4) w h];
HANDLES.fax.log = uicontrol(HANDLES.fig.ctrl,...
    'Style','radiobutton',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Value',0,...
    'Callback','control(''faxlog'')');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Plot Spectral Control
%
% rows 10 & 11
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%***********************************
% Plot Spectral Control Header Text
%***********************************
lStr(1) = {'Spectral'};
lStr(2) = {'Parameters'};
btnPos=[x(25,1) y(25,1) w 2*h];
HANDLES.plotspec.txt = uicontrol(HANDLES.fig.ctrl,...
    'Style','text',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',lStr,...
    'FontUnits','normalized', ...
    'Visible','off');
%***********************************
% Spectral FFT Length Text
%***********************************
labelStr='FFT Length';
btnPos=[x(24,2) y(24,2) w h];
HANDLES.specnfft.txt = uicontrol(HANDLES.fig.ctrl,...
    'Style','text',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off');
%***********************************
% Spectral FFT Length Editable Text
%***********************************
labelStr=num2str(PARAMS.nfft);
btnPos=[x(25,2) y(25,2) w h];
HANDLES.specnfft.edtxt = uicontrol(HANDLES.fig.ctrl,...
    'Style','edit',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Callback','control(''setspec'')');
%***********************************
% Spectral Overlap Text
%***********************************
labelStr='%Overlap';
btnPos=[x(24,3) y(24,3) w h];
HANDLES.specol.txt = uicontrol(HANDLES.fig.ctrl,...
    'Style','text',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off');
%***********************************
% Spectral Overlap Editable Text
%***********************************
labelStr=num2str(PARAMS.overlap);
btnPos=[x(25,3) y(25,3) w h];
HANDLES.specol.edtxt = uicontrol(HANDLES.fig.ctrl,...
    'Style','edit',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Callback','control(''setspec'')');
%***********************************
% Display Spectral Window Type Text
%***********************************
labelStr='Window Type';
btnPos=[x(24,4) y(24,4) w h];
HANDLES.specwindow.txt = uicontrol(HANDLES.fig.ctrl,...
    'Style','text',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor3,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off');
%*********************************
%  Window Type popup setup
%*********************************
labelStr = PARAMS.window;
btnPos=[x(25,4) y(25,4) w h];
HANDLES.specwindow.pop = uicontrol(HANDLES.fig.ctrl, ...
    'Style','popup', ...
    'Units','normalized', ...
    'Position',btnPos, ... 
    'BackgroundColor',bgColor,...
    'HorizontalAlignment','center',...
    'Visible','off',...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Callback','control(''setspec'')'); 

HANDLES.faxcontrol = [HANDLES.fax.linear HANDLES.fax.log];
HANDLES.freqcontrols = ...
    [HANDLES.plotfreq.txt ...
        HANDLES.stfreq.txt HANDLES.stfreq.edtxt ...
        HANDLES.specwindow.txt HANDLES.specwindow.pop ...
        HANDLES.endfreq.txt HANDLES.endfreq.edtxt ...
        HANDLES.plotspec.txt ...
        HANDLES.specnfft.txt HANDLES.specnfft.edtxt ...
        HANDLES.specol.txt HANDLES.specol.edtxt...
        HANDLES.faxcontrol];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Brightness -> row 12
% Contrast -> row 13
% Colormap - row 14 (1st half)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%*********************************
%  Brightness slider text
%*********************************
labelStr='Brightness (dB)';
% lStr(2)={'(gain)'};
btnPos=[x(26,1) y(26,1) w h];
HANDLES.amp.brtxt = uicontrol(HANDLES.fig.ctrl, ...
    'Style','text', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off'); 
%*********************************
%  Brightness slider setup
%*********************************
btnPos=[x(26,2) y(26,2) 2*w h];
HANDLES.amp.brsld = uicontrol(HANDLES.fig.ctrl, ...
    'Style','slider', ...
    'SliderStep',[2/600,5/600], ...
    'Units','normalized', ...
    'FontUnits','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'Visible','off',...
    'Min',-300,...
    'Max',300,...
    'Value',PARAMS.bright,...
    'Callback','control(''ampadj'')'); 
%*********************************
%  Brightness slider value
%*********************************
% labelStr='Brightness';
btnPos=[x(26,4) y(26,4) w h];
HANDLES.amp.bredt = uicontrol(HANDLES.fig.ctrl, ...
    'Style','edit', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor,...
    'String',num2str(PARAMS.bright), ...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Callback','control(''ampadj'')'); 
%*********************************
%  Contrast slider text
%*********************************
labelStr='Contrast (%dB)';
% lStr(2)={'(scale)'};
btnPos=[x(27,1) y(27,1) w h];
HANDLES.amp.contxt = uicontrol(HANDLES.fig.ctrl, ...
    'Style','text', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off'); 
%*********************************
%  Contrast slider setup
%*********************************
btnPos=[x(27,2) y(27,2) 2*w h];
HANDLES.amp.consld = uicontrol(HANDLES.fig.ctrl, ...
    'Style','slider', ...
    'SliderStep',[2/600,5/600], ...
    'Units','normalized', ...
    'FontUnits','normalized', ...
    'Position',btnPos, ...   
    'BackgroundColor',bgColor3,...
    'Visible','off',...
    'Min',0,...
    'Max',1000,...
    'Value',PARAMS.contrast,...
    'Callback','control(''ampadj'')'); 
%*********************************
%  Contrast slider value
%*********************************
btnPos=[x(27,4) y(27,4) w h];
HANDLES.amp.conedt = uicontrol(HANDLES.fig.ctrl, ...
    'Style','edit', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor,...
    'String',num2str(PARAMS.contrast), ...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Callback','control(''ampadj'')');

%*********************************
% cmap jet button setup
%*********************************
labelStr='Jet';
btnPos=[x(28,1) y(28,1) 0.5*w h];
HANDLES.amp.cmapjet = uicontrol(HANDLES.fig.ctrl, ...
    'Style','radiobutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Value',1,...
    'Callback','control(''setcmapjet'')'); 
%*********************************
% cmap gray button setup
%*********************************
labelStr='Gray';
btnPos=[x(28,1)+0.5*w y(28,1) 0.5*w h];
HANDLES.amp.cmapgray = uicontrol(HANDLES.fig.ctrl, ...
    'Style','radiobutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Value',0,...
    'Callback','control(''setcmapgray'')'); 
%*********************************
% cmap cool button setup
%*********************************
labelStr='Cool';
btnPos=[x(28,2) y(28,2) 0.5*w h];
HANDLES.amp.cmapcool = uicontrol(HANDLES.fig.ctrl, ...
    'Style','radiobutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Value',0,...
    'Callback','control(''setcmapcool'')'); 
%*********************************
% cmap hot button setup
%*********************************
labelStr='Hot';
btnPos=[x(28,2)+0.5*w y(28,2) 0.5*w h];
HANDLES.amp.cmaphot = uicontrol(HANDLES.fig.ctrl, ...
    'Style','radiobutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Value',0,...
    'Callback','control(''setcmaphot'')'); 
%
HANDLES.amp.cmapcontrol = ...
    [HANDLES.amp.cmapjet HANDLES.amp.cmapgray ...
        HANDLES.amp.cmapcool HANDLES.amp.cmaphot]; 
%
HANDLES.ampcontrols = ...
    [HANDLES.amp.brsld HANDLES.amp.brtxt HANDLES.amp.bredt...
        HANDLES.amp.consld HANDLES.amp.contxt HANDLES.amp.conedt...
        HANDLES.amp.cmapcontrol];
    
    
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Detection controls -> row 14, 2nd half
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%***********************************
% Enable/disable detection
%***********************************
% labelStr = 'Detector';
% btnPos = [x(28,4) y(28,4) w h];
% HANDLES.dt.Enabled = uicontrol(HANDLES.fig.ctrl, ...
%     'Style','radiobutton', ...
%     'Units','normalized', ...
%     'Position',btnPos, ...
%     'BackgroundColor',bgColor3,...
%     'String',labelStr, ...
%     'FontUnits','normalized', ...
%     'Visible','off',...
%     'Value', 0,...
%     'Callback','control(''detection_toggle'')'); 
%***********************************
% Enable/disable noise selection
%***********************************
% labelStr = 'Pick noise';
% btnPos = [x(28,3)+.125*w y(28,3) .875*w h];
% HANDLES.dt.NoiseEst = uicontrol(HANDLES.fig.ctrl, ...
%     'Style','radiobutton', ...
%     'Units','normalized', ...
%     'Position',btnPos, ...
%     'BackgroundColor',bgColor3,...
%     'String',labelStr, ...
%     'FontUnits','normalized', ...
%     'Visible','off',...
%     'Value', 0,...
%     'Callback','control(''detection_noise'')'); 
% 
%***********************************
% Detection controls group
%***********************************
% HANDLES.dt.controls = [ ...
%     HANDLES.dt.Enabled]; % HANDLES.dt.NoiseEst];       
           
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% spectrogram equalization toggle Row 15
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%*********************************
%  Specgram Equalization text
%*********************************
labelStr='SG Equalization';
btnPos=[x(29,1) y(29,1) w h];
HANDLES.sgeq.txt = uicontrol(HANDLES.fig.ctrl, ...
    'Style','text', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off'); 

%***********************************
% Toggle Button On/Off
%***********************************
labelStr='OFF';
btnPos=[x(29,2) y(29,2) w h];
HANDLES.sgeq.tog = uicontrol(HANDLES.fig.ctrl,...
    'Style','toggle',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Value',0,...
    'Visible','off',...
    'Callback','control(''toggleSGEqual'')');
%***********************************
% Toggle Button Pick/Full
%***********************************
labelStr='Full';
btnPos=[x(29,3) y(29,3) w h];
HANDLES.sgeq.tog2 = uicontrol(HANDLES.fig.ctrl,...
    'Style','toggle',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Value',0,...
    'Visible','off',...
    'Callback','control(''toggleMean'')');

HANDLES.sgequal = [...
    HANDLES.sgeq.txt HANDLES.sgeq.tog HANDLES.sgeq.tog2];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%*********************************
% Delimit toggle radio button setup
%*********************************
labelStr='Delimiter';
btnPos=[x(29,4) y(29,4) w h];
HANDLES.delimit.but = uicontrol(HANDLES.fig.ctrl, ...
    'Style','radiobutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Value',PARAMS.delimit.value,...
    'Callback','control(''delimit'')'); 


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Sound Playback Control - row 16
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%*********************************
%  Sound Playback text
%*********************************
labelStr='Sound';
btnPos=[x(30,1) y(30,1) 0.5*w h];
HANDLES.snd.sndtxt = uicontrol(HANDLES.fig.ctrl, ...
    'Style','text', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off'); 
%*********************************
%  Speed Factor text
%*********************************
labelStr='Speed';
btnPos=[x(30,1)+0.5*w y(30,1) 0.5*w h];
HANDLES.snd.spftxt = uicontrol(HANDLES.fig.ctrl, ...
    'Style','text', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off'); 
%***********************************
% Speed Factor Editable Text
%***********************************
labelStr=num2str(PARAMS.speedFactor);
btnPos=[x(30,2) y(30,3) 0.5*w h];
HANDLES.snd.edtxt = uicontrol(HANDLES.fig.ctrl,...
    'Style','edit',...
    'Units','normalized',...
    'Position',btnPos,...
    'BackgroundColor',bgColor,...
    'String',labelStr,...
    'FontUnits','normalized', ...
    'Visible','off',...
    'Callback','control(''setspeedFactor'')');
%*********************************
%  Volume text
%*********************************
labelStr='Volume';
btnPos=[x(30,2)+0.5*w y(30,2) 0.5*w h];
HANDLES.snd.svtxt = uicontrol(HANDLES.fig.ctrl, ...
    'Style','text', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Visible','off'); 

%*********************************
%  Volume slider setup
%*********************************
btnPos=[x(30,3) y(30,3) w h];
HANDLES.snd.svsld = uicontrol(HANDLES.fig.ctrl, ...
    'Style','slider', ...
    'Units','normalized', ...
    'FontUnits','normalized', ...
    'Position',btnPos, ...   
    'BackgroundColor',bgColor3,...
    'Visible','off',...
    'Min',0,...
    'Max',1,...
    'Value',PARAMS.sndVol,...
    'Callback','control(''setVolume'')'); 


%*********************************
% Sound Stop button setup
%*********************************
labelStr='Stop';
btnPos=[x(30,4) y(30,4) 0.5*w h];
HANDLES.snd.stop = uicontrol(HANDLES.fig.ctrl, ...
    'Style','pushbutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'Visible','off',...
    'Enable','off',...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Callback','control(''stopSound'')'); 

%*********************************
% Sound Play button setup
%*********************************
labelStr='>';
btnPos=[x(30,4)+0.5*x(30,2) y(30,4) 0.5*w h];
HANDLES.snd.play = uicontrol(HANDLES.fig.ctrl, ...
    'Style','pushbutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'Visible','off',...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Callback','control(''playSound'')'); 

HANDLES.sndcontrol = [...
    HANDLES.snd.sndtxt HANDLES.snd.spftxt HANDLES.snd.edtxt...
    HANDLES.snd.svtxt HANDLES.snd.svsld ...
    HANDLES.snd.stop HANDLES.snd.play];

%**************************************************************************
%
% figure window motion
%
%**********************************************************
%button layout
btm = y(32,1);
gap = .01;
btnWid=0.15;
mid = .5 - btnWid/2;
sbtnWid=btnWid/3;
btnHt = 2 * h;
% vertical Spacing between the button and	the next command's label
spacing=0.01;
%*********************************
% The FORWARD button setup
%*********************************
labelStr='>';
btnPos=[mid+btnWid+gap btm btnWid btnHt];
HANDLES.motion.fwd = uicontrol(HANDLES.fig.ctrl, ...
    'Style','pushbutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'Enable','off',...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Callback','motion(''forward'')'); 
%*********************************
% The BACK button setup
%*********************************
labelStr='<';
btnPos=[mid-btnWid-gap btm btnWid btnHt];
HANDLES.motion.back = uicontrol(HANDLES.fig.ctrl, ...
    'Style','pushbutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'Enable','off',...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Callback','motion(''back'')'); 
%*********************************
% The AutoRun Forward button setup
%*********************************
labelStr='>>';
btnPos=[mid+2*(btnWid+gap) btm btnWid btnHt];
HANDLES.motion.autofwd = uicontrol(HANDLES.fig.ctrl, ...
    'Style','pushbutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'Interruptible','on',...
    'Enable','off',...
    'Value',0,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Callback','motion(''autof'')');     	  
%*********************************
% The Seek to End button setup
%*********************************
labelStr='>|';
btnPos=[mid+3*(btnWid+gap) btm sbtnWid btnHt];
HANDLES.motion.seekeof = uicontrol(HANDLES.fig.ctrl, ...
    'Style','pushbutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'Interruptible','on',...
    'Enable','off',...
    'Value',0,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Callback','motion(''seekeof'')');
%*********************************
% The Seek to Begin button setup
%*********************************
labelStr='|<';
btnPos=[mid-2*(btnWid+gap)-(sbtnWid+gap) btm sbtnWid btnHt];
HANDLES.motion.seekbof = uicontrol(HANDLES.fig.ctrl, ...
    'Style','pushbutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'Interruptible','on',...
    'Enable','off',...
    'Value',0,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Callback','motion(''seekbof'')');
%*********************************
% The AutoRun backward button setup
%*********************************
labelStr='<<';
btnPos=[mid-2*(btnWid+gap) btm btnWid btnHt];
HANDLES.motion.autoback = uicontrol(HANDLES.fig.ctrl, ...
    'Style','pushbutton', ...
    'Units','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'Interruptible','on',...
    'Enable','off',...
    'Value',0,...
    'String',labelStr, ...
    'FontUnits','normalized', ...
    'Callback','motion(''autob'')');   
%*********************************
% The STOP Auto button setup
%*********************************
labelStr='Stop';
btnPos=[mid btm btnWid btnHt];
HANDLES.motion.stop = uicontrol(HANDLES.fig.ctrl, ...
    'Style','pushbutton', ...
    'Units','normalized', ...
    'FontUnits','normalized', ...
    'Position',btnPos, ...
    'BackgroundColor',bgColor3,...
    'String',labelStr, ...
    'Interruptible','on',...
    'Enable','off',...
    'Userdata',-1,...
    'Callback','motion(''stop'')');
%
HANDLES.motioncontrols = ...
    [HANDLES.motion.fwd HANDLES.motion.back ...
        HANDLES.motion.autofwd HANDLES.motion.autoback HANDLES.motion.stop...
        HANDLES.motion.seekbof HANDLES.motion.seekeof];
    
        set(HANDLES.motioncontrols,'Visible','off')

% put all controls into one HANDLES
% HANDLES.allcontrol = [...
%         HANDLES.displaycontrol HANDLES.timecontrols HANDLES.chan...
%         HANDLES.filtcontrol HANDLES.freqcontrols HANDLES.faxcontrol...
%         HANDLES.ampcontrols HANDLES.sgequal HANDLES.delimit.but...
%         HANDLES.sndcontrol HANDLES.motioncontrols HANDLES.dt.controls];
    HANDLES.allcontrol = [...
        HANDLES.displaycontrol HANDLES.timecontrols HANDLES.chan...
        HANDLES.filtcontrol HANDLES.freqcontrols HANDLES.faxcontrol...
        HANDLES.ampcontrols HANDLES.sgequal HANDLES.delimit.but...
        HANDLES.sndcontrol HANDLES.motioncontrols];
    
HANDLES.timeseriescontrol = [ ...
    HANDLES.timecontrols HANDLES.chan HANDLES.filtcontrol...
    HANDLES.sndcontrol HANDLES.delimit.but HANDLES.motioncontrols];

% HANDLES.specgramcontrol = [ ...
%     HANDLES.timeseriescontrol HANDLES.freqcontrols HANDLES.faxcontrol...
%         HANDLES.ampcontrols HANDLES.sgequal HANDLES.delimit.but HANDLES.dt.controls];
    
HANDLES.specgramcontrol = [ ...
    HANDLES.timeseriescontrol HANDLES.freqcontrols HANDLES.faxcontrol...
        HANDLES.ampcontrols HANDLES.sgequal HANDLES.delimit.but];

HANDLES.spectracontrol = [ ...
    HANDLES.timecontrols HANDLES.chan HANDLES.filtcontrol...
    HANDLES.freqcontrols HANDLES.faxcontrol...
    HANDLES.motioncontrols ...
    HANDLES.tfradios];
        
    
% 060612 smw added:
%
% 'FontUnits','normalized', ...
% 
% to UIcontrol calls so that fonts of uicontrols will scale with window
% size
   % hopefully this will make control window look similar on machines with
% differnt display resolutions 
% if strcmp(PARAMS.ver(1),'7')
% set(HANDLES.allcontrol,'FontUnits','pixels','FontSize',10);
% end     
        
% end of inticontrol.m