1// Copyright (c) 2013-2014 Conformal Systems <info@conformal.com>
2//
3// This file originated from: http://opensource.conformal.com/
4//
5// Permission to use, copy, modify, and distribute this software for any
6// purpose with or without fee is hereby granted, provided that the above
7// copyright notice and this permission notice appear in all copies.
8//
9// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
17// Package cairo implements Go bindings for Cairo.  Supports version 1.10 and
18// later.
19package cairo
20
21// #cgo pkg-config: cairo cairo-gobject gobject-2.0
22// #include <stdlib.h>
23// #include <cairo.h>
24// #include <cairo-gobject.h>
25import "C"
26import (
27	"unsafe"
28
29	"github.com/gotk3/gotk3/glib"
30)
31
32func init() {
33	tm := []glib.TypeMarshaler{
34		// Enums
35		{glib.Type(C.cairo_gobject_antialias_get_type()), marshalAntialias},
36		{glib.Type(C.cairo_gobject_content_get_type()), marshalContent},
37		{glib.Type(C.cairo_gobject_fill_rule_get_type()), marshalFillRule},
38		{glib.Type(C.cairo_gobject_line_cap_get_type()), marshalLineCap},
39		{glib.Type(C.cairo_gobject_line_join_get_type()), marshalLineJoin},
40		{glib.Type(C.cairo_gobject_operator_get_type()), marshalOperator},
41		{glib.Type(C.cairo_gobject_status_get_type()), marshalStatus},
42		{glib.Type(C.cairo_gobject_surface_type_get_type()), marshalSurfaceType},
43
44		// Boxed
45		{glib.Type(C.cairo_gobject_context_get_type()), marshalContext},
46		{glib.Type(C.cairo_gobject_surface_get_type()), marshalSurface},
47	}
48	glib.RegisterGValueMarshalers(tm)
49}
50
51// Constants
52
53// Content is a representation of Cairo's cairo_content_t.
54type Content int
55
56const (
57	CONTENT_COLOR       Content = C.CAIRO_CONTENT_COLOR
58	CONTENT_ALPHA       Content = C.CAIRO_CONTENT_ALPHA
59	CONTENT_COLOR_ALPHA Content = C.CAIRO_CONTENT_COLOR_ALPHA
60)
61
62func marshalContent(p uintptr) (interface{}, error) {
63	c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
64	return Content(c), nil
65}
66