Code

C++ification of SPObject continued along with the onset of XML Privatisation. Users...
[inkscape.git] / src / sp-clippath.h
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 (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 struct SPClipPath : public SPObjectGroup {
31         class Reference;
33         unsigned int clipPathUnits_set : 1;
34         unsigned int clipPathUnits : 1;
36         SPClipPathView *display;
37 };
39 struct SPClipPathClass {
40         SPObjectGroupClass parent_class;
41 };
43 GType sp_clippath_get_type (void);
45 class SPClipPathReference : public Inkscape::URIReference {
46 public:
47         SPClipPathReference(SPObject *obj) : URIReference(obj) {}
48         SPClipPath *getObject() const {
49                 return (SPClipPath *)URIReference::getObject();
50         }
51 protected:
52     /**
53      * If the owner element of this reference (the element with <... clippath="...">)
54      * is a child of the clippath it refers to, return false.
55      * \return false if obj is not a clippath or if obj is a parent of this
56      *         reference's owner element.  True otherwise.
57      */
58         virtual bool _acceptObject(SPObject *obj) const {
59                 if (!SP_IS_CLIPPATH(obj)) {
60                     return false;
61             }
62             SPObject * const owner = this->getOwner();
63         if (obj->isAncestorOf(owner)) {
64                         //XML Tree being used directly here while it shouldn't be...
65             Inkscape::XML::Node * const owner_repr = owner->getRepr();
66                         //XML Tree being used directly here while it shouldn't be...
67             Inkscape::XML::Node * const obj_repr = obj->getRepr();
68             gchar const * owner_name = NULL;
69             gchar const * owner_clippath = NULL;
70             gchar const * obj_name = NULL;
71             gchar const * obj_id = NULL;
72             if (owner_repr != NULL) {
73                 owner_name = owner_repr->name();
74                 owner_clippath = owner_repr->attribute("clippath");
75             }
76             if (obj_repr != NULL) {
77                 obj_name = obj_repr->name();
78                 obj_id = obj_repr->attribute("id");
79             }
80             g_warning("Ignoring recursive clippath reference "
81                       "<%s clippath=\"%s\"> in <%s id=\"%s\">",
82                       owner_name, owner_clippath,
83                       obj_name, obj_id);
84             return false;
85         }
86         return true;
87         }
88 };
90 NRArenaItem *sp_clippath_show(SPClipPath *cp, NRArena *arena, unsigned int key);
91 void sp_clippath_hide(SPClipPath *cp, unsigned int key);
93 void sp_clippath_set_bbox(SPClipPath *cp, unsigned int key, NRRect *bbox);
94 void sp_clippath_get_bbox(SPClipPath *cp, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
96 const gchar *sp_clippath_create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTransform);
98 #endif