mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-26 13:19:29 +02:00
Gtk3: implemented cairo based TGtk3WidgetSet.DrawGrid().
This commit is contained in:
parent
d7aa102b72
commit
f3573ad638
@ -107,32 +107,42 @@ begin
|
|||||||
*)
|
*)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TGtk3WidgetSet.DrawGrid(DC: HDC; const R: TRect; DX, DY: Integer);
|
procedure TGtk3WidgetSet.DrawGrid(DC: HDC; const R: TRect; DX, DY: Integer);
|
||||||
var
|
var
|
||||||
X, Y: Integer;
|
x, y: Integer;
|
||||||
W, H: Integer;
|
gc: TGdkRGBA;
|
||||||
SavedDC: Integer;
|
GtkDC: TGtk3DeviceContext absolute DC;
|
||||||
|
DotSize: integer;
|
||||||
|
//matrix: Tcairo_matrix_t;
|
||||||
begin
|
begin
|
||||||
SavedDC := SaveDC(DC);
|
if not IsValidDC(DC) then
|
||||||
try
|
exit;
|
||||||
W := (R.Right - R.Left - 1) div DX;
|
|
||||||
H := (R.Bottom - R.Top - 1) div DY;
|
|
||||||
|
|
||||||
// remove rows from clip rect
|
gc := TColortoTGdkRGBA(ColorToRGB(GtkDC.CurrentPen.Color));
|
||||||
for Y := 0 to H do
|
DotSize := Max(1, GtkDC.CurrentPen.Width);
|
||||||
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
|
cairo_save(GtkDC.pcr);
|
||||||
for X := 0 to W do
|
//TODO: cairo_get_matrix(pcr, @matrix);
|
||||||
|
cairo_set_source_rgb(GtkDC.pcr, gc.red, gc.green, gc.blue);
|
||||||
|
|
||||||
|
cairo_set_antialias(GtkDC.pcr, CAIRO_ANTIALIAS_NONE);
|
||||||
|
|
||||||
|
y := R.Top;
|
||||||
|
while y < R.Bottom do
|
||||||
|
begin
|
||||||
|
x := R.Left;
|
||||||
|
while x < R.Right do
|
||||||
begin
|
begin
|
||||||
if MoveToEx(DC, R.Left + X * DX, R.Top, nil) then
|
cairo_rectangle(GtkDC.pcr, x, y, DotSize, DotSize);
|
||||||
LineTo(DC, R.Left + X * DX, R.Bottom + 1);
|
x := x + DX;
|
||||||
end;
|
end;
|
||||||
finally
|
y := y + DY;
|
||||||
RestoreDC(DC, SavedDC);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
cairo_fill(GtkDC.pcr);
|
||||||
|
cairo_new_path(GtkDC.pcr);
|
||||||
|
cairo_restore(GtkDC.pcr);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user