pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
adjustedRect = displayRect;
+ adjustedRect.width = lineBounds.width;
adjustedRect.height = lineBounds.height;
if (action == TEXT_OBJECT_ACTION_TYPE_ABBREV)
{
SysTryReturn(NID_GRP, __pCurrentTextColumn, -1, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet.");
- TextLine* pTextLine = new (std::nothrow)TextLine(this);
- SysTryReturn(NID_GRP, pTextLine, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
+ TextLine* pTextLine = null;
FloatRectangle lineBounds;
- FloatDimension lineTextSize;
- int lineLength = __length;
+ FloatDimension textSize;
+ int lineOffset = 0;
+ int lineLength = 0;
+ int endType = TEXT_RETBY_NORMAL;
+ bool isChanged = false;
float baseline = 0;
+ int textIndex = 0;
+
+ textIndex = (__workStart < 0) ? 0 : __workStart;
+ textIndex = (textIndex > __length) ? __length : textIndex;
+ bool forwardSearch = (textIndex == __length) ? false : true;
+
+ if (__pCurrentTextColumn->GetTotalLineCount() > 0)
+ {
+ pTextLine = __pCurrentTextColumn->GetTextLine(0);
+ SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
+
+ lineBounds = pTextLine->GetBoundsF();
+ endType = pTextLine->GetEndType();
+
+ if (lineBounds.width != rect.width)
+ {
+ isChanged = true;
+ }
+
+ lineOffset = pTextLine->GetTextOffset();
+ lineLength = pTextLine->GetTextLength();
+
+ if (lineOffset <= textIndex && textIndex < lineOffset + lineLength)
+ {
+ isChanged = true;
+ }
+ }
+ else
+ {
+ pTextLine = new (std::nothrow)TextLine(this);
+ SysTryReturn(NID_GRP, pTextLine, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+
+ if (forwardSearch)
+ {
+ if (pNoneWrapComposeInfo != null)
+ {
+ lineOffset = pNoneWrapComposeInfo->prevTextOffset;
+ }
+ else
+ {
+ lineOffset = 0;
+ }
+ }
+ else
+ {
+ lineOffset = __length - 1;
+ }
+
+ lineLength = 0;
+ lineBounds.width = rect.width;
+ lineBounds.x = 0;
+ lineBounds.y = 0;
+ lineBounds.height = 0;
+
+ __pCurrentTextColumn->AddLineDuringCompose(pTextLine);
+
+ isChanged = true;
+ }
+
+ if (isChanged)
+ {
+ lineBounds.width = rect.width;
+ lineBounds.x = 0;
+ lineBounds.y = 0;
+
+ if (forwardSearch)
+ {
+ endType = ForwardAnalyzeWithBaseline(lineOffset, __length - lineOffset, lineBounds.width, __wrap,
+ lineLength, textSize.width, textSize.height, baseline);
+
+ lineBounds.height = textSize.height;
+ pTextLine->SetBounds(lineBounds);
+ pTextLine->SetTextOffset(lineOffset);
+ pTextLine->SetTextLength(lineLength);
+ pTextLine->SetRegion(textSize.width, textSize.height);
+ pTextLine->SetEndType(endType);
+ pTextLine->SetBaseline(baseline);
+ GetTextExtentList(pTextLine);
+ }
+ else
+ {
+ int textCount = 0;
- GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
+ BackwardAnalyze(lineOffset, lineBounds.width, &textCount, &textSize.width, &textSize.height);
- lineBounds.width = (rect.width < lineTextSize.width) ? lineTextSize.width :rect.width;
- lineBounds.height = lineTextSize.height;
- baseline = lineBounds.height / 3.0f;
+ lineBounds.height = textSize.height;
+ lineOffset -= (textCount - 1);
+ lineLength = textCount;
+ endType = (lineOffset == 0) ? TEXT_RETBY_NORMAL : TEXT_RETBY_LIMITWIDTH;
+
+ pTextLine->SetBounds(lineBounds);
+ pTextLine->SetTextOffset(lineOffset);
+ pTextLine->SetTextLength(lineLength);
+ pTextLine->SetRegion(textSize.width, textSize.height);
+ pTextLine->SetEndType(endType);
+ pTextLine->SetBaseline(baseline);
+ GetTextExtentList(pTextLine);
+ }
+ }
+
+ if (__length == 0)
+ {
+ pTextLine->SetEndType(TEXT_RETBY_NORMAL);
+ return 1;
+ }
+
+ rect.height = lineBounds.height;
+
+ if (textIndex < lineOffset)
+ {
+ lineOffset = textIndex;
+ endType = ForwardAnalyze(lineOffset, __length - lineOffset, lineBounds.width, __wrap,
+ lineLength, textSize.width, textSize.height);
+
+ lineBounds.height = textSize.height;
+ }
+ else if (forwardSearch && textIndex >= lineOffset + lineLength)
+ {
+ FloatDimension needDim;
+ GetRegion(lineOffset + lineLength, textIndex - (lineOffset + lineLength) + 1, needDim.width, needDim.height);
+
+ int index = 0;
+ float remainingWidth = needDim.width - (lineBounds.width - textSize.width);
+
+ FloatDimension charDim;
+ textSize.width += needDim.width;
+ lineLength += textIndex - (lineOffset + lineLength) + 1;
+
+ while (1)
+ {
+ GetRegion(lineOffset, 1, charDim.width, charDim.height);
+ lineOffset++;
+ index++;
+ remainingWidth -= charDim.width;
+ textSize.width -= charDim.width;
+
+ if (remainingWidth <= 0)
+ {
+ break;
+ }
+ }
+
+ lineLength -= index;
+ }
+ else if (endType != TEXT_RETBY_LIMITWIDTH && lineLength != __length)
+ {
+ if (lineOffset > 0)
+ {
+ FloatDimension lineTextSize;
+ int textCount = 0;
+ float remainingWidth = 0;
+
+ pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
+ remainingWidth = lineBounds.width - lineTextSize.width;
+ BackwardAnalyze(lineOffset - 1, remainingWidth, &textCount, &textSize.width, &textSize.height);
+
+ if (textSize.width > 0)
+ {
+ lineOffset -= textCount;
+ lineLength += textCount;
+ textSize.width += lineTextSize.width;
+ lineBounds.height = textSize.height;
+ endType = TEXT_RETBY_LIMITLENGTH;
+ }
+ else
+ {
+ return 1;
+ }
+ }
+ else
+ {
+ return 1;
+ }
+ }
+ else
+ {
+ return 1;
+ }
pTextLine->SetBounds(lineBounds);
- pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
- pTextLine->SetTextOffset(0);
+ pTextLine->SetRegion(textSize.width, textSize.height);
pTextLine->SetTextLength(lineLength);
- pTextLine->SetEndType(TEXT_RETBY_NORMAL);
+ pTextLine->SetTextOffset(lineOffset);
+ pTextLine->SetEndType(endType);
pTextLine->SetBaseline(baseline);
GetTextExtentList(pTextLine);
- __pCurrentTextColumn->AddLineDuringCompose(pTextLine);
-
return 1;
}
maxHeight = textSize.height;
- BackwardAnalyze(__length - 1, lineBounds.width - __middleEllipsisWidth - __middleEllipsisHeadWidth, length, textSize.width, textSize.height);
+ ForwardAnalyze(__middleEllipsisTextLengthInHead, __length - __middleEllipsisTextLengthInHead, lineBounds.width - __middleEllipsisWidth -
+ __middleEllipsisHeadWidth, __wrap, length, textSize.width, textSize.height);
__middleEllipsisTextLengthInTail = length;
maxHeight = (maxHeight < textSize.height) ? textSize.height : maxHeight;
__pAbbrevTextElement->GetRegion(0, 1, abbrevTextDim.width, abbrevTextDim.height);
__headEllipsisWidth = abbrevTextDim.width;
- BackwardAnalyze(__length - 1, lineBounds.width - abbrevTextDim.width, __headEllipsisTextLength, textSize.width, textSize.height);
-
+ BackwardAnalyze(__length - 1, lineBounds.width - abbrevTextDim.width, &__headEllipsisTextLength, &textSize.width, &textSize.height);
maxHeight = textSize.height;
TextLine* pTextLine = new (std::nothrow)TextLine(this);
}
bool
-TextComposite::BackwardAnalyze(int startTextIndex, float maxWidth, int& actualLength, float& width, float& height)
+TextComposite::BackwardAnalyze(int startTextIndex, float maxWidth, int* actualLength, float* width, float* height)
{
float remainingWidth = 0;
int length = 0;
FloatDimension textSize;
- actualLength = 0;
- width = 0;
- height = 0;
+ *actualLength = 0;
+ *width = 0;
+ *height = 0;
remainingWidth = maxWidth;
length = 1;
if (textSize.width <= remainingWidth)
{
- actualLength = length;
- width = textSize.width;
- height = textSize.height;
+ *actualLength = length;
+ *width = textSize.width;
+ *height = textSize.height;
}
startTextIndex--;
__pTextColumn->SetChangeAction(TextColumn::TEXT_CHANGE_UNKONWN, 0, 0);
__pTextColumn->SetFirstDisplayLineIndex(0);
__pTextColumn->SetFirstDisplayPositionY(0.0f);
- __pTextColumn->SetFirstDisplayPositionX(0.0f);
}
ResetSweepInfo();
TextLine* pTextLine = __pTextColumn->GetTextLine(0);
if (pTextLine != null)
{
- FloatRectangle lineBounds = pTextLine->GetBoundsF();
int lineLength = pTextLine->GetTextLength();
int totalLength = __pCompositeText->GetTextLength();
- if (lineLength < totalLength || __rect.width < lineBounds.width)
+ if (lineLength < totalLength)
{
__isActionOn = true;
__pTextColumn->SetSlidingPosition(0.0f);
}
result
-TextObject::SetFirstDisplayPositionX(int x)
-{
- return SetFirstDisplayPositionX(_CoordinateSystemUtils::ConvertToFloat(x));
-}
-
-result
-TextObject::SetFirstDisplayPositionX(float x)
-{
- IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
- SysTryReturn(NID_GRP, __wrap == TEXT_OBJECT_WRAP_TYPE_NONE
- , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] The argument is invalid.");
-
- TextLine* pTextLine = __pTextColumn->GetTextLine(0);
- SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
-
- FloatRectangle lineBounds = pTextLine->GetBoundsF();
-
- if (x < 0)
- {
- x = 0;
- }
-
- if (lineBounds.width - __rect.width < x)
- {
- x = lineBounds.width - __rect.width;
- }
-
- __pTextColumn->SetFirstDisplayPositionX(x);
-
- return E_SUCCESS;
-}
-
-int
-TextObject::GetFirstDisplayPositionX(void) const
-{
- return _CoordinateSystemUtils::ConvertToInteger(GetFirstDisplayPositionXF());
-}
-
-float
-TextObject::GetFirstDisplayPositionXF(void) const
-{
- IF_NOT_CONSTRUCTED(return -1);
-
- return __pTextColumn->GetFirstDisplayPositionX();
-}
-
-result
TextObject::SetFirstDisplayPositionY(int y)
{
return SetFirstDisplayPositionY(_CoordinateSystemUtils::ConvertToFloat(y));
SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
int lineLength = pTextLine->GetTextLength();
- float firstDisplayPositionX = __pTextColumn->GetFirstDisplayPositionX();
float posX = 0.0f;
float posY = 0.0f;
break;
}
- absX = posX + textExtent.x - firstDisplayPositionX;
+ absX = posX + textExtent.x;
logicalX = (absX >= 0.0f) ? absX + __rect.x : absX;
absY = posY;
logicalY = absY + __rect.y;