GtkSharp/cairo/Region.cs
Mike Kestner f6d11d67b6 Cairo# 1.10.0 assembly.
* configure.ac: drop cairo conditionality
* cairo/AssemblyInfo.cs: set version to 1.10.0.0
* cairo/Makefile.am: unconditional build and add Region.cs
* cairo/cairo-api.xml: initial type exposure.
* pango/Makefile.am: use cairo-sharp.dll and cairo-api.xml
* pango/Pango.metadata: drop explicit symbol additions.
* gdk/Gdk.metadata: drop explicit symbol additions.
* gdk/Makefile.am: use cairo-sharp.dll and cairo-api.xml
* gtk/Makefile.am: use cairo-sharp.dll and cairo-api.xml
* sample/Makefile.am: use cairo-sharp.dll
* sample/GtkDemo/Makefile.am: use cairo-sharp.dll

This is an initial stab at a 1.10 binding.  It will probably take
more based on the number of errors still coming out of the Gdk
build.
2011-01-30 17:00:03 -06:00

253 lines
6.4 KiB
C#

// Copyright (C) 2011 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.Runtime.InteropServices;
namespace Cairo
{
[StructLayout(LayoutKind.Sequential)]
public struct RectangleInt {
public int X;
public int Y;
public int Width;
public int Height;
}
public enum RegionOverlap {
In,
Out,
Part,
}
public class Region : IDisposable {
const string libname = "libcairo.dll";
IntPtr handle;
public IntPtr Handle {
get { return handle; }
}
~Region ()
{
Dispose (false);
}
[DllImport (libname)]
static extern IntPtr cairo_region_reference (IntPtr region);
public Region (IntPtr handle)
{
handle = cairo_region_reference (handle);
}
[DllImport (libname)]
static extern IntPtr cairo_region_create ();
public Region ()
{
handle = cairo_region_create ();
}
[DllImport (libname)]
static extern IntPtr cairo_region_create_rectangle (ref RectangleInt rect);
public Region (RectangleInt rect)
{
handle = cairo_region_create_rectangle (ref rect);
}
[DllImport (libname)]
static extern IntPtr cairo_region_create_rectangles (RectangleInt[] rects, int count);
public Region (RectangleInt[] rects)
{
handle = cairo_region_create_rectangles (rects, rects.Length);
}
[DllImport (libname)]
static extern IntPtr cairo_region_copy (IntPtr original);
public Region Copy ()
{
return new Region (cairo_region_copy (Handle));
}
[DllImport (libname)]
static extern void cairo_region_destroy (IntPtr region);
public void Dispose ()
{
Dispose (true);
}
void Dispose (bool disposing)
{
if (handle != IntPtr.Zero)
cairo_region_destroy (Handle);
handle = IntPtr.Zero;
if (disposing)
GC.SuppressFinalize (this);
}
[DllImport (libname)]
static extern bool cairo_region_equal (IntPtr a, IntPtr b);
public override bool Equals (object obj)
{
return (obj is Region) && cairo_region_equal (Handle, (obj as Region).Handle);
}
[DllImport (libname)]
static extern Status cairo_region_status (IntPtr region);
public Status Status {
get { return cairo_region_status (Handle); }
}
[DllImport (libname)]
static extern void cairo_region_get_extents (IntPtr region, out RectangleInt extents);
public RectangleInt Extents {
get {
RectangleInt result;
cairo_region_get_extents (Handle, out result);
return result;
}
}
[DllImport (libname)]
static extern int cairo_region_num_rectangles (IntPtr region);
public int NumRectangles {
get { return cairo_region_num_rectangles (Handle); }
}
[DllImport (libname)]
static extern void cairo_region_get_rectangle (IntPtr region, int nth, out RectangleInt rectangle);
public RectangleInt GetRectangle (int nth)
{
RectangleInt val;
cairo_region_get_rectangle (Handle, nth, out val);
return val;
}
[DllImport (libname)]
static extern bool cairo_region_is_empty (IntPtr region);
public bool IsEmpty {
get { return cairo_region_is_empty (Handle); }
}
[DllImport (libname)]
static extern RegionOverlap cairo_region_contains_rectangle (IntPtr region, ref RectangleInt rectangle);
public RegionOverlap ContainsPoint (RectangleInt rectangle)
{
return cairo_region_contains_rectangle (Handle, ref rectangle);
}
[DllImport (libname)]
static extern bool cairo_region_contains_point (IntPtr region, int x, int y);
public bool ContainsPoint (int x, int y)
{
return cairo_region_contains_point (Handle, x, y);
}
[DllImport (libname)]
static extern void cairo_region_translate (IntPtr region, int dx, int dy);
public void Translate (int dx, int dy)
{
cairo_region_translate (Handle, dx, dy);
}
[DllImport (libname)]
static extern Status cairo_region_subtract (IntPtr dst, IntPtr other);
public Status Subtract (Region other)
{
return cairo_region_subtract (Handle, other.Handle);
}
[DllImport (libname)]
static extern Status cairo_region_subtract_rectangle (IntPtr dst, ref RectangleInt rectangle);
public Status SubtractRectangle (RectangleInt rectangle)
{
return cairo_region_subtract_rectangle (Handle, ref rectangle);
}
[DllImport (libname)]
static extern Status cairo_region_intersect (IntPtr dst, IntPtr other);
public Status Intersect (Region other)
{
return cairo_region_intersect (Handle, other.Handle);
}
[DllImport (libname)]
static extern Status cairo_region_intersect_rectangle (IntPtr dst, ref RectangleInt rectangle);
public Status IntersectRectangle (RectangleInt rectangle)
{
return cairo_region_intersect_rectangle (Handle, ref rectangle);
}
[DllImport (libname)]
static extern Status cairo_region_union (IntPtr dst, IntPtr other);
public Status Union (Region other)
{
return cairo_region_union (Handle, other.Handle);
}
[DllImport (libname)]
static extern Status cairo_region_union_rectangle (IntPtr dst, ref RectangleInt rectangle);
public Status UnionRectangle (RectangleInt rectangle)
{
return cairo_region_union_rectangle (Handle, ref rectangle);
}
[DllImport (libname)]
static extern Status cairo_region_xor (IntPtr dst, IntPtr other);
public Status Xor (Region other)
{
return cairo_region_xor (Handle, other.Handle);
}
[DllImport (libname)]
static extern Status cairo_region_xor_rectangle (IntPtr dst, ref RectangleInt rectangle);
public Status XorRectangle (RectangleInt rectangle)
{
return cairo_region_xor_rectangle (Handle, ref rectangle);
}
}
}