function dguicw1d(varargin)
%DGUICW1D Demonstrates continuous wavelet GUI tools in the Wavelet Toolbox. 

%   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 12-Mar-96.
%   Last Revision: 27-Jun-1999.
%   Copyright 1995-2000 The MathWorks, Inc.
% $Revision: 1.9 $

% Check arguments.
%=================
switch nargin
  case 0 , figNumber = 0; wait_mode = 1;
  case 2 ,   
    if isequal(varargin{1},'noGUI')
        figNumber = 0;
        wait_mode = varargin{2};
    else
        figNumber = varargin{1};
        wait_mode = 1;
    end
end

if wshowdrv('init',figNumber)
    if figNumber==0 
        active_fig = cw1dtool;
	wenamngr('Inactive',active_fig);
    else
        active_fig = demoguim('startshow',figNumber,'cw1dtool');
	wenamngr('Inactive',active_fig);
        wshowdrv('setactfig',figNumber,active_fig);
        return;
    end
end
if figNumber , active_fig = wshowdrv('getactfig',figNumber); end

% Initialization.
%----------------
handles = wfigmngr('getValue',active_fig,['CW1D_handles']);
UIC = handles.hdl_UIC;
pop_ccm = UIC.pop_ccm;
pop_pal = cbcolmap('get',active_fig,'pop_pal');
cba_ccm = get(pop_ccm,'Callback');
cba_pal = get(pop_pal,'Callback');
map_val = get(pop_pal,'Value');
if map_val==2 , map_val = 1; else , map_val =2; end
str_col = get(pop_pal,'String');
str_col = deblank(str_col(map_val,:));

cw1dmngr('demo',active_fig,'freqbrk','db1',1,1,32,1);
wenamngr('Inactive',active_fig);
msg = str2mat(...
        ['To change the Colormap use the popupmenu at the ' ...
         'bottom right of the window.'], ...
        ['We select the ' str_col '  colormap']...
        );
if dguiwait('pause',figNumber,0,active_fig,msg); return; end

set(pop_pal,'value',map_val);
eval(cba_pal);

if wshowdrv('pause',figNumber,wait_mode), return; end;

msg = str2mat(...
        ['To change the Coloration Mode use the popupmenu in the ' ...
         'middle of the window.'], ...
         'The present mode is the (init+ by scale + abs) mode. ', ...
         'We select the (init+ by scale) mode.'...
        );
if dguiwait('pause',figNumber,0,active_fig,msg); return; end

set(pop_ccm,'value',2);
eval(cba_ccm);

if wshowdrv('pause',figNumber,wait_mode), return; end;

cw1dmngr('demo',active_fig,'quachirp','db1',1,1,64,1);
wenamngr('Inactive',active_fig);
if wshowdrv('pause',figNumber,wait_mode), return; end;

msg = 'We select the hot colormap';
if dguiwait('pause',figNumber,0,active_fig,msg); return; end

set(pop_pal,'value',4);
eval(cba_pal);
set([pop_ccm;pop_pal],'Enable','On');
if figNumber==0
    wshowdrv('pause',figNumber,wait_mode);
    cw1dtool('close',active_fig);
    delete(active_fig)
end
