aboutsummaryrefslogtreecommitdiff
path: root/dw
diff options
context:
space:
mode:
Diffstat (limited to 'dw')
-rw-r--r--dw/table.cc92
-rw-r--r--dw/table.hh7
2 files changed, 97 insertions, 2 deletions
diff --git a/dw/table.cc b/dw/table.cc
index 6118de75..8fe949bb 100644
--- a/dw/table.cc
+++ b/dw/table.cc
@@ -210,10 +210,11 @@ int Table::getAvailWidthOfChild (Widget *child, bool forceValue)
if (availWidth == -1)
width = -1;
else {
+ // Within tables, a percentage 'width' specifies the total
+ // width, not the content width.
int containerContentWidth = availWidth - boxDiffWidth ();
width = core::style::multiplyWithPerLength (containerContentWidth,
- child->getStyle()->width)
- + child->boxDiffWidth ();
+ child->getStyle()->width);
}
} else {
DBG_OBJ_MSG ("resize", 1, "no length specified");
@@ -255,6 +256,93 @@ int Table::getAvailWidthOfChild (Widget *child, bool forceValue)
return width;
}
+void Table::correctRequisitionOfChild (Widget *child,
+ core::Requisition *requisition,
+ void (*splitHeightFun)(int height,
+ int *ascent,
+ int *descent))
+{
+ // (Mostly copied from Widget::correctRequisitionOfChild; could be
+ // cleaned up a bit.)
+
+ // TODO Correct by extremes?
+
+ DBG_OBJ_MSGF ("resize", 0,
+ "<b>correctRequisitionOfChild</b> (%p, %d * (%d + %d), ...)",
+ child, requisition->width, requisition->ascent,
+ requisition->descent);
+ DBG_OBJ_MSG_START ();
+
+ if (core::style::isAbsLength (child->getStyle()->width))
+ requisition->width = core::style::absLengthVal (child->getStyle()->width)
+ + child->boxDiffWidth ();
+ else if (core::style::isPerLength (child->getStyle()->width)) {
+ int availWidth = getAvailWidth (false);
+ if (availWidth != -1) {
+ // Within tables, a percentage 'width' specifies the total
+ // width, not the content width.
+ int containerWidth = availWidth - boxDiffWidth ();
+ requisition->width =
+ core::style::multiplyWithPerLength (containerWidth,
+ child->getStyle()->width);
+ }
+ }
+
+ // TODO Perhaps split first, then add box ascent and descent.
+ if (core::style::isAbsLength (child->getStyle()->height))
+ splitHeightFun (core::style::absLengthVal (child->getStyle()->height)
+ + child->boxDiffHeight (),
+ &requisition->ascent, &requisition->descent);
+ else if (core::style::isPerLength (child->getStyle()->height)) {
+ int availHeight = getAvailHeight (false);
+ if (availHeight != -1) {
+ int containerHeight = availHeight - boxDiffHeight ();
+ splitHeightFun (core::style::multiplyWithPerLength
+ (containerHeight, child->getStyle()->height)
+ + child->boxDiffHeight (),
+ &requisition->ascent, &requisition->descent);
+ }
+ }
+
+ DBG_OBJ_MSGF ("resize", 1, "=> %d * (%d + %d)",
+ requisition->width, requisition->ascent,
+ requisition->descent);
+ DBG_OBJ_MSG_END ();
+}
+
+void Table::correctExtremesOfChild (Widget *child, core::Extremes *extremes)
+{
+ // (Mostly copied from Widget::correctExtremesOfChild; could be
+ // cleaned up a bit.)
+
+ // TODO Extremes only corrected?
+
+ DBG_OBJ_MSGF ("resize", 0,
+ "<b>correctExtremedOfChild</b> (%p, %d / %d)",
+ child, extremes->minWidth, extremes->maxWidth);
+ DBG_OBJ_MSG_START ();
+
+ if (core::style::isAbsLength (child->getStyle()->width))
+ extremes->minWidth =extremes->maxWidth =
+ core::style::absLengthVal (child->getStyle()->width)
+ + child->boxDiffWidth ();
+ else if (core::style::isPerLength (child->getStyle()->width)) {
+ int availWidth = getAvailWidth (false);
+ if (availWidth != -1) {
+ // Within tables, a percentage 'width' specifies the total
+ // width, not the content width.
+ int containerWidth = availWidth - boxDiffWidth ();
+ extremes->minWidth =extremes->maxWidth =
+ core::style::multiplyWithPerLength (containerWidth,
+ child->getStyle()->width);
+ }
+ }
+
+ DBG_OBJ_MSGF ("resize", 1, "=> %d / %d",
+ extremes->minWidth, extremes->maxWidth);
+ DBG_OBJ_MSG_END ();
+}
+
void Table::containerSizeChangedForChildren ()
{
for (int col = 0; col < numCols; col++) {
diff --git a/dw/table.hh b/dw/table.hh
index a1e0ed38..580f4431 100644
--- a/dw/table.hh
+++ b/dw/table.hh
@@ -427,6 +427,13 @@ protected:
void resizeDrawImpl ();
int getAvailWidthOfChild (Widget *child, bool forceValue);
+ void correctRequisitionOfChild (Widget *child,
+ core::Requisition *requisition,
+ void (*splitHeightFun)(int height,
+ int *ascent,
+ int *descent));
+ void correctExtremesOfChild (Widget *child, core::Extremes *extremes);
+
void containerSizeChangedForChildren ();
bool usesAvailWidth ();