changeset 615:d0694361ecd0

add workaround for table row coloring
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Fri, 28 Nov 2008 16:55:31 +0100
parents bbf774ce88d4
children f6ee95a3f49a
files src/styleengine.cc src/styleengine.hh src/table.cc
diffstat 3 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/styleengine.cc	Tue Nov 25 20:55:13 2008 +0100
+++ b/src/styleengine.cc	Fri Nov 28 16:55:31 2008 +0100
@@ -64,6 +64,7 @@
    n->klass = NULL;
    n->pseudo = NULL;
    n->styleAttribute = NULL;
+   n->inheritBackgroundColor = false;
 }
 
 void StyleEngine::setId (const char *id) {
@@ -95,6 +96,16 @@
 }
 
 /**
+ * \brief Use of the background color of the parent style as default.
+ *   This is only used in table code to allow for colors specified for
+ *   table rows as table rows are currently no widgets and therefore
+ *   don't draw any background.
+ */
+void StyleEngine::inheritBackgroundColor () {
+   stack->getRef (stack->size () - 1)->inheritBackgroundColor = true;
+}
+
+/**
  * \brief set the CSS pseudo class (e.g. "link", "visited").
  */
 void StyleEngine::setPseudo (const char *pseudo) {
@@ -337,6 +348,10 @@
    StyleAttrs attrs = *stack->getRef (stack->size () - 2)->style;
    // reset values that are not inherited according to CSS
    attrs.resetValues ();
+  
+   if (stack->getRef (stack->size () - 2)->inheritBackgroundColor)
+      attrs.backgroundColor =
+         stack->getRef (stack->size () - 2)->style->backgroundColor; 
 
    cssContext->apply (&props, this, tagStyleProps, nonCssProperties);
 
--- a/src/styleengine.hh	Tue Nov 25 20:55:13 2008 +0100
+++ b/src/styleengine.hh	Fri Nov 28 16:55:31 2008 +0100
@@ -11,6 +11,7 @@
          public:
             dw::core::style::Style *style;
             const char *styleAttribute;
+            bool inheritBackgroundColor;
       };
 
       dw::core::Layout *layout;
@@ -44,6 +45,7 @@
       void endElement (int tag);
       void setPseudo (const char *pseudo);
       void setNonCssHints (CssPropertyList *nonCssHints);
+      void inheritBackgroundColor ();
 
       inline dw::core::style::Style *style () {
          dw::core::style::Style *s = stack->getRef (stack->size () - 1)->style;
--- a/src/table.cc	Tue Nov 25 20:55:13 2008 +0100
+++ b/src/table.cc	Fri Nov 28 16:55:31 2008 +0100
@@ -191,6 +191,7 @@
          }
       }
 
+      html->styleEngine->inheritBackgroundColor ();
       html->styleEngine->setNonCssHints (&props);
 
       ((dw::Table*)S_TOP(html)->table)->addRow (html->styleEngine->style ());