aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dw/layout.cc4
-rw-r--r--dw/layout.hh2
-rw-r--r--dw/style.cc31
-rw-r--r--dw/style.hh10
-rw-r--r--dw/textblock.cc14
-rw-r--r--dw/textblock.hh4
-rw-r--r--dw/widget.cc67
-rw-r--r--dw/widget.hh4
8 files changed, 59 insertions, 77 deletions
diff --git a/dw/layout.cc b/dw/layout.cc
index 7fa93046..f0470748 100644
--- a/dw/layout.cc
+++ b/dw/layout.cc
@@ -37,8 +37,8 @@ bool Layout::LayoutImgRenderer::readyToDraw ()
return true;
}
-void Layout::LayoutImgRenderer::getPaddingArea (int *x, int *y, int *width,
- int *height)
+void Layout::LayoutImgRenderer::getBgArea (int *x, int *y, int *width,
+ int *height)
{
// TODO Actually not padding area, but visible area?
getRefArea (x, y, width, height);
diff --git a/dw/layout.hh b/dw/layout.hh
index abc763b1..65fe2312 100644
--- a/dw/layout.hh
+++ b/dw/layout.hh
@@ -26,7 +26,7 @@ private:
LayoutImgRenderer (Layout *layout) { this->layout = layout; }
bool readyToDraw ();
- void getPaddingArea (int *x, int *y, int *width, int *height);
+ void getBgArea (int *x, int *y, int *width, int *height);
void getRefArea (int *xRef, int *yRef, int *widthRef, int *heightRef);
style::StyleImage *getBackgroundImage ();
style::BackgroundRepeat getBackgroundRepeat ();
diff --git a/dw/style.cc b/dw/style.cc
index 721e6c81..cda61845 100644
--- a/dw/style.cc
+++ b/dw/style.cc
@@ -520,7 +520,7 @@ void StyleImage::ExternalImgRenderer::drawRow (int row)
int imgHeight = imgbuf->getRootHeight ();
int x, y, width, height;
- getPaddingArea (&x, &y, &width, &height);
+ getBgArea (&x, &y, &width, &height);
int xRef, yRef, widthRef, heightRef;
getRefArea (&xRef, &yRef, &widthRef, &heightRef);
@@ -557,23 +557,6 @@ void StyleImage::ExternalImgRenderer::drawRow (int row)
// ----------------------------------------------------------------------
-void StyleImage::ExternalWidgetImgRenderer::getPaddingArea (int *x, int *y,
- int *width,
- int *height)
-{
- Style *style = getStyle ();
- assert (style != NULL);
-
- int x0, y0, width0, height0;
- getArea (&x0, &y0, &width0, &height0);
- *x = x0 + style->margin.left + style->borderWidth.left;
- *y = y0 + style->margin.top + style->borderWidth.top;
- *width = width0 - style->margin.left - style->borderWidth.left
- - style->margin.right - style->borderWidth.right;
- *height = height0 - style->margin.top - style->borderWidth.top
- - style->margin.bottom - style->borderWidth.bottom;
-}
-
StyleImage *StyleImage::ExternalWidgetImgRenderer::getBackgroundImage ()
{
Style *style = getStyle ();
@@ -1096,14 +1079,10 @@ void drawBackground (View *view, Layout *layout, Rectangle *area,
if (bgColor || bgImage) {
Rectangle bgArea, intersection;
- bgArea.x = x + style->margin.left + style->borderWidth.left;
- bgArea.y = y + style->margin.top + style->borderWidth.top;
- bgArea.width =
- width - style->margin.left - style->borderWidth.left -
- style->margin.right - style->borderWidth.right;
- bgArea.height =
- height - style->margin.top - style->borderWidth.top -
- style->margin.bottom - style->borderWidth.bottom;
+ bgArea.x = x;
+ bgArea.y = y;
+ bgArea.width = width;
+ bgArea.height = height;
if (area->intersectsWith (&bgArea, &intersection)) {
if (bgColor)
diff --git a/dw/style.hh b/dw/style.hh
index 04380dde..361741be 100644
--- a/dw/style.hh
+++ b/dw/style.hh
@@ -739,9 +739,9 @@ public:
virtual bool readyToDraw () = 0;
/**
- * \brief ...
+ * \brief Return the area covered by the background image.
*/
- virtual void getPaddingArea (int *x, int *y, int *width, int *height) = 0;
+ virtual void getBgArea (int *x, int *y, int *width, int *height) = 0;
/**
* \brief Return the "reference area".
@@ -779,12 +779,6 @@ public:
Length getBackgroundPositionY ();
/**
- * \brief Return the total area this background image is
- * attached to, in canvas coordinates.
- */
- virtual void getArea (int *x, int *y, int *width, int *height) = 0;
-
- /**
* \brief Return the style this background image is part of.
*/
virtual Style *getStyle () = 0;
diff --git a/dw/textblock.cc b/dw/textblock.cc
index fbff3e23..6538ed1e 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -70,9 +70,10 @@ bool Textblock::WordImgRenderer::readyToDraw ()
&& lineNo < textblock->lines->size();
}
-void Textblock::WordImgRenderer::getArea (int *x, int *y, int *width,
- int *height)
+void Textblock::WordImgRenderer::getBgArea (int *x, int *y, int *width,
+ int *height)
{
+ // TODO Subtract margin and border (padding box)?
Line *line = textblock->lines->getRef (lineNo);
*x = textblock->allocation.x + this->xWordWidget;
*y = textblock->lineYOffsetCanvas (line);
@@ -83,7 +84,8 @@ void Textblock::WordImgRenderer::getArea (int *x, int *y, int *width,
void Textblock::WordImgRenderer::getRefArea (int *xRef, int *yRef,
int *widthRef, int *heightRef)
{
- textblock->getBgRefArea (xRef, yRef, widthRef, heightRef);
+ // See comment in Widget::drawBox about the reference area.q
+ textblock->getPaddingArea (xRef, yRef, widthRef, heightRef);
}
core::style::Style *Textblock::WordImgRenderer::getStyle ()
@@ -98,10 +100,10 @@ void Textblock::WordImgRenderer::draw (int x, int y, int width, int height)
}
-void Textblock::SpaceImgRenderer::getArea (int *x, int *y, int *width,
- int *height)
+void Textblock::SpaceImgRenderer::getBgArea (int *x, int *y, int *width,
+ int *height)
{
- WordImgRenderer::getArea (x, y, width, height);
+ WordImgRenderer::getBgArea (x, y, width, height);
*x += *width;
*width = textblock->words->getRef(wordNo)->effSpace;
}
diff --git a/dw/textblock.hh b/dw/textblock.hh
index e61d2961..2bd85917 100644
--- a/dw/textblock.hh
+++ b/dw/textblock.hh
@@ -258,7 +258,7 @@ protected:
void setData (int xWordWidget, int lineNo);
bool readyToDraw ();
- void getArea (int *x, int *y, int *width, int *height);
+ void getBgArea (int *x, int *y, int *width, int *height);
void getRefArea (int *xRef, int *yRef, int *widthRef, int *heightRef);
core::style::Style *getStyle ();
void draw (int x, int y, int width, int height);
@@ -270,7 +270,7 @@ protected:
inline SpaceImgRenderer (Textblock *textblock, int wordNo) :
WordImgRenderer (textblock, wordNo) { }
- void getArea (int *x, int *y, int *width, int *height);
+ void getBgArea (int *x, int *y, int *width, int *height);
core::style::Style *getStyle ();
};
diff --git a/dw/widget.cc b/dw/widget.cc
index 719f1263..415da6bc 100644
--- a/dw/widget.cc
+++ b/dw/widget.cc
@@ -37,19 +37,16 @@ bool Widget::WidgetImgRenderer::readyToDraw ()
return widget->wasAllocated ();
}
-void Widget::WidgetImgRenderer::getArea (int *x, int *y, int *width,
- int *height)
+void Widget::WidgetImgRenderer::getBgArea (int *x, int *y, int *width,
+ int *height)
{
- *x = widget->allocation.x;
- *y = widget->allocation.y;
- *width = widget->allocation.width;
- *height = widget->getHeight ();
+ widget->getPaddingArea (x, y, width, height);
}
void Widget::WidgetImgRenderer::getRefArea (int *xRef, int *yRef, int *widthRef,
int *heightRef)
{
- widget->getBgRefArea (xRef, yRef, widthRef, heightRef);
+ widget->getPaddingArea (xRef, yRef, widthRef, heightRef);
}
style::Style *Widget::WidgetImgRenderer::getStyle ()
@@ -404,12 +401,21 @@ void Widget::drawBox (View *view, style::Style *style, Rectangle *area,
allocation.x + x, allocation.y + y,
width, height, style, inverse);
- int xRef, yRef, widthRef, heightRef;
- getBgRefArea (&xRef, &yRef, &widthRef, &heightRef);
- style::drawBackground (view, layout, &canvasArea,
- allocation.x + x, allocation.y + y, width, height,
- xRef, yRef, widthRef, heightRef, style, inverse,
- false);
+ // This method is used for inline elements, where the CSS 2 specification
+ // does not define what here is called "reference area". To make it look
+ // smoothly, the widget padding box is used.
+
+ int xPad, yPad, widthPad, heightPad;
+ getPaddingArea (&xPad, &yPad, &widthPad, &heightPad);
+ style::drawBackground
+ (view, layout, &canvasArea,
+ allocation.x + x + style->margin.left + style->borderWidth.left,
+ allocation.y + y + style->margin.top + style->borderWidth.top,
+ width - style->margin.left - style->borderWidth.left
+ - style->margin.right - style->borderWidth.right,
+ height - style->margin.top - style->borderWidth.top
+ - style->margin.bottom - style->borderWidth.bottom,
+ xPad, yPad, widthPad, heightPad, style, inverse, false);
}
/**
@@ -429,11 +435,12 @@ void Widget::drawWidgetBox (View *view, Rectangle *area, bool inverse)
style::drawBorder (view, layout, &canvasArea, allocation.x, allocation.y,
allocation.width, getHeight (), style, inverse);
- int xRef, yRef, widthRef, heightRef;
- getBgRefArea (&xRef, &yRef, &widthRef, &heightRef);
- style::drawBackground (view, layout, &canvasArea, allocation.x, allocation.y,
- allocation.width, getHeight (), xRef, yRef, widthRef,
- heightRef, style, inverse, parent == NULL);
+ int xPad, yPad, widthPad, heightPad;
+ getPaddingArea (&xPad, &yPad, &widthPad, &heightPad);
+ style::drawBackground (view, layout, &canvasArea,
+ xPad, yPad, widthPad, heightPad,
+ xPad, yPad, widthPad, heightPad,
+ style, inverse, parent == NULL);
}
/*
@@ -578,20 +585,20 @@ void Widget::scrollTo (HPosition hpos, VPosition vpos,
}
/**
- * \brief Return the "reference area" for backgrounds.
+ * \brief Return the padding area (content plus padding).
*
- * See comment of "style::drawBackground".
+ * Used as "reference area" (ee comment of "style::drawBackground")
+ * for backgrounds.
*/
-void Widget::getBgRefArea (int *xRef, int *yRef, int *widthRef, int *heightRef)
-{
- /**
- * \todo Reference should be the containing block (which will be
- * introduced later), not the widget allocation.
- */
- *xRef = allocation.x;
- *yRef = allocation.y;
- *widthRef = allocation.width;
- *heightRef = getHeight ();
+void Widget::getPaddingArea (int *xPad, int *yPad, int *widthPad,
+ int *heightPad)
+{
+ *xPad = allocation.x + style->margin.left + style->borderWidth.left;
+ *yPad = allocation.y + style->margin.top + style->borderWidth.top;
+ *widthPad = allocation.width - style->margin.left - style->borderWidth.left
+ - style->margin.right - style->borderWidth.right;
+ *heightPad = getHeight () - style->margin.top - style->borderWidth.top
+ - style->margin.bottom - style->borderWidth.bottom;
}
void Widget::getExtremesImpl (Extremes *extremes)
diff --git a/dw/widget.hh b/dw/widget.hh
index ad36df92..34b35efa 100644
--- a/dw/widget.hh
+++ b/dw/widget.hh
@@ -88,7 +88,7 @@ protected:
inline WidgetImgRenderer (Widget *widget) { this->widget = widget; }
bool readyToDraw ();
- void getArea (int *x, int *y, int *width, int *height);
+ void getBgArea (int *x, int *y, int *width, int *height);
void getRefArea (int *xRef, int *yRef, int *widthRef, int *heightRef);
style::Style *getStyle ();
void draw (int x, int y, int width, int height);
@@ -311,7 +311,7 @@ public:
void scrollTo (HPosition hpos, VPosition vpos,
int x, int y, int width, int height);
- void getBgRefArea (int *xRef, int *yRef, int *widthRef, int *heightRef);
+ void getPaddingArea (int *xPad, int *yPad, int *widthPad, int *heightPad);
/**
* \brief Return an iterator for this widget.