svg-tree-0.1: SVG file loader and serializer

Safe HaskellNone

Graphics.Svg.CssTypes

Description

Define the types used to describes CSS elements

Synopsis

Documentation

data CssSelector Source

Define complex selector.

Constructors

Nearby

Correspond to the + CSS selector.

DirectChildren

Correspond to the > CSS selectro.

AllOf [CssDescriptor]

Grouping construct, all the elements of the list must be matched.

Instances

type CssSelectorRule = [CssSelector]Source

A CssSelectorRule is a list of all the elements that must be meet in a depth first search fashion.

data CssRule Source

Represent a CSS selector and the different declarations to apply to the matched elemens.

Constructors

CssRule 

Fields

cssRuleSelector :: ![CssSelectorRule]

At the first level represent a list of elements to be matched. If any match is made, you can apply the declarations. At the second level

cssDeclarations :: ![CssDeclaration]

Declarations to apply to the matched element.

Instances

Eq CssRule 
Show CssRule 

data CssDescriptor Source

Describe an element of a CSS selector. Multiple elements can be combined in a CssSelector type.

Constructors

OfClass Text

.IDENT

OfName Text

IDENT

OfId Text

#IDENT

OfPseudoClass Text

`:IDENT` (ignore function syntax)

AnyElem

*

WithAttrib Text Text

``

Instances

data CssDeclaration Source

Represent the content to apply to some CSS matched rules.

Constructors

CssDeclaration 

Fields

_cssDeclarationProperty :: Text

Property name to change (like font-family or color).

_cssDecarationlValues :: [[CssElement]]

List of values

Instances

class CssMatcheable a whereSource

Interface for elements to be matched against some CssRule.

Methods

cssIdOf :: a -> Maybe TextSource

For an element, tell its optional ID attribute.

cssClassOf :: a -> [Text]Source

For an element, return all of it's class attributes.

cssNameOf :: a -> TextSource

Return the name of the tagname of the element

cssAttribOf :: a -> Text -> Maybe TextSource

Return a value of a given attribute if present

Instances

type CssContext a = [[a]]Source

Represent a zipper in depth at the first list level, and the previous nodes at in the second list level.

type Dpi = IntSource

Alias describing a dot per inch information used for size calculation (see toUserUnit).

data Number Source

Encode complex number possibly dependant to the current render size.

Constructors

Num Float

Simple coordinate in current user coordinate.

Px Float

With suffix px

Em Float

Number relative to the current font size.

Percent Float

Number relative to the current viewport size.

Pc Float 
Mm Float

Number in millimeters, relative to DPI.

Cm Float

Number in centimeters, relative to DPI.

Point Float

Number in points, relative to DPI.

Inches Float

Number in inches, relative to DPI.

Instances

Eq Number 
Show Number 

serializeNumber :: Number -> StringSource

Encode the number to string which can be used in a CSS or a svg attributes.

findMatchingDeclarations :: CssMatcheable a => [CssRule] -> CssContext a -> [CssDeclaration]Source

Given CSS rules, find all the declaration to apply to the element in a given context.

toUserUnit :: Dpi -> Number -> NumberSource

This function replace all device dependant units to user units given it's DPI configuration. Preserve percentage and em notation.

mapNumber :: (Float -> Float) -> Number -> NumberSource

Helper function to modify inner value of a number

tserialize :: TextBuildable a => a -> BuilderSource

Serialize an element to a text builder.