%% show
%    create the figure to show the gui used to change the settings
% inputs:
%   object:Settings - current object
% outputs:
%   none
% Author: Colin Eles elesc@mcmaster.ca
% Organization: McMaster Centre for Software Certification
function [] = show(object)
if (object.open)
    figure(object.fig);
else
    
    object.fig = figure('units','pixels',...
        'position',[0 0 object.fig_width object.fig_height],...
        'menubar','none',...
        'name','Settings',...
        'numbertitle','off',...
        'resize','off',...
        'CloseRequestFcn',@(src,event)close_fig(object,src,event));
end

% Ok Button
uicontrol('style','push',...
    'units','pix',...
    'string','Ok',...
    'HorizontalAlign','left',...
    'Parent',object.fig,...
    'Position',[object.fig_width - object.button_width*3 - object.button_offset*3, object.button_offset, object.button_width, object.button_height],...
    'callback',@(src,event)ok_call(object,src,event));

% Cancel Button
uicontrol('style','push',...
    'units','pix',...
    'string','Cancel',...
    'HorizontalAlign','left',...
    'Parent',object.fig,...
    'Position',[object.fig_width - object.button_width*2 - object.button_offset*2, object.button_offset, object.button_width, object.button_height],...
    'callback',@(src,event)cancel_call(object,src,event));


% Apply Button
uicontrol('style','push',...
    'units','pix',...
    'string','Apply',...
    'HorizontalAlign','left',...
    'Parent',object.fig,...
    'Position',[object.fig_width - object.button_width - object.button_offset, object.button_offset, object.button_width, object.button_height],...
    'callback',@(src,event)apply_call(object,src,event));

% main label
uicontrol('style','text',...
    'string','Table Tool Settings',...
    'HorizontalAlign','center',...
    'FontWeight','bold',...
    'Parent',object.fig,...
    'Position',[0, object.fig_height-object.text_offset-object.title_height, object.fig_width, object.title_height],...
    'BackgroundColor',get(object.fig,'Color'));

panel_height = object.text_offset*7+object.label_height*4;
panel_width = object.fig_width-object.text_offset*2;
panel = uipanel('Title','PVS',...
    'visible','on',...
    'units','pix',...
    'BackgroundColor',get(object.fig,'Color'),...
    'Position',[object.text_offset,object.fig_height-object.text_offset-object.title_height-panel_height,panel_width,panel_height]);


% imports label
uicontrol('style','text',...
    'string','Imports:',...
    'HorizontalAlign','left',...
    'parent',panel,...
    'Position',[object.text_offset, panel_height-object.text_offset*3-object.label_height, object.label_width, object.label_height],...
    'BackgroundColor',get(object.fig,'Color'));

elipse_width = 20;
% import text box
object.include_text = uicontrol('style','edit',...
    'units','pix',...
    'Parent',panel,...
    'String',object.pvs_includes,...
    'HorizontalAlign','center',...
    'BackgroundColor',get(object.fig,'Color'),...
    'Position',[object.text_offset+object.label_width, panel_height-object.text_offset*2-object.label_height, panel_width - (object.text_offset*3+object.label_width+elipse_width), object.label_height]);

% elipsis button
uicontrol('style','push',...
    'units','pix',...
    'string','...',...
    'HorizontalAlign','left',...
    'Parent',panel,...
    'Position',[panel_width-elipse_width-object.text_offset, panel_height-object.text_offset*2-object.label_height, elipse_width, object.label_height],...
    'callback',@(src,event)elipse_call(object,src,event));



% count label
uicontrol('style','text',...
    'string','Test Count:',...
    'HorizontalAlign','left',...
    'parent',panel,...
    'Position',[object.text_offset, panel_height-object.text_offset*4-object.label_height*2, object.label_width, object.label_height],...
    'BackgroundColor',get(object.fig,'Color'));

% count text box
object.count_text = uicontrol('style','edit',...
    'units','pix',...
    'Parent',panel,...
    'String',object.counter_trials,...
    'HorizontalAlign','center',...
    'BackgroundColor',get(object.fig,'Color'),...
    'Position',[object.text_offset+object.label_width, panel_height-object.text_offset*3-object.label_height*2, panel_width - (object.text_offset*2+object.label_width), object.label_height]);


% range label
uicontrol('style','text',...
    'string','Test Range:',...
    'HorizontalAlign','left',...
    'parent',panel,...
    'Position',[object.text_offset, panel_height-object.text_offset*5-object.label_height*3, object.label_width, object.label_height],...
    'BackgroundColor',get(object.fig,'Color'));

% range text box
object.range_text = uicontrol('style','edit',...
    'units','pix',...
    'Parent',panel,...
    'String',object.counter_range,...
    'HorizontalAlign','center',...
    'BackgroundColor',get(object.fig,'Color'),...
    'Position',[object.text_offset+object.label_width, panel_height-object.text_offset*4-object.label_height*3, panel_width - (object.text_offset*2+object.label_width), object.label_height]);

% range label
uicontrol('style','text',...
    'string','Exception Output',...
    'HorizontalAlign','left',...
    'parent',panel,...
    'Position',[object.text_offset, panel_height-object.text_offset*6-object.label_height*4, object.label_width, object.label_height],...
    'BackgroundColor',get(object.fig,'Color'));


% range text box
object.except_check = uicontrol('style','checkbox',...
    'units','pix',...
    'Parent',panel,...
    'HorizontalAlign','center',...
    'BackgroundColor',get(object.fig,'Color'),...
    'Position',[object.text_offset+object.label_width, panel_height-object.text_offset*5-object.label_height*4, panel_width - (object.text_offset*2+object.label_width), object.label_height]);

if (object.except)
    set(object.except_check,'value',get(object.except_check,'Max'));
else
    set(object.except_check,'value',get(object.except_check,'Min'));

end
object.open = 1;
end


