function varargout = ltpda_constructor_helper(varargin)

% LTPDA_CONSTRUCTOR_HELPER allows the user to explore object constructors.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DESCRIPTION: LTPDA_CONSTRUCTOR_HELPER allows the user to explore object constructors.
%
% CALL:        ltpda_constructor_helper
%
%
% VERSION:     $Id: ltpda_constructor_helper.m,v 1.4 2008/06/20 10:51:55 hewitson Exp $
%
% HISTORY: 07-03-08 M Hewitson
%             Creation
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%% Check if I exist already
id = findobj('Tag', 'LTPDAconstructor_helper');
if ~isempty(id)
  figure(id)
  return
end

%% Some initial setup

Gproperties.Gcol    = [240 240 240]/255;
Gproperties.Gwidth  = 500;
Gproperties.Gheight = 300;
Gproperties.Gborder = 10;
fontsize = getappdata(0, 'ltpda_repo_gui_fontsize');

Gproperties.Screen   = get(0,'screensize');
Gproperties.Gposition = [150 ...
  150 ...
  Gproperties.Gwidth...
  Gproperties.Gheight];

%  Initialize and hide the GUI as it is being constructed.
mainfig = figure('Name', 'LTPDA Constructor Helper',...
  'NumberTitle', 'off',...
  'Visible','off',...
  'Position',Gproperties.Gposition,...
  'Color', Gproperties.Gcol,...
  'Resize', 'off',...
  'ToolBar',      'none',           ...
  'NextPlot',     'new',            ...
  'MenuBar', 'none',...
  'Tag', 'LTPDAconstructor_helper');

% Set mainfig callbacks
set(mainfig, 'CloseRequestFcn', {@ltpda_constructor_helper_close, mainfig});

% Set Application data
setappdata(mainfig, 'Gproperties', Gproperties);


%% GUI parts

%--- Class selection
% text field
sth = uicontrol(mainfig,'Style','text',...
  'String','Class',...
  'HorizontalAlignment', 'left', ...
  'BackgroundColor', Gproperties.Gcol, ...
  'Position',[10 Gproperties.Gheight-40 50 25]);

% pop-up dialog
pmh = uicontrol(mainfig,'Style','popupmenu',...
  'String', utils.helper.ltpda_userclasses,...
  'Value', 1, ...
  'BackgroundColor', Gproperties.Gcol, ...
  'Tag', 'LTPDA_constructor_helper_class', ...
  'Callback', {'ltpda_constructor_helper_class', mainfig}, ...
  'Position',[90 Gproperties.Gheight-40 120 25]);

%--- Constructor set list


% text field
sth = uicontrol(mainfig,'Style','text',...
  'String','Sets',...
  'HorizontalAlignment', 'left', ...
  'BackgroundColor', Gproperties.Gcol, ...
  'Position',[10 Gproperties.Gheight-80 50 25]);

% Set list
lbh = uicontrol(mainfig,'Style','listbox',...
                'String', '',...
                'Value', 1, ...
                'BackgroundColor', 'w', ...
                'Tag', 'LTPDA_constructor_helper_sets', ...
                'Callback', {'ltpda_constructor_helper_sets', mainfig}, ...
                'Position',[10 Gproperties.Gheight-270 200 200]);
              
% Constructor view
eth = uicontrol(mainfig,'Style','edit',...
                'String','',...
                'BackgroundColor', 'w', ...
                'Max', 100, ...
                'HorizontalAlignment', 'left', ...
                'FontSize', 14, ...
                'Tag', 'LTPDA_constructor_helper_constructor', ...
                'Position',[240 Gproperties.Gheight-210 250 200]);

% Variable name
sth = uicontrol(mainfig,'Style','text',...
  'String','Variable',...
  'HorizontalAlignment', 'left', ...
  'BackgroundColor', Gproperties.Gcol, ...
  'Position',[240 Gproperties.Gheight-260 50 25]);

eth = uicontrol(mainfig,'Style','edit',...
                'String','obj',...
                'BackgroundColor', 'w', ...
                'HorizontalAlignment', 'center', ...
                'Tag', 'LTPDA_constructor_helper_var', ...
                'Position',[300 Gproperties.Gheight-260 50 25]);
              

%  Build btn
pbh = uicontrol(mainfig,'Style','pushbutton','String','Build',...
  'Position',[360  Gproperties.Gheight-260 60 25],...
  'Tag', 'LTPDA_constructor_helper_buildBtn');
set(pbh, 'Callback', {'ltpda_constructor_helper_build'});

%% Start the GUI

% Make the GUI visible.
set(mainfig,'Visible','on')


%% Callbacks

  %--- Close
  function ltpda_constructor_helper_close(varargin)
    disp('* Goodbye from the LTPDA Constructor Helper *')
    delete(varargin{end})
  end
end



