style.h revision 74ba6bbc2af90e342434b2a1b7a65bfe70f9d33f
#ifndef __SP_STYLE_H__
#define __SP_STYLE_H__
/** \file
* SPStyle - a style object for SPItem objects
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
*
* Copyright (C) 2001-2002 Lauris Kaplinski
* Copyright (C) 2001 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "color.h"
#include "forward.h"
#include "sp-marker-loc.h"
}
}
}
/// Float type internal to SPStyle.
struct SPIFloat {
unsigned set : 1;
unsigned inherit : 1;
unsigned data : 30;
float value;
};
/*
* One might think that the best value for SP_SCALE24_MAX would be ((1<<24)-1), which allows the
* greatest possible precision for fitting [0, 1] fractions into 24 bits.
*
* However, in practice, that gives a problem with 0.5, which falls half way between two fractions
* of ((1<<24)-1). What's worse is that casting double(1<<23) / ((1<<24)-1) to float on x86
* produces wrong rounding behaviour, resulting in a fraction of ((1<<23)+2.0f) / (1<<24) rather
* than ((1<<23)+1.0f) / (1<<24) as one would expect, let alone ((1<<23)+0.0f) / (1<<24) as one
* would ideally like for this example.
*
* The value (1<<23) is thus best if one considers float conversions alone.
*
* The value 0xff0000 can exactly represent all 8-bit alpha channel values,
* and can exactly represent all multiples of 0.1. I haven't yet tested whether
* rounding bugs still get in the way of conversions to & from float, but my instinct is that
* it's fairly safe because 0xff fits three times inside float's significand.
*
* though that might need to be accompanied by greater use of double instead of float for
* colours and opacities, to be safe from rounding bugs.
*/
#define SP_SCALE24_MAX (0xff0000)
#define SP_SCALE24_TO_FLOAT(v) ((double) (v) / SP_SCALE24_MAX)
/** Returns a scale24 for the product of two scale24 values. */
/// 24 bit data type internal to SPStyle.
struct SPIScale24 {
unsigned set : 1;
unsigned inherit : 1;
unsigned value : 24;
};
/// Int type internal to SPStyle.
struct SPIInt {
unsigned set : 1;
unsigned inherit : 1;
unsigned data : 30;
int value;
};
/// Short type internal to SPStyle.
struct SPIShort {
unsigned set : 1;
unsigned inherit : 1;
unsigned data : 14;
int value : 16;
};
/// Enum type internal to SPStyle.
struct SPIEnum {
unsigned set : 1;
unsigned inherit : 1;
unsigned value : 8;
unsigned computed : 8;
};
/// String type internal to SPStyle.
struct SPIString {
unsigned set : 1;
unsigned inherit : 1;
unsigned data : 30;
};
enum {
};
/// Length type internal to SPStyle.
struct SPILength {
unsigned set : 1;
unsigned inherit : 1;
unsigned unit : 4;
float value;
float computed;
};
enum {
};
/// Paint type internal to SPStyle.
struct SPIPaint {
unsigned set : 1;
unsigned inherit : 1;
unsigned currentcolor : 1;
unsigned type : 2;
union {
struct {
} paint;
} value;
};
enum {
};
#define SP_STYLE_FLAG_IFSET (1 << 0)
/// Fontsize type internal to SPStyle.
struct SPIFontSize {
unsigned set : 1;
unsigned inherit : 1;
unsigned type : 2;
unsigned value : 24;
float computed;
};
/// Text decoration type internal to SPStyle.
struct SPITextDecoration {
unsigned set : 1;
unsigned inherit : 1;
unsigned underline : 1;
unsigned overline : 1;
unsigned line_through : 1;
};
/// Extended length type internal to SPStyle.
struct SPILengthOrNormal {
unsigned set : 1;
unsigned inherit : 1;
unsigned normal : 1;
unsigned unit : 4;
float value;
float computed;
};
/// Stroke dash details.
double offset;
int n_dash;
double *dash;
};
/// An SVG style object.
struct SPStyle {
int refcount;
/** Object we are attached to */
/** Our text style component */
unsigned text_private : 1;
/* CSS2 */
/* Font */
/** Size of the font */
/** Style of the font */
/** Which substyle of the font */
/** Weight of the font */
/** Stretch of the font */
/** First line indent of paragraphs (css2 16.1) */
/** text alignment (css2 16.2) (not to be confused with text-anchor) */
/** text decoration (css2 16.3.1) */
// 16.3.2 is text-shadow. That's complicated.
/** Line spacing (css2 10.8.1) */
/** letter spacing (css2 16.4) */
/** word spacing (also css2 16.4) */
/** capitalization (css2 16.5) */
/* CSS3 Text */
/** text direction (css3 text 3.2) */
/** block progression (css3 text 3.2) */
/** Writing mode (css3 text 3.2 and svg1.1 10.7.2) */
/* SVG */
/** Anchor of the text (svg1.1 10.9.1) */
/* Misc attributes */
unsigned clip_set : 1;
unsigned color_set : 1;
unsigned cursor_set : 1;
unsigned overflow_set : 1;
unsigned clip_path_set : 1;
unsigned clip_rule_set : 1;
unsigned mask_set : 1;
/** display */
/** overflow */
/** visibility */
/** opacity */
/** color */
/** fill */
/** fill-opacity */
/** fill-rule: 0 nonzero, 1 evenodd */
/** stroke */
/** stroke-width */
/** stroke-linecap */
/** stroke-linejoin */
/** stroke-miterlimit */
/** stroke-dash* */
unsigned stroke_dasharray_set : 1;
unsigned stroke_dasharray_inherit : 1;
unsigned stroke_dashoffset_set : 1;
/** stroke-opacity */
/** Marker list */
/// style belongs to a cloned object, must not href anything
bool cloned;
bool color_hreffed;
bool fill_hreffed;
bool stroke_hreffed;
bool color_listening;
bool fill_listening;
bool stroke_listening;
};
SPStyle *sp_style_new();
/* SPTextStyle */
enum SPCSSFontSize {
};
enum SPCSSFontStyle {
};
enum SPCSSFontVariant {
};
enum SPCSSFontWeight {
};
enum SPCSSFontStretch {
};
enum SPCSSTextAlign {
// also <string> is allowed, but only within table calls
};
enum SPCSSTextTransform {
};
enum SPCSSDirection {
};
enum SPCSSBlockProgression {
};
enum SPCSSWritingMode {
};
enum SPTextAnchor {
};
enum SPVisibility {
};
enum SPOverflow {
};
/// \todo more display types
enum SPCSSDisplay {
};
/// An SPTextStyle has a refcount, a font family, and a font name.
struct SPTextStyle {
int refcount;
/* CSS font properties */
/** \todo fixme: The 'font' property is ugly, and not working (lauris) */
};
void sp_style_unset_property_attrs(SPObject *o);
#endif
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :