summaryrefslogtreecommitdiff
path: root/dw/textblock.cc
diff options
context:
space:
mode:
Diffstat (limited to 'dw/textblock.cc')
-rw-r--r--dw/textblock.cc150
1 files changed, 2 insertions, 148 deletions
diff --git a/dw/textblock.cc b/dw/textblock.cc
index f4a53f7f..f0bdf72a 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -2988,155 +2988,9 @@ void Textblock::queueDrawRange (int index1, int index2)
DBG_OBJ_LEAVE ();
}
-void Textblock::borderChanged (int oofmIndex, int y, Widget *widgetOOF)
+void Textblock::updateReference (int ref)
{
- DBG_OBJ_ENTER ("resize", 0, "borderChanged", "%s, %d, %p",
- OOFM_NAME[oofmIndex], y, widgetOOF);
-
- // Calculate the widget coordinate of `y`. Since this method is only called
- // for floats, `findSizeRequestReference` returning `false` means than
- // `sizeRequest` has not been called yet, so queuing is not necessary.
- int yRef;
- if (findSizeRequestReference (oofmIndex, NULL, &yRef)) {
- int yWidget = y - yRef;
- int lineIndex = findLineIndex (yWidget);
- DBG_OBJ_MSGF ("resize", 1, "Line index: %d (of %d).",
- lineIndex, lines->size ());
-
- // Nothing to do at all, when lineIndex >= lines->size (),
- // i. e. the change is below the bottom of this widget.
- if (lineIndex < lines->size ()) {
- int wrapLineIndex;
- if (lineIndex < 0)
- // Rewrap all.
- wrapLineIndex = 0;
- else
- wrapLineIndex = lineIndex;
-
- int realWrapLineIndex = wrapLineIndex;
- // The following two variables are only used for debugging:
- int minWrapLineIndex = wrapLineIndex, maxWrapLineIndex = wrapLineIndex;
-
- if (widgetOOF->getGenerator() == this && lines->size () > 0) {
- bool found = false;
- // Sometimes, the respective word is not yet part of a
- // line. Nothing to do, but because of the assertion below
- // (and also for performace reasons) this should be
- // considered. TODO: Integrate this below.
- for (int wordIndex =
- lines->size() > 0 ? lines->getLastRef()->lastWord + 1 : 0;
- !found && wordIndex < words->size(); wordIndex++) {
- Word *word = words->getRef (wordIndex);
- if (word->content.type == core::Content::WIDGET_OOF_REF &&
- word->content.widgetReference->widget == widgetOOF)
- found = true;
- }
-
- // We search for the line of the float reference. There are
- // two cases when this is not the line corresponsing to y:
- //
- // (1) When the float was moved down, due to collisions with
- // other floats: in this case, the line number gets
- // smaller (since the float reference is before).
- //
- // (2) In some cases, the line number may become larger, due
- // to the per-line optimization of the words: initially,
- // lines->size() - 1 is assigned, but it may happen that
- // the float reference is put into another line.
- //
- // Only in the first case, a correction is neccessary, but a
- // test for the second case is useful. (TODO: I've forgotten
- // why a correction is neccessary.)
- //
- // Searched is done in the following order:
- //
- // - wrapLineIndex,
- // - wrapLineIndex - 1,
- // - wrapLineIndex + 1,
- // - wrapLineIndex - 2,
- // - wrapLineIndex + 2,
- //
- // etc. until either the float reference has been found or
- // all lines have been searched (the latter triggers an
- // abortion).
-
- bool exceedsBeginning = false, exceedsEnd = false;
- for (int i = 0; !found; i++) {
- bool exceeds;
- int lineIndex2;
- if (i % 2 == 0) {
- // even: +0, +1, +2, ...
- lineIndex2 = realWrapLineIndex + i / 2;
- if (i > 0)
- exceeds = exceedsEnd = lineIndex2 >= lines->size ();
- else
- exceeds = exceedsEnd = false;
- } else {
- // odd: -1, -2, ...
- lineIndex2 = realWrapLineIndex - (i + 1) / 2;
- exceeds = exceedsBeginning = lineIndex2 < 0;
- }
-
- DBG_OBJ_MSGF ("resize", 2,
- "lineIndex2 = %d (of %d), exceeds = %s, "
- "exceedsBeginning = %s, exceedsEnd = %s",
- lineIndex2, lines->size (),
- exceeds ? "true" : "false",
- exceedsBeginning ? "true" : "false",
- exceedsEnd ? "true" : "false");
-
- if (exceedsBeginning && exceedsEnd)
- break;
-
- if (!exceeds) {
- Line *line = lines->getRef (lineIndex2);
- for (int wordIndex = line->firstWord;
- !found && wordIndex <= line->lastWord; wordIndex++) {
- Word *word = words->getRef (wordIndex);
- if (word->content.type == core::Content::WIDGET_OOF_REF &&
- word->content.widgetReference->widget == widgetOOF) {
- found = true;
- // Correct only by smaller values (case (1) above):
- realWrapLineIndex =
- misc::min (realWrapLineIndex, lineIndex2);
- }
- }
-
- minWrapLineIndex = misc::min (minWrapLineIndex, lineIndex2);
- maxWrapLineIndex = misc::max (maxWrapLineIndex, lineIndex2);
- }
- }
-
- assert (found);
- }
-
- DBG_OBJ_MSGF ("resize", 1,
- "wrapLineIndex: corrected from %d to %d (%d lines "
- "total); searched between %d and %d; this is the GB: %s",
- wrapLineIndex, realWrapLineIndex, lines->size (),
- minWrapLineIndex, maxWrapLineIndex,
- widgetOOF->getGenerator() == this ? "yes" : "no");
-
- queueResize (makeParentRefInFlow (realWrapLineIndex), true);
-
- // Notice that the line no. realWrapLineIndex may not exist yet.
- if (realWrapLineIndex == 0)
- lastWordDrawn = misc::min (lastWordDrawn, -1);
- else
- lastWordDrawn =
- misc::min (lastWordDrawn,
- lines->getRef(realWrapLineIndex - 1)->lastWord);
- DBG_OBJ_SET_NUM ("lastWordDrawn", lastWordDrawn);
-
- // TODO Is the following necessary? Or even useless?
- //redrawY =
- // misc::min (redrawY,
- // lineYOffsetWidget (lines->getRef (realWrapLineIndex)));
- //DBG_OBJ_SET_NUM ("redrawY", redrawY);
- }
- }
-
- DBG_OBJ_LEAVE ();
+ queueResize (ref, false);
}
void Textblock::widgetRefSizeChanged (int externalIndex)