summaryrefslogtreecommitdiff
path: root/dw/textblock.hh
diff options
context:
space:
mode:
Diffstat (limited to 'dw/textblock.hh')
-rw-r--r--dw/textblock.hh88
1 files changed, 53 insertions, 35 deletions
diff --git a/dw/textblock.hh b/dw/textblock.hh
index 5e6bfa1c..5fea8ffc 100644
--- a/dw/textblock.hh
+++ b/dw/textblock.hh
@@ -96,9 +96,10 @@ namespace dw {
*
* <h3>Some Internals</h3>
*
- * There are 3 lists, dw::Textblock::words, dw::Textblock::lines, and
- * dw::Textblock::anchors. The word list is quite static; only new words
- * may be added. A word is either text, a widget, or a break.
+ * There are 4 lists, dw::Textblock::words, dw::Textblock::paragraphs,
+ * dw::Textblock::lines, and dw::Textblock::anchors. The word list is
+ * quite static; only new words may be added. A word is either text, a
+ * widget, or a break.
*
* Lines refer to the word list (first and last). They are completely
* redundant, i.e., they can be rebuilt from the words. Lines can be
@@ -106,6 +107,10 @@ namespace dw {
* below). For the latter purpose, several values are accumulated in the
* lines. See dw::Textblock::Line for details.
*
+ * A recent change was the introduction of the paragraphs list, which
+ * works quite similar, is also redundant, but is used to calculate
+ * the extremes, not the size.
+ *
* Anchors associate the anchor name with the index of the next word at
* the point of the anchor.
*
@@ -232,6 +237,36 @@ private:
static const char *hyphenDrawChar;
protected:
+ struct Paragraph
+ {
+ int firstWord; /* first word's index in word vector */
+ int lastWord; /* last word's index in word vector */
+
+ // TODO Adjust comments. Short note: maxParMin/maxParMax is
+ // is never smaller than parMin/parMax.
+
+ /*
+ * General remark: all values include the last hyphen width, but
+ * not the last space; these values are, however corrected, when
+ * another word is added.
+ *
+ * Also, as opposed to lines, paragraphs are created with the
+ * first, not the last word, so these values change when new
+ * words are added.
+ */
+
+ int parMin; /* The sum of all word minima (plus spaces,
+ hyphen width etc.) of the last c */
+ int parMax; /* The sum of all word maxima in this
+ * paragraph (plus spaces, hyphen width
+ * etc.). */
+
+ int maxParMin; /* Maximum of all paragraph minima, including
+ * this line. */
+ int maxParMax; /* Maximum of all paragraph maxima (value of "parMax"),
+ * including this one. */
+ };
+
struct Line
{
int firstWord; /* first word's index in word vector */
@@ -246,35 +281,12 @@ protected:
* widgets within this line. */
int marginDescent;
- /* The following members contain accumulated values, from the
- * top down to this line. Please notice a change: until
- * recently, the values were accumulated up to the last line,
- * not this line.
- *
- * Also, keep in mind that at the end of a line, the space of
- * the last word is ignored, but instead, the hyphen width must
- * be considered.*/
-
- int maxLineWidth; /* Maximum of all line widths, including this
- * line. Does not include the last space, but
- * the last hyphen width. */
- int maxParMin; /* Maximum of all paragraph minima, including
- * this line. */
- int maxParMax; /* Maximum of all paragraph maxima. This line
- * is only included, if it is the last line of
- * the paragraph (last word is a forced
- * break); otherwise, it is the value of the
- * last paragraph. For this reason, consider
- * also parMax. */
- int parMax; /* The maximal total width down from the last
- * paragraph start, to the *end* of this line.
- * The space at the end of this line is
- * included, but not the hyphen width (as
- * opposed to the other values). So, in some
- * cases, the space has to be subtracted and
- * the hyphen width to be added, to compare it
- * to maxParMax. (Search the code for
- * occurances.) */
+ /* Maximum of all line widths, including this line. Does not
+ * include the last space, but the last hyphen width. Please
+ * notice a change: until recently (before hyphenation and
+ * changed line breaking), the values were accumulated up to the
+ * last line, not this line.*/
+ int maxLineWidth;
};
struct Word
@@ -336,6 +348,7 @@ protected:
};
void printWordShort (Word *word);
+ void printWordWithFlags (Word *word);
void printWord (Word *word);
struct Anchor
@@ -412,9 +425,10 @@ protected:
/* These values are set by set_... */
int availWidth, availAscent, availDescent;
- int wrapRef; /* [0 based] */
+ int wrapRefLines, wrapRefParagraphs; /* [0 based] */
lout::misc::SimpleVector <Line> *lines;
+ lout::misc::SimpleVector <Paragraph> *paragraphs;
int nonTemporaryLines;
lout::misc::NotSoSimpleVector <Word> *words;
lout::misc::SimpleVector <Anchor> *anchors;
@@ -427,11 +441,11 @@ protected:
void queueDrawRange (int index1, int index2);
void getWordExtremes (Word *word, core::Extremes *extremes);
- void markChange (int ref);
void justifyLine (Line *line, int diff);
Line *addLine (int firstWord, int lastWord, bool temporary);
void calcWidgetSize (core::Widget *widget, core::Requisition *size);
void rewrap ();
+ void fillParagraphs ();
void showMissingLines ();
void removeTemporaryLines ();
@@ -540,10 +554,14 @@ protected:
void accumulateWordExtremes (int firstWord, int lastWord,
int *maxOfMinWidth, int *sumOfMaxWidth);
+ void processWord (int wordIndex);
virtual void wordWrap (int wordIndex, bool wrapAll);
+ void handleWordExtremes (int wordIndex);
+ void correctLastWordExtremes ();
+
int hyphenateWord (int wordIndex);
void accumulateWordForLine (int lineIndex, int wordIndex);
- void accumulateWordData(int wordIndex);
+ void accumulateWordData (int wordIndex);
int calcAvailWidth (int lineIndex);
void initLine1Offset (int wordIndex);
void alignLine (int lineIndex);