[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/System.Drawing.Postscript PostscriptP
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/System.Drawing.Postscript PostscriptPen.cs, NONE, 1.1 PostscriptGraphics.cs, 1.2, 1.3 PostscriptPrintSession.cs, 1.2, 1.3 PostscriptToolkit.cs, 1.1, 1.2 |
Date: |
Sat, 19 Jul 2003 23:11:11 -0400 |
Update of /cvsroot/dotgnu-pnet/pnetlib/System.Drawing.Postscript
In directory subversions:/tmp/cvs-serv20622/System.Drawing.Postscript
Modified Files:
PostscriptGraphics.cs PostscriptPrintSession.cs
PostscriptToolkit.cs
Added Files:
PostscriptPen.cs
Log Message:
Implement simple line drawing primitives in the Postscript driver.
--- NEW FILE ---
/*
* PostscriptPen.cs - Implementation of pens for System.Drawing.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Drawing.Toolkit
{
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
internal sealed class PostscriptPen : IToolkitPen
{
// Internal state.
private Pen properties;
private PostscriptGraphics selectedInto;
// Constructor.
public PostscriptPen(Pen properties)
{
this.properties = properties;
this.selectedInto = null;
}
// Select this pen into a graphics object.
public void Select(IToolkitGraphics _graphics)
{
PostscriptGraphics graphics = (_graphics as
PostscriptGraphics);
if(graphics != null)
{
if(selectedInto == graphics &&
graphics.selectObject == this)
{
// Same pen as last time, so
don't output a
// redundant version of the
Postscript definitions.
return;
}
if(selectedInto != null)
{
selectedInto.selectObject =
null;
selectedInto = null;
}
graphics.writer.WriteLine("grestore
gsave");
switch(properties.PenType)
{
case PenType.SolidColor:
{
Color color =
properties.Color;
graphics.writer.WriteLine
("{0} {1} {2}
setrgbcolor",
((double)(color.R)) / 255.0,
((double)(color.G)) / 255.0,
((double)(color.B)) / 255.0);
}
break;
// TODO: other pen types
}
graphics.writer.WriteLine("{0}
setlinewidth",
properties.Width);
// TODO: caps, joins, miters, etc
selectedInto = graphics;
graphics.selectObject = this;
}
}
// Dispose of this pen.
public void Dispose()
{
// Nothing to do here in this implementation.
}
}; // class PostscriptPen
}; // namespace System.Drawing.Toolkit
Index: PostscriptGraphics.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/System.Drawing.Postscript/PostscriptGraphics.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** PostscriptGraphics.cs 19 Jul 2003 10:17:10 -0000 1.2
--- PostscriptGraphics.cs 20 Jul 2003 03:11:09 -0000 1.3
***************
*** 31,36 ****
{
// Internal state.
! private TextWriter writer;
private PostscriptPrintSession session;
// Constructor.
--- 31,37 ----
{
// Internal state.
! internal TextWriter writer;
private PostscriptPrintSession session;
+ internal IToolkitSelectObject selectObject;
// Constructor.
***************
*** 41,44 ****
--- 42,46 ----
this.writer = writer;
this.session = session;
+ this.selectObject = null;
}
***************
*** 69,73 ****
public override void DrawLine(int x1, int y1, int x2, int y2)
{
! // TODO
}
--- 71,76 ----
public override void DrawLine(int x1, int y1, int x2, int y2)
{
! writer.WriteLine("{0} {1} moveto {2} {3} lineto
stroke",
! x1, y1, x2,
y2);
}
***************
*** 75,79 ****
public override void DrawLines(Point[] points)
{
! // TODO
}
--- 78,89 ----
public override void DrawLines(Point[] points)
{
! int index;
! writer.Write("{0} {1} moveto ", points[0].X,
points[0].Y);
! for(index = 1; index < points.Length; ++index)
! {
! writer.Write("{0} {1} lineto ",
!
points[index].X, points[index].Y);
! }
! writer.WriteLine("stroke");
}
***************
*** 81,85 ****
public override void DrawPolygon(Point[] points)
{
! // TODO
}
--- 91,102 ----
public override void DrawPolygon(Point[] points)
{
! int index;
! writer.Write("{0} {1} moveto ", points[0].X,
points[0].Y);
! for(index = 1; index < points.Length; ++index)
! {
! writer.Write("{0} {1} lineto ",
!
points[index].X, points[index].Y);
! }
! writer.WriteLine("closepath stroke");
}
***************
*** 87,91 ****
public override void FillPolygon(Point[] points, FillMode fillMode)
{
! // TODO
}
--- 104,115 ----
public override void FillPolygon(Point[] points, FillMode fillMode)
{
! int index;
! writer.Write("{0} {1} moveto ", points[0].X,
points[0].Y);
! for(index = 1; index < points.Length; ++index)
! {
! writer.Write("{0} {1} lineto ",
!
points[index].X, points[index].Y);
! }
! writer.WriteLine("closepath fill");
}
Index: PostscriptPrintSession.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/System.Drawing.Postscript/PostscriptPrintSession.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** PostscriptPrintSession.cs 19 Jul 2003 10:17:10 -0000 1.2
--- PostscriptPrintSession.cs 20 Jul 2003 03:11:09 -0000 1.3
***************
*** 133,137 ****
writer.WriteLine("/pagelevel save def");
! // TODO: apply a rotation for landscape mode.
// Mark the end of the page header information.
--- 133,148 ----
writer.WriteLine("/pagelevel save def");
! // Flip the co-ordinate system so that the
top-left
! // margin position on the page is the origin.
! double temp;
! if(e.PageSettings.Landscape)
! {
! // TODO: rotate the co-ordinate system
for landscape mode.
! }
! else
! {
! temp = (e.PageBounds.Height * 72.0) /
100.0;
! writer.WriteLine("0 {0} translate 1 -1
scale", temp);
! }
// Mark the end of the page header information.
***************
*** 141,144 ****
--- 152,159 ----
onPage = true;
+ // Save the graphics state. It will be
restored and
+ // re-saved every time a pen or brush is
changed.
+ writer.WriteLine("gsave");
+
// Create a "Graphics" object for this page and
return it.
return ToolkitManager.CreateGraphics
***************
*** 152,156 ****
{
// Restore the VM state at the start of
the page.
! writer.WriteLine("pagelevel restore");
// Show the page.
--- 167,171 ----
{
// Restore the VM state at the start of
the page.
! writer.WriteLine("grestore pagelevel
restore");
// Show the page.
Index: PostscriptToolkit.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/System.Drawing.Postscript/PostscriptToolkit.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** PostscriptToolkit.cs 18 Jul 2003 05:17:56 -0000 1.1
--- PostscriptToolkit.cs 20 Jul 2003 03:11:09 -0000 1.2
***************
*** 23,31 ****
{
using System.Drawing.Printing;
internal sealed class PostscriptToolkit : NullToolkit
{
! // TODO: handle pens, brushes, etc
}; // class PostscriptToolkit
--- 23,82 ----
{
+ using System.Drawing;
using System.Drawing.Printing;
+ using System.Drawing.Drawing2D;
+ using System.Drawing.Imaging;
internal sealed class PostscriptToolkit : NullToolkit
{
! // Create a solid toolkit brush.
! public override IToolkitBrush CreateSolidBrush(Color color)
! {
! return null;
! }
!
! // Create a hatched toolkit brush.
! public override IToolkitBrush CreateHatchBrush
! (HatchStyle style, Color foreColor, Color
backColor)
! {
! return null;
! }
!
! // Create a linear gradient brush. Returns null if the
! // toolkit does not support linear gradient brushes.
! public override IToolkitBrush CreateLinearGradientBrush
! (RectangleF rect, Color color1, Color color2,
! LinearGradientMode mode)
! {
! return null;
! }
! public override IToolkitBrush CreateLinearGradientBrush
! (RectangleF rect, Color color1, Color color2,
! float angle, bool isAngleScaleable)
! {
! return null;
! }
!
! // Create a texture brush.
! public override IToolkitBrush CreateTextureBrush
! (TextureBrush properties, RectangleF dstRect,
! ImageAttributes imageAttr)
! {
! return null;
! }
!
! // Create a toolkit pen from the properties in the specified object.
! // If the toolkit does not support the precise combination of pen
! // properties, it will return the closest matching pen.
! public override IToolkitPen CreatePen(Pen pen)
! {
! return new PostscriptPen(pen);
! }
!
! // Create a toolkit font from the properties in the specified object.
! public override IToolkitFont CreateFont(Font font)
! {
! return null;
! }
}; // class PostscriptToolkit
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/System.Drawing.Postscript PostscriptPen.cs, NONE, 1.1 PostscriptGraphics.cs, 1.2, 1.3 PostscriptPrintSession.cs, 1.2, 1.3 PostscriptToolkit.cs, 1.1, 1.2,
Rhys Weatherley <address@hidden> <=