aboutsummaryrefslogtreecommitdiff
path: root/dw
diff options
context:
space:
mode:
Diffstat (limited to 'dw')
-rw-r--r--dw/layout.cc7
-rw-r--r--dw/oofawarewidget.cc155
-rw-r--r--dw/oofawarewidget.hh13
-rw-r--r--dw/ooffloatsmgr.cc43
-rw-r--r--dw/ooffloatsmgr.hh10
-rw-r--r--dw/oofpositionedmgr.cc25
-rw-r--r--dw/oofpositionedmgr.hh4
-rw-r--r--dw/outofflowmgr.hh6
-rw-r--r--dw/stackingcontextmgr.cc71
-rw-r--r--dw/stackingcontextmgr.hh23
-rw-r--r--dw/table.cc41
-rw-r--r--dw/table.hh4
-rw-r--r--dw/textblock.cc57
-rw-r--r--dw/textblock.hh4
-rw-r--r--dw/widget.cc84
-rw-r--r--dw/widget.hh14
16 files changed, 153 insertions, 408 deletions
diff --git a/dw/layout.cc b/dw/layout.cc
index ca2ceb98..d18bc486 100644
--- a/dw/layout.cc
+++ b/dw/layout.cc
@@ -1110,9 +1110,10 @@ Widget *Layout::getWidgetAtPoint (int x, int y)
DBG_OBJ_ENTER ("events", 0, "getWidgetAtPoint", "%d, %d", x, y);
Widget *widget;
- if (topLevel && topLevel->wasAllocated ())
- widget = topLevel->getWidgetAtPointToplevel (x, y);
- else
+ if (topLevel && topLevel->wasAllocated ()) {
+ GettingWidgetAtPointContext context;
+ widget = topLevel->getWidgetAtPoint (x, y, &context);
+ } else
widget = NULL;
DBG_OBJ_MSGF ("events", 0, "=> %p", widget);
diff --git a/dw/oofawarewidget.cc b/dw/oofawarewidget.cc
index eac4580b..e457a84e 100644
--- a/dw/oofawarewidget.cc
+++ b/dw/oofawarewidget.cc
@@ -397,7 +397,8 @@ void OOFAwareWidget::draw (View *view, Rectangle *area, DrawingContext *context)
DBG_OBJ_ENTER ("draw", 0, "draw", "%d, %d, %d * %d",
area->x, area->y, area->width, area->height);
- for (int level = 0; level < OOFStackingIterator::END; level++)
+ for (int level = OOFStackingIterator::START + 1;
+ level < OOFStackingIterator::END; level++)
drawLevel (view, area, level, context);
DBG_OBJ_LEAVE ();
@@ -458,120 +459,43 @@ void OOFAwareWidget::drawOOF (View *view, Rectangle *area,
}
Widget *OOFAwareWidget::getWidgetAtPoint (int x, int y,
- StackingIteratorStack *iteratorStack,
- Widget **interruptedWidget)
+ GettingWidgetAtPointContext *context)
{
DBG_OBJ_ENTER ("events", 0, "getWidgetAtPoint", "%d, %d", x, y);
Widget *widgetAtPoint = NULL;
- if (wasAllocated () && x >= allocation.x && y >= allocation.y &&
- x <= allocation.x + allocation.width &&
- y <= allocation.y + getHeight ()) {
- while (widgetAtPoint == NULL && *interruptedWidget == NULL &&
- ((OOFStackingIterator*)iteratorStack->getTop())->majorLevel
- > OOFStackingIterator::START) {
- widgetAtPoint =
- getWidgetAtPointLevel (x, y, iteratorStack, interruptedWidget,
- ((OOFStackingIterator*)iteratorStack
- ->getTop())->majorLevel);
-
- if (*interruptedWidget) {
- assert (widgetAtPoint == NULL); // Not both set.
-
- if ((*interruptedWidget)->getParent () == this) {
- DBG_OBJ_MSGF ("events", 1,
- "interrupted at %p, searching widget seperately",
- *interruptedWidget);
- DBG_IF_RTFL {
- StringBuffer sb;
- iteratorStack->intoStringBuffer (&sb);
- DBG_OBJ_MSGF ("events", 2, "iteratorStack: %s",
- sb.getChars ());
- }
-
- // Similar to Widget::getWidgetAtPointToplevel. Nested
- // interruptions are not allowed.
- StackingIteratorStack iteratorStack2;
- Widget *interruptedWidget2 = NULL;
- widgetAtPoint = (*interruptedWidget)
- ->getWidgetAtPointTotal (x, y, &iteratorStack2,
- &interruptedWidget2);
- assert (interruptedWidget2 == NULL);
-
- ((OOFStackingIterator*)iteratorStack->getTop())
- ->registerWidgetDrawnAfterInterruption (*interruptedWidget);
-
- // Continue with the current state of "iterator".
- *interruptedWidget = NULL;
- DBG_OBJ_MSG ("events", 1, "done with interruption");
-
- // The interrupted widget may have returned non-NULL. In this
- // case, the stack must be cleaned up explicitly, which would
- // otherwise be done implicitly during the further search.
- // (Since drawing is never quit completely, this problem only
- // applies to searching.)
- if (widgetAtPoint) {
- iteratorStack->cleanup ();
-
- DBG_IF_RTFL {
- StringBuffer sb;
- iteratorStack->intoStringBuffer (&sb);
- DBG_OBJ_MSGF ("events", 2,
- "iteratorStack after cleanup: %s",
- sb.getChars ());
- }
- }
-
- }
- } else {
- OOFStackingIterator* osi =
- (OOFStackingIterator*)iteratorStack->getTop();
- osi->majorLevel--;
- if (osi->majorLevel > OOFStackingIterator::START) {
- osi->minorLevel = getLastMinorLevel (osi->majorLevel);
- osi->index =
- getLastLevelIndex (osi->majorLevel, osi->minorLevel);
- }
- }
- }
+ if (inAllocation (x, y)) {
+ for (int level = OOFStackingIterator::END - 1;
+ widgetAtPoint == NULL && level > OOFStackingIterator::START; level--)
+ widgetAtPoint = getWidgetAtPointLevel (x, y, context, level);
}
-
- DBG_OBJ_MSGF ("events", 1, "=> %p (i: %p)",
- widgetAtPoint, *interruptedWidget);
+
+ DBG_OBJ_MSGF ("events", 1, "=> %p", widgetAtPoint);
DBG_OBJ_LEAVE ();
return widgetAtPoint;
}
Widget *OOFAwareWidget::getWidgetAtPointLevel (int x, int y,
- StackingIteratorStack
- *iteratorStack,
- Widget **interruptedWidget,
- int majorLevel)
+ GettingWidgetAtPointContext
+ *context,
+ int level)
{
DBG_OBJ_ENTER ("events", 0, "OOFAwareWidget::getWidgetAtPointLevel",
- "%d, %d, %s", x, y,
- OOFStackingIterator::majorLevelText (majorLevel));
+ "%d, %d, %s",
+ x, y, OOFStackingIterator::majorLevelText (level));
Widget *widgetAtPoint = NULL;
- switch (majorLevel) {
+ switch (level) {
case OOFStackingIterator::BACKGROUND:
- if (wasAllocated () && x >= allocation.x && y >= allocation.y &&
- x <= allocation.x + allocation.width &&
- y <= allocation.y + getHeight ())
+ if (inAllocation (x, y))
widgetAtPoint = this;
break;
case OOFStackingIterator::SC_BOTTOM:
- if (stackingContextMgr) {
- OOFStackingIterator *osi =
- (OOFStackingIterator*)iteratorStack->getTop ();
- widgetAtPoint =
- stackingContextMgr->getBottomWidgetAtPoint (x, y, iteratorStack,
- interruptedWidget,
- &osi->minorLevel,
- &osi->index);
- }
+ if (stackingContextMgr)
+ widgetAtPoint =
+ stackingContextMgr->getBottomWidgetAtPoint (x, y, context);
break;
case OOFStackingIterator::IN_FLOW:
@@ -584,56 +508,33 @@ Widget *OOFAwareWidget::getWidgetAtPointLevel (int x, int y,
break;
case OOFStackingIterator::OOF_CONT:
- widgetAtPoint =
- getWidgetOOFAtPoint (x, y, iteratorStack, interruptedWidget);
+ widgetAtPoint = getWidgetOOFAtPoint (x, y, context);
break;
case OOFStackingIterator::SC_TOP:
- if (stackingContextMgr) {
- OOFStackingIterator *osi =
- (OOFStackingIterator*)iteratorStack->getTop ();
+ if (stackingContextMgr)
widgetAtPoint =
- stackingContextMgr->getTopWidgetAtPoint (x, y, iteratorStack,
- interruptedWidget,
- &osi->minorLevel,
- &osi->index);
- }
+ stackingContextMgr->getTopWidgetAtPoint (x, y, context);
break;
default:
assertNotReached ();
}
- DBG_OBJ_MSGF ("events", 1, "=> %p (i: %p)",
- widgetAtPoint, *interruptedWidget);
+ DBG_OBJ_MSGF ("events", 1, "=> %p", widgetAtPoint);
DBG_OBJ_LEAVE ();
return widgetAtPoint;
}
Widget *OOFAwareWidget::getWidgetOOFAtPoint (int x, int y,
- core::StackingIteratorStack
- *iteratorStack,
- Widget **interruptedWidget)
+ GettingWidgetAtPointContext
+ *context)
{
- OOFStackingIterator *osi = (OOFStackingIterator*)iteratorStack->getTop ();
- assert (osi->majorLevel == OOFStackingIterator::OOF_CONT);
-
Widget *widgetAtPoint = NULL;
- while (*interruptedWidget == NULL && widgetAtPoint == NULL &&
- osi->minorLevel >= 0) {
- if (outOfFlowMgr[osi->minorLevel])
- widgetAtPoint =
- outOfFlowMgr[osi->minorLevel]->getWidgetAtPoint (x, y,
- iteratorStack,
- interruptedWidget,
- &(osi->index));
-
- if (*interruptedWidget == NULL) {
- osi->minorLevel--;
- if (osi->minorLevel > 0 && outOfFlowMgr[osi->minorLevel] != NULL)
- osi->index = outOfFlowMgr[osi->minorLevel]->getNumWidgets () - 1;
- }
+ for (int i = NUM_OOFM -1; widgetAtPoint == NULL && i >= 0; i--) {
+ if(outOfFlowMgr[i])
+ widgetAtPoint = outOfFlowMgr[i]->getWidgetAtPoint (x, y, context);
}
return widgetAtPoint;
diff --git a/dw/oofawarewidget.hh b/dw/oofawarewidget.hh
index 8573fd3f..a654f0f6 100644
--- a/dw/oofawarewidget.hh
+++ b/dw/oofawarewidget.hh
@@ -163,16 +163,13 @@ protected:
core::DrawingContext *context);
Widget *getWidgetAtPoint (int x, int y,
- core::StackingIteratorStack *iteratorStack,
- Widget **interruptedWidget);
+ core::GettingWidgetAtPointContext *context);
virtual Widget *getWidgetAtPointLevel (int x, int y,
- core::StackingIteratorStack
- *iteratorStack,
- Widget **interruptedWidget,
- int majorLevel);
+ core::GettingWidgetAtPointContext
+ *context,
+ int level);
Widget *getWidgetOOFAtPoint (int x, int y,
- core::StackingIteratorStack *iteratorStack,
- Widget **interruptedWidget);
+ core::GettingWidgetAtPointContext *context);
virtual int getLastMinorLevel (int majorLevel);
virtual int getLastLevelIndex (int majorLevel, int minorLevel);
diff --git a/dw/ooffloatsmgr.cc b/dw/ooffloatsmgr.cc
index 5f0d9eff..5b6c8755 100644
--- a/dw/ooffloatsmgr.cc
+++ b/dw/ooffloatsmgr.cc
@@ -1489,51 +1489,32 @@ void OOFFloatsMgr::markExtremesChange (int ref)
}
Widget *OOFFloatsMgr::getWidgetAtPoint (int x, int y,
- core::StackingIteratorStack
- *iteratorStack,
- core::Widget **interruptedWidget,
- int *index)
+ GettingWidgetAtPointContext *context)
{
Widget *widgetAtPoint = NULL;
- widgetAtPoint =
- getFloatWidgetAtPoint (rightFloatsCB, x, y, iteratorStack,
- interruptedWidget, index,
- leftFloatsCB->size ());
- if (widgetAtPoint == NULL && *interruptedWidget == NULL)
- widgetAtPoint =
- getFloatWidgetAtPoint (leftFloatsCB, x, y, iteratorStack,
- interruptedWidget, index, 0);
+ widgetAtPoint = getFloatWidgetAtPoint (rightFloatsCB, x, y, context);
+ if (widgetAtPoint == NULL)
+ widgetAtPoint = getFloatWidgetAtPoint (leftFloatsCB, x, y, context);
+
return widgetAtPoint;
}
Widget *OOFFloatsMgr::getFloatWidgetAtPoint (SortedFloatsVector *list, int x,
int y,
- StackingIteratorStack
- *iteratorStack,
- Widget **interruptedWidget,
- int *index, int startIndex)
+ GettingWidgetAtPointContext
+ *context)
{
// Could use binary search to be faster (similar to drawing).
Widget *widgetAtPoint = NULL;
- OOFAwareWidget::OOFStackingIterator *osi =
- (OOFAwareWidget::OOFStackingIterator*)iteratorStack->getTop ();
- while (widgetAtPoint == NULL && *interruptedWidget == NULL &&
- *index - startIndex >= 0 &&
- // In case the list is empty:
- *index - startIndex < list->size()) {
- Widget *childWidget = list->get(*index - startIndex)->getWidget ();
- if (!osi->hasWidgetBeenDrawnAfterInterruption (childWidget) &&
+ for (int i = list->size() - 1; widgetAtPoint == NULL && i >= 0; i--) {
+ Widget *childWidget = list->get(i)->getWidget ();
+ if (!context->hasWidgetBeenProcessedAsInterruption (childWidget) &&
!StackingContextMgr::handledByStackingContextMgr (childWidget))
- widgetAtPoint =
- childWidget->getWidgetAtPointTotal (x, y, iteratorStack,
- interruptedWidget);
-
- if (*interruptedWidget == NULL)
- (*index)--;
+ widgetAtPoint = childWidget->getWidgetAtPoint (x, y, context);
}
-
+
return widgetAtPoint;
}
diff --git a/dw/ooffloatsmgr.hh b/dw/ooffloatsmgr.hh
index 1c0b5f03..430f383f 100644
--- a/dw/ooffloatsmgr.hh
+++ b/dw/ooffloatsmgr.hh
@@ -287,10 +287,8 @@ private:
void drawFloats (SortedFloatsVector *list, core::View *view,
core::Rectangle *area, core::DrawingContext *context);
core::Widget *getFloatWidgetAtPoint (SortedFloatsVector *list, int x, int y,
- core::StackingIteratorStack
- *iteratorStack,
- core::Widget **interruptedWidget,
- int *index, int startIndex);
+ core::GettingWidgetAtPointContext
+ *context);
bool collidesV (Float *vloat, Float *other, SFVType type, int *yReal,
bool useAllocation);
@@ -350,9 +348,7 @@ public:
void markSizeChange (int ref);
void markExtremesChange (int ref);
core::Widget *getWidgetAtPoint (int x, int y,
- core::StackingIteratorStack *iteratorStack,
- core::Widget **interruptedWidget,
- int *index);
+ core::GettingWidgetAtPointContext *context);
void addWidgetInFlow (OOFAwareWidget *textblock, OOFAwareWidget *parentBlock,
int externalIndex);
diff --git a/dw/oofpositionedmgr.cc b/dw/oofpositionedmgr.cc
index 10c48b1e..661c5bb9 100644
--- a/dw/oofpositionedmgr.cc
+++ b/dw/oofpositionedmgr.cc
@@ -287,32 +287,23 @@ void OOFPositionedMgr::markExtremesChange (int ref)
}
Widget *OOFPositionedMgr::getWidgetAtPoint (int x, int y,
- StackingIteratorStack
- *iteratorStack,
- Widget **interruptedWidget,
- int *index)
+ GettingWidgetAtPointContext
+ *context)
{
DBG_OBJ_ENTER ("events", 0, "getWidgetAtPoint", "%d, %d", x, y);
Widget *widgetAtPoint = NULL;
- OOFAwareWidget::OOFStackingIterator *osi =
- (OOFAwareWidget::OOFStackingIterator*)iteratorStack->getTop ();
- while (widgetAtPoint == NULL && *interruptedWidget == NULL && *index >= 0) {
- Widget *childWidget = children->get(*index)->widget;
- if (!osi->hasWidgetBeenDrawnAfterInterruption (childWidget) &&
+ for (int i = children->size() - 1; widgetAtPoint == NULL && i >= 0; i--) {
+ Widget *childWidget = children->get(i)->widget;
+ if (!context->hasWidgetBeenProcessedAsInterruption (childWidget) &&
!StackingContextMgr::handledByStackingContextMgr (childWidget))
- widgetAtPoint =
- childWidget->getWidgetAtPointTotal (x, y, iteratorStack,
- interruptedWidget);
-
- if (*interruptedWidget == NULL)
- (*index)--;
+ widgetAtPoint = childWidget->getWidgetAtPoint (x, y, context);
}
- DBG_OBJ_MSGF ("events", 0, "=> %p (i: %p)",
- widgetAtPoint, *interruptedWidget);
+ DBG_OBJ_MSGF ("events", 0, "=> %p", widgetAtPoint);
DBG_OBJ_LEAVE ();
+
return widgetAtPoint;
}
diff --git a/dw/oofpositionedmgr.hh b/dw/oofpositionedmgr.hh
index f33d7fe6..9b99f3cd 100644
--- a/dw/oofpositionedmgr.hh
+++ b/dw/oofpositionedmgr.hh
@@ -92,9 +92,7 @@ public:
void markSizeChange (int ref);
void markExtremesChange (int ref);
core::Widget *getWidgetAtPoint (int x, int y,
- core::StackingIteratorStack *iteratorStack,
- core::Widget **interruptedWidget,
- int *index);
+ core::GettingWidgetAtPointContext *context);
void addWidgetInFlow (OOFAwareWidget *widget, OOFAwareWidget *parent,
int externalIndex);
diff --git a/dw/outofflowmgr.hh b/dw/outofflowmgr.hh
index 38ac78b9..0ca19ee6 100644
--- a/dw/outofflowmgr.hh
+++ b/dw/outofflowmgr.hh
@@ -31,10 +31,8 @@ public:
virtual void markSizeChange (int ref) = 0;
virtual void markExtremesChange (int ref) = 0;
virtual core::Widget *getWidgetAtPoint (int x, int y,
- core::StackingIteratorStack
- *iteratorStack,
- core::Widget **interruptedWidget,
- int *index)= 0;
+ core::GettingWidgetAtPointContext
+ *context) = 0;
virtual void addWidgetInFlow (OOFAwareWidget *widget,
OOFAwareWidget *parent, int externalIndex) = 0;
diff --git a/dw/stackingcontextmgr.cc b/dw/stackingcontextmgr.cc
index 00a6d43b..98cef164 100644
--- a/dw/stackingcontextmgr.cc
+++ b/dw/stackingcontextmgr.cc
@@ -153,82 +153,39 @@ void StackingContextMgr::draw (View *view, Rectangle *area, int startZIndex,
DBG_OBJ_LEAVE ();
}
-Widget *StackingContextMgr::getTopWidgetAtPoint (int x, int y,
- core::StackingIteratorStack
- *iteratorStack,
- Widget **interruptedWidget,
- int *zIndexIndex, int *index)
-{
- DBG_OBJ_ENTER ("events", 0, "getWidgetAtPointTop", "%d, %d", x, y);
- Widget *widget = getWidgetAtPoint (x, y, iteratorStack, interruptedWidget,
- zIndexIndex, 0, INT_MAX, index);
- DBG_OBJ_MSGF ("events", 0, "=> %p (i: %p)", widget, *interruptedWidget);
- DBG_OBJ_LEAVE ();
- return widget;
-}
-
-Widget *StackingContextMgr::getBottomWidgetAtPoint (int x, int y,
- core::StackingIteratorStack
- *iteratorStack,
- Widget **interruptedWidget,
- int *zIndexIndex,
- int *index)
-{
- DBG_OBJ_ENTER ("events", 0, "getWidgetAtPointBottom", "%d, %d", x, y);
- Widget *widget = getWidgetAtPoint (x, y, iteratorStack, interruptedWidget,
- zIndexIndex, INT_MIN, -1, index);
- DBG_OBJ_MSGF ("events", 0, "=> %p (i: %p)", widget, *interruptedWidget);
- DBG_OBJ_LEAVE ();
- return widget;
-}
-
Widget *StackingContextMgr::getWidgetAtPoint (int x, int y,
- StackingIteratorStack
- *iteratorStack,
- Widget **interruptedWidget,
- int *zIndexIndex,
- int startZIndex, int endZIndex,
- int *index)
+ GettingWidgetAtPointContext
+ *context,
+ int startZIndex, int endZIndex)
{
DBG_OBJ_ENTER ("events", 0, "getWidgetAtPoint", "%d, %d", x, y);
Widget *widgetAtPoint = NULL;
- while (*interruptedWidget == NULL && widgetAtPoint == NULL &&
- *zIndexIndex >= 0) {
+ for (int zIndexIndex = numZIndices - 1;
+ widgetAtPoint == NULL && zIndexIndex >= 0; zIndexIndex--) {
// Wrong region of z-indices (top or bottom) is simply ignored
// (as well as non-defined zIndices).
- if (zIndices != NULL && zIndices[*zIndexIndex] >= startZIndex &&
- zIndices[*zIndexIndex] <= endZIndex) {
+ if (zIndices != NULL && zIndices[zIndexIndex] >= startZIndex &&
+ zIndices[zIndexIndex] <= endZIndex) {
DBG_OBJ_MSGF ("events", 1, "searching zIndex = %d",
- zIndices[*zIndexIndex]);
+ zIndices[zIndexIndex]);
DBG_OBJ_MSG_START ();
- while (*interruptedWidget == NULL && widgetAtPoint == NULL &&
- *index >= 0) {
- Widget *child = childSCWidgets->get (*index);
+ for (int i = childSCWidgets->size () - 1;
+ widgetAtPoint == NULL && i >= 0; i--) {
+ Widget *child = childSCWidgets->get (i);
DBG_OBJ_MSGF ("events", 2, "widget %p has zIndex = %d",
child, child->getStyle()->zIndex);
- if (child->getStyle()->zIndex == zIndices[*zIndexIndex])
- widgetAtPoint =
- child->getWidgetAtPointTotal (x, y, iteratorStack,
- interruptedWidget);
-
- if (*interruptedWidget == NULL)
- (*index)--;
+ if (child->getStyle()->zIndex == zIndices[zIndexIndex])
+ widgetAtPoint = child->getWidgetAtPoint (x, y, context);
}
DBG_OBJ_MSG_END ();
}
-
- if (*interruptedWidget == NULL) {
- (*zIndexIndex)--;
- *index = childSCWidgets->size () - 1;
- }
}
- DBG_OBJ_MSGF ("events", 0, "=> %p (i: %p)",
- widgetAtPoint, *interruptedWidget);
+ DBG_OBJ_MSGF ("events", 0, "=> %p", widgetAtPoint);
DBG_OBJ_LEAVE ();
return widgetAtPoint;
}
diff --git a/dw/stackingcontextmgr.hh b/dw/stackingcontextmgr.hh
index 3836d98d..3a877031 100644
--- a/dw/stackingcontextmgr.hh
+++ b/dw/stackingcontextmgr.hh
@@ -26,9 +26,9 @@ private:
int findZIndex (int zIndex, bool mustExist);
void draw (View *view, Rectangle *area, int startZIndex, int endZIndex,
DrawingContext *context);
- Widget *getWidgetAtPoint (int x, int y, StackingIteratorStack *iteratorStack,
- Widget **interruptedWidget, int *zIndexIndex,
- int startZIndex, int endZIndex, int *index);
+ Widget *getWidgetAtPoint (int x, int y,
+ core::GettingWidgetAtPointContext *context,
+ int startZIndex, int endZIndex);
public:
StackingContextMgr (Widget *widget);
@@ -57,14 +57,15 @@ public:
void drawTop (View *view, Rectangle *area, DrawingContext *context)
{ draw (view, area, 0, INT_MAX, context); }
- Widget *getTopWidgetAtPoint (int x, int y,
- core::StackingIteratorStack *iteratorStack,
- Widget **interruptedWidget,
- int *zIndexIndex, int *index);
- Widget *getBottomWidgetAtPoint (int x, int y,
- core::StackingIteratorStack *iteratorStack,
- Widget **interruptedWidget,
- int *zIndexIndex, int *index);
+ inline Widget *getTopWidgetAtPoint (int x, int y,
+ core::GettingWidgetAtPointContext
+ *context)
+ { return getWidgetAtPoint (x, y, context, 0, INT_MAX); }
+
+ inline Widget *getBottomWidgetAtPoint (int x, int y,
+ core::GettingWidgetAtPointContext
+ *context)
+ { return getWidgetAtPoint (x, y, context, INT_MIN, -1); }
};
} // namespace core
diff --git a/dw/table.cc b/dw/table.cc
index 5570c853..9e493e51 100644
--- a/dw/table.cc
+++ b/dw/table.cc
@@ -415,49 +415,36 @@ bool Table::isBlockLevel ()
}
core::Widget *Table::getWidgetAtPointLevel (int x, int y,
- core::StackingIteratorStack
- *iteratorStack,
- Widget **interruptedWidget,
- int majorLevel)
+ core::GettingWidgetAtPointContext
+ *context,
+ int level)
{
DBG_OBJ_ENTER ("events", 0, "Table::getWidgetAtPointLevel", "%d, %d, %s",
- x, y, OOFStackingIterator::majorLevelText (majorLevel));
+ x, y, OOFStackingIterator::majorLevelText (level));
Widget *widgetAtPoint = NULL;
- switch (majorLevel) {
+ switch (level) {
case OOFStackingIterator::IN_FLOW:
- {
- OOFStackingIterator *osi =
- (OOFStackingIterator*)iteratorStack->getTop ();
-
- while (widgetAtPoint == NULL && *interruptedWidget == NULL &&
- osi->index >= 0) {
- if (childDefined (osi->index)) {
- Widget *child = children->get(osi->index)->cell.widget;
- if (!core::StackingContextMgr::handledByStackingContextMgr
- (child))
- widgetAtPoint =
- child->getWidgetAtPointTotal (x, y, iteratorStack,
- interruptedWidget);
- }
-
- if (*interruptedWidget == NULL)
- osi->index--;
+ for (int i = children->size () - 1; widgetAtPoint == NULL && i >= 0;
+ i--) {
+ if (childDefined (i)) {
+ Widget *child = children->get(i)->cell.widget;
+ if (!core::StackingContextMgr::handledByStackingContextMgr (child))
+ widgetAtPoint = child->getWidgetAtPoint (x, y, context);
}
}
break;
default:
widgetAtPoint =
- OOFAwareWidget::getWidgetAtPointLevel (x, y, iteratorStack,
- interruptedWidget, majorLevel);
+ OOFAwareWidget::getWidgetAtPointLevel (x, y, context, level);
break;
}
- DBG_OBJ_MSGF ("events", 1, "=> %p (i: %p)",
- widgetAtPoint, *interruptedWidget);
+ DBG_OBJ_MSGF ("events", 1, "=> %p", widgetAtPoint);
DBG_OBJ_LEAVE ();
+
return widgetAtPoint;
}
diff --git a/dw/table.hh b/dw/table.hh
index 23298ac2..491bb709 100644
--- a/dw/table.hh
+++ b/dw/table.hh
@@ -478,8 +478,8 @@ protected:
core::DrawingContext *context);
Widget *getWidgetAtPointLevel (int x, int y,
- core::StackingIteratorStack *iteratorStack,
- Widget **interruptedWidget, int majorLevel);
+ core::GettingWidgetAtPointContext *context,
+ int level);
int getLastLevelIndex (int majorLevel, int minorLevel);
//bool buttonPressImpl (core::EventButton *event);
diff --git a/dw/textblock.cc b/dw/textblock.cc
index 754d278c..1e1733d0 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -2754,60 +2754,63 @@ void Textblock::breakAdded ()
words->getRef(words->size () - 2)->effSpace = 0;
}
-core::Widget *Textblock::getWidgetAtPointLevel (int x, int y,
- core::StackingIteratorStack
- *iteratorStack,
- Widget **interruptedWidget,
- int majorLevel)
+core::Widget *Textblock::getWidgetAtPointLevel(int x, int y,
+ core::GettingWidgetAtPointContext
+ *context,
+ int level)
{
DBG_OBJ_ENTER ("events", 0, "Textblock::getWidgetAtPointLevel", "%d, %d, %s",
- x, y, OOFStackingIterator::majorLevelText (majorLevel));
+ x, y, OOFStackingIterator::majorLevelText (level));
Widget *widgetAtPoint = NULL;
- switch (majorLevel) {
+ switch (level) {
case OOFStackingIterator::IN_FLOW:
{
- OOFStackingIterator *osi =
- (OOFStackingIterator*)iteratorStack->getTop ();
-
int lineIndex = findLineIndexWhenAllocated (y - allocation.y);
if (lineIndex >= 0 && lineIndex < lines->size ()) {
Line *line = lines->getRef (lineIndex);
- if (osi->index > line->lastWord)
- osi->index = line->lastWord;
- while (widgetAtPoint == NULL && *interruptedWidget == NULL &&
- osi->index >= 0) {
- Word *word = words->getRef (osi->index);
+ for (int wordIndex = line->lastWord;
+ widgetAtPoint == NULL && wordIndex >= line->firstWord;
+ wordIndex--) {
+ Word *word = words->getRef (wordIndex);
if (word->content.type == core::Content::WIDGET_IN_FLOW &&
!core::StackingContextMgr::handledByStackingContextMgr
- (word->content.widget))
- widgetAtPoint = word->content.widget
- ->getWidgetAtPointTotal (x, y, iteratorStack,
- interruptedWidget);
- if (*interruptedWidget == NULL)
- osi->index--;
+ (word->content.widget))
+ widgetAtPoint =
+ word->content.widget->getWidgetAtPoint (x, y, context);
}
}
}
break;
case OOFStackingIterator::OOF_REF:
- handleOOFReferences (iteratorStack, interruptedWidget, true);
- // No searching, only interruption.
+ // TODO Inefficient. Perhaps store OOF references in seperate
+ // (much smaller!) list.
+ for (int oofmIndex = NUM_OOFM; widgetAtPoint == NULL && oofmIndex >= 0;
+ oofmIndex--) {
+ for (int wordIndex = words->size () - 1;
+ widgetAtPoint == NULL && wordIndex >= 0; wordIndex--) {
+ Word *word = words->getRef (wordIndex);
+ if (word->content.type == core::Content::WIDGET_OOF_REF &&
+ getOOFMIndex (word->content.widget) == oofmIndex &&
+ doesWidgetOOFInterruptDrawing (word->content.widget))
+ widgetAtPoint =
+ word->content.widget->getWidgetAtPointInterrupted (x, y,
+ context);
+ }
+ }
break;
default:
widgetAtPoint =
- OOFAwareWidget::getWidgetAtPointLevel (x, y, iteratorStack,
- interruptedWidget, majorLevel);
+ OOFAwareWidget::getWidgetAtPointLevel (x, y, context, level);
break;
}
- DBG_OBJ_MSGF ("events", 1, "=> %p (i: %p)",
- widgetAtPoint, *interruptedWidget);
+ DBG_OBJ_MSGF ("events", 1, "=> %p", widgetAtPoint);
DBG_OBJ_LEAVE ();
return widgetAtPoint;
}
diff --git a/dw/textblock.hh b/dw/textblock.hh
index cc18cdab..dd128a0a 100644
--- a/dw/textblock.hh
+++ b/dw/textblock.hh
@@ -813,8 +813,8 @@ protected:
core::DrawingContext *context);
Widget *getWidgetAtPointLevel (int x, int y,
- core::StackingIteratorStack *iteratorStack,
- Widget **interruptedWidget, int majorLevel);
+ core::GettingWidgetAtPointContext *context,
+ int level);
int getLastLevelIndex (int majorLevel, int minorLevel);
void sizeRequestImpl (core::Requisition *requisition);
diff --git a/dw/widget.cc b/dw/widget.cc
index 00ce8d97..4903c067 100644
--- a/dw/widget.cc
+++ b/dw/widget.cc
@@ -204,93 +204,25 @@ void Widget::drawInterruption (View *view, Rectangle *area,
}
Widget *Widget::getWidgetAtPoint (int x, int y,
- StackingIteratorStack *iteratorStack,
- Widget **interruptedWidget)
+ GettingWidgetAtPointContext *context)
{
// Suitable for simple widgets, without children.
- if (wasAllocated () && x >= allocation.x && y >= allocation.y &&
- x <= allocation.x + allocation.width && y <= allocation.y + getHeight ())
+ if (inAllocation (x, y))
return this;
else
return NULL;
}
-Widget *Widget::getWidgetAtPointTotal (int x, int y,
- StackingIteratorStack *iteratorStack,
- Widget **interruptedWidget)
+Widget *Widget::getWidgetAtPointInterrupted (int x, int y,
+ GettingWidgetAtPointContext
+ *context)
{
- DBG_OBJ_ENTER ("events", 0, "getWidgetAtPointTotal", "%d, %d", x, y);
-
- DBG_IF_RTFL {
- misc::StringBuffer sb;
- iteratorStack->intoStringBuffer (&sb);
- DBG_OBJ_MSGF ("events", 2, "initial iteratorStack: %s", sb.getChars ());
- }
-
- Object *si = NULL;
-
- if (iteratorStack->atRealTop ()) {
- si = stackingIterator (true);
- if (si) {
- iteratorStack->push (si);
- }
- } else
- iteratorStack->forward ();
-
- DBG_IF_RTFL {
- misc::StringBuffer sb;
- iteratorStack->intoStringBuffer (&sb);
- DBG_OBJ_MSGF ("events", 2, "iteratorStack before: %s",
- sb.getChars ());
- }
-
- Widget *widget = getWidgetAtPoint (x, y, iteratorStack, interruptedWidget);
- DBG_OBJ_MSGF ("events", 1, "=> %p (i: %p)", widget, *interruptedWidget);
-
- DBG_IF_RTFL {
- misc::StringBuffer sb;
- iteratorStack->intoStringBuffer (&sb);
- DBG_OBJ_MSGF ("events", 2, "iteratorStack after: %s",
- sb.getChars ());
- }
-
- // See comment in drawTotal().
-
- // assert (*interruptedWidget == NULL || si != NULL);
-
- if (*interruptedWidget == NULL) {
- if (si)
- iteratorStack->pop ();
- } else
- iteratorStack->backward ();
-
- DBG_IF_RTFL {
- misc::StringBuffer sb;
- iteratorStack->intoStringBuffer (&sb);
- DBG_OBJ_MSGF ("events", 2, "final iteratorStack: %s", sb.getChars ());
- }
-
- DBG_OBJ_LEAVE ();
- return widget;
-}
-
-Widget *Widget::getWidgetAtPointToplevel (int x, int y)
-{
- assert (parent == NULL);
-
- StackingIteratorStack iteratorStack;
- Widget *interruptedWidget = NULL;
- Widget *widget =
- getWidgetAtPointTotal (x, y, &iteratorStack, &interruptedWidget);
-
- // Everything should be finished at this point.
- assert (interruptedWidget == NULL);
-
- return widget;
+ Widget *widgetAtPoint = getWidgetAtPoint (x, y, context);
+ context->addWidgetProcessedAsInterruption (this);
+ return widgetAtPoint;
}
-
void Widget::setParent (Widget *parent)
{
DBG_OBJ_ENTER ("construct", 0, "setParent", "%p", parent);
diff --git a/dw/widget.hh b/dw/widget.hh
index c8a57250..c8431f97 100644
--- a/dw/widget.hh
+++ b/dw/widget.hh
@@ -426,6 +426,11 @@ public:
inline style::Style *getStyle () { return style; }
/** \todo I do not like this. */
inline Allocation *getAllocation () { return &allocation; }
+ inline bool inAllocation (int x, int y) {
+ return wasAllocated () && x >= allocation.x && y >= allocation.y &&
+ x <= allocation.x + allocation.width &&
+ y <= allocation.y + getHeight ();
+ }
inline int boxOffsetX ()
{ return extraSpace.left + getStyle()->boxOffsetX (); }
@@ -475,12 +480,9 @@ public:
void drawInterruption (View *view, Rectangle *area, DrawingContext *context);
virtual Widget *getWidgetAtPoint (int x, int y,
- StackingIteratorStack *iteratorStack,
- Widget **interruptedWidget);
- Widget *getWidgetAtPointTotal (int x, int y,
- StackingIteratorStack *iteratorStack,
- Widget **interruptedWidget);
- Widget *getWidgetAtPointToplevel (int x, int y);
+ GettingWidgetAtPointContext *context);
+ Widget *getWidgetAtPointInterrupted (int x, int y,
+ GettingWidgetAtPointContext *context);
bool buttonPress (EventButton *event);
bool buttonRelease (EventButton *event);