Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,89 @@
//
//
// Mono.Cairo drawing samples using X11 as drawing surface
// Autor: Hisham Mardam Bey <hisham@hisham.cc>
//
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Cairo;
public class X11Test
{
static readonly double M_PI = 3.14159265358979323846;
static void draw (Cairo.Context gr, int width, int height)
{
double xc = 0.5;
double yc = 0.5;
double radius = 0.4;
double angle1 = 45.0 * (M_PI/180.0); /* angles are specified */
double angle2 = 180.0 * (M_PI/180.0); /* in radians */
gr.Scale (width, height);
gr.LineWidth = 0.04;
gr.Arc (xc, yc, radius, angle1, angle2);
gr.Stroke ();
/* draw helping lines */
gr.Color = new Color(1, 0.2, 0.2, 0.6);
gr.Arc (xc, yc, 0.05, 0, 2*M_PI);
gr.Fill ();
gr.LineWidth = 0.03;
gr.Arc (xc, yc, radius, angle1, angle1);
gr.LineTo (new PointD(xc, yc));
gr.Arc (xc, yc, radius, angle2, angle2);
gr.LineTo (new PointD(xc, yc));
gr.Stroke ();
}
static void Main (string [] args)
{
Window win = new Window (500, 500);
win.Show ();
Cairo.XlibSurface s = new Cairo.XlibSurface (win.Display,
win.XWindow,
X11.XDefaultVisual (win.Display, win.Screen),
(int)win.Width, (int)win.Height);
Cairo.Context g = new Cairo.Context (s);
draw (g, 500, 500);
IntPtr xev = new IntPtr ();
while (true) {
X11.XNextEvent (win.Display, xev);
}
}
}

View File

@@ -0,0 +1,88 @@
//
//
// Mono.Cairo drawing samples using X11 as drawing surface
// Autor: Hisham Mardam Bey <hisham@hisham.cc>
//
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Cairo;
public class X11Test
{
static readonly double M_PI = 3.14159265358979323846;
static void draw (Cairo.Context gr, int width, int height)
{
double xc = 0.5;
double yc = 0.5;
double radius = 0.4;
double angle1 = 45.0 * (M_PI/180.0); /* angles are specified */
double angle2 = 180.0 * (M_PI/180.0); /* in radians */
gr.Scale (width, height);
gr.LineWidth = 0.04;
gr.ArcNegative (xc, yc, radius, angle1, angle2);
gr.Stroke ();
/* draw helping lines */
gr.Color = new Color(1, 0.2, 0.2, 0.6);
gr.Arc (xc, yc, 0.05, 0, 2*M_PI);
gr.Fill ();
gr.LineWidth = 0.03;
gr.Arc (xc, yc, radius, angle1, angle1);
gr.LineTo (new PointD(xc, yc));
gr.Arc (xc, yc, radius, angle2, angle2);
gr.LineTo (new PointD(xc, yc));
gr.Stroke ();
}
static void Main (string [] args)
{
Window win = new Window (500, 500);
win.Show ();
Cairo.XlibSurface s = new Cairo.XlibSurface (win.Display,
win.XWindow,
X11.XDefaultVisual (win.Display, win.Screen),
(int)win.Width, (int)win.Height);
Cairo.Context g = new Cairo.Context (s);
draw (g, 500, 500);
IntPtr xev = new IntPtr ();
while (true) {
X11.XNextEvent (win.Display, xev);
}
}
}

View File

@@ -0,0 +1,81 @@
//
//
// Mono.Cairo drawing samples using X11 as drawing surface
// Autor: Hisham Mardam Bey <hisham@hisham.cc>
//
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Cairo;
public class X11Test
{
static readonly double M_PI = 3.14159265358979323846;
static void draw (Cairo.Context gr, int width, int height)
{
gr.Scale (width, height);
gr.LineWidth = 0.04;
gr.Arc (0.5, 0.5, 0.3, 0, 2 * M_PI);
gr.Clip ();
gr.NewPath ();
gr.Rectangle (new PointD (0, 0), 1, 1);
gr.Fill ();
gr.Color = new Color (0, 1, 0, 1);
gr.MoveTo ( new PointD (0, 0) );
gr.LineTo ( new PointD (1, 1) );
gr.MoveTo ( new PointD (1, 0) );
gr.LineTo ( new PointD (0, 1) );
gr.Stroke ();
}
static void Main (string [] args)
{
Window win = new Window (500, 500);
win.Show ();
Cairo.XlibSurface s = new Cairo.XlibSurface (win.Display,
win.XWindow,
X11.XDefaultVisual (win.Display, win.Screen),
(int)win.Width, (int)win.Height);
Cairo.Context g = new Cairo.Context (s);
draw (g, 500, 500);
IntPtr xev = new IntPtr ();
while (true) {
X11.XNextEvent (win.Display, xev);
}
}
}

View File

@@ -0,0 +1,98 @@
//
//
// Mono.Cairo drawing samples using X11 as drawing surface
// Autor: Hisham Mardam Bey <hisham@hisham.cc>
// Based on work from Jordi Mas <jordi@ximian.com>
//
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Cairo;
public class X11Test
{
static readonly double M_PI = 3.14159265358979323846;
static void draw (Cairo.Context gr, int width, int height)
{
int w, h;
ImageSurface image;
gr.Scale (width, height);
gr.LineWidth = 0.04;
gr.Arc (0.5, 0.5, 0.3, 0, 2*M_PI);
gr.Clip ();
gr.NewPath ();
image = new ImageSurface("data/e.png");
w = image.Width;
h = image.Height;
gr.Scale (1.0/w, 1.0/h);
image.Show (gr, 0, 0);
image.Destroy();
gr.Arc (0.5, 0.5, 0.3, 0, 2 * M_PI);
gr.Clip ();
gr.NewPath ();
gr.Rectangle (new PointD (0, 0), 1, 1);
gr.Fill ();
gr.Color = new Color (0, 1, 0, 1);
gr.MoveTo ( new PointD (0, 0) );
gr.LineTo ( new PointD (1, 1) );
gr.MoveTo ( new PointD (1, 0) );
gr.LineTo ( new PointD (0, 1) );
gr.Stroke ();
}
static void Main (string [] args)
{
Window win = new Window (500, 500);
win.Show ();
Cairo.XlibSurface s = new Cairo.XlibSurface (win.Display,
win.XWindow,
X11.XDefaultVisual (win.Display, win.Screen),
(int)win.Width, (int)win.Height);
Cairo.Context g = new Cairo.Context (s);
draw (g, 500, 500);
IntPtr xev = new IntPtr ();
while (true) {
X11.XNextEvent (win.Display, xev);
}
}
}

View File

@@ -0,0 +1,12 @@
#!/bin/bash
mcs -r:System.Drawing -r:Mono.Cairo arc.cs x11.cs
mcs -r:System.Drawing -r:Mono.Cairo arcneg.cs x11.cs
mcs -r:System.Drawing -r:Mono.Cairo clip.cs x11.cs
mcs -r:System.Drawing -r:Mono.Cairo clip_img.cs x11.cs
mcs -r:System.Drawing -r:Mono.Cairo curve_rect.cs x11.cs
mcs -r:System.Drawing -r:Mono.Cairo curve_to.cs x11.cs
mcs -r:System.Drawing -r:Mono.Cairo fillstroke.cs x11.cs
mcs -r:System.Drawing -r:Mono.Cairo gradient.cs x11.cs
mcs -r:System.Drawing -r:Mono.Cairo image.cs x11.cs
mcs -r:System.Drawing -r:Mono.Cairo image_pattern.cs x11.cs
mcs -r:System.Drawing -r:Mono.Cairo text.cs x11.cs

View File

@@ -0,0 +1,191 @@
//
//
// Mono.Cairo drawing samples using X11 as drawing surface
// Autor: Hisham Mardam Bey <hisham@hisham.cc>
//
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Cairo;
public class X11Test
{
static void draw (Cairo.Context gr, int width, int height)
{
double x0 = 0.1;
double y0 = 0.1;
double rect_width = 0.8;
double rect_height = 0.8;
double radius = 0.4;
double x1,y1;
gr.Scale (width, height);
gr.LineWidth = 0.04;
x1=x0+rect_width;
y1=y0+rect_height;
if (rect_width == 0 || rect_height == 0)
return;
if (rect_width/2<radius) {
if (rect_height/2<radius) {
gr.MoveTo( new PointD(x0, (y0 + y1)/2) );
gr.CurveTo ( new PointD (x0 ,y0),
new PointD (x0, y0),
new PointD ((x0 + x1)/2, y0)
);
gr.CurveTo ( new PointD (x1, y0 ),
new PointD (x1, y0 ),
new PointD (x1, (y0 + y1)/2)
);
gr.CurveTo ( new PointD (x1, y1),
new PointD (x1, y1),
new PointD ((x1 + x0)/2, y1)
);
gr.CurveTo ( new PointD (x0, y1),
new PointD (x0, y1),
new PointD (x0, (y0 + y1)/2)
);
}
else {
gr.MoveTo ( new PointD (x0, y0 + radius) );
gr.CurveTo ( new PointD (x0 ,y0),
new PointD (x0, y0),
new PointD ((x0 + x1)/2, y0)
);
gr.CurveTo ( new PointD (x1, y0),
new PointD (x1, y0),
new PointD (x1, y0 + radius)
);
gr.LineTo ( new PointD (x1 , y1 - radius) );
gr.CurveTo ( new PointD (x1, y1),
new PointD (x1, y1),
new PointD ((x1 + x0)/2, y1)
);
gr.CurveTo ( new PointD (x0, y1),
new PointD (x0, y1),
new PointD (x0, y1- radius)
);
}
}
else {
if (rect_height/2<radius) {
gr.MoveTo ( new PointD (x0, (y0 + y1)/2) );
gr.CurveTo ( new PointD (x0 , y0),
new PointD (x0 , y0),
new PointD (x0 + radius, y0)
);
gr.LineTo ( new PointD (x1 - radius, y0) );
gr.CurveTo ( new PointD (x1, y0),
new PointD (x1, y0),
new PointD (x1, (y0 + y1)/2)
);
gr.CurveTo ( new PointD (x1, y1),
new PointD (x1, y1),
new PointD (x1 - radius, y1)
);
gr.LineTo ( new PointD (x0 + radius, y1) );
gr.CurveTo ( new PointD ( x0, y1),
new PointD (x0, y1),
new PointD (x0, (y0 + y1)/2)
);
}
else {
gr.MoveTo ( new PointD (x0, y0 + radius) );
gr.CurveTo ( new PointD (x0 , y0),
new PointD (x0 , y0),
new PointD (x0 + radius, y0)
);
gr.LineTo ( new PointD (x1 - radius, y0) );
gr.CurveTo ( new PointD (x1, y0),
new PointD (x1, y0),
new PointD (x1, y0 + radius)
);
gr.LineTo ( new PointD (x1 , y1 - radius) );
gr.CurveTo ( new PointD ( x1, y1),
new PointD (x1, y1),
new PointD (x1 - radius, y1)
);
gr.LineTo ( new PointD (x0 + radius, y1) );
gr.CurveTo ( new PointD ( x0, y1),
new PointD (x0, y1),
new PointD (x0, y1- radius)
);
}
}
gr.Color = new Color (0.5,0.5,1, 1);
gr.FillPreserve ();
gr.Color = new Color(0.5, 0, 0, 0.5);
gr.Stroke ();
}
static void Main (string [] args)
{
Window win = new Window (500, 500);
win.Show ();
Cairo.XlibSurface s = new Cairo.XlibSurface (win.Display,
win.XWindow,
X11.XDefaultVisual (win.Display, win.Screen),
(int)win.Width, (int)win.Height);
Cairo.Context g = new Cairo.Context (s);
draw (g, 500, 500);
IntPtr xev = new IntPtr ();
while (true) {
X11.XNextEvent (win.Display, xev);
}
}
}

View File

@@ -0,0 +1,86 @@
//
//
// Mono.Cairo drawing samples using X11 as drawing surface
// Autor: Hisham Mardam Bey <hisham@hisham.cc>
//
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Cairo;
public class X11Test
{
static void draw (Cairo.Context gr, int width, int height)
{
double x=0.1, y=0.5;
double x1=0.4, y1=0.9, x2=0.6, y2=0.1, x3=0.9, y3=0.5;
gr.Scale (width, height);
gr.LineWidth = 0.04;
gr.MoveTo ( new PointD (x, y) );
gr.CurveTo ( new PointD (x1, y1),
new PointD (x2, y2),
new PointD (x3, y3)
);
gr.Stroke ();
gr.Color = new Color (1, 0.2, 0.2, 0.6);
gr.LineWidth = 0.03;
gr.MoveTo ( new PointD (x, y) );
gr.LineTo ( new PointD (x1, y1) );
gr.MoveTo ( new PointD (x2, y2) );
gr.LineTo ( new PointD (x3, y3) );
gr.Stroke ();
}
static void Main (string [] args)
{
Window win = new Window (500, 500);
win.Show ();
Cairo.XlibSurface s = new Cairo.XlibSurface (win.Display,
win.XWindow,
X11.XDefaultVisual (win.Display, win.Screen),
(int)win.Width, (int)win.Height);
Cairo.Context g = new Cairo.Context (s);
draw (g, 500, 500);
IntPtr xev = new IntPtr ();
while (true) {
X11.XNextEvent (win.Display, xev);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

View File

@@ -0,0 +1,86 @@
//
//
// Mono.Cairo drawing samples using X11 as drawing surface
// Autor: Hisham Mardam Bey <hisham@hisham.cc>
//
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Cairo;
public class X11Test
{
static void draw (Cairo.Context gr, int width, int height)
{
gr.Scale (width, height);
gr.LineWidth = 0.04;
gr.MoveTo ( new PointD (0.5, 0.1) );
gr.LineTo ( new PointD (0.9, 0.9) );
gr.RelLineTo ( new Distance (-0.4, 0.0) );
gr.CurveTo ( new PointD (0.2, 0.9),
new PointD ( 0.2, 0.5),
new PointD (0.5, 0.5)
);
gr.ClosePath ();
gr.MoveTo ( new PointD (0.25, 0.1) );
gr.RelLineTo ( new Distance (0.2, 0.2) );
gr.RelLineTo ( new Distance ( -0.2, 0.2) );
gr.RelLineTo ( new Distance (-0.2, -0.2) );
gr.ClosePath ();
gr.Color = new Color (0, 0, 1, 1);
gr.FillPreserve ();
gr.Color = new Color ( 0, 0, 0, 1);
gr.Stroke ();
}
static void Main (string [] args)
{
Window win = new Window (500, 500);
win.Show ();
Cairo.XlibSurface s = new Cairo.XlibSurface (win.Display,
win.XWindow,
X11.XDefaultVisual (win.Display, win.Screen),
(int)win.Width, (int)win.Height);
Cairo.Context g = new Cairo.Context (s);
draw (g, 500, 500);
IntPtr xev = new IntPtr ();
while (true) {
X11.XNextEvent (win.Display, xev);
}
}
}

View File

@@ -0,0 +1,89 @@
//
//
// Mono.Cairo drawing samples using X11 as drawing surface
// Autor: Hisham Mardam Bey <hisham@hisham.cc>
//
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Cairo;
public class X11Test
{
static readonly double M_PI = 3.14159265358979323846;
static void draw (Cairo.Context gr, int width, int height)
{
gr.Scale (width, height);
gr.LineWidth = 0.04;
LinearGradient pat = new LinearGradient (0.0, 0.0, 0.0, 1.0);
pat.AddColorStop (1, new Color (0, 0, 0, 1) );
pat.AddColorStop (0, new Color (1, 1, 1, 1) );
gr.Rectangle ( new PointD (0, 0),
1, 1
);
gr.Pattern = pat;
gr.Fill ();
pat.Destroy ();
RadialGradient pat2 = new RadialGradient (0.45, 0.4, 0.1,
0.4, 0.4, 0.5);
pat2.AddColorStop (0, new Color (1, 1, 1, 1) );
pat2.AddColorStop (1, new Color (0, 0, 0, 1) );
gr.Pattern = pat2;
gr.Arc (0.5, 0.5, 0.3, 0, 2 * M_PI);
gr.Fill ();
pat2.Destroy ();
}
static void Main (string [] args)
{
Window win = new Window (500, 500);
win.Show ();
Cairo.XlibSurface s = new Cairo.XlibSurface (win.Display,
win.XWindow,
X11.XDefaultVisual (win.Display, win.Screen),
(int)win.Width, (int)win.Height);
Cairo.Context g = new Cairo.Context (s);
draw (g, 500, 500);
IntPtr xev = new IntPtr ();
while (true) {
X11.XNextEvent (win.Display, xev);
}
}
}

View File

@@ -0,0 +1,84 @@
//
//
// Mono.Cairo drawing samples using X11 as drawing surface
// Autor: Hisham Mardam Bey <hisham@hisham.cc>
//
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Cairo;
public class X11Test
{
static readonly double M_PI = 3.14159265358979323846;
static void draw (Cairo.Context gr, int width, int height)
{
int w, h;
ImageSurface image;
gr.Scale (width, height);
gr.LineWidth = 0.04;
image = new ImageSurface ("data/e.png");
w = image.Width;
h = image.Height;
gr.Translate (0.5, 0.5);
gr.Rotate (45* M_PI/180);
gr.Scale (1.0/w, 1.0/h);
gr.Translate (-0.5*w, -0.5*h);
image.Show (gr, 0, 0);
image.Destroy ();
}
static void Main (string [] args)
{
Window win = new Window (500, 500);
win.Show ();
Cairo.XlibSurface s = new Cairo.XlibSurface (win.Display,
win.XWindow,
X11.XDefaultVisual (win.Display, win.Screen),
(int)win.Width, (int)win.Height);
Cairo.Context g = new Cairo.Context (s);
draw (g, 500, 500);
IntPtr xev = new IntPtr ();
while (true) {
X11.XNextEvent (win.Display, xev);
}
}
}

View File

@@ -0,0 +1,100 @@
//
//
// Mono.Cairo drawing samples using X11 as drawing surface
// Autor: Hisham Mardam Bey <hisham@hisham.cc>
//
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Cairo;
public class X11Test
{
static readonly double M_PI = 3.14159265358979323846;
static void draw (Cairo.Context gr, int width, int height)
{
int w, h;
ImageSurface image;
Matrix matrix;
SurfacePattern pattern;
gr.Scale (width, height);
gr.LineWidth = 0.04;
image = new ImageSurface ("data/e.png");
w = image.Width;
h = image.Height;
pattern = new SurfacePattern (image);
pattern.Extend = Cairo.Extend.Repeat;
gr.Translate (0.5, 0.5);
gr.Rotate (M_PI / 4);
gr.Scale (1 / Math.Sqrt (2), 1 / Math.Sqrt (2));
gr.Translate (- 0.5, - 0.5);
matrix = new Matrix ();
matrix.InitScale (w * 5.0, h * 5.0);
pattern.Matrix = matrix;
gr.Pattern = pattern;
gr.Rectangle ( new PointD (0, 0),
1.0, 1.0);
gr.Fill ();
pattern.Destroy ();
image.Destroy();
}
static void Main (string [] args)
{
Window win = new Window (500, 500);
win.Show ();
Cairo.XlibSurface s = new Cairo.XlibSurface (win.Display,
win.XWindow,
X11.XDefaultVisual (win.Display, win.Screen),
(int)win.Width, (int)win.Height);
Cairo.Context g = new Cairo.Context (s);
draw (g, 500, 500);
IntPtr xev = new IntPtr ();
while (true) {
X11.XNextEvent (win.Display, xev);
}
}
}

View File

@@ -0,0 +1,149 @@
//
//
// Mono.Cairo drawing samples using X11 as drawing surface
// Autor: Hisham Mardam Bey <hisham@hisham.cc>
//
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Cairo;
public class X11Test
{
static readonly double M_PI = 3.14159265358979323846;
static void draw (Cairo.Context gr, int width, int height)
{
double X_FUZZ = 0.08;
double Y_FUZZ = 0.08;
double X_INNER_RADIUS = 0.3;
double Y_INNER_RADIUS = 0.2;
double X_OUTER_RADIUS = 0.45;
double Y_OUTER_RADIUS = 0.35;
double SPIKES = 10;
int i;
double x;
double y;
string text = "KAPOW!";
cairo_text_extents_t extents;
srand (45);
cairo_set_line_width (cr, 0.01);
for (i = 0; i < SPIKES * 2; i++) {
x = 0.5 + cos (M_PI * i / SPIKES) * X_INNER_RADIUS +
(double) rand() * X_FUZZ / RAND_MAX;
y = 0.5 + sin (M_PI * i / SPIKES) * Y_INNER_RADIUS +
(double) rand() * Y_FUZZ / RAND_MAX;
if (i == 0)
cairo_move_to (cr, x, y);
else
cairo_line_to (cr, x, y);
i++;
x = 0.5 + cos (M_PI * i / SPIKES) * X_OUTER_RADIUS +
(double) rand() * X_FUZZ / RAND_MAX;
y = 0.5 + sin (M_PI * i / SPIKES) * Y_OUTER_RADIUS +
(double) rand() * Y_FUZZ / RAND_MAX;
cairo_line_to (cr, x, y);
}
cairo_close_path (cr);
cairo_stroke (cr);
cairo_select_font_face (cr, "Sans",
CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_BOLD);
cairo_move_to (cr, x, y);
cairo_text_path (cr, text);
cairo_set_font_size (cr, 0.2);
cairo_text_extents (cr, text, &extents);
x = 0.5-(extents.width/2 + extents.x_bearing);
y = 0.5-(extents.height/2 + extents.y_bearing);
cairo_set_source_rgb (cr, 1 , 1, 0.5);
cairo_fill (cr);
cairo_move_to (cr, x, y);
cairo_text_path (cr, text);
cairo_set_source_rgb (cr, 0 , 0, 0);
cairo_stroke (cr);
$
gr.Arc (xc, yc, radius, angle1, angle2);
gr.Stroke ();
/* draw helping lines */
gr.Color = new Color(1, 0.2, 0.2, 0.6);
gr.Arc (xc, yc, 0.05, 0, 2*M_PI);
gr.Fill ();
gr.LineWidth = 0.03;
gr.Arc (xc, yc, radius, angle1, angle1);
gr.LineTo (new PointD(xc, yc));
gr.Arc (xc, yc, radius, angle2, angle2);
gr.LineTo (new PointD(xc, yc));
gr.Stroke ();
}
static void Main (string [] args)
{
Window win = new Window (500, 500);
win.Show ();
Cairo.Surface s = Cairo.Surface.CreateForXlib (win.Display,
win.XWindow,
X11.XDefaultVisual (win.Display, win.Screen),
(int)win.Width, (int)win.Height);
Cairo.Context g = new Cairo.Context (s);
draw (g, 500, 500);
IntPtr xev = new IntPtr ();
while (true) {
X11.XNextEvent (win.Display, xev);
}
}
}

View File

@@ -0,0 +1,86 @@
//
//
// Mono.Cairo drawing samples using X11 as drawing surface
// Autor: Hisham Mardam Bey <hisham@hisham.cc>
//
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Cairo;
public class X11Test
{
static readonly double M_PI = 3.14159265358979323846;
static void draw (Cairo.Context gr, int width, int height)
{
gr.Scale (width, height);
gr.LineWidth = 0.04;
gr.SelectFontFace ("Sans", FontSlant.Normal, FontWeight.Bold);
gr.SetFontSize (0.35);
gr.MoveTo ( new PointD(0.04, 0.53) );
gr.ShowText ("Hello");
gr.MoveTo ( new PointD(0.27, 0.65) );
gr.TextPath ("void");
gr.ColorRgb = new Color (0.5, 0.5, 1, 0);
gr.FillPreserve ();
gr.ColorRgb = new Color (0, 0, 0, 0);
gr.LineWidth = 0.01;
gr.Stroke ();
gr.Color = new Color (1,0.2,0.2, 0.6);
gr.Arc (0.04, 0.53, 0.02, 0, 2*M_PI);
gr.Arc (0.27, 0.65, 0.02, 0, 2*M_PI);
gr.Fill ();
}
static void Main (string [] args)
{
Window win = new Window (500, 500);
win.Show ();
Cairo.XlibSurface s = new Cairo.XlibSurface (win.Display,
win.XWindow,
X11.XDefaultVisual (win.Display, win.Screen),
(int)win.Width, (int)win.Height);
Cairo.Context g = new Cairo.Context (s);
draw (g, 500, 500);
IntPtr xev = new IntPtr ();
while (true) {
X11.XNextEvent (win.Display, xev);
}
}
}

View File

@@ -0,0 +1,155 @@
//
//
// X11 Interface
// Authors: Hisham Mardam Bey <hisham.mardambey@gmail.com>
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using Cairo;
using System.Runtime.InteropServices;
public class Window {
protected IntPtr display;
protected int screen;
protected IntPtr window;
protected IntPtr gc;
protected uint width = 0;
protected uint height = 0;
public Window () {
}
public Window (uint width, uint height)
{
this.width = width;
this.height = height;
display = X11.XOpenDisplay (0);
IntPtr root = X11.XDefaultRootWindow (display);
screen = X11.XDefaultScreen (display);
window = X11.XCreateSimpleWindow (display, root, 0, 0,
width, height, (ulong)0,
X11.XWhitePixel (display, screen),
X11.XWhitePixel (display, screen));
}
public int Show ()
{
return X11.XMapWindow(display, window);
}
public int Clear ()
{
return X11.XClearWindow (display, window);
}
public uint Width {
get { return width; }
set { width = value; }
}
public uint Height {
get { return height; }
set { height = value; }
}
public IntPtr Display {
get { return display; }
}
public IntPtr XWindow {
get { return window; }
}
public int Screen {
get { return screen; }
}
public void Close ()
{
X11.XCloseDisplay(display);
}
}
public class X11
{
[DllImport("X11")]
internal static extern IntPtr XDefaultVisual (IntPtr display,
int screen_number);
[DllImport("X11")]
internal static extern IntPtr XDefaultRootWindow (IntPtr display);
[DllImport("X11")]
internal static extern int XDefaultScreen (IntPtr display);
[DllImport("X11")]
internal static extern IntPtr XCreateSimpleWindow (IntPtr display,
IntPtr window,
int x,
int y,
uint width,
uint height,
ulong border_width,
ulong border,
ulong background);
[DllImport("X11")]
internal static extern int XMapWindow (IntPtr display,
IntPtr window);
[DllImport("X11")]
internal static extern int XClearWindow (IntPtr display,
IntPtr window);
[DllImport("X11")]
internal static extern IntPtr XOpenDisplay (int display_name);
[DllImport("X11")]
internal static extern IntPtr XScreenOfDisplay (IntPtr display,
int screen_number);
[DllImport("X11")]
internal static extern int XCloseDisplay(IntPtr display);
[DllImport("X11")]
internal static extern ulong XBlackPixel (IntPtr display,
int screen);
[DllImport("X11")]
internal static extern ulong XWhitePixel (IntPtr display,
int screen);
[DllImport("X11")]
internal static extern int XNextEvent (IntPtr display,
IntPtr event_return);
}