diff options
Diffstat (limited to 'dw')
-rw-r--r-- | dw/Makefile.am | 2 | ||||
-rw-r--r-- | dw/oofawarewidget.cc | 54 | ||||
-rw-r--r-- | dw/oofawarewidget.hh | 29 | ||||
-rw-r--r-- | dw/ooffloatsmgr.cc | 240 | ||||
-rw-r--r-- | dw/ooffloatsmgr.hh | 126 | ||||
-rw-r--r-- | dw/oofposabsmgr.cc | 26 | ||||
-rw-r--r-- | dw/oofposabsmgr.hh | 10 | ||||
-rw-r--r-- | dw/oofposfixedmgr.cc | 12 | ||||
-rw-r--r-- | dw/oofposfixedmgr.hh | 10 | ||||
-rw-r--r-- | dw/oofpositionedmgr.cc | 130 | ||||
-rw-r--r-- | dw/oofpositionedmgr.hh | 65 | ||||
-rw-r--r-- | dw/outofflowmgr.cc | 2 | ||||
-rw-r--r-- | dw/outofflowmgr.hh | 56 | ||||
-rw-r--r-- | dw/textblock.cc | 7 | ||||
-rw-r--r-- | dw/textblock.hh | 5 |
15 files changed, 444 insertions, 330 deletions
diff --git a/dw/Makefile.am b/dw/Makefile.am index a90fa20f..6383fc74 100644 --- a/dw/Makefile.am +++ b/dw/Makefile.am @@ -69,6 +69,8 @@ libDw_widgets_a_SOURCES = \ image.hh \ listitem.cc \ listitem.hh \ + oofawarewidget.cc \ + oofawarewidget.hh \ ooffloatsmgr.cc \ ooffloatsmgr.hh \ oofposabsmgr.cc \ diff --git a/dw/oofawarewidget.cc b/dw/oofawarewidget.cc new file mode 100644 index 00000000..f2a85563 --- /dev/null +++ b/dw/oofawarewidget.cc @@ -0,0 +1,54 @@ +/* + * Dillo Widget + * + * Copyright 2014 Sebastian Geerken <sgeerken@dillo.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "oofawarewidget.hh" + +using namespace lout::misc; + +namespace dw { + +namespace oof { + +void OOFAwareWidget::borderChanged (int y, Widget *vloat) +{ + assertNotReached (); +} + +void OOFAwareWidget::oofSizeChanged (bool extremesChanged) +{ + DBG_OBJ_ENTER ("resize", 0, "oofSizeChanged", "%s", + extremesChanged ? "true" : "false"); + queueResize (-1, extremesChanged); + + // Extremes changes may become also relevant for the children. + if (extremesChanged) + containerSizeChanged (); + + DBG_OBJ_LEAVE (); +} + +int OOFAwareWidget::getLineBreakWidth () +{ + assertNotReached (); + return 0; +} + +} // namespace oof + +} // namespace dw diff --git a/dw/oofawarewidget.hh b/dw/oofawarewidget.hh new file mode 100644 index 00000000..bf13958d --- /dev/null +++ b/dw/oofawarewidget.hh @@ -0,0 +1,29 @@ +#ifndef __DW_OOFAWAREWIDGET_HH__ +#define __DW_OOFAWAREWIDGET_HH__ + +#include "core.hh" + +namespace dw { + +namespace oof { + +/** + * \brief Base class for widgets which can act as container and + * generator for widgets out of flow. + * + * (Perhaps it should be diffenciated between the two roles, container + * and generator, but this would make multiple inheritance necessary.) + */ +class OOFAwareWidget: public core::Widget +{ +public: + virtual void borderChanged (int y, core::Widget *vloat); + virtual void oofSizeChanged (bool extremesChanged); + virtual int getLineBreakWidth (); // Should perhaps be renamed. +}; + +} // namespace oof + +} // namespace dw + +#endif // __DW_OOFAWAREWIDGET_HH__ diff --git a/dw/ooffloatsmgr.cc b/dw/ooffloatsmgr.cc index 762fea1b..1dfdecf7 100644 --- a/dw/ooffloatsmgr.cc +++ b/dw/ooffloatsmgr.cc @@ -18,9 +18,11 @@ */ #include "ooffloatsmgr.hh" -#include "textblock.hh" +#include "oofawarewidget.hh" #include "../lout/debug.hh" +#include <limits.h> + using namespace lout::object; using namespace lout::container::typed; using namespace lout::misc; @@ -62,8 +64,8 @@ void OOFFloatsMgr::WidgetInfo::update (bool wasAllocated, int xCB, int yCB, // ---------------------------------------------------------------------- OOFFloatsMgr::Float::Float (OOFFloatsMgr *oofm, Widget *widget, - Textblock *generatingBlock, int externalIndex) : - WidgetInfo (oofm, widget) + OOFAwareWidget *generatingBlock, int externalIndex) + : WidgetInfo (oofm, widget) { this->generatingBlock = generatingBlock; this->externalIndex = externalIndex; @@ -134,7 +136,7 @@ void OOFFloatsMgr::Float::intoStringBuffer(StringBuffer *sb) sb->append (" }"); } -bool OOFFloatsMgr::Float::covers (Textblock *textblock, int y, int h) +bool OOFFloatsMgr::Float::covers (OOFAwareWidget *textblock, int y, int h) { DBG_OBJ_ENTER_O ("border", 0, getOOFFloatsMgr (), "covers", "%p, %d, %d [vloat: %p]", @@ -286,8 +288,8 @@ int OOFFloatsMgr::Float::CompareGBAndExtIndex::compare (Object *o1, Object *o2) "(a) generating blocks equal => %d - %d = %d", f1->externalIndex, f2->externalIndex, r); } else { - TBInfo *t1 = oofm->getTextblock (f1->generatingBlock), - *t2 = oofm->getTextblock (f2->generatingBlock); + TBInfo *t1 = oofm->getOOFAwareWidget (f1->generatingBlock), + *t2 = oofm->getOOFAwareWidget (f2->generatingBlock); bool rdef = false; for (TBInfo *t = t1; t != NULL; t = t->parent) @@ -297,8 +299,8 @@ int OOFFloatsMgr::Float::CompareGBAndExtIndex::compare (Object *o1, Object *o2) DBG_OBJ_MSGF_O ("border", 2, oofm, "(b) %p is an achestor of %p; direct child is " "%p (%d) => %d - %d = %d\n", - t2->getTextblock (), t1->getTextblock (), - t->getTextblock (), t->parentExtIndex, + t2->getOOFAwareWidget (), t1->getOOFAwareWidget (), + t->getOOFAwareWidget (), t->parentExtIndex, t->parentExtIndex, f2->externalIndex, r); } @@ -309,8 +311,8 @@ int OOFFloatsMgr::Float::CompareGBAndExtIndex::compare (Object *o1, Object *o2) DBG_OBJ_MSGF_O ("border", 2, oofm, "(c) %p is an achestor of %p; direct child is %p " "(%d) => %d - %d = %d\n", - t1->getTextblock (), t2->getTextblock (), - t->getTextblock (), t->parentExtIndex, + t1->getOOFAwareWidget (), t2->getOOFAwareWidget (), + t->getOOFAwareWidget (), t->parentExtIndex, f1->externalIndex, t->parentExtIndex, r); } @@ -326,7 +328,7 @@ int OOFFloatsMgr::Float::CompareGBAndExtIndex::compare (Object *o1, Object *o2) return r; } -int OOFFloatsMgr::SortedFloatsVector::findFloatIndex (Textblock *lastGB, +int OOFFloatsMgr::SortedFloatsVector::findFloatIndex (OOFAwareWidget *lastGB, int lastExtIndex) { DBG_OBJ_ENTER_O ("border", 0, oofm, "findFloatIndex", "%p, %d", @@ -353,12 +355,12 @@ int OOFFloatsMgr::SortedFloatsVector::findFloatIndex (Textblock *lastGB, //printf ("[%p] findFloatIndex (%p, %d) => i = %d, r = %d (size = %d); " // "in %s list %p on the %s side\n", - // oofm->containingBlock, lastGB, lastExtIndex, i, r, size (), + // oofm->container, lastGB, lastExtIndex, i, r, size (), // type == GB ? "GB" : "CB", this, side == LEFT ? "left" : "right"); //for (int i = 0; i < size (); i++) { // Float *f = get(i); - // TBInfo *t = oofm->getTextblock(f->generatingBlock); + // TBInfo *t = oofm->getOOFAwareWidget(f->generatingBlock); // printf (" %d: (%p [%d, %p], %d)\n", i, f->generatingBlock, // t->index, t->parent ? t->parent->textblock : NULL, // get(i)->externalIndex); @@ -369,7 +371,7 @@ int OOFFloatsMgr::SortedFloatsVector::findFloatIndex (Textblock *lastGB, return r; } -int OOFFloatsMgr::SortedFloatsVector::find (Textblock *textblock, int y, +int OOFFloatsMgr::SortedFloatsVector::find (OOFAwareWidget *textblock, int y, int start, int end) { DBG_OBJ_ENTER_O ("border", 0, oofm, "find", "%p, %d, %d, %d", @@ -387,9 +389,9 @@ int OOFFloatsMgr::SortedFloatsVector::find (Textblock *textblock, int y, return result; } -int OOFFloatsMgr::SortedFloatsVector::findFirst (Textblock *textblock, +int OOFFloatsMgr::SortedFloatsVector::findFirst (OOFAwareWidget *textblock, int y, int h, - Textblock *lastGB, + OOFAwareWidget *lastGB, int lastExtIndex, int *lastReturn) { @@ -463,7 +465,7 @@ void OOFFloatsMgr::SortedFloatsVector::put (Float *vloat) vloat->setIndex (type, size() - 1); } -OOFFloatsMgr::TBInfo::TBInfo (OOFFloatsMgr *oofm, Textblock *textblock, +OOFFloatsMgr::TBInfo::TBInfo (OOFFloatsMgr *oofm, OOFAwareWidget *textblock, TBInfo *parent, int parentExtIndex) : WidgetInfo (oofm, textblock) { @@ -493,11 +495,11 @@ void OOFFloatsMgr::TBInfo::updateAllocation () DBG_OBJ_LEAVE_O (getWidget ()); } -OOFFloatsMgr::OOFFloatsMgr (Textblock *containingBlock) +OOFFloatsMgr::OOFFloatsMgr (OOFAwareWidget *container) { DBG_OBJ_CREATE ("dw::OOFFloatsMgr"); - this->containingBlock = (Textblock*)containingBlock; + this->container = (OOFAwareWidget*)container; leftFloatsCB = new SortedFloatsVector (this, LEFT, CB); rightFloatsCB = new SortedFloatsVector (this, RIGHT, CB); @@ -514,16 +516,16 @@ OOFFloatsMgr::OOFFloatsMgr (Textblock *containingBlock) floatsByWidget = new HashTable <TypedPointer <Widget>, Float> (true, false); tbInfos = new Vector<TBInfo> (1, false); - tbInfosByTextblock = - new HashTable <TypedPointer <Textblock>, TBInfo> (true, true); + tbInfosByOOFAwareWidget = + new HashTable <TypedPointer <OOFAwareWidget>, TBInfo> (true, true); leftFloatsMark = rightFloatsMark = 0; lastLeftTBIndex = lastRightTBIndex = 0; - containingBlockWasAllocated = containingBlock->wasAllocated (); - containingBlockAllocation = *(containingBlock->getAllocation()); + containerWasAllocated = container->wasAllocated (); + containerAllocation = *(container->getAllocation()); - addWidgetInFlow (this->containingBlock, NULL, 0); + addWidgetInFlow (this->container, NULL, 0); } OOFFloatsMgr::~OOFFloatsMgr () @@ -533,10 +535,10 @@ OOFFloatsMgr::~OOFFloatsMgr () delete leftFloatsCB; delete rightFloatsCB; - // Order is important: tbInfosByTextblock is owner of the instances - // of TBInfo.tbInfosByTextblock + // Order is important: tbInfosByOOFAwareWidget is owner of the instances + // of TBInfo.tbInfosByOOFAwareWidget delete tbInfos; - delete tbInfosByTextblock; + delete tbInfosByOOFAwareWidget; delete floatsByWidget; @@ -549,24 +551,25 @@ OOFFloatsMgr::~OOFFloatsMgr () DBG_OBJ_DELETE (); } -void OOFFloatsMgr::sizeAllocateStart (Textblock *caller, Allocation *allocation) +void OOFFloatsMgr::sizeAllocateStart (OOFAwareWidget *caller, + Allocation *allocation) { DBG_OBJ_ENTER ("resize.oofm", 0, "sizeAllocateStart", "%p, (%d, %d, %d * (%d + %d))", caller, allocation->x, allocation->y, allocation->width, allocation->ascent, allocation->descent); - getTextblock(caller)->allocation = *allocation; - getTextblock(caller)->wasAllocated = true; + getOOFAwareWidget(caller)->allocation = *allocation; + getOOFAwareWidget(caller)->wasAllocated = true; - if (caller == containingBlock) { + if (caller == container) { // In the size allocation process, the *first* OOFM method // called is sizeAllocateStart, with the containing block as an // argument. So this is the correct point to initialize size // allocation. - containingBlockAllocation = *allocation; - containingBlockWasAllocated = true; + containerAllocation = *allocation; + containerWasAllocated = true; // Move floats from GB lists to the one CB list. moveFromGBToCB (LEFT); @@ -580,19 +583,19 @@ void OOFFloatsMgr::sizeAllocateStart (Textblock *caller, Allocation *allocation) DBG_OBJ_LEAVE (); } -void OOFFloatsMgr::sizeAllocateEnd (Textblock *caller) +void OOFFloatsMgr::sizeAllocateEnd (OOFAwareWidget *caller) { DBG_OBJ_ENTER ("resize.oofm", 0, "sizeAllocateEnd", "%p", caller); // (Later, absolutely positioned blocks have to be allocated.) - if (caller != containingBlock) { + if (caller != container) { // Allocate all floats "before" this textblock. sizeAllocateFloats (LEFT, leftFloatsCB->findFloatIndex (caller, -1)); sizeAllocateFloats (RIGHT, rightFloatsCB->findFloatIndex (caller, -1)); } - if (caller == containingBlock) { + if (caller == container) { // In the size allocation process, the *last* OOFM method called // is sizeAllocateEnd, with the containing block as an // argument. So this is the correct point to finish size @@ -604,12 +607,12 @@ void OOFFloatsMgr::sizeAllocateEnd (Textblock *caller) // Check changes of both textblocks and floats allocation. (All // is checked by hasRelationChanged (...).) - for (lout::container::typed::Iterator<TypedPointer <Textblock> > it = - tbInfosByTextblock->iterator (); + for (lout::container::typed::Iterator<TypedPointer <OOFAwareWidget> > it = + tbInfosByOOFAwareWidget->iterator (); it.hasNext (); ) { - TypedPointer <Textblock> *key = it.getNext (); - TBInfo *tbInfo = tbInfosByTextblock->get (key); - Textblock *tb = key->getTypedValue(); + TypedPointer <OOFAwareWidget> *key = it.getNext (); + TBInfo *tbInfo = tbInfosByOOFAwareWidget->get (key); + OOFAwareWidget *tb = key->getTypedValue(); int minFloatPos; Widget *minFloat; @@ -621,12 +624,12 @@ void OOFFloatsMgr::sizeAllocateEnd (Textblock *caller) checkAllocatedFloatCollisions (RIGHT); // Store some information for later use. - for (lout::container::typed::Iterator<TypedPointer <Textblock> > it = - tbInfosByTextblock->iterator (); + for (lout::container::typed::Iterator<TypedPointer <OOFAwareWidget> > it = + tbInfosByOOFAwareWidget->iterator (); it.hasNext (); ) { - TypedPointer <Textblock> *key = it.getNext (); - TBInfo *tbInfo = tbInfosByTextblock->get (key); - Textblock *tb = key->getTypedValue(); + TypedPointer <OOFAwareWidget> *key = it.getNext (); + TBInfo *tbInfo = tbInfosByOOFAwareWidget->get (key); + OOFAwareWidget *tb = key->getTypedValue(); tbInfo->updateAllocation (); tbInfo->lineBreakWidth = tb->getLineBreakWidth (); @@ -648,7 +651,7 @@ void OOFFloatsMgr::sizeAllocateEnd (Textblock *caller) rightFloatsCB->get(i)->updateAllocation (); if (sizeChanged || extremesChanged) - containingBlock->oofSizeChanged (extremesChanged); + container->oofSizeChanged (extremesChanged); } DBG_OBJ_LEAVE (); @@ -722,7 +725,7 @@ bool OOFFloatsMgr::hasRelationChanged (TBInfo *tbInfo, Side side, Float *vloat = list->get(i); int floatPos; - if (tbInfo->getTextblock () == vloat->generatingBlock) + if (tbInfo->getOOFAwareWidget () == vloat->generatingBlock) DBG_OBJ_MSGF ("resize.oofm", 1, "not checking (generating!) textblock %p against float " "%p", tbInfo->getWidget (), vloat->getWidget ()); @@ -731,10 +734,10 @@ bool OOFFloatsMgr::hasRelationChanged (TBInfo *tbInfo, Side side, int newFlx = calcFloatX (vloat, side, - gba->x - containingBlockAllocation.x, gba->width, + gba->x - containerAllocation.x, gba->width, vloat->generatingBlock->getLineBreakWidth ()); int newFly = vloat->generatingBlock->getAllocation()->y - - containingBlockAllocation.y + vloat->yReal; + - containerAllocation.y + vloat->yReal; DBG_OBJ_MSGF ("resize.oofm", 1, "checking textblock %p against float %p", @@ -1026,7 +1029,7 @@ bool OOFFloatsMgr::doFloatsExceedCB (Side side) // tables) differ from the new allocation. (Generally, a widget may // allocated at a different size.) core::Requisition cbReq; - containingBlock->sizeRequest (&cbReq); + container->sizeRequest (&cbReq); SortedFloatsVector *list = side == LEFT ? leftFloatsCB : rightFloatsCB; bool exceeds = false; @@ -1041,11 +1044,11 @@ bool OOFFloatsMgr::doFloatsExceedCB (Side side) "Does FlA = (%d, %d, %d * %d) exceed CB req+alloc = " "(%d, %d, %d * %d)?", fla->x, fla->y, fla->width, fla->ascent + fla->descent, - containingBlockAllocation.x, containingBlockAllocation.y, + containerAllocation.x, containerAllocation.y, cbReq.width, cbReq.ascent + cbReq.descent); - if (fla->x + fla->width > containingBlockAllocation.x + cbReq.width || + if (fla->x + fla->width > containerAllocation.x + cbReq.width || fla->y + fla->ascent + fla->descent - > containingBlockAllocation.y + cbReq.ascent + cbReq.descent) { + > containerAllocation.y + cbReq.ascent + cbReq.descent) { exceeds = true; DBG_OBJ_MSG ("resize.oofm", 2, "Yes."); } else @@ -1081,7 +1084,7 @@ bool OOFFloatsMgr::haveExtremesChanged (Side side) Float *vloat = list->get (i); // When the GB is the CB, an allocation change does not play a // role here. - if (vloat->generatingBlock != containingBlock) { + if (vloat->generatingBlock != container) { if (!vloat->wasThenAllocated () && vloat->isNowAllocated ()) changed = true; else { @@ -1089,8 +1092,8 @@ bool OOFFloatsMgr::haveExtremesChanged (Side side) // containinBlock->getAllocation() (old value) and // containinBlockAllocation (new value) are different. - Allocation *oldCBA = containingBlock->getAllocation (); - Allocation *newCBA = &containingBlockAllocation; + Allocation *oldCBA = container->getAllocation (); + Allocation *newCBA = &containerAllocation; // Compare also to getFloatsExtremes. The box difference // of the GB (from style) has not changed in this context, @@ -1169,7 +1172,7 @@ void OOFFloatsMgr::sizeAllocateFloats (Side side, int newLastAllocatedFloat) side == LEFT ? "LEFT" : "RIGHT", *lastAllocatedFloat, newLastAllocatedFloat, list->size ()); - Allocation *cba = &containingBlockAllocation; + Allocation *cba = &containerAllocation; for (int i = *lastAllocatedFloat + 1; i <= newLastAllocatedFloat; i++) { Float *vloat = list->get(i); @@ -1219,12 +1222,12 @@ int OOFFloatsMgr::calcFloatX (Float *vloat, Side side, int gbX, int gbWidth, // container, it is corrected (but not left of the container). // This way, we save space and, especially within tables, avoid // some problems. - if (wasAllocated (containingBlock) && - x + vloat->size.width > containingBlock->getLineBreakWidth ()) { - x = max (0, containingBlock->getLineBreakWidth () - vloat->size.width); + if (wasAllocated (container) && + x + vloat->size.width > container->getLineBreakWidth ()) { + x = max (0, container->getLineBreakWidth () - vloat->size.width); DBG_OBJ_MSGF ("resize.common", 1, "corrected to: max (0, %d - %d) = %d", - containingBlock->getLineBreakWidth (), vloat->size.width, + container->getLineBreakWidth (), vloat->size.width, x); } break; @@ -1283,23 +1286,25 @@ void OOFFloatsMgr::drawFloats (SortedFloatsVector *list, View *view, } } -void OOFFloatsMgr::addWidgetInFlow (Textblock *textblock, - Textblock *parentBlock, int externalIndex) +void OOFFloatsMgr::addWidgetInFlow (OOFAwareWidget *textblock, + OOFAwareWidget *parentBlock, + int externalIndex) { //printf ("[%p] addWidgetInFlow (%p, %p, %d)\n", - // containingBlock, textblock, parentBlock, externalIndex); + // container, textblock, parentBlock, externalIndex); TBInfo *tbInfo = new TBInfo (this, textblock, - parentBlock ? getTextblock (parentBlock) : NULL, + parentBlock ? getOOFAwareWidget (parentBlock) : NULL, externalIndex); tbInfo->index = tbInfos->size(); tbInfos->put (tbInfo); - tbInfosByTextblock->put (new TypedPointer<Textblock> (textblock), tbInfo); + tbInfosByOOFAwareWidget->put (new TypedPointer<OOFAwareWidget> (textblock), + tbInfo); } -int OOFFloatsMgr::addWidgetOOF (Widget *widget, Textblock *generatingBlock, +int OOFFloatsMgr::addWidgetOOF (Widget *widget, OOFAwareWidget *generatingBlock, int externalIndex) { DBG_OBJ_ENTER ("construct.oofm", 0, "addWidgetOOF", "%p, %p, %d", @@ -1307,7 +1312,7 @@ int OOFFloatsMgr::addWidgetOOF (Widget *widget, Textblock *generatingBlock, int subRef; - TBInfo *tbInfo = getTextblock (generatingBlock); + TBInfo *tbInfo = getOOFAwareWidget (generatingBlock); Float *vloat = new Float (this, widget, generatingBlock, externalIndex); // Note: Putting the float first in the GB list, and then, possibly @@ -1380,10 +1385,10 @@ int OOFFloatsMgr::addWidgetOOF (Widget *widget, Textblock *generatingBlock, return subRef; } -void OOFFloatsMgr::moveExternalIndices (Textblock *generatingBlock, +void OOFFloatsMgr::moveExternalIndices (OOFAwareWidget *generatingBlock, int oldStartIndex, int diff) { - TBInfo *tbInfo = getTextblock (generatingBlock); + TBInfo *tbInfo = getOOFAwareWidget (generatingBlock); moveExternalIndices (tbInfo->leftFloatsGB, oldStartIndex, diff); moveExternalIndices (tbInfo->rightFloatsGB, oldStartIndex, diff); } @@ -1673,7 +1678,7 @@ void OOFFloatsMgr::getFloatsListsAndSide (Float *vloat, SortedFloatsVector **listOpp, Side *side) { - TBInfo *tbInfo = getTextblock (vloat->generatingBlock); + TBInfo *tbInfo = getOOFAwareWidget (vloat->generatingBlock); switch (vloat->getWidget()->getStyle()->vloat) { case FLOAT_LEFT: @@ -1717,9 +1722,9 @@ void OOFFloatsMgr::getSize (Requisition *cbReq, int *oofWidth, int *oofHeight) // boxRestHeight() are added here. *oofWidth = - max (oofWidthtLeft, oofWidthRight) + containingBlock->boxRestWidth (); + max (oofWidthtLeft, oofWidthRight) + container->boxRestWidth (); *oofHeight = - max (oofHeightLeft, oofHeightRight) + containingBlock->boxRestHeight (); + max (oofHeightLeft, oofHeightRight) + container->boxRestHeight (); DBG_OBJ_MSGF ("resize.oofm", 1, "=> (l: %d, r: %d => %d) * (l: %d, r: %d => %d)", @@ -1735,7 +1740,7 @@ void OOFFloatsMgr::getFloatsSize (Requisition *cbReq, Side side, int *width, cbReq->width, cbReq->ascent, cbReq->descent, side == LEFT ? "LEFT" : "RIGHT"); - SortedFloatsVector *list = getFloatsListForTextblock (containingBlock, side); + SortedFloatsVector *list = getFloatsListForOOFAwareWidget (container, side); *width = *height = 0; @@ -1744,21 +1749,21 @@ void OOFFloatsMgr::getFloatsSize (Requisition *cbReq, Side side, int *width, for (int i = 0; i < list->size(); i++) { Float *vloat = list->get(i); - if (vloat->generatingBlock == containingBlock || + if (vloat->generatingBlock == container || wasAllocated (vloat->generatingBlock)) { ensureFloatSize (vloat); int x, y; - if (vloat->generatingBlock == containingBlock) { + if (vloat->generatingBlock == container) { x = calcFloatX (vloat, side, 0, cbReq->width, vloat->generatingBlock->getLineBreakWidth ()); y = vloat->yReal; } else { Allocation *gba = getAllocation(vloat->generatingBlock); x = calcFloatX (vloat, side, - gba->x - containingBlockAllocation.x, gba->width, + gba->x - containerAllocation.x, gba->width, vloat->generatingBlock->getLineBreakWidth ()); - y = gba->y - containingBlockAllocation.y + vloat->yReal; + y = gba->y - containerAllocation.y + vloat->yReal; } *width = max (*width, x + vloat->size.width); @@ -1809,7 +1814,7 @@ void OOFFloatsMgr::getFloatsExtremes (Extremes *cbExtr, Side side, *minWidth = *maxWidth = 0; - SortedFloatsVector *list = getFloatsListForTextblock (containingBlock, side); + SortedFloatsVector *list = getFloatsListForOOFAwareWidget (container, side); DBG_OBJ_MSGF ("resize.oofm", 1, "%d floats to be examined", list->size()); for (int i = 0; i < list->size(); i++) { @@ -1852,7 +1857,7 @@ bool OOFFloatsMgr::getFloatDiffToCB (Float *vloat, int *leftDiff, bool result; - if (vloat->generatingBlock == containingBlock) { + if (vloat->generatingBlock == container) { *leftDiff = vloat->generatingBlock->getStyle()->boxOffsetX(); *rightDiff = vloat->generatingBlock->getStyle()->boxRestWidth(); result = true; @@ -1861,20 +1866,20 @@ bool OOFFloatsMgr::getFloatDiffToCB (Float *vloat, int *leftDiff, *leftDiff, *rightDiff); } else if (wasAllocated (vloat->generatingBlock)) { Allocation *gba = getAllocation(vloat->generatingBlock); - *leftDiff = gba->x - containingBlockAllocation.x + *leftDiff = gba->x - containerAllocation.x + vloat->generatingBlock->getStyle()->boxOffsetX(); *rightDiff = - (containingBlockAllocation.x + containingBlockAllocation.width) + (containerAllocation.x + containerAllocation.width) - (gba->x + gba->width) + vloat->generatingBlock->getStyle()->boxRestWidth(); result = true; DBG_OBJ_MSGF ("resize.oofm", 1, "GB != CB => leftDiff = %d - %d + %d = %d, " "rightDiff = (%d + %d) - (%d + %d) + %d = %d", - gba->x, containingBlockAllocation.x, + gba->x, containerAllocation.x, vloat->generatingBlock->getStyle()->boxOffsetX(), - *leftDiff, containingBlockAllocation.x, - containingBlockAllocation.width, gba->x, gba->width, + *leftDiff, containerAllocation.x, + containerAllocation.width, gba->x, gba->width, vloat->generatingBlock->getStyle()->boxRestWidth(), *rightDiff); } else { @@ -1886,10 +1891,10 @@ bool OOFFloatsMgr::getFloatDiffToCB (Float *vloat, int *leftDiff, return result; } -OOFFloatsMgr::TBInfo *OOFFloatsMgr::getTextblock (Textblock *textblock) +OOFFloatsMgr::TBInfo *OOFFloatsMgr::getOOFAwareWidget (OOFAwareWidget *widget) { - TypedPointer<Textblock> key (textblock); - TBInfo *tbInfo = tbInfosByTextblock->get (&key); + TypedPointer<OOFAwareWidget> key (widget); + TBInfo *tbInfo = tbInfosByOOFAwareWidget->get (&key); assert (tbInfo); return tbInfo; } @@ -1903,8 +1908,8 @@ OOFFloatsMgr::TBInfo *OOFFloatsMgr::getTextblock (Textblock *textblock) * but is 0 if there is no float, so a caller should also consider * other borders. */ -int OOFFloatsMgr::getLeftBorder (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex) +int OOFFloatsMgr::getLeftBorder (OOFAwareWidget *textblock, int y, int h, + OOFAwareWidget *lastGB, int lastExtIndex) { int b = getBorder (textblock, LEFT, y, h, lastGB, lastExtIndex); DBG_OBJ_MSGF ("border", 0, "left border (%p, %d, %d, %p, %d) => %d", @@ -1918,8 +1923,8 @@ int OOFFloatsMgr::getLeftBorder (Textblock *textblock, int y, int h, * * See also getLeftBorder(int, int); */ -int OOFFloatsMgr::getRightBorder (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex) +int OOFFloatsMgr::getRightBorder (OOFAwareWidget *textblock, int y, int h, + OOFAwareWidget *lastGB, int lastExtIndex) { int b = getBorder (textblock, RIGHT, y, h, lastGB, lastExtIndex); DBG_OBJ_MSGF ("border", 0, "right border (%p, %d, %d, %p, %d) => %d", @@ -1927,14 +1932,14 @@ int OOFFloatsMgr::getRightBorder (Textblock *textblock, int y, int h, return b; } -int OOFFloatsMgr::getBorder (Textblock *textblock, Side side, int y, int h, - Textblock *lastGB, int lastExtIndex) +int OOFFloatsMgr::getBorder (OOFAwareWidget *textblock, Side side, int y, int h, + OOFAwareWidget *lastGB, int lastExtIndex) { DBG_OBJ_ENTER ("border", 0, "getBorder", "%p, %s, %d, %d, %p, %d", textblock, side == LEFT ? "LEFT" : "RIGHT", y, h, lastGB, lastExtIndex); - SortedFloatsVector *list = getFloatsListForTextblock (textblock, side); + SortedFloatsVector *list = getFloatsListForOOFAwareWidget (textblock, side); int last; int first = list->findFirst (textblock, y, h, lastGB, lastExtIndex, &last); @@ -2002,10 +2007,10 @@ int OOFFloatsMgr::getBorder (Textblock *textblock, Side side, int y, int h, } -OOFFloatsMgr::SortedFloatsVector *OOFFloatsMgr::getFloatsListForTextblock - (Textblock *textblock, Side side) +OOFFloatsMgr::SortedFloatsVector *OOFFloatsMgr::getFloatsListForOOFAwareWidget + (OOFAwareWidget *textblock, Side side) { - DBG_OBJ_ENTER ("oofm.common", 1, "getFloatsListForTextblock", "%p, %s", + DBG_OBJ_ENTER ("oofm.common", 1, "getFloatsListForOOFAwareWidget", "%p, %s", textblock, side == LEFT ? "LEFT" : "RIGHT"); OOFFloatsMgr::SortedFloatsVector *list; @@ -2015,7 +2020,7 @@ OOFFloatsMgr::SortedFloatsVector *OOFFloatsMgr::getFloatsListForTextblock list = side == LEFT ? leftFloatsCB : rightFloatsCB; } else { DBG_OBJ_MSG ("oofm.common", 2, "returning <b>GB</b> list"); - TBInfo *tbInfo = getTextblock (textblock); + TBInfo *tbInfo = getOOFAwareWidget (textblock); list = side == LEFT ? tbInfo->leftFloatsGB : tbInfo->rightFloatsGB; } @@ -2024,8 +2029,8 @@ OOFFloatsMgr::SortedFloatsVector *OOFFloatsMgr::getFloatsListForTextblock } -bool OOFFloatsMgr::hasFloatLeft (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex) +bool OOFFloatsMgr::hasFloatLeft (OOFAwareWidget *textblock, int y, int h, + OOFAwareWidget *lastGB, int lastExtIndex) { bool b = hasFloat (textblock, LEFT, y, h, lastGB, lastExtIndex); DBG_OBJ_MSGF ("border", 0, "has float left (%p, %d, %d, %p, %d) => %s", @@ -2033,8 +2038,8 @@ bool OOFFloatsMgr::hasFloatLeft (Textblock *textblock, int y, int h, return b; } -bool OOFFloatsMgr::hasFloatRight (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex) +bool OOFFloatsMgr::hasFloatRight (OOFAwareWidget *textblock, int y, int h, + OOFAwareWidget *lastGB, int lastExtIndex) { bool b = hasFloat (textblock, RIGHT, y, h, lastGB, lastExtIndex); DBG_OBJ_MSGF ("border", 0, "has float right (%p, %d, %d, %p, %d) => %s", @@ -2042,14 +2047,14 @@ bool OOFFloatsMgr::hasFloatRight (Textblock *textblock, int y, int h, return b; } -bool OOFFloatsMgr::hasFloat (Textblock *textblock, Side side, int y, int h, - Textblock *lastGB, int lastExtIndex) +bool OOFFloatsMgr::hasFloat (OOFAwareWidget *textblock, Side side, int y, int h, + OOFAwareWidget *lastGB, int lastExtIndex) { DBG_OBJ_ENTER ("border", 0, "hasFloat", "%p, %s, %d, %d, %p, %d", textblock, side == LEFT ? "LEFT" : "RIGHT", y, h, lastGB, lastExtIndex); - SortedFloatsVector *list = getFloatsListForTextblock (textblock, side); + SortedFloatsVector *list = getFloatsListForOOFAwareWidget (textblock, side); int first = list->findFirst (textblock, y, h, lastGB, lastExtIndex, NULL); DBG_OBJ_MSGF ("border", 1, "first = %d", first); @@ -2057,27 +2062,28 @@ bool OOFFloatsMgr::hasFloat (Textblock *textblock, Side side, int y, int h, return first != -1; } -int OOFFloatsMgr::getLeftFloatHeight (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex) +int OOFFloatsMgr::getLeftFloatHeight (OOFAwareWidget *textblock, int y, int h, + OOFAwareWidget *lastGB, int lastExtIndex) { return getFloatHeight (textblock, LEFT, y, h, lastGB, lastExtIndex); } -int OOFFloatsMgr::getRightFloatHeight (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex) +int OOFFloatsMgr::getRightFloatHeight (OOFAwareWidget *textblock, int y, int h, + OOFAwareWidget *lastGB, int lastExtIndex) { return getFloatHeight (textblock, RIGHT, y, h, lastGB, lastExtIndex); } // Calculate height from the position *y*. -int OOFFloatsMgr::getFloatHeight (Textblock *textblock, Side side, int y, int h, - Textblock *lastGB, int lastExtIndex) +int OOFFloatsMgr::getFloatHeight (OOFAwareWidget *textblock, Side side, int y, + int h, OOFAwareWidget *lastGB, + int lastExtIndex) { DBG_OBJ_ENTER ("border", 0, "getFloatHeight", "%p, %s, %d, %d, %p, %d", textblock, side == LEFT ? "LEFT" : "RIGHT", y, h, lastGB, lastExtIndex); - SortedFloatsVector *list = getFloatsListForTextblock (textblock, side); + SortedFloatsVector *list = getFloatsListForOOFAwareWidget (textblock, side); int first = list->findFirst (textblock, y, h, lastGB, lastExtIndex, NULL); assert (first != -1); /* This method must not be called when there is no float on the respective side. */ @@ -2115,7 +2121,7 @@ int OOFFloatsMgr::getFloatHeight (Textblock *textblock, Side side, int y, int h, /** * Returns position relative to the textblock "tb". */ -int OOFFloatsMgr::getClearPosition (Textblock *textblock) +int OOFFloatsMgr::getClearPosition (OOFAwareWidget *textblock) { DBG_OBJ_ENTER ("resize.oofm", 0, "getClearPosition", "%p", textblock); @@ -2153,7 +2159,7 @@ bool OOFFloatsMgr::affectsRightBorder (core::Widget *widget) return widget->getStyle()->vloat == core::style::FLOAT_RIGHT; }; -int OOFFloatsMgr::getClearPosition (Textblock *textblock, Side side) +int OOFFloatsMgr::getClearPosition (OOFAwareWidget *textblock, Side side) { DBG_OBJ_ENTER ("resize.oofm", 0, "getClearPosition", "%p, %s", textblock, side == LEFT ? "LEFT" : "RIGHT"); @@ -2204,7 +2210,7 @@ void OOFFloatsMgr::ensureFloatSize (Float *vloat) DBG_OBJ_MSG ("resize.oofm", 1, "dirty: recalculation"); vloat->getWidget()->sizeRequest (&vloat->size); - vloat->cbLineBreakWidth = containingBlock->getLineBreakWidth (); + vloat->cbLineBreakWidth = container->getLineBreakWidth (); vloat->dirty = false; DBG_OBJ_SET_BOOL_O (vloat->getWidget (), "<Float>.dirty", vloat->dirty); diff --git a/dw/ooffloatsmgr.hh b/dw/ooffloatsmgr.hh index cca83af1..8f5cdd1f 100644 --- a/dw/ooffloatsmgr.hh +++ b/dw/ooffloatsmgr.hh @@ -7,6 +7,13 @@ namespace dw { namespace oof { +/** + * \brief OutOfFlowMgr implementation dealing with floats. + * + * Note: The identifiers and comments of this class still refer to + * "Textblock" instead of "OOFAwareWidget"; should be cleaned up some + * day. (OTOH, these widgets are always textblocks.) + */ class OOFFloatsMgr: public OutOfFlowMgr { friend class WidgetInfo; @@ -15,12 +22,12 @@ private: enum Side { LEFT, RIGHT }; enum SFVType { GB, CB }; - Textblock *containingBlock; + OOFAwareWidget *container; // These two values are redundant to TBInfo::wasAllocated and // TBInfo::allocation, for some special cases. - bool containingBlockWasAllocated; - core::Allocation containingBlockAllocation; + bool containerWasAllocated; + core::Allocation containerAllocation; class WidgetInfo: public lout::object::Object { @@ -57,11 +64,12 @@ private: { private: OOFFloatsMgr *oofm; - Textblock *refTB; + OOFAwareWidget *refTB; SFVType type; // actually only used for debugging public: - ComparePosition (OOFFloatsMgr *oofm, Textblock *refTB, SFVType type) + ComparePosition (OOFFloatsMgr *oofm, OOFAwareWidget *refTB, + SFVType type) { this->oofm = oofm; this->refTB = refTB; this->type = type; } int compare(Object *o1, Object *o2); }; @@ -84,7 +92,7 @@ private: int compare(Object *o1, Object *o2); }; - Textblock *generatingBlock; + OOFAwareWidget *generatingBlock; int externalIndex; int yReq, yReal; // relative to generator, not container int indexGBList; /* Refers to TBInfo::leftFloatsGB or @@ -100,13 +108,13 @@ private: bool dirty, sizeChangedSinceLastAllocation; Float (OOFFloatsMgr *oofm, core::Widget *widget, - Textblock *generatingBlock, int externalIndex); + OOFAwareWidget *generatingBlock, int externalIndex); inline bool isNowAllocated () { return getWidget()->wasAllocated (); } inline int getNewXCB () { return getWidget()->getAllocation()->x - - getOOFFloatsMgr()->containingBlockAllocation.x; } + getOOFFloatsMgr()->containerAllocation.x; } inline int getNewYCB () { return getWidget()->getAllocation()->y - - getOOFFloatsMgr()->containingBlockAllocation.y; } + getOOFFloatsMgr()->containerAllocation.y; } inline int getNewWidth () { return getWidget()->getAllocation()->width; } inline int getNewHeight () { return getWidget()->getAllocation()->ascent + getWidget()->getAllocation()->descent; } @@ -120,7 +128,7 @@ private: void intoStringBuffer(lout::misc::StringBuffer *sb); - bool covers (Textblock *textblock, int y, int h); + bool covers (OOFAwareWidget *textblock, int y, int h); }; /** @@ -149,10 +157,10 @@ private: lout::container::typed::Vector<Float> (1, false) { this->oofm = oofm; this->side = side; this->type = type; } - int findFloatIndex (Textblock *lastGB, int lastExtIndex); - int find (Textblock *textblock, int y, int start, int end); - int findFirst (Textblock *textblock, int y, int h, Textblock *lastGB, - int lastExtIndex, int *lastReturn); + int findFloatIndex (OOFAwareWidget *lastGB, int lastExtIndex); + int find (OOFAwareWidget *textblock, int y, int start, int end); + int findFirst (OOFAwareWidget *textblock, int y, int h, + OOFAwareWidget *lastGB, int lastExtIndex, int *lastReturn); int findLastBeforeSideSpanningIndex (int sideSpanningIndex); void put (Float *vloat); @@ -188,27 +196,27 @@ private: // as long as this textblock is not allocates. SortedFloatsVector *leftFloatsGB, *rightFloatsGB; - TBInfo (OOFFloatsMgr *oofm, Textblock *textblock, + TBInfo (OOFFloatsMgr *oofm, OOFAwareWidget *textblock, TBInfo *parent, int parentExtIndex); ~TBInfo (); inline bool isNowAllocated () { - return getOOFFloatsMgr()->wasAllocated (getTextblock ()); } + return getOOFFloatsMgr()->wasAllocated (getOOFAwareWidget ()); } inline int getNewXCB () { - return getOOFFloatsMgr()->getAllocation (getTextblock ())->x - - getOOFFloatsMgr()->containingBlockAllocation.x; } + return getOOFFloatsMgr()->getAllocation (getOOFAwareWidget ())->x - + getOOFFloatsMgr()->containerAllocation.x; } inline int getNewYCB () { - return getOOFFloatsMgr()->getAllocation (getTextblock ())->y - - getOOFFloatsMgr()->containingBlockAllocation.y; } + return getOOFFloatsMgr()->getAllocation (getOOFAwareWidget ())->y - + getOOFFloatsMgr()->containerAllocation.y; } inline int getNewWidth () { - return getOOFFloatsMgr()->getAllocation (getTextblock ())->width; } + return getOOFFloatsMgr()->getAllocation (getOOFAwareWidget ())->width; } inline int getNewHeight () { core::Allocation *allocation = - getOOFFloatsMgr()->getAllocation (getTextblock ()); + getOOFFloatsMgr()->getAllocation (getOOFAwareWidget ()); return allocation->ascent + allocation->descent; } void updateAllocation (); - inline Textblock *getTextblock () { return (Textblock*)getWidget (); } + inline OOFAwareWidget *getOOFAwareWidget () { return (OOFAwareWidget*)getWidget (); } }; // These two lists store all floats, in the order in which they are @@ -227,8 +235,8 @@ private: <dw::core::Widget>, Float> *floatsByWidget; lout::container::typed::Vector<TBInfo> *tbInfos; - lout::container::typed::HashTable<lout::object::TypedPointer <Textblock>, - TBInfo> *tbInfosByTextblock; + lout::container::typed::HashTable<lout::object::TypedPointer<OOFAwareWidget>, + TBInfo> *tbInfosByOOFAwareWidget; int lastLeftTBIndex, lastRightTBIndex, leftFloatsMark, rightFloatsMark; @@ -236,16 +244,16 @@ private: * Variant of Widget::wasAllocated(), which can also be used within * OOFM::sizeAllocateEnd(). */ - inline bool wasAllocated (Textblock *textblock) { - return getTextblock(textblock)->wasAllocated; + inline bool wasAllocated (OOFAwareWidget *textblock) { + return getOOFAwareWidget(textblock)->wasAllocated; } /** * Variant of Widget::getAllocation(), which can also be used * within OOFM::sizeAllocateEnd(). */ - inline core::Allocation *getAllocation (Textblock *textblock) { - return &(getTextblock(textblock)->allocation); + inline core::Allocation *getAllocation (OOFAwareWidget *textblock) { + return &(getOOFAwareWidget(textblock)->allocation); } void moveExternalIndices (SortedFloatsVector *list, int oldStartIndex, @@ -291,18 +299,19 @@ private: int *maxWidth); bool getFloatDiffToCB (Float *vloat, int *leftDiff, int *rightDiff); - TBInfo *getTextblock (Textblock *textblock); - int getBorder (Textblock *textblock, Side side, int y, int h, - Textblock *lastGB, int lastExtIndex); - SortedFloatsVector *getFloatsListForTextblock (Textblock *textblock, - Side side); - bool hasFloat (Textblock *textblock, Side side, int y, int h, - Textblock *lastGB, int lastExtIndex); + TBInfo *getOOFAwareWidget (OOFAwareWidget *textblock); + int getBorder (OOFAwareWidget *textblock, Side side, int y, int h, + OOFAwareWidget *lastGB, int lastExtIndex); + SortedFloatsVector *getFloatsListForOOFAwareWidget (OOFAwareWidget + *textblock, + Side side); + bool hasFloat (OOFAwareWidget *textblock, Side side, int y, int h, + OOFAwareWidget *lastGB, int lastExtIndex); - int getFloatHeight (Textblock *textblock, Side side, int y, int h, - Textblock *lastGB, int lastExtIndex); + int getFloatHeight (OOFAwareWidget *textblock, Side side, int y, int h, + OOFAwareWidget *lastGB, int lastExtIndex); - int getClearPosition (Textblock *textblock, Side side); + int getClearPosition (OOFAwareWidget *textblock, Side side); void ensureFloatSize (Float *vloat); @@ -319,11 +328,12 @@ private: { return ref == -1 ? ref : (ref >> 1); } public: - OOFFloatsMgr (Textblock *containingBlock); + OOFFloatsMgr (OOFAwareWidget *container); ~OOFFloatsMgr (); - void sizeAllocateStart (Textblock *caller, core::Allocation *allocation); - void sizeAllocateEnd (Textblock *caller); + void sizeAllocateStart (OOFAwareWidget *caller, + core::Allocation *allocation); + void sizeAllocateEnd (OOFAwareWidget *caller); void containerSizeChangedForChildren (); void draw (core::View *view, core::Rectangle *area); @@ -333,11 +343,11 @@ public: static bool _isWidgetOutOfFlow (core::Widget *widget); static bool _isWidgetHandledByOOFM (core::Widget *widget); - void addWidgetInFlow (Textblock *textblock, Textblock *parentBlock, + void addWidgetInFlow (OOFAwareWidget *textblock, OOFAwareWidget *parentBlock, int externalIndex); - int addWidgetOOF (core::Widget *widget, Textblock *generatingBlock, + int addWidgetOOF (core::Widget *widget, OOFAwareWidget *generatingBlock, int externalIndex); - void moveExternalIndices (Textblock *generatingBlock, int oldStartIndex, + void moveExternalIndices (OOFAwareWidget *generatingBlock, int oldStartIndex, int diff); void tellPosition (core::Widget *widget, int yReq); @@ -346,25 +356,25 @@ public: void getExtremes (core::Extremes *cbExtr, int *oofMinWidth, int *oofMaxWidth); - int getLeftBorder (Textblock *textblock, int y, int h, Textblock *lastGB, - int lastExtIndex); - int getRightBorder (Textblock *textblock, int y, int h, Textblock *lastGB, - int lastExtIndex); + int getLeftBorder (OOFAwareWidget *textblock, int y, int h, + OOFAwareWidget *lastGB, int lastExtIndex); + int getRightBorder (OOFAwareWidget *textblock, int y, int h, + OOFAwareWidget *lastGB, int lastExtIndex); - bool hasFloatLeft (Textblock *textblock, int y, int h, Textblock *lastGB, - int lastExtIndex); - bool hasFloatRight (Textblock *textblock, int y, int h, Textblock *lastGB, - int lastExtIndex); + bool hasFloatLeft (OOFAwareWidget *textblock, int y, int h, + OOFAwareWidget *lastGB, int lastExtIndex); + bool hasFloatRight (OOFAwareWidget *textblock, int y, int h, + OOFAwareWidget *lastGB, int lastExtIndex); - int getLeftFloatHeight (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex); - int getRightFloatHeight (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex); + int getLeftFloatHeight (OOFAwareWidget *textblock, int y, int h, + OOFAwareWidget *lastGB, int lastExtIndex); + int getRightFloatHeight (OOFAwareWidget *textblock, int y, int h, + OOFAwareWidget *lastGB, int lastExtIndex); bool affectsLeftBorder (core::Widget *widget); bool affectsRightBorder (core::Widget *widget); - int getClearPosition (Textblock *textblock); + int getClearPosition (OOFAwareWidget *textblock); bool dealingWithSizeOfChild (core::Widget *child); int getAvailWidthOfChild (core::Widget *child, bool forceValue); diff --git a/dw/oofposabsmgr.cc b/dw/oofposabsmgr.cc index 21409e35..7e7778c7 100644 --- a/dw/oofposabsmgr.cc +++ b/dw/oofposabsmgr.cc @@ -18,14 +18,14 @@ */ #include "oofposabsmgr.hh" -#include "textblock.hh" +#include "oofawarewidget.hh" namespace dw { namespace oof { -OOFPosAbsMgr::OOFPosAbsMgr (Textblock *containingBlock) : - OOFPositionedMgr (containingBlock) +OOFPosAbsMgr::OOFPosAbsMgr (OOFAwareWidget *container) : + OOFPositionedMgr (container) { DBG_OBJ_CREATE ("dw::OOFPosAbsMgr"); } @@ -35,28 +35,24 @@ OOFPosAbsMgr::~OOFPosAbsMgr () DBG_OBJ_DELETE (); } -int OOFPosAbsMgr::cbBoxOffsetX () +int OOFPosAbsMgr::containerBoxOffsetX () { - return containingBlock->boxOffsetX () - - containingBlock->getStyle()->padding.left; + return container->boxOffsetX () - container->getStyle()->padding.left; } -int OOFPosAbsMgr::cbBoxOffsetY () +int OOFPosAbsMgr::containerBoxOffsetY () { - return containingBlock->boxOffsetY () - - containingBlock->getStyle()->padding.top; + return container->boxOffsetY () - container->getStyle()->padding.top; } -int OOFPosAbsMgr::cbBoxRestWidth () +int OOFPosAbsMgr::containerBoxRestWidth () { - return containingBlock->boxRestWidth () - - containingBlock->getStyle()->padding.right; + return container->boxRestWidth () - container->getStyle()->padding.right; } -int OOFPosAbsMgr::cbBoxRestHeight () +int OOFPosAbsMgr::containerBoxRestHeight () { - return containingBlock->boxRestHeight () - - containingBlock->getStyle()->padding.bottom; + return container->boxRestHeight () - container->getStyle()->padding.bottom; } } // namespace oof diff --git a/dw/oofposabsmgr.hh b/dw/oofposabsmgr.hh index eb460881..20c09535 100644 --- a/dw/oofposabsmgr.hh +++ b/dw/oofposabsmgr.hh @@ -10,13 +10,13 @@ namespace oof { class OOFPosAbsMgr: public OOFPositionedMgr { protected: - int cbBoxOffsetX (); - int cbBoxOffsetY (); - int cbBoxRestWidth (); - int cbBoxRestHeight (); + int containerBoxOffsetX (); + int containerBoxOffsetY (); + int containerBoxRestWidth (); + int containerBoxRestHeight (); public: - OOFPosAbsMgr (Textblock *containingBlock); + OOFPosAbsMgr (OOFAwareWidget *container); ~OOFPosAbsMgr (); }; diff --git a/dw/oofposfixedmgr.cc b/dw/oofposfixedmgr.cc index f0d591a7..22cca983 100644 --- a/dw/oofposfixedmgr.cc +++ b/dw/oofposfixedmgr.cc @@ -23,8 +23,8 @@ namespace dw { namespace oof { -OOFPosFixedMgr::OOFPosFixedMgr (Textblock *containingBlock) : - OOFPositionedMgr (containingBlock) +OOFPosFixedMgr::OOFPosFixedMgr (OOFAwareWidget *container) : + OOFPositionedMgr (container) { DBG_OBJ_CREATE ("dw::OOFPosFixedMgr"); } @@ -35,22 +35,22 @@ OOFPosFixedMgr::~OOFPosFixedMgr () } -int OOFPosFixedMgr::cbBoxOffsetX () +int OOFPosFixedMgr::containerBoxOffsetX () { return 0; } -int OOFPosFixedMgr::cbBoxOffsetY () +int OOFPosFixedMgr::containerBoxOffsetY () { return 0; } -int OOFPosFixedMgr::cbBoxRestWidth () +int OOFPosFixedMgr::containerBoxRestWidth () { return 0; } -int OOFPosFixedMgr::cbBoxRestHeight () +int OOFPosFixedMgr::containerBoxRestHeight () { return 0; } diff --git a/dw/oofposfixedmgr.hh b/dw/oofposfixedmgr.hh index 02b0820f..38937878 100644 --- a/dw/oofposfixedmgr.hh +++ b/dw/oofposfixedmgr.hh @@ -10,13 +10,13 @@ namespace oof { class OOFPosFixedMgr: public OOFPositionedMgr { protected: - int cbBoxOffsetX (); - int cbBoxOffsetY (); - int cbBoxRestWidth (); - int cbBoxRestHeight (); + int containerBoxOffsetX (); + int containerBoxOffsetY (); + int containerBoxRestWidth (); + int containerBoxRestHeight (); public: - OOFPosFixedMgr (Textblock *containingBlock); + OOFPosFixedMgr (OOFAwareWidget *container); ~OOFPosFixedMgr (); }; diff --git a/dw/oofpositionedmgr.cc b/dw/oofpositionedmgr.cc index 13eeda2a..e314e641 100644 --- a/dw/oofpositionedmgr.cc +++ b/dw/oofpositionedmgr.cc @@ -18,7 +18,7 @@ */ #include "oofpositionedmgr.hh" -#include "textblock.hh" +#include "oofawarewidget.hh" #include "../lout/debug.hh" using namespace lout::object; @@ -31,11 +31,11 @@ namespace dw { namespace oof { -OOFPositionedMgr::OOFPositionedMgr (Textblock *containingBlock) +OOFPositionedMgr::OOFPositionedMgr (OOFAwareWidget *container) { DBG_OBJ_CREATE ("dw::OOFPositionedMgr"); - this->containingBlock = (Textblock*)containingBlock; + this->container = (OOFAwareWidget*)container; children = new Vector<Widget> (1, false); DBG_OBJ_SET_NUM ("children.size", children->size()); } @@ -47,23 +47,23 @@ OOFPositionedMgr::~OOFPositionedMgr () DBG_OBJ_DELETE (); } -void OOFPositionedMgr::sizeAllocateStart (Textblock *caller, +void OOFPositionedMgr::sizeAllocateStart (OOFAwareWidget *caller, Allocation *allocation) { - containingBlockAllocation = *allocation; + containerAllocation = *allocation; } -void OOFPositionedMgr::sizeAllocateEnd (Textblock *caller) +void OOFPositionedMgr::sizeAllocateEnd (OOFAwareWidget *caller) { DBG_OBJ_ENTER ("resize.oofm", 0, "sizeAllocateEnd", "%p", caller); - if (caller == containingBlock) { + if (caller == container) { sizeAllocateChildren (); - bool sizeChanged = doChildrenExceedCB (); + bool sizeChanged = doChildrenExceedContainer (); bool extremesChanged = haveExtremesChanged (); if (sizeChanged || extremesChanged) - containingBlock->oofSizeChanged (extremesChanged); + container->oofSizeChanged (extremesChanged); } DBG_OBJ_LEAVE (); @@ -74,8 +74,8 @@ void OOFPositionedMgr::sizeAllocateChildren () { DBG_OBJ_ENTER0 ("resize.oofm", 0, "sizeAllocateChildren"); - int refWidth = containingBlock->getAvailWidth (true) - cbBoxDiffWidth (); - int refHeight = containingBlock->getAvailHeight (true) - cbBoxDiffHeight (); + int refWidth = container->getAvailWidth (true) - containerBoxDiffWidth (); + int refHeight = container->getAvailHeight (true) - containerBoxDiffHeight (); for (int i = 0; i < children->size(); i++) { Widget *child = children->get (i); @@ -85,8 +85,8 @@ void OOFPositionedMgr::sizeAllocateChildren () &ascent, &descent); Allocation childAllocation; - childAllocation.x = containingBlockAllocation.x + x + cbBoxOffsetX (); - childAllocation.y = containingBlockAllocation.y + y + cbBoxOffsetY (); + childAllocation.x = containerAllocation.x + x + containerBoxOffsetX (); + childAllocation.y = containerAllocation.y + y + containerBoxOffsetY (); childAllocation.width = width; childAllocation.ascent = ascent; childAllocation.descent = descent; @@ -107,17 +107,17 @@ void OOFPositionedMgr::containerSizeChangedForChildren () DBG_OBJ_LEAVE (); } -bool OOFPositionedMgr::doChildrenExceedCB () +bool OOFPositionedMgr::doChildrenExceedContainer () { - DBG_OBJ_ENTER0 ("resize.oofm", 0, "doChildrenExceedCB"); + DBG_OBJ_ENTER0 ("resize.oofm", 0, "doChildrenExceedContainer"); // This method is called to determine whether the *requisition* of - // the CB must be recalculated. So, we check the allocations of the - // children against the *requisition* of the CB, which may - // (e. g. within tables) differ from the new allocation. + // the container must be recalculated. So, we check the allocations + // of the children against the *requisition* of the container, + // which may (e. g. within tables) differ from the new allocation. // (Generally, a widget may allocated at a different size.) - Requisition cbReq; - containingBlock->sizeRequest (&cbReq); + Requisition containerReq; + container->sizeRequest (&containerReq); bool exceeds = false; DBG_OBJ_MSG_START (); @@ -126,16 +126,18 @@ bool OOFPositionedMgr::doChildrenExceedCB () Widget *child = children->get (i); Allocation *childAlloc = child->getAllocation (); DBG_OBJ_MSGF ("resize.oofm", 2, - "Does childAlloc = (%d, %d, %d * %d) exceed CB alloc+req = " - "(%d, %d, %d * %d)?", + "Does childAlloc = (%d, %d, %d * %d) exceed container " + "alloc+req = (%d, %d, %d * %d)?", childAlloc->x, childAlloc->y, childAlloc->width, childAlloc->ascent + childAlloc->descent, - containingBlockAllocation.x, containingBlockAllocation.y, - cbReq.width, cbReq.ascent + cbReq.descent); + containerAllocation.x, containerAllocation.y, + containerReq.width, + containerReq.ascent + containerReq.descent); if (childAlloc->x + childAlloc->width - > containingBlockAllocation.x + cbReq.width || + > containerAllocation.x + containerReq.width || childAlloc->y + childAlloc->ascent + childAlloc->descent - > containingBlockAllocation.y + cbReq.ascent + cbReq.descent) { + > containerAllocation.y + + containerReq.ascent + containerReq.descent) { exceeds = true; DBG_OBJ_MSG ("resize.oofm", 2, "Yes."); } else @@ -173,16 +175,17 @@ void OOFPositionedMgr::draw (View *view, Rectangle *area) } -void OOFPositionedMgr::addWidgetInFlow (Textblock *textblock, - Textblock *parentBlock, int externalIndex) +void OOFPositionedMgr::addWidgetInFlow (OOFAwareWidget *widget, + OOFAwareWidget *parent, + int externalIndex) { } -int OOFPositionedMgr::addWidgetOOF (Widget *widget, Textblock *generatingBlock, - int externalIndex) +int OOFPositionedMgr::addWidgetOOF (Widget *widget, OOFAwareWidget *generater, + int externalIndex) { DBG_OBJ_ENTER ("construct.oofm", 0, "addWidgetOOF", "%p, %p, %d", - widget, generatingBlock, externalIndex); + widget, generator, externalIndex); children->put (widget); int subRef = children->size() - 1; @@ -194,7 +197,7 @@ int OOFPositionedMgr::addWidgetOOF (Widget *widget, Textblock *generatingBlock, return subRef; } -void OOFPositionedMgr::moveExternalIndices (Textblock *generatingBlock, +void OOFPositionedMgr::moveExternalIndices (OOFAwareWidget *generator, int oldStartIndex, int diff) { } @@ -226,33 +229,34 @@ void OOFPositionedMgr::tellPosition (Widget *widget, int yReq) { } -void OOFPositionedMgr::getSize (Requisition *cbReq, int *oofWidth, +void OOFPositionedMgr::getSize (Requisition *containerReq, int *oofWidth, int *oofHeight) { DBG_OBJ_ENTER0 ("resize.oofm", 0, "getSize"); *oofWidth = *oofHeight = 0; - int refWidth = containingBlock->getAvailWidth (true); - int refHeight = containingBlock->getAvailHeight (true); + int refWidth = container->getAvailWidth (true); + int refHeight = container->getAvailHeight (true); for (int i = 0; i < children->size(); i++) { Widget *child = children->get(i); int x, y, width, ascent, descent; calcPosAndSizeChildOfChild (child, refWidth, refHeight, &x, &y, &width, &ascent, &descent); - *oofWidth = max (*oofWidth, x + width) + cbBoxDiffWidth (); - *oofHeight = max (*oofHeight, y + ascent + descent) + cbBoxDiffHeight (); + *oofWidth = max (*oofWidth, x + width) + containerBoxDiffWidth (); + *oofHeight = + max (*oofHeight, y + ascent + descent) + containerBoxDiffHeight (); } DBG_OBJ_LEAVE (); } -void OOFPositionedMgr::getExtremes (Extremes *cbExtr, int *oofMinWidth, +void OOFPositionedMgr::getExtremes (Extremes *containerExtr, int *oofMinWidth, int *oofMaxWidth) { DBG_OBJ_ENTER ("resize.oofm", 0, "getExtremes", "(%d / %d), ...", - cbExtr->minWidth, cbExtr->maxWidth); + containerExtr->minWidth, containerExtr->maxWidth); // TODO Something to do? *oofMinWidth = *oofMaxWidth = 0; @@ -261,44 +265,46 @@ void OOFPositionedMgr::getExtremes (Extremes *cbExtr, int *oofMinWidth, } -int OOFPositionedMgr::getLeftBorder (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex) +int OOFPositionedMgr::getLeftBorder (OOFAwareWidget *widget, int y, int h, + OOFAwareWidget *lastGen, int lastExtIndex) { return 0; } -int OOFPositionedMgr::getRightBorder (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex) +int OOFPositionedMgr::getRightBorder (OOFAwareWidget *widget, int y, int h, + OOFAwareWidget *lastGen, int lastExtIndex) { return 0; } -bool OOFPositionedMgr::hasFloatLeft (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex) +bool OOFPositionedMgr::hasFloatLeft (OOFAwareWidget *widget, int y, int h, + OOFAwareWidget *lastGen, int lastExtIndex) { return false; } -bool OOFPositionedMgr::hasFloatRight (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex) +bool OOFPositionedMgr::hasFloatRight (OOFAwareWidget *widget, int y, int h, + OOFAwareWidget *lastGen, int lastExtIndex) { return false; } -int OOFPositionedMgr::getLeftFloatHeight (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex) +int OOFPositionedMgr::getLeftFloatHeight (OOFAwareWidget *widget, int y, int h, + OOFAwareWidget *lastGen, + int lastExtIndex) { return 0; } -int OOFPositionedMgr::getRightFloatHeight (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex) +int OOFPositionedMgr::getRightFloatHeight (OOFAwareWidget *widget, int y, int h, + OOFAwareWidget *lastGen, + int lastExtIndex) { return 0; } -int OOFPositionedMgr::getClearPosition (Textblock *textblock) +int OOFPositionedMgr::getClearPosition (OOFAwareWidget *widget) { return 0; } @@ -333,8 +339,8 @@ int OOFPositionedMgr::getAvailWidthOfChild (Widget *child, bool forceValue) // TODO Is "boxDiffWidth()" correct here? DBG_OBJ_MSG ("resize.oofm", 1, "no specification"); if (forceValue) { - int availWidth = containingBlock->getAvailWidth (true); - width = max (availWidth - cbBoxDiffWidth () + int availWidth = container->getAvailWidth (true); + width = max (availWidth - containerBoxDiffWidth () // Regard an undefined value as 0: - max (getPosLeft (child, availWidth), 0), - max (getPosRight (child, availWidth), 0), @@ -343,10 +349,10 @@ int OOFPositionedMgr::getAvailWidthOfChild (Widget *child, bool forceValue) width = -1; } else { if (forceValue) { - int availWidth = containingBlock->getAvailWidth (true); + int availWidth = container->getAvailWidth (true); child->calcFinalWidth (child->getStyle(), - availWidth - cbBoxDiffWidth (), NULL, 0, true, - &width); + availWidth - containerBoxDiffWidth (), NULL, + 0, true, &width); } else width = -1; } @@ -375,8 +381,8 @@ int OOFPositionedMgr::getAvailHeightOfChild (Widget *child, bool forceValue) // TODO Is "boxDiffHeight()" correct here? DBG_OBJ_MSG ("resize.oofm", 1, "no specification"); if (forceValue) { - int availHeight = containingBlock->getAvailHeight (true); - height = max (availHeight - cbBoxDiffHeight () + int availHeight = container->getAvailHeight (true); + height = max (availHeight - containerBoxDiffHeight () // Regard an undefined value as 0: - max (getPosTop (child, availHeight), 0), - max (getPosBottom (child, availHeight), 0), @@ -385,10 +391,10 @@ int OOFPositionedMgr::getAvailHeightOfChild (Widget *child, bool forceValue) height = -1; } else { if (forceValue) { - int availHeight = containingBlock->getAvailHeight (true); + int availHeight = container->getAvailHeight (true); height = child->calcHeight (child->getStyle()->height, true, - availHeight - - cbBoxDiffHeight (), NULL, - true); + availHeight - containerBoxDiffHeight (), + NULL, true); } else height = -1; } diff --git a/dw/oofpositionedmgr.hh b/dw/oofpositionedmgr.hh index d19c60b6..9a1d59b7 100644 --- a/dw/oofpositionedmgr.hh +++ b/dw/oofpositionedmgr.hh @@ -10,21 +10,22 @@ namespace oof { class OOFPositionedMgr: public OutOfFlowMgr { protected: - virtual int cbBoxOffsetX () = 0; - virtual int cbBoxOffsetY () = 0; - virtual int cbBoxRestWidth () = 0; - virtual int cbBoxRestHeight () = 0; + virtual int containerBoxOffsetX () = 0; + virtual int containerBoxOffsetY () = 0; + virtual int containerBoxRestWidth () = 0; + virtual int containerBoxRestHeight () = 0; - inline int cbBoxDiffWidth () { return cbBoxOffsetX () + cbBoxRestWidth (); } - inline int cbBoxDiffHeight () - { return cbBoxOffsetY () + cbBoxRestHeight (); } + inline int containerBoxDiffWidth () + { return containerBoxOffsetX () + containerBoxRestWidth (); } + inline int containerBoxDiffHeight () + { return containerBoxOffsetY () + containerBoxRestHeight (); } - Textblock *containingBlock; - core::Allocation containingBlockAllocation; + OOFAwareWidget *container; + core::Allocation containerAllocation; lout::container::typed::Vector<core::Widget> *children; - bool doChildrenExceedCB (); + bool doChildrenExceedContainer (); bool haveExtremesChanged (); void sizeAllocateChildren (); @@ -43,11 +44,12 @@ protected: int *ascent, int *descent); public: - OOFPositionedMgr (Textblock *containingBlock); + OOFPositionedMgr (OOFAwareWidget *container); ~OOFPositionedMgr (); - void sizeAllocateStart (Textblock *caller, core::Allocation *allocation); - void sizeAllocateEnd (Textblock *caller); + void sizeAllocateStart (OOFAwareWidget *caller, + core::Allocation *allocation); + void sizeAllocateEnd (OOFAwareWidget *caller); void containerSizeChangedForChildren (); void draw (core::View *view, core::Rectangle *area); @@ -55,35 +57,36 @@ public: void markExtremesChange (int ref); core::Widget *getWidgetAtPoint (int x, int y, int level); - void addWidgetInFlow (Textblock *textblock, Textblock *parentBlock, + void addWidgetInFlow (OOFAwareWidget *widget, OOFAwareWidget *parent, int externalIndex); - int addWidgetOOF (core::Widget *widget, Textblock *generatingBlock, + int addWidgetOOF (core::Widget *widget, OOFAwareWidget *generator, int externalIndex); - void moveExternalIndices (Textblock *generatingBlock, int oldStartIndex, + void moveExternalIndices (OOFAwareWidget *generator, int oldStartIndex, int diff); void tellPosition (core::Widget *widget, int yReq); - void getSize (core::Requisition *cbReq, int *oofWidth, int *oofHeight); - void getExtremes (core::Extremes *cbExtr, + void getSize (core::Requisition *containerReq, int *oofWidth, + int *oofHeight); + void getExtremes (core::Extremes *containerExtr, int *oofMinWidth, int *oofMaxWidth); - int getLeftBorder (Textblock *textblock, int y, int h, Textblock *lastGB, - int lastExtIndex); - int getRightBorder (Textblock *textblock, int y, int h, Textblock *lastGB, - int lastExtIndex); + int getLeftBorder (OOFAwareWidget *widget, int y, int h, + OOFAwareWidget *lastGen, int lastExtIndex); + int getRightBorder (OOFAwareWidget *widget, int y, int h, + OOFAwareWidget *lastGen, int lastExtIndex); - bool hasFloatLeft (Textblock *textblock, int y, int h, Textblock *lastGB, - int lastExtIndex); - bool hasFloatRight (Textblock *textblock, int y, int h, Textblock *lastGB, - int lastExtIndex); + bool hasFloatLeft (OOFAwareWidget *widget, int y, int h, + OOFAwareWidget *lastGen, int lastExtIndex); + bool hasFloatRight (OOFAwareWidget *widget, int y, int h, + OOFAwareWidget *lastGen, int lastExtIndex); - int getLeftFloatHeight (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex); - int getRightFloatHeight (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex); + int getLeftFloatHeight (OOFAwareWidget *widget, int y, int h, + OOFAwareWidget *lastGen, int lastExtIndex); + int getRightFloatHeight (OOFAwareWidget *widget, int y, int h, + OOFAwareWidget *lastGen, int lastExtIndex); - int getClearPosition (Textblock *textblock); + int getClearPosition (OOFAwareWidget *widget); bool affectsLeftBorder (core::Widget *widget); bool affectsRightBorder (core::Widget *widget); diff --git a/dw/outofflowmgr.cc b/dw/outofflowmgr.cc index 60670f74..405c5e62 100644 --- a/dw/outofflowmgr.cc +++ b/dw/outofflowmgr.cc @@ -19,7 +19,7 @@ #include "outofflowmgr.hh" -#include "textblock.hh" +#include "oofawarewidget.hh" #include "../lout/debug.hh" diff --git a/dw/outofflowmgr.hh b/dw/outofflowmgr.hh index 475b93b8..0245803c 100644 --- a/dw/outofflowmgr.hh +++ b/dw/outofflowmgr.hh @@ -5,12 +5,12 @@ namespace dw { -class Textblock; - namespace oof { +class OOFAwareWidget; + /** - * \brief Represents additional data for containing blocks. + * \brief Represents additional data for OOF containers. */ class OutOfFlowMgr { @@ -18,9 +18,9 @@ public: OutOfFlowMgr (); virtual ~OutOfFlowMgr (); - virtual void sizeAllocateStart (Textblock *caller, + virtual void sizeAllocateStart (OOFAwareWidget *caller, core::Allocation *allocation) = 0; - virtual void sizeAllocateEnd (Textblock *caller) = 0; + virtual void sizeAllocateEnd (OOFAwareWidget *caller) = 0; virtual void containerSizeChangedForChildren () = 0; virtual void draw (core::View *view, core::Rectangle *area) = 0; @@ -28,45 +28,47 @@ public: virtual void markExtremesChange (int ref) = 0; virtual core::Widget *getWidgetAtPoint (int x, int y, int level) = 0; - virtual void addWidgetInFlow (Textblock *textblock, Textblock *parentBlock, - int externalIndex) = 0; - virtual int addWidgetOOF (core::Widget *widget, Textblock *generatingBlock, + virtual void addWidgetInFlow (OOFAwareWidget *widget, + OOFAwareWidget *parent, int externalIndex) = 0; + virtual int addWidgetOOF (core::Widget *widget, OOFAwareWidget *generator, int externalIndex) = 0; - virtual void moveExternalIndices (Textblock *generatingBlock, + virtual void moveExternalIndices (OOFAwareWidget *generator, int oldStartIndex, int diff) = 0; virtual void tellPosition (core::Widget *widget, int yReq) = 0; - - virtual void getSize (core::Requisition *cbReq, int *oofWidth, + + virtual void getSize (core::Requisition *containerReq, int *oofWidth, int *oofHeight) = 0; - virtual void getExtremes (core::Extremes *cbExtr, int *oofMinWidth, + virtual void getExtremes (core::Extremes *containerExtr, int *oofMinWidth, int *oofMaxWidth) = 0; - virtual int getLeftBorder (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex) = 0; - virtual int getRightBorder (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex) = 0; + virtual int getLeftBorder (OOFAwareWidget *widget, int y, int h, + OOFAwareWidget *lastGen, int lastExtIndex) = 0; + virtual int getRightBorder (OOFAwareWidget *widget, int y, int h, + OOFAwareWidget *lastGen, int lastExtIndex) = 0; - virtual bool hasFloatLeft (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex) = 0; - virtual bool hasFloatRight (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex) = 0; - - virtual int getLeftFloatHeight (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex) = 0; - virtual int getRightFloatHeight (Textblock *textblock, int y, int h, - Textblock *lastGB, int lastExtIndex) = 0; + virtual bool hasFloatLeft (OOFAwareWidget *widget, int y, int h, + OOFAwareWidget *lastGen, int lastExtIndex) = 0; + virtual bool hasFloatRight (OOFAwareWidget *widget, int y, int h, + OOFAwareWidget *lastGen, int lastExtIndex) = 0; + virtual int getLeftFloatHeight (OOFAwareWidget *widget, int y, int h, + OOFAwareWidget *lastGen, int lastExtIndex) + = 0; + virtual int getRightFloatHeight (OOFAwareWidget *widget, int y, int h, + OOFAwareWidget *lastGen, int lastExtIndex) + = 0; + virtual bool affectsLeftBorder (core::Widget *widget) = 0; virtual bool affectsRightBorder (core::Widget *widget) = 0; - virtual int getClearPosition (Textblock *textblock) = 0; + virtual int getClearPosition (OOFAwareWidget *widget) = 0; virtual bool dealingWithSizeOfChild (core::Widget *child) = 0; virtual int getAvailWidthOfChild (core::Widget *child, bool forceValue) = 0; virtual int getAvailHeightOfChild (core::Widget *child, bool forceValue) = 0; - + // for iterators virtual int getNumWidgets () = 0; virtual core::Widget *getWidget (int i) = 0; diff --git a/dw/textblock.cc b/dw/textblock.cc index b399a076..5f610b07 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -2980,7 +2980,7 @@ void Textblock::setVerticalOffset (int verticalOffset) } /** - * Called by dw::OutOfFlowMgr when the border has changed due to a + * Called by dw::OOFFloatsMgr when the border has changed due to a * float (or some floats). * * "y", which given in widget coordinates, denotes the minimal @@ -3144,6 +3144,11 @@ void Textblock::oofSizeChanged (bool extremesChanged) DBG_OBJ_LEAVE (); } +int Textblock::getLineBreakWidth () +{ + return lineBreakWidth; +} + Textblock *Textblock::getTextblockForLine (Line *line) { return getTextblockForLine (line->firstWord, line->lastWord); diff --git a/dw/textblock.hh b/dw/textblock.hh index f7db7b1c..67f55569 100644 --- a/dw/textblock.hh +++ b/dw/textblock.hh @@ -5,6 +5,7 @@ #include "core.hh" #include "outofflowmgr.hh" +#include "oofawarewidget.hh" #include "../lout/misc.hh" // These were used when improved line breaking and hyphenation were implemented. @@ -152,7 +153,7 @@ namespace dw { * necessary, or otherwise the line from which a rewrap is necessary. * */ -class Textblock: public core::Widget +class Textblock: public oof::OOFAwareWidget { private: /** @@ -905,7 +906,7 @@ public: void borderChanged (int y, core::Widget *vloat); void oofSizeChanged (bool extremesChanged); - inline int getLineBreakWidth () { return lineBreakWidth; } + int getLineBreakWidth (); }; #define DBG_SET_WORD_PENALTY(n, i, is) \ |