[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] pnetlib/System.Drawing/Toolkit IToolkitGraphics.cs
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] pnetlib/System.Drawing/Toolkit IToolkitGraphics.cs, 1.8, 1.9 ToolkitGraphicsBase.cs, 1.12, 1.13 ToolkitGraphicsImageBase.cs, 1.2, 1.3 ToolkitManager.cs, 1.9, 1.10 |
Date: |
Thu, 20 Nov 2003 07:42:22 +0000 |
Update of /cvsroot/dotgnu-pnet/pnetlib/System.Drawing/Toolkit
In directory subversions:/tmp/cvs-serv21563/System.Drawing/Toolkit
Modified Files:
IToolkitGraphics.cs ToolkitGraphicsBase.cs
ToolkitGraphicsImageBase.cs ToolkitManager.cs
Log Message:
Add the "DrawGlyph" primitive, for drawing simple xbm-based glyphs for
minimize, close, scroll arrows, etc.
Index: ToolkitGraphicsImageBase.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/System.Drawing/Toolkit/ToolkitGraphicsImageBase.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ToolkitGraphicsImageBase.cs 16 Nov 2003 20:28:49 -0000 1.2
--- ToolkitGraphicsImageBase.cs 20 Nov 2003 07:42:20 -0000 1.3
***************
*** 19,24 ****
* 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
{
--- 19,24 ----
* 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
{
***************
*** 27,51 ****
using System.Drawing.Drawing2D;
using DotGNU.Images;
!
! [NonStandardExtra]
! public abstract class ToolkitGraphicsImageBase : ToolkitGraphicsBase
! {
protected ToolkitImageBase image;
protected IToolkitPen selectedPen;
protected IToolkitBrush selectedBrush;
! protected IToolkitFont selectedFont;
!
! protected ToolkitGraphicsImageBase(IToolkit toolkit,
IToolkitImage image)
! : base(toolkit)
! {
! this.image = image as ToolkitImageBase;
! }
!
! protected override void Dispose(bool disposing)
! {
!
! }
!
!
// Clear the entire drawing surface.
public override void Clear(Color color)
--- 27,51 ----
using System.Drawing.Drawing2D;
using DotGNU.Images;
!
! [NonStandardExtra]
! public abstract class ToolkitGraphicsImageBase : ToolkitGraphicsBase
! {
protected ToolkitImageBase image;
protected IToolkitPen selectedPen;
protected IToolkitBrush selectedBrush;
! protected IToolkitFont selectedFont;
!
! protected ToolkitGraphicsImageBase(IToolkit toolkit,
IToolkitImage image)
! : base(toolkit)
! {
! this.image = image as ToolkitImageBase;
! }
!
! protected override void Dispose(bool disposing)
! {
!
! }
!
!
// Clear the entire drawing surface.
public override void Clear(Color color)
***************
*** 61,119 ****
Frame frame = image.image.GetFrame(0);
// TODO: Finish off
! int dy = y2 - y1;
! int dx = x2 - x1;
! int stepx, stepy;
!
! if (dy < 0)
! {
! dy = -dy;
! stepy = -frame.Stride;
! }
! else
! stepy = frame.Stride;
! if (dx < 0)
! {
! dx = -dx;
! stepx = -1;
! }
! else
! {
! stepx = 1;
! }
! dy <<= 1;
! dx <<= 1;
!
! y1 *= frame.Stride;
! y2 *= frame.Stride;
! SetPixelLine(frame, x1,y1, color);
! if (dx > dy)
! {
! int fraction = dy - (dx >> 1);
! while (x1 != x2)
! {
! if (fraction >= 0)
! {
! y1 += stepy;
! fraction -= dx;
! }
! x1 += stepx;
! fraction += dy;
! SetPixelLine(frame,
x1,y1, color);
! }
! }
! else
! {
! int fraction = dx - (dy >> 1);
! while (y1 != y2)
! {
! if (fraction >= 0)
! {
! x1 += stepx;
! fraction -= dy;
! }
! y1 += stepy;
! fraction += dx;
! SetPixelLine(frame,
x1,y1, color);
! }
}
}
--- 61,119 ----
Frame frame = image.image.GetFrame(0);
// TODO: Finish off
! int dy = y2 - y1;
! int dx = x2 - x1;
! int stepx, stepy;
!
! if (dy < 0)
! {
! dy = -dy;
! stepy = -frame.Stride;
! }
! else
! stepy = frame.Stride;
! if (dx < 0)
! {
! dx = -dx;
! stepx = -1;
! }
! else
! {
! stepx = 1;
! }
! dy <<= 1;
! dx <<= 1;
!
! y1 *= frame.Stride;
! y2 *= frame.Stride;
! SetPixelLine(frame, x1,y1, color);
! if (dx > dy)
! {
! int fraction = dy - (dx >> 1);
! while (x1 != x2)
! {
! if (fraction >= 0)
! {
! y1 += stepy;
! fraction -= dx;
! }
! x1 += stepx;
! fraction += dy;
! SetPixelLine(frame,
x1,y1, color);
! }
! }
! else
! {
! int fraction = dx - (dy >> 1);
! while (y1 != y2)
! {
! if (fraction >= 0)
! {
! x1 += stepx;
! fraction -= dy;
! }
! y1 += stepy;
! fraction += dx;
! SetPixelLine(frame,
x1,y1, color);
! }
}
}
***************
*** 143,151 ****
// Fill a polygon using the current brush.
! public override void FillPolygon(Point[] points, FillMode
fillMode)
! {
! // TODO
! }
!
// Draw an arc within a rectangle defined by four points.
public override void DrawArc (Point[] rect, float startAngle,
float sweepAngle)
--- 143,151 ----
// Fill a polygon using the current brush.
! public override void FillPolygon(Point[] points, FillMode
fillMode)
! {
! // TODO
! }
!
// Draw an arc within a rectangle defined by four points.
public override void DrawArc (Point[] rect, float startAngle,
float sweepAngle)
***************
*** 154,260 ****
// f(x,y) = Ax^2 + Bxy + Cy^2 + Dx + Ey
+ F
// Ellipse B^2 - 4AC<0, circle if A=C
and B=0
! /*final static int OCTANTS =
0x12650374;
! public void conic(
! int x0, int y0, //
starting point
! int x1, int y1, // ending
point
! Color color, // color
of curve
! float A, float B, float C, //
coefficients of conic
! float D, float E, float F)
!
! int pix = color.getRGB();
! int dxDiag, dyDiag, dxLine, dyLine;
! int octant = 0;
! float d, u, v;
!
! F = 0;
! D = 2*A*x0 + B*y0 + D;
! E = B*x0 + 2*C*y0 + E;
!
! if (D >= 0) {
! dxDiag = dxLine = 1;
! octant += 1;
! } else {
! dxDiag = dxLine = -1;
! }
!
! if (E >= 0) {
! dyDiag = dyLine = 1;
! octant += 2;
! } else {
! dyDiag = dyLine = -1;
! }
!
! if (Math.abs(E) > Math.abs(D)) {
! dxLine = 0;
! u = dxDiag*dyDiag*B/2 + C +
dyDiag*E;
! d = u + A/4 + dxDiag*D/2 + F;
! v = u + dxDiag*D;
! octant += 4;
! } else {
! dyLine = 0;
! u = dxDiag*dyDiag*B/2 + A +
dxDiag*D;
! d = u + C/4 + dyDiag*E/2 + F;
! v = u + dyDiag*E;
! }
! octant = (OCTANTS >> (4*octant)) & 7;
!
! float k1 = 2*(A + dyLine*dyDiag*(C -
A));
! float k2 = dxDiag*dyDiag*B;
! float k3 = 2*(A + C + k2);
! k2 += k1;
!
! loop: do {
! if ((octant & 1) == 0) {
! while (2*v <= k2) {
!
raster.setPixel(pix, x0, y0);
! if ((x0 == x1)
& (y0 == y1)) break loop;
! if (d < 0) {
! x0 +=
dxLine;
! y0 +=
dyLine;
! u += k1;
! v += k2;
! d += u;
! } else {
! x0 +=
dxDiag;
! y0 +=
dyDiag;
! u += k2;
! v += k3;
! d += v;
! }
! }
! d = d - u + v/2 - k2/2
+ 3*k3/8;
! u = -u + v - k2/2 +
k3/2;
! v = v - k2 + k3/2;
! k1 = k1 - 2*k2 + k3;
! k2 = k3 - k2;
! int t = dxLine; dxLine
= -dyLine; dyLine = t;
! } else {
! while (2*u < k2) {
!
raster.setPixel(pix, x0, y0);
! if ((x0 == x1)
& (y0 == y1)) break loop;
! if (d > 0) {
! x0 +=
dxLine;
! y0 +=
dyLine;
! u += k1;
! v += k2;
! d += u;
! } else {
! x0 +=
dxDiag;
! y0 +=
dyDiag;
! u += k2;
! v += k3;
! d += v;
! }
! }
! float dk = k1 - k2;
! d = d + u - v + dk;
! v = 2*u - v + dk;
! u = u + dk;
! k3 = k3 + 4*dk;
! k2 = k1 + dk;
! int t = dxDiag; dxDiag
= -dyDiag; dyDiag = t;
! }
! octant = (octant + 1) & 7;
! } while (true);*/
}
--- 154,260 ----
// f(x,y) = Ax^2 + Bxy + Cy^2 + Dx + Ey
+ F
// Ellipse B^2 - 4AC<0, circle if A=C
and B=0
! /*final static int OCTANTS =
0x12650374;
! public void conic(
! int x0, int y0, //
starting point
! int x1, int y1, // ending
point
! Color color, // color
of curve
! float A, float B, float C, //
coefficients of conic
! float D, float E, float F)
!
! int pix = color.getRGB();
! int dxDiag, dyDiag, dxLine, dyLine;
! int octant = 0;
! float d, u, v;
!
! F = 0;
! D = 2*A*x0 + B*y0 + D;
! E = B*x0 + 2*C*y0 + E;
!
! if (D >= 0) {
! dxDiag = dxLine = 1;
! octant += 1;
! } else {
! dxDiag = dxLine = -1;
! }
!
! if (E >= 0) {
! dyDiag = dyLine = 1;
! octant += 2;
! } else {
! dyDiag = dyLine = -1;
! }
!
! if (Math.abs(E) > Math.abs(D)) {
! dxLine = 0;
! u = dxDiag*dyDiag*B/2 + C +
dyDiag*E;
! d = u + A/4 + dxDiag*D/2 + F;
! v = u + dxDiag*D;
! octant += 4;
! } else {
! dyLine = 0;
! u = dxDiag*dyDiag*B/2 + A +
dxDiag*D;
! d = u + C/4 + dyDiag*E/2 + F;
! v = u + dyDiag*E;
! }
! octant = (OCTANTS >> (4*octant)) & 7;
!
! float k1 = 2*(A + dyLine*dyDiag*(C -
A));
! float k2 = dxDiag*dyDiag*B;
! float k3 = 2*(A + C + k2);
! k2 += k1;
!
! loop: do {
! if ((octant & 1) == 0) {
! while (2*v <= k2) {
!
raster.setPixel(pix, x0, y0);
! if ((x0 == x1)
& (y0 == y1)) break loop;
! if (d < 0) {
! x0 +=
dxLine;
! y0 +=
dyLine;
! u += k1;
! v += k2;
! d += u;
! } else {
! x0 +=
dxDiag;
! y0 +=
dyDiag;
! u += k2;
! v += k3;
! d += v;
! }
! }
! d = d - u + v/2 - k2/2
+ 3*k3/8;
! u = -u + v - k2/2 +
k3/2;
! v = v - k2 + k3/2;
! k1 = k1 - 2*k2 + k3;
! k2 = k3 - k2;
! int t = dxLine; dxLine
= -dyLine; dyLine = t;
! } else {
! while (2*u < k2) {
!
raster.setPixel(pix, x0, y0);
! if ((x0 == x1)
& (y0 == y1)) break loop;
! if (d > 0) {
! x0 +=
dxLine;
! y0 +=
dyLine;
! u += k1;
! v += k2;
! d += u;
! } else {
! x0 +=
dxDiag;
! y0 +=
dyDiag;
! u += k2;
! v += k3;
! d += v;
! }
! }
! float dk = k1 - k2;
! d = d + u - v + dk;
! v = 2*u - v + dk;
! u = u + dk;
! k3 = k3 + 4*dk;
! k2 = k1 + dk;
! int t = dxDiag; dxDiag
= -dyDiag; dyDiag = t;
! }
! octant = (octant + 1) & 7;
! } while (true);*/
}
***************
*** 266,274 ****
// Fill a pie slice within a rectangle defined by four points.
! public override void FillPie (Point[] rect, float startAngle,
float sweepAngle)
! {
! // TODO
! }
!
// Set the clipping region to empty.
public override void SetClipEmpty()
--- 266,274 ----
// Fill a pie slice within a rectangle defined by four points.
! public override void FillPie (Point[] rect, float startAngle,
float sweepAngle)
! {
! // TODO
! }
!
// Set the clipping region to empty.
public override void SetClipEmpty()
***************
*** 312,316 ****
destFrame.Copy(sourceFrame, x, y);
this.image.ImageChanged();
! }
! }
! }
--- 312,326 ----
destFrame.Copy(sourceFrame, x, y);
this.image.ImageChanged();
! }
!
! // Draw a bitmap-based glyph to a "Graphics" object. "bits"
must be
! // in the form of an xbm bitmap.
! public override void DrawGlyph
! (int x, int y,
! byte[] bits, int bitsWidth, int
bitsHeight, Color color)
! {
! // TODO
! }
!
! }
! }
Index: IToolkitGraphics.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/System.Drawing/Toolkit/IToolkitGraphics.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** IToolkitGraphics.cs 8 Nov 2003 00:20:27 -0000 1.8
--- IToolkitGraphics.cs 20 Nov 2003 07:42:20 -0000 1.9
***************
*** 134,137 ****
--- 134,143 ----
void DrawImage(IToolkitImage image,Point[] src, Point[] dest);
+ // Draw a bitmap-based glyph to a "Graphics" object. "bits" must be
+ // in the form of an xbm bitmap.
+ void DrawGlyph(int x, int y,
+ byte[] bits, int bitsWidth, int bitsHeight,
+ Color color);
+
}; // interface IToolkitGraphics
Index: ToolkitGraphicsBase.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/System.Drawing/Toolkit/ToolkitGraphicsBase.cs,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** ToolkitGraphicsBase.cs 16 Nov 2003 20:28:49 -0000 1.12
--- ToolkitGraphicsBase.cs 20 Nov 2003 07:42:20 -0000 1.13
***************
*** 648,651 ****
--- 648,657 ----
public abstract void DrawImage(IToolkitImage image, int x, int y);
+ // Draw a bitmap-based glyph to a "Graphics" object. "bits" must be
+ // in the form of an xbm bitmap.
+ public abstract void DrawGlyph(int x, int y,
+ byte[] bits,
int bitsWidth, int bitsHeight,
+ Color color);
+
}; // class ToolkitGraphicsBase
Index: ToolkitManager.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/System.Drawing/Toolkit/ToolkitManager.cs,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** ToolkitManager.cs 10 Oct 2003 04:10:22 -0000 1.9
--- ToolkitManager.cs 20 Nov 2003 07:42:20 -0000 1.10
***************
*** 147,150 ****
--- 147,159 ----
}
+ // Draw a bitmap-based glyph to a "Graphics" object. "bits" must be
+ // in the form of an xbm bitmap.
+ public static void DrawGlyph(Graphics graphics, int x, int y,
+ byte[] bits,
int bitsWidth, int bitsHeight,
+ Color color)
+ {
+ graphics.DrawGlyph(x, y, bits, bitsWidth,
bitsHeight, color);
+ }
+
// Get the override toolkit name.
private static String GetToolkitOverride()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] pnetlib/System.Drawing/Toolkit IToolkitGraphics.cs, 1.8, 1.9 ToolkitGraphicsBase.cs, 1.12, 1.13 ToolkitGraphicsImageBase.cs, 1.2, 1.3 ToolkitManager.cs, 1.9, 1.10,
Rhys Weatherley <address@hidden> <=