This commit is contained in:
Lluis Sanchez 2012-12-05 17:18:19 +01:00
Родитель 4e3a8d12a4
Коммит 4e9ebac950
13 изменённых файлов: 42 добавлений и 80 удалений

Просмотреть файл

@ -343,7 +343,7 @@ namespace Xwt.CairoBackend
}
}
public object CreatePath ()
public override object CreatePath ()
{
Cairo.Surface sf = new Cairo.ImageSurface (null, Cairo.Format.A1, 0, 0, 0);
return new CairoContextBackend {
@ -352,7 +352,7 @@ namespace Xwt.CairoBackend
};
}
public void AppendPath (object backend, object otherBackend)
public override void AppendPath (object backend, object otherBackend)
{
Cairo.Context dest = ((CairoContextBackend)backend).Context;
Cairo.Context src = ((CairoContextBackend)otherBackend).Context;
@ -361,17 +361,17 @@ namespace Xwt.CairoBackend
dest.AppendPath (path);
}
public bool IsPointInFill (object backend, double x, double y)
public override bool IsPointInFill (object backend, double x, double y)
{
return ((CairoContextBackend)backend).Context.InFill (x, y);
}
public bool IsPointInStroke (object backend, double x, double y)
public override bool IsPointInStroke (object backend, double x, double y)
{
return ((CairoContextBackend)backend).Context.InStroke (x, y);
}
public void Dispose (object backend)
public override void Dispose (object backend)
{
var ctx = (CairoContextBackend) backend;
IDisposable d = (IDisposable) ctx.Context;

Просмотреть файл

@ -62,6 +62,7 @@ namespace Xwt.GtkBackend
WidgetRegistry.RegisterBackend (typeof(Xwt.Drawing.Context), typeof(ContextBackendHandler));
WidgetRegistry.RegisterBackend (typeof(Xwt.Drawing.TextLayout), typeof(CairoTextLayoutBackendHandler));
#endif
RegisterBackend (typeof(Xwt.Drawing.Path), typeof(CairoContextBackendHandler));
RegisterBackend (typeof(Xwt.Drawing.Gradient), typeof(CairoGradientBackendHandler));
RegisterBackend (typeof(Xwt.Drawing.Font), typeof(GtkFontBackendHandler));
RegisterBackend (typeof(Xwt.Menu), typeof(MenuBackend));

Просмотреть файл

@ -113,7 +113,7 @@ namespace Xwt.Mac
CGContextBackend gc = (CGContextBackend)backend;
CGContext ctx = SetupContextForDrawing (gc, out needsRestore);
if (gc.Gradient != null)
GradientBackendHandler.Draw (ctx, gc.Gradient);
MacGradientBackendHandler.Draw (ctx, gc.Gradient);
else
ctx.DrawPath (CGPathDrawingMode.Fill);
if (needsRestore)
@ -238,7 +238,7 @@ namespace Xwt.Mac
{
bool needsRestore;
CGContext ctx = SetupContextForDrawing ((CGContextBackend)backend, out needsRestore);
MacTextLayoutBackendHandler.Draw (ctx, WidgetRegistry.GetBackend (layout), x, y);
MacTextLayoutBackendHandler.Draw (ctx, Toolkit.GetBackend (layout), x, y);
if (needsRestore)
ctx.RestoreState ();
}
@ -342,12 +342,12 @@ namespace Xwt.Mac
}
}
public object CreatePath ()
public override object CreatePath ()
{
return new CGPath ();
}
public void AppendPath (object backend, object otherBackend)
public override void AppendPath (object backend, object otherBackend)
{
CGContext dest = ((CGContextBackend)backend).Context;
CGContextBackend src = otherBackend as CGContextBackend;
@ -360,17 +360,17 @@ namespace Xwt.Mac
}
}
public bool IsPointInFill (object backend, double x, double y)
public override bool IsPointInFill (object backend, double x, double y)
{
return ((CGContextBackend)backend).Context.PathContainsPoint (new PointF ((float)x, (float)y), CGPathDrawingMode.Fill);
}
public bool IsPointInStroke (object backend, double x, double y)
public override bool IsPointInStroke (object backend, double x, double y)
{
return ((CGContextBackend)backend).Context.PathContainsPoint (new PointF ((float)x, (float)y), CGPathDrawingMode.Stroke);
}
public void Dispose (object backend)
public override void Dispose (object backend)
{
((CGContextBackend)backend).Context.Dispose ();
}

Просмотреть файл

@ -67,7 +67,7 @@ namespace Xwt.Mac
RegisterBackend (typeof(Xwt.Canvas), typeof(CanvasBackend));
RegisterBackend (typeof(Xwt.Drawing.Image), typeof(ImageHandler));
RegisterBackend (typeof(Xwt.Drawing.Context), typeof(MacContextBackendHandler));
WidgetRegistry.RegisterBackend (typeof(Xwt.Drawing.Path), typeof(PathBackendHandler));
RegisterBackend (typeof(Xwt.Drawing.Path), typeof(MacPathBackendHandler));
RegisterBackend (typeof(Xwt.Drawing.ImageBuilder), typeof(MacImageBuilderBackendHandler));
RegisterBackend (typeof(Xwt.Drawing.ImagePattern), typeof(MacImagePatternBackendHandler));
RegisterBackend (typeof(Xwt.Drawing.Gradient), typeof(MacGradientBackendHandler));

