1 #ifndef __SP_PATTERN_H__
2 #define __SP_PATTERN_H__
4 /*
5 * SVG <pattern> implementation
6 *
7 * Author:
8 * Lauris Kaplinski <lauris@kaplinski.com>
9 *
10 * Copyright (C) 2002 Lauris Kaplinski
11 *
12 * Released under GNU GPL, read the file 'COPYING' for more information
13 */
15 #include <gtk/gtktypeutils.h>
17 #include "forward.h"
19 #define SP_TYPE_PATTERN (sp_pattern_get_type ())
20 #define SP_PATTERN(o) (GTK_CHECK_CAST ((o), SP_TYPE_PATTERN, SPPattern))
21 #define SP_PATTERN_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), SP_TYPE_PATTERN, SPPatternClass))
22 #define SP_IS_PATTERN(o) (GTK_CHECK_TYPE ((o), SP_TYPE_PATTERN))
23 #define SP_IS_PATTERN_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_PATTERN))
25 GType sp_pattern_get_type (void);
27 class SPPatternClass;
29 #include <libnr/nr-rect.h>
30 #include <libnr/nr-matrix.h>
31 #include "svg/svg-length.h"
32 #include "sp-paint-server.h"
33 #include "uri-references.h"
35 #include <sigc++/connection.h>
37 class SPPatternReference : public Inkscape::URIReference {
38 public:
39 SPPatternReference (SPObject *obj) : URIReference(obj) {}
40 SPPattern *getObject() const {
41 return (SPPattern *)URIReference::getObject();
42 }
43 protected:
44 virtual bool _acceptObject(SPObject *obj) const {
45 return SP_IS_PATTERN (obj);
46 }
47 };
49 enum {
50 SP_PATTERN_UNITS_USERSPACEONUSE,
51 SP_PATTERN_UNITS_OBJECTBOUNDINGBOX
52 };
54 struct SPPattern : public SPPaintServer {
55 /* Reference (href) */
56 gchar *href;
57 SPPatternReference *ref;
59 /* patternUnits and patternContentUnits attribute */
60 guint patternUnits : 1;
61 guint patternUnits_set : 1;
62 guint patternContentUnits : 1;
63 guint patternContentUnits_set : 1;
64 /* patternTransform attribute */
65 NR::Matrix patternTransform;
66 guint patternTransform_set : 1;
67 /* Tile rectangle */
68 SVGLength x;
69 SVGLength y;
70 SVGLength width;
71 SVGLength height;
72 /* VieBox */
73 NRRect viewBox;
74 guint viewBox_set : 1;
76 sigc::connection modified_connection;
77 };
79 struct SPPatternClass {
80 SPPaintServerClass parent_class;
81 };
83 guint pattern_users (SPPattern *pattern);
84 SPPattern *pattern_chain (SPPattern *pattern);
85 SPPattern *sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const gchar *property);
86 void sp_pattern_transform_multiply (SPPattern *pattern, NR::Matrix postmul, bool set);
88 const gchar *pattern_tile (GSList *reprs, NR::Rect bounds, SPDocument *document, NR::Matrix transform, NR::Matrix move);
90 SPPattern *pattern_getroot (SPPattern *pat);
92 guint pattern_patternUnits (SPPattern *pat);
93 guint pattern_patternContentUnits (SPPattern *pat);
94 NR::Matrix const &pattern_patternTransform(SPPattern const *pat);
95 gdouble pattern_x (SPPattern *pat);
96 gdouble pattern_y (SPPattern *pat);
97 gdouble pattern_width (SPPattern *pat);
98 gdouble pattern_height (SPPattern *pat);
99 NRRect *pattern_viewBox (SPPattern *pat);
102 #endif