diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-10-29 19:30:50 +0100 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-10-29 19:30:50 +0100 |
commit | aa1490d3b8731d4797d13033526feb7c1a651f81 (patch) | |
tree | ffd00aca5e8e90134be223c3772a7530c3e7ee4e /src/styleengine.cc | |
parent | 2ca059af0e113cf167a848a9e43fa149c2c9f7bd (diff) |
start implementing StyleEngine::apply
Diffstat (limited to 'src/styleengine.cc')
-rw-r--r-- | src/styleengine.cc | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/styleengine.cc b/src/styleengine.cc index 14a33bd3..670eec29 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -12,6 +12,8 @@ #include <stdio.h> #include "styleengine.hh" +using namespace dw::core::style; + StyleEngine::StyleEngine (dw::core::Layout *layout) { stack = new lout::misc::SimpleVector <Node> (1); cssContext = new CssContext (); @@ -52,36 +54,53 @@ StyleEngine::endElement (int tag) { stack->setSize (stack->size () - 1); } -void StyleEngine::apply (dw::core::style::StyleAttrs *attr, - CssPropertyList *props) { +void StyleEngine::apply (StyleAttrs *attrs, CssPropertyList *props) { + FontAttrs fontAttrs = *attrs->font; for (int i = 0; i < props->size (); i++) { CssProperty *p = props->getRef (i); switch (p->name) { - + /* \todo missing cases */ + case CssProperty::CSS_PROPERTY_BACKGROUND_COLOR: + attrs->backgroundColor = + Color::createSimple (layout, p->value.color); + break; + case CssProperty::CSS_PROPERTY_BORDER_BOTTOM_COLOR: + attrs->borderColor.bottom = + Color::createSimple (layout, p->value.color); + break; + case CssProperty::CSS_PROPERTY_BORDER_BOTTOM_STYLE: + attrs->borderStyle.bottom = p->value.borderStyle; + break; + case CssProperty::CSS_PROPERTY_FONT_FAMILY: + fontAttrs.name = p->value.name; + break; + case CssProperty::CSS_PROPERTY_FONT_SIZE: + fontAttrs.size = p->value.size; + break; default: break; } } + + attrs->font = Font::create (layout, &fontAttrs); } -dw::core::style::Style * StyleEngine::style0 () { +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; + 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); + stack->getRef (stack->size () - 1)->style = Style::create (layout, &attrs); return NULL; } |