IDE designer: boosted paint grid

git-svn-id: trunk@13997 -
This commit is contained in:
tombo 2008-02-06 12:39:13 +00:00
parent a7714f09e0
commit f013d19da8
4 changed files with 40 additions and 14 deletions

View File

@ -2101,20 +2101,12 @@ begin
end;
// paint points
if ShowGrid then begin
StepX:=GridSizeX;
StepY:=GridSizeY;
MaxX:=AWinControl.ClientWidth;
MaxY:=AWinControl.ClientHeight;
x := 0;
while x <= MaxX do begin
y := 0;
while y <= MaxY do begin
aDDC.Canvas.Pixels[x, y] := GridColor;
Inc(y, StepY);
end;
Inc(x, StepX);
end;
if ShowGrid then
begin
ADDC.Canvas.Pen.Color := GridColor;
ADDC.Canvas.Pen.Width := 1;
ADDC.Canvas.Pen.Style := psSolid;
DrawGrid(ADDC.Canvas.Handle, AWinControl.ClientRect, GridSizeX, GridSizeY);
end;
if ShowBorderSpacing then begin

View File

@ -181,6 +181,34 @@ begin
DefaultDockImage(ANewRect);
end;
procedure TWidgetSet.DrawGrid(DC: HDC; const R: TRect; DX, DY: Integer);
var
X, Y: Integer;
W, H: Integer;
SavedDC: Integer;
begin
SavedDC := SaveDC(DC);
try
W := (R.Right - R.Left - 1) div DX;
H := (R.Bottom - R.Top - 1) div DY;
// remove rows from clip rect
for Y := 0 to H do
begin
ExcludeClipRect(DC, R.Left, R.Top + Y * DY + 1, R.Right + 1, R.Top + (Y + 1) * DY);
end;
// draw vertical lines cross excluded rows -> only grid cross points painted
for X := 0 to W do
begin
if MoveToEx(DC, R.Left + X * DX, R.Top, nil) then
LineTo(DC, R.Left + X * DX, R.Bottom + 1);
end;
finally
RestoreDC(DC, SavedDC);
end;
end;
function TWidgetSet.ExtUTF8Out(DC: HDC; X, Y: Integer; Options: Longint;
Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean;
begin

View File

@ -154,6 +154,11 @@ begin
WidgetSet.DrawDefaultDockImage(AOldRect, ANewRect, AOperation);
end;
procedure DrawGrid(DC: HDC; const R: TRect; DX, DY: Integer);
begin
WidgetSet.DrawGrid(DC, R, DX, DY);
end;
function ExtUTF8Out(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect;
Str: PChar; Count: Longint; Dx: PInteger): Boolean;
begin

View File

@ -67,6 +67,7 @@ function DCClipRegionValid(DC: HDC): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$E
procedure DeallocateHWnd(Wnd: HWND); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
procedure DrawArrow(Arrow: TComponent; Canvas: TPersistent); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
procedure DrawDefaultDockImage(AOldRect, ANewRect: TRect; AOperation: TDockImageOperation); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
procedure DrawGrid(DC: HDC; const R: TRect; DX, DY: Integer); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function ExtUTF8Out(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}