1 #ifndef SEEN_SP_MASK_H
2 #define SEEN_SP_MASK_H
4 /*
5 * SVG <mask> implementation
6 *
7 * Authors:
8 * Lauris Kaplinski <lauris@kaplinski.com>
9 * Abhishek Sharma
10 *
11 * Copyright (C) 2003 authors
12 *
13 * Released under GNU GPL, read the file 'COPYING' for more information
14 */
16 #define SP_TYPE_MASK (sp_mask_get_type ())
17 #define SP_MASK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_MASK, SPMask))
18 #define SP_MASK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_MASK, SPMaskClass))
19 #define SP_IS_MASK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_MASK))
20 #define SP_IS_MASK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_MASK))
22 class SPMask;
23 class SPMaskClass;
24 class SPMaskView;
26 #include "display/nr-arena-forward.h"
27 #include "libnr/nr-forward.h"
28 #include "sp-object-group.h"
29 #include "uri-references.h"
30 #include "xml/node.h"
32 struct SPMask : public SPObjectGroup {
33 unsigned int maskUnits_set : 1;
34 unsigned int maskUnits : 1;
36 unsigned int maskContentUnits_set : 1;
37 unsigned int maskContentUnits : 1;
39 SPMaskView *display;
40 };
42 struct SPMaskClass {
43 SPObjectGroupClass parent_class;
44 };
46 GType sp_mask_get_type (void);
48 class SPMaskReference : public Inkscape::URIReference {
49 public:
50 SPMaskReference(SPObject *obj) : URIReference(obj) {}
51 SPMask *getObject() const {
52 return (SPMask *)URIReference::getObject();
53 }
54 protected:
55 /**
56 * If the owner element of this reference (the element with <... mask="...">)
57 * is a child of the mask it refers to, return false.
58 * \return false if obj is not a mask or if obj is a parent of this
59 * reference's owner element. True otherwise.
60 */
61 virtual bool _acceptObject(SPObject *obj) const {
62 if (!SP_IS_MASK(obj)) {
63 return false;
64 }
65 SPObject * const owner = this->getOwner();
66 if (obj->isAncestorOf(owner)) {
67 //XML Tree being used directly here while it shouldn't be...
68 Inkscape::XML::Node * const owner_repr = owner->getRepr();
69 //XML Tree being used directly here while it shouldn't be...
70 Inkscape::XML::Node * const obj_repr = obj->getRepr();
71 gchar const * owner_name = NULL;
72 gchar const * owner_mask = NULL;
73 gchar const * obj_name = NULL;
74 gchar const * obj_id = NULL;
75 if (owner_repr != NULL) {
76 owner_name = owner_repr->name();
77 owner_mask = owner_repr->attribute("mask");
78 }
79 if (obj_repr != NULL) {
80 obj_name = obj_repr->name();
81 obj_id = obj_repr->attribute("id");
82 }
83 g_warning("Ignoring recursive mask reference "
84 "<%s mask=\"%s\"> in <%s id=\"%s\">",
85 owner_name, owner_mask,
86 obj_name, obj_id);
87 return false;
88 }
89 return true;
90 }
91 };
93 NRArenaItem *sp_mask_show (SPMask *mask, NRArena *arena, unsigned int key);
94 void sp_mask_hide (SPMask *mask, unsigned int key);
96 void sp_mask_set_bbox (SPMask *mask, unsigned int key, NRRect *bbox);
98 const gchar *sp_mask_create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTransform);
100 #endif // SEEN_SP_MASK_H