gtk, gtk2: PolyLine must skip last point draw to be delphi/win32 compatible

git-svn-id: trunk@16689 -
This commit is contained in:
paul 2008-09-23 23:29:10 +00:00
parent fa633cdfbc
commit d0f9e88743
3 changed files with 26 additions and 21 deletions

View File

@ -284,6 +284,8 @@ type
FSelectedColors: TDevContextSelectedColorsType;
FOwnedGDIObjects: array[TGDIType] of PGdiObject;
FLineSkipLastPoint: Boolean;
FCurValues: TGdkGCValues;
function GetGDIObjects(ID: TGDIType): PGdiObject;
function GetOffset: TPoint;
@ -341,6 +343,8 @@ type
function HasGC: Boolean;
procedure ResetGCClipping;
procedure SetLineSkipLastPoint;
procedure UnsetLineSkipLastPoint;
// origins
property Origin: TPoint read FOrigin write FOrigin;

View File

@ -652,6 +652,24 @@ begin
SelectRegion;
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;
var
NewDrawable: PGdkPixmap;

View File

@ -6820,8 +6820,6 @@ var
FromY: Integer;
ToX: Integer;
ToY: Integer;
CurValues: TGdkGCValues;
AdjustAttrib: Boolean;
begin
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;
{$IFDEF DebugGDK}BeginGDKErrorTrap;{$ENDIF}
gdk_gc_get_values(DevCtx.GC, @CurValues);
// 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;
DevCtx.SetLineSkipLastPoint;
gdk_draw_line(DevCtx.Drawable, DevCtx.GC, FromX, FromY, ToX, ToY);
if AdjustAttrib
then begin
gdk_gc_set_line_attributes(DevCtx.GC, CurValues.line_width, CurValues.line_style,
CurValues.cap_style, CurValues.join_style);
end;
DevCtx.UnsetLineSkipLastPoint;
{$IFDEF DebugGDK}EndGDKErrorTrap;{$ENDIF}
DevCtx.PenPos:= Point(X, Y);
@ -7225,7 +7206,9 @@ begin
if Result and not DevCtx.IsNullPen
then begin
{$IFDEF DebugGDK}BeginGDKErrorTrap;{$ENDIF}
DevCtx.SetLineSkipLastPoint;
gdk_draw_lines(DevCtx.Drawable, DevCtx.GC, PointArray, NumPts);
DevCtx.UnsetLineSkipLastPoint;
{$IFDEF DebugGDKTraps}EndGDKErrorTrap;{$ENDIF}
end;