function uirestore(uistate,kidsOnly)
%UIRESTORE Restores the interactive functionality figure window.
%  UIRESTORE(UISTATE) restores the state of a figure window to
%  what it was before it was suspended by a call to UISUSPEND.
%  The input UISTATE is the structure returned by UISUSPEND which
%  contains information about the window properties and the button
%  down functions for all of the objects in the figure.
%
%  UIRESTORE(UISTATE, 'children') updates ONLY the children of
%  the figure.
%
%  UIRESTORE(UISTATE, 'nochildren') updates ONLY the figure.
%
%  See also UISUSPEND.

%   Chris Griffin, 6-19-97
%   Copyright 1984-2000 The Mathworks, Inc.
%   $Revision: 1.10 $ $Date: 2000/06/02 04:41:57 $

if ~isempty(uistate.ploteditEnable)
   plotedit(uistate.figureHandle,...
           'setenabletools',uistate.ploteditEnable);
end

updateFigure   = 1;    
updateChildren = 1;

if nargin == 2
    if strcmpi(kidsOnly, 'children');
        updateFigure   = 0;
    elseif strcmpi(kidsOnly, 'nochildren');
        updateChildren = 0;
    end        
end

if updateFigure
    set(uistate.figureHandle, 'pointer',uistate.Pointer, ...
                      'PointerShapeCData', uistate.PointerCdata, ...
                      'PointerShapeHotSpot', uistate.PointerHotSpot, ...
                      'KeyPressFcn', uistate.KeyPressFcn, ...
                      'WindowButtonMotionFcn', uistate.WindowButtonMotionFcn ,...
                      'WindowButtonDownFcn', uistate.WindowButtonDownFcn, ...
                      'WindowButtonUpFcn', uistate.WindowButtonUpFcn);
end

if updateChildren
    stillAround = ishandle(uistate.children);
    set(uistate.children(stillAround), ...
        {'buttondownfcn'},uistate.ButtonDownFcns(stillAround), ...
        {'BusyAction'}, uistate.BusyAction(stillAround), ...
        {'Interruptible'}, uistate.Interruptible(stillAround));
end
