function installtip(this,gobjects,tipfcn,info)
%INSTALLTIP  Installs point tip on specified G-objects.

%   Author(s): P. Gahinet, John Glass
%   Copyright 1986-2004 The MathWorks, Inc.
%   $Revision: 1.1.6.2 $  $Date: 2004/04/11 00:26:51 $

% RE: TIPFCN is either '' or a MATLAB callback. The tip text is generated by evaluating the 
%     tip function according to
%        TIPTEXT = feval(@fcn,INFO,arg1,...,argN)
%     for TIPFCN = {@fcn arg1 ... argN}
if isempty(tipfcn)
   % Clear tip function
   BDF = '';
else
   BDF = {@LocalButtonDownFcn tipfcn info};
end
set(gobjects,'ButtonDownFcn',BDF)

for ct = 1:length(gobjects)
    set(gobjects(ct),'handlevisibility','off')
    %% Get the behavior object
    hb = hggetbehavior(gobjects(ct),'DataCursor');
    if iscell(tipfcn)
        set(hb,'UpdateFcn',{tipfcn{1} info tipfcn{2:end}});
    else
        set(hb,'UpdateFcn',{tipfcn info});
    end
end

%%%%%%%%%%  Local Functions   %%%%%%%%%%  

function tip = LocalButtonDownFcn(EventSrc,EventData,tipfcn,info)
% Creates data tip and sets its tip function

if ~isa(info.View.PointTips{info.Row,info.Col},'tippack.linetip') 
    %% Create the datatip
    tip = pointtip(EventSrc,info.TipOptions{:});
    PointTips = info.View.PointTips; 
    PointTips{info.Row,info.Col} = tip;
    info.View.PointTips = PointTips;
else
    tip = [];
end
