function answer = inputdlgMLS(prompt,dlg_title,num_lines,defAns)
% inputdlgMLS 
%   inputdlgMLS(prompt,dlg_title,num_lines,defAns) input dialog

%   Project: IMPACT
%   Title of Code: inputdlgMLS
%   Relevant additional documentation:
%   Developer: Carlos Gonzalez
%   External Dependencies: NA
%
%   Disclaimer
%   CAUTION: It is strongly recommended that changes to this code
%   should be avoided without first consulting with authors.

if nargin < 4
    defAns = repmat({''}, 1, numel(prompt));
end

uiColor = get(0,'defaultUicontrolBackgroundColor');
position = [100, 450, 240, 0];

nPrompt = numel(prompt);
% height
position(4) = nPrompt*50;
position(4) = position(4) + 40;


hFig = figureMLS(...
    'Position',             position,...
    'Resize',               'off',...
    'MenuBar',              'none',...
    'Name',                 dlg_title,...
    'NumberTitle',          'Off',...
    'color',                uiColor,...
    'windowStyle',          'modal',...
    'Visible',              'off'); % open a new figure


movegui(hFig, 'center');
set(hFig, 'Visible', 'on');


% prompt text
for m = 1:nPrompt
    uicontrol('Style','text', 'Position',[5, position(4)-50*(m-1)-30, position(3), 20],...
        'String', prompt{m}, 'HorizontalAlignment','left', 'FontName', 'Verdana', 'ForegroundColor', [0 0 160]/255);
end

% prompt edit box
hEdit = zeros(1, nPrompt);
for m = 1:nPrompt
    hEdit(m) = uicontrol('Style','edit', 'Position',[5, position(4)-50*(m-1)-50, position(3)-10, 24],...
        'String', defAns{m}, 'HorizontalAlignment','left', 'backGroundColor', 'white', 'FontName', 'Verdana');
end

% ok button
uicontrol('Style','pushbutton',...
    'Position',[130,8,50,24],'String','OK',...
    'Callback', {@pushbutton_okay_Callback, hEdit},...
    'FontName', 'Verdana');
% Cancel button
uicontrol('Style','pushbutton',...
    'Position',[190,8,50,24],'String','Cancel',...
    'Callback', 'close;',...
    'FontName', 'Verdana');

set(hFig, 'Visible', 'on');

h = findobj('type', 'figure', 'Visible', 'Off', 'tag', 'inputdlgMLS');
close(h);
h = figure('Visible', 'Off', 'tag', 'inputdlgMLS');
guidata(h, {});
uiwait(hFig);

h = findobj('type', 'figure', 'Visible', 'Off', 'tag', 'inputdlgMLS');
answer = guidata(h);
close(h);


function pushbutton_okay_Callback(source, evnt, hEdit)

h = findobj('type', 'figure', 'Visible', 'Off', 'tag', 'inputdlgMLS');

answer = cell(1, numel(hEdit));
for m = 1:numel(hEdit)
    answer{m} = get(hEdit(m), 'String');
end
guidata(h, answer);
close;
