diff options
author | Sebastian Geerken <devnull@localhost> | 2016-04-02 22:48:21 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2016-04-02 22:48:21 +0200 |
commit | 70b9f2b70d9f0c0f48d2ae649023ea3ae5271367 (patch) | |
tree | 41c998067cde197225621171b0ab096734e5812e | |
parent | 639fbbfd350e32ab128482078d83a05a3f208983 (diff) |
Content with type WIDGET_OOF_REF now refers to new class WidgetReference.
-rw-r--r-- | dw/iterator.cc | 10 | ||||
-rw-r--r-- | dw/textblock.cc | 23 | ||||
-rw-r--r-- | dw/textblock.hh | 7 | ||||
-rw-r--r-- | dw/textblock_linebreaking.cc | 20 | ||||
-rw-r--r-- | dw/types.cc | 6 | ||||
-rw-r--r-- | dw/types.hh | 15 |
6 files changed, 54 insertions, 27 deletions
diff --git a/dw/iterator.cc b/dw/iterator.cc index dbb779f6..51b49125 100644 --- a/dw/iterator.cc +++ b/dw/iterator.cc @@ -362,7 +362,7 @@ Iterator *DeepIterator::searchDownward (Iterator *it, Content::Type mask, // indent, "", from_end ? "back" : "for", a_Dw_iterator_text (it)); assert (it->getContent()->type & Content::ANY_WIDGET); - it2 = it->getContent()->widget->iterator (mask, fromEnd); + it2 = it->getContent()->getWidget()->iterator (mask, fromEnd); if (it2 == NULL) { // Moving downwards failed. @@ -442,7 +442,7 @@ Iterator *DeepIterator::searchSideward (Iterator *it, Content::Type mask, misc::assertNotReached (); if (it2->getContent()->type & Content::ANY_WIDGET && - it2->getContent()->widget == it->getWidget ()) { + it2->getContent()->getWidget () == it->getWidget ()) { it3 = searchSideward (it2, mask, fromEnd); it2->unref (); //DEBUG_MSG (1, "%*smoving %swards succeeded: %s\n", @@ -571,7 +571,7 @@ DeepIterator::DeepIterator (Iterator *it) assert (hasNext); if (it->getContent()->type & Content::ANY_WIDGET && - it->getContent()->widget == w) + it->getContent()->getWidget () == w) break; } @@ -675,7 +675,7 @@ bool DeepIterator::next () if (it->next ()) { if (it->getContent()->type & Content::ANY_WIDGET) { // Widget: new iterator on stack, to search in this widget. - stack.push (it->getContent()->widget->iterator (mask, false)); + stack.push (it->getContent()->getWidget()->iterator (mask, false)); return next (); } else { // Simply return the content of the iterartor. @@ -708,7 +708,7 @@ bool DeepIterator::prev () if (it->prev ()) { if (it->getContent()->type & Content::ANY_WIDGET) { // Widget: new iterator on stack, to search in this widget. - stack.push (it->getContent()->widget->iterator (mask, true)); + stack.push (it->getContent()->getWidget()->iterator (mask, true)); return prev (); } else { // Simply return the content of the iterartor. diff --git a/dw/textblock.cc b/dw/textblock.cc index 514d3e93..fb7c141c 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -1748,7 +1748,8 @@ void Textblock::drawLevel (core::View *view, core::Rectangle *area, for (int wordIndex = 0; wordIndex < words->size (); wordIndex++) { Word *word = words->getRef (wordIndex); if (word->content.type == core::Content::WIDGET_OOF_REF && - getOOFMIndex (word->content.widget) == oofmIndex && + getOOFMIndex (word->content.widgetReference->widget) + == oofmIndex && doesWidgetOOFInterruptDrawing (word->content.widget)) word->content.widget->drawInterruption (view, area, context); } @@ -1805,7 +1806,9 @@ void Textblock::cleanupWord (int wordNo) if (word->content.type == core::Content::WIDGET_IN_FLOW) delete word->content.widget; - /** \todo Widget references? What about texts? */ + if (word->content.type == core::Content::WIDGET_OOF_REF) + delete word->content.widgetReference; + /** \todo What about texts? */ removeWordImgRenderer (wordNo); removeSpaceImgRenderer (wordNo); @@ -2421,7 +2424,7 @@ void Textblock::addWidget (core::Widget *widget, core::style::Style *style) oofm->calcWidgetRefSize (widget, &size); Word *word = addWord (size.width, size.ascent, size.descent, 0, style); word->content.type = core::Content::WIDGET_OOF_REF; - word->content.widget = widget; + word->content.widgetReference = new core::WidgetReference (widget); // After a out-of-flow reference, breaking is allowed. (This avoids some // problems with breaking near float definitions.) @@ -2835,11 +2838,13 @@ core::Widget *Textblock::getWidgetAtPointLevel (int x, int y, int level, 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)) + getOOFMIndex (word->content.widgetReference->widget) + == oofmIndex && + doesWidgetOOFInterruptDrawing (word->content.widgetReference + ->widget)) widgetAtPoint = - word->content.widget->getWidgetAtPointInterrupted (x, y, - context); + word->content.widgetReference->widget + ->getWidgetAtPointInterrupted (x, y, context); } } break; @@ -3022,7 +3027,7 @@ void Textblock::borderChanged (int oofmIndex, int y, Widget *widgetOOF) !found && wordIndex < words->size(); wordIndex++) { Word *word = words->getRef (wordIndex); if (word->content.type == core::Content::WIDGET_OOF_REF && - word->content.widget == widgetOOF) + word->content.widgetReference->widget == widgetOOF) found = true; } @@ -3088,7 +3093,7 @@ void Textblock::borderChanged (int oofmIndex, int y, Widget *widgetOOF) !found && wordIndex <= line->lastWord; wordIndex++) { Word *word = words->getRef (wordIndex); if (word->content.type == core::Content::WIDGET_OOF_REF && - word->content.widget == widgetOOF) { + word->content.widgetReference->widget == widgetOOF) { found = true; // Correct only by smaller values (case (1) above): realWrapLineIndex = diff --git a/dw/textblock.hh b/dw/textblock.hh index 91ecbd7a..f78be2df 100644 --- a/dw/textblock.hh +++ b/dw/textblock.hh @@ -940,9 +940,11 @@ public: words->getRef(n)->content.widget); \ break; \ case ::dw::core::Content::WIDGET_OOF_REF: \ + /* It would be nice to show also parentRef. */ \ DBG_OBJ_ARRATTRSET_SYM ("words", n, "type", "WIDGET_OOF_REF"); \ DBG_OBJ_ARRATTRSET_PTR ("words", n, "text/widget/breakSpace", \ - words->getRef(n)->content.widget); \ + words->getRef(n) \ + ->content.widgetReference->widget); \ break; \ case ::dw::core::Content::BREAK: \ DBG_OBJ_ARRATTRSET_SYM ("words", n, "type", "BREAK"); \ @@ -982,8 +984,9 @@ public: words->getRef(n)->content.widget); \ break; \ case ::dw::core::Content::WIDGET_OOF_REF: \ + /* It would be nice to show also parentRef. */ \ DBG_OBJ_MSGF (aspect, prio, prefix "WIDGET_OOF_REF / %p" suffix, \ - words->getRef(n)->content.widget); \ + words->getRef(n)->content.widgetReference->widget); \ break; \ case ::dw::core::Content::BREAK: \ DBG_OBJ_MSGF (aspect, prio, prefix "BREAK / %d" suffix, \ diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc index ab4e3eab..1ef4b932 100644 --- a/dw/textblock_linebreaking.cc +++ b/dw/textblock_linebreaking.cc @@ -463,7 +463,7 @@ Textblock::Line *Textblock::addLine (int firstWord, int lastWord, word->spaceImgRenderer->setData (xWidget, lines->size () - 1); if (word->content.type == core::Content::WIDGET_OOF_REF) { - Widget *widget = word->content.widget; + Widget *widget = word->content.widgetReference->widget; int oofmIndex = getWidgetOOFIndex (widget); oof::OutOfFlowMgr *oofm = searchOutOfFlowMgr (oofmIndex); // See also Textblock::sizeAllocate, and notes there about @@ -737,10 +737,9 @@ int Textblock::wrapWordInFlow (int wordIndex, bool wrapAll) core::Content *content = &(words->getRef(i)->content); if (content->type == core::Content::WIDGET_OOF_REF) { for (int j = 0; newFloatPos == -1 && j < NUM_OOFM; j++) { - if ((searchOutOfFlowMgr(j)->affectsLeftBorder(content - ->widget) || - searchOutOfFlowMgr(j)->affectsRightBorder (content - ->widget))) + Widget *widget = content->widgetReference->widget; + if ((searchOutOfFlowMgr(j)->affectsLeftBorder(widget) || + searchOutOfFlowMgr(j)->affectsRightBorder (widget))) newFloatPos = i; } } @@ -760,7 +759,8 @@ int Textblock::wrapWordInFlow (int wordIndex, bool wrapAll) lastFloatPos = newFloatPos; - Widget *widget = words->getRef(lastFloatPos)->content.widget; + Widget *widget = + words->getRef(lastFloatPos)->content.widgetReference->widget; int oofmIndex = getWidgetOOFIndex (widget); oof::OutOfFlowMgr *oofm = searchOutOfFlowMgr (oofmIndex); if (oofm && oofm->mayAffectBordersAtAll ()) { @@ -862,7 +862,7 @@ int Textblock::wrapWordOofRef (int wordIndex, bool wrapAll) wordIndex, wrapAll ? "true" : "false"); Word *word = words->getRef (wordIndex); - Widget *widget = word->content.widget; + Widget *widget = word->content.widgetReference->widget; int yNewLine = yOffsetOfLineToBeCreated (); // Floats, which affect either border, are handled in wrapWordInFlow; this @@ -1920,9 +1920,11 @@ void Textblock::rewrap () case core::Content::WIDGET_OOF_REF: { - int oofmIndex = getOOFMIndex (word->content.widget); + int oofmIndex = + getOOFMIndex (word->content.widgetReference->widget); oof::OutOfFlowMgr *oofm = searchOutOfFlowMgr (oofmIndex); - oofm->calcWidgetRefSize (word->content.widget, &(word->size)); + oofm->calcWidgetRefSize (word->content.widgetReference->widget, + &(word->size)); DBG_SET_WORD_SIZE (i); } break; diff --git a/dw/types.cc b/dw/types.cc index 56af66d1..bd7ff748 100644 --- a/dw/types.cc +++ b/dw/types.cc @@ -299,9 +299,11 @@ void Content::intoStringBuffer(Content *content, misc::StringBuffer *sb) break; case WIDGET_OOF_REF: sb->append ("<widget oof ref: "); - sb->appendPointer (content->widget); + sb->appendPointer (content->widgetReference->widget); sb->append (" ("); - sb->append (content->widget->getClassName()); + sb->append (content->widgetReference->widget->getClassName()); + sb->append (", "); + sb->appendInt (content->widgetReference->parentRef); sb->append (")>"); break; case WIDGET_OOF_CONT: diff --git a/dw/types.hh b/dw/types.hh index 481f4804..ab562a49 100644 --- a/dw/types.hh +++ b/dw/types.hh @@ -185,6 +185,15 @@ struct Extremes int adjustmentWidth; }; +class WidgetReference: public lout::object::Object +{ +public: + Widget *widget; + int parentRef; + + WidgetReference (Widget *widget) { this->widget = widget; } +}; + struct Content { enum Type { @@ -226,6 +235,7 @@ struct Content union { const char *text; Widget *widget; + WidgetReference *widgetReference; int breakSpace; }; @@ -235,6 +245,11 @@ struct Content static void maskIntoStringBuffer(Type mask, lout::misc::StringBuffer *sb); static void print (Content *content); static void printMask (Type mask); + + inline Widget *getWidget () { + assert (type & ANY_WIDGET); + return type == WIDGET_OOF_REF ? widgetReference->widget : widget; + } }; /** |