function mouseResizeDialogPanelWidth(dp,h,e)
% Change width of dialog presenter panel.
%
% Resizes all docked dialogs within panel.

%   Copyright 2010-2011 The MathWorks, Inc.

if nargin>2
  h.CurrentPoint = e.Point;
end

if dp.PanelVisible && ~dp.PanelLock && ~dp.PanelLockWidth
    updatePanelWidth(dp);
    resizeChildPanels(dp,'width');
end

end

function updatePanelWidth(dp)
% Update .PanelWidth property based on current mouse coord.

% At the start of the panel-width drag operation,
% .ResizePanelWidthMouseCache is initialized to the vector:
%    [pt_x, dp.PanelWidth]
%
cache = dp.ResizePanelWidthMouseCache;
origX = cache(1);
origWidth = cache(2);

pt_parent = getMouseInParentRefFrame(dp); % xxx could just get x-coord
if strcmpi(dp.DockLocation,'left');
    delta_x = pt_parent(1)-origX;  % info panel is on left
else
    delta_x = origX-pt_parent(1);  % info panel is on right
end

dp.PanelWidth = min(dp.PanelMaxWidth, ...
    max(dp.PanelMinWidth, origWidth+delta_x) );

end
