aboutsummaryrefslogtreecommitdiff
path: root/dw
diff options
context:
space:
mode:
Diffstat (limited to 'dw')
-rw-r--r--dw/oofawarewidget.cc2
-rw-r--r--dw/oofawarewidget.hh7
-rw-r--r--dw/ooffloatsmgr.cc8
-rw-r--r--dw/textblock.cc22
-rw-r--r--dw/textblock.hh2
5 files changed, 28 insertions, 13 deletions
diff --git a/dw/oofawarewidget.cc b/dw/oofawarewidget.cc
index f33df546..025111ae 100644
--- a/dw/oofawarewidget.cc
+++ b/dw/oofawarewidget.cc
@@ -585,7 +585,7 @@ int OOFAwareWidget::getGeneratorY (int oofmIndex)
return 0;
}
-int OOFAwareWidget::getGeneratorWidth ()
+int OOFAwareWidget::getGeneratorWidth (int callerX, int callerWidth)
{
notImplemented ("OOFAwareWidget::getGeneratorWidth");
return 0;
diff --git a/dw/oofawarewidget.hh b/dw/oofawarewidget.hh
index 9d5fa38a..e49cce14 100644
--- a/dw/oofawarewidget.hh
+++ b/dw/oofawarewidget.hh
@@ -287,8 +287,13 @@ public:
/**
* Return width including margin/border/padding Called by OOFFloatsMgr to
* position floats.
+ *
+ * In somce cases (as in dw::Textblock::getGeneratorRest), the value is not
+ * up to date; for this, the caller may pass its position relative to this
+ * widget, as well as its width, which are used for adjustments. (See comment
+ * in dw::Textblock::getGeneratorRest.)
*/
- virtual int getGeneratorWidth ();
+ virtual int getGeneratorWidth (int callerX, int callerWidth);
virtual int getMaxGeneratorWidth ();
diff --git a/dw/ooffloatsmgr.cc b/dw/ooffloatsmgr.cc
index 2ec73bf3..84b2f6ff 100644
--- a/dw/ooffloatsmgr.cc
+++ b/dw/ooffloatsmgr.cc
@@ -473,7 +473,7 @@ int OOFFloatsMgr::calcFloatX (Float *vloat)
// (ii) If there is more than one line, the line break will already be
// exceeded, and so be smaller that GB width + float width.
effGeneratorWidth =
- min (vloat->generator->getGeneratorWidth () + vloat->size.width,
+ min (vloat->generator->getGeneratorWidth (0, 0) + vloat->size.width,
vloat->generator->getMaxGeneratorWidth ());
x = max (generator->getGeneratorX (oofmIndex) + effGeneratorWidth
@@ -857,7 +857,7 @@ bool OOFFloatsMgr::collidesH (Float *vloat, Float *other)
if (vloat->generator == other->generator)
collidesH = vloat->size.width + other->size.width
+ vloat->generator->boxDiffWidth()
- > vloat->generator->getGeneratorWidth ();
+ > vloat->generator->getGeneratorWidth (0, 0);
else {
// Again, if the other float is not allocated, there is no
// collision. Compare to collidesV. (But vloat->size is used
@@ -1025,8 +1025,8 @@ void OOFFloatsMgr::getFloatsExtremes (Extremes *cbExtr, Side side,
*maxWidth = max (*maxWidth,
extr.maxWidth
+ vloat->generator->getStyle()->boxDiffWidth(),
- + max (container->getGeneratorWidth ()
- - vloat->generator->getGeneratorWidth (),
+ + max (container->getGeneratorWidth (0, 0)
+ - vloat->generator->getGeneratorWidth (0, 0),
0));
DBG_OBJ_MSGF ("resize.oofm", 1, "%d / %d => %d / %d",
diff --git a/dw/textblock.cc b/dw/textblock.cc
index 391e660a..28606aca 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -3053,9 +3053,17 @@ int Textblock::getGeneratorRest (int oofmIndex)
int xRef, rest;
OOFAwareWidget *container = oofContainer[oofmIndex];
- if (container != NULL && findSizeRequestReference (container, &xRef, NULL))
- rest = container->getGeneratorWidth () - (xRef + getGeneratorWidth ());
- else {
+ if (container != NULL && findSizeRequestReference (container, &xRef, NULL)) {
+ // This method is typically called within sizeRequest; so, this widget has
+ // more information to calculate the width that the container, wich will
+ // result in to too small values (often negative) of the rest. For this
+ // reason, we use the possibility to pass values from this widget.
+
+ // (Also notice that the return value may actually be negative.)
+
+ int width = getGeneratorWidth (0, 0);
+ rest = container->getGeneratorWidth (xRef, width) - (xRef + width);
+ } else {
// Only callend for floats, so this should not happen:
assertNotReached ();
rest = 0;
@@ -3065,16 +3073,18 @@ int Textblock::getGeneratorRest (int oofmIndex)
return rest;
}
-int Textblock::getGeneratorWidth ()
+int Textblock::getGeneratorWidth (int callerX, int callerWidth)
{
- DBG_OBJ_ENTER0 ("resize", 0, "Textblock::getGeneratorWidth");
+ DBG_OBJ_ENTER ("resize", 0, "Textblock::getGeneratorWidth", "%d, %d",
+ callerX, callerWidth);
// Cf. sizeRequestImpl.
if (usesMaxGeneratorWidth ()) {
DBG_OBJ_LEAVE_VAL ("%d", lineBreakWidth);
return lineBreakWidth;
} else {
- int w0 = lines->size () > 0 ? lines->getLastRef()->maxLineWidth : 0,
+ int w0 = max (lines->size () > 0 ? lines->getLastRef()->maxLineWidth : 0,
+ callerX + callerWidth),
w = min (w0 + leftInnerPadding + boxDiffWidth (), lineBreakWidth);
DBG_OBJ_LEAVE_VAL ("min (%d + %d + %d, %d) = %d",
w0, leftInnerPadding, boxDiffWidth (), lineBreakWidth,
diff --git a/dw/textblock.hh b/dw/textblock.hh
index 01f7d9f3..499ee063 100644
--- a/dw/textblock.hh
+++ b/dw/textblock.hh
@@ -905,7 +905,7 @@ public:
void oofSizeChanged (bool extremesChanged);
int getGeneratorX (int oofmIndex);
int getGeneratorY (int oofmIndex);
- int getGeneratorWidth ();
+ int getGeneratorWidth (int callerX, int callerWidth);
int getMaxGeneratorWidth ();
bool usesMaxGeneratorWidth ();
bool isPossibleOOFContainer (int oofmIndex);