aboutsummaryrefslogtreecommitdiff
path: root/dw
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2014-05-28 01:47:02 +0200
committerSebastian Geerken <devnull@localhost>2014-05-28 01:47:02 +0200
commit62fd27e851224c15bd41c1b70ad9710e2200c7bb (patch)
tree244d71e4169b504a13a0ad29c500c251541b9d37 /dw
parent935287d467ef8fecd0fe6e0170d7ec8778e73dad (diff)
Introduced Widget::container.
Diffstat (limited to 'dw')
-rw-r--r--dw/layout.cc3
-rw-r--r--dw/widget.cc14
-rw-r--r--dw/widget.hh11
3 files changed, 24 insertions, 4 deletions
diff --git a/dw/layout.cc b/dw/layout.cc
index f9b3f763..998878ca 100644
--- a/dw/layout.cc
+++ b/dw/layout.cc
@@ -371,8 +371,9 @@ void Layout::addWidget (Widget *widget)
topLevel = widget;
widget->layout = this;
+ widget->container = NULL;
queueResizeList->clear ();
- widget->notifySetAsTopLevel();
+ widget->notifySetAsTopLevel ();
findtextState.setWidget (widget);
diff --git a/dw/widget.cc b/dw/widget.cc
index 10312bf7..5ff02e22 100644
--- a/dw/widget.cc
+++ b/dw/widget.cc
@@ -70,7 +70,7 @@ Widget::Widget ()
registerName ("dw::core::Widget", &CLASS_ID);
flags = (Flags)(NEEDS_RESIZE | EXTREMES_CHANGED | HAS_CONTENTS);
- parent = generator = NULL;
+ parent = generator = container = NULL;
layout = NULL;
allocation.x = -1;
@@ -153,6 +153,18 @@ void Widget::setParent (Widget *parent)
//printf ("The %s %p becomes a child of the %s %p\n",
// getClassName(), this, parent->getClassName(), parent);
+ // Determine the container. Currently rather simple; will become
+ // more complicated when absolute and fixed positions are
+ // supported.
+ container = NULL;
+ for (Widget *widget = this; widget != NULL && container == NULL;
+ widget = widget->getParent())
+ if (widget->isBlockLevel ())
+ container = widget;
+ // If there is no block-level widget, there is also no container
+ // (i. e. the viewport is used). Does not occur in dillo, where the
+ // toplevel widget is a Textblock.
+
notifySetParent();
}
diff --git a/dw/widget.hh b/dw/widget.hh
index 6482c63a..3abde988 100644
--- a/dw/widget.hh
+++ b/dw/widget.hh
@@ -122,11 +122,18 @@ private:
/**
* \brief The generating widget, NULL for top-level widgets, or if
- * not set; in the latter case, the effective generator (see
- * getGenerator) is the parent.
+ * not set; in the latter case, the effective generator (see
+ * getGenerator) is the parent.
*/
Widget *generator;
+ /**
+ * \brief The containing widget, equivalent to the "containing
+ * block" defined by CSS. May be NULL, in this case the viewport
+ * is used.
+ */
+ Widget *container;
+
style::Style *style;
Flags flags;