[CPML] Removed dependency on alloca
[adg.git] / adg / adg-style.c
blob2fc900a255a81f41d75e3c893aa39b1a4b55435f
1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007,2008,2009,2010 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.
21 /**
22 * SECTION:adg-style
23 * @short_description: The base class of all styling objects
25 * This is the fundamental abstract class for styles.
26 **/
28 /**
29 * AdgStyle:
31 * All fields are private and should not be used directly.
32 * Use its public methods instead.
33 **/
36 #include "adg-internal.h"
37 #include "adg-style.h"
40 static void apply (AdgStyle *style,
41 AdgEntity *entity,
42 cairo_t *cr);
45 G_DEFINE_ABSTRACT_TYPE(AdgStyle, adg_style, G_TYPE_OBJECT);
48 static void
49 adg_style_class_init(AdgStyleClass *klass)
51 klass->apply = apply;
54 static void
55 adg_style_init(AdgStyle *style)
60 /**
61 * adg_style_apply:
62 * @style: an #AdgStyle derived style
63 * @entity: the caller #AdgEntity
64 * @cr: the subject cairo context
66 * Applies @style to @cr so the next rendering operations will be
67 * done accordling to this style directives. The @entity parameter
68 * is used to resolve the internal dresses of @style, if any.
69 **/
70 void
71 adg_style_apply(AdgStyle *style, AdgEntity *entity, cairo_t *cr)
73 AdgStyleClass *klass;
75 g_return_if_fail(ADG_IS_STYLE(style));
76 g_return_if_fail(ADG_IS_ENTITY(entity));
77 g_return_if_fail(cr != NULL);
79 klass = ADG_STYLE_GET_CLASS(style);
81 if (klass->apply)
82 klass->apply(style, entity, cr);
86 static void
87 apply(AdgStyle *style, AdgEntity *entity, cairo_t *cr)
89 /* The apply method must be defined */
90 g_warning("%s: `apply' method not implemented for type `%s'",
91 G_STRLOC, g_type_name(G_OBJECT_TYPE(style)));