1 #ifndef __SP_CLIPPATH_H__
2 #define __SP_CLIPPATH_H__
4 /*
5 * SVG <clipPath> implementation
6 *
7 * Authors:
8 * Lauris Kaplinski <lauris@kaplinski.com>
9 *
10 * Copyright (C) 2001-2002 authors
11 * Copyright (C) 2001 Ximian, Inc.
12 *
13 * Released under GNU GPL, read the file 'COPYING' for more information
14 */
16 #define SP_TYPE_CLIPPATH (SPClipPath::sp_clippath_get_type ())
17 #define SP_CLIPPATH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CLIPPATH, SPClipPath))
18 #define SP_CLIPPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_CLIPPATH, SPClipPathClass))
19 #define SP_IS_CLIPPATH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_CLIPPATH))
20 #define SP_IS_CLIPPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_CLIPPATH))
22 class SPClipPathView;
24 #include "display/nr-arena-forward.h"
25 #include "libnr/nr-forward.h"
26 #include "sp-object-group.h"
27 #include "uri-references.h"
28 #include "xml/node.h"
30 class SPClipPath : public SPObjectGroup {
31 public:
32 class Reference;
34 unsigned int clipPathUnits_set : 1;
35 unsigned int clipPathUnits : 1;
37 SPClipPathView *display;
38 static const gchar *create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTransform);
39 static GType sp_clippath_get_type (void);
41 NRArenaItem *sp_clippath_show(NRArena *arena, unsigned int key);
42 void sp_clippath_hide(unsigned int key);
44 void sp_clippath_set_bbox(unsigned int key, NRRect *bbox);
45 void sp_clippath_get_bbox(NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
46 private:
47 static void sp_clippath_init(SPClipPath *clippath);
49 static void sp_clippath_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
50 static void sp_clippath_release(SPObject * object);
51 static void sp_clippath_set(SPObject *object, unsigned int key, gchar const *value);
52 static void sp_clippath_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref);
53 static void sp_clippath_update(SPObject *object, SPCtx *ctx, guint flags);
54 static void sp_clippath_modified(SPObject *object, guint flags);
55 static Inkscape::XML::Node *sp_clippath_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
57 friend class SPClipPathClass;
58 };
60 class SPClipPathClass {
61 public:
62 SPObjectGroupClass parent_class;
63 private:
64 static void sp_clippath_class_init(SPClipPathClass *klass);
65 static SPObjectGroupClass *static_parent_class;
67 friend class SPClipPath;
68 };
70 //GType sp_clippath_get_type (void);
72 class SPClipPathReference : public Inkscape::URIReference {
73 public:
74 SPClipPathReference(SPObject *obj) : URIReference(obj) {}
75 SPClipPath *getObject() const {
76 return (SPClipPath *)URIReference::getObject();
77 }
78 protected:
79 /**
80 * If the owner element of this reference (the element with <... clippath="...">)
81 * is a child of the clippath it refers to, return false.
82 * \return false if obj is not a clippath or if obj is a parent of this
83 * reference's owner element. True otherwise.
84 */
85 virtual bool _acceptObject(SPObject *obj) const {
86 if (!SP_IS_CLIPPATH(obj)) {
87 return false;
88 }
89 SPObject * const owner = this->getOwner();
90 if (obj->isAncestorOf(owner)) {
91 //XML Tree being used directly here while it shouldn't be...
92 Inkscape::XML::Node * const owner_repr = owner->getRepr();
93 //XML Tree being used directly here while it shouldn't be...
94 Inkscape::XML::Node * const obj_repr = obj->getRepr();
95 gchar const * owner_name = NULL;
96 gchar const * owner_clippath = NULL;
97 gchar const * obj_name = NULL;
98 gchar const * obj_id = NULL;
99 if (owner_repr != NULL) {
100 owner_name = owner_repr->name();
101 owner_clippath = owner_repr->attribute("clippath");
102 }
103 if (obj_repr != NULL) {
104 obj_name = obj_repr->name();
105 obj_id = obj_repr->attribute("id");
106 }
107 g_warning("Ignoring recursive clippath reference "
108 "<%s clippath=\"%s\"> in <%s id=\"%s\">",
109 owner_name, owner_clippath,
110 obj_name, obj_id);
111 return false;
112 }
113 return true;
114 }
115 };
117 /*NRArenaItem *sp_clippath_show(SPClipPath *cp, NRArena *arena, unsigned int key);
118 void sp_clippath_hide(SPClipPath *cp, unsigned int key);
120 void sp_clippath_set_bbox(SPClipPath *cp, unsigned int key, NRRect *bbox);
121 void sp_clippath_get_bbox(SPClipPath *cp, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);*/
123 //const gchar *sp_clippath_create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTransform);
125 #endif