function drawn = g_drawParPanel(varargin)
   
   global params objName guiFontSize

if nparams(params)==0, drawn = 0; return;
else drawn = 1;
end

% if nargin>0 && strcmp(varargin{1},'cbk'), return; end
   
% panelDimens = get(currPanel, 'Position');
backColor   = [1 1 1];

try close(findobj('Tag','parampanelFigure')); catch, end;
lineSpacing = 22 * guiFontSize/10;
setappdata(0,'ltpda_gui_LineSpacing',lineSpacing);
currPos = get(0,'PointerLocation');
panelFigureSize = [350 10+21*nparams(params)];
panelDimens = [currPos(1)-100 currPos(2)-60-panelFigureSize(2) panelFigureSize];
currPanel = figure('Position',panelDimens,'Name','Parameters','Tag','parampanelFigure','Resize','off','NumberTitle','off','Toolbar','none','Menubar','none');

y = nparams(params);
for pp=1:y
   paramkeys{pp} = params.params(pp).key;
   paramvals{pp} = params.params(pp).val;
end

currParam = -1;
for ii = 1:y
    currParam = currParam + 1;
%     addedPar = 0;
%   % Checkbox to enable input setting:
%     objName{ii,1}   =   uicontrol('Parent',currPanel,'Units','pixels','Position',[10,panelDimens(4)-lineSpacing*(currParam+1+currGap),14,14],'Value',paramEnabled(ii),'Visible','on','Enable','on','Callback', @g_EnableCallback,'Tag',paramkeys{ii},'UserData',ii,'Style','checkbox');
%   % Remove Param Button:
%     try %#ok<ALIGN>
%     if strcmpi(paramkeys{ii}(1:7),'addPar_')
%         uicontrol('Parent',currPanel,'Units','pixels','Position',[panelDimens(3)-30 panelDimens(4)-lineSpacing*(currParam+1+currGap) 20 20],'String','-','TooltipString','Remove this parameter','Visible','on','Enable','on','UserData',ii,'Callback', @g_RemParamCallback,'Style','pushbutton');
%         addedPar = 1;
%         paramkeys{ii}(1:7) = [];
%     end
%     catch, end

    switch class(paramvals{ii})

      % ==========================================================================     
        case {'double'}
      % ==========================================================================
          % Key value:
            objName{ii,2} =  uicontrol('Parent',currPanel,'BackgroundColor',backColor,'TooltipString','Key (name of the parameter)','Units','pixels','Position',[5 panelDimens(4)-(4+lineSpacing*(currParam+1)) 70 20],'String',paramkeys{ii},'FontSize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Style','text');
          % Val value:
            data = mat2str(paramvals{ii});
            objName{ii,3} = uicontrol('Parent',currPanel,'TooltipString','Val (value of the parameter)','Units','pixels','Position',[80 panelDimens(4)-lineSpacing*(currParam+1) 180 guiFontSize*20/10],'String',data,'Fontsize',guiFontSize+1,'Visible','on','Enable','on','UserData',ii,'Callback',@g_editValueCallback,'Style','edit');
%             objName{ii,4} = uicontrol('UserData',objName{ii,3},'TooltipString','Expand the edit field','Parent',currPanel,'BackgroundColor',[0.7 0.7 0.7],'HorizontalAlignment','left','Position',[405 panelDimens(4)+3-lineSpacing*(currParam+1+currGap) 13 13],'Visible','on','Callback',@g_ExpandEdit,'Style','pushbutton');
          % Enable parameters from Simulink:
            objName{ii,10} = uicontrol('TooltipString','Retrieve from Simulink','String','','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[270 panelDimens(4)-lineSpacing*(currParam+1) 20 20],'Max',1,'Min',0,'Value',0,'Visible','on','Tag',num2str(ii),'UserData',[],'Callback',@g_fromSimulinkCallback,'Style','checkbox');
            if strcmp(paramvals{ii},'-->')
                set(objName{ii,3},'Visible','off');
                set(objName{ii,4},'Visible','off');
                set(objName{ii,10},'Value',1);
            end

      % ==========================================================================     
        case {'char'}
      % ==========================================================================
          % Key value:
            objName{ii,2} =  uicontrol('Parent',currPanel,'BackgroundColor',backColor,'TooltipString','Key (name of the parameter)','Units','pixels','Position',[5 panelDimens(4)-(4+lineSpacing*(currParam+1)) 70 20],'String',paramkeys{ii},'FontSize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Style','text');
            if strcmpi(paramkeys{ii},'filename')
              % Browse button:
                currFilename = paramvals{ii};
                if isempty(currFilename), currFilename = 'Browse'; end
                if numel(currFilename)>30, currFilename = ['...',currFilename(end-29:end)]; end
                objName{ii,3} =  uicontrol('Parent',currPanel,'Units','pixels','Position',[80 panelDimens(4)-lineSpacing*(currParam+1) 180 20],'String',currFilename,'Visible','on','Enable','on','Callback',@g_browseCallback,'Style','pushbutton');
            else
             % Val value:
               objName{ii,3} = uicontrol('Parent',currPanel,'Units','pixels','Position',[80 panelDimens(4)-lineSpacing*(currParam+1) 180 20],'String',['''',strrep(paramvals{ii},'''',''''''),''''],'Fontsize',guiFontSize+1,'Visible','on','Enable','on','UserData',ii,'Callback',@g_editValueCallback,'Style','edit');
               objName{ii,4} =   uicontrol('UserData',objName{ii,3},'TooltipString','Expand the edit field','Parent',currPanel,'BackgroundColor',[0.7 0.7 0.7],'HorizontalAlignment','left','Position',[405 panelDimens(4)+3-lineSpacing*(currParam+1) 13 13],'Visible','on','Callback',@g_ExpandEdit,'Style','pushbutton');
            end
            objName{ii,10} = uicontrol('TooltipString','Retrieve from Simulink','String','','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[270 panelDimens(4)-lineSpacing*(currParam+1) 20 20],'Max',1,'Min',0,'Value',0,'Visible','on','Tag',num2str(ii),'UserData',[],'Callback',@fromSimulinkCallback,'Style','checkbox');
            if strcmp(paramvals{ii},'-->')
               set(objName{ii,3},'Visible','off');
               set(objName{ii,4},'Visible','off');
               set(objName{ii,10},'Value',1);
            else
               set(objName{ii,10},'Visible','off');
            end
               
%       % ==========================================================================     
%         case {'unit'}
%       % ==========================================================================
%           % Key value:
%             objName{ii,2} =  uicontrol('Parent',currPanel,'Units','pixels','Position',[120 panelDimens(4)-lineSpacing*(currParam+1) 60 20],'String',paramkeys{ii},'FontSize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Callback',@g_editNameCallback,'Style','edit');
%             if ~noParamsReq && ~addedPar
%                 set(objName{ii,2},'Style','text','BackgroundColor',backColor,'Position',[50 panelDimens(4)-(4+lineSpacing*(currParam+1)) 120 20]);
%             end
%           % Val value:
%             unitVal = paramvals{ii}.strs; if isempty(unitVal), unitVal = {''}; end
%             allunits = unit.supportedUnits;
%             unitsTooltip = 'Supported units: ';
%             for kk=1:numel(allunits), unitsTooltip = [unitsTooltip,allunits{kk},',']; end
%             unitsTooltip(end)=[];
%             objName{ii,3} = uicontrol('Parent',currPanel,'TooltipString',unitsTooltip,'Units','pixels','Position',[200 panelDimens(4)-lineSpacing*(currParam+1) 200 20],'String',['''',unitVal{1},''''],'Fontsize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Callback',@g_unitValCallback,'Style','edit');
%             
%       % ==========================================================================     
%         case {'logical'}
%       % ==========================================================================
%           % Key value:
%             objName{ii,2} =  uicontrol('Parent',currPanel,'Units','pixels','Position',[120 panelDimens(4)-lineSpacing*(currParam+1) 60 20],'String',paramkeys{ii},'FontSize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Callback',@g_editNameCallback,'Style','edit');
%             if ~noParamsReq && ~addedPar
%                 set(objName{ii,2},'Style','text','BackgroundColor',backColor,'Position',[50 panelDimens(4)-(4+lineSpacing*(currParam+1)) 120 20]);
%             end
%           % Val value:
%             objName{ii,3} = uicontrol('Parent',currPanel,'Units','pixels','Position',[200 panelDimens(4)-lineSpacing*(currParam+1) 100 20],'String',{'false','true'},'Value',paramvals{ii}+1,'Fontsize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Callback',@g_logicValCallback,'Style','popupmenu');

      % ==========================================================================     
        case 'specwin'
      % ==========================================================================     
            selectWind      = paramvals{ii}.type;
            listWindows         = ['Kaiser',specwin.getTypes];
            selectWindValue = strmatch(selectWind,listWindows,'exact');
          % Window text:
            objName{ii,2} =   uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[5 panelDimens(4)-lineSpacing*(currParam+1)-3 60 20],'String','Window:','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Visible','on','Style','text');
          % Window type popup:
            objName{ii,3} =  uicontrol('Parent',currPanel,'Units','pixels','Position',[80 panelDimens(4)-lineSpacing*(currParam+1) 100 20],'String',listWindows,'TooltipString','Window names','Value',selectWindValue,'Visible','on','Enable','off','Tag',paramkeys{ii},'UserData',ii,'Callback', @g_WindListCallback,'Style','popupmenu');
          % Length value:
            currLength = num2str(length(params.params(ii).val.win));
            objName{ii,4} =  uicontrol('Parent',currPanel,'Units','pixels','Position',[190 panelDimens(4)-lineSpacing*(currParam+1) 70 20],'String',num2str(currLength),'TooltipString','Window Length','Visible','on','Enable','off','UserData',ii,'Callback', @g_WindlengthCallback,'Style','edit');
            if strcmp(selectWind,'Kaiser')
             % PSL value if Kaiser:
               currPSL = params.params(ii).val.psll;
               objName{ii,5} =  uicontrol('Parent',currPanel,'Units','pixels','Position',[240 panelDimens(4)-lineSpacing*(currParam+1) 60 20],'String',num2str(currPSL),'TooltipString','Peak Sidelobe','Visible','on','Enable','off','UserData',ii,'Callback',@g_WindPSLCallback,'Style','edit');
            end
          % Simulink checkbox:
            objName{ii,10} = uicontrol('TooltipString','Retrieve from Simulink','String','','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[270 panelDimens(4)-lineSpacing*(currParam+1) 20 20],'Max',1,'Min',0,'Value',0,'Visible','on','Tag',num2str(ii),'UserData',paramvals{ii},'Callback',@g_fromSimulinkCallback,'Style','checkbox');

            

      % ==========================================================================
        otherwise % Other types of param?
      % ==========================================================================
          % Key value:
            objName{ii,3} =  uicontrol('Parent',currPanel,'BackgroundColor',backColor,'Units','pixels','Position',[5 panelDimens(4)-5-lineSpacing*(currParam+1) 100 20],'String',paramkeys{ii},'FontSize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Callback',@g_editNameCallback,'Style','text');
          % Text: input not supported. Please construct by proper block.
            objName{ii,4} = uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[100 panelDimens(4)-4-lineSpacing*(currParam+1) 150 20],'String','Not supported','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Visible','on','Style','text');
            fromSimulink = 0;
            
          % Simulink checkbox:
            objName{ii,10} = uicontrol('TooltipString','Retrieve from Simulink','String','','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[270 panelDimens(4)-lineSpacing*(currParam+1) 20 20],'Max',1,'Min',0,'Value',fromSimulink,'Visible','on','Tag',num2str(ii),'UserData',paramvals{ii},'Callback',@g_fromSimulinkCallback,'Style','checkbox');
            
  % ==============================================================================
    end % of SWITCH the param type
    
end % of cycle among params

   
   
   
end