From cac7e92c13a813dff29606fb29d273f9fc0c95a8 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Wed, 19 Dec 2001 07:42:43 +0000 Subject: Wrapping supported. --- src/ContractionState.cxx | 90 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 75 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/ContractionState.cxx b/src/ContractionState.cxx index 1f1469665..362dc1ed8 100644 --- a/src/ContractionState.cxx +++ b/src/ContractionState.cxx @@ -11,8 +11,9 @@ OneLine::OneLine() { displayLine = 0; - docLine = 0; + //docLine = 0; visible = true; + height = 1; expanded = true; } @@ -22,6 +23,8 @@ ContractionState::ContractionState() { linesInDoc = 1; linesInDisplay = 1; valid = false; + docLines = 0; + sizeDocLines = 0; } ContractionState::~ContractionState() { @@ -30,14 +33,32 @@ ContractionState::~ContractionState() { void ContractionState::MakeValid() const { if (!valid) { - // Could be cleverer by keeping the index of the last still valid entry + // Could be cleverer by keeping the index of the last still valid entry // rather than invalidating all. - int lineDisplay = 0; + linesInDisplay = 0; + for (int lineInDoc=0; lineInDoc= lineDoc + lineCount; i--) { lines[i].visible = lines[i - lineCount].visible; + lines[i].height = lines[i - lineCount].height; + linesInDisplay += lines[i].height; lines[i].expanded = lines[i - lineCount].expanded; } for (int d=0;d lineDocEnd) - return false; + if (lineDocStart == 0) + lineDocStart++; + if (lineDocStart > lineDocEnd) + return false; if (size == 0) { Grow(linesInDoc + growSize); } @@ -170,7 +203,7 @@ bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < linesInDoc)) { for (int line=lineDocStart; line <= lineDocEnd; line++) { if (lines[line].visible != visible) { - delta += visible ? 1 : -1; + delta += visible ? lines[line].height : -lines[line].height; lines[line].visible = visible; } } @@ -181,7 +214,7 @@ bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible } bool ContractionState::GetExpanded(int lineDoc) const { - if (size == 0) + if (size == 0) return true; if ((lineDoc >= 0) && (lineDoc < linesInDoc)) { return lines[lineDoc].expanded; @@ -203,6 +236,33 @@ bool ContractionState::SetExpanded(int lineDoc, bool expanded) { return false; } +int ContractionState::GetHeight(int lineDoc) const { + if (size == 0) + return 1; + if ((lineDoc >= 0) && (lineDoc < linesInDoc)) { + return lines[lineDoc].height; + } else { + return 1; + } +} + +// Set the number of display lines needed for this line. +// Return true if this is a change. +bool ContractionState::SetHeight(int lineDoc, int height) { + if (lineDoc > linesInDoc) + return false; + if (size == 0) { + Grow(linesInDoc + growSize); + } + if (lines[lineDoc].height != height) { + lines[lineDoc].height = height; + valid = false; + return true; + } else { + return false; + } +} + void ContractionState::ShowAll() { delete []lines; lines = 0; -- cgit v1.2.3