Просмотреть файл

@ -26,7 +26,6 @@
using System;
using Xwt.Backends;
using Xwt.Engine;
using MonoMac.AppKit;
using Xwt.Drawing;
using MonoMac.Foundation;
@ -35,76 +34,76 @@ using System.Drawing;
namespace Xwt.Mac
{
public class PathBackendHandler: IPathBackendHandler
public class MacPathBackendHandler: PathBackendHandler
{
const double degrees = System.Math.PI / 180d;
public PathBackendHandler ()
public MacPathBackendHandler ()
{
}
public void Arc (object backend, double xc, double yc, double radius, double angle1, double angle2)
public override void Arc (object backend, double xc, double yc, double radius, double angle1, double angle2)
{
((CGPath)backend).AddArc ((float)xc, (float)yc, (float)radius, (float)(angle1 * degrees), (float)(angle2 * degrees), false);
}
public void ArcNegative (object backend, double xc, double yc, double radius, double angle1, double angle2)
public override void ArcNegative (object backend, double xc, double yc, double radius, double angle1, double angle2)
{
((CGPath)backend).AddArc ((float)xc, (float)yc, (float)radius, (float)(angle1 * degrees), (float)(angle2 * degrees), true);
}
public void ClosePath (object backend)
public override void ClosePath (object backend)
{
((CGPath)backend).CloseSubpath ();
}
public void CurveTo (object backend, double x1, double y1, double x2, double y2, double x3, double y3)
public override void CurveTo (object backend, double x1, double y1, double x2, double y2, double x3, double y3)
{
((CGPath)backend).AddCurveToPoint ((float)x1, (float)y1, (float)x2, (float)y2, (float)x3, (float)y3);
}
public void LineTo (object backend, double x, double y)
public override void LineTo (object backend, double x, double y)
{
((CGPath)backend).AddLineToPoint ((float)x, (float)y);
}
public void MoveTo (object backend, double x, double y)
public override void MoveTo (object backend, double x, double y)
{
((CGPath)backend).MoveToPoint ((float)x, (float)y);
}
public void Rectangle (object backend, double x, double y, double width, double height)
public override void Rectangle (object backend, double x, double y, double width, double height)
{
((CGPath)backend).AddRect (new RectangleF ((float)x, (float)y, (float)width, (float)height));
}
public void RelCurveTo (object backend, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3)
public override void RelCurveTo (object backend, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3)
{
CGPath path = (CGPath)backend;
PointF p = path.CurrentPoint;
path.AddCurveToPoint ((float)(p.X + dx1), (float)(p.Y + dy1), (float)(p.X + dx2), (float)(p.Y + dy2), (float)(p.X + dx3), (float)(p.Y + dy3));
}
public void RelLineTo (object backend, double dx, double dy)
public override void RelLineTo (object backend, double dx, double dy)
{
CGPath path = (CGPath)backend;
PointF p = path.CurrentPoint;
path.AddLineToPoint ((float)(p.X + dx), (float)(p.Y + dy));
}
public void RelMoveTo (object backend, double dx, double dy)
public override void RelMoveTo (object backend, double dx, double dy)
{
CGPath path = (CGPath)backend;
PointF p = path.CurrentPoint;
path.MoveToPoint ((float)(p.X + dx), (float)(p.Y + dy));
}
public object CreatePath ()
public override object CreatePath ()
{
return new CGPath ();
}
public void AppendPath (object backend, object otherBackend)
public override void AppendPath (object backend, object otherBackend)
{
CGPath dest = (CGPath)backend;
CGContextBackend src = otherBackend as CGContextBackend;
@ -117,12 +116,12 @@ namespace Xwt.Mac
}
}
public bool IsPointInFill (object backend, double x, double y)
public override bool IsPointInFill (object backend, double x, double y)
{
return ((CGPath)backend).ContainsPoint (new PointF ((float)x, (float)y), false);
}
public void Dispose (object backend)
public override void Dispose (object backend)
{
((CGPath)backend).Dispose ();
}

Просмотреть файл

@ -30,7 +30,6 @@ using MonoMac.AppKit;
using MonoMac.Foundation;
using MonoMac.CoreText;
using MonoMac.CoreGraphics;
using Xwt.Engine;
using Xwt.Drawing;
using PointF = System.Drawing.PointF;

Просмотреть файл

@ -103,7 +103,7 @@ Global
{3C7623A9-9E16-41F6-BBB2-0B550F28E749}.Win-Debug|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = MacTest\MacTest.csproj
StartupItem = GtkTest\GtkTest.csproj
Policies = $0
$0.DotNetNamingPolicy = $1
$1.DirectoryNamespaceAssociation = None

Просмотреть файл

@ -30,44 +30,24 @@ using Xwt.Drawing;
namespace Xwt.Backends
{
public abstract class ContextBackendHandler: BackendHandler
public abstract class ContextBackendHandler: PathBackendHandler
{
public abstract void Save (object backend);
public abstract void Restore (object backend);
public abstract void Arc (object backend, double xc, double yc, double radius, double angle1, double angle2);
public abstract void ArcNegative (object backend, double xc, double yc, double radius, double angle1, double angle2);
public abstract void Clip (object backend);
public abstract void ClipPreserve(object backend);
public abstract void ResetClip (object backend);
public abstract void ClosePath(object backend);
public abstract void CurveTo (object backend, double x1, double y1, double x2, double y2, double x3, double y3);
public abstract void Fill (object backend);
public abstract void FillPreserve (object backend);
public abstract void LineTo (object backend, double x, double y);
public abstract void MoveTo (object backend, double x, double y);
public abstract void NewPath (object backend);
public abstract void Rectangle (object backend, double x, double y, double width, double height);
public abstract void RelCurveTo (object backend, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3);
public abstract void RelLineTo (object backend, double dx, double dy);
public abstract void RelMoveTo (object backend, double dx, double dy);
public abstract void Stroke (object backend);
public abstract void StrokePreserve (object backend);
@ -105,14 +85,14 @@ namespace Xwt.Backends
public abstract void TransformPoints (object backend, Point[] points);
public abstract void TransformDistances (object backend, Distance[] vectors);
public abstract bool IsPointInStroke (object backend, double x, double y);
/// <summary>
/// Sets a global alpha to be applied to all drawing operations.
/// It doesn't affect colors that have already been set.
/// </summary>
public abstract void SetGlobalAlpha (object backend, double globalAlpha);
public abstract void Dispose (object backend);
}
}

Просмотреть файл

@ -36,12 +36,7 @@ namespace Xwt.Drawing
Font font;
double globalAlpha = 1;
internal Context (object backend): base (backend)
{
handler = ToolkitEngine.ContextBackendHandler;
}
internal Context (object backend): base (backend, ToolkitEngine.ContextBackendHandler)
internal Context (object backend, Toolkit toolkit): base (backend, toolkit, toolkit.ContextBackendHandler)
{
handler = ToolkitEngine.ContextBackendHandler;
}

Просмотреть файл

@ -48,7 +48,7 @@ namespace Xwt.Drawing
this.width = width;
this.height = height;
backend = handler.CreateImageBuilder (width, height, format);
ctx = new Context (handler.CreateContext (backend));
ctx = new Context (handler.CreateContext (backend), ToolkitEngine);
}
public int Width {

Просмотреть файл

@ -25,34 +25,20 @@
// THE SOFTWARE.
using System;
using Xwt.Backends;
using Xwt.Engine;
namespace Xwt.Drawing
{
public class Path: XwtObject, IDisposable
{
static IPathBackendHandler pathHandler;
static Path ()
{
pathHandler = WidgetRegistry.CreateSharedBackend<IPathBackendHandler> (typeof(Path));
}
IPathBackendHandler handler;
protected override IBackendHandler BackendHandler {
get {
return handler;
}
}
PathBackendHandler handler;
public Path ()
{
handler = pathHandler;
handler = ToolkitEngine.PathBackendHandler;
Backend = handler.CreatePath ();
}
internal Path (object backend, IPathBackendHandler h): base (backend)
internal Path (object backend, Toolkit toolkit, PathBackendHandler h): base (backend, toolkit)
{
handler = h;
}

Просмотреть файл

@ -69,7 +69,7 @@ namespace Xwt
{
Context ctx = null;
try {
ctx = new Context (context);
ctx = new Context (context, ToolkitEngine);
((Canvas)Parent).OnDraw (ctx, dirtyRect);
}
finally {

Просмотреть файл

@ -140,6 +140,7 @@ namespace Xwt
ImageBuilderBackendHandler = Backend.CreateSharedBackend<ImageBuilderBackendHandler> (typeof(ImageBuilder));
ImagePatternBackendHandler = Backend.CreateSharedBackend<ImagePatternBackendHandler> (typeof(ImagePattern));
ImageBackendHandler = Backend.CreateSharedBackend<ImageBackendHandler> (typeof(Image));
PathBackendHandler = Backend.CreateSharedBackend<PathBackendHandler> (typeof(Path));
}
internal void SetActive ()
@ -293,6 +294,7 @@ namespace Xwt
internal ImageBuilderBackendHandler ImageBuilderBackendHandler;
internal ImagePatternBackendHandler ImagePatternBackendHandler;
internal ImageBackendHandler ImageBackendHandler;
internal PathBackendHandler PathBackendHandler;
}
class NativeWindowFrame: WindowFrame