summaryrefslogtreecommitdiffstats
path: root/src/sp-pattern.h
diff options
context:
space:
mode:
authorTomasz Boczkowski <penginsbacon@gmail.com>2015-04-25 12:59:51 +0000
committerTomasz Boczkowski <penginsbacon@gmail.com>2015-04-25 12:59:51 +0000
commit3eb2b94eded9236bea634cd28eae13a3645a8cfb (patch)
treef89f5fc023b87e5127ed57a1fc22c6d21e88fbd0 /src/sp-pattern.h
parentmerged SPColorSlider c++-sification from svgpaints branch (diff)
parentSPPattern c++-sification: class fields are private (diff)
downloadinkscape-3eb2b94eded9236bea634cd28eae13a3645a8cfb.tar.gz
inkscape-3eb2b94eded9236bea634cd28eae13a3645a8cfb.zip
merged SPPattern c++-sification from svgpaints branch
(bzr r14059.1.2)
Diffstat (limited to 'src/sp-pattern.h')
-rw-r--r--src/sp-pattern.h131
1 files changed, 81 insertions, 50 deletions
diff --git a/src/sp-pattern.h b/src/sp-pattern.h
index f021101e2..83336f991 100644
--- a/src/sp-pattern.h
+++ b/src/sp-pattern.h
@@ -1,9 +1,6 @@
-#ifndef SEEN_SP_PATTERN_H
-#define SEEN_SP_PATTERN_H
-
-/*
+/** @file
* SVG <pattern> implementation
- *
+ *//*
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
* Abhishek Sharma
@@ -13,45 +10,66 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#define SP_PATTERN(obj) (dynamic_cast<SPPattern*>((SPObject*)obj))
-#define SP_IS_PATTERN(obj) (dynamic_cast<const SPPattern*>((SPObject*)obj) != NULL)
+#ifndef SEEN_SP_PATTERN_H
+#define SEEN_SP_PATTERN_H
-class SPPatternReference;
-class SPItem;
-typedef struct _GSList GSList;
+#include <list>
+#include <stddef.h>
+#include <glibmm/ustring.h>
+#include <sigc++/connection.h>
#include "svg/svg-length.h"
#include "sp-paint-server.h"
#include "uri-references.h"
#include "viewbox.h"
-#include <sigc++/connection.h>
+class SPPatternReference;
+class SPItem;
+
+namespace Inkscape {
+namespace XML {
+
+class Node;
+}
+}
+
+#define SP_PATTERN(obj) (dynamic_cast<SPPattern*>((SPObject*)obj))
+#define SP_IS_PATTERN(obj) (dynamic_cast<const SPPattern*>((SPObject*)obj) != NULL)
class SPPattern : public SPPaintServer, public SPViewBox {
public:
+ enum PatternUnits {
+ UNITS_USERSPACEONUSE,
+ UNITS_OBJECTBOUNDINGBOX
+ };
+
SPPattern();
virtual ~SPPattern();
/* Reference (href) */
- char *href;
+ Glib::ustring href;
SPPatternReference *ref;
- /* patternUnits and patternContentUnits attribute */
- unsigned int patternUnits : 1;
- unsigned int patternUnits_set : 1;
- unsigned int patternContentUnits : 1;
- unsigned int patternContentUnits_set : 1;
- /* patternTransform attribute */
- Geom::Affine patternTransform;
- unsigned int patternTransform_set : 1;
- /* Tile rectangle */
- SVGLength x;
- SVGLength y;
- SVGLength width;
- SVGLength height;
-
- sigc::connection modified_connection;
+ gdouble get_x() const;
+ gdouble get_y() const;
+ gdouble get_width() const;
+ gdouble get_height() const;
+ Geom::OptRect get_viewbox() const;
+ SPPattern::PatternUnits get_pattern_units() const;
+ SPPattern::PatternUnits get_pattern_content_units() const;
+ Geom::Affine const &get_transform() const;
+ SPPattern *get_root(); //TODO: const
+
+ SPPattern *clone_if_necessary(SPItem *item, const gchar *property);
+ void transform_multiply(Geom::Affine postmul, bool set);
+
+ /**
+ * @brief create a new pattern in XML tree
+ * @return created pattern id
+ */
+ static const gchar *produce(const std::list<Inkscape::XML::Node*> &reprs,
+ Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move);
bool isValid() const;
@@ -63,6 +81,42 @@ protected:
virtual void set(unsigned int key, const gchar* value);
virtual void update(SPCtx* ctx, unsigned int flags);
virtual void modified(unsigned int flags);
+
+private:
+ bool _has_item_children() const;
+ void _get_children(std::list<SPObject*>& l);
+ SPPattern *_chain() const;
+
+ /**
+ Count how many times pattern is used by the styles of o and its descendants
+ */
+ guint _count_hrefs(SPObject* o) const;
+
+ /**
+ Gets called when the pattern is reattached to another <pattern>
+ */
+ void _on_ref_changed(SPObject *old_ref, SPObject *ref);
+
+ /**
+ Gets called when the referenced <pattern> is changed
+ */
+ void _on_ref_modified(SPObject *ref, guint flags);
+
+ /* patternUnits and patternContentUnits attribute */
+ PatternUnits patternUnits : 1;
+ bool patternUnits_set : 1;
+ PatternUnits patternContentUnits : 1;
+ bool patternContentUnits_set : 1;
+ /* patternTransform attribute */
+ Geom::Affine patternTransform;
+ bool patternTransform_set : 1;
+ /* Tile rectangle */
+ SVGLength x;
+ SVGLength y;
+ SVGLength width;
+ SVGLength height;
+
+ sigc::connection modified_connection;
};
@@ -79,29 +133,6 @@ protected:
}
};
-enum {
- SP_PATTERN_UNITS_USERSPACEONUSE,
- SP_PATTERN_UNITS_OBJECTBOUNDINGBOX
-};
-
-unsigned int pattern_users (SPPattern *pattern);
-SPPattern *pattern_chain (SPPattern *pattern);
-SPPattern *sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const char *property);
-void sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool set);
-
-const char *pattern_tile (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move);
-
-SPPattern *pattern_getroot (SPPattern *pat);
-
-unsigned int pattern_patternUnits (SPPattern const *pat);
-unsigned int pattern_patternContentUnits (SPPattern const *pat);
-Geom::Affine const &pattern_patternTransform(SPPattern const *pat);
-double pattern_x (SPPattern const *pat);
-double pattern_y (SPPattern const *pat);
-double pattern_width (SPPattern const *pat);
-double pattern_height (SPPattern const *pat);
-Geom::OptRect pattern_viewBox (SPPattern const *pat);
-
#endif // SEEN_SP_PATTERN_H
/*