source: trunk/third/libgnomecanvas/libgnomecanvas/gnome-canvas-bpath.c @ 20821

Revision 20821, 5.2 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r20820, which included commits to RCS files with non-trunk default branches.
Line 
1/* Bpath item type for GnomeCanvas widget
2 *
3 * GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas widget.  Tk is
4 * copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
5 *
6 * Copyright (C) 1998,1999 The Free Software Foundation
7 *
8 * Authors: Federico Mena <federico@nuclecu.unam.mx>
9 *          Raph Levien <raph@acm.org>
10 *          Lauris Kaplinski <lauris@ximian.com>
11 *          Miguel de Icaza <miguel@kernel.org>
12 *          Cody Russell <bratsche@gnome.org>
13 *          Rusty Conover <rconover@bangtail.net>
14 */
15
16/* These includes are set up for standalone compile. If/when this codebase
17   is integrated into libgnomeui, the includes will need to change. */
18
19#include <math.h>
20#include <string.h>
21
22#include <gtk/gtkobject.h>
23#include "gnome-canvas.h"
24#include "gnome-canvas-util.h"
25
26#include "gnome-canvas-bpath.h"
27#include "gnome-canvas-shape.h"
28#include "gnome-canvas-shape-private.h"
29#include "gnome-canvas-path-def.h"
30
31enum {
32        PROP_0,
33        PROP_BPATH
34};
35
36static void gnome_canvas_bpath_class_init   (GnomeCanvasBpathClass *class);
37static void gnome_canvas_bpath_init         (GnomeCanvasBpath      *bpath);
38static void gnome_canvas_bpath_destroy      (GtkObject               *object);
39static void gnome_canvas_bpath_set_property (GObject               *object,
40                                             guint                  param_id,
41                                             const GValue          *value,
42                                             GParamSpec            *pspec);
43static void gnome_canvas_bpath_get_property (GObject               *object,
44                                             guint                  param_id,
45                                             GValue                *value,
46                                             GParamSpec            *pspec);
47
48static void   gnome_canvas_bpath_update      (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags);
49
50
51static GnomeCanvasShapeClass *parent_class;
52
53GtkType
54gnome_canvas_bpath_get_type (void)
55{
56        static GType bpath_type;
57
58        if (!bpath_type) {
59                static const GTypeInfo object_info = {
60                        sizeof (GnomeCanvasBpathClass),
61                        (GBaseInitFunc) NULL,
62                        (GBaseFinalizeFunc) NULL,
63                        (GClassInitFunc) gnome_canvas_bpath_class_init,
64                        (GClassFinalizeFunc) NULL,
65                        NULL,                   /* class_data */
66                        sizeof (GnomeCanvasBpath),
67                        0,                      /* n_preallocs */
68                        (GInstanceInitFunc) gnome_canvas_bpath_init,
69                        NULL                    /* value_table */
70                };
71
72                bpath_type = g_type_register_static (GNOME_TYPE_CANVAS_SHAPE, "GnomeCanvasBpath",
73                                                     &object_info, 0);
74        }
75
76        return bpath_type;
77}
78
79static void
80gnome_canvas_bpath_class_init (GnomeCanvasBpathClass *class)
81{
82        GObjectClass         *gobject_class;
83        GtkObjectClass       *object_class;
84        GnomeCanvasItemClass *item_class;
85
86        gobject_class = (GObjectClass *) class;
87        object_class = (GtkObjectClass *) class;
88        item_class = (GnomeCanvasItemClass *) class;
89
90        parent_class = g_type_class_peek_parent (class);
91
92        /* when this gets checked into libgnomeui, change the
93           GTK_TYPE_POINTER to GTK_TYPE_GNOME_CANVAS_BPATH, and add an
94           entry to gnome-boxed.defs */
95
96        gobject_class->set_property = gnome_canvas_bpath_set_property;
97        gobject_class->get_property = gnome_canvas_bpath_get_property;
98
99        object_class->destroy = gnome_canvas_bpath_destroy;
100
101        g_object_class_install_property (gobject_class,
102                                         PROP_BPATH,
103                                         g_param_spec_pointer ("bpath", NULL, NULL,
104                                                               (G_PARAM_READABLE | G_PARAM_WRITABLE)));
105
106        item_class->update = gnome_canvas_bpath_update;
107}
108
109static void
110gnome_canvas_bpath_init (GnomeCanvasBpath *bpath)
111{
112
113}
114
115static void
116gnome_canvas_bpath_destroy (GtkObject *object)
117{
118        if (GTK_OBJECT_CLASS (parent_class)->destroy)
119                (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
120}
121
122static void
123gnome_canvas_bpath_set_property (GObject      *object,
124                                 guint         param_id,
125                                 const GValue *value,
126                                 GParamSpec   *pspec)
127{
128        GnomeCanvasItem         *item;
129        GnomeCanvasBpath        *bpath;
130        GnomeCanvasPathDef      *gpp;
131
132        item = GNOME_CANVAS_ITEM (object);
133        bpath = GNOME_CANVAS_BPATH (object);
134
135        switch (param_id) {
136        case PROP_BPATH:
137                gpp = g_value_get_pointer (value);
138
139                gnome_canvas_shape_set_path_def (GNOME_CANVAS_SHAPE (object), gpp);
140
141                gnome_canvas_item_request_update (item);
142                break;
143
144        default:
145                break;
146        }
147}
148
149
150static void
151gnome_canvas_bpath_get_property (GObject     *object,
152                                 guint        param_id,
153                                 GValue      *value,
154                                 GParamSpec  *pspec)
155{
156        GnomeCanvasShape        *shape;
157
158        shape = GNOME_CANVAS_SHAPE(object);
159
160        switch (param_id) {
161        case PROP_BPATH:
162                if (shape->priv->path) {
163                        gnome_canvas_path_def_ref (shape->priv->path);
164                        g_value_set_pointer (value, shape->priv->path);
165                } else
166                        g_value_set_pointer (value, NULL);
167                break;
168        default:
169                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
170                break;
171        }
172}
173
174static void
175gnome_canvas_bpath_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
176{
177        if(GNOME_CANVAS_ITEM_CLASS(parent_class)->update) {
178                (* GNOME_CANVAS_ITEM_CLASS(parent_class)->update)(item, affine, clip_path, flags);
179        }
180}
Note: See TracBrowser for help on using the repository browser.