2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FGrp_TextTextObject.cpp
20 * @brief This is the implementation file for TextObject class.
24 #include <FGrpBitmap.h>
25 #include <FBaseSysLog.h>
26 #include "FGrpCoordinateSystem.h"
27 #include "FGrp_FontImpl.h"
28 #include "FGrp_CanvasImpl.h"
29 #include "../FGrp_ResUtil.h"
30 #include "FGrp_TextTextObject.h"
31 #include "FGrp_TextTextElement.h"
32 #include "FGrp_TextTextSimple.h"
33 #include "FGrp_TextTextImage.h"
34 #include "FGrp_TextTextCutLink.h"
35 #include "FGrp_TextTextComposite.h"
36 #include "FGrp_TextTextLine.h"
37 #include "FGrp_TextTextColumn.h"
38 #include "FGrp_TextTextUtility.h"
39 #include "FGrp_Screen.h"
40 #include "FGrp_CoordinateSystemUtils.h"
44 const int DEFAULT_FONT_SIZE = 42;
47 #define IF_NOT_CONSTRUCTED(code) if (this->__pCompositeText == null || this->__pTextColumn == null) \
59 using namespace Tizen::Base::Utility;
60 using namespace Tizen::Base;
62 namespace Tizen { namespace Graphics
68 TextObject::TextObject(void)
70 __action = TEXT_OBJECT_ACTION_TYPE_NONE;
71 __align = (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
72 __wrap = TEXT_OBJECT_WRAP_TYPE_NONE;
75 __pCompositeText = null;
76 __pDefaultFont = null;
77 __defaultForegroundColor = Color::GetColor(COLOR_ID_BLACK);
78 __defaultBackgroundColor = Color::GetColor(COLOR_ID_WHITE);
79 __defaultOutlineColor = Color::GetColor(COLOR_ID_WHITE);
80 __isAlternateLookEnabled = false;
82 __textObjectEllipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_TAIL;
83 __isFirstDisplayPositionYChanged = false;
88 __slidingGap = CoordinateSystem::ConvertToLogicalX(30.0f);
89 __slidingStep = CoordinateSystem::ConvertToLogicalX(2.0f);
90 __linkViewModeEnabled = false;
91 __isUrlLinkColorDefined = false;
92 __isEmailLinkColorDefined = false;
93 __isPhoneNumberLinkColorDefined = false;
94 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_NORMAL] = Color::GetColor(COLOR_ID_BLUE);
95 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_SELECT] = Color::GetColor(COLOR_ID_BLUE);
96 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_NORMAL] = Color::GetColor(COLOR_ID_BLUE);
97 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_SELECT] = Color::GetColor(COLOR_ID_BLUE);
98 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_NORMAL] = Color::GetColor(COLOR_ID_BLUE);
99 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_SELECT] = Color::GetColor(COLOR_ID_BLUE);
100 __bidiHint = TEXT_BIDI_HINT_NONE;
101 __isDisplayBoundsExpandEnabled = false;
103 __sweepInfo.isValid = false;
104 __sweepInfo.sweepType = TEXT_OBJECT_SWEEP_TYPE_NONE;
105 __sweepInfo.sweepEventType = TEXT_OBJECT_SWEEP_EVENT_INSERT;
106 __sweepInfo.anchorTextIndex = 0;
107 __sweepInfo.anchorLineIndex = 0;
108 __sweepInfo.prevAnchorLineIndex = 0;
109 __sweepInfo.sweepRegionStartLineIndex = 0;
110 __sweepInfo.sweepRegionLineCount = 0;
111 __sweepInfo.insertedLineCount = 0;
112 __sweepInfo.deletedLineCount = 0;
113 __sweepInfo.widthChanged = 0;
116 TextObject::~TextObject(void)
118 Release(__pCompositeText);
119 Release(__pTextColumn);
120 Release(__pDefaultFont);
124 TextObject::Construct(void)
126 result r = E_SUCCESS;
128 __action = TEXT_OBJECT_ACTION_TYPE_NONE;
129 __align = (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
130 __wrap = TEXT_OBJECT_WRAP_TYPE_WORD;
131 __isActionOn = false;
133 __defaultForegroundColor = Color::GetColor(COLOR_ID_BLACK);
134 __defaultBackgroundColor = Color::GetColor(COLOR_ID_WHITE);
135 __defaultOutlineColor = Color::GetColor(COLOR_ID_WHITE);
136 __isAlternateLookEnabled = false;
137 __linkViewModeEnabled = false;
138 __bidiHint = TEXT_BIDI_HINT_NONE;
140 __pCompositeText = new (std::nothrow)TextComposite();
141 SysTryCatch(NID_GRP, __pCompositeText, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
143 __pTextColumn = new (std::nothrow)TextColumn(__pCompositeText);
144 SysTryCatch(NID_GRP, __pTextColumn, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
146 __pDefaultFont = new (std::nothrow)Font();
147 SysTryCatch(NID_GRP, __pDefaultFont, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
149 r = __pDefaultFont->Construct(FONT_STYLE_PLAIN, DEFAULT_FONT_SIZE);
150 SysTryCatch(NID_GRP, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Fail to set font.");
152 __pCompositeText->SetWrap(__wrap);
153 __pCompositeText->SetTextSweepInfo(&__sweepInfo);
158 Release(__pDefaultFont);
159 Release(__pCompositeText);
160 Release(__pTextColumn);
166 TextObject::Construct(const Rectangle& rect)
168 result r = E_SUCCESS;
170 __action = TEXT_OBJECT_ACTION_TYPE_NONE;
171 __align = (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
172 __wrap = TEXT_OBJECT_WRAP_TYPE_WORD;
173 __isActionOn = false;
175 __defaultForegroundColor = Color::GetColor(COLOR_ID_BLACK);
176 __defaultBackgroundColor = Color::GetColor(COLOR_ID_WHITE);
177 __defaultOutlineColor = Color::GetColor(COLOR_ID_WHITE);
178 __isAlternateLookEnabled = false;
179 __linkViewModeEnabled = false;
180 __bidiHint = TEXT_BIDI_HINT_NONE;
181 __rect = _CoordinateSystemUtils::ConvertToFloat(rect);
183 __pCompositeText = new (std::nothrow)TextComposite();
184 SysTryCatch(NID_GRP, __pCompositeText, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
186 __pTextColumn = new (std::nothrow)TextColumn(__pCompositeText);
187 SysTryCatch(NID_GRP, __pTextColumn, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
189 __pDefaultFont = new (std::nothrow)Font();
190 SysTryCatch(NID_GRP, __pTextColumn, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
192 r = __pDefaultFont->Construct(FONT_STYLE_PLAIN, DEFAULT_FONT_SIZE);
193 SysTryCatch(NID_GRP, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Fail to set font.");
195 __pCompositeText->SetWrap(__wrap);
196 __pCompositeText->SetTextSweepInfo(&__sweepInfo);
201 Release(__pDefaultFont);
202 Release(__pCompositeText);
203 Release(__pTextColumn);
209 TextObject::Construct(const FloatRectangle& rect)
211 result r = E_SUCCESS;
213 __action = TEXT_OBJECT_ACTION_TYPE_NONE;
214 __align = (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
215 __wrap = TEXT_OBJECT_WRAP_TYPE_WORD;
216 __isActionOn = false;
218 __defaultForegroundColor = Color::GetColor(COLOR_ID_BLACK);
219 __defaultBackgroundColor = Color::GetColor(COLOR_ID_WHITE);
220 __defaultOutlineColor = Color::GetColor(COLOR_ID_WHITE);
221 __isAlternateLookEnabled = false;
222 __linkViewModeEnabled = false;
223 __bidiHint = TEXT_BIDI_HINT_NONE;
226 __pCompositeText = new (std::nothrow)TextComposite();
227 SysTryCatch(NID_GRP, __pCompositeText, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
229 __pTextColumn = new (std::nothrow)TextColumn(__pCompositeText);
230 SysTryCatch(NID_GRP, __pTextColumn, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
232 __pDefaultFont = new (std::nothrow)Font();
233 SysTryCatch(NID_GRP, __pTextColumn, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
235 r = __pDefaultFont->Construct(FONT_STYLE_PLAIN, DEFAULT_FONT_SIZE);
236 SysTryCatch(NID_GRP, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Fail to set font.");
238 __pCompositeText->SetWrap(__wrap);
239 __pCompositeText->SetTextSweepInfo(&__sweepInfo);
244 Release(__pDefaultFont);
245 Release(__pCompositeText);
246 Release(__pTextColumn);
252 TextObject::CloneN(void)
254 IF_NOT_CONSTRUCTED(return null);
256 result r = E_SUCCESS;
257 TextObject* pTextObject = null;
258 TextElement* pTextElement = null;
259 TextElement* pCloneTextElement = null;
260 int count = __pCompositeText->GetElementCount();
262 pTextObject = new (std::nothrow)TextObject();
263 SysTryReturn(NID_GRP, pTextObject, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
265 r = pTextObject->Construct();
266 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
268 for (int i=0; i < count; i++)
270 pTextElement = __pCompositeText->GetElementAtElementIndex(i);
271 SysTryCatch(NID_GRP, pTextElement, , E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
273 pCloneTextElement = pTextElement->CloneN(SET_ALLVALUE_CLONE,0);
274 pTextObject->AppendElement(*pCloneTextElement);
277 SetLastResult(E_SUCCESS);
282 Release(pTextObject);
288 TextObject::Draw(_CanvasImpl& canvasImpl)
290 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
292 if (__rect.width == 0.0f || __rect.height == 0.0f)
297 result r = E_SUCCESS;
298 TextLine* pTextLine = null;
299 FloatRectangle clipRect;
300 FloatRectangle lineBounds;
301 FloatRectangle targetBounds;
302 float totalHeight = 0;
303 float slidingWidth = 0;
305 SysTryReturn(NID_GRP, __rect.width > 0.0f && __rect.height > 0.0f, E_INVALID_STATE, E_INVALID_STATE
306 , "[E_INVALID_STATE] This instance is not constructed yet. (width = %d, height = %d)", __rect.width, __rect.height);
308 TextBidiHint bidiHint = _GetTextBidiHint();
309 _SetTextBidiHint(__bidiHint);
312 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
314 if (__pTextColumn->GetTotalLineCount() <= 1)
316 __pTextColumn->SetFirstDisplayLineIndex(0);
317 __pTextColumn->SetFirstDisplayPositionY(0.0f);
320 targetBounds = __rect;
322 if (__action == TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT)
324 if (__pTextColumn->GetTotalLineCount() == 0)
329 totalHeight = TextUtility::GetFontMaxHeightF(__pDefaultFont);
333 totalHeight = __pTextColumn->GetTotalHeightF();
336 if (totalHeight == 0)
341 if (totalHeight < targetBounds.height)
343 switch (__align & TEXT_ALIGNMASK_VERT)
345 case TEXT_OBJECT_ALIGNMENT_TOP:
350 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
351 targetBounds.y += (targetBounds.height - totalHeight) / 2.0f;
354 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
355 targetBounds.y += targetBounds.height - totalHeight;
361 if (targetBounds.height < totalHeight)
363 if (__action == TEXT_OBJECT_ACTION_TYPE_ABBREV)
366 int lineCount = __pTextColumn->GetTotalLineCount();
370 totalHeight = targetBounds.height;
374 float lineHeight = __pTextColumn->GetLineHeightAtF(0);
376 if (targetBounds.height < lineHeight)
378 totalHeight = targetBounds.height;
384 for (i = 0; i < lineCount; i++)
386 lineHeight += __pTextColumn->GetLineHeightAtF(i);
387 if (targetBounds.height < lineHeight)
389 lineHeight -= __pTextColumn->GetLineHeightAtF(i);
394 totalHeight = lineHeight;
408 switch (__align & TEXT_ALIGNMASK_VERT)
410 case TEXT_OBJECT_ALIGNMENT_TOP:
415 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
416 targetBounds.y += (targetBounds.height - totalHeight) / 2.0f;
419 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
420 targetBounds.y += targetBounds.height - totalHeight;
423 targetBounds.height = totalHeight;
427 FloatRectangle finalClipRect;
428 clipRect = canvasImpl.GetClipBoundsF();
430 finalClipRect.x = (clipRect.x > __rect.x) ? clipRect.x : __rect.x;
431 finalClipRect.y = (clipRect.y > __rect.y) ? clipRect.y: __rect.y;
432 finalClipRect.width = (clipRect.x + clipRect.width > __rect.x + __rect.width) ? (__rect.x + __rect.width) - finalClipRect.x : (clipRect.x + clipRect.width) - finalClipRect.x;
433 finalClipRect.height = (clipRect.y + clipRect.height > __rect.y + __rect.height) ? (__rect.y + __rect.height) - finalClipRect.y : (clipRect.y + clipRect.height) - finalClipRect.y;
435 if (__isDisplayBoundsExpandEnabled == true)
437 finalClipRect.y = clipRect.y;
438 finalClipRect.height = clipRect.height;
441 SysTryReturn(NID_GRP, 0.0f <= finalClipRect.width && 0.0f <= finalClipRect.height, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get clip rectangle.");
443 canvasImpl.SetClipBounds(finalClipRect);
447 case TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT:
448 pTextLine = __pTextColumn->GetTextLine(0);
449 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
451 lineBounds = pTextLine->GetBoundsF();
452 __pTextColumn->SetDisplayLineCount(1);
453 __pTextColumn->SetDisplayHeight(lineBounds.height);
455 slidingWidth = (__pTextColumn->GetSlidingDimension().width > __rect.width) ? __pTextColumn->GetSlidingDimension().width : __rect.width;
459 FloatRectangle slidingRect;
461 targetBounds.width = lineBounds.width;
462 targetBounds.height = lineBounds.height;
464 slidingRect = targetBounds;
466 slidingRect.x += __pTextColumn->GetSlidingPositionF();
467 FloatDimension slidingDim = __pTextColumn->GetSlidingDimensionF();
468 slidingRect.width = slidingDim.width;
469 slidingRect.height = slidingDim.height;
471 __pCompositeText->Draw(canvasImpl, slidingRect, 0, __pCompositeText->GetTextLength(),
472 (TextObjectAlignment)(__align & TEXT_ALIGNMASK_HORIZ), TEXT_OBJECT_ACTION_TYPE_NONE);
474 slidingRect.x += slidingDim.width + __slidingGap;
475 if (slidingRect.x < targetBounds.x + targetBounds.width)
477 slidingRect.width = targetBounds.x + targetBounds.width - slidingRect.x;
478 __pCompositeText->Draw(canvasImpl, slidingRect, 0, __pCompositeText->GetTextLength()
479 ,(TextObjectAlignment)(__align & TEXT_ALIGNMASK_HORIZ), TEXT_OBJECT_ACTION_TYPE_NONE);
484 pTextLine->Draw(canvasImpl, targetBounds, 0, pTextLine->GetTextLength(),
485 (TextObjectAlignment)(__align & TEXT_ALIGNMASK_HORIZ), TEXT_OBJECT_ACTION_TYPE_NONE);
489 case TEXT_OBJECT_ACTION_TYPE_SLIDE_UP:
491 FloatRectangle slidingRect = targetBounds;
492 slidingRect.y += __pTextColumn->GetSlidingPositionF();
494 int lineCount = __pTextColumn->GetTotalLineCount();
495 for (int i = 0; i < lineCount; i++)
497 pTextLine = __pTextColumn->GetTextLine(i);
498 if (pTextLine != null)
500 lineBounds = pTextLine->GetBoundsF();
501 slidingRect.height = lineBounds.height;
502 if ((slidingRect.y + slidingRect.height >= targetBounds.y) && (slidingRect.y < targetBounds.y + targetBounds.height))
504 pTextLine->Draw(canvasImpl, slidingRect, 0, pTextLine->GetTextLength(),
505 (TextObjectAlignment)(__align & TEXT_ALIGNMASK_HORIZ), TEXT_OBJECT_ACTION_TYPE_NONE);
508 slidingRect.y += slidingRect.height;
513 case TEXT_OBJECT_ACTION_TYPE_ABBREV:
514 if (__pCompositeText->IsTextAbbreviationEnabled())
516 __pCompositeText->DrawAbbrev(canvasImpl, targetBounds, __align);
520 DrawByLine(canvasImpl, targetBounds);
524 case TEXT_OBJECT_ACTION_TYPE_NONE:
527 DrawByLine(canvasImpl, targetBounds);
531 canvasImpl.SetClipBounds(clipRect);
532 _SetTextBidiHint(bidiHint);
538 TextObject::GetChangedLineRange(int& startChangedLineIndex, int& endChangedLineIndex)
540 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
542 result r = E_SUCCESS;
545 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
547 startChangedLineIndex = __sweepInfo.sweepRegionStartLineIndex;
548 endChangedLineIndex = __sweepInfo.sweepRegionStartLineIndex + __sweepInfo.sweepRegionLineCount - 1;
554 TextObject::DrawLine(_CanvasImpl& canvasImpl, int lineIndex)
556 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
558 SysTryReturn(NID_GRP, lineIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
560 result r = E_SUCCESS;
561 TextLine* pTextLine = null;
562 FloatRectangle lineBounds;
563 float firstDisplayY = __pTextColumn->GetFirstDisplayPositionYF();
565 TextBidiHint bidiHint = _GetTextBidiHint();
566 _SetTextBidiHint(__bidiHint);
569 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
571 pTextLine = __pTextColumn->GetTextLine(lineIndex);
572 if (pTextLine == null)
574 SysLog(NID_GRP, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d, total line count = %d)"
575 , lineIndex, __pTextColumn->GetTotalLineCount());
577 return E_INVALID_ARG;
580 lineBounds = pTextLine->GetBoundsF();
581 lineBounds.y = lineBounds.y - firstDisplayY + __rect.y;
583 int length = pTextLine->GetTextLength();
584 pTextLine->Draw(canvasImpl, lineBounds, 0, length, __align, TEXT_OBJECT_ACTION_TYPE_NONE);
586 _SetTextBidiHint(bidiHint);
592 TextObject::DrawWithOffset(_CanvasImpl& canvasImpl)
594 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
596 SysTryReturn(NID_GRP, __isActionOn, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Action is off.");
598 float slidingStartIndex = __pTextColumn->GetSlidingPositionF();
599 FloatDimension slidingDim = __pTextColumn->GetSlidingDimensionF();
603 case TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT:
604 if (__rect.width < slidingDim.width)
606 slidingDim.width = (slidingDim.width > __rect.width) ? slidingDim.width: __rect.width;
608 if (__slidingStep < slidingStartIndex + slidingDim.width + __slidingGap)
610 slidingStartIndex -= __slidingStep;
614 slidingStartIndex += slidingDim.width + __slidingGap;
619 if (0.0f < slidingStartIndex + slidingDim.width)
621 slidingStartIndex -= __slidingStep;
625 slidingStartIndex = __rect.width + __slidingGap + slidingStartIndex;
628 __pTextColumn->SetSlidingPosition(slidingStartIndex);
631 case TEXT_OBJECT_ACTION_TYPE_SLIDE_UP:
632 if (slidingStartIndex + slidingDim.height >= 0.0f)
634 slidingStartIndex -= __slidingStep;
638 slidingStartIndex = __rect.height;
640 __pTextColumn->SetSlidingPosition(slidingStartIndex);
643 case TEXT_OBJECT_ACTION_TYPE_ABBREV:
645 case TEXT_OBJECT_ACTION_TYPE_NONE:
651 return Draw(canvasImpl);
655 TextObject::UpdateChangedInfo(int startTextIndex, int textLength)
657 result r = E_SUCCESS;
659 if (startTextIndex >= 0)
661 r = __pTextColumn->SetChangeAction(TextColumn::TEXT_CHANGE_UNKONWN, startTextIndex, 0);
662 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
667 if (IsPartialComposingModeEnabled())
669 __pCompositeText->InitPartialComposeMode();
676 TextObject::IsChanged(void) const
678 IF_NOT_CONSTRUCTED(return false);
684 TextObject::SetPartialComposingModeEnabled(bool enable)
686 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
688 __pCompositeText->SetPartialComposingModeEnabled(enable);
694 TextObject::IsPartialComposingModeEnabled(void) const
696 IF_NOT_CONSTRUCTED(return false);
698 return __pCompositeText->IsPartialComposingModeEnabled();
702 TextObject::Compose(void)
704 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
706 SysTryReturn(NID_GRP, __rect.width >= 0.0f && __rect.height >= 0.0f, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet.");
708 TextBidiHint bidiHint = _GetTextBidiHint();
709 _SetTextBidiHint(__bidiHint);
712 FloatRectangle rect = __rect;
713 FloatRectangle lineBounds;
715 if (__pCompositeText->IsPartialComposingModeEnabled())
717 if (__pCompositeText->IsComposeDone() || !__isFirstDisplayPositionYChanged)
719 if (GetTotalLineCount() != 0)
727 if (!__isChanged || __pTextColumn->GetChangeActionEventCount() == 0)
733 __isActionOn = false;
735 if (__pTextColumn->GetTotalLineCount() == 0)
737 __pTextColumn->SetChangeAction(TextColumn::TEXT_CHANGE_UNKONWN, 0, 0);
738 __pTextColumn->SetFirstDisplayLineIndex(0);
739 __pTextColumn->SetFirstDisplayPositionY(0.0f);
743 lineCount = __pCompositeText->Compose(rect, __pTextColumn);
747 case TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT:
749 TextLine* pTextLine = __pTextColumn->GetTextLine(0);
750 if (pTextLine != null)
752 int lineLength = pTextLine->GetTextLength();
753 int totalLength = __pCompositeText->GetTextLength();
755 if (lineLength < totalLength)
758 __pTextColumn->SetSlidingPosition(0.0f);
760 FloatDimension slidingDim;
761 FloatDimension lineTextSize;
763 __pCompositeText->GetRegion(0, totalLength, slidingDim.width, slidingDim.height);
764 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
765 lineBounds = pTextLine->GetBoundsF();
767 __pTextColumn->SetSlidingDimension(slidingDim);
769 lineBounds.height = slidingDim.height;
770 lineTextSize.width = lineBounds.width;
772 pTextLine->SetBounds(lineBounds);
773 pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
779 case TEXT_OBJECT_ACTION_TYPE_SLIDE_UP:
781 __pTextColumn->SetSlidingPosition(0.0f);
783 float totalHeight = __pTextColumn->GetTotalHeightF();
784 FloatDimension slidingDim;
785 slidingDim.width = __rect.width;
786 slidingDim.height = totalHeight;
788 __pTextColumn->SetSlidingDimension(slidingDim);
790 if (__rect.height < totalHeight)
797 case TEXT_OBJECT_ACTION_TYPE_ABBREV:
799 case TEXT_OBJECT_ACTION_TYPE_NONE:
807 _SetTextBidiHint(bidiHint);
813 TextObject::GetText(wchar_t* pCopiedText, int textLength) const
815 IF_NOT_CONSTRUCTED(return -1);
817 SysTryReturn(NID_GRP, pCopiedText, -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
818 SysTryReturn(NID_GRP, textLength > 0, -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
820 int textElementCount = 0;
822 int outLength = textLength;
823 int copiedLength = 0;
824 TextElement* pTextElement = null;
825 wchar_t* pSrcText = null;
826 wchar_t* pDstText = null;
828 textElementCount = __pCompositeText->GetElementCount();
829 pDstText = pCopiedText;
831 for (int i = 0; i < textElementCount && totalLength < outLength; i++)
833 pTextElement = __pCompositeText->GetElementAtElementIndex(i);
834 if (pTextElement == null)
839 TextElementType objectType = pTextElement->GetType();
840 if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK)
842 int elementTextLength = pTextElement->GetTextLength();
843 TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
844 if (pSimpleText != null)
846 copiedLength = (elementTextLength > outLength - totalLength) ? outLength - totalLength : elementTextLength;
847 SysTryReturn(NID_GRP, 0 <= copiedLength, -1, E_SYSTEM, "[E_SYSTEM] Fail to string copy.");
849 pSrcText = (wchar_t*)pSimpleText->GetText();
851 result r = TextUtility::CopyText(pDstText, pSrcText, copiedLength);
852 SysTryReturn(NID_GRP, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
854 pDstText += copiedLength;
855 totalLength += copiedLength;
860 SetLastResult(E_SUCCESS);
866 TextObject::SetFirstDisplayLineIndex(int lineIndex)
868 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
870 if (lineIndex == 0 && __pTextColumn->GetTotalLineCount() == 0)
875 result r = E_SUCCESS;
876 FloatRectangle lineBounds;
877 TextLine* pTextLine = null;
878 float firstDisplayPositionY = 0.0f;
879 float rollbackFirstDisplayPositionY = 0.0f;
880 int rollbackFirstDisplayLineIndex = 0;
882 rollbackFirstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
883 rollbackFirstDisplayLineIndex = __pTextColumn->GetFirstDisplayLineIndex();
885 __pTextColumn->SetFirstDisplayLineIndex(lineIndex);
887 pTextLine = __pTextColumn->GetTextLine(lineIndex);
888 SysTryCatch(NID_GRP, pTextLine, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
890 lineBounds = pTextLine->GetBoundsF();
891 firstDisplayPositionY = lineBounds.y;
893 __pTextColumn->SetFirstDisplayPositionY(firstDisplayPositionY);
898 __pTextColumn->SetFirstDisplayLineIndex(rollbackFirstDisplayLineIndex);
899 __pTextColumn->SetFirstDisplayPositionY(rollbackFirstDisplayPositionY);
905 TextObject::SetFirstDisplayPositionY(int y)
907 return SetFirstDisplayPositionY(_CoordinateSystemUtils::ConvertToFloat(y));
911 TextObject::SetFirstDisplayPositionY(float y)
913 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
915 result r = E_SUCCESS;
917 if (IsPartialComposingModeEnabled())
919 __isFirstDisplayPositionYChanged = true;
921 if (__pCompositeText->GetTotalComposedHeight() <= (y + __rect.height))
923 __pCompositeText->SetComposePartialLimitHeight(y + __rect.height - GetTotalComposedHeight());
926 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
930 __isFirstDisplayPositionYChanged = false;
931 __pTextColumn->SetFirstDisplayPositionY(y);
936 __isFirstDisplayPositionYChanged = false;
941 TextObject::GetMaxLineHeight(void) const
943 return _CoordinateSystemUtils::ConvertToInteger(GetMaxLineHeightF());
947 TextObject::GetMaxLineHeightF(void) const
949 IF_NOT_CONSTRUCTED(return -1);
951 float lineMaxHeight = __pCompositeText->GetMaxLineHeightF();
952 float fontMaxHeight = TextUtility::GetFontMaxHeightF(__pDefaultFont);
954 return (lineMaxHeight > fontMaxHeight) ? lineMaxHeight: fontMaxHeight;
958 TextObject::IsDisplayedAtStartPosition(void) const
960 IF_NOT_CONSTRUCTED(return false);
962 float firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
964 bool isDisplayedAtStartPosition = (firstDisplayPositionY == 0.0f) ? true : false;
966 return isDisplayedAtStartPosition;
970 TextObject::IsDisplayedAtEndPosition(void) const
972 IF_NOT_CONSTRUCTED(return false);
974 float totalHeight = 0.0f;
975 float firstDisplayPositionY = 0.0f;
977 firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
978 totalHeight = __pTextColumn->GetTotalHeightF();
980 bool isDisplayedAtEndPosition = ((totalHeight - firstDisplayPositionY) <= __rect.height) ? true : false;
982 return isDisplayedAtEndPosition;
986 TextObject::IsDisplayedFirstLine(void) const
988 IF_NOT_CONSTRUCTED(return false);
990 float firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
991 float firstLineHeight = GetLineHeightAtF(0);
993 bool isDisplayedFirstLine = false;
994 if(firstDisplayPositionY == 0.0f || firstDisplayPositionY < firstLineHeight)
996 isDisplayedFirstLine = true;
999 return isDisplayedFirstLine;
1003 TextObject::IsDisplayedLastLine(void) const
1005 IF_NOT_CONSTRUCTED(return false);
1007 float totalHeight = 0.0f;
1008 float firstDisplayPositionY = 0.0f;
1009 bool isDisplayedLastLine = false;
1011 firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
1012 totalHeight = __pTextColumn->GetTotalHeightF();
1014 float lastLineHeight = GetLineHeightAtF(GetTotalLineCount()-1);
1016 float remainingHeight = totalHeight - firstDisplayPositionY;
1017 if (remainingHeight - __rect.height < lastLineHeight || remainingHeight <= __rect.height)
1019 isDisplayedLastLine = true;
1022 return isDisplayedLastLine;
1026 TextObject::SetAction(TextObjectActionType action)
1028 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1030 SysTryReturn(NID_GRP, TEXT_OBJECT_ACTION_TYPE_NONE <= action && action < TEXT_OBJECT_ACTION_TYPE_MAX
1031 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1033 if (__action != action)
1035 if ((__action == TEXT_OBJECT_ACTION_TYPE_NONE && action == TEXT_OBJECT_ACTION_TYPE_ABBREV) ||
1036 (__action == TEXT_OBJECT_ACTION_TYPE_ABBREV && action == TEXT_OBJECT_ACTION_TYPE_NONE))
1039 UpdateChangedInfo(0, 0);
1044 UpdateChangedInfo(0, 0);
1048 bool isAbbreviationEnable = (__action == TEXT_OBJECT_ACTION_TYPE_ABBREV) ? true : false;
1049 __pCompositeText->SetTextAbbreviationEnabled(isAbbreviationEnable);
1055 TextObject::SetAlignment(TextObjectAlignment alignment)
1057 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1059 SysTryReturn(NID_GRP, TEXT_OBJECT_ALIGNMENT_LEFT <= alignment && alignment < TEXT_OBJECT_ALIGNMENT_INVALID
1060 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. alignment(%d)", alignment);
1062 if (__align != alignment)
1064 __align = alignment;
1065 UpdateChangedInfo(0, 0);
1072 TextObject::SetBounds(const Rectangle& rect)
1074 return SetBounds(_CoordinateSystemUtils::ConvertToFloat(rect));
1078 TextObject::SetBounds(const FloatRectangle& rect)
1080 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1082 SysTryReturn(NID_GRP, (rect.width >= 0.0f) && (rect.height >= 0.0f), E_OUT_OF_RANGE, E_OUT_OF_RANGE
1083 , "[E_OUT_OF_RANGE] The given rectangle(width:%d,height:%d) is out of range.\n", rect.width, rect.height);
1085 if (__rect.width != rect.width)
1087 UpdateChangedInfo(0, 0);
1096 TextObject::SetLineSpace(int lineSpacing)
1098 return SetLineSpace(_CoordinateSystemUtils::ConvertToFloat(lineSpacing));
1102 TextObject::SetLineSpace(float lineSpacing)
1104 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1106 SysTryReturn(NID_GRP, lineSpacing >= 0.0f, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. lineSpacing(%d)", lineSpacing);
1108 if (__pCompositeText->GetLineSpace() != lineSpacing)
1110 __pCompositeText->SetLineSpace(lineSpacing);
1118 TextObject::SetElementVerticalAlignment(TextObjectAlignment alignment)
1120 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1122 SysTryReturn(NID_GRP
1123 , (alignment & TEXT_OBJECT_ALIGNMENT_TOP) || (alignment & TEXT_OBJECT_ALIGNMENT_MIDDLE) || (alignment & TEXT_OBJECT_ALIGNMENT_BOTTOM) || (alignment & TEXT_OBJECT_ALIGNMENT_BASELINE)
1124 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. alignment(%d)", alignment);
1126 if (__pCompositeText->GetElementVerticalAlignment() == alignment)
1131 __pCompositeText->SetElementVerticalAlignment(alignment);
1138 TextObject::GetTextExtent(int startTextIndex, int textLength) const
1140 return _CoordinateSystemUtils::ConvertToInteger(GetTextExtentF(startTextIndex,textLength));
1144 TextObject::GetTextExtentF(int startTextIndex, int textLength) const
1146 IF_NOT_CONSTRUCTED(return FloatDimension(-1, -1));
1148 TextBidiHint bidiHint = _GetTextBidiHint();
1149 _SetTextBidiHint(__bidiHint);
1151 FloatDimension textSize;
1152 result r = __pCompositeText->GetRegion(startTextIndex, textLength, textSize.width, textSize.height);
1153 SysTryReturn(NID_GRP, r == E_SUCCESS, FloatDimension(-1, -1), r, "[%s] Propagating.", GetErrorMessage(r));
1155 _SetTextBidiHint(bidiHint);
1157 SetLastResult(E_SUCCESS);
1163 TextObject::GetTextExtent(void) const
1165 return _CoordinateSystemUtils::ConvertToInteger(GetTextExtentF());
1169 TextObject::GetTextExtentF(void) const
1171 IF_NOT_CONSTRUCTED(return FloatDimension(-1, -1));
1173 TextBidiHint bidiHint = _GetTextBidiHint();
1174 _SetTextBidiHint(__bidiHint);
1176 TextLine* pTextLine = null;
1177 FloatDimension textSize(0.0f, 0.0f);
1178 FloatDimension lineSize(0.0f, 0.0f);
1179 int lineCount = GetTotalLineCount();
1181 for (int i = 0; i < lineCount; i++)
1183 pTextLine = __pTextColumn->GetTextLine(i);
1184 SysTryReturn(NID_GRP, pTextLine, FloatDimension(-1, -1), E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
1186 pTextLine->GetRegion(0, pTextLine->GetTextLength(), lineSize.width, lineSize.height);
1188 if (textSize.width < lineSize.width)
1190 textSize.width = lineSize.width;
1194 textSize.height = GetTotalHeightF();
1196 _SetTextBidiHint(bidiHint);
1198 SetLastResult(E_SUCCESS);
1204 TextObject::AppendElement(TextElement& textElement)
1206 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1208 result r = E_SUCCESS;
1209 TextElementType objecType = textElement.GetType();
1210 if (objecType == TEXT_ELEMENT_TYPE_CUTLINK)
1212 TextCutLink* pLinkText = dynamic_cast < TextCutLink* >(&textElement);
1213 if (pLinkText != null)
1215 switch (pLinkText->GetCutLinkType())
1218 if (__isUrlLinkColorDefined)
1220 pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_NORMAL], __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_SELECT]);
1224 case LINK_TYPE_EMAIL:
1225 if (__isEmailLinkColorDefined)
1227 pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_NORMAL], __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_SELECT]);
1231 case LINK_TYPE_TEL_NUM:
1232 if (__isPhoneNumberLinkColorDefined)
1234 pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_NORMAL],
1235 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_SELECT]);
1245 int textIndex = __pCompositeText->GetTextLength();
1246 int elementTextLength = textElement.GetTextLength();
1248 r = __pCompositeText->AppendElement(textElement);
1249 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1251 int elementCount = __pCompositeText->GetElementCount();
1252 if (elementCount > 0)
1254 __pCompositeText->Optimize(elementCount-1, elementCount-1);
1257 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
1259 UpdateChangedInfo(0, 0);
1263 NotifyTextAdded(textIndex, elementTextLength);
1270 TextObject::InsertElementAt(int textIndex, TextElement& textElement)
1272 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1274 result r = E_SUCCESS;
1275 TextElementType objecType = textElement.GetType();
1277 if (objecType == TEXT_ELEMENT_TYPE_CUTLINK)
1279 TextCutLink* pLinkText = dynamic_cast < TextCutLink* >(&textElement);
1280 if (pLinkText != null)
1282 switch (pLinkText->GetCutLinkType())
1285 if (__isUrlLinkColorDefined)
1287 pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_NORMAL],
1288 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_SELECT]);
1292 case LINK_TYPE_EMAIL:
1293 if (__isEmailLinkColorDefined)
1295 pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_NORMAL],
1296 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_SELECT]);
1300 case LINK_TYPE_TEL_NUM:
1301 if (__isPhoneNumberLinkColorDefined)
1303 pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_NORMAL],
1304 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_SELECT]);
1314 r = __pCompositeText->InsertElementAt(textElement, textIndex);
1315 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Fail to insert element.", GetErrorMessage(r));
1317 int elementIndex = __pCompositeText->GetElementIndexOf(textElement);
1318 if (elementIndex != -1)
1320 __pCompositeText->Optimize(elementIndex, elementIndex);
1323 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
1325 UpdateChangedInfo(0, 0);
1329 NotifyTextAdded(textIndex, textElement.GetTextLength());
1336 TextObject::RemoveAll(bool deallocate)
1338 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1340 result r = __pTextColumn->RemoveAllLines();
1341 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1343 r = __pCompositeText->RemoveAllElements(deallocate);
1344 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1346 UpdateChangedInfo(0);
1348 __isActionOn = false;
1354 TextObject::Remove(int startTextIndex, int textLength)
1356 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1358 SysTryReturn(NID_GRP, startTextIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1360 result r = __pTextColumn->RemoveAllLines();
1361 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1363 r = __pCompositeText->Remove(startTextIndex, textLength);
1364 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1366 UpdateChangedInfo(0);
1372 TextObject::RemoveElement(TextElement& textElement, bool deallocate)
1374 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1376 result r = E_SUCCESS;
1377 int elementIndex = 0;
1379 int elementTextLength = 0;
1380 TextElement* pCurrentTextElement = null;
1382 elementIndex = __pCompositeText->GetElementIndexOf(textElement);
1383 SysTryReturn(NID_GRP, 0 <= elementIndex, E_INVALID_ARG, E_INVALID_ARG, "[E_SYSTEM] The argument is invalid.");
1385 for (int i = 0; i < elementIndex; i++)
1387 pCurrentTextElement = __pCompositeText->GetElementAtElementIndex(i);
1388 if (pCurrentTextElement != null)
1390 textIndex += pCurrentTextElement->GetTextLength();
1394 elementTextLength = textElement.GetTextLength();
1396 r = __pCompositeText->RemoveElementAt(elementIndex, deallocate);
1397 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1399 NotifyTextDeleted(textIndex, elementTextLength);
1401 if (__pCompositeText->GetElementCount() == 0 || GetTextLength() == 0)
1403 __pTextColumn->RemoveAllLines();
1410 TextObject::GetElementAtTextIndex(int textIndex) const
1412 IF_NOT_CONSTRUCTED(return null);
1414 TextElement* pTextElement = null;
1415 int elementTextLength = 0;
1416 int textIndexFromElementOffset = 0;
1417 int elementIndex = 0;
1418 int elementOffset = 0;
1420 pTextElement = __pCompositeText->GetElementAtTextIndex(textIndex, elementOffset, elementIndex, elementTextLength,textIndexFromElementOffset);
1421 SysTryCatch(NID_GRP, pTextElement, , E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
1423 SetLastResult(E_SUCCESS);
1424 return pTextElement;
1433 TextObject::SetFont(Font* pFont, int startTextIndex, int textLength)
1435 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1437 SysTryReturn(NID_GRP, pFont, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1438 SysTryReturn(NID_GRP, startTextIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1440 result r = E_SUCCESS;
1441 Font* pTmpFont = null;
1443 pTmpFont = _FontImpl::CloneN(const_cast < Font& >(*pFont));
1444 r = GetLastResult();
1445 SysTryReturn(NID_GRP, pTmpFont, r, r, "[%s] Propagating.", GetErrorMessage(r));
1447 Release(__pDefaultFont);
1449 __pDefaultFont = pTmpFont;
1451 __pCompositeText->SetRange(startTextIndex, textLength);
1452 r = __pCompositeText->SetFont(__pDefaultFont);
1453 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1455 UpdateChangedInfo(__pCompositeText->GetWorkStart(), 0);
1461 TextObject::GetFont(int textIndex) const
1463 IF_NOT_CONSTRUCTED(return null);
1465 Font* pFont = __pCompositeText->GetFont(textIndex);
1468 pFont = __pDefaultFont;
1471 SetLastResult(E_SUCCESS);
1476 TextObject::SetDefaultFontSize(int size)
1478 return SetDefaultFontSize(_CoordinateSystemUtils::ConvertToFloat(size));
1482 TextObject::SetDefaultFontSize(float size)
1484 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1486 _FontImpl::GetInstance(*__pDefaultFont)->SetSize(size);
1492 TextObject::GetDefaultFontSize(void) const
1494 return _CoordinateSystemUtils::ConvertToInteger(GetDefaultFontSizeF());
1498 TextObject::GetDefaultFontSizeF(void) const
1500 IF_NOT_CONSTRUCTED(return -1);
1502 return _FontImpl::GetInstance(*__pDefaultFont)->GetSizeF();
1506 TextObject::SetFontSize(int size, int startTextIndex, int textLength)
1508 return SetFontSize(_CoordinateSystemUtils::ConvertToFloat(size), startTextIndex, textLength);
1512 TextObject::SetFontSize(float size, int startTextIndex, int textLength)
1514 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1516 SysTryReturn(NID_GRP
1517 , startTextIndex >= 0
1518 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1520 __pCompositeText->SetRange(startTextIndex, textLength);
1521 __pCompositeText->SetFontSize(size);
1522 UpdateChangedInfo(0, 0);
1528 TextObject::GetFontSize(int textIndex) const
1530 return _CoordinateSystemUtils::ConvertToInteger(GetFontSizeF(textIndex));
1534 TextObject::GetFontSizeF(int textIndex) const
1536 IF_NOT_CONSTRUCTED(return -1);
1538 SysTryReturn(NID_GRP
1540 , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1542 return __pCompositeText->GetFontSizeF(textIndex);
1546 TextObject::SetDefaultFontStyle(int style)
1548 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1550 _FontImpl::GetInstance(*__pDefaultFont)->SetStyle(style);
1556 TextObject::GetDefaultFontStyle(void) const
1558 IF_NOT_CONSTRUCTED(return FONT_STYLE_MIN);
1560 return _FontImpl::GetInstance(*__pDefaultFont)->GetStyle();
1564 TextObject::SetFontStyle(int style, int startTextIndex, int textLength)
1566 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1568 SysTryReturn(NID_GRP
1569 , startTextIndex >= 0
1570 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1572 __pCompositeText->SetRange(startTextIndex, textLength);
1573 __pCompositeText->SetFontStyle(style);
1574 UpdateChangedInfo(0, 0);
1580 TextObject::GetFontStyle(int textIndex) const
1582 IF_NOT_CONSTRUCTED(return -1);
1584 SysTryReturn(NID_GRP
1586 , FONT_STYLE_MIN, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1588 return __pCompositeText->GetFontStyle(textIndex);
1592 TextObject::SetDefaultForegroundColor(const Color& color)
1594 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1596 __defaultForegroundColor = color;
1602 TextObject::GetDefaultForegroundColor(void) const
1604 IF_NOT_CONSTRUCTED(return Color::GetColor(COLOR_ID_BLACK));
1606 return __defaultForegroundColor;
1610 TextObject::SetForegroundColor(const Color& color, int startTextIndex, int textLength)
1612 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1614 SysTryReturn(NID_GRP, startTextIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1616 __defaultForegroundColor = color;
1618 __pCompositeText->SetRange(startTextIndex, textLength);
1619 __pCompositeText->SetForegroundColor(color);
1625 TextObject::GetForegroundColor(int textIndex) const
1627 IF_NOT_CONSTRUCTED(return Color::GetColor(COLOR_ID_BLACK));
1629 SysTryReturn(NID_GRP, textIndex >= 0, __defaultForegroundColor, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1631 return __pCompositeText->GetForegroundColor(textIndex);
1635 TextObject::SetBackgroundColor(const Color& color, int startTextIndex, int textLength)
1637 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1639 SysTryReturn(NID_GRP, startTextIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1641 __defaultBackgroundColor = color;
1643 __pCompositeText->SetRange(startTextIndex, textLength);
1644 __pCompositeText->SetBackgroundColor(color);
1650 TextObject::GetBackgroundColor(int textIndex) const
1652 IF_NOT_CONSTRUCTED(return Color::GetColor(COLOR_ID_BLACK));
1654 SysTryReturn(NID_GRP, textIndex >= 0, __defaultBackgroundColor, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1656 return __pCompositeText->GetBackgroundColor(textIndex);
1660 TextObject::SetOutlineColor(const Color& color, int startTextIndex, int textLength)
1662 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1664 SysTryReturn(NID_GRP, startTextIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1666 __defaultOutlineColor = color;
1668 __pCompositeText->SetRange(startTextIndex, textLength);
1669 __pCompositeText->SetOutlineColor(color);
1675 TextObject::GetOutlineColor(int textIndex) const
1677 IF_NOT_CONSTRUCTED(return Color::GetColor(COLOR_ID_BLACK));
1679 SysTryReturn(NID_GRP, textIndex >= 0, __defaultOutlineColor, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1681 return __pCompositeText->GetOutlineColor(textIndex);
1685 TextObject::SetBlockColor(const Color& color)
1687 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1689 __pCompositeText->SetBlockColor(color);
1695 TextObject::GetBlockColor(void) const
1697 IF_NOT_CONSTRUCTED(return Color::GetColor(COLOR_ID_BLACK));
1699 return __pCompositeText->GetBlockColor();
1703 TextObject::SetDisplayBitmap(const Bitmap* pBitmap, int startTextIndex, int textLength)
1705 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1707 SysTryReturn(NID_GRP, startTextIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1709 __pCompositeText->SetRange(startTextIndex, textLength);
1710 __pCompositeText->SetDisplayBitmap(pBitmap);
1711 UpdateChangedInfo(0, 0);
1717 TextObject::GetDisplayBitmap(int textIndex) const
1719 IF_NOT_CONSTRUCTED(return null);
1721 return __pCompositeText->GetDisplayBitmap(textIndex);
1725 TextObject::SetWrap(TextObjectWrapType wrap)
1727 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1734 result r = __pCompositeText->SetWrap(wrap);
1735 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1738 UpdateChangedInfo(0, 0);
1744 TextObject::InsertElementAt(int textIndex, Bitmap& bitmap, TextElementSourceType sourceType)
1746 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1748 TextImage* pImageText = new (std::nothrow)TextImage(bitmap, sourceType, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP));
1749 SysTryReturn(NID_GRP, pImageText, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
1751 int addedTextLength = pImageText->GetTextLength();
1752 __pCompositeText->InsertElementAt(*pImageText, textIndex);
1753 int startTextIndex = __pCompositeText->GetWorkStart();
1754 NotifyTextAdded(startTextIndex, addedTextLength);
1760 TextObject::AppendElement(Bitmap& bitmap, TextElementSourceType sourceType)
1762 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1764 result r = E_SUCCESS;
1765 TextImage* pImageText = new (std::nothrow)TextImage(bitmap, sourceType, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP));
1766 SysTryReturn(NID_GRP, pImageText, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
1768 r = __pCompositeText->AppendElement(*pImageText);
1769 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1771 int startTextIndex = __pCompositeText->GetWorkStart();
1772 int elementTextLength = pImageText->GetTextLength();
1774 NotifyTextAdded(startTextIndex, elementTextLength);
1780 TextObject::SetAlternateLookEnabled(bool enable)
1782 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1784 TextElement* pTextElement = null;
1786 __isAlternateLookEnabled = enable;
1787 int elementCount = __pCompositeText->GetElementCount();
1789 for (int i = 0; i < elementCount; i++)
1791 pTextElement = __pCompositeText->GetElementAtElementIndex(i);
1792 if (pTextElement != null)
1794 pTextElement->SetAlternateLookEnabled(enable);
1802 TextObject::SetAlternativeForegroundColor(const Color& color)
1804 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1806 TextElement* pTextElement = null;
1807 int elementCount = __pCompositeText->GetElementCount();
1809 for (int i = 0; i < elementCount; i++)
1811 pTextElement = __pCompositeText->GetElementAtElementIndex(i);
1812 SysTryReturn(NID_GRP, pTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
1814 pTextElement->SetAlternativeForegroundColor(color);
1821 TextObject::ChangeTextOffset(wchar_t* pText, int textIndex, int gap)
1823 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1825 result r = E_SUCCESS;
1826 int elementStartTextIndex = 0;
1827 int elementIndex = 0;
1828 int elementTextLength = 0;
1829 int textIndexFromElementOffset = 0;
1831 TextElement* pTextElement = __pCompositeText->GetElementAtTextIndex(textIndex, elementStartTextIndex,
1832 elementIndex, elementTextLength, textIndexFromElementOffset);
1834 SysTryReturn(NID_GRP, pTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
1836 r = __pCompositeText->ChangeTextOffset(pText, elementIndex, gap);
1837 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1843 TextObject::NotifyTextChanged(wchar_t* pText, int textOffset, int textLength, int gap)
1845 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1847 result r = E_SUCCESS;
1848 int startTextIndex = __pCompositeText->GetWorkStart();
1849 r = __pCompositeText->NotifyTextChanged(pText, textOffset, textLength, gap, __pDefaultFont,
1850 __defaultForegroundColor, __defaultBackgroundColor, __defaultOutlineColor);
1852 SysTryCatch(NID_GRP, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Fail to update change information.");
1854 if (__wrap != TEXT_OBJECT_WRAP_TYPE_NONE)
1858 NotifyTextAdded(startTextIndex, gap);
1861 InputText(startTextIndex);
1866 NotifyTextDeleted(startTextIndex, -gap);
1870 RemoveText(startTextIndex);
1875 UpdateChangedInfo(startTextIndex, 0);
1877 ChangeText(startTextIndex);
1882 UpdateChangedInfo(startTextIndex, 0);
1888 if (__pCompositeText->GetElementCount() == 0)
1891 TextSimple* pSimpleText = new (std::nothrow)TextSimple(pText, textLength, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1892 AppendElement(*pSimpleText);
1895 UpdateChangedInfo(0, 0);
1902 TextObject::GetTextIndexFromPosition(int x, int y, bool cursorMode) const
1904 return GetTextIndexFromPosition(_CoordinateSystemUtils::ConvertToFloat(x), _CoordinateSystemUtils::ConvertToFloat(y), cursorMode);
1908 TextObject::GetTextIndexFromPosition(float x, float y, bool cursorMode) const
1910 IF_NOT_CONSTRUCTED(return -1);
1912 int lineCount = __pTextColumn->GetTotalLineCount();
1918 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
1920 return GetTextIndexFromPositionInNoneWrap(x, y, !cursorMode);
1924 return GetTextIndexFromPositionInWrap(x, y, !cursorMode);
1929 TextObject::GetTextIndexFromPositionAtLine(int lineIndex, int x, bool cursorMode) const
1931 return GetTextIndexFromPositionAtLine(lineIndex, _CoordinateSystemUtils::ConvertToFloat(x), cursorMode);
1935 TextObject::GetTextIndexFromPositionAtLine(int lineIndex, float x, bool cursorMode) const
1937 IF_NOT_CONSTRUCTED(return -1);
1939 SysTryReturn(NID_GRP, lineIndex >= 0, -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
1941 TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex);
1942 SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
1944 int lineOffset = pTextLine->GetTextOffset();
1945 int lineLength = pTextLine->GetTextLength();
1947 TextElementType objectType;
1948 FloatRectangle lineBounds = pTextLine->GetBoundsF();
1949 FloatDimension lineTextSize;
1950 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
1952 switch (__align & TEXT_ALIGNMASK_HORIZ)
1954 case TEXT_OBJECT_ALIGNMENT_LEFT:
1957 case TEXT_OBJECT_ALIGNMENT_CENTER:
1958 x -= (lineBounds.width - lineTextSize.width) / 2.0f;
1961 case TEXT_OBJECT_ALIGNMENT_RIGHT:
1962 x -= (lineBounds.width - lineTextSize.width);
1966 x = (x < 0.0f) ? 0.0f : x;
1967 __pCompositeText->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
1973 __pCompositeText->ForwardAnalyzeWithFocusedObjectType(lineOffset, lineLength, x, length, objectType);
1977 endType = __pCompositeText->ForwardAnalyzeInNoneCursorMode(lineOffset, lineLength, x, length);
1980 __pCompositeText->SetWrap(__wrap);
1990 int index = pTextLine->GetTextOffset() + length;
1991 if (pTextLine->GetEndType() == TEXT_RETBY_LINEFEED && lineLength == length && pTextLine->GetTextOffset() < index)
1996 if (index != GetTextLength() && index == lineOffset + lineLength)
1998 TextElement* pTextElement = GetElementAtTextIndex(index-1);
1999 if (pTextElement != null)
2001 const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pTextElement);
2002 if (pSimpleText != null)
2004 const wchar_t* pText = pSimpleText->GetText();
2005 SysTryReturn(NID_GRP, pText, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text.");
2007 int i = index - 1 - pSimpleText->GetTextOffset();
2008 SysTryReturn(NID_GRP, i >= 0 && i < pSimpleText->GetTextLength(), -1, E_OUT_OF_RANGE
2009 , "[E_OUT_OF_RANGE] text index(%d) must greater than 0 and must be less than total string length(%d)",i, pSimpleText->GetTextLength());
2011 if (pText[i] == L' ' || pText[i] == TEXT_JAPANESE_SPACE)
2019 SetLastResult(E_SUCCESS);
2025 TextObject::SetFirstDisplayLineIndexFromTextIndex(int textIndex)
2027 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2029 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
2031 return SetFirstDisplayLineIndexFromTextIndexInNoneWrap(textIndex);
2035 return SetFirstDisplayLineIndexFromTextIndexInWrap(textIndex);
2040 TextObject::SetCutLinkViewMode(bool enable)
2042 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2044 if (__linkViewModeEnabled == enable)
2049 __linkViewModeEnabled = enable;
2054 TextObject::GetCutLinkIndexFromPositionData(int x, int y) const
2056 return GetCutLinkIndexFromPositionData(_CoordinateSystemUtils::ConvertToFloat(x), _CoordinateSystemUtils::ConvertToFloat(y));
2060 TextObject::GetCutLinkIndexFromPositionData(float x, float y) const
2062 IF_NOT_CONSTRUCTED(return -1);
2064 result r = E_SUCCESS;
2066 TextBidiHint bidiHint = _GetTextBidiHint();
2067 _SetTextBidiHint(__bidiHint);
2069 int lineCount = __pTextColumn->GetTotalLineCount();
2077 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
2079 textIndex = GetTextIndexFromPositionInNoneWrap(x, y, false);
2083 textIndex = GetTextIndexFromPositionInWrap(x, y, false);
2092 float height = 0.0f;
2093 FloatPoint absPoint;
2094 FloatPoint relPoint;
2096 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
2098 r = GetTextPositionInfoInNoneWrapAt(textIndex, width, height, absPoint.x, absPoint.y, relPoint.x, relPoint.y);
2102 r = GetTextPositionInfoInWrapAt(textIndex, width, height, absPoint.x, absPoint.y, relPoint.x, relPoint.y);
2104 SysTryReturn(NID_GRP, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
2105 SysTryReturn(NID_GRP, y + __rect.y >= relPoint.y, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text position information");
2107 int elementIndex = __pCompositeText->GetCutLinkElementIndexAt(textIndex);
2109 _SetTextBidiHint(bidiHint);
2111 return elementIndex;
2115 TextObject::GetCutLinkElementAtCutLinkElementIndex(int linkIndex) const
2117 IF_NOT_CONSTRUCTED(return null);
2119 return __pCompositeText->GetCutLinkElementAtCutLinkElementIndex(linkIndex);
2123 TextObject::SetCutLinkColor(LinkType linkType, const Color& color, const Color& colorInSelect)
2125 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2127 SysTryReturn(NID_GRP, LINK_TYPE_NONE < linkType && linkType < LINK_TYPE_MAX, E_INVALID_ARG, E_INVALID_ARG
2128 , "[E_INVALID_ARG] The argument is invalid.");
2133 __isUrlLinkColorDefined = true;
2134 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_NORMAL] = color;
2135 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_SELECT] = colorInSelect;
2138 case LINK_TYPE_EMAIL:
2139 __isEmailLinkColorDefined = true;
2140 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_NORMAL] = color;
2141 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_SELECT] = colorInSelect;
2144 case LINK_TYPE_TEL_NUM:
2145 __isPhoneNumberLinkColorDefined = true;
2146 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_NORMAL] = color;
2147 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_SELECT] = colorInSelect;
2154 int totalCutlinkTextCount = __pCompositeText->GetCutLinkElementCount();
2155 for (int i = 0; i < totalCutlinkTextCount; i++)
2157 TextCutLink* pCutlinkText = dynamic_cast < TextCutLink* >(__pCompositeText->GetCutLinkElementAtCutLinkElementIndex(i));
2158 SysTryReturn(NID_GRP, pCutlinkText, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to convert to cutlink element.");
2160 if (pCutlinkText->GetCutLinkType() == linkType)
2162 pCutlinkText->SetUserColor(color, colorInSelect);
2170 TextObject::ResetCutLinkColor(LinkType linkType)
2172 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2174 SysTryReturn(NID_GRP, LINK_TYPE_NONE < linkType && linkType < LINK_TYPE_MAX, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
2179 __isUrlLinkColorDefined = false;
2182 case LINK_TYPE_EMAIL:
2183 __isEmailLinkColorDefined = false;
2186 case LINK_TYPE_TEL_NUM:
2187 __isPhoneNumberLinkColorDefined = false;
2194 int totalCutlinkTextCount = __pCompositeText->GetCutLinkElementCount();
2195 for (int i = 0; i < totalCutlinkTextCount; i++)
2197 TextCutLink* pCutlinkText = dynamic_cast < TextCutLink* >(__pCompositeText->GetCutLinkElementAtCutLinkElementIndex(i));
2198 SysTryReturn(NID_GRP, pCutlinkText, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to convert to cutlink element.");
2200 if (pCutlinkText->GetCutLinkType() == linkType)
2202 pCutlinkText->ResetUserColor();
2210 TextObject::GetCutLinkBounds(int cutLinkIndex, Point& startPoint, Point& endPoint) const
2212 FloatPoint startPointF = _CoordinateSystemUtils::ConvertToFloat(startPoint);
2213 FloatPoint endPointF = _CoordinateSystemUtils::ConvertToFloat(endPoint);
2215 result r = GetCutLinkBounds(cutLinkIndex, startPointF, endPointF);
2216 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2218 startPoint = _CoordinateSystemUtils::ConvertToInteger(startPointF);
2219 endPoint = _CoordinateSystemUtils::ConvertToInteger(endPointF);
2225 TextObject::GetCutLinkBounds(int cutLinkIndex, FloatPoint& startPoint, FloatPoint& endPoint) const
2227 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2229 result r = E_SUCCESS;
2233 float heigth = 0.0f;
2234 FloatPoint tempPoint;
2236 r = __pCompositeText->GetCutLinkObjectInfo(cutLinkIndex, textIndex, textLength);
2237 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2239 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
2241 r = GetTextPositionInfoInNoneWrapAt(textIndex, width, heigth, tempPoint.x, tempPoint.y, startPoint.x, startPoint.y);
2242 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2244 r = GetTextPositionInfoInNoneWrapAt(textIndex + textLength - 1, width, heigth, tempPoint.x, tempPoint.y, endPoint.x, endPoint.y);
2245 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2249 r = GetTextPositionInfoInWrapAt(textIndex, width, heigth, tempPoint.x, tempPoint.y, startPoint.x, startPoint.y);
2250 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2252 r = GetTextPositionInfoInWrapAt(textIndex + textLength - 1, width, heigth, tempPoint.x, tempPoint.y, endPoint.x, endPoint.y);
2253 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2256 endPoint.x = endPoint.x + width;
2257 endPoint.y = endPoint.y + heigth;
2271 TextObject::GetTextPositionInfoAt(int textIndex, int& width, int& height, int& absX, int& absY, int& logicalX, int& logicalY) const
2273 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2275 float widthF = _CoordinateSystemUtils::ConvertToFloat(width);
2276 float heightF = _CoordinateSystemUtils::ConvertToFloat(height);
2277 float absXF = _CoordinateSystemUtils::ConvertToFloat(absX);
2278 float absYF = _CoordinateSystemUtils::ConvertToFloat(absY);
2279 float logicalXF = _CoordinateSystemUtils::ConvertToFloat(logicalX);
2280 float logicalYF = _CoordinateSystemUtils::ConvertToFloat(logicalY);
2282 result r = GetTextPositionInfoAt(textIndex, widthF, heightF, absXF, absYF, logicalXF, logicalYF);
2283 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2285 width = _CoordinateSystemUtils::ConvertToInteger(widthF);
2286 height = _CoordinateSystemUtils::ConvertToInteger(heightF);
2287 absX = _CoordinateSystemUtils::ConvertToInteger(absXF);
2288 absY = _CoordinateSystemUtils::ConvertToInteger(absYF);
2289 logicalX = _CoordinateSystemUtils::ConvertToInteger(logicalXF);
2290 logicalY = _CoordinateSystemUtils::ConvertToInteger(logicalYF);
2296 TextObject::GetTextPositionInfoAt(int textIndex, float& width, float& height, float& absX, float& absY, float& logicalX, float& logicalY) const
2298 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2300 result r = E_SUCCESS;
2301 TextBidiHint bidiHint = _GetTextBidiHint();
2302 _SetTextBidiHint(__bidiHint);
2304 int lineCount = __pTextColumn->GetTotalLineCount();
2308 _FontImpl* pFont = _FontImpl::GetInstance(*__pDefaultFont);
2309 SysTryReturn(NID_GRP, pFont, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
2311 float maxHeight = TextUtility::GetFontMaxHeightF(pFont);
2317 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
2319 switch (__align & TEXT_ALIGNMASK_VERT)
2321 case TEXT_OBJECT_ALIGNMENT_TOP:
2324 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
2325 posY += (__rect.height - maxHeight) / 2.0f;
2328 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
2329 posY += (__rect.height - maxHeight);
2332 logicalY = __rect.y + posY;
2334 switch (__align & TEXT_ALIGNMASK_HORIZ)
2336 case TEXT_OBJECT_ALIGNMENT_LEFT:
2339 case TEXT_OBJECT_ALIGNMENT_CENTER:
2340 posX += __rect.width / 2.0f;
2343 case TEXT_OBJECT_ALIGNMENT_RIGHT:
2344 posX += __rect.width;
2347 logicalX = __rect.x + posX;
2351 float lineHeight = maxHeight + __pCompositeText->GetLineSpaceF();
2352 TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment();
2353 switch (alignment & TEXT_ALIGNMASK_VERT)
2355 case TEXT_OBJECT_ALIGNMENT_TOP:
2360 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
2361 posY += (lineHeight - maxHeight) / 2.0f;
2364 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
2365 posY += lineHeight - maxHeight;
2369 switch (__align & TEXT_ALIGNMASK_HORIZ)
2371 case TEXT_OBJECT_ALIGNMENT_LEFT:
2374 case TEXT_OBJECT_ALIGNMENT_CENTER:
2375 posX += __rect.width / 2.0f;
2378 case TEXT_OBJECT_ALIGNMENT_RIGHT:
2379 posX += __rect.width;
2383 logicalX = posX + __rect.x;
2384 logicalY = posY + __rect.y;
2394 r = (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE) ? GetTextPositionInfoInNoneWrapAt(textIndex, width, height, absX, absY, logicalX, logicalY)
2395 : GetTextPositionInfoInWrapAt(textIndex, width, height, absX, absY, logicalX, logicalY);
2396 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2399 _SetTextBidiHint(bidiHint);
2405 TextObject::GetBlockTextPositionInfoAt(int textIndex, int& width, int& height, int& absX, int& absY, int& logicalX, int& logicalY) const
2407 float widthF = _CoordinateSystemUtils::ConvertToFloat(width);
2408 float heightF = _CoordinateSystemUtils::ConvertToFloat(height);
2409 float absXF = _CoordinateSystemUtils::ConvertToFloat(absX);
2410 float absYF = _CoordinateSystemUtils::ConvertToFloat(absY);
2411 float logicalXF = _CoordinateSystemUtils::ConvertToFloat(logicalX);
2412 float logicalYF = _CoordinateSystemUtils::ConvertToFloat(logicalY);
2414 result r = GetBlockTextPositionInfoAt(textIndex, widthF, heightF, absXF, absYF, logicalXF, logicalYF);
2415 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2417 width = _CoordinateSystemUtils::ConvertToInteger(widthF);
2418 height = _CoordinateSystemUtils::ConvertToInteger(heightF);
2419 absX = _CoordinateSystemUtils::ConvertToInteger(absXF);
2420 absY = _CoordinateSystemUtils::ConvertToInteger(absYF);
2421 logicalX = _CoordinateSystemUtils::ConvertToInteger(logicalXF);
2422 logicalY = _CoordinateSystemUtils::ConvertToInteger(logicalYF);
2428 TextObject::GetBlockTextPositionInfoAt(int textIndex, float& width, float& height, float& absX, float& absY, float& logicalX, float& logicalY) const
2430 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2432 result r = E_SUCCESS;
2433 TextBidiHint bidiHint = _GetTextBidiHint();
2434 _SetTextBidiHint(__bidiHint);
2436 int lineCount = __pTextColumn->GetTotalLineCount();
2440 _FontImpl* pFont =_FontImpl::GetInstance(*__pDefaultFont);
2441 SysTryReturn(NID_GRP, pFont, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
2443 float maxHeight = TextUtility::GetFontMaxHeightF(pFont);
2449 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
2451 switch (__align & TEXT_ALIGNMASK_VERT)
2453 case TEXT_OBJECT_ALIGNMENT_TOP:
2456 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
2457 posY += (__rect.height - maxHeight) / 2.0f;
2460 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
2461 posY += (__rect.height - maxHeight);
2464 logicalY = __rect.y + posY;
2466 switch (__align & TEXT_ALIGNMASK_HORIZ)
2468 case TEXT_OBJECT_ALIGNMENT_LEFT:
2471 case TEXT_OBJECT_ALIGNMENT_CENTER:
2472 posX += __rect.width / 2.0f;
2475 case TEXT_OBJECT_ALIGNMENT_RIGHT:
2476 posX += __rect.width;
2479 logicalX = __rect.x + posX;
2483 float lineHeight = maxHeight + __pCompositeText->GetLineSpace();
2484 TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment();
2485 switch (alignment & TEXT_ALIGNMASK_VERT)
2487 case TEXT_OBJECT_ALIGNMENT_TOP:
2492 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
2493 posY += (lineHeight - maxHeight) / 2.0f;
2496 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
2497 posY += lineHeight - maxHeight;
2501 logicalX = __rect.x;
2502 logicalY = posY + __rect.y;
2512 r = (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE) ? GetTextPositionInfoInNoneWrapAt(textIndex, width, height, absX, absY, logicalX, logicalY)
2513 : GetBlockTextPositionInfoInWrapAt(textIndex, width, height, absX, absY, logicalX, logicalY);
2514 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2517 _SetTextBidiHint(bidiHint);
2523 TextObject::SetTextObjectEllipsisType(TextObjectEllipsisType type)
2525 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2527 SysTryReturn(NID_GRP, TEXT_OBJECT_ELLIPSIS_TYPE_INVALID < type && type < TEXT_OBJECT_ELLIPSIS_TYPE_MAX
2528 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
2530 __textObjectEllipsisType = type;
2531 __pCompositeText->SetTextObjectEllipsisType(type);
2537 TextObject::NotifyTextAdded(int textIndex, int textLength)
2539 result r = E_SUCCESS;
2541 r = __pTextColumn->SetChangeAction(TextColumn::TEXT_CHANGE_INSERT, textIndex, textLength);
2542 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2550 TextObject::NotifyTextDeleted(int textIndex, int textLength)
2552 result r = E_SUCCESS;
2554 r = __pTextColumn->SetChangeAction(TextColumn::TEXT_CHANGE_REMOVE, textIndex, textLength);
2555 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2563 TextObject::DrawByLine(_CanvasImpl& canvasImpl, const Rectangle& displayRect)
2565 return DrawByLine(canvasImpl, _CoordinateSystemUtils::ConvertToFloat(displayRect));
2569 TextObject::DrawByLine(_CanvasImpl& canvasImpl, const FloatRectangle& displayRect)
2571 FloatRectangle targetBounds = displayRect;
2573 return __pTextColumn->Draw(canvasImpl, targetBounds, 0, __pTextColumn->GetTextLength(), __align, __action);
2577 TextObject::GetTextIndexFromPositionInWrap(int x, int y, bool cursorMode) const
2579 return GetTextIndexFromPositionInWrap(_CoordinateSystemUtils::ConvertToFloat(x), _CoordinateSystemUtils::ConvertToFloat(y), cursorMode);
2583 TextObject::GetTextIndexFromPositionInWrap(float x, float y, bool cursorMode) const
2585 TextLine* pTextLine = null;
2586 FloatRectangle lineBounds;
2587 int firstDisplayLineIndex = __pTextColumn->GetFirstDisplayLineIndex();
2588 float firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
2589 int lineCount = __pTextColumn->GetTotalLineCount();
2591 float totalHeight = __pTextColumn->GetTotalHeightF();
2593 TextBidiHint bidiHint = _GetTextBidiHint();
2594 _SetTextBidiHint(__bidiHint);
2596 switch (__align & TEXT_ALIGNMASK_VERT)
2598 case TEXT_OBJECT_ALIGNMENT_TOP:
2601 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
2602 y -= (__rect.height - totalHeight) / 2.0f;
2605 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
2606 y -= (__rect.height - totalHeight);
2610 for (lineIndex = firstDisplayLineIndex; lineIndex < lineCount; lineIndex++)
2612 pTextLine = __pTextColumn->GetTextLine(lineIndex);
2613 SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2615 lineBounds = pTextLine->GetBoundsF();
2617 if (lineIndex == firstDisplayLineIndex)
2619 if (y < lineBounds.y - firstDisplayPositionY)
2625 if ((lineBounds.y - firstDisplayPositionY <= y) && (y < lineBounds.y + lineBounds.height - firstDisplayPositionY))
2630 if (lineIndex == lineCount - 1)
2634 return pTextLine->GetTextLength() + pTextLine->GetTextOffset();
2643 SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2645 int lineLength = pTextLine->GetTextLength();
2646 Dimension lineTextSize;
2647 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
2649 switch (__align & TEXT_ALIGNMASK_HORIZ)
2651 case TEXT_OBJECT_ALIGNMENT_LEFT:
2654 case TEXT_OBJECT_ALIGNMENT_CENTER:
2655 x -= (lineBounds.width - lineTextSize.width) / 2.0f;
2658 case TEXT_OBJECT_ALIGNMENT_RIGHT:
2659 x -= (lineBounds.width - lineTextSize.width);
2668 int index = pTextLine->GetTextIndexFromPosition(x);
2670 _SetTextBidiHint(bidiHint);
2672 SetLastResult(E_SUCCESS);
2678 TextObject::GetTextIndexFromPositionInNoneWrap(int x, int y, bool cursorMode) const
2680 return GetTextIndexFromPositionInNoneWrap(_CoordinateSystemUtils::ConvertToFloat(x), _CoordinateSystemUtils::ConvertToFloat(y), cursorMode);
2684 TextObject::GetTextIndexFromPositionInNoneWrap(float x, float y, bool cursorMode) const
2686 FloatDimension lineTextSize;
2687 FloatRectangle lineBounds;
2690 TextLine* pTextLine = null;
2692 pTextLine = __pTextColumn->GetTextLine(0);
2693 SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2695 TextBidiHint bidiHint = _GetTextBidiHint();
2696 _SetTextBidiHint(__bidiHint);
2698 lineOffset = pTextLine->GetTextOffset();
2699 lineLength = pTextLine->GetTextLength();
2700 lineBounds = pTextLine->GetBoundsF();
2701 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
2703 switch (__align & TEXT_ALIGNMASK_HORIZ)
2705 case TEXT_OBJECT_ALIGNMENT_LEFT:
2708 case TEXT_OBJECT_ALIGNMENT_CENTER:
2709 x -= (lineBounds.width - lineTextSize.width) / 2.0f;
2712 case TEXT_OBJECT_ALIGNMENT_RIGHT:
2713 x -= (lineBounds.width - lineTextSize.width);
2717 switch (__align & TEXT_ALIGNMASK_VERT)
2719 case TEXT_OBJECT_ALIGNMENT_TOP:
2722 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
2723 y -= (__rect.height - lineTextSize.height) / 2.0f;
2726 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
2727 y -= (__rect.height - lineTextSize.height);
2736 int index = pTextLine->GetTextIndexFromPosition(x);
2738 _SetTextBidiHint(bidiHint);
2740 SetLastResult(E_SUCCESS);
2745 TextObject::SetFirstDisplayLineIndexFromTextIndexInWrap(int textIndex)
2747 result r = E_SUCCESS;
2748 FloatRectangle lineBounds;
2749 float firstDisplayPositionY = 0.0f;
2750 int currentTextIndex = textIndex;
2751 int firstDisplayLineIndex = 0;
2754 float remainingHeight = 0.0f;
2755 TextLine* pTextLine = null;
2756 bool isChanged = false;
2758 lineCount = __pTextColumn->GetTotalLineCount();
2759 lineIndex = __pTextColumn->GetLineIndexAtTextIndex(currentTextIndex);
2760 firstDisplayLineIndex = __pTextColumn->GetFirstDisplayLineIndex();
2762 if (lineIndex == -1 && 0 < currentTextIndex && currentTextIndex == __pCompositeText->GetTextLength())
2765 lineIndex = __pTextColumn->GetLineIndexAtTextIndex(currentTextIndex);
2768 pTextLine = __pTextColumn->GetTextLine(lineIndex);
2769 SysTryReturn(NID_GRP, pTextLine, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2771 lineBounds = pTextLine->GetBoundsF();
2773 if (firstDisplayLineIndex < lineIndex)
2775 TextLine* pTextLine = null;
2776 int currentLineIndex = 0;
2777 int displayLineCount = 0;
2779 currentLineIndex = firstDisplayLineIndex;
2780 pTextLine = __pTextColumn->GetTextLine(currentLineIndex);
2781 SysTryReturn(NID_GRP, pTextLine, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2783 remainingHeight = __rect.height;
2785 while ((remainingHeight != 0.0f) && firstDisplayLineIndex < lineCount)
2787 if (remainingHeight < 0.0f)
2792 lineBounds = pTextLine->GetBoundsF();
2794 remainingHeight -= lineBounds.height;
2798 pTextLine = __pTextColumn->GetTextLine(currentLineIndex);
2799 if (pTextLine == null)
2805 if (lineIndex < firstDisplayLineIndex + displayLineCount)
2807 if (0.0f < remainingHeight && 0 < firstDisplayLineIndex)
2809 pTextLine = __pTextColumn->GetTextLine(firstDisplayLineIndex - 1);
2810 SysTryReturn(NID_GRP, pTextLine, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2812 while (remainingHeight && pTextLine)
2814 lineBounds = pTextLine->GetBoundsF();
2815 remainingHeight -= lineBounds.height;
2817 if (remainingHeight < 0.0f)
2819 firstDisplayPositionY = lineBounds.y + remainingHeight;
2821 firstDisplayLineIndex--;
2826 firstDisplayPositionY = lineBounds.y;
2830 firstDisplayLineIndex--;
2832 pTextLine = __pTextColumn->GetTextLine(firstDisplayLineIndex - 1);
2837 else if (remainingHeight < 0.0f && (lineIndex == firstDisplayLineIndex + displayLineCount - 1))
2839 pTextLine = __pTextColumn->GetTextLine(lineIndex);
2840 SysTryReturn(NID_GRP, pTextLine, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2842 lineBounds = pTextLine->GetBoundsF();
2843 remainingHeight = __rect.height;
2845 firstDisplayLineIndex = lineIndex;
2846 firstDisplayPositionY = lineBounds.y;
2847 remainingHeight -= lineBounds.height;
2849 int currentLineIndex = lineIndex - 1;
2850 pTextLine = __pTextColumn->GetTextLine(currentLineIndex);
2852 while ((pTextLine != null) && 0 < firstDisplayLineIndex && 0.0f < remainingHeight)
2854 lineBounds = pTextLine->GetBoundsF();
2856 if (remainingHeight < lineBounds.height)
2858 firstDisplayLineIndex--;
2859 firstDisplayPositionY = lineBounds.y + (lineBounds.height - remainingHeight);
2864 remainingHeight -= lineBounds.height;
2865 firstDisplayLineIndex--;
2866 firstDisplayPositionY = lineBounds.y;
2868 pTextLine = __pTextColumn->GetTextLine(currentLineIndex);
2876 pTextLine = __pTextColumn->GetTextLine(lineIndex);
2877 SysTryReturn(NID_GRP, pTextLine, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2879 lineBounds = pTextLine->GetBoundsF();
2881 remainingHeight = __rect.height;
2883 firstDisplayLineIndex = lineIndex;
2884 firstDisplayPositionY = lineBounds.y;
2885 remainingHeight -= lineBounds.height;
2887 int currentLineIndex = lineIndex - 1;
2888 pTextLine = __pTextColumn->GetTextLine(currentLineIndex);
2890 while (pTextLine && 0 < firstDisplayLineIndex && 0.0f < remainingHeight)
2892 lineBounds = pTextLine->GetBoundsF();
2894 if (remainingHeight < lineBounds.height)
2896 firstDisplayLineIndex--;
2897 firstDisplayPositionY = lineBounds.y + (lineBounds.height - remainingHeight);
2902 remainingHeight -= lineBounds.height;
2903 firstDisplayLineIndex--;
2904 firstDisplayPositionY = lineBounds.y;
2906 pTextLine = __pTextColumn->GetTextLine(currentLineIndex);
2914 lineBounds = pTextLine->GetBoundsF();
2915 firstDisplayLineIndex = lineIndex;
2916 firstDisplayPositionY = lineBounds.y;
2920 if (isChanged == true)
2922 __pTextColumn->SetFirstDisplayLineIndex(firstDisplayLineIndex);
2923 __pTextColumn->SetFirstDisplayPositionY(firstDisplayPositionY);
2930 TextObject::SetFirstDisplayLineIndexFromTextIndexInNoneWrap(int textIndex)
2932 result r = E_SUCCESS;
2933 int currentTextIndex = textIndex;
2935 int lineEndIndex = 0;
2937 FloatRectangle lineBounds;
2938 FloatDimension lineTextSize;
2940 _FontImpl* pFont = _FontImpl::GetInstance(*__pDefaultFont);
2941 SysTryReturn(NID_GRP, pFont, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
2943 TextLine* pTextLine = __pTextColumn->GetTextLine(0);
2944 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2946 lineOffset = pTextLine->GetTextOffset();
2947 lineLength = pTextLine->GetTextLength();
2948 lineEndIndex = pTextLine->GetTextOffset() + pTextLine->GetTextLength();
2950 lineBounds = pTextLine->GetBoundsF();
2951 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
2953 if (currentTextIndex < pTextLine->GetTextOffset() + 1)
2955 lineOffset = currentTextIndex;
2956 pTextLine->SetTextOffset(lineOffset);
2957 lineOffset = pTextLine->GetTextOffset();
2961 pTextLine->SetTextOffset(lineOffset);
2964 __pCompositeText->ForwardAnalyze(lineOffset, __pCompositeText->GetTextLength() - lineOffset, lineBounds.width,
2965 __wrap, lineLength, lineTextSize.width, lineTextSize.height);
2967 lineBounds.height = (lineBounds.height > lineTextSize.height) ? lineBounds.height : lineTextSize.height;
2968 if (lineBounds.height == 0.0f)
2970 lineBounds.height = TextUtility::GetFontMaxHeightF(pFont);
2973 pTextLine->SetBounds(lineBounds);
2974 pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
2975 pTextLine->SetTextLength(lineLength);
2976 __pCompositeText->GetTextExtentList(pTextLine);
2978 else if (lineEndIndex <= currentTextIndex)
2980 float gapWidth = 0.0f;
2981 float gapHeight = 0.0f;
2982 float tempWidth = 0.0f;
2985 r = __pCompositeText->GetRegion(lineEndIndex, currentTextIndex - lineEndIndex, gapWidth, gapHeight);
2986 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2988 gapWidth -= lineBounds.width - lineTextSize.width;
2990 __pCompositeText->ForwardAnalyze(lineOffset, __pCompositeText->GetTextLength() - lineOffset, gapWidth, __wrap,
2991 textCount, tempWidth, gapHeight);
2993 if (tempWidth < gapWidth)
2995 lineOffset += (textCount + 1);
2999 lineOffset += textCount;
3002 __pCompositeText->ForwardAnalyze(lineOffset, __pCompositeText->GetTextLength() - lineOffset, lineBounds.width,
3003 __wrap, lineLength, lineTextSize.width, lineTextSize.height);
3005 lineBounds.height = (lineBounds.height > lineTextSize.height) ? lineBounds.height: lineTextSize.height;
3006 if (lineBounds.height == 0.0f)
3008 lineBounds.height = TextUtility::GetFontMaxHeightF(pFont);
3011 pTextLine->SetBounds(lineBounds);
3012 pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
3013 pTextLine->SetTextOffset(lineOffset);
3014 pTextLine->SetTextLength(lineLength);
3015 __pCompositeText->GetTextExtentList(pTextLine);
3018 __pTextColumn->SetFirstDisplayLineIndex(0);
3019 __pTextColumn->SetFirstDisplayPositionY(0.0f);
3025 TextObject::GetTextPositionInfoInWrapAt(int textIndex, int& width, int& height, int& absX, int& absY,
3026 int& logicalX, int& logicalY) const
3028 float widthF = _CoordinateSystemUtils::ConvertToFloat(width);
3029 float heightF = _CoordinateSystemUtils::ConvertToFloat(height);
3030 float absXF = _CoordinateSystemUtils::ConvertToFloat(absX);
3031 float absYF = _CoordinateSystemUtils::ConvertToFloat(absY);
3032 float logicalXF = _CoordinateSystemUtils::ConvertToFloat(logicalX);
3033 float logicalYF = _CoordinateSystemUtils::ConvertToFloat(logicalY);
3035 result r = GetTextPositionInfoInWrapAt(textIndex, widthF, heightF, absXF, absYF, logicalXF, logicalYF);
3036 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3038 width = _CoordinateSystemUtils::ConvertToInteger(widthF);
3039 height = _CoordinateSystemUtils::ConvertToInteger(heightF);
3040 absX = _CoordinateSystemUtils::ConvertToInteger(absXF);
3041 absY = _CoordinateSystemUtils::ConvertToInteger(absYF);
3042 logicalX = _CoordinateSystemUtils::ConvertToInteger(logicalXF);
3043 logicalY = _CoordinateSystemUtils::ConvertToInteger(logicalYF);
3049 TextObject::GetTextPositionInfoInWrapAt(int textIndex, float& width, float& height, float& absX, float& absY,
3050 float& logicalX, float& logicalY) const
3052 TextLine* pTextLine = null;
3053 FloatRectangle lineBounds;
3054 float firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
3055 int lineCount = __pTextColumn->GetTotalLineCount();
3059 int textIndexFromLineOffset = 0;
3064 _FontImpl* pFont = _FontImpl::GetInstance(*__pDefaultFont);
3065 SysTryReturn(NID_GRP, pFont, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
3067 for (lineIndex = 0; lineIndex < lineCount; lineIndex++)
3069 pTextLine = __pTextColumn->GetTextLine(lineIndex);
3070 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3072 lineBounds = pTextLine->GetBoundsF();
3073 lineOffset = pTextLine->GetTextOffset();
3074 lineLength = pTextLine->GetTextLength();
3076 if (lineOffset <= textIndex && textIndex < lineOffset + lineLength)
3081 if (lineIndex + 1 < lineCount)
3083 lineY += lineBounds.height;
3087 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3089 if (lineIndex == lineCount)
3091 textIndexFromLineOffset = lineLength;
3095 textIndexFromLineOffset = textIndex - lineOffset;
3098 FloatDimension lineTextSize;
3099 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
3101 if (lineTextSize.height == 0)
3103 lineTextSize.height = TextUtility::GetFontMaxHeightF(pFont);
3106 switch (__align & TEXT_ALIGNMASK_HORIZ)
3108 case TEXT_OBJECT_ALIGNMENT_LEFT:
3111 case TEXT_OBJECT_ALIGNMENT_CENTER:
3112 posX += (lineBounds.width - lineTextSize.width) / 2.0f;
3115 case TEXT_OBJECT_ALIGNMENT_RIGHT:
3116 posX += (lineBounds.width - lineTextSize.width);
3120 switch (__align & TEXT_ALIGNMASK_VERT)
3122 case TEXT_OBJECT_ALIGNMENT_TOP:
3125 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3126 posY += (__rect.height - __pTextColumn->GetDisplayHeightF()) / 2.0f;
3129 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3130 posY += (__rect.height - __pTextColumn->GetDisplayHeightF());
3144 FloatRectangle textExtent = pTextLine->GetTextExtentF(textIndexFromLineOffset, 1);
3146 if (lineIndex == lineCount)
3148 textExtent.width = 0.0f;
3153 Font* pTextFont = __pCompositeText->GetFont(textIndex - 1);
3154 textExtent.height = TextUtility::GetFontMaxHeightF(pTextFont);
3157 if (textExtent.height < 0.0f)
3159 textExtent.height = TextUtility::GetFontMaxHeightF(pFont);
3162 TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment();
3163 switch (alignment & TEXT_ALIGNMASK_VERT)
3165 case TEXT_OBJECT_ALIGNMENT_TOP:
3170 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3171 lineY = lineY + (lineBounds.height - textExtent.height) / 2.0f;
3174 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3175 lineY = lineY + (lineBounds.height - textExtent.height);
3179 width = textExtent.width;
3180 height = textExtent.height;
3181 absX = posX + textExtent.x;
3182 logicalX = absX + __rect.x;
3184 logicalY = absY - firstDisplayPositionY + __rect.y + posY;
3190 TextObject::GetBlockTextPositionInfoInWrapAt(int textIndex, int& width, int& height, int& absX, int& absY,
3191 int& logicalX, int& logicalY) const
3193 float widthF = _CoordinateSystemUtils::ConvertToFloat(width);
3194 float heightF = _CoordinateSystemUtils::ConvertToFloat(height);
3195 float absXF = _CoordinateSystemUtils::ConvertToFloat(absX);
3196 float absYF = _CoordinateSystemUtils::ConvertToFloat(absY);
3197 float logicalXF = _CoordinateSystemUtils::ConvertToFloat(logicalX);
3198 float logicalYF = _CoordinateSystemUtils::ConvertToFloat(logicalY);
3200 result r = GetBlockTextPositionInfoInWrapAt(textIndex, widthF, heightF, absXF, absYF, logicalXF, logicalYF);
3201 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3203 width = _CoordinateSystemUtils::ConvertToInteger(widthF);
3204 height = _CoordinateSystemUtils::ConvertToInteger(heightF);
3205 absX = _CoordinateSystemUtils::ConvertToInteger(absXF);
3206 absY = _CoordinateSystemUtils::ConvertToInteger(absYF);
3207 logicalX = _CoordinateSystemUtils::ConvertToInteger(logicalXF);
3208 logicalY = _CoordinateSystemUtils::ConvertToInteger(logicalYF);
3214 TextObject::GetBlockTextPositionInfoInWrapAt(int textIndex, float& width, float& height, float& absX, float& absY,
3215 float& logicalX, float& logicalY) const
3217 TextLine* pTextLine = null;
3218 FloatRectangle lineBounds;
3219 float firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
3220 int lineCount = __pTextColumn->GetTotalLineCount();
3224 int textIndexFromLineOffset = 0;
3229 _FontImpl* pFont = _FontImpl::GetInstance(*__pDefaultFont);
3230 SysTryReturn(NID_GRP, pFont, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
3232 for (lineIndex = 0; lineIndex < lineCount; lineIndex++)
3234 pTextLine = __pTextColumn->GetTextLine(lineIndex);
3235 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3237 lineBounds = pTextLine->GetBoundsF();
3238 lineOffset = pTextLine->GetTextOffset();
3239 lineLength = pTextLine->GetTextLength();
3241 if (lineOffset <= textIndex && textIndex <= lineOffset + lineLength)
3246 if (lineIndex + 1 < lineCount)
3248 lineY += lineBounds.height;
3252 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3254 if (lineIndex == lineCount)
3256 textIndexFromLineOffset = lineLength;
3260 textIndexFromLineOffset = textIndex - lineOffset;
3263 FloatDimension lineTextSize;
3264 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
3266 if (lineTextSize.height == 0.0f)
3268 lineTextSize.height = TextUtility::GetFontMaxHeightF(pFont);
3271 switch (__align & TEXT_ALIGNMASK_HORIZ)
3273 case TEXT_OBJECT_ALIGNMENT_LEFT:
3276 case TEXT_OBJECT_ALIGNMENT_CENTER:
3277 posX += (lineBounds.width - lineTextSize.width) / 2.0f;
3280 case TEXT_OBJECT_ALIGNMENT_RIGHT:
3281 posX += (lineBounds.width - lineTextSize.width);
3285 switch (__align & TEXT_ALIGNMASK_VERT)
3287 case TEXT_OBJECT_ALIGNMENT_TOP:
3290 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3291 posY += (__rect.height - __pTextColumn->GetDisplayHeightF()) / 2.0f;
3294 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3295 posY += (__rect.height - __pTextColumn->GetDisplayHeightF());
3309 FloatRectangle textExtent = pTextLine->GetBlockTextExtentF(textIndexFromLineOffset, 1);
3311 if (lineIndex == lineCount)
3313 textExtent.width = 0.0f;
3318 Font* pTextFont = __pCompositeText->GetFont(textIndex - 1);
3319 textExtent.height = TextUtility::GetFontMaxHeightF(pTextFont);
3322 if (textExtent.height < 0)
3324 textExtent.height = TextUtility::GetFontMaxHeightF(pFont);
3327 TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment();
3328 switch (alignment & TEXT_ALIGNMASK_VERT)
3330 case TEXT_OBJECT_ALIGNMENT_TOP:
3335 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3336 lineY = lineY + (lineBounds.height - textExtent.height) / 2.0f;
3339 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3340 lineY = lineY + (lineBounds.height - textExtent.height);
3344 width = textExtent.width;
3345 height = textExtent.height;
3346 absX = posX + textExtent.x;
3347 logicalX = absX + __rect.x;
3349 logicalY = absY - firstDisplayPositionY + __rect.y + posY;
3355 TextObject::GetTextPositionInfoInNoneWrapAt(int textIndex, int& width, int& height, int& absX, int& absY,
3356 int& logicalX, int& logicalY) const
3358 float widthF = _CoordinateSystemUtils::ConvertToFloat(width);
3359 float heightF = _CoordinateSystemUtils::ConvertToFloat(height);
3360 float absXF = _CoordinateSystemUtils::ConvertToFloat(absX);
3361 float absYF = _CoordinateSystemUtils::ConvertToFloat(absY);
3362 float logicalXF = _CoordinateSystemUtils::ConvertToFloat(logicalX);
3363 float logicalYF = _CoordinateSystemUtils::ConvertToFloat(logicalY);
3365 result r = GetTextPositionInfoInNoneWrapAt(textIndex, widthF, heightF, absXF, absYF, logicalXF, logicalYF);
3366 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3368 width = _CoordinateSystemUtils::ConvertToInteger(widthF);
3369 height = _CoordinateSystemUtils::ConvertToInteger(heightF);
3370 absX = _CoordinateSystemUtils::ConvertToInteger(absXF);
3371 absY = _CoordinateSystemUtils::ConvertToInteger(absYF);
3372 logicalX = _CoordinateSystemUtils::ConvertToInteger(logicalXF);
3373 logicalY = _CoordinateSystemUtils::ConvertToInteger(logicalYF);
3379 TextObject::GetTextPositionInfoInNoneWrapAt(int textIndex, float& width, float& height, float& absX, float& absY,
3380 float& logicalX, float& logicalY) const
3382 TextLine* pTextLine = null;
3383 pTextLine = __pTextColumn->GetTextLine(0);
3384 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3386 int lineLength = pTextLine->GetTextLength();
3390 _FontImpl* pFont = _FontImpl::GetInstance(*__pDefaultFont);
3391 SysTryReturn(NID_GRP, pFont, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
3393 FloatDimension lineTextSize;
3394 FloatRectangle lineBounds;
3395 lineBounds = pTextLine->GetBoundsF();
3396 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
3398 if (lineTextSize.height == 0.0f || pTextLine->GetTextLength() == 0.0f)
3400 lineTextSize.height = TextUtility::GetFontMaxHeightF(pFont);
3403 switch (__align & TEXT_ALIGNMASK_HORIZ)
3405 case TEXT_OBJECT_ALIGNMENT_LEFT:
3408 case TEXT_OBJECT_ALIGNMENT_CENTER:
3409 posX += (lineBounds.width - lineTextSize.width) / 2.0f;
3412 case TEXT_OBJECT_ALIGNMENT_RIGHT:
3413 posX += (lineBounds.width - lineTextSize.width);
3417 switch (__align & TEXT_ALIGNMASK_VERT)
3419 case TEXT_OBJECT_ALIGNMENT_TOP:
3422 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3423 posY += (__rect.height - lineTextSize.height) / 2.0f;
3426 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3427 posY += (__rect.height - lineTextSize.height);
3431 posX = (posX < 0.0f) ? 0.0f : posX;
3432 posY = (posY < 0.0f) ? 0.0f : posY;
3434 FloatRectangle textExtent = pTextLine->GetTextExtentF(textIndex - pTextLine->GetTextOffset(), 1);
3438 Font* pTextFont = __pCompositeText->GetFont(textIndex - 1);
3439 textExtent.height = TextUtility::GetFontMaxHeightF(pTextFont);
3442 if (textExtent.height < 0.0f)
3444 textExtent.height = TextUtility::GetFontMaxHeightF(pFont);
3447 TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment();
3448 switch (alignment & TEXT_ALIGNMASK_VERT)
3450 case TEXT_OBJECT_ALIGNMENT_TOP:
3455 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3456 posY = posY + (lineBounds.height - textExtent.height) / 2.0f;
3459 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3460 posY = posY + (lineBounds.height - textExtent.height);
3464 absX = posX + textExtent.x;
3465 logicalX = (absX >= 0.0f) ? absX + __rect.x : absX;
3467 logicalY = absY + __rect.y;
3468 width = textExtent.width;
3469 height = textExtent.height;
3475 TextObject::GetTotalComposedHeight(void) const
3477 return _CoordinateSystemUtils::ConvertToInteger(GetTotalComposedHeightF());
3481 TextObject::GetTotalComposedHeightF(void) const
3483 return __pCompositeText->GetTotalComposedHeightF();
3487 TextObject::GetLineWidthAt(int lineIndex) const
3489 return _CoordinateSystemUtils::ConvertToInteger(GetLineWidthAtF(lineIndex));
3493 TextObject::GetLineWidthAtF(int lineIndex) const
3495 IF_NOT_CONSTRUCTED(return -1);
3497 result r = E_SUCCESS;
3498 TextLine* pTextLine = null;
3499 FloatDimension lineTextSize;
3502 pTextLine = __pTextColumn->GetTextLine(lineIndex);
3503 SysTryCatch(NID_GRP, pTextLine, , E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3505 lineLength = pTextLine->GetTextLength();
3506 r = pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
3507 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3509 SetLastResult(E_SUCCESS);
3510 return lineTextSize.width;
3517 TextObject::GetTotalHeight(void) const
3519 return _CoordinateSystemUtils::ConvertToInteger(GetTotalHeightF());
3523 TextObject::GetTotalHeightF(void) const
3525 IF_NOT_CONSTRUCTED(return -1);
3527 float height = 0.0f;
3528 if (IsPartialComposingModeEnabled())
3530 height = __pCompositeText->GetAnalysedTotalHeightF();
3534 height = __pTextColumn->GetTotalHeightF();
3541 TextObject::GetElementIndexOf(TextElement& textElement) const
3543 IF_NOT_CONSTRUCTED(return -1);
3545 return __pCompositeText->GetElementIndexOf(textElement);
3549 TextObject::RemoveElementAt(int elementIndex, bool deallocate)
3551 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3553 return __pCompositeText->RemoveElementAt(elementIndex, deallocate);
3557 TextObject::HideFrontSpace(TextObjectSpaceHideType mode)
3559 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3561 __pCompositeText->HideFrontSpace(mode);
3567 TextObject::HideRearSpace(TextObjectSpaceHideType mode)
3569 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3571 __pCompositeText->HideRearSpace(mode);
3577 TextObject::GetSlidingStep(void) const
3579 return _CoordinateSystemUtils::ConvertToInteger(GetSlidingStepF());
3583 TextObject::GetSlidingStepF(void) const
3585 IF_NOT_CONSTRUCTED(return -1.0f);
3587 return __slidingStep;
3592 TextObject::SetSlidingStep(int slidingStep)
3594 return SetSlidingStep(_CoordinateSystemUtils::ConvertToFloat(slidingStep));
3598 TextObject::SetSlidingStep(float slidingStep)
3600 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3602 __slidingStep = slidingStep;
3608 TextObject::GetTotalLineCount(void) const
3610 IF_NOT_CONSTRUCTED(return -1);
3612 return __pTextColumn->GetTotalLineCount();
3616 TextObject::GetLineIndexAtTextIndex(int textIndex) const
3618 IF_NOT_CONSTRUCTED(return -1);
3620 return __pTextColumn->GetLineIndexAtTextIndex(textIndex);
3624 TextObject::GetLineHeightAt(int lineIndex) const
3626 return _CoordinateSystemUtils::ConvertToInteger(GetLineHeightAtF(lineIndex));
3630 TextObject::GetLineHeightAtF(int lineIndex) const
3632 IF_NOT_CONSTRUCTED(return -1);
3634 SysTryReturn(NID_GRP, lineIndex >= 0, -1, E_INVALID_ARG
3635 , "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
3637 return __pTextColumn->GetLineHeightAtF(lineIndex);
3641 TextObject::GetDisplayLineCount(void) const
3643 IF_NOT_CONSTRUCTED(return -1);
3645 return __pTextColumn->GetDisplayLineCount();
3649 TextObject::GetFirstDisplayLineIndex(void) const
3651 IF_NOT_CONSTRUCTED(return -1);
3653 return __pTextColumn->GetFirstDisplayLineIndex();
3657 TextObject::GetFirstDisplayPositionY(void) const
3659 return _CoordinateSystemUtils::ConvertToInteger(GetFirstDisplayPositionYF());
3663 TextObject::GetFirstDisplayPositionYF(void) const
3665 IF_NOT_CONSTRUCTED(return -1);
3667 return __pTextColumn->GetFirstDisplayPositionYF();
3671 TextObject::GetLineIndexAtPositionY(int y) const
3673 return GetLineIndexAtPositionY(_CoordinateSystemUtils::ConvertToFloat(y));
3677 TextObject::GetLineIndexAtPositionY(float y) const
3679 IF_NOT_CONSTRUCTED(return -1);
3681 return __pTextColumn->GetLineIndexAtPositionY(y);
3685 TextObject::GetFirstTextIndexAt(int lineIndex) const
3687 IF_NOT_CONSTRUCTED(return -1);
3689 SysTryReturn(NID_GRP, lineIndex >= 0, -1, E_INVALID_ARG
3690 , "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
3692 return __pTextColumn->GetFirstTextIndexAt(lineIndex);
3696 TextObject::GetTextLengthAt(int lineIndex) const
3698 IF_NOT_CONSTRUCTED(return -1);
3700 SysTryReturn(NID_GRP, lineIndex >= 0, -1, E_INVALID_ARG
3701 , "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
3703 return __pTextColumn->GetTextLengthAt(lineIndex);
3707 TextObject::GetBounds(void) const
3709 IF_NOT_CONSTRUCTED(return Rectangle(0, 0, 0, 0));
3711 return _CoordinateSystemUtils::ConvertToInteger(__rect);
3715 TextObject::GetBoundsF(void) const
3721 TextObject::GetLineSpace(void) const
3723 IF_NOT_CONSTRUCTED(return -1);
3725 return _CoordinateSystemUtils::ConvertToInteger(GetLineSpaceF());
3729 TextObject::GetLineSpaceF(void) const
3731 IF_NOT_CONSTRUCTED(return -1);
3733 return __pCompositeText->GetLineSpaceF();
3737 TextObject::GetTextLength(void) const
3739 IF_NOT_CONSTRUCTED(return -1);
3741 return __pCompositeText->GetTextLength();
3745 TextObject::GetElementVerticalAlignment(void) const
3747 IF_NOT_CONSTRUCTED(return TEXT_OBJECT_ALIGNMENT_INVALID);
3749 return __pCompositeText->GetElementVerticalAlignment();
3752 TextObjectActionType
3753 TextObject::GetAction(void) const
3755 IF_NOT_CONSTRUCTED(return TEXT_OBJECT_ACTION_TYPE_NONE);
3761 TextObject::GetAlignment(void) const
3763 IF_NOT_CONSTRUCTED(return TEXT_OBJECT_ALIGNMENT_INVALID);
3769 TextObject::GetElementCount(void) const
3771 IF_NOT_CONSTRUCTED(return -1);
3773 return __pCompositeText->GetElementCount();
3777 TextObject::GetElementAtElementIndex(int elementIndex) const
3779 IF_NOT_CONSTRUCTED(return null);
3781 return __pCompositeText->GetElementAtElementIndex(elementIndex);
3785 TextObject::SetRange(int startTextIndex, int textLength)
3787 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3789 return __pCompositeText->SetRange(startTextIndex, textLength);
3793 TextObject::GetRange(int& startTextIndex, int& textLength) const
3795 IF_NOT_CONSTRUCTED(return);
3797 return __pCompositeText->GetRange(startTextIndex, textLength);
3801 TextObject::GetWrap(void) const
3803 IF_NOT_CONSTRUCTED(return TEXT_OBJECT_WRAP_TYPE_NONE);
3809 TextObject::SetCursorIndex(int cursorIndex)
3811 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3813 SysTryReturn(NID_GRP, cursorIndex >= 0, E_INVALID_ARG, E_INVALID_ARG
3814 , "[E_INVALID_ARG] The argument is invalid.");
3816 __pCompositeText->SetCursorIndex(cursorIndex);
3822 TextObject::GetCursorIndex(void) const
3824 IF_NOT_CONSTRUCTED(return -1);
3826 return __pCompositeText->GetCursorIndex();
3830 TextObject::SetBlock(bool enable)
3832 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3834 __pCompositeText->SetBlock(enable);
3840 TextObject::GetBlock(void) const
3842 IF_NOT_CONSTRUCTED(return false);
3844 return __pCompositeText->GetBlock();
3848 TextObject::SetBlockRange(int startTextIndex, int textLength)
3850 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3852 result r = E_SUCCESS;
3853 r = __pCompositeText->SetRange(startTextIndex, textLength);
3854 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3860 TextObject::GetBlockRange(int& startTextIndex, int& textLength)
3862 IF_NOT_CONSTRUCTED(return);
3864 __pCompositeText->GetRange(startTextIndex, textLength);
3868 TextObject::IsAlternateLookEnabled(void) const
3870 IF_NOT_CONSTRUCTED(return false);
3872 return __isAlternateLookEnabled;
3876 TextObject::GetTotalCutLinkElementCount(void) const
3878 IF_NOT_CONSTRUCTED(return -1);
3880 return __pCompositeText->GetCutLinkElementCount();
3884 TextObject::ChangeCutLinkState(int linkIndex, bool select)
3886 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3888 return __pCompositeText->ChangeCutLinkState(linkIndex, select);
3892 TextObject::ResetAllCutLinkElementsState(void)
3894 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3896 return __pCompositeText->ResetAllCutLinkElementsState();
3900 TextObject::IsActionOn(void) const
3902 IF_NOT_CONSTRUCTED(return false);
3904 return __isActionOn;
3907 TextObjectEllipsisType
3908 TextObject::GetTextObjectEllipsisType(void) const
3910 IF_NOT_CONSTRUCTED(return TEXT_OBJECT_ELLIPSIS_TYPE_INVALID);
3912 return __textObjectEllipsisType;
3916 TextObject::ChangeText(int textIndex)
3918 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3920 if (__sweepInfo.isValid)
3922 __sweepInfo.isValid = false;
3923 return E_INVALID_STATE;
3926 __sweepInfo.isValid = true;
3927 __sweepInfo.sweepType = TEXT_OBJECT_SWEEP_TYPE_REPLACE;
3928 __sweepInfo.sweepEventType = TEXT_OBJECT_SWEEP_EVENT_INSERT;
3929 __sweepInfo.anchorTextIndex = textIndex;
3930 __sweepInfo.sweepRegionStartLineIndex = GetLineIndexAtTextIndex(textIndex);
3931 __sweepInfo.sweepRegionLineCount = 1;
3932 __sweepInfo.anchorLineIndex = __sweepInfo.sweepRegionStartLineIndex;
3933 __sweepInfo.widthChanged = 0;
3935 __pCompositeText->SetTextSweepInfo(&__sweepInfo);
3941 TextObject::InputText(int textIndex)
3943 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3945 if (__sweepInfo.isValid == true)
3947 __sweepInfo.isValid = false;
3948 return E_INVALID_STATE;
3951 __sweepInfo.isValid = true;
3952 __sweepInfo.sweepType = TEXT_OBJECT_SWEEP_TYPE_KEYINPUT;
3953 __sweepInfo.sweepEventType = TEXT_OBJECT_SWEEP_EVENT_INSERT;
3954 __sweepInfo.anchorTextIndex = textIndex;
3955 __sweepInfo.prevAnchorLineIndex = GetLineIndexAtTextIndex(textIndex);
3957 if (__sweepInfo.prevAnchorLineIndex == -1)
3959 __sweepInfo.prevAnchorLineIndex = __pTextColumn->GetTotalLineCount()-1;
3962 __pCompositeText->SetTextSweepInfo(&__sweepInfo);
3968 TextObject::RemoveText(int textIndex)
3970 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3972 if (__sweepInfo.isValid == true)
3974 __sweepInfo.isValid = false;
3975 return E_INVALID_STATE;
3978 __sweepInfo.isValid = true;
3979 __sweepInfo.sweepEventType = TEXT_OBJECT_SWEEP_EVENT_REMOVE;
3980 __sweepInfo.anchorTextIndex = textIndex;
3981 __sweepInfo.prevAnchorLineIndex = GetLineIndexAtTextIndex(textIndex);
3983 if (__sweepInfo.prevAnchorLineIndex == -1)
3985 __sweepInfo.prevAnchorLineIndex = __pTextColumn->GetTotalLineCount()-1;
3988 __pCompositeText->SetTextSweepInfo(&__sweepInfo);
3994 TextObject::ResetSweepInfo(void)
3996 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3998 __sweepInfo.isValid = false;
4004 TextObject::GetSweepInfo(void) const
4006 TextObjectSweepInfo textSweepInfo;
4007 textSweepInfo.isValid = false;
4008 textSweepInfo.sweepType = TEXT_OBJECT_SWEEP_TYPE_NONE;
4009 textSweepInfo.sweepEventType = TEXT_OBJECT_SWEEP_EVENT_NONE;
4010 textSweepInfo.anchorTextIndex = -1;
4011 textSweepInfo.anchorLineIndex = -1;
4012 textSweepInfo.prevAnchorLineIndex = -1;
4013 textSweepInfo.sweepRegionStartLineIndex = -1;
4014 textSweepInfo.sweepRegionLineCount = -1;
4015 textSweepInfo.insertedLineCount = -1;
4016 textSweepInfo.deletedLineCount = -1;
4017 textSweepInfo.widthChanged = -1;
4019 IF_NOT_CONSTRUCTED(return textSweepInfo);
4021 textSweepInfo.isValid = __sweepInfo.isValid;
4022 textSweepInfo.sweepType = __sweepInfo.sweepType;
4023 textSweepInfo.sweepEventType = __sweepInfo.sweepEventType;
4024 textSweepInfo.anchorTextIndex = __sweepInfo.anchorTextIndex;
4025 textSweepInfo.anchorLineIndex = __sweepInfo.anchorLineIndex;
4026 textSweepInfo.prevAnchorLineIndex = __sweepInfo.prevAnchorLineIndex;
4027 textSweepInfo.sweepRegionStartLineIndex = __sweepInfo.sweepRegionStartLineIndex;
4028 textSweepInfo.sweepRegionLineCount = __sweepInfo.sweepRegionLineCount;
4029 textSweepInfo.insertedLineCount = __sweepInfo.insertedLineCount;
4030 textSweepInfo.deletedLineCount = __sweepInfo.deletedLineCount;
4031 textSweepInfo.widthChanged = __sweepInfo.widthChanged;
4033 return textSweepInfo;
4037 TextObject::GetSweepComposeLineInfo(int lineIndex, TextObjectSweepComposeLineInfo& textSweepComposeLineInfo) const
4039 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4041 SysTryReturn(NID_GRP, lineIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4043 TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex);
4044 SysTryReturn(NID_GRP, pTextLine, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4046 textSweepComposeLineInfo = pTextLine->GetSweepComposeInfo();
4052 TextObject::GetTextOffsetAtLine(int lineIndex) const
4054 IF_NOT_CONSTRUCTED(return -1);
4056 SysTryReturn(NID_GRP, lineIndex >= 0, -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4058 TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex);
4059 SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
4061 return pTextLine->GetTextOffset();
4065 TextObject::GetTextLengthAtLine(int lineIndex) const
4067 IF_NOT_CONSTRUCTED(return -1);
4069 SysTryReturn(NID_GRP, lineIndex >= 0, -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4071 TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex);
4072 SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
4074 return pTextLine->GetTextLength();
4078 TextObject::GetBoundsAtLine(int lineIndex) const
4080 return _CoordinateSystemUtils::ConvertToInteger(GetBoundsAtLineF(lineIndex));
4084 TextObject::GetBoundsAtLineF(int lineIndex) const
4086 IF_NOT_CONSTRUCTED(return FloatRectangle(-1, -1, -1, -1));
4088 SysTryReturn(NID_GRP, lineIndex >= 0, FloatRectangle(-1, -1, -1, -1), E_INVALID_ARG
4089 , "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4091 TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex);
4092 SysTryReturn(NID_GRP, pTextLine, FloatRectangle(-1, -1, -1, -1), E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
4094 FloatRectangle lineBounds = pTextLine->GetBoundsF();
4100 TextObject::GetDisplayPositionAtLine(int lineIndex, int textIndexFromLineOffset)
4102 return _CoordinateSystemUtils::ConvertToInteger(GetDisplayPositionAtLineF(lineIndex, textIndexFromLineOffset));
4106 TextObject::GetDisplayPositionAtLineF(int lineIndex, int textIndexFromLineOffset)
4108 IF_NOT_CONSTRUCTED(return FloatPoint(-1.0f, -1.0f));
4110 SysTryReturn(NID_GRP, lineIndex >= 0, FloatPoint(-1.0f, -1.0f), E_INVALID_ARG
4111 , "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4113 TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex);
4114 SysTryReturn(NID_GRP, pTextLine, FloatPoint(-1.0f, -1.0f), E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
4116 int lineOffset = pTextLine->GetTextOffset();
4117 int lineLength = pTextLine->GetTextLength();
4118 FloatDimension lineTextSize;
4119 FloatDimension extentDim;
4120 FloatRectangle lineBounds;
4123 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
4124 lineBounds = pTextLine->GetBoundsF();
4126 __pCompositeText->ForwardAnalyze(lineOffset, textIndexFromLineOffset, lineTextSize.width, __wrap, textCount, extentDim.width, extentDim.height);
4128 switch (__align & TEXT_ALIGNMASK_HORIZ)
4130 case TEXT_OBJECT_ALIGNMENT_LEFT:
4133 case TEXT_OBJECT_ALIGNMENT_CENTER:
4134 extentDim.width += (lineBounds.width - lineTextSize.width) / 2.0f;
4137 case TEXT_OBJECT_ALIGNMENT_RIGHT:
4138 extentDim.width += (lineBounds.width - lineTextSize.width);
4142 if (extentDim.width < 0.0f)
4144 extentDim.width = 0.0f;
4147 return FloatPoint(extentDim.width + __rect.x, lineBounds.y - __pTextColumn->GetFirstDisplayPositionYF() + __rect.y);
4151 TextObject::GetDisplayableText(void)
4153 IF_NOT_CONSTRUCTED(return -1);
4155 return __pCompositeText->GetDisplayableText(__rect, __action);
4159 TextObject::WordExceedsWidthAt(int lineIndex) const
4161 IF_NOT_CONSTRUCTED(return false);
4163 SysTryReturn(NID_GRP, lineIndex >= 0, false, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4165 TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex);
4166 SysTryReturn(NID_GRP, pTextLine, false, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
4168 bool hasOneWord = (pTextLine->GetEndType() == TEXT_RETBY_LIMITWIDTH) ? true : false;
4174 TextObject::SetTextBidiHint(TextBidiHint bidiHint)
4178 case TEXT_BIDI_HINT_NONE:
4179 case TEXT_BIDI_HINT_LTR:
4180 case TEXT_BIDI_HINT_RTL:
4181 __bidiHint = bidiHint;
4187 TextObject::GetTextBidiHint(void) const
4193 TextObject::SetDisplayBoundsExpandEnabled(bool enable)
4195 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4197 __isDisplayBoundsExpandEnabled = enable;
4203 TextObject::IsDisplayBoundsExpandEnabled(void) const
4205 IF_NOT_CONSTRUCTED(return false);
4207 return __isDisplayBoundsExpandEnabled;
4210 }}} // Tizen::Graphics::_Text