#include <new>
#include <memory>
+#include <pthread.h>
#include <FGrpFont.h>
-
#include <FBaseSysLog.h>
+#include <FBaseRtMutex.h>
#include "FGrp_FontImpl.h"
#include "FGrp_Font.h"
#include "FGrp_ResUtil.h"
+using namespace Tizen::Base::Runtime;
+
#define IF_NOT_INITIALIZED(code) if (this->_pNativeFont == null || this->_pCoordHolder == null) \
{ \
code; \
}
#define IsSucceeded(X) (!IsFailed(X))
+
+#if 1
+#define CRITICAL_SECTION _MutexGuard __mutexGuard__
+#else
+#define CRITICAL_SECTION
+#endif
+
+
namespace Tizen { namespace Graphics
{
+class _MutexGuard
+{
+public:
+ _MutexGuard()
+ {
+ Mutex* pMutex = GetMutexInstance();
+ pMutex->Acquire();
+ }
+
+ ~_MutexGuard()
+ {
+ Mutex* pMutex = GetMutexInstance();
+ pMutex->Release();
+ }
+
+private:
+ static void __InitCreateMutex(void)
+ {
+ static Mutex mutex;
+ mutex.Create();
+ _MutexGuard::pMutexInstance = &mutex;
+ }
+
+ static Mutex* GetMutexInstance(void)
+ {
+ static pthread_once_t once_block = PTHREAD_ONCE_INIT;
+
+ if (_MutexGuard::pMutexInstance == null)
+ {
+ pthread_once(&once_block, __InitCreateMutex);
+ }
+
+ return _MutexGuard::pMutexInstance;
+ }
+
+public:
+ static Mutex* pMutexInstance;
+};
+
+Mutex* _MutexGuard::pMutexInstance = null;
+
+
struct _FontCoordHolder
{
_ResUtil::CoordHolder <int> size;
result
_FontImpl::Construct(int style, int vcSize)
{
+ CRITICAL_SECTION;
IF_NOT_INITIALIZED(return E_OUT_OF_MEMORY);
// convert VC -> PC
result
_FontImpl::Construct(const Tizen::Base::String& fontName, int style, int vcSize, bool isPathEnabled)
{
+ CRITICAL_SECTION;
IF_NOT_INITIALIZED(return E_OUT_OF_MEMORY);
// convert VC -> PC
result
_FontImpl::Construct(const Tizen::Base::ByteBuffer& fontData, int style, int vcSize)
{
+ CRITICAL_SECTION;
IF_NOT_INITIALIZED(return E_OUT_OF_MEMORY);
// convert VC -> PC
result
_FontImpl::Construct(int style, float vcSize)
{
+ CRITICAL_SECTION;
IF_NOT_INITIALIZED(return E_OUT_OF_MEMORY);
// convert VC -> PC
result
_FontImpl::Construct(const Tizen::Base::String& fontName, int style, float vcSize, bool isPathEnabled)
{
+ CRITICAL_SECTION;
IF_NOT_INITIALIZED(return E_OUT_OF_MEMORY);
// convert VC -> PC
result
_FontImpl::Construct(const Tizen::Base::ByteBuffer& fontData, int style, float vcSize)
{
+ CRITICAL_SECTION;
IF_NOT_INITIALIZED(return E_OUT_OF_MEMORY);
// convert VC -> PC
bool
_FontImpl::IsConstructed(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return false);
return true;
int
_FontImpl::GetMaxHeight(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return -1);
int pcMaxHeight = _DoubleToIntForPos(ceil(_pNativeFont->GetMaxHeight().ToDouble()));
float
_FontImpl::GetMaxHeightF(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return -1.0f);
float pcMaxHeight = float(ceil(_pNativeFont->GetMaxHeight().ToDouble()));
int
_FontImpl::GetMaxWidth(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return -1);
int pcMaxWidth = _pNativeFont->GetMaxWidth().ToInt();
float
_FontImpl::GetMaxWidthF(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return -1.0f);
float pcMaxWidth = _pNativeFont->GetMaxWidth().ToFloat();
int
_FontImpl::GetAscender(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return -1);
- int pcAscender = _pNativeFont->GetAscender().ToInt();
+ int pcAscender = _DoubleToIntForPos(ceil(_pNativeFont->GetAscender().ToDouble()));
+
+ for (int i = pcAscender; i < INT_MAX; i++)
+ {
+ if (_ResUtil::ConvertToPhyCoord(_ResUtil::ConvertToVirCoordY(i)) >= pcAscender)
+ {
+ pcAscender = i;
+ break;
+ }
+ }
+
int vcAscender = _ResUtil::ConvertToVirCoordY(pcAscender);
return vcAscender;
float
_FontImpl::GetAscenderF(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return -1.0f);
- float pcAscender = _pNativeFont->GetAscender().ToFloat();
+ float pcAscender = float(ceil(_pNativeFont->GetAscender().ToDouble()));
float vcAscender = _ResUtil::ConvertToVirCoordY(pcAscender);
return vcAscender;
int
_FontImpl::GetDescender(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return -1);
- int pcDescender = _pNativeFont->GetDescender().ToInt();
- int vcDescender = _ResUtil::ConvertToVirCoordY(pcDescender);
+ int pcDescender = _DoubleToIntForPos(ceil(_pNativeFont->GetDescender().ToDouble()));
- if (vcDescender < 0)
+ if (pcDescender < 0)
{
- vcDescender *= -1;
+ pcDescender *= -1;
+ }
+
+ for (int i = pcDescender; i < INT_MAX; i++)
+ {
+ if (_ResUtil::ConvertToPhyCoord(_ResUtil::ConvertToVirCoordY(i)) >= pcDescender)
+ {
+ pcDescender = i;
+ break;
+ }
}
+ int vcDescender = _ResUtil::ConvertToVirCoordY(pcDescender);
+
return vcDescender;
}
float
_FontImpl::GetDescenderF(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return -1.0f);
- float pcDescender = _pNativeFont->GetDescender().ToFloat();
+ float pcDescender = float(ceil(_pNativeFont->GetDescender().ToDouble()));
float vcDescender = _ResUtil::ConvertToVirCoordY(pcDescender);
if (vcDescender < 0.0f)
result
_FontImpl::GetLeftBear(wchar_t character, int& vcLeftBear) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
_Util::FixedPoint22_10 pcLeftBear(0);
result
_FontImpl::GetLeftBear(wchar_t character, float& vcLeftBear) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
_Util::FixedPoint22_10 pcLeftBear(0);
result
_FontImpl::GetRightBear(wchar_t character, int& vcRightBear) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
_Util::FixedPoint22_10 pcRightBear(0);
result
_FontImpl::GetRightBear(wchar_t character, float& vcRightBear) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
_Util::FixedPoint22_10 pcRightBear(0);
result
_FontImpl::GetTextExtent(const Tizen::Base::String& text, int length, Dimension& vcDim, bool outline) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
int dummyCount = 0 ;
result
_FontImpl::GetTextExtent(const Tizen::Base::String& text, int length, FloatDimension& vcDim, bool outline) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
int dummyCount = 0;
bool
_FontImpl::IsBold(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return false);
return _pNativeFont->IsBold();
bool
_FontImpl::IsItalic(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return false);
return _pNativeFont->IsItalic();
bool
_FontImpl::IsPlain(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return false);
return _pNativeFont->IsPlain();
bool
_FontImpl::IsStrikeOut(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return false);
return _pNativeFont->IsStrikeOut();
bool
_FontImpl::IsUnderlined(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return false);
return _pNativeFont->IsUnderlined();
int
_FontImpl::GetSize(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return -1);
return _pCoordHolder->size.required;
float
_FontImpl::GetSizeF(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return -1.0f);
return _pCoordHolder->sizeF.required;
void
_FontImpl::SetStrikeOut(bool strikeOut)
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return);
_pNativeFont->SetStrikeOut(strikeOut);
void
_FontImpl::SetUnderline(bool underline)
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return);
_pNativeFont->SetUnderline(underline);
void
_FontImpl::SetCharSpace(int vcSpace)
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return);
// save it
void
_FontImpl::SetCharSpace(float vcSpace)
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return);
// save it
int
_FontImpl::GetCharSpace(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return 0);
return _pCoordHolder->charSpace.required;
float
_FontImpl::GetCharSpaceF(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return 0.0f);
return _pCoordHolder->charSpaceF.required;
Tizen::Base::String
_FontImpl::GetFaceName(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return "");
return _pNativeFont->GetFaceName();
Tizen::Base::Collection::IList*
_FontImpl::GetSystemFontListN(void)
{
+ CRITICAL_SECTION;
return _Font::GetSystemFontListN();
}
Tizen::Base::String
_FontImpl::GetFaceName(const Tizen::Base::String& filePath)
{
+ CRITICAL_SECTION;
return _Font::GetFaceName(filePath);
}
_FontImpl*
_FontImpl::CloneN(void)
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return null);
std::auto_ptr<_FontImpl> pFontImpl(new (std::nothrow) _FontImpl(*this));
Font*
_FontImpl::CloneN(const Font& font)
{
+ CRITICAL_SECTION;
+
// check the validation of input param
SysTryReturn(NID_GRP, font.__pImpl && font.__pImpl->IsConstructed(), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid input param given");
result
_FontImpl::GetTextExtent(int vcWidth, const Tizen::Base::String& text, int startIndex, int length, bool outline, int& count, Dimension& vcDim) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
SysTryReturnResult(NID_GRP, startIndex >= 0 && length >= 0 && startIndex < text.GetLength(), E_OUT_OF_RANGE,
result
_FontImpl::GetTextExtent(int vcWidth, const Tizen::Base::String& text, int startIndex, int length, bool outline, const Tizen::Base::String& delimiter, int& count, Dimension& vcDim) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
SysTryReturnResult(NID_GRP, startIndex >= 0 && length >= 0 && startIndex < text.GetLength(), E_OUT_OF_RANGE,
result
_FontImpl::GetTextExtent(float vcWidth, const Tizen::Base::String& text, int startIndex, int length, bool outline, int& count, FloatDimension& vcDim) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
SysTryReturnResult(NID_GRP, startIndex >= 0 && length >= 0 && startIndex < text.GetLength(), E_OUT_OF_RANGE,
result
_FontImpl::GetTextExtent(float vcWidth, const Tizen::Base::String& text, int startIndex, int length, bool outline, const Tizen::Base::String& delimiter, int& count, FloatDimension& vcDim) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
SysTryReturnResult(NID_GRP, startIndex >= 0 && length >= 0 && startIndex < text.GetLength(), E_OUT_OF_RANGE,
result
_FontImpl::SetSize(int vcSize)
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
SysTryReturnResult(NID_GRP, vcSize > 0, E_INVALID_ARG, "Font size should be greater than 0");
result
_FontImpl::SetSize(float vcSize)
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
SysTryReturnResult(NID_GRP, vcSize > 0.0f, E_INVALID_ARG, "Font size should be greater than 0");
result
_FontImpl::SetStyle(int style)
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
SysTryReturnResult(NID_GRP, style > FONT_STYLE_MIN && style <= (FONT_STYLE_PLAIN | FONT_STYLE_BOLD | FONT_STYLE_ITALIC), E_INVALID_ARG,
"Style(%d) is invalid", style);
int
_FontImpl::GetStyle(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return FONT_STYLE_PLAIN);
return _pNativeFont->GetStyle();
int
_FontImpl::GetLeading(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return -1);
int pcLeading = _DoubleToIntForPos(ceil(_pNativeFont->GetLeading().ToDouble()));
float
_FontImpl::GetLeadingF(void) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return -1.0f);
float pcLeading = float(ceil(_pNativeFont->GetLeading().ToDouble()));
_FontImpl*
_FontImpl::GetInstance(Font& font)
{
+ CRITICAL_SECTION;
return (&font != null) ? font.__pImpl : null;
}
const _FontImpl*
_FontImpl::GetInstance(const Font& font)
{
+ CRITICAL_SECTION;
return (&font != null) ? font.__pImpl : null;
}
bool
_FontImpl::UpdateDefaultFont(const Tizen::Base::String& key)
{
+ CRITICAL_SECTION;
return _Font::UpdateDefaultFont(key);
}
result
_FontImpl::GetTextExtentList(const Tizen::Base::String& string, int startIndex, int length, Tizen::Base::Collection::ArrayListT<_FloatPair>& outList) const
{
+ CRITICAL_SECTION;
IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
SysTryReturnResult(NID_GRP, startIndex >= 0 && length >= 0 && startIndex < string.GetLength(), E_OUT_OF_RANGE,
TextBidiHint GetTextBidiHint(void) const;
- result SetFirstDisplayPositionX(int x);
+ result SetDisplayBoundsExpandEnabled(bool enable);
- result SetFirstDisplayPositionX(float x);
-
- int GetFirstDisplayPositionX(void) const;
-
- float GetFirstDisplayPositionXF(void) const;
+ bool IsDisplayBoundsExpandEnabled(void) const;
private:
result DrawByLine(_CanvasImpl& canvasImpl, const Rectangle& displayRect);
bool __isActionOn;
bool __isChanged;
bool __isAlternateLookEnabled;
+ bool __isDisplayBoundsExpandEnabled;
Font* __pDefaultFont;
Color __defaultForegroundColor;
Color __defaultBackgroundColor;
__displayLineCount = 0;
__firstDisplayLineIndex = 0;
__firstDisplayPositionY = -1;
- __firstDisplayPositionX = -1;
__displayHeight = -1;
__slidingPosition = 0;
__pCompositeText = pCompositeText;
__displayHeight -= __firstDisplayPositionY - lineBounds.y;
}
- if (__firstDisplayPositionX > 0)
- {
- displayRect.x -= __firstDisplayPositionX;
- }
-
while (pTextLineNode != null && 0 <= displayRect.height)
{
if (action == TEXT_OBJECT_ACTION_TYPE_ABBREV)
{
lineAction = TEXT_OBJECT_ACTION_TYPE_ABBREV;
}
-
- if (displayRect.width < lineBounds.width)
- {
- lineAction = TEXT_OBJECT_ACTION_TYPE_ABBREV;
- }
}
else
{
}
void
-TextColumn::SetFirstDisplayPositionX(float x)
-{
- __firstDisplayPositionX = x;
-}
-
-float
-TextColumn::GetFirstDisplayPositionX(void) const
-{
- return __firstDisplayPositionX;
-}
-
-void
TextColumn::SetDisplayHeight(int height)
{
__displayHeight = _CoordinateSystemUtils::ConvertToFloat(height);
float GetFirstDisplayPositionYF(void) const;
- void SetFirstDisplayPositionX(float x);
-
- float GetFirstDisplayPositionX(void) const;
-
int GetTextLengthAt(int lineIndex) const;
int GetFirstTextIndexAt(int lineIndex) const;
int __totalLineCount;
int __firstDisplayLineIndex;
float __firstDisplayPositionY;
- float __firstDisplayPositionX;
int __displayLineCount;
float __displayHeight;
Tizen::Graphics::FloatDimension __slidingDimension;
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--;
int ComposeInPartialMode(FloatRectangle& rect);
- bool BackwardAnalyze(int startTextIndex, float maxWidth, int& actualLength, float& width, float& height);
+ bool BackwardAnalyze(int startTextIndex, float maxWidth, int* actualLength, float* width, float* height);
result DrawAbbrevInMiddleEllipsis(_CanvasImpl& canvasImpl, const FloatRectangle& displayRect, const TextObjectAlignment alignment);
__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_NORMAL] = Color::GetColor(COLOR_ID_BLUE);
__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_SELECT] = Color::GetColor(COLOR_ID_BLUE);
__bidiHint = TEXT_BIDI_HINT_NONE;
+ __isDisplayBoundsExpandEnabled = false;
__sweepInfo.isValid = false;
__sweepInfo.sweepType = TEXT_OBJECT_SWEEP_TYPE_NONE;
FloatRectangle finalClipRect;
clipRect = canvasImpl.GetClipBoundsF();
- finalClipRect.x = (clipRect.x > targetBounds.x) ? clipRect.x : targetBounds.x;
- finalClipRect.y = (clipRect.y > targetBounds.y) ? clipRect.y: targetBounds.y;
- finalClipRect.width = (clipRect.x + clipRect.width > targetBounds.x + targetBounds.width) ? (targetBounds.x + targetBounds.width) - finalClipRect.x : (clipRect.x + clipRect.width) - finalClipRect.x;
- finalClipRect.height = (clipRect.y + clipRect.height > targetBounds.y + targetBounds.height) ? (targetBounds.y + targetBounds.height) - finalClipRect.y : (clipRect.y + clipRect.height) - finalClipRect.y;
+ finalClipRect.x = (clipRect.x > __rect.x) ? clipRect.x : __rect.x;
+ finalClipRect.y = (clipRect.y > __rect.y) ? clipRect.y: __rect.y;
+ finalClipRect.width = (clipRect.x + clipRect.width > __rect.x + __rect.width) ? (__rect.x + __rect.width) - finalClipRect.x : (clipRect.x + clipRect.width) - finalClipRect.x;
+ finalClipRect.height = (clipRect.y + clipRect.height > __rect.y + __rect.height) ? (__rect.y + __rect.height) - finalClipRect.y : (clipRect.y + clipRect.height) - finalClipRect.y;
+
+ if (__isDisplayBoundsExpandEnabled == true)
+ {
+ finalClipRect.y = clipRect.y;
+ finalClipRect.height = clipRect.height;
+ }
SysTryReturn(NID_GRP, 0.0f <= finalClipRect.width && 0.0f <= finalClipRect.height, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get clip rectangle.");
__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);
{
IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
+ if (lineIndex == 0 && __pTextColumn->GetTotalLineCount() == 0)
+ {
+ return E_SUCCESS;
+ }
+
result r = E_SUCCESS;
FloatRectangle lineBounds;
TextLine* pTextLine = null;
}
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;
return __bidiHint;
}
+result
+TextObject::SetDisplayBoundsExpandEnabled(bool enable)
+{
+ IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
+
+ __isDisplayBoundsExpandEnabled = enable;
+
+ return E_SUCCESS;
+}
+
+bool
+TextObject::IsDisplayBoundsExpandEnabled(void) const
+{
+ IF_NOT_CONSTRUCTED(return false);
+
+ return __isDisplayBoundsExpandEnabled;
+}
+
}}} // Tizen::Graphics::_Text