aboutsummaryrefslogtreecommitdiff
path: root/dw/ui.cc
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2014-07-18 14:09:01 +0200
committerSebastian Geerken <devnull@localhost>2014-07-18 14:09:01 +0200
commitf5aae2463edf320c69053959e53ec6ea3ef87935 (patch)
tree970f775ecb508b6249617ba545dbc45b7b98b97c /dw/ui.cc
parent17a739b7e10e1417124d5aa1a1d253c266dccc21 (diff)
Handling nested layouts (e. g. <button>), part 2.
Diffstat (limited to 'dw/ui.cc')
-rw-r--r--dw/ui.cc117
1 files changed, 117 insertions, 0 deletions
diff --git a/dw/ui.cc b/dw/ui.cc
index 80b33700..22b0b78e 100644
--- a/dw/ui.cc
+++ b/dw/ui.cc
@@ -64,6 +64,28 @@ void Embed::sizeAllocateImpl (Allocation *allocation)
resource->sizeAllocate (allocation);
}
+int Embed::getAvailWidthOfChild (Widget *child, bool forceValue)
+{
+ return resource->getAvailWidthOfChild (child, forceValue);
+}
+
+int Embed::getAvailHeightOfChild (Widget *child, bool forceValue)
+{
+ return resource->getAvailHeightOfChild (child, forceValue);
+}
+
+void Embed::correctRequisitionOfChild (Widget *child,
+ Requisition *requisition,
+ void (*splitHeightFun) (int, int*, int*))
+{
+ resource->correctRequisitionOfChild (child, requisition, splitHeightFun);
+}
+
+void Embed::correctExtremesOfChild (Widget *child, Extremes *extremes)
+{
+ resource->correctExtremesOfChild (child, extremes);
+}
+
void Embed::containerSizeChangedForChildren ()
{
DBG_OBJ_ENTER0 ("resize", 0, "containerSizeChangedForChildren");
@@ -200,6 +222,35 @@ void Resource::sizeAllocate (Allocation *allocation)
{
}
+int Resource::getAvailWidthOfChild (Widget *child, bool forceValue)
+{
+ // Only used when the resource contains other dillo widgets.
+ misc::assertNotReached ();
+ return 0;
+}
+
+int Resource::getAvailHeightOfChild (Widget *child, bool forceValue)
+{
+ // Only used when the resource contains other dillo widgets.
+ misc::assertNotReached ();
+ return 0;
+}
+
+void Resource::correctRequisitionOfChild (Widget *child,
+ Requisition *requisition,
+ void (*splitHeightFun) (int, int*,
+ int*))
+{
+ // Only used when the resource contains other dillo widgets.
+ misc::assertNotReached ();
+}
+
+void Resource::correctExtremesOfChild (Widget *child, Extremes *extremes)
+{
+ // Only used when the resource contains other dillo widgets.
+ misc::assertNotReached ();
+}
+
void Resource::setDisplayed (bool displayed)
{
}
@@ -330,6 +381,72 @@ void ComplexButtonResource::sizeAllocate (Allocation *allocation)
{
}
+int ComplexButtonResource::getAvailWidthOfChild (Widget *child, bool forceValue)
+{
+ int embedWidth = getEmbed()->getAvailWidth (forceValue);
+ if (embedWidth == -1)
+ return -1;
+ else
+ return misc::max (embedWidth - 2 * reliefXThickness (), 0);
+}
+
+int ComplexButtonResource::getAvailHeightOfChild (Widget *child,
+ bool forceValue)
+{
+ int embedHeight = getEmbed()->getAvailHeight (forceValue);
+ if (embedHeight == -1)
+ return -1;
+ else
+ return misc::max (embedHeight - 2 * reliefYThickness (), 0);
+}
+
+void ComplexButtonResource::correctRequisitionOfChild (Widget *child,
+ Requisition *requisition,
+ void (*splitHeightFun)
+ (int, int*, int*))
+{
+ // Similar to Widget::correctRequisitionOfChild, but for percentage
+ // the relief has to be considered.
+
+ if (style::isPerLength (child->getStyle()->width)) {
+ int availWidth = getEmbed()->getAvailHeight (false);
+ if (availWidth != -1) {
+ int baseWidth = misc::max (availWidth
+ - getEmbed()->boxDiffWidth ()
+ - 2 * reliefXThickness (),
+ 0);
+ requisition->width =
+ child->applyPerWidth (baseWidth, child->getStyle()->width);
+ }
+ } else
+ getEmbed()->correctReqWidthOfChildNoRec (child, requisition);
+
+ // TODO Percentage heights are ignored again.
+ getEmbed()->correctReqHeightOfChildNoRec (child, requisition,
+ splitHeightFun);
+
+}
+
+void ComplexButtonResource::correctExtremesOfChild (Widget *child,
+ Extremes *extremes)
+{
+ // Similar to Widget::correctExtremesOfChild, but for percentage
+ // the relief has to be considered.
+
+ if (style::isPerLength (child->getStyle()->width)) {
+ int availWidth = getEmbed()->getAvailHeight (false);
+ if (availWidth != -1) {
+ int baseWidth = misc::max (availWidth
+ - getEmbed()->boxDiffWidth ()
+ - 2 * reliefXThickness (),
+ 0);
+ extremes->minWidth = extremes->maxWidth =
+ child->applyPerWidth (baseWidth, child->getStyle()->width);
+ }
+ } else
+ getEmbed()->correctExtremesOfChildNoRec (child, extremes);
+}
+
Iterator *ComplexButtonResource::iterator (Content::Type mask, bool atEnd)
{
/**