diff options
Diffstat (limited to 'dw')
-rw-r--r-- | dw/fltkviewbase.cc | 2 | ||||
-rw-r--r-- | dw/image.cc | 4 | ||||
-rw-r--r-- | dw/ooffloatsmgr.cc | 85 | ||||
-rw-r--r-- | dw/ooffloatsmgr.hh | 1 | ||||
-rw-r--r-- | dw/table.cc | 10 | ||||
-rw-r--r-- | dw/table.hh | 2 | ||||
-rw-r--r-- | dw/textblock_linebreaking.cc | 64 | ||||
-rw-r--r-- | dw/widget.cc | 11 |
8 files changed, 82 insertions, 97 deletions
diff --git a/dw/fltkviewbase.cc b/dw/fltkviewbase.cc index 68218800..4778cd87 100644 --- a/dw/fltkviewbase.cc +++ b/dw/fltkviewbase.cc @@ -365,6 +365,8 @@ int FltkViewBase::handle (int event) // FLTK delivers UNFOCUS to the previously focused widget if (find(Fl::focus()) < children()) focused_child = Fl::focus(); // remember the focused child! + else if (Fl::focus() == this) + focused_child = NULL; // no focused child this time return 0; case FL_KEYBOARD: if (Fl::event_key() == FL_Tab) diff --git a/dw/image.cc b/dw/image.cc index bd7c1ac9..a1052726 100644 --- a/dw/image.cc +++ b/dw/image.cc @@ -241,7 +241,7 @@ void Image::getExtremesImpl (core::Extremes *extremes) { int contentWidth; if (buffer) - contentWidth =buffer->getRootWidth (); + contentWidth = buffer->getRootWidth (); else { if (altText && altText[0]) { if (altTextWidth == -1) @@ -252,7 +252,7 @@ void Image::getExtremesImpl (core::Extremes *extremes) contentWidth = 0; } - int width = contentWidth + + boxDiffWidth (); + int width = contentWidth + boxDiffWidth (); // With percentage width, the image may be narrower than the buffer. extremes->minWidth = diff --git a/dw/ooffloatsmgr.cc b/dw/ooffloatsmgr.cc index b7a4c8bc..0553e25d 100644 --- a/dw/ooffloatsmgr.cc +++ b/dw/ooffloatsmgr.cc @@ -1926,75 +1926,38 @@ void OOFFloatsMgr::getFloatsExtremes (Extremes *cbExtr, Side side, for (int i = 0; i < list->size(); i++) { Float *vloat = list->get(i); - int leftDiff, rightDiff; - if (getFloatDiffToCB (vloat, &leftDiff, &rightDiff)) { + DBG_OBJ_MSGF ("resize.oofm", 1, + "float %p has generator %p (container is %p)", + vloat->getWidget (), vloat->generatingBlock, + containingBlock); + + if (vloat->generatingBlock == container || + wasAllocated (vloat->generatingBlock)) { Extremes extr; vloat->getWidget()->getExtremes (&extr); + int x; - DBG_OBJ_MSGF ("resize.oofm", 1, - "considering float %p generated by %p: %d / %d", - vloat->getWidget (), vloat->generatingBlock, - extr.minWidth, extr.maxWidth); - - // TODO: Or zero (instead of rightDiff) for right floats? - *minWidth = - max (*minWidth, - extr.minWidth + (side == LEFT ? leftDiff : rightDiff)); - *maxWidth = max (*maxWidth, extr.maxWidth + leftDiff + rightDiff); - - DBG_OBJ_MSGF ("resize.oofm", 1, " => %d / %d", *minWidth, *maxWidth); + if (vloat->generatingBlock == container) + x = side == LEFT ? + vloat->generatingBlock->getStyle()->boxOffsetX() : 0; + else { + Allocation *gba = getAllocation(vloat->generatingBlock); + x = calcFloatX (vloat, side, + gba->x - containerAllocation.x, gba->width, + vloat->generatingBlock->getLineBreakWidth ()); + } + + *minWidth = max (*minWidth, x + extr.minWidth); + *maxWidth = max (*maxWidth, x + extr.maxWidth); + + DBG_OBJ_MSGF ("resize.oofm", 1, "%d + %d / %d => %d * %d", + x, extr.minWidth, extr.maxWidth, *minWidth, *maxWidth); } else - DBG_OBJ_MSGF ("resize.oofm", 1, - "considering float %p generated by %p: not allocated", - vloat->getWidget (), vloat->generatingBlock); - } - - DBG_OBJ_LEAVE (); -} - -// Returns "false" when borders cannot yet determined; *leftDiff and -// *rightDiff are undefined in this case. -bool OOFFloatsMgr::getFloatDiffToCB (Float *vloat, int *leftDiff, - int *rightDiff) -{ - DBG_OBJ_ENTER ("resize.oofm", 0, "getDiffToCB", - "float %p [generated by %p], ...", - vloat->getWidget (), vloat->generatingBlock); - - bool result; - - if (vloat->generatingBlock == container) { - *leftDiff = vloat->generatingBlock->boxOffsetX(); - *rightDiff = vloat->generatingBlock->boxRestWidth(); - result = true; - DBG_OBJ_MSGF ("resize.oofm", 1, - "GB == CB => leftDiff = %d, rightDiff = %d", - *leftDiff, *rightDiff); - } else if (wasAllocated (vloat->generatingBlock)) { - Allocation *gba = getAllocation(vloat->generatingBlock); - *leftDiff = gba->x - containerAllocation.x - + vloat->generatingBlock->boxOffsetX(); - *rightDiff = - (containerAllocation.x + containerAllocation.width) - - (gba->x + gba->width) - + vloat->generatingBlock->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, containerAllocation.x, - vloat->generatingBlock->boxOffsetX(), *leftDiff, - containerAllocation.x, containerAllocation.width, - gba->x, gba->width, vloat->generatingBlock->boxRestWidth(), - *rightDiff); - } else { - DBG_OBJ_MSG ("resize.oofm", 1, "GB != CB, and float not allocated"); - result = false; + DBG_OBJ_MSG ("resize.oofm", 1, "not allocated"); } DBG_OBJ_LEAVE (); - return result; } OOFFloatsMgr::TBInfo *OOFFloatsMgr::getOOFAwareWidgetWhenRegistered diff --git a/dw/ooffloatsmgr.hh b/dw/ooffloatsmgr.hh index 86bf62da..b82019fe 100644 --- a/dw/ooffloatsmgr.hh +++ b/dw/ooffloatsmgr.hh @@ -306,7 +306,6 @@ private: int *height); void getFloatsExtremes (core::Extremes *cbExtr, Side side, int *minWidth, int *maxWidth); - bool getFloatDiffToCB (Float *vloat, int *leftDiff, int *rightDiff); TBInfo *getOOFAwareWidget (OOFAwareWidget *widget); TBInfo *getOOFAwareWidgetWhenRegistered (OOFAwareWidget *widget); diff --git a/dw/table.cc b/dw/table.cc index 2d820035..d6dbe633 100644 --- a/dw/table.cc +++ b/dw/table.cc @@ -814,10 +814,10 @@ void Table::calcCellSizes (bool calcHeights) calcHeights ? "true" : "false"); bool sizeChanged = needsResize () || resizeQueued (); - bool extremesChanges = extremesChanged () || extremesQueued (); + bool extremesChanget = extremesChanged () || extremesQueued (); - if (calcHeights ? (extremesChanges || sizeChanged) : - (extremesChanges || !colWidthsUpToDateWidthColExtremes)) + if (calcHeights ? (extremesChanget || sizeChanged) : + (extremesChanget || !colWidthsUpToDateWidthColExtremes)) forceCalcCellSizes (calcHeights); DBG_OBJ_LEAVE (); @@ -1215,8 +1215,10 @@ void Table::apportionRowSpan () * * \bug Some parts are missing. */ -void Table::calcColumnExtremes () +void Table::_unused_calcColumnExtremes () { + // This method is actually not used. Consider removal. + DBG_OBJ_ENTER0 ("resize", 0, "calcColumnExtremes"); if (extremesChanged () || extremesQueued ()) diff --git a/dw/table.hh b/dw/table.hh index 44abc42f..2ad56447 100644 --- a/dw/table.hh +++ b/dw/table.hh @@ -436,7 +436,7 @@ private: void forceCalcCellSizes (bool calcHeights); void apportionRowSpan (); - void calcColumnExtremes (); + void _unused_calcColumnExtremes (); void forceCalcColumnExtremes (); void calcExtremesSpanMulteCols (int col, int cs, core::Extremes *cellExtremes, diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc index 5cc6ad65..666a38f8 100644 --- a/dw/textblock_linebreaking.cc +++ b/dw/textblock_linebreaking.cc @@ -544,6 +544,7 @@ void Textblock::processWord (int wordIndex) if (paragraphs->size() > 0) { firstWord = paragraphs->getLastRef()->firstWord; paragraphs->setSize (paragraphs->size() - 1); + DBG_OBJ_SET_NUM ("paragraphs.size", paragraphs->size ()); DBG_OBJ_MSG ("construct.paragraph", 1, "removing last paragraph"); } else firstWord = 0; @@ -1251,6 +1252,8 @@ void Textblock::handleWordExtremes (int wordIndex) ->badnessAndPenalty.lineMustBeBroken (1)) { // Add a new paragraph. paragraphs->increase (); + DBG_OBJ_SET_NUM ("paragraphs.size", paragraphs->size ()); + Paragraph *prevPar = paragraphs->size() == 1 ? NULL : paragraphs->getRef(paragraphs->size() - 2); Paragraph *par = paragraphs->getLastRef(); @@ -1268,12 +1271,16 @@ void Textblock::handleWordExtremes (int wordIndex) par->maxParMin = par->maxParMinIntrinsic = par->maxParMax = par->maxParMaxIntrinsic = 0; - DBG_OBJ_MSGF ("construct.paragraph", 1, "new par: %d", - paragraphs->size() - 1); + DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, "maxParMin", + par->maxParMin); + DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, + "maxParMinIntrinsic", par->maxParMinIntrinsic); + DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, "maxParMax", + par->maxParMax); + DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, + "maxParMaxIntrinsic", par->maxParMaxIntrinsic); } - DBG_OBJ_MSGF ("construct.paragraph", 1, "last par: %d", - paragraphs->size() - 1); Paragraph *lastPar = paragraphs->getLastRef(); int corrDiffMin, corrDiffMax; @@ -1289,19 +1296,6 @@ void Textblock::handleWordExtremes (int wordIndex) } else corrDiffMin = corrDiffMax = 0; - DBG_OBJ_MSGF ("construct.paragraph", 1, - "(lastPar from %d to %d; corrDiffMin = %d, corDiffMax = %d)", - lastPar->firstWord, lastPar->lastWord, corrDiffMin, - corrDiffMax); - - DBG_OBJ_MSGF ("construct.paragraph", 1, - "before: parMin = %d (%d) (max = %d (%d)), " - "parMax = %d (%d) (max = %d (%d))", - lastPar->parMin, lastPar->parMinIntrinsic, - lastPar->maxParMin, lastPar->maxParMinIntrinsic, - lastPar->parMax, lastPar->parMaxIntrinsic, - lastPar->maxParMax, lastPar->maxParMaxIntrinsic); - // Minimum: between two *possible* breaks. // Shrinkability could be considered, but really does not play a role. lastPar->parMin += wordExtremes.minWidth + word->hyphenWidth + corrDiffMin; @@ -1310,10 +1304,26 @@ void Textblock::handleWordExtremes (int wordIndex) lastPar->maxParMin = misc::max (lastPar->maxParMin, lastPar->parMin); lastPar->maxParMinIntrinsic = misc::max (lastPar->maxParMinIntrinsic, lastPar->parMinIntrinsic); + + DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, "parMin", + lastPar->parMin); + DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, + "parMinIntrinsic", lastPar->parMinIntrinsic); + DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, "maxParMin", + lastPar->maxParMin); + DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, + "maxParMinIntrinsic", lastPar->maxParMinIntrinsic); + if (word->badnessAndPenalty.lineCanBeBroken (1) && - (word->flags & Word::UNBREAKABLE_FOR_MIN_WIDTH) == 0) + (word->flags & Word::UNBREAKABLE_FOR_MIN_WIDTH) == 0) { lastPar->parMin = lastPar->parMinIntrinsic = 0; + DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, "parMin", + lastPar->parMin); + DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, + "parMinIntrinsic", lastPar->parMinIntrinsic); + } + // Maximum: between two *necessary* breaks. lastPar->parMax += wordExtremes.maxWidth + word->hyphenWidth + corrDiffMax; lastPar->parMaxIntrinsic += @@ -1322,14 +1332,15 @@ void Textblock::handleWordExtremes (int wordIndex) lastPar->maxParMaxIntrinsic = misc::max (lastPar->maxParMaxIntrinsic, lastPar->parMaxIntrinsic); - DBG_OBJ_MSGF ("construct.paragraph", 1, - "after: parMin = %d (%d) (max = %d (%d)), " - "parMax = %d (%d) (max = %d (%d))", - lastPar->parMin, lastPar->parMinIntrinsic, - lastPar->maxParMin, lastPar->maxParMinIntrinsic, - lastPar->parMax, lastPar->parMaxIntrinsic, - lastPar->maxParMax, lastPar->maxParMaxIntrinsic); - + DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, "parMax", + lastPar->parMax); + DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, + "parMaxIntrinsic", lastPar->parMaxIntrinsic); + DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, "maxParMax", + lastPar->maxParMax); + DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, + "maxParMaxIntrinsic", lastPar->maxParMaxIntrinsic); + lastPar->lastWord = wordIndex; DBG_OBJ_LEAVE (); } @@ -1925,6 +1936,7 @@ void Textblock::fillParagraphs () parNo = misc::max (0, findParagraphOfWord (firstWordOfLine)); paragraphs->setSize (parNo); + DBG_OBJ_SET_NUM ("paragraphs.size", paragraphs->size ()); int firstWord; if (paragraphs->size () > 0) diff --git a/dw/widget.cc b/dw/widget.cc index ca6abb37..757452a4 100644 --- a/dw/widget.cc +++ b/dw/widget.cc @@ -734,8 +734,15 @@ void Widget::sizeRequest (Requisition *requisition) */ int Widget::getMinWidth (Extremes *extremes, bool forceValue) { - DBG_OBJ_ENTER ("resize", 0, "getMinWidth", "..., %s", - forceValue ? "true" : "false"); + if (extremes) + DBG_OBJ_ENTER ("resize", 0, "getMinWidth", "[%d (%d) / %d (%d), %s", + extremes->minWidth, extremes->minWidthIntrinsic, + extremes->maxWidth, extremes->maxWidthIntrinsic, + forceValue ? "true" : "false"); + else + DBG_OBJ_ENTER ("resize", 0, "getMinWidth", "(nil), %s", + forceValue ? "true" : "false"); + int minWidth; if (getAdjustMinWidth ()) { |