function thisrender(this, varargin)
%RENDER Renders the UI components of the object
%   RENDER(H, HFIG, POS)
%   H       -   Object handle
%   HFIG    -   Figure handle, if none specified, gcf is used
%   POS     -   Containing frame position

%   Author(s): Z. Mecklai
%   Copyright 1988-2010 The MathWorks, Inc.

frPos = parserenderinputs(this, varargin{:});

% Get/Set defaults
sz   = gui_sizes(this);
hFig = get(this, 'FigureHandle');
cbs  = siggui_cbs(this);

if isempty(frPos), error(message('signal:siggui:specsfsspecifier:thisrender:NotSupported')); end

%Set the width based on extent of the text
label = getString(message('signal:sigtools:siggui:Units'));
strs = {label};
w = largestuiwidth(strs)+ 5*sz.pixf;

pos = [frPos(1)+sz.hfus frPos(2)+frPos(4)-sz.uh-2*sz.vfus-sz.lblTweak ...
        w sz.uh];

h.units_lbl = uicontrol('Parent', hFig, ...
    'Style',                      'Text', ...
    'Visible',                    'off', ...
    'String',                     label, ...
    'Tag',                        'fsspecifier_popup_lbl', ...
    'HorizontalAlignment',        'left', ...
    'Units',                      'pixels', ...
    'Position',                   pos);

pos = [pos(1)+pos(3) pos(2)+sz.lblTweak ...
    frPos(1)+frPos(3)-pos(1)-pos(3)-17*sz.pixf sz.uh];

h.units = uicontrol('Parent', hFig, ...
    'Style',                  'popup', ...
    'Visible',                'off', ...
    'String',                 getTranslatedStringcell('signal:siggui:labelsandvalues:updateuis',set(this, 'Units')), ...
    'Callback',               {cbs.property, this, 'units', 'change Fs units'}, ...
    'Tag',                    'fsspecifier_popup', ...
    'Value',                  2, ...
    'BackgroundColor',        'w', ...
    'Units',                  'pixels', ...
    'Position',               pos);
% Save untranslated strings in the app data for use in the callback  
setappdata(h.units, 'PopupStrings', set(this, 'Units')); 


pos = get(h.units_lbl, 'Position');

%Set the width based on extent of the text
label = 'Fs:';
strs = {label};
w = largestuiwidth(strs)+ 3*sz.pixf;

pos = [pos(1)+sz.uuhs pos(2)-(sz.uh+sz.uuvs+sz.lblTweak) w sz.uh];

h.value_lbl = uicontrol('Parent', hFig, ...
    'Style',                      'Text', ...
    'Visible',                    'off', ...
    'String',                     label, ...
    'Tag',                        'fsspecifier_editbox_lbl', ...
    'HorizontalAlignment',        'left', ...
    'Units',                      'pixels', ...
    'Position',                   pos);

left = frPos(1)+sz.hfus+w+2*sz.uuhs;

pos = [left pos(2)+sz.lblTweak frPos(1)+frPos(3)-left-17 sz.uh];

h.value = uicontrol('Parent', hFig, ...
    'Style',                  'Edit', ...
    'Callback',               {cbs.property, this, 'value', 'change Fs'}, ...
    'Visible',                'off', ...
    'Tag',                    'fsspecifier_editbox', ...
    'Units',                  'pixels', ...
    'Position',               pos, ...
    'String',                 this.Value, ...
    'HorizontalAlignment',    'left');

set(this, 'Handles', h);

wrl = handle.listener(this, [this.findprop('Units') this.findprop('Value')], ...
    'PropertyPostSet', @lclprop_listener);

set(wrl, 'CallbackTarget', this);
set(this, 'WhenRenderedListeners', wrl);

setupenablelink(this, 'units', {'hz','khz','mhz','ghz'}, 'value');

% -------------------------------------------------------------------------
function lclprop_listener(this, eventData)

prop_listener(this, eventData);

% [EOF]
