diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-10-29 19:03:43 +0100 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-10-29 19:03:43 +0100 |
commit | 2ca059af0e113cf167a848a9e43fa149c2c9f7bd (patch) | |
tree | f9fbb120defa9293c6494f2a95ad427a81e06a8d /src/styleengine.cc | |
parent | faa12b128ac5e22aed81a1ca692ddc504b31bd10 (diff) |
pass Layout to StyleEngine
Diffstat (limited to 'src/styleengine.cc')
-rw-r--r-- | src/styleengine.cc | 60 |
1 files changed, 58 insertions, 2 deletions
diff --git a/src/styleengine.cc b/src/styleengine.cc index 4147fb17..14a33bd3 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -12,8 +12,10 @@ #include <stdio.h> #include "styleengine.hh" -StyleEngine::StyleEngine () { +StyleEngine::StyleEngine (dw::core::Layout *layout) { stack = new lout::misc::SimpleVector <Node> (1); + cssContext = new CssContext (); + this->layout = layout; } StyleEngine::~StyleEngine () { @@ -21,11 +23,65 @@ StyleEngine::~StyleEngine () { } void -StyleEngine::startElement (int tag, const char *id, const char *klass, const char *style) { +StyleEngine::startElement (int tag, const char *id, const char *klass, + const char *style) { fprintf(stderr, "===> START %d %s %s %s\n", tag, id, klass, style); + + if (stack->getRef (stack->size () - 1)->style == NULL) + stack->getRef (stack->size () - 1)->style = style0 (); + + stack->increase (); + Node *n = stack->getRef (stack->size () - 1); + n->style = NULL; + n->nonCssProperties = NULL; + n->depth = stack->size (); + n->tag = tag; + n->id = id; + n->klass = klass; + n->styleAttribute = style; +} + +void +StyleEngine::setNonCssProperties (CssPropertyList *props) { + stack->getRef (stack->size () - 1)->nonCssProperties = props; } void StyleEngine::endElement (int tag) { fprintf(stderr, "===> END %d\n", tag); + stack->setSize (stack->size () - 1); +} + +void StyleEngine::apply (dw::core::style::StyleAttrs *attr, + CssPropertyList *props) { + + for (int i = 0; i < props->size (); i++) { + CssProperty *p = props->getRef (i); + + switch (p->name) { + + + default: + break; + } + } +} + +dw::core::style::Style * StyleEngine::style0 () { + CssPropertyList props; + CssPropertyList *tagStyleProps = CssPropertyList::parse ( + stack->getRef (stack->size () - 1)->styleAttribute); + + dw::core::style::StyleAttrs attrs = + *stack->getRef (stack->size () - 1)->style; + + cssContext->apply (&props, this, tagStyleProps, + stack->getRef (stack->size () - 1)->nonCssProperties); + + apply (&attrs, &props); + + stack->getRef (stack->size () - 1)->style = + dw::core::style::Style::create (layout, &attrs); + + return NULL; } |