summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--prototypes/fpgui2/tests/drawtest.lpi2
-rw-r--r--src/corelib/gdi/gfx_gdi.pas10
-rw-r--r--src/corelib/x11/gfx_x11.pas100
3 files changed, 81 insertions, 31 deletions
diff --git a/prototypes/fpgui2/tests/drawtest.lpi b/prototypes/fpgui2/tests/drawtest.lpi
index 463c580b..348d0d52 100644
--- a/prototypes/fpgui2/tests/drawtest.lpi
+++ b/prototypes/fpgui2/tests/drawtest.lpi
@@ -2,7 +2,7 @@
<CONFIG>
<ProjectOptions>
<PathDelim Value="/"/>
- <Version Value="5"/>
+ <Version Value="6"/>
<General>
<Flags>
<SaveOnlyProjectUnits Value="True"/>
diff --git a/src/corelib/gdi/gfx_gdi.pas b/src/corelib/gdi/gfx_gdi.pas
index 921c0b1e..6c190a90 100644
--- a/src/corelib/gdi/gfx_gdi.pas
+++ b/src/corelib/gdi/gfx_gdi.pas
@@ -1294,6 +1294,11 @@ procedure TfpgCanvasImpl.DoDrawArc(x, y, w, h: TfpgCoord; a1, a2: Extended);
var
SX, SY, EX, EY: Longint;
begin
+ {Stupid GDI can't tell the difference between 0 and 360°!!}
+ if a2 = 0 then exit;
+ {Stupid GDI must be told in which direction to draw}
+ if a2 < 0 then Windows.SetArcDirection(FGc,AD_CLOCKWISE)
+ else Windows.SetArcDirection(FGc,AD_COUNTERCLOCKWISE);
Angles2Coords(x, y, w, h, a1*16, a2*16, SX, SY, EX, EY);
{$IFNDEF wince}
Windows.Arc(Fgc, x, y, x+w, y+h, SX, SY, EX, EY);
@@ -1304,6 +1309,11 @@ procedure TfpgCanvasImpl.DoFillArc(x, y, w, h: TfpgCoord; a1, a2: Extended);
var
SX, SY, EX, EY: Longint;
begin
+ {Stupid GDI can't tell the difference between 0 and 360°!!}
+ if a2 = 0 then exit;
+ {Stupid GDI must be told in which direction to draw}
+ if a2 < 0 then Windows.SetArcDirection(FGc,AD_CLOCKWISE)
+ else Windows.SetArcDirection(FGc,AD_COUNTERCLOCKWISE);
Angles2Coords(x, y, w, h, a1*16, a2*16, SX, SY, EX, EY);
{$IFNDEF wince}
Windows.Pie(Fgc, x, y, x+w, y+h, SX, SY, EX, EY);
diff --git a/src/corelib/x11/gfx_x11.pas b/src/corelib/x11/gfx_x11.pas
index 066274d4..97601011 100644
--- a/src/corelib/x11/gfx_x11.pas
+++ b/src/corelib/x11/gfx_x11.pas
@@ -1511,36 +1511,76 @@ const
cDash: array[0..1] of Char = #4#2;
cDashDot: array[0..3] of Char = #4#1#1#1;
cDashDotDot: array[0..5] of Char = #4#1#1#1#1#1;
-begin
- case AStyle of
- lsDot:
- begin
- XSetLineAttributes(xapplication.display, Fgc, 0,
- LineOnOffDash, CapNotLast, JoinMiter);
- XSetDashes(xapplication.display, Fgc, 0, cDot, 2);
- end;
- lsDash:
- begin
- XSetLineAttributes(xapplication.display, Fgc, 0,
- LineOnOffDash, CapNotLast, JoinMiter);
- XSetDashes(xapplication.display, Fgc, 0, cDash, 2);
- end;
- lsDashDot:
- begin
- XSetLineAttributes(xapplication.display, Fgc, 0,
- LineOnOffDash, CapNotLast, JoinMiter);
- XSetDashes(xapplication.display, Fgc, 0, cDashDot, 4);
- end;
- lsDashDotDot:
- begin
- XSetLineAttributes(xapplication.display, Fgc, 0,
- LineOnOffDash, CapNotLast, JoinMiter);
- XSetDashes(xapplication.display, Fgc, 0, cDashDotDot, 6);
- end;
- else // which includes lsSolid
- XSetLineAttributes(xapplication.display, Fgc, 0,
- LineSolid, CapNotLast, JoinMiter);
- end; { case }
+var
+ aCapStyle: Longint;
+begin
+ if awidth < 0 then begin
+ { Alternative line drawing - Using X algorithm instead of hardware algorithm }
+ awidth := -awidth;
+ aCapStyle := CapNotLast;
+ if (awidth > 1) and (astyle = lsSolid) then aCapStyle := CapButt;
+ case AStyle of
+ lsDot:
+ begin
+ XSetLineAttributes(xapplication.display, Fgc, 1,
+ LineOnOffDash, aCapStyle, JoinMiter);
+ XSetDashes(xapplication.display, Fgc, 0, cDot, 2);
+ end;
+ lsDash:
+ begin
+ XSetLineAttributes(xapplication.display, Fgc, 1,
+ LineOnOffDash, aCapStyle, JoinMiter);
+ XSetDashes(xapplication.display, Fgc, 0, cDash, 2);
+ end;
+ lsDashDot:
+ begin
+ XSetLineAttributes(xapplication.display, Fgc, 1,
+ LineOnOffDash, aCapStyle, JoinMiter);
+ XSetDashes(xapplication.display, Fgc, 0, cDashDot, 4);
+ end;
+ lsDashDotDot:
+ begin
+ XSetLineAttributes(xapplication.display, Fgc, 1,
+ LineOnOffDash, aCapStyle, JoinMiter);
+ XSetDashes(xapplication.display, Fgc, 0, cDashDotDot, 6);
+ end;
+ else // which includes lsSolid
+ XSetLineAttributes(xapplication.display, Fgc, awidth,
+ LineSolid, aCapStyle, JoinMiter);
+ end; { case }
+ end
+ else begin
+ awidth := 0;
+ case AStyle of
+ lsDot:
+ begin
+ XSetLineAttributes(xapplication.display, Fgc, 0,
+ LineOnOffDash, CapNotLast, JoinMiter);
+ XSetDashes(xapplication.display, Fgc, 0, cDot, 2);
+ end;
+ lsDash:
+ begin
+ XSetLineAttributes(xapplication.display, Fgc, 0,
+ LineOnOffDash, CapNotLast, JoinMiter);
+ XSetDashes(xapplication.display, Fgc, 0, cDash, 2);
+ end;
+ lsDashDot:
+ begin
+ XSetLineAttributes(xapplication.display, Fgc, 0,
+ LineOnOffDash, CapNotLast, JoinMiter);
+ XSetDashes(xapplication.display, Fgc, 0, cDashDot, 4);
+ end;
+ lsDashDotDot:
+ begin
+ XSetLineAttributes(xapplication.display, Fgc, 0,
+ LineOnOffDash, CapNotLast, JoinMiter);
+ XSetDashes(xapplication.display, Fgc, 0, cDashDotDot, 6);
+ end;
+ else // which includes lsSolid
+ XSetLineAttributes(xapplication.display, Fgc, awidth,
+ LineSolid, CapNotLast, JoinMiter);
+ end; { case }
+ end; { awidth >= 0 }
end;
procedure TfpgCanvasImpl.DoDrawString(x, y: TfpgCoord; const txt: string);