Code

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