designer: reduce SaveDC, RestoreDC calls

git-svn-id: trunk@21609 -
This commit is contained in:
paul 2009-09-08 08:26:26 +00:00
parent d43964d5f1
commit 88641be03d

View File

@ -2501,8 +2501,9 @@ var
Diff, ItemLeftTop: TPoint; Diff, ItemLeftTop: TPoint;
IconRect, TextRect: TRect; IconRect, TextRect: TRect;
TextSize: TSize; TextSize: TSize;
IsSelected: Boolean; IsSelected, IsSaved: Boolean;
begin begin
IsSaved := False;
for i := 0 to FLookupRoot.ComponentCount - 1 do for i := 0 to FLookupRoot.ComponentCount - 1 do
begin begin
AComponent := FLookupRoot.Components[i]; AComponent := FLookupRoot.Components[i];
@ -2516,12 +2517,18 @@ begin
ItemTop := ItemLeftTop.Y - Diff.Y; ItemTop := ItemLeftTop.Y - Diff.Y;
ItemRight := ItemLeft + NonVisualCompWidth; ItemRight := ItemLeft + NonVisualCompWidth;
ItemBottom := ItemTop + NonVisualCompWidth; ItemBottom := ItemTop + NonVisualCompWidth;
if not IsSaved then
begin
aDDC.Save;
IsSaved := True;
end;
if not aDDC.RectVisible(ItemLeft, ItemTop, ItemRight, ItemBottom) then if not aDDC.RectVisible(ItemLeft, ItemTop, ItemRight, ItemBottom) then
Continue; Continue;
IsSelected := ControlSelection.IsSelected(AComponent); IsSelected := ControlSelection.IsSelected(AComponent);
aDDC.Save; with aDDC.Canvas do
with aDDC.Canvas do
begin begin
// draw component frame // draw component frame
Pen.Width := 1; Pen.Width := 1;
@ -2561,9 +2568,11 @@ begin
if (ControlSelection.Count > 1) and IsSelected then if (ControlSelection.Count > 1) and IsSelected then
ControlSelection.DrawMarkerAt(aDDC, ControlSelection.DrawMarkerAt(aDDC,
ItemLeft, ItemTop, NonVisualCompWidth, NonVisualCompWidth); ItemLeft, ItemTop, NonVisualCompWidth, NonVisualCompWidth);
aDDC.Restore;
end; end;
end; end;
if IsSaved then
aDDC.Restore;
end; end;
procedure TDesigner.DrawDesignerItems(OnlyIfNeeded: boolean); procedure TDesigner.DrawDesignerItems(OnlyIfNeeded: boolean);