function h = render_quantizationswitch(hFig)
% RENDER_QUANTIZATIONSWITCH Renders the Quantization frame and its uicontrol.
%
% Input:
%   hFig  - Handle to the Filter Design GUI figure.
%
% Outputs:
%   h - handle to the frame, its label, and uicontrols.

%   Author(s): P. Costa
%   Copyright 1988-2000 The MathWorks, Inc.
%   $Revision: 1.5 $  $Date: 2000/06/13 21:23:33 $ 

% Render the full-size Current Filter Information frame.
h = quantizationswitch_frame(hFig);

% Render Quantization Switch checkbox 
h.quantizeSwitch = quantization_switch(hFig,h);


%----------------------------------------------------------------------
function h_qswitchFr = quantizationswitch_frame(hFig)
% QUANTIZATIONSWITCH_FRAME Renders the Quantization switch frame.
%
% Input:
%   hFig   - Handle to the Filter Design GUI figure.
%
% Output:
%   h_qswitchFr - A structure containing the handles to the frame & its label.

% Sizes and spaces used in building the Filter Design GUI.
sz = gui_sizes;

% Cache the figure position and frame height.
figPos = get(hFig,'Position');
frHeight = sz.fh2;

% Using sz.fhl so that bottom of frame will align with the 
% bottom of the Analysis area.
yPos = figPos(4)-sz.fh1-sz.vffs; 

frameWidth = (figPos(3)-5.5*sz.ffs)/4;
framePos = [1.5*sz.ffs yPos frameWidth frHeight];
bgc = get(hFig,'Color');

frame = framewlabel(hFig,framePos,'Quantization','quantizationswitch',bgc);
h_qswitchFr.frame = frame;


%-------------------------------------------------------------------------
function h_quantizeSwitch = quantization_switch(hFig, h)
% QUANTIZATION_SWITCH  Renders the checkbox for turning ON/OFF quantization
%                      only if the FD Toolbox is installed.
%
% Inputs:
%   hFig   - Handle to the Filter Design GUI figure.
%   h      - Strucutre containg the handles to the Quantization frame 
%
% Output:
%   h_quantizeSwitch - Handles to the uicontrol that is the switch.

% Cache the uicontrol sizes and spaces used in this GUI.
sz = gui_sizes;

frPos = get(h.frame(1),'Position');
frColor = get(h.frame(1),'BackgroundColor');

% Determine necessary width for the checkbox.
btnStr = {'Turn quantization on'};
uiWidth = largestuiwidth(btnStr,'checkbox');

% Uicontrol positioning.
x = frPos(1)+sz.hfus; % Left justified.
yOffset = (frPos(4)-sz.uh)/2;
y = frPos(2)+yOffset; 
quantizeSwitchPos = [x y uiWidth sz.uh];

h_quantizeSwitch = uicontrol(...
    'Style','Checkbox',...
    'Tag','quantizebtnSwitch',...
    'BackgroundColor',frColor,...
    'Position',quantizeSwitchPos,...
    'String',btnStr,...
    'Visible','On',...
    'Callback', @quantizationswitch_cb);

% [EOF] render_quantizationswitch.m
