function resizeguifig(arg1,varargin)
%
% resizeguifig.m--Resizes the current figure and the gui objects it
% contains.
%
% Syntax: resizeguifig(multiplier,<FigHndl>)
% OR resizeguifig(position)
%
% e.g., designmooring; resizeguifig(.6)
% Developed in Matlab 6.1.0.450 (R12.1) on SUN OS 5.8.
% Kevin Bartlett(kpb@hawaii.edu), 2002/08/17, 04:14
%------------------------------------------------------------------------------
% Handle input arguments.
if nargin == 2
FigHndl = varargin{1};
elseif nargin == 1
FigHndl = gcf;
else
error([mfilename '.m--Incorrect number of input arguments.'])
end % if
if length(arg1) == 1,
multiplier = arg1;
OrigPos = get(FigHndl,'position');
OrigCentre = [OrigPos(1)+ 0.5*(OrigPos(3)) OrigPos(2)+ 0.5*(OrigPos(4))];
NewWidth = multiplier* OrigPos(3);
NewHeight = multiplier* OrigPos(4);
NewX = OrigCentre(1) - 0.5*NewWidth;
NewY = OrigCentre(2) - 0.5*NewHeight;
position = [NewX NewY NewWidth NewHeight];
elseif length(arg1) == 4,
position = arg1;
else
error([mfilename '.m--Input argument must be either a scale factor scalar or a 4-element vector'])
end % if
% Set all the children objects to have normalized units.
%OrigFigUnits = get(FigHndl,'units');
% Get all the children of the current figure that have a "units" property
% (this excludes uimenu objects).
%chil = findobj(FigHndl);
chil = findobj(FigHndl,'-property','units','-not','Type','Figure');
% ...Find units of children objects.
OrigUnits = get(chil,'units');
% Set all the children objects to have normalized units.
set(chil,'units','normalized');
%set(findobj(chil,'type','uicontrol'),'FontUnits','normalized');
% % Previous command also reset units of current figure. Revert the figure units to
% % the original type.
% set(FigHndl,'units',OrigFigUnits);
% Resize the figure window.
set(FigHndl,'position',position);
% Return the children objects to their original units.
for ChilCount = 1:length(chil)
set(chil(ChilCount),'units',OrigUnits{ChilCount});
end % for