aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dw/oofawarewidget.cc5
-rw-r--r--dw/oofawarewidget.hh1
-rw-r--r--dw/ooffloatsmgr.cc33
-rw-r--r--dw/ooffloatsmgr.hh4
-rw-r--r--dw/textblock.cc9
-rw-r--r--dw/textblock.hh1
6 files changed, 44 insertions, 9 deletions
diff --git a/dw/oofawarewidget.cc b/dw/oofawarewidget.cc
index 7017ebfa..9994c0cc 100644
--- a/dw/oofawarewidget.cc
+++ b/dw/oofawarewidget.cc
@@ -347,6 +347,11 @@ void OOFAwareWidget::borderChanged (int y, Widget *vloat)
assertNotReached ();
}
+void OOFAwareWidget::clearPositionChanged ()
+{
+ assertNotReached ();
+}
+
void OOFAwareWidget::oofSizeChanged (bool extremesChanged)
{
DBG_OBJ_ENTER ("resize", 0, "oofSizeChanged", "%s",
diff --git a/dw/oofawarewidget.hh b/dw/oofawarewidget.hh
index 9a80b9bb..d2d5ef85 100644
--- a/dw/oofawarewidget.hh
+++ b/dw/oofawarewidget.hh
@@ -191,6 +191,7 @@ public:
~OOFAwareWidget ();
virtual void borderChanged (int y, core::Widget *vloat);
+ virtual void clearPositionChanged ();
virtual void oofSizeChanged (bool extremesChanged);
virtual int getLineBreakWidth (); // Should perhaps be renamed.
virtual bool isPossibleContainer (int oofmIndex);
diff --git a/dw/ooffloatsmgr.cc b/dw/ooffloatsmgr.cc
index 655fa743..fdfd986b 100644
--- a/dw/ooffloatsmgr.cc
+++ b/dw/ooffloatsmgr.cc
@@ -477,6 +477,7 @@ OOFFloatsMgr::TBInfo::TBInfo (OOFFloatsMgr *oofm, OOFAwareWidget *textblock,
wasAllocated = getWidget()->wasAllocated ();
allocation = *(getWidget()->getAllocation ());
+ clearPosition = 0;
}
OOFFloatsMgr::TBInfo::~TBInfo ()
@@ -598,6 +599,17 @@ void OOFFloatsMgr::sizeAllocateEnd (OOFAwareWidget *caller)
sizeAllocateFloats (LEFT, leftFloatsCB->findFloatIndex (caller, -1));
sizeAllocateFloats (RIGHT, rightFloatsCB->findFloatIndex (caller, -1));
}
+
+ // The checks below do not cover "clear position" in all cases,
+ // so this is done here separately. This position is stored in
+ // TBInfo and calculated at this points; changes will be noticed
+ // to the textblock.
+ TBInfo *tbInfo = getOOFAwareWidget (caller);
+ int newClearPosition = calcClearPosition (caller);
+ if (newClearPosition != tbInfo->clearPosition) {
+ tbInfo->clearPosition = newClearPosition;
+ caller->clearPositionChanged ();
+ }
if (caller == container) {
// In the size allocation process, the *last* OOFM method called
@@ -2142,6 +2154,11 @@ int OOFFloatsMgr::getFloatHeight (OOFAwareWidget *textblock, Side side, int y,
*/
int OOFFloatsMgr::getClearPosition (OOFAwareWidget *textblock)
{
+ return getOOFAwareWidget(textblock)->clearPosition;
+}
+
+int OOFFloatsMgr::calcClearPosition (OOFAwareWidget *textblock)
+{
DBG_OBJ_ENTER ("resize.oofm", 0, "getClearPosition", "%p", textblock);
int pos;
@@ -2156,8 +2173,8 @@ int OOFFloatsMgr::getClearPosition (OOFAwareWidget *textblock)
default: assertNotReached ();
}
- pos = max (left ? getClearPosition (textblock, LEFT) : 0,
- right ? getClearPosition (textblock, RIGHT) : 0);
+ pos = max (left ? calcClearPosition (textblock, LEFT) : 0,
+ right ? calcClearPosition (textblock, RIGHT) : 0);
} else
pos = 0;
@@ -2167,7 +2184,6 @@ int OOFFloatsMgr::getClearPosition (OOFAwareWidget *textblock)
return pos;
}
-
bool OOFFloatsMgr::affectsLeftBorder (core::Widget *widget)
{
return widget->getStyle()->vloat == core::style::FLOAT_LEFT;
@@ -2183,7 +2199,7 @@ bool OOFFloatsMgr::mayAffectBordersAtAll ()
return true;
}
-int OOFFloatsMgr::getClearPosition (OOFAwareWidget *textblock, Side side)
+int OOFFloatsMgr::calcClearPosition (OOFAwareWidget *textblock, Side side)
{
DBG_OBJ_ENTER ("resize.oofm", 0, "getClearPosition", "%p, %s",
textblock, side == LEFT ? "LEFT" : "RIGHT");
@@ -2210,11 +2226,12 @@ int OOFFloatsMgr::getClearPosition (OOFAwareWidget *textblock, Side side)
pos = 0; // See above.
else {
ensureFloatSize (vloat);
- pos = getAllocation(vloat->generatingBlock)->y + vloat->yReal
- + vloat->size.ascent + vloat->size.descent
- - getAllocation(textblock)->y;
+ pos = max (getAllocation(vloat->generatingBlock)->y + vloat->yReal
+ + vloat->size.ascent + vloat->size.descent
+ - getAllocation(textblock)->y,
+ 0);
DBG_OBJ_MSGF ("resize.oofm", 1,
- "float %p => %d + %d + (%d + %d) - %d",
+ "float %p => max (%d + %d + (%d + %d) - %d, 0)",
vloat->getWidget (),
getAllocation(vloat->generatingBlock)->y,
vloat->yReal, vloat->size.ascent, vloat->size.descent,
diff --git a/dw/ooffloatsmgr.hh b/dw/ooffloatsmgr.hh
index 75bc596e..b23ba072 100644
--- a/dw/ooffloatsmgr.hh
+++ b/dw/ooffloatsmgr.hh
@@ -191,6 +191,7 @@ private:
// down) for usage.
bool wasAllocated;
core::Allocation allocation;
+ int clearPosition;
// These two lists store all floats generated by this textblock,
// as long as this textblock is not allocates.
@@ -314,7 +315,8 @@ private:
int getFloatHeight (OOFAwareWidget *textblock, Side side, int y, int h,
OOFAwareWidget *lastGB, int lastExtIndex);
- int getClearPosition (OOFAwareWidget *textblock, Side side);
+ int calcClearPosition (OOFAwareWidget *textblock);
+ int calcClearPosition (OOFAwareWidget *textblock, Side side);
void ensureFloatSize (Float *vloat);
diff --git a/dw/textblock.cc b/dw/textblock.cc
index 5e5bd264..d90c0781 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -3008,6 +3008,15 @@ void Textblock::borderChanged (int y, Widget *vloat)
DBG_OBJ_LEAVE ();
}
+void Textblock::clearPositionChanged ()
+{
+ DBG_OBJ_ENTER0 ("resize", 0, "clearPositionChanged");
+ // Not very efficient (actually, a rewrapping could be easily
+ // avoided), but this case should not occur very often.
+ queueResize (0, false);
+ DBG_OBJ_LEAVE ();
+}
+
void Textblock::oofSizeChanged (bool extremesChanged)
{
DBG_OBJ_ENTER ("resize", 0, "oofSizeChanged", "%s",
diff --git a/dw/textblock.hh b/dw/textblock.hh
index e55c2ce3..f041488b 100644
--- a/dw/textblock.hh
+++ b/dw/textblock.hh
@@ -838,6 +838,7 @@ public:
bool includeFirstSpace, bool includeLastSpace);
void borderChanged (int y, core::Widget *vloat);
+ void clearPositionChanged ();
void oofSizeChanged (bool extremesChanged);
int getLineBreakWidth ();
bool isPossibleContainer (int oofmIndex);