~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to src/sp-clippath.h

  • Committer: JazzyNico
  • Date: 2011-08-29 20:25:30 UTC
  • Revision ID: nicoduf@yahoo.fr-20110829202530-6deuoz11q90usldv
Code refactoring and merging with trunk (revision 10599).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef __SP_CLIPPATH_H__
2
 
#define __SP_CLIPPATH_H__
 
1
#ifndef SEEN_SP_CLIPPATH_H
 
2
#define SEEN_SP_CLIPPATH_H
3
3
 
4
4
/*
5
5
 * SVG <clipPath> implementation
6
6
 *
7
7
 * Authors:
8
8
 *   Lauris Kaplinski <lauris@kaplinski.com>
 
9
 *   Abhishek Sharma
 
10
 *   Jon A. Cruz <jon@joncruz.org>
9
11
 *
10
12
 * Copyright (C) 2001-2002 authors
11
13
 * Copyright (C) 2001 Ximian, Inc.
13
15
 * Released under GNU GPL, read the file 'COPYING' for more information
14
16
 */
15
17
 
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))
 
18
#define SP_TYPE_CLIPPATH (SPClipPath::sp_clippath_get_type())
 
19
#define SP_CLIPPATH(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_CLIPPATH, SPClipPath))
 
20
#define SP_CLIPPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_CLIPPATH, SPClipPathClass))
 
21
#define SP_IS_CLIPPATH(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_CLIPPATH))
 
22
#define SP_IS_CLIPPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_CLIPPATH))
21
23
 
22
24
class SPClipPathView;
23
25
 
24
 
#include "display/nr-arena-forward.h"
25
 
#include "libnr/nr-forward.h"
 
26
#include "display/display-forward.h"
26
27
#include "sp-object-group.h"
27
28
#include "uri-references.h"
28
29
#include "xml/node.h"
29
30
 
30
 
struct SPClipPath : public SPObjectGroup {
31
 
        class Reference;
32
 
 
33
 
        unsigned int clipPathUnits_set : 1;
34
 
        unsigned int clipPathUnits : 1;
35
 
 
36
 
        SPClipPathView *display;
37
 
};
38
 
 
39
 
struct SPClipPathClass {
40
 
        SPObjectGroupClass parent_class;
41
 
};
42
 
 
43
 
GType sp_clippath_get_type (void);
 
31
class SPClipPath : public SPObjectGroup {
 
32
public:
 
33
    class Reference;
 
34
 
 
35
    unsigned int clipPathUnits_set : 1;
 
36
    unsigned int clipPathUnits : 1;
 
37
 
 
38
    SPClipPathView *display;
 
39
    static const gchar *create(GSList *reprs, SPDocument *document, Geom::Affine const* applyTransform);
 
40
    static GType sp_clippath_get_type(void);
 
41
 
 
42
    Inkscape::DrawingItem *show(Inkscape::Drawing &drawing, unsigned int key);
 
43
    void hide(unsigned int key);
 
44
 
 
45
    void setBBox(unsigned int key, Geom::OptRect const &bbox);
 
46
    Geom::OptRect geometricBounds(Geom::Affine const &transform);
 
47
 
 
48
private:
 
49
    static void init(SPClipPath *clippath);
 
50
 
 
51
    static void build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
 
52
    static void release(SPObject * object);
 
53
    static void set(SPObject *object, unsigned int key, gchar const *value);
 
54
    static void childAdded(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref);
 
55
    static void update(SPObject *object, SPCtx *ctx, guint flags);
 
56
    static void modified(SPObject *object, guint flags);
 
57
    static Inkscape::XML::Node *write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
 
58
 
 
59
    friend class SPClipPathClass;
 
60
};
 
61
 
 
62
class SPClipPathClass {
 
63
public:
 
64
    SPObjectGroupClass parent_class;
 
65
 
 
66
private:
 
67
    static void sp_clippath_class_init(SPClipPathClass *klass);
 
68
    static SPObjectGroupClass *static_parent_class;
 
69
 
 
70
    friend class SPClipPath;
 
71
};
44
72
 
45
73
class SPClipPathReference : public Inkscape::URIReference {
46
74
public:
47
 
        SPClipPathReference(SPObject *obj) : URIReference(obj) {}
48
 
        SPClipPath *getObject() const {
49
 
                return (SPClipPath *)URIReference::getObject();
50
 
        }
 
75
    SPClipPathReference(SPObject *obj) : URIReference(obj) {}
 
76
    SPClipPath *getObject() const {
 
77
        return (SPClipPath *)URIReference::getObject();
 
78
    }
 
79
 
51
80
protected:
52
81
    /**
53
82
     * If the owner element of this reference (the element with <... clippath="...">)
55
84
     * \return false if obj is not a clippath or if obj is a parent of this
56
85
     *         reference's owner element.  True otherwise.
57
86
     */
58
 
        virtual bool _acceptObject(SPObject *obj) const {
59
 
                if (!SP_IS_CLIPPATH(obj)) {
60
 
                    return false;
61
 
            }
62
 
            SPObject * const owner = this->getOwner();
 
87
    virtual bool _acceptObject(SPObject *obj) const {
 
88
        if (!SP_IS_CLIPPATH(obj)) {
 
89
            return false;
 
90
        }
 
91
        SPObject * const owner = this->getOwner();
63
92
        if (obj->isAncestorOf(owner)) {
64
 
            Inkscape::XML::Node * const owner_repr = owner->repr;
65
 
            Inkscape::XML::Node * const obj_repr = obj->repr;
 
93
            //XML Tree being used directly here while it shouldn't be...
 
94
            Inkscape::XML::Node * const owner_repr = owner->getRepr();
 
95
            //XML Tree being used directly here while it shouldn't be...
 
96
            Inkscape::XML::Node * const obj_repr = obj->getRepr();
66
97
            gchar const * owner_name = NULL;
67
98
            gchar const * owner_clippath = NULL;
68
99
            gchar const * obj_name = NULL;
82
113
            return false;
83
114
        }
84
115
        return true;
85
 
        }
 
116
    }
86
117
};
87
118
 
88
 
NRArenaItem *sp_clippath_show(SPClipPath *cp, NRArena *arena, unsigned int key);
89
 
void sp_clippath_hide(SPClipPath *cp, unsigned int key);
90
 
 
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);
93
 
 
94
 
const gchar *sp_clippath_create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTransform);
95
 
 
96
 
#endif
 
119
#endif // SEEN_SP_CLIPPATH_H
 
120
 
 
121
/*
 
122
  Local Variables:
 
123
  mode:c++
 
124
  c-file-style:"stroustrup"
 
125
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
126
  indent-tabs-mode:nil
 
127
  fill-column:99
 
128
  End:
 
129
*/
 
130
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :