aboutsummaryrefslogtreecommitdiff
path: root/dw
diff options
context:
space:
mode:
Diffstat (limited to 'dw')
-rw-r--r--dw/layout.cc15
-rw-r--r--dw/layout.hh5
-rw-r--r--dw/widget.cc10
3 files changed, 12 insertions, 18 deletions
diff --git a/dw/layout.cc b/dw/layout.cc
index b30831c7..aa9f05ed 100644
--- a/dw/layout.cc
+++ b/dw/layout.cc
@@ -246,7 +246,6 @@ void Layout::addWidget (Widget *widget)
canvasHeightGreater = false;
setSizeHints ();
- updateBgColor ();
queueResize ();
}
@@ -609,17 +608,11 @@ void Layout::updateCursor ()
setCursor (style::CURSOR_DEFAULT);
}
-void Layout::updateBgColor ()
+void Layout::setBgColor (style::Color *color)
{
- /* The toplevel widget should always have a defined background color,
- * except at the beginning. Searching a defined background is not
- * necessary. */
- if (topLevel && topLevel->getStyle() &&
- topLevel->getStyle()->backgroundColor)
- bgColor = topLevel->getStyle()->backgroundColor;
- else
- bgColor = NULL;
- view->setBgColor (bgColor);
+ bgColor = color;
+ if (view)
+ view->setBgColor (bgColor);
}
void Layout::resizeIdle ()
diff --git a/dw/layout.hh b/dw/layout.hh
index 304cf166..dc9bf227 100644
--- a/dw/layout.hh
+++ b/dw/layout.hh
@@ -202,7 +202,6 @@ private:
void removeAnchor (Widget *widget, char* name);
void setCursor (style::Cursor cursor);
void updateCursor ();
- void updateBgColor ();
void queueDraw (int x, int y, int width, int height);
void queueDrawExcept (int x, int y, int width, int height,
int ex, int ey, int ewidth, int eheight);
@@ -362,6 +361,10 @@ public:
/** \brief See dw::core::FindtextState::resetSearch. */
inline void resetSearch () { findtextState.resetSearch (); }
+
+ void setBgColor (style::Color *color);
+
+ inline style::Color* getBgColor () { return bgColor; }
};
} // namespace dw
diff --git a/dw/widget.cc b/dw/widget.cc
index fb0d29e0..ee8cb17c 100644
--- a/dw/widget.cc
+++ b/dw/widget.cc
@@ -302,8 +302,6 @@ void Widget::setStyle (style::Style *style)
this->style = style;
if (layout != NULL) {
- if (parent == NULL)
- layout->updateBgColor ();
layout->updateCursor ();
}
@@ -339,9 +337,7 @@ style::Color *Widget::getBgColor ()
widget = widget->parent;
}
- MSG_WARN("No background color found!\n");
- return NULL;
-
+ return layout->getBgColor ();
}
@@ -399,7 +395,9 @@ void Widget::drawWidgetBox (View *view, Rectangle *area, bool inverse)
* widget->style->background_color is NULL (shining through).
*/
/** \todo Background images? */
- if (parent && style->backgroundColor)
+
+ if (style->backgroundColor &&
+ (parent || layout->getBgColor () != style->backgroundColor))
style::drawBackground (view, &viewArea, allocation.x, allocation.y,
allocation.width, getHeight (), style, inverse);
}