function draw_onto( object, parent_handle )
%DRAW_ONTO Draws the controls onto the parent_handle.  This function needs
%to be called everytime an update happens.
%   This function draws the entire handle onto the handle.  This function
%   needs to be called everytime the back table is updated.  The class will
%   notify when its necessary.

    [x, y] = object.get_bounding_box();
    
    if size(object.controls, 2) ~= size(object.drawables, 2) || size(object.controls, 1) ~= size(object.drawables, 1)
        object.controls(size(object.drawables, 1), size(object.drawables, 2)) = 0;
    end

   for i = 1:size(object.drawables, 2)
        for j = 1:size(object.drawables, 1)
            if ~isempty( object.drawables{j, i} )
                [~, yi] = object.drawables{j, i}.get_bounding_box();
                if object.controls(j, i) == 0 || ~ishandle(object.controls(j, i))
                    p = uipanel('Parent', parent_handle, 'Units', 'pixels', 'Position', [sum(object.column_sizes(1:j-1))+(j-1)*20, y - sum(object.row_sizes(1:i)) - (i-1)*20, x, y]);
                    object.controls(j, i) = p;
                else
                    p = object.controls(j, i);
                    set(p, 'Position', [sum(object.column_sizes(1:j-1))+(j-1)*20, y - sum(object.row_sizes(1:i-1)) - (i-1)*20 - yi, x, y]);
                end
            object.drawables{j, i}.draw(p);
            end
        end
   end
end
