Code

Pot and Dutch translation update
[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             Inkscape::XML::Node * const owner_repr = owner->repr;
65             Inkscape::XML::Node * const obj_repr = obj->repr;
66             gchar const * owner_name = NULL;
67             gchar const * owner_clippath = NULL;
68             gchar const * obj_name = NULL;
69             gchar const * obj_id = NULL;
70             if (owner_repr != NULL) {
71                 owner_name = owner_repr->name();
72                 owner_clippath = owner_repr->attribute("clippath");
73             }
74             if (obj_repr != NULL) {
75                 obj_name = obj_repr->name();
76                 obj_id = obj_repr->attribute("id");
77             }
78             g_warning("Ignoring recursive clippath reference "
79                       "<%s clippath=\"%s\"> in <%s id=\"%s\">",
80                       owner_name, owner_clippath,
81                       obj_name, obj_id);
82             return false;
83         }
84         return true;
85         }
86 };
88 NRArenaItem *sp_clippath_show(SPClipPath *cp, NRArena *arena, unsigned int key);
89 void sp_clippath_hide(SPClipPath *cp, unsigned int key);
91 void sp_clippath_set_bbox(SPClipPath *cp, unsigned int key, NRRect *bbox);
92 void sp_clippath_get_bbox(SPClipPath *cp, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
94 const gchar *sp_clippath_create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTransform);
96 #endif