function dynamicPanel_ManualInput(h)
% DYNAMICPANEL_MANUALINPUT initializes dynamic panel

% Author: Rong Chen 
% Revised: 
% Copyright 1986-2004 The MathWorks, Inc.

h.Handles.PNLtimeManual = uipanel('Parent',h.Handles.PNLtime,...
    'Units','Pixels',...
    'BackgroundColor',h.DefaultPos.TimePanelDefaultColor,...
    'BorderType','none',...
    'Position',[5 ...
                5 ...
                h.DefaultPos.widthpnl-10 ...
                h.DefaultPos.TXTtimeSheetbottomoffset-h.DefaultPos.separation-5], ...
    'Visible','off' ...                
    );
% create sheet combobox controls whose values are based on the rawdata
h.Handles.TXTuseFormat = uicontrol('Parent',h.Handles.PNLtimeManual,...
    'style','text', ...
    'Units','Pixels',...
    'BackgroundColor',h.DefaultPos.TimePanelDefaultColor,...
    'HorizontalAlignment','Right', ...
    'String','Use : ', ...
    'Position',[h.DefaultPos.TXTtimeIndexleftoffset ...
                h.DefaultPos.TXTtimeIndexbottomoffset ...
                h.DefaultPos.TXTtimeIndexwidth ...
                h.DefaultPos.heighttxt] ...
    );
h.Handles.COMBuseFormat = uicontrol('Parent',h.Handles.PNLtimeManual,...
    'style','popupmenu',...
    'Units', 'Pixels',...
    'BackgroundColor',[1 1 1], ...
    'String',[{'Absolute Date/Time'};{'Relative Time'}], ...
    'Value',2, ...
    'Position',[h.DefaultPos.COMBtimeIndexleftoffset ...
                h.DefaultPos.TXTtimeIndexbottomoffset+4 ...
                h.DefaultPos.COMBtimeIndexwidth ...
                h.DefaultPos.heightcomb], ...
    'Callback',{@localSwitchUse h} ...
    );
% start, end, interval, format
h.Handles.TXTtimeManualStart = uicontrol('Parent',h.Handles.PNLtimeManual,...
    'style','text', ...
    'Units','Pixels',...
    'BackgroundColor',h.DefaultPos.TimePanelDefaultColor,...
    'String','Start Time : ',...
    'HorizontalAlignment','Right', ...
    'Position',[h.DefaultPos.TXTtimeSheetStartleftoffset ...
                h.DefaultPos.TXTtimeSheetStartbottomoffset ...
                h.DefaultPos.TXTtimeSheetStartwidth ...
                h.DefaultPos.heighttxt] ...
    );
h.Handles.EDTtimeManualStart = uicontrol('Parent',h.Handles.PNLtimeManual,...
    'style','edit', ...
    'Units','Pixels',...
    'BackgroundColor',[1 1 1],...
    'String',' ',...
    'HorizontalAlignment','Left',...
    'Position',[h.DefaultPos.EDTtimeSheetStartleftoffset ...
                h.DefaultPos.TXTtimeSheetStartbottomoffset+2 ...
                h.DefaultPos.EDTtimeSheetStartwidth ...
                h.DefaultPos.heightedt], ...
    'Callback',{@localSetStartTime h} ...
    );
h.Handles.TXTtimeManualEnd = uicontrol('Parent',h.Handles.PNLtimeManual,...
    'style','text', ...
    'Units','Pixels',...
    'BackgroundColor',h.DefaultPos.TimePanelDefaultColor,...
    'String','Samples : ',...
    'HorizontalAlignment','Right', ...
    'Position',[h.DefaultPos.TXTtimeSheetEndleftoffset ...
                h.DefaultPos.TXTtimeSheetEndbottomoffset ...
                h.DefaultPos.TXTtimeSheetEndwidth ...
                h.DefaultPos.heighttxt] ...
    );
h.Handles.EDTtimeManualEnd = uicontrol('Parent',h.Handles.PNLtimeManual,...
    'style','edit', ...
    'Units','Pixels',...
    'BackgroundColor',[1 1 1],...
    'String',' ',...
    'HorizontalAlignment','Left',...
    'Position',[h.DefaultPos.EDTtimeSheetEndleftoffset ...
                h.DefaultPos.TXTtimeSheetEndbottomoffset+2 ...
                h.DefaultPos.EDTtimeSheetEndwidth ...
                h.DefaultPos.heightedt], ...
    'Enable','off' ...
    );
h.Handles.TXTtimeManualInterval = uicontrol('Parent',h.Handles.PNLtimeManual,...
    'style','text', ...
    'Units','Pixels',...
    'BackgroundColor',h.DefaultPos.TimePanelDefaultColor,...
    'String','Time Step : ',...
    'HorizontalAlignment','Right', ...
    'Position',[h.DefaultPos.TXTtimeSheetIntervalleftoffset ...
                h.DefaultPos.TXTtimeSheetIntervalbottomoffset ...
                h.DefaultPos.TXTtimeSheetIntervalwidth ...
                h.DefaultPos.heighttxt] ...
    );
h.Handles.EDTtimeManualInterval = uicontrol('Parent',h.Handles.PNLtimeManual,...
    'style','edit', ...
    'Units','Pixels',...
    'BackgroundColor',[1 1 1],...
    'String',' ',...
    'HorizontalAlignment','Left',...
    'Position',[h.DefaultPos.EDTtimeSheetIntervalleftoffset ...
                h.DefaultPos.TXTtimeSheetIntervalbottomoffset+2 ...
                h.DefaultPos.EDTtimeSheetIntervalwidth ...
                h.DefaultPos.heightedt], ...
    'Callback',{@localSetInterval h} ...
    );
h.Handles.TXTtimeManualIntervalUnit = uicontrol('Parent',h.Handles.PNLtimeManual,...
    'style','text', ...
    'Units','Pixels',...
    'BackgroundColor',h.DefaultPos.TimePanelDefaultColor,...
    'String','(in secs)',...
    'HorizontalAlignment','Left', ...
    'Position',[h.DefaultPos.UNITtimeSheetIntervalleftoffset ...
                h.DefaultPos.TXTtimeSheetIntervalbottomoffset ...
                h.DefaultPos.UNITtimeSheetIntervalwidth ...
                h.DefaultPos.heighttxt], ...
    'Visible','off' ...                
    );
h.Handles.TXTtimeManualFormat = uicontrol('Parent',h.Handles.PNLtimeManual,...
    'style','text', ...
    'Units','Pixels',...
    'BackgroundColor',h.DefaultPos.TimePanelDefaultColor,...
    'HorizontalAlignment','Right', ...
    'String','Format : ', ...
    'Position',[h.DefaultPos.TXTtimeSheetFormatleftoffset ...
                h.DefaultPos.TXTtimeSheetFormatbottomoffset ...
                h.DefaultPos.TXTtimeSheetFormatwidth ...
                h.DefaultPos.heighttxt] ...
    );
h.Handles.COMBtimeManualFormat = uicontrol('Parent',h.Handles.PNLtimeManual,...
    'style','popupmenu',...
    'Units', 'Pixels',...
    'BackgroundColor',[1 1 1], ...
    'String',{'Years','Weeks','Days','Hours','Mins','Secs'}, ...
    'Value',6, ...
    'Position',[h.DefaultPos.COMBtimeSheetFormatleftoffset ...
                h.DefaultPos.TXTtimeSheetFormatbottomoffset+4 ...
                h.DefaultPos.COMBtimeSheetFormatwidth ...
                h.DefaultPos.heightcomb], ...
    'Callback',{@localSwitchFormat h} ...
    );


function localSwitchUse(eventSrc, eventData, h)
%% Callback for the absolute/relative time format combo

if get(h.Handles.COMBuseFormat,'Value')==1
    % Set the contents of the format combo to be absolute time formats
    set(h.Handles.TXTtimeManualFormat,'String','Format : ')
    set(h.Handles.COMBtimeManualFormat,'String',h.IOData.formatcell.matlabFormatString,'Value',1)
    % display the content in relative time formats
    set(h.Handles.EDTtimeManualStart,'String','');
    set(h.Handles.EDTtimeManualInterval,'String','');
    % switch unit text on
    set(h.Handles.TXTtimeManualIntervalUnit,'Visible','on');
else
    % Set the contents of the format combo to be relative time formats
    set(h.Handles.TXTtimeManualFormat,'String','Unit : ')
    set(h.Handles.COMBtimeManualFormat,'String',{'Years','Weeks','Days','Hours','Mins','Secs'},'Value',6);
    % display the content in relative time formats
    set(h.Handles.EDTtimeManualStart,'String','');
    set(h.Handles.EDTtimeManualInterval,'String','');
    % switch unit text off
    set(h.Handles.TXTtimeManualIntervalUnit,'Visible','off');
end


function localSetStartTime(eventSrc, eventData, h)
%% Callback for the start time edit box


function localSetInterval(eventSrc, eventData, h)
%% Callback for the interval time edit box


function localSwitchFormat(eventSrc, eventData, h)
%% Callback for the format/unit edit box

