summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dw/textblock.cc1
-rw-r--r--dw/widget.cc2
-rw-r--r--dw/widget.hh12
3 files changed, 14 insertions, 1 deletions
diff --git a/dw/textblock.cc b/dw/textblock.cc
index fd743c21..2a6f083e 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -1867,6 +1867,7 @@ void Textblock::addWidget (core::Widget *widget, core::style::Style *style)
}
widget->setParent (containingBlock);
+ widget->setGenerator (this);
containingBlock->outOfFlowMgr->addWidget (widget, this);
Word *word = addWord (0, 0, 0, false, style);
word->content.type = core::Content::WIDGET_OOF_REF;
diff --git a/dw/widget.cc b/dw/widget.cc
index 4018c069..a4f62174 100644
--- a/dw/widget.cc
+++ b/dw/widget.cc
@@ -39,7 +39,7 @@ Widget::Widget ()
registerName ("dw::core::Widget", &CLASS_ID);
flags = (Flags)(NEEDS_RESIZE | EXTREMES_CHANGED | HAS_CONTENTS);
- parent = NULL;
+ parent = generator = NULL;
layout = NULL;
allocation.x = -1;
diff --git a/dw/widget.hh b/dw/widget.hh
index b50269cf..ff52e096 100644
--- a/dw/widget.hh
+++ b/dw/widget.hh
@@ -79,6 +79,14 @@ private:
* \brief The parent widget, NULL for top-level widgets.
*/
Widget *parent;
+
+ /**
+ * \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.
+ */
+ Widget *generator;
+
style::Style *style;
Flags flags;
@@ -246,6 +254,8 @@ public:
void setParent (Widget *parent);
+ void setGenerator (Widget *generator) { this->generator = generator; }
+
inline style::Style *getStyle () { return style; }
/** \todo I do not like this. */
inline Allocation *getAllocation () { return &allocation; }
@@ -285,6 +295,8 @@ public:
int getLevel ();
Widget *getNearestCommonAncestor (Widget *otherWidget);
+ inline Widget *getGenerator () { return generator ? generator : parent; }
+
inline Layout *getLayout () { return layout; }
virtual Widget *getWidgetAtPoint (int x, int y, int level);