function enablequantized(hFig,quantizationswitch)
%ENABLEQUANTIZED Change the enable state of the quantized page.
%   ENABLEQUANTIZED(hFig,quantizationswitch) restores the enable state of the
%   quantized page if quantizationswitch==1, and disables if
%   quantizationswitch==0, where hFig is the handle to the current figure.  The
%   user data is changed.

%   Thomas A. Bryan
%   Copyright 1988-2000 The MathWorks, Inc.
%   $Revision: 1.2 $  $Date: 2000/06/15 20:04:53 $ 

% Get the user data
ud = get(hFig,'userdata');

if nargin<2
  quantizationswitch = ud.flags.quantizationswitch;
end

switch quantizationswitch
  case -1
    % Turn them all on.
    set(ud.h.quantize_params.enablehandles,'enable','on');
  case 1
    enable(hFig);
  case 0
    disable(hFig);
end
drawnow

function enable(hFig)
%ENABLE Restore the enable state of the quantized page.
%   ENABLE(hFig) restores the enable state of the quantized page
%   where hFig is the handle to the current figure.  The user data is not
%   changed.

% Get the user data
ud = get(hFig,'userdata');

if isfield(ud.specs.quantize,'enablestates')
  % Restore the enable states if they have been previously stored.
  set(ud.h.quantize_params.enablehandles,...
      {'enable'},ud.specs.quantize.enablestates);
end

function disable(hFig)
%DISABLE  Disable the quantized page.
%   DISABLE(hFig) stores the current enable settings of the
%   quantized page, and then disables everything on the quantized page.  The
%   current enable settings are stored in the figure's user data.

% Get the user data
ud = get(hFig,'userdata');

% Store the current values of the enable states
ud.specs.quantize.enablestates = ...
    get(ud.h.quantize_params.enablehandles,'enable');

% Disable all the quantize parameters
set(ud.h.quantize_params.enablehandles,'enable','off');

% Set the user data
set(hFig,'userdata',ud)
