%% check_call
%   callback function for check pushbutton. compiles a message of
%   the errors that were detected in each of the grids. outputs the
%   message to users via a msgbox.
% inputs:
%   object:GUI - current GUI object
%   src:double - source of the callback calling
%   event:eventdata - event that triggered the callback
% outputs:
%   none
% Author: Colin Eles elesc@mcmaster.ca
% Organization: McMaster Centre for Software Certification
function error = check_call(object,src,event)
error = 0;

msg = object.check_inputs;
if (isempty(msg))
    set(object.function_inputs_control,'BackgroundColor',[1 1 1]);
    msg = object.check_grid_condition(object.data.left_cond); %TODO: Rename this function
    
    if object.multi_mode == 0 && ~(object.data.top_cond.length == 1 && object.data.top_cond.max_width == 1 && (strcmp(object.data.top_cond.get_cell(1).get_user_string, '') || isempty(object.data.top_cond.get_cell(1).get_user_string)))
        msg = [msg object.check_grid_condition(object.data.top_cond)];
    end
    msg = [msg object.check_grid_result(object.data.outputs_grid)];
else
    set(object.function_inputs_control,'BackgroundColor',[0.92 0.65 0.65]);
end

if ~isempty(msg)
    
    if isempty(event)
        msgbox(msg);
    end
    error = 1;
end

end

