X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fstyle.h;h=d5ccc4901ac5553d0fe6c29db161d30894a43d77;hb=429ce09996dfe0ef44a115a89465c69eb4d376a6;hp=df2ba127f6b374ccdb401fb4155afcfe10a0ffd4;hpb=3a8e479f331858946168c32bfc7622c9010b6680;p=inkscape.git diff --git a/src/style.h b/src/style.h index df2ba127f..d5ccc4901 100644 --- a/src/style.h +++ b/src/style.h @@ -3,8 +3,8 @@ /** \file * SPStyle - a style object for SPItem objects - * - * Authors: + */ +/* Authors: * Lauris Kaplinski * * Copyright (C) 2001-2002 Lauris Kaplinski @@ -17,6 +17,10 @@ #include "forward.h" #include "sp-marker-loc.h" #include "sp-filter.h" +#include "sp-filter-reference.h" +#include "uri-references.h" +#include "uri.h" +#include "sp-paint-server.h" #include @@ -28,10 +32,6 @@ class Node; class SPCSSAttr; -namespace Inkscape { -gchar *parse_css_url(gchar const *string); -} - class SPIFloat; class SPIScale24; class SPIInt; @@ -139,17 +139,10 @@ struct SPILength { float computed; }; -#define SP_STYLE_FILL_SERVER(s) (((SPStyle *) (s))->fill.value.paint.server) -#define SP_STYLE_STROKE_SERVER(s) (((SPStyle *) (s))->stroke.value.paint.server) -#define SP_OBJECT_STYLE_FILL_SERVER(o) (SP_OBJECT (o)->style->fill.value.paint.server) -#define SP_OBJECT_STYLE_STROKE_SERVER(o) (SP_OBJECT (o)->style->stroke.value.paint.server) - -enum { - SP_PAINT_TYPE_NONE, - SP_PAINT_TYPE_COLOR, - SP_PAINT_TYPE_PAINTSERVER, - SP_PAINT_TYPE_IMPOSSIBLE -}; +#define SP_STYLE_FILL_SERVER(s) (((SPStyle *) (s))->getFillPaintServer()) +#define SP_STYLE_STROKE_SERVER(s) (((SPStyle *) (s))->getStrokePaintServer()) +#define SP_OBJECT_STYLE_FILL_SERVER(o) (SP_OBJECT (o)->style->getFillPaintServer()) +#define SP_OBJECT_STYLE_STROKE_SERVER(o) (SP_OBJECT (o)->style->getStrokePaintServer()) class SVGICCColor; @@ -158,18 +151,29 @@ struct SPIPaint { unsigned set : 1; unsigned inherit : 1; unsigned currentcolor : 1; - unsigned type : 2; + unsigned int colorSet : 1; + unsigned int noneSet : 1; struct { - struct { - SPPaintServer *server; - gchar *uri; - } paint; - SPColor color; - SVGICCColor *iccColor; + SPPaintServerReference *href; + SPColor color; } value; -}; -struct SPFilterReference; + + bool isSet() const { return true; /* set || colorSet*/} + bool isSameType( SPIPaint const & other ) const {return (isPaintserver() == other.isPaintserver()) && (colorSet == other.colorSet) && (currentcolor == other.currentcolor);} + + bool isNoneSet() const {return noneSet;} + + bool isNone() const {return !currentcolor && !colorSet && !isPaintserver();} // TODO refine + bool isColor() const {return colorSet && !isPaintserver();} + bool isPaintserver() const {return value.href && value.href->getObject();} + + void clear(); + + void setColor( float r, float g, float b ) {value.color.set( r, g, b ); colorSet = true;} + void setColor( guint32 val ) {value.color.set( val ); colorSet = true;} + void setColor( SPColor const& color ) {value.color = color; colorSet = true;} +}; /// Filter type internal to SPStyle struct SPIFilter { @@ -235,8 +239,12 @@ public: /// An SVG style object. struct SPStyle { int refcount; + /** Object we are attached to */ SPObject *object; + /** Document we are associated with */ + SPDocument *document; + /** Our text style component */ SPTextStyle *text; unsigned text_private : 1; @@ -347,19 +355,21 @@ struct SPStyle { * their background image */ SPIEnum enable_background; - /// style belongs to a cloned object, must not href anything + /// style belongs to a cloned object bool cloned; - /// style has hreffed its fill/stroke paintservers, needs to release. - bool fill_hreffed; - bool stroke_hreffed; sigc::connection release_connection; - sigc::connection fill_release_connection; - sigc::connection fill_modified_connection; + sigc::connection filter_modified_connection; + sigc::connection fill_ps_modified_connection; + sigc::connection stroke_ps_modified_connection; - sigc::connection stroke_release_connection; - sigc::connection stroke_modified_connection; + SPObject *getFilter() {if (filter.href) return filter.href->getObject(); else return NULL;} + const gchar *getFilterURI() {if (filter.href) return filter.href->getURI()->toString(); else return NULL;} + SPPaintServer *getFillPaintServer() {if (fill.value.href) return fill.value.href->getObject(); else return NULL;} + const gchar *getFillURI() {if (fill.value.href) return fill.value.href->getURI()->toString(); else return NULL;} + SPPaintServer *getStrokePaintServer() {if (stroke.value.href) return stroke.value.href->getObject(); else return NULL;} + const gchar *getStrokeURI() {if (stroke.value.href) return stroke.value.href->getURI()->toString(); else return NULL;} }; SPStyle *sp_style_new(SPDocument *document); @@ -372,7 +382,7 @@ SPStyle *sp_style_unref(SPStyle *style); void sp_style_read_from_object(SPStyle *style, SPObject *object); -void sp_style_read_from_repr(SPStyle *style, Inkscape::XML::Node *repr); +void sp_style_read_from_prefs(SPStyle *style, Glib::ustring const &path); void sp_style_merge_from_style_string(SPStyle *style, gchar const *p); @@ -384,6 +394,8 @@ gchar *sp_style_write_string(SPStyle const *style, guint flags = SP_STYLE_FLAG_I gchar *sp_style_write_difference(SPStyle const *from, SPStyle const *to); +void sp_style_set_to_uri_string (SPStyle *style, bool isfill, const gchar *uri); + /* SPTextStyle */ enum SPCSSFontSize { @@ -526,6 +538,9 @@ struct SPTextStyle { /* CSS font properties */ SPIString font_family; + /* Full font name, as font_factory::ConstructFontSpecification would give */ + SPIString font_specification; + /** \todo fixme: The 'font' property is ugly, and not working (lauris) */ SPIString font; };