diff options
author | Sebastian Geerken <devnull@localhost> | 2012-09-24 21:47:19 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2012-09-24 21:47:19 +0200 |
commit | b1ea92cce6ef995c429236f34e6164ead811ad9b (patch) | |
tree | 320da65ed9ed3cc7e8c01b4ac09b8f5ecf18ca98 | |
parent | b38df648b637a221bd6d9107de433cbe8107c276 (diff) |
Split up content type WIDGET; removed FLOAT_REF.
-rw-r--r-- | dw/findtext.cc | 4 | ||||
-rw-r--r-- | dw/iterator.cc | 36 | ||||
-rw-r--r-- | dw/iterator.hh | 2 | ||||
-rw-r--r-- | dw/table.cc | 14 | ||||
-rw-r--r-- | dw/textblock.cc | 19 | ||||
-rw-r--r-- | dw/textblock_linebreaking.cc | 29 | ||||
-rw-r--r-- | dw/types.hh | 25 | ||||
-rw-r--r-- | dw/widget.cc | 4 |
8 files changed, 83 insertions, 50 deletions
diff --git a/dw/findtext.cc b/dw/findtext.cc index 9793db91..9e9076dc 100644 --- a/dw/findtext.cc +++ b/dw/findtext.cc @@ -91,7 +91,7 @@ FindtextState::Result FindtextState::search (const char *key, bool caseSens, if (iterator) delete iterator; - iterator = new CharIterator (widget); + iterator = new CharIterator (widget, true); if (backwards) { /* Go to end */ @@ -123,7 +123,7 @@ FindtextState::Result FindtextState::search (const char *key, bool caseSens, } else { // Nothing found anymore, reset the state for the next trial. delete iterator; - iterator = new CharIterator (widget); + iterator = new CharIterator (widget, true); if (backwards) { /* Go to end */ while (iterator->next ()) ; diff --git a/dw/iterator.cc b/dw/iterator.cc index e9431e9b..73beca6f 100644 --- a/dw/iterator.cc +++ b/dw/iterator.cc @@ -343,7 +343,7 @@ Iterator *DeepIterator::searchDownward (Iterator *it, Content::Type mask, //DEBUG_MSG (1, "%*smoving down (%swards) from %s\n", // indent, "", from_end ? "back" : "for", a_Dw_iterator_text (it)); - assert (it->getContent()->type == Content::WIDGET); + assert (it->getContent()->type & Content::ANY_WIDGET); it2 = it->getContent()->widget->iterator (mask, fromEnd); if (it2 == NULL) { @@ -356,7 +356,7 @@ Iterator *DeepIterator::searchDownward (Iterator *it, Content::Type mask, //DEBUG_MSG (1, "%*sexamining %s\n", // indent, "", a_Dw_iterator_text (it2)); - if (it2->getContent()->type == Content::WIDGET) { + if (it2->getContent()->type & Content::ANY_WIDGET) { // Another widget. Search in it downwards. it3 = searchDownward (it2, mask, fromEnd); if (it3 != NULL) { @@ -390,11 +390,11 @@ Iterator *DeepIterator::searchSideward (Iterator *it, Content::Type mask, //DEBUG_MSG (1, "%*smoving %swards from %s\n", // indent, "", from_end ? "back" : "for", a_Dw_iterator_text (it)); - assert (it->getContent()->type == Content::WIDGET); + assert (it->getContent()->type & Content::ANY_WIDGET); it2 = it->cloneIterator (); while (fromEnd ? it2->prev () : it2->next ()) { - if (it2->getContent()->type == Content::WIDGET) { + if (it2->getContent()->type & Content::ANY_WIDGET) { // Search downwards in this widget. it3 = searchDownward (it2, mask, fromEnd); if (it3 != NULL) { @@ -422,7 +422,7 @@ Iterator *DeepIterator::searchSideward (Iterator *it, Content::Type mask, if (!it2->next ()) misc::assertNotReached (); - if (it2->getContent()->type == Content::WIDGET && + if (it2->getContent()->type & Content::ANY_WIDGET && it2->getContent()->widget == it->getWidget ()) { it3 = searchSideward (it2, mask, fromEnd); it2->unref (); @@ -467,7 +467,7 @@ DeepIterator::DeepIterator (Iterator *it) // If it points to a widget, find a near non-widget content, // since an DeepIterator should never return widgets. - if (it->getContent()->type == Content::WIDGET) { + if (it->getContent()->type & Content::ANY_WIDGET) { Iterator *it2; // The second argument of searchDownward is actually a matter of @@ -505,7 +505,7 @@ DeepIterator::DeepIterator (Iterator *it) bool hasNext = it->next(); assert (hasNext); - if (it->getContent()->type == Content::WIDGET && + if (it->getContent()->type & Content::ANY_WIDGET && it->getContent()->widget == w) break; } @@ -577,7 +577,7 @@ bool DeepIterator::next () Iterator *it = stack.getTop (); if (it->next ()) { - if (it->getContent()->type == Content::WIDGET) { + 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)); return next (); @@ -610,7 +610,7 @@ bool DeepIterator::prev () Iterator *it = stack.getTop (); if (it->prev ()) { - if (it->getContent()->type == Content::WIDGET) { + 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)); return prev (); @@ -642,9 +642,21 @@ CharIterator::CharIterator () it = NULL; } -CharIterator::CharIterator (Widget *widget) -{ - Iterator *i = widget->iterator (Content::SELECTION_CONTENT, false); +/** + * \brief ... + * + * If followReferences is true, only the reference are followed, when + * the container and generator for a widget is different. If false, + * only the container is followed. + */ +CharIterator::CharIterator (Widget *widget, bool followReferences) +{ + Content::Type widgetMask = (Content::Type) + (Content::WIDGET_IN_FLOW | + (followReferences ? Content::WIDGET_OOF_REF : Content::WIDGET_OOF_CONT)); + Iterator *i = + widget->iterator ((Content::Type) + (Content::SELECTION_CONTENT | widgetMask), false); it = new DeepIterator (i); i->unref (); ch = START; diff --git a/dw/iterator.hh b/dw/iterator.hh index 838d66a1..222a05c0 100644 --- a/dw/iterator.hh +++ b/dw/iterator.hh @@ -230,7 +230,7 @@ private: CharIterator (); public: - CharIterator (Widget *widget); + CharIterator (Widget *widget, bool followReferences); ~CharIterator (); lout::object::Object *clone(); diff --git a/dw/table.cc b/dw/table.cc index c21b7a09..c4108e47 100644 --- a/dw/table.cc +++ b/dw/table.cc @@ -1103,7 +1103,7 @@ Table::TableIterator::TableIterator (Table *table, else if (index >= table->children->size ()) content.type = core::Content::END; else { - content.type = core::Content::WIDGET; + content.type = core::Content::WIDGET_IN_FLOW; content.widget = table->children->get(index)->cell.widget; } } @@ -1125,8 +1125,8 @@ bool Table::TableIterator::next () if (content.type == core::Content::END) return false; - // tables only contain widgets: - if ((getMask() & core::Content::WIDGET) == 0) { + // tables only contain widgets (in flow): + if ((getMask() & core::Content::WIDGET_IN_FLOW) == 0) { content.type = core::Content::END; return false; } @@ -1140,7 +1140,7 @@ bool Table::TableIterator::next () } while (table->children->get(index) == NULL || table->children->get(index)->type != Child::CELL); - content.type = core::Content::WIDGET; + content.type = core::Content::WIDGET_IN_FLOW; content.widget = table->children->get(index)->cell.widget; return true; } @@ -1152,8 +1152,8 @@ bool Table::TableIterator::prev () if (content.type == core::Content::START) return false; - // tables only contain widgets: - if ((getMask() & core::Content::WIDGET) == 0) { + // tables only contain widgets (in flow): + if ((getMask() & core::Content::WIDGET_IN_FLOW) == 0) { content.type = core::Content::START; return false; } @@ -1167,7 +1167,7 @@ bool Table::TableIterator::prev () } while (table->children->get(index) == NULL || table->children->get(index)->type != Child::CELL); - content.type = core::Content::WIDGET; + content.type = core::Content::WIDGET_IN_FLOW; content.widget = table->children->get(index)->cell.widget; return true; } diff --git a/dw/textblock.cc b/dw/textblock.cc index 3e06b4ab..30c8e731 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -108,8 +108,9 @@ Textblock::~Textblock () for (int i = 0; i < words->size(); i++) { Word *word = words->getRef (i); - if (word->content.type == core::Content::WIDGET) + if (word->content.type == core::Content::WIDGET_IN_FLOW) delete word->content.widget; + /** \todo Widget references? What about texts? */ word->style->unref (); word->spaceStyle->unref (); } @@ -193,7 +194,7 @@ void Textblock::sizeRequestImpl (core::Requisition *requisition) */ void Textblock::getWordExtremes (Word *word, core::Extremes *extremes) { - if (word->content.type == core::Content::WIDGET) { + if (word->content.type == core::Content::WIDGET_IN_FLOW) { if (word->content.widget->usesHints ()) word->content.widget->getExtremes (extremes); else { @@ -365,7 +366,7 @@ void Textblock::sizeAllocateImpl (core::Allocation *allocation) redrawY = misc::min (redrawY, lineYOffsetWidget (line)); } - if (word->content.type == core::Content::WIDGET) { + if (word->content.type == core::Content::WIDGET_IN_FLOW) { /** \todo Justification within the line is done here. */ childAllocation.x = xCursor + allocation->x; /* align=top: @@ -1176,10 +1177,10 @@ void Textblock::drawLine (Line *line, core::View *view, core::Rectangle *area) if (xWidget + word->size.width + word->effSpace >= area->x) { if (word->content.type == core::Content::TEXT || - word->content.type == core::Content::WIDGET) { + word->content.type == core::Content::WIDGET_IN_FLOW) { if (word->size.width > 0) { - if (word->content.type == core::Content::WIDGET) { + if (word->content.type == core::Content::WIDGET_IN_FLOW) { core::Widget *child = word->content.widget; core::Rectangle childArea; @@ -1633,7 +1634,7 @@ void Textblock::addWidget (core::Widget *widget, core::style::Style *style) calcWidgetSize (widget, &size); word = addWord (size.width, size.ascent, size.descent, false, style); - word->content.type = core::Content::WIDGET; + word->content.type = core::Content::WIDGET_IN_FLOW; word->content.widget = widget; //DBG_OBJ_ARRSET_PTR (page, "words.%d.content.widget", words->size() - 1, @@ -1820,7 +1821,7 @@ void Textblock::addParbreak (int space, core::style::Style *style) Textblock *textblock2 = (Textblock*)widget->getParent (); int index = textblock2->hasListitemValue ? 1 : 0; bool isfirst = (textblock2->words->getRef(index)->content.type - == core::Content::WIDGET + == core::Content::WIDGET_IN_FLOW && textblock2->words->getRef(index)->content.widget == widget); if (!isfirst) { @@ -1924,7 +1925,7 @@ core::Widget *Textblock::getWidgetAtPoint(int x, int y, int level) for (wordIndex = line->firstWord; wordIndex <= line->lastWord;wordIndex++) { Word *word = words->getRef (wordIndex); - if (word->content.type == core::Content::WIDGET) { + if (word->content.type == core::Content::WIDGET_IN_FLOW) { core::Widget * childAtPoint; childAtPoint = word->content.widget->getWidgetAtPoint (x, y, level + 1); @@ -2011,7 +2012,7 @@ void Textblock::changeLinkColor (int link, int newColor) old_style->unref(); break; } - case core::Content::WIDGET: + case core::Content::WIDGET_IN_FLOW: { core::Widget *widget = word->content.widget; styleAttrs = *widget->getStyle(); styleAttrs.color = core::style::Color::create (layout, diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc index b11c9cd1..41dac336 100644 --- a/dw/textblock_linebreaking.cc +++ b/dw/textblock_linebreaking.cc @@ -212,8 +212,14 @@ void Textblock::printWord (Word *word) case core::Content::TEXT: printf ("\"%s\"", word->content.text); break; - case core::Content::WIDGET: - printf ("<widget: %p>\n", word->content.widget); + case core::Content::WIDGET_IN_FLOW: + printf ("<widget in flow: %p>\n", word->content.widget); + break; + case core::Content::WIDGET_OOF_REF: + printf ("<widget oof ref: %p>\n", word->content.widget); + break; + case core::Content::WIDGET_OOF_CONT: + printf ("<widge oof cont: %p>\n", word->content.widget); break; case core::Content::BREAK: printf ("<break>\n"); @@ -706,7 +712,7 @@ void Textblock::accumulateWordForLine (int lineIndex, int wordIndex) len += word->style->font->ascent / 3; line->contentDescent = misc::max (line->contentDescent, len); - if (word->content.type == core::Content::WIDGET) { + if (word->content.type == core::Content::WIDGET_IN_FLOW) { int collapseMarginTop = 0; line->marginDescent = @@ -829,7 +835,7 @@ void Textblock::initLine1Offset (int wordIndex) } else { int indent = 0; - if (word->content.type == core::Content::WIDGET && + if (word->content.type == core::Content::WIDGET_IN_FLOW && word->content.widget->blockLevel() == true) { /* don't use text-indent when nesting blocks */ } else { @@ -920,12 +926,9 @@ void Textblock::rewrap () for (int i = firstWord; i < words->size (); i++) { Word *word = words->getRef (i); - - if (word->content.type == core::Content::WIDGET && - // ABC - word->content.widget->parentRef == - (1 | (dw::core::style::FLOAT_NONE << 1) | ((lines->size () - 1) << 3))) - calcWidgetSize (word->content.widget, &word->size); + + if (word->content.type == core::Content::WIDGET_IN_FLOW) + calcWidgetSize (word->content.widget, &word->size); wordWrap (i, false); @@ -934,9 +937,9 @@ void Textblock::rewrap () // changed, so getRef() must be called again. word = words->getRef (i); - if (word->content.type == core::Content::WIDGET) { - word->content.widget->parentRef = lines->size () - 1; - } + if (word->content.type == core::Content::WIDGET_IN_FLOW) + word->content.widget->parentRef = + OutOfFlowMgr::createRefNormalFlow (lines->size () - 1); } /* Next time, the page will not have to be rewrapped. */ diff --git a/dw/types.hh b/dw/types.hh index abed38e6..61136673 100644 --- a/dw/types.hh +++ b/dw/types.hh @@ -188,12 +188,27 @@ struct Content START = 1 << 0, END = 1 << 1, TEXT = 1 << 2, - WIDGET = 1 << 3, - BREAK = 1 << 4, - FLOAT_REF = 1 << 6, /** \todo A bit ugly. */ + + /** \brief widget in normal flow, so that _this_ widget + (containing this content) is both container (parent) and + generator */ + WIDGET_IN_FLOW = 1 << 3, + + /** \brief widget out of flow (OOF); _this_ widget (containing + this content) is only the container (parent), but _not_ + generator */ + WIDGET_OOF_CONT, + + /** \brief reference to a widget out of flow (OOF); _this_ + widget (containing this content) is only the generator + (parent), but _not_ container */ + WIDGET_OOF_REF = 1 << 4, + + BREAK = 1 << 5, ALL = 0xff, - REAL_CONTENT = 0xff ^ (START | END | FLOAT_REF), - SELECTION_CONTENT = TEXT | WIDGET | BREAK + REAL_CONTENT = 0xff ^ (START | END), + SELECTION_CONTENT = TEXT | BREAK, // WIDGET_* must be set additionally + ANY_WIDGET = WIDGET_IN_FLOW | WIDGET_OOF_CONT | WIDGET_OOF_REF, }; /* Content is embedded in struct Word therefore we diff --git a/dw/widget.cc b/dw/widget.cc index 193c5aac..3a3eebbc 100644 --- a/dw/widget.cc +++ b/dw/widget.cc @@ -525,7 +525,9 @@ Widget *Widget::getWidgetAtPoint (int x, int y, int level) * is such a child, it is returned. Otherwise, this widget is returned. */ childAtPoint = NULL; - it = iterator (Content::WIDGET, false); + it = iterator ((Content::Type) + (Content::WIDGET_IN_FLOW | Content::WIDGET_OOF_CONT), + false); while (childAtPoint == NULL && it->next ()) childAtPoint = it->getContent()->widget->getWidgetAtPoint (x, y, |