aboutsummaryrefslogtreecommitdiff
path: root/dw
diff options
context:
space:
mode:
Diffstat (limited to 'dw')
-rw-r--r--dw/ooffloatsmgr.cc5
-rw-r--r--dw/ooffloatsmgr.hh1
-rw-r--r--dw/oofpositionedmgr.cc37
-rw-r--r--dw/oofpositionedmgr.hh6
-rw-r--r--dw/outofflowmgr.hh1
-rw-r--r--dw/textblock.cc7
-rw-r--r--dw/textblock.hh1
-rw-r--r--dw/textblock_linebreaking.cc29
8 files changed, 77 insertions, 10 deletions
diff --git a/dw/ooffloatsmgr.cc b/dw/ooffloatsmgr.cc
index 54dc1634..183bb46b 100644
--- a/dw/ooffloatsmgr.cc
+++ b/dw/ooffloatsmgr.cc
@@ -2177,6 +2177,11 @@ bool OOFFloatsMgr::affectsRightBorder (core::Widget *widget)
return widget->getStyle()->vloat == core::style::FLOAT_RIGHT;
};
+bool OOFFloatsMgr::mayAffectBordersAtAll ()
+{
+ return true;
+}
+
int OOFFloatsMgr::getClearPosition (OOFAwareWidget *textblock, Side side)
{
DBG_OBJ_ENTER ("resize.oofm", 0, "getClearPosition", "%p, %s",
diff --git a/dw/ooffloatsmgr.hh b/dw/ooffloatsmgr.hh
index 00cd5b9e..47bcbab4 100644
--- a/dw/ooffloatsmgr.hh
+++ b/dw/ooffloatsmgr.hh
@@ -377,6 +377,7 @@ public:
bool affectsLeftBorder (core::Widget *widget);
bool affectsRightBorder (core::Widget *widget);
+ bool mayAffectBordersAtAll ();
int getClearPosition (OOFAwareWidget *textblock);
diff --git a/dw/oofpositionedmgr.cc b/dw/oofpositionedmgr.cc
index 8edbed5b..949965b2 100644
--- a/dw/oofpositionedmgr.cc
+++ b/dw/oofpositionedmgr.cc
@@ -36,13 +36,16 @@ OOFPositionedMgr::OOFPositionedMgr (OOFAwareWidget *container)
DBG_OBJ_CREATE ("dw::OOFPositionedMgr");
this->container = (OOFAwareWidget*)container;
- children = new Vector<Child> (1, true);
+ children = new Vector<Child> (1, false);
+ childrenByWidget = new HashTable<TypedPointer<Widget>, Child> (true, true);
+
DBG_OBJ_SET_NUM ("children.size", children->size());
}
OOFPositionedMgr::~OOFPositionedMgr ()
{
delete children;
+ delete childrenByWidget;
DBG_OBJ_DELETE ();
}
@@ -193,7 +196,10 @@ int OOFPositionedMgr::addWidgetOOF (Widget *widget, OOFAwareWidget *generator,
DBG_OBJ_ENTER ("construct.oofm", 0, "addWidgetOOF", "%p, %p, %d",
widget, generator, externalIndex);
- children->put (new Child (widget, generator));
+ Child *child = new Child (widget, generator);
+ children->put (child);
+ childrenByWidget->put (new TypedPointer<Widget> (widget), child);
+
int subRef = children->size() - 1;
DBG_OBJ_SET_NUM ("children.size", children->size());
DBG_OBJ_ARRSET_PTR ("children", children->size() - 1, widget);
@@ -235,6 +241,20 @@ Widget *OOFPositionedMgr::getWidgetAtPoint (int x, int y, int level)
void OOFPositionedMgr::tellPosition (Widget *widget, int x, int y)
{
+ DBG_OBJ_ENTER ("resize.oofm", 0, "tellPosition", "%p, %d, %d",
+ widget, x, y);
+
+ TypedPointer<Widget> key (widget);
+ Child *child = childrenByWidget->get (&key);
+ assert (child);
+
+ child->x = x;
+ child->y = y;
+
+ DBG_OBJ_SET_NUM_O (child->widget, "<Positioned>.x", x);
+ DBG_OBJ_SET_NUM_O (child->widget, "<Positioned>.y", y);
+
+ DBG_OBJ_LEAVE ();
}
void OOFPositionedMgr::getSize (Requisition *containerReq, int *oofWidth,
@@ -327,6 +347,11 @@ bool OOFPositionedMgr::affectsRightBorder (Widget *widget)
return false;
}
+bool OOFPositionedMgr::mayAffectBordersAtAll ()
+{
+ return false;
+}
+
bool OOFPositionedMgr::dealingWithSizeOfChild (Widget *child)
{
return true;
@@ -445,14 +470,14 @@ void OOFPositionedMgr::calcPosAndSizeChildOfChild (Child *child, int refWidth,
bool widthDefined;
if (style::isAbsLength (child->widget->getStyle()->width)) {
DBG_OBJ_MSGF ("resize.oofm", 1, "absolute width: %dpx",
- style::absLengthVal (child->getStyle()->width));
+ style::absLengthVal (child->widget->getStyle()->width));
*width = style::absLengthVal (child->widget->getStyle()->width)
+ child->widget->boxDiffWidth ();
widthDefined = true;
} else if (style::isPerLength (child->widget->getStyle()->width)) {
DBG_OBJ_MSGF ("resize.oofm", 1, "percentage width: %g%%",
100 * style::perLengthVal_useThisOnlyForDebugging
- (child->getStyle()->width));
+ (child->widget->getStyle()->width));
*width = style::multiplyWithPerLength (refWidth,
child->widget->getStyle()->width)
+ child->widget->boxDiffWidth ();
@@ -486,7 +511,7 @@ void OOFPositionedMgr::calcPosAndSizeChildOfChild (Child *child, int refWidth,
*descent = childRequisition.descent;
if (style::isAbsLength (child->widget->getStyle()->height)) {
DBG_OBJ_MSGF ("resize.oofm", 1, "absolute height: %dpx",
- style::absLengthVal (child->getStyle()->height));
+ style::absLengthVal (child->widget->getStyle()->height));
int height = style::absLengthVal (child->widget->getStyle()->height)
+ child->widget->boxDiffHeight ();
splitHeightPreserveAscent (height, ascent, descent);
@@ -494,7 +519,7 @@ void OOFPositionedMgr::calcPosAndSizeChildOfChild (Child *child, int refWidth,
} else if (style::isPerLength (child->widget->getStyle()->height)) {
DBG_OBJ_MSGF ("resize.oofm", 1, "percentage height: %g%%",
100 * style::perLengthVal_useThisOnlyForDebugging
- (child->getStyle()->height));
+ (child->widget->getStyle()->height));
int height =
style::multiplyWithPerLength (refHeight,
child->widget->getStyle()->height)
diff --git a/dw/oofpositionedmgr.hh b/dw/oofpositionedmgr.hh
index ff24a194..ad469b8f 100644
--- a/dw/oofpositionedmgr.hh
+++ b/dw/oofpositionedmgr.hh
@@ -34,7 +34,10 @@ protected:
core::Allocation containerAllocation;
lout::container::typed::Vector<Child> *children;
-
+ lout::container::typed::HashTable<lout::object::TypedPointer
+ <dw::core::Widget>,
+ Child> *childrenByWidget;
+
bool doChildrenExceedContainer ();
bool haveExtremesChanged ();
void sizeAllocateChildren ();
@@ -100,6 +103,7 @@ public:
bool affectsLeftBorder (core::Widget *widget);
bool affectsRightBorder (core::Widget *widget);
+ bool mayAffectBordersAtAll ();
bool dealingWithSizeOfChild (core::Widget *child);
int getAvailWidthOfChild (core::Widget *child, bool forceValue);
diff --git a/dw/outofflowmgr.hh b/dw/outofflowmgr.hh
index 9a9032a7..5b03562d 100644
--- a/dw/outofflowmgr.hh
+++ b/dw/outofflowmgr.hh
@@ -65,6 +65,7 @@ public:
virtual bool affectsLeftBorder (core::Widget *widget) = 0;
virtual bool affectsRightBorder (core::Widget *widget) = 0;
+ virtual bool mayAffectBordersAtAll () = 0;
virtual int getClearPosition (OOFAwareWidget *widget) = 0;
diff --git a/dw/textblock.cc b/dw/textblock.cc
index 59817bdd..f1598fec 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -2260,6 +2260,11 @@ void Textblock::addWidget (core::Widget *widget, core::style::Style *style)
words->size ());
widget->parentRef = makeParentRefOOF (oofmIndex, oofmSubRef);
+ DBG_OBJ_MSGF ("construct.word", 1,
+ "ouf of flow: oofmIndex = %d, oofmSubRef = %d => "
+ "parentRef = %d",
+ oofmIndex, oofmSubRef, widget->parentRef);
+
Word *word = addWord (0, 0, 0, 0, style);
word->content.type = core::Content::WIDGET_OOF_REF;
word->content.widget = widget;
@@ -2268,6 +2273,8 @@ void Textblock::addWidget (core::Widget *widget, core::style::Style *style)
// problems with breaking near float definitions.)
setBreakOption (word, style, 0, 0, false);
} else {
+ DBG_OBJ_MSG ("construct.word", 1, "in flow");
+
widget->setParent (this);
// TODO Replace (perhaps) later "textblock" by "OOF aware widget".
diff --git a/dw/textblock.hh b/dw/textblock.hh
index 870a7c87..499992c1 100644
--- a/dw/textblock.hh
+++ b/dw/textblock.hh
@@ -710,6 +710,7 @@ protected:
void processWord (int wordIndex);
virtual int wordWrap (int wordIndex, bool wrapAll);
int wrapWordInFlow (int wordIndex, bool wrapAll);
+ int wrapWordOofRef (int wordIndex, bool wrapAll);
void balanceBreakPosAndHeight (int wordIndex, int firstIndex,
int *searchUntil, bool tempNewLine,
int penaltyIndex, bool borderIsCalculated,
diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc
index 82aef93a..dbce505e 100644
--- a/dw/textblock_linebreaking.cc
+++ b/dw/textblock_linebreaking.cc
@@ -570,7 +570,7 @@ int Textblock::wordWrap (int wordIndex, bool wrapAll)
int n;
if (word->content.type == core::Content::WIDGET_OOF_REF)
- n = 0;
+ n = wrapWordOofRef (wordIndex, wrapAll);
else
n = wrapWordInFlow (wordIndex, wrapAll);
@@ -735,8 +735,8 @@ 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) ||
+ if ((searchOutOfFlowMgr(j)->affectsLeftBorder(content
+ ->widget) ||
searchOutOfFlowMgr(j)->affectsRightBorder (content
->widget)))
newFloatPos = i;
@@ -838,6 +838,29 @@ int Textblock::wrapWordInFlow (int wordIndex, bool wrapAll)
return diffWords;
}
+int Textblock::wrapWordOofRef (int wordIndex, bool wrapAll)
+{
+ DBG_OBJ_ENTER ("construct.word", 0, "wrapWordOofRef", "%d, %s",
+ wordIndex, wrapAll ? "true" : "false");
+
+ Word *word = words->getRef (wordIndex);
+ Widget *widget = word->content.widget;
+ int yNewLine = yOffsetOfPossiblyMissingLine (lines->size ());
+
+ // Floats, which affect either border, are handled in wrapWordInFlow; this
+ // is rather for positioned elements.
+ oof::OutOfFlowMgr *oofm = searchOutOfFlowMgr (getWidgetOOFIndex (widget));
+ DBG_OBJ_MSGF ("construct.word", 1, "parentRef = %d, oofm = %p",
+ widget->parentRef, oofm);
+ if (oofm && !oofm->mayAffectBordersAtAll ())
+ // TODO Again, "x = 0" is not correct (see above).
+ oofm->tellPosition (widget, 0, yNewLine);
+
+ DBG_OBJ_LEAVE ();
+
+ return 0; // Words list not changed.
+}
+
// *height must be initialized, but not *breakPos.
// *wordIndexEnd must be initialized (initially to wordIndex)
void Textblock::balanceBreakPosAndHeight (int wordIndex, int firstIndex,