mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 10:39:18 +02:00
gtk, gtk2: PolyLine must skip last point draw to be delphi/win32 compatible
git-svn-id: trunk@16689 -
This commit is contained in:
parent
fa633cdfbc
commit
d0f9e88743
@ -284,6 +284,8 @@ type
|
|||||||
FSelectedColors: TDevContextSelectedColorsType;
|
FSelectedColors: TDevContextSelectedColorsType;
|
||||||
|
|
||||||
FOwnedGDIObjects: array[TGDIType] of PGdiObject;
|
FOwnedGDIObjects: array[TGDIType] of PGdiObject;
|
||||||
|
FLineSkipLastPoint: Boolean;
|
||||||
|
FCurValues: TGdkGCValues;
|
||||||
|
|
||||||
function GetGDIObjects(ID: TGDIType): PGdiObject;
|
function GetGDIObjects(ID: TGDIType): PGdiObject;
|
||||||
function GetOffset: TPoint;
|
function GetOffset: TPoint;
|
||||||
@ -341,6 +343,8 @@ type
|
|||||||
function HasGC: Boolean;
|
function HasGC: Boolean;
|
||||||
procedure ResetGCClipping;
|
procedure ResetGCClipping;
|
||||||
|
|
||||||
|
procedure SetLineSkipLastPoint;
|
||||||
|
procedure UnsetLineSkipLastPoint;
|
||||||
|
|
||||||
// origins
|
// origins
|
||||||
property Origin: TPoint read FOrigin write FOrigin;
|
property Origin: TPoint read FOrigin write FOrigin;
|
||||||
|
@ -652,6 +652,24 @@ begin
|
|||||||
SelectRegion;
|
SelectRegion;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TGtkDeviceContext.SetLineSkipLastPoint;
|
||||||
|
begin
|
||||||
|
gdk_gc_get_values(GC, @FCurValues);
|
||||||
|
FLineSkipLastPoint :=
|
||||||
|
(FCurValues.line_width = 1) or
|
||||||
|
(FCurValues.cap_style <> GDK_CAP_NOT_LAST);
|
||||||
|
if FLineSkipLastPoint then
|
||||||
|
gdk_gc_set_line_attributes(GC, 0, FCurValues.line_style,
|
||||||
|
GDK_CAP_NOT_LAST, FCurValues.join_style);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TGtkDeviceContext.UnsetLineSkipLastPoint;
|
||||||
|
begin
|
||||||
|
if FLineSkipLastPoint then
|
||||||
|
gdk_gc_set_line_attributes(GC, FCurValues.line_width, FCurValues.line_style,
|
||||||
|
FCurValues.cap_style, FCurValues.join_style);
|
||||||
|
end;
|
||||||
|
|
||||||
function TGtkDeviceContext.SelectBitmap(AGdiObject: PGdiObject): PGdiObject;
|
function TGtkDeviceContext.SelectBitmap(AGdiObject: PGdiObject): PGdiObject;
|
||||||
var
|
var
|
||||||
NewDrawable: PGdkPixmap;
|
NewDrawable: PGdkPixmap;
|
||||||
|
@ -6820,8 +6820,6 @@ var
|
|||||||
FromY: Integer;
|
FromY: Integer;
|
||||||
ToX: Integer;
|
ToX: Integer;
|
||||||
ToY: Integer;
|
ToY: Integer;
|
||||||
CurValues: TGdkGCValues;
|
|
||||||
AdjustAttrib: Boolean;
|
|
||||||
begin
|
begin
|
||||||
Assert(False, Format('trace:> [TGtkWidgetSet.LineTo] DC:0x%x, X:%d, Y:%d', [DC, X, Y]));
|
Assert(False, Format('trace:> [TGtkWidgetSet.LineTo] DC:0x%x, X:%d, Y:%d', [DC, X, Y]));
|
||||||
|
|
||||||
@ -6840,26 +6838,9 @@ begin
|
|||||||
ToY:=Y+DCOrigin.Y;
|
ToY:=Y+DCOrigin.Y;
|
||||||
|
|
||||||
{$IFDEF DebugGDK}BeginGDKErrorTrap;{$ENDIF}
|
{$IFDEF DebugGDK}BeginGDKErrorTrap;{$ENDIF}
|
||||||
gdk_gc_get_values(DevCtx.GC, @CurValues);
|
DevCtx.SetLineSkipLastPoint;
|
||||||
|
|
||||||
// LineTo should not paint the last point
|
|
||||||
// this works under gtk only with line_width=0
|
|
||||||
// => set linewidth to 0 and GDK_CAP_NOT_LAST
|
|
||||||
AdjustAttrib := (CurValues.line_width = 1)
|
|
||||||
or (CurValues.cap_style <> GDK_CAP_NOT_LAST);
|
|
||||||
if AdjustAttrib
|
|
||||||
then begin
|
|
||||||
gdk_gc_set_line_attributes(DevCtx.GC, 0, CurValues.line_style,
|
|
||||||
GDK_CAP_NOT_LAST, CurValues.join_style);
|
|
||||||
end;
|
|
||||||
|
|
||||||
gdk_draw_line(DevCtx.Drawable, DevCtx.GC, FromX, FromY, ToX, ToY);
|
gdk_draw_line(DevCtx.Drawable, DevCtx.GC, FromX, FromY, ToX, ToY);
|
||||||
|
DevCtx.UnsetLineSkipLastPoint;
|
||||||
if AdjustAttrib
|
|
||||||
then begin
|
|
||||||
gdk_gc_set_line_attributes(DevCtx.GC, CurValues.line_width, CurValues.line_style,
|
|
||||||
CurValues.cap_style, CurValues.join_style);
|
|
||||||
end;
|
|
||||||
{$IFDEF DebugGDK}EndGDKErrorTrap;{$ENDIF}
|
{$IFDEF DebugGDK}EndGDKErrorTrap;{$ENDIF}
|
||||||
|
|
||||||
DevCtx.PenPos:= Point(X, Y);
|
DevCtx.PenPos:= Point(X, Y);
|
||||||
@ -7225,7 +7206,9 @@ begin
|
|||||||
if Result and not DevCtx.IsNullPen
|
if Result and not DevCtx.IsNullPen
|
||||||
then begin
|
then begin
|
||||||
{$IFDEF DebugGDK}BeginGDKErrorTrap;{$ENDIF}
|
{$IFDEF DebugGDK}BeginGDKErrorTrap;{$ENDIF}
|
||||||
|
DevCtx.SetLineSkipLastPoint;
|
||||||
gdk_draw_lines(DevCtx.Drawable, DevCtx.GC, PointArray, NumPts);
|
gdk_draw_lines(DevCtx.Drawable, DevCtx.GC, PointArray, NumPts);
|
||||||
|
DevCtx.UnsetLineSkipLastPoint;
|
||||||
{$IFDEF DebugGDKTraps}EndGDKErrorTrap;{$ENDIF}
|
{$IFDEF DebugGDKTraps}EndGDKErrorTrap;{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user