summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dw/oofposabsmgr.cc25
-rw-r--r--dw/oofposabsmgr.hh6
-rw-r--r--dw/oofposfixedmgr.cc21
-rw-r--r--dw/oofposfixedmgr.hh6
-rw-r--r--dw/oofpositionedmgr.cc66
-rw-r--r--dw/oofpositionedmgr.hh11
6 files changed, 110 insertions, 25 deletions
diff --git a/dw/oofposabsmgr.cc b/dw/oofposabsmgr.cc
index 013f00c0..3ddc1ed2 100644
--- a/dw/oofposabsmgr.cc
+++ b/dw/oofposabsmgr.cc
@@ -18,6 +18,7 @@
*/
#include "oofposabsmgr.hh"
+#include "textblock.hh"
namespace dw {
@@ -32,4 +33,28 @@ OOFPosAbsMgr::~OOFPosAbsMgr ()
DBG_OBJ_DELETE ();
}
+int OOFPosAbsMgr::cbBoxOffsetX ()
+{
+ return containingBlock->boxOffsetX ()
+ - containingBlock->getStyle()->padding.left;
+}
+
+int OOFPosAbsMgr::cbBoxOffsetY ()
+{
+ return containingBlock->boxOffsetY ()
+ - containingBlock->getStyle()->padding.top;
+}
+
+int OOFPosAbsMgr::cbBoxRestWidth ()
+{
+ return containingBlock->boxRestWidth ()
+ - containingBlock->getStyle()->padding.right;
+}
+
+int OOFPosAbsMgr::cbBoxRestHeight ()
+{
+ return containingBlock->boxRestHeight ()
+ - containingBlock->getStyle()->padding.bottom;
+}
+
} // namespace dw
diff --git a/dw/oofposabsmgr.hh b/dw/oofposabsmgr.hh
index 1873c184..839c0a1c 100644
--- a/dw/oofposabsmgr.hh
+++ b/dw/oofposabsmgr.hh
@@ -7,6 +7,12 @@ namespace dw {
class OOFPosAbsMgr: public OOFPositionedMgr
{
+protected:
+ int cbBoxOffsetX ();
+ int cbBoxOffsetY ();
+ int cbBoxRestWidth ();
+ int cbBoxRestHeight ();
+
public:
OOFPosAbsMgr (Textblock *containingBlock);
~OOFPosAbsMgr ();
diff --git a/dw/oofposfixedmgr.cc b/dw/oofposfixedmgr.cc
index d70db050..defb8182 100644
--- a/dw/oofposfixedmgr.cc
+++ b/dw/oofposfixedmgr.cc
@@ -32,4 +32,25 @@ OOFPosFixedMgr::~OOFPosFixedMgr ()
DBG_OBJ_DELETE ();
}
+
+int OOFPosFixedMgr::cbBoxOffsetX ()
+{
+ return 0;
+}
+
+int OOFPosFixedMgr::cbBoxOffsetY ()
+{
+ return 0;
+}
+
+int OOFPosFixedMgr::cbBoxRestWidth ()
+{
+ return 0;
+}
+
+int OOFPosFixedMgr::cbBoxRestHeight ()
+{
+ return 0;
+}
+
} // namespace dw
diff --git a/dw/oofposfixedmgr.hh b/dw/oofposfixedmgr.hh
index 6a88289f..f3fc6011 100644
--- a/dw/oofposfixedmgr.hh
+++ b/dw/oofposfixedmgr.hh
@@ -7,6 +7,12 @@ namespace dw {
class OOFPosFixedMgr: public OOFPositionedMgr
{
+protected:
+ int cbBoxOffsetX ();
+ int cbBoxOffsetY ();
+ int cbBoxRestWidth ();
+ int cbBoxRestHeight ();
+
public:
OOFPosFixedMgr (Textblock *containingBlock);
~OOFPosFixedMgr ();
diff --git a/dw/oofpositionedmgr.cc b/dw/oofpositionedmgr.cc
index 57235dd2..ce85446f 100644
--- a/dw/oofpositionedmgr.cc
+++ b/dw/oofpositionedmgr.cc
@@ -72,8 +72,8 @@ void OOFPositionedMgr::sizeAllocateChildren ()
{
DBG_OBJ_ENTER0 ("resize.oofm", 0, "sizeAllocateChildren");
- int refWidth = containingBlock->getAvailWidth (true);
- int refHeight = containingBlock->getAvailHeight (true);
+ int refWidth = containingBlock->getAvailWidth (true) - cbBoxDiffWidth ();
+ int refHeight = containingBlock->getAvailHeight (true) - cbBoxDiffHeight ();
for (int i = 0; i < children->size(); i++) {
Widget *child = children->get (i);
@@ -83,8 +83,8 @@ void OOFPositionedMgr::sizeAllocateChildren ()
&ascent, &descent);
Allocation childAllocation;
- childAllocation.x = containingBlockAllocation.x + x;
- childAllocation.y = containingBlockAllocation.y + y;
+ childAllocation.x = containingBlockAllocation.x + x + cbBoxOffsetX ();
+ childAllocation.y = containingBlockAllocation.y + y + cbBoxOffsetY ();
childAllocation.width = width;
childAllocation.ascent = ascent;
childAllocation.descent = descent;
@@ -107,6 +107,8 @@ void OOFPositionedMgr::containerSizeChangedForChildren ()
bool OOFPositionedMgr::doChildrenExceedCB ()
{
+ // TODO Something similar like this for positioned elements.
+
#if 0
DBG_OBJ_ENTER ("resize.oofm", 0, "doFloatsExceedCB", "%s",
side == LEFT ? "LEFT" : "RIGHT");
@@ -239,8 +241,8 @@ void OOFPositionedMgr::getSize (Requisition *cbReq, int *oofWidth,
int x, y, width, ascent, descent;
calcPosAndSizeChildOfChild (child, refWidth, refHeight, &x, &y, &width,
&ascent, &descent);
- *oofWidth = max (*oofWidth, x + width);
- *oofHeight = max (*oofHeight, y + ascent + descent);
+ *oofWidth = max (*oofWidth, x + width) + cbBoxDiffWidth ();
+ *oofHeight = max (*oofHeight, y + ascent + descent) + cbBoxDiffHeight ();
}
DBG_OBJ_LEAVE ();
@@ -332,17 +334,22 @@ int OOFPositionedMgr::getAvailWidthOfChild (Widget *child, bool forceValue)
DBG_OBJ_MSG ("resize.oofm", 1, "no specification");
if (forceValue) {
int availWidth = containingBlock->getAvailWidth (true);
- width = max (availWidth - containingBlock->boxDiffWidth ()
+ width = max (availWidth - cbBoxDiffWidth ()
// Regard an undefined value as 0:
- max (getPosLeft (child, availWidth), 0),
- max (getPosRight (child, availWidth), 0),
0);
} else
width = -1;
- } else
- // TODO Percentage widths must refer to padding area.
- child->calcFinalWidth (child->getStyle(), -1, containingBlock, 0,
- forceValue, &width);
+ } else {
+ if (forceValue) {
+ int availWidth = containingBlock->getAvailWidth (true);
+ child->calcFinalWidth (child->getStyle(),
+ availWidth - cbBoxDiffWidth (), NULL, 0, true,
+ &width);
+ } else
+ width = -1;
+ }
if (width != -1)
width = max (width, child->getMinWidth (NULL, forceValue));
@@ -369,17 +376,22 @@ int OOFPositionedMgr::getAvailHeightOfChild (Widget *child, bool forceValue)
DBG_OBJ_MSG ("resize.oofm", 1, "no specification");
if (forceValue) {
int availHeight = containingBlock->getAvailHeight (true);
- height = max (availHeight - containingBlock->boxDiffHeight ()
+ height = max (availHeight - cbBoxDiffHeight ()
// Regard an undefined value as 0:
- max (getPosTop (child, availHeight), 0),
- max (getPosBottom (child, availHeight), 0),
0);
} else
height = -1;
- } else
- // TODO Percentage heights must refer to padding area.
- height = child->calcHeight (child->getStyle()->height, true, -1,
- containingBlock, forceValue);
+ } else {
+ if (forceValue) {
+ int availHeight = containingBlock->getAvailHeight (true);
+ height = child->calcHeight (child->getStyle()->height, true,
+ availHeight - - cbBoxDiffHeight (), NULL,
+ true);
+ } else
+ height = -1;
+ }
DBG_OBJ_MSGF ("resize.oofm", 1, "=> %d", height);
DBG_OBJ_LEAVE ();
@@ -403,13 +415,15 @@ void OOFPositionedMgr::calcPosAndSizeChildOfChild (Widget *child, int refWidth,
int *y, int *width,
int *ascent, int *descent)
{
+ // *x and *y refer to reference area; caller must adjust them.
+
DBG_OBJ_ENTER ("resize.oofm", 0, "calcPosAndSizeChildOfChild",
"%p, %d, %d, ...", child, refWidth, refHeight);
- // TODO (i) Consider {min|max}-{width|heigt}. (ii) Clarify where
- // sizes refer to. (iii) Height is always apportioned to descent
- // (ascent is preserved), which makes sense when the children are
- // textblocks. (iv) Consider minimal width (getMinWidth)?
+ // TODO (i) Consider {min|max}-{width|heigt}. (ii) Height is always
+ // apportioned to descent (ascent is preserved), which makes sense
+ // when the children are textblocks. (iii) Consider minimal width
+ // (getMinWidth)?
Requisition childRequisition;
child->sizeRequest (&childRequisition);
@@ -418,14 +432,16 @@ void OOFPositionedMgr::calcPosAndSizeChildOfChild (Widget *child, int refWidth,
if (style::isAbsLength (child->getStyle()->width)) {
DBG_OBJ_MSGF ("resize.oofm", 1, "absolute width: %dpx",
style::absLengthVal (child->getStyle()->width));
- *width = style::absLengthVal (child->getStyle()->width);
+ *width = style::absLengthVal (child->getStyle()->width)
+ + child->boxDiffWidth ();
widthDefined = true;
} else if (style::isPerLength (child->getStyle()->width)) {
DBG_OBJ_MSGF ("resize.oofm", 1, "percentage width: %g%%",
100 * style::perLengthVal_useThisOnlyForDebugging
(child->getStyle()->width));
*width = style::multiplyWithPerLength (refWidth,
- child->getStyle()->width);
+ child->getStyle()->width)
+ + child->boxDiffWidth ();
widthDefined = true;
} else {
DBG_OBJ_MSG ("resize.oofm", 1, "width not specified");
@@ -457,7 +473,8 @@ void OOFPositionedMgr::calcPosAndSizeChildOfChild (Widget *child, int refWidth,
if (style::isAbsLength (child->getStyle()->height)) {
DBG_OBJ_MSGF ("resize.oofm", 1, "absolute height: %dpx",
style::absLengthVal (child->getStyle()->height));
- int height = style::absLengthVal (child->getStyle()->height);
+ int height = style::absLengthVal (child->getStyle()->height)
+ + child->boxDiffHeight ();
splitHeightPreserveAscent (height, ascent, descent);
heightDefined = true;
} else if (style::isPerLength (child->getStyle()->height)) {
@@ -465,7 +482,8 @@ void OOFPositionedMgr::calcPosAndSizeChildOfChild (Widget *child, int refWidth,
100 * style::perLengthVal_useThisOnlyForDebugging
(child->getStyle()->height));
int height = style::multiplyWithPerLength (refHeight,
- child->getStyle()->height);
+ child->getStyle()->height)
+ + child->boxDiffHeight ();
splitHeightPreserveAscent (height, ascent, descent);
heightDefined = true;
} else {
diff --git a/dw/oofpositionedmgr.hh b/dw/oofpositionedmgr.hh
index f4ded844..dc6943ed 100644
--- a/dw/oofpositionedmgr.hh
+++ b/dw/oofpositionedmgr.hh
@@ -7,7 +7,16 @@ namespace dw {
class OOFPositionedMgr: public OutOfFlowMgr
{
-private:
+protected:
+ virtual int cbBoxOffsetX () = 0;
+ virtual int cbBoxOffsetY () = 0;
+ virtual int cbBoxRestWidth () = 0;
+ virtual int cbBoxRestHeight () = 0;
+
+ inline int cbBoxDiffWidth () { return cbBoxOffsetX () + cbBoxRestWidth (); }
+ inline int cbBoxDiffHeight ()
+ { return cbBoxOffsetY () + cbBoxRestHeight (); }
+
Textblock *containingBlock;
core::Allocation containingBlockAllocation;