Updated "GNU Library General License" to "GNU Lesser General License
[adg.git] / adg / adg-canvas.c
blobaf049f349949845b63705e4fa6a2b9237380701d
1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007-2008, Nicola Fontana <ntd at entidi.it>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 /**
21 * SECTION:canvas
22 * @title: AdgCanvas
23 * @short_description: The drawing container
25 * This container represents the object where the rendering process draws. All
26 * the drawing must have a canvas, and only one, as master parent (as all the
27 * #GtkWidget must have a #GtkWindow).
29 * Internally, the target is mantained as a #cairo_t context pointer.
32 #include "adg-canvas.h"
33 #include "adg-canvas-private.h"
34 #include "adg-line-style.h"
35 #include "adg-font-style.h"
36 #include "adg-arrow-style.h"
37 #include "adg-intl.h"
39 #define PARENT_CLASS ((AdgContainerClass *) adg_canvas_parent_class)
42 static AdgStyle * context_filler (AdgStyleClass *style_class,
43 gpointer user_data);
46 G_DEFINE_TYPE(AdgCanvas, adg_canvas, ADG_TYPE_CONTAINER);
49 static void
50 adg_canvas_class_init(AdgCanvasClass *klass)
52 g_type_class_add_private(klass, sizeof(AdgCanvasPrivate));
55 static void
56 adg_canvas_init(AdgCanvas *canvas)
58 AdgContext *context;
59 AdgCanvasPrivate *priv =
60 G_TYPE_INSTANCE_GET_PRIVATE(canvas, ADG_TYPE_CANVAS,
61 AdgCanvasPrivate);
63 canvas->priv = priv;
65 context = adg_context_new(context_filler, NULL);
66 adg_entity_set_context((AdgEntity *) canvas, context);
67 g_object_unref(context);
71 /**
72 * adg_canvas_new:
74 * Creates a new empty canvas object.
76 * Return value: the canvas
77 **/
78 AdgCanvas *
79 adg_canvas_new(void)
81 return g_object_new(ADG_TYPE_CANVAS, NULL);
85 static AdgStyle *
86 context_filler(AdgStyleClass *style_class, gpointer user_data)
88 return adg_style_get_default(style_class);