X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fstyle.h;h=b4663e8f6c043cb86434eafb514e9a08306611a6;hb=030609cb99174ea85e69635c494ccaaaa20b2ac5;hp=0aec2151dd4101377ef116c6c1d759e37be2c973;hpb=2a2558985bdd7d96bcecb578cb2b6a5f50addd0c;p=inkscape.git diff --git a/src/style.h b/src/style.h index 0aec2151d..b4663e8f6 100644 --- a/src/style.h +++ b/src/style.h @@ -1,12 +1,14 @@ -#ifndef __SP_STYLE_H__ -#define __SP_STYLE_H__ +#ifndef SEEN_SP_STYLE_H +#define SEEN_SP_STYLE_H /** \file * SPStyle - a style object for SPItem objects - * - * Authors: + */ +/* Authors: * Lauris Kaplinski + * Jon A. Cruz * + * Copyright (C) 2010 Jon A. Cruz * Copyright (C) 2001-2002 Lauris Kaplinski * Copyright (C) 2001 Ximian, Inc. * @@ -18,6 +20,9 @@ #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 @@ -29,10 +34,6 @@ class Node; class SPCSSAttr; -namespace Inkscape { -gchar *parse_css_url(gchar const *string); -} - class SPIFloat; class SPIScale24; class SPIInt; @@ -42,6 +43,7 @@ class SPIString; class SPILength; class SPIPaint; class SPIFontSize; +class SPIBaselineShift; /// Float type internal to SPStyle. struct SPIFloat { @@ -140,17 +142,8 @@ 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()) class SVGICCColor; @@ -159,15 +152,38 @@ 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; + + SPIPaint(); + + 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;} + + void read( gchar const *str, SPStyle &tyle, SPDocument *document = 0); + + // Win32 is a temp work-around until the emf extension is fixed: +#ifndef WIN32 +private: + SPIPaint(SPIPaint const&); + SPIPaint &operator=(SPIPaint const &); +#endif // WIN32 }; /// Filter type internal to SPStyle @@ -183,6 +199,12 @@ enum { SP_FONT_SIZE_PERCENTAGE }; +enum { + SP_BASELINE_SHIFT_LITERAL, + SP_BASELINE_SHIFT_LENGTH, + SP_BASELINE_SHIFT_PERCENTAGE +}; + #define SP_FONT_SIZE ((1 << 24) - 1) #define SP_F8_16_TO_FLOAT(v) ((gdouble) (v) / (1 << 16)) @@ -201,6 +223,17 @@ struct SPIFontSize { float computed; }; +/// Baseline shift type internal to SPStyle. +struct SPIBaselineShift { + unsigned set : 1; + unsigned inherit : 1; + unsigned type : 2; + unsigned unit : 4; + unsigned literal: 2; + float value; // Can be negative + float computed; +}; + /// Text decoration type internal to SPStyle. struct SPITextDecoration { unsigned set : 1; @@ -234,8 +267,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; @@ -276,6 +313,8 @@ struct SPStyle { SPIEnum block_progression; /** Writing mode (css3 text 3.2 and svg1.1 10.7.2) */ SPIEnum writing_mode; + /** Baseline shift (svg1.1 10.9.2) */ + SPIBaselineShift baseline_shift; /* SVG */ /** Anchor of the text (svg1.1 10.9.1) */ @@ -327,6 +366,7 @@ struct SPStyle { unsigned stroke_dasharray_set : 1; unsigned stroke_dasharray_inherit : 1; unsigned stroke_dashoffset_set : 1; + unsigned stroke_dashoffset_inherit : 1; /** stroke-opacity */ SPIScale24 stroke_opacity; @@ -346,21 +386,26 @@ struct SPStyle { * their background image */ SPIEnum enable_background; - /// style belongs to a cloned object, must not href anything - bool cloned; - /// style has hreffed its fill/stroke paintservers, needs to release. - bool fill_hreffed; - bool stroke_hreffed; + /// style belongs to a cloned object + bool cloned; 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; + + SPObject *getFilter() { return (filter.href) ? filter.href->getObject() : 0; } + SPObject const *getFilter() const { return (filter.href) ? filter.href->getObject() : 0; } + gchar const *getFilterURI() const { return (filter.href) ? filter.href->getURI()->toString() : 0; } - sigc::connection stroke_release_connection; - sigc::connection stroke_modified_connection; + SPPaintServer *getFillPaintServer() { return (fill.value.href) ? fill.value.href->getObject() : 0; } + SPPaintServer const *getFillPaintServer() const { return (fill.value.href) ? fill.value.href->getObject() : 0; } + gchar const *getFillURI() const { return (fill.value.href) ? fill.value.href->getURI()->toString() : 0; } - SPObject *getFilter() {if (filter.href) return filter.href->getObject(); else return NULL;} + SPPaintServer *getStrokePaintServer() { return (stroke.value.href) ? stroke.value.href->getObject() : 0; } + SPPaintServer const *getStrokePaintServer() const { return (stroke.value.href) ? stroke.value.href->getObject() : 0; } + gchar const *getStrokeURI() const { return (stroke.value.href) ? stroke.value.href->getURI()->toString() : 0; } }; SPStyle *sp_style_new(SPDocument *document); @@ -373,7 +418,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); @@ -385,6 +430,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 { @@ -481,6 +528,12 @@ enum SPTextAnchor { SP_CSS_TEXT_ANCHOR_END }; +enum SPCSSBaselineShift { + SP_CSS_BASELINE_SHIFT_BASELINE, + SP_CSS_BASELINE_SHIFT_SUB, + SP_CSS_BASELINE_SHIFT_SUPER +}; + enum SPVisibility { SP_CSS_VISIBILITY_HIDDEN, SP_CSS_VISIBILITY_COLLAPSE, @@ -527,6 +580,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; }; @@ -544,7 +600,7 @@ void sp_style_set_property_url (SPObject *item, gchar const *property, SPObject gchar *attribute_unquote(gchar const *val); gchar *css2_escape_quote(gchar const *val); -#endif +#endif // SEEN_SP_STYLE_H /* @@ -556,4 +612,4 @@ gchar *css2_escape_quote(gchar const *val); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :