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;
89 __slidingGap = CoordinateSystem::ConvertToLogicalX(30.0f);
90 __slidingStep = CoordinateSystem::ConvertToLogicalX(2.0f);
91 __linkViewModeEnabled = false;
92 __isUrlLinkColorDefined = false;
93 __isEmailLinkColorDefined = false;
94 __isPhoneNumberLinkColorDefined = false;
95 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_NORMAL] = Color::GetColor(COLOR_ID_BLUE);
96 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_SELECT] = Color::GetColor(COLOR_ID_BLUE);
97 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_NORMAL] = Color::GetColor(COLOR_ID_BLUE);
98 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_SELECT] = Color::GetColor(COLOR_ID_BLUE);
99 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_NORMAL] = Color::GetColor(COLOR_ID_BLUE);
100 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_SELECT] = Color::GetColor(COLOR_ID_BLUE);
101 __bidiHint = TEXT_BIDI_HINT_NONE;
102 __isDisplayBoundsExpandEnabled = false;
104 __sweepInfo.isValid = false;
105 __sweepInfo.sweepType = TEXT_OBJECT_SWEEP_TYPE_NONE;
106 __sweepInfo.sweepEventType = TEXT_OBJECT_SWEEP_EVENT_NONE;
107 __sweepInfo.anchorTextIndex = 0;
108 __sweepInfo.anchorLineIndex = 0;
109 __sweepInfo.prevAnchorLineIndex = 0;
110 __sweepInfo.sweepRegionStartLineIndex = 0;
111 __sweepInfo.sweepRegionLineCount = 0;
112 __sweepInfo.insertedLineCount = 0;
113 __sweepInfo.deletedLineCount = 0;
114 __sweepInfo.widthChanged = 0;
117 TextObject::~TextObject(void)
119 Release(__pCompositeText);
120 Release(__pTextColumn);
121 Release(__pDefaultFont);
125 TextObject::Construct(void)
127 result r = E_SUCCESS;
129 __action = TEXT_OBJECT_ACTION_TYPE_NONE;
130 __align = (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
131 __wrap = TEXT_OBJECT_WRAP_TYPE_WORD;
132 __isActionOn = false;
134 __defaultForegroundColor = Color::GetColor(COLOR_ID_BLACK);
135 __defaultBackgroundColor = Color::GetColor(COLOR_ID_WHITE);
136 __defaultOutlineColor = Color::GetColor(COLOR_ID_WHITE);
137 __isAlternateLookEnabled = false;
138 __linkViewModeEnabled = false;
139 __bidiHint = TEXT_BIDI_HINT_NONE;
141 __pCompositeText = new (std::nothrow)TextComposite();
142 SysTryCatch(NID_GRP, __pCompositeText, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
144 __pTextColumn = new (std::nothrow)TextColumn(__pCompositeText);
145 SysTryCatch(NID_GRP, __pTextColumn, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
147 __pDefaultFont = new (std::nothrow)Font();
148 SysTryCatch(NID_GRP, __pDefaultFont, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
150 r = __pDefaultFont->Construct(FONT_STYLE_PLAIN, DEFAULT_FONT_SIZE);
151 SysTryCatch(NID_GRP, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Fail to set font.");
153 __pCompositeText->SetWrap(__wrap);
154 __pCompositeText->SetTextSweepInfo(&__sweepInfo);
159 Release(__pDefaultFont);
160 Release(__pCompositeText);
161 Release(__pTextColumn);
167 TextObject::Construct(const Rectangle& rect)
169 result r = E_SUCCESS;
171 __action = TEXT_OBJECT_ACTION_TYPE_NONE;
172 __align = (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
173 __wrap = TEXT_OBJECT_WRAP_TYPE_WORD;
174 __isActionOn = false;
176 __defaultForegroundColor = Color::GetColor(COLOR_ID_BLACK);
177 __defaultBackgroundColor = Color::GetColor(COLOR_ID_WHITE);
178 __defaultOutlineColor = Color::GetColor(COLOR_ID_WHITE);
179 __isAlternateLookEnabled = false;
180 __linkViewModeEnabled = false;
181 __bidiHint = TEXT_BIDI_HINT_NONE;
182 __rect = _CoordinateSystemUtils::ConvertToFloat(rect);
184 __pCompositeText = new (std::nothrow)TextComposite();
185 SysTryCatch(NID_GRP, __pCompositeText, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
187 __pTextColumn = new (std::nothrow)TextColumn(__pCompositeText);
188 SysTryCatch(NID_GRP, __pTextColumn, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
190 __pDefaultFont = new (std::nothrow)Font();
191 SysTryCatch(NID_GRP, __pTextColumn, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
193 r = __pDefaultFont->Construct(FONT_STYLE_PLAIN, DEFAULT_FONT_SIZE);
194 SysTryCatch(NID_GRP, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Fail to set font.");
196 __pCompositeText->SetWrap(__wrap);
197 __pCompositeText->SetTextSweepInfo(&__sweepInfo);
202 Release(__pDefaultFont);
203 Release(__pCompositeText);
204 Release(__pTextColumn);
210 TextObject::Construct(const FloatRectangle& rect)
212 result r = E_SUCCESS;
214 __action = TEXT_OBJECT_ACTION_TYPE_NONE;
215 __align = (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
216 __wrap = TEXT_OBJECT_WRAP_TYPE_WORD;
217 __isActionOn = false;
219 __defaultForegroundColor = Color::GetColor(COLOR_ID_BLACK);
220 __defaultBackgroundColor = Color::GetColor(COLOR_ID_WHITE);
221 __defaultOutlineColor = Color::GetColor(COLOR_ID_WHITE);
222 __isAlternateLookEnabled = false;
223 __linkViewModeEnabled = false;
224 __bidiHint = TEXT_BIDI_HINT_NONE;
227 __pCompositeText = new (std::nothrow)TextComposite();
228 SysTryCatch(NID_GRP, __pCompositeText, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
230 __pTextColumn = new (std::nothrow)TextColumn(__pCompositeText);
231 SysTryCatch(NID_GRP, __pTextColumn, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
233 __pDefaultFont = new (std::nothrow)Font();
234 SysTryCatch(NID_GRP, __pTextColumn, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
236 r = __pDefaultFont->Construct(FONT_STYLE_PLAIN, DEFAULT_FONT_SIZE);
237 SysTryCatch(NID_GRP, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Fail to set font.");
239 __pCompositeText->SetWrap(__wrap);
240 __pCompositeText->SetTextSweepInfo(&__sweepInfo);
245 Release(__pDefaultFont);
246 Release(__pCompositeText);
247 Release(__pTextColumn);
253 TextObject::CloneN(void)
255 IF_NOT_CONSTRUCTED(return null);
257 result r = E_SUCCESS;
258 TextObject* pTextObject = null;
259 TextElement* pTextElement = null;
260 TextElement* pCloneTextElement = null;
261 int count = __pCompositeText->GetElementCount();
263 pTextObject = new (std::nothrow)TextObject();
264 SysTryReturn(NID_GRP, pTextObject, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
266 r = pTextObject->Construct();
267 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
269 for (int i=0; i < count; i++)
271 pTextElement = __pCompositeText->GetElementAtElementIndex(i);
272 SysTryCatch(NID_GRP, pTextElement, , E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
274 pCloneTextElement = pTextElement->CloneN(SET_ALLVALUE_CLONE,0);
275 pTextObject->AppendElement(*pCloneTextElement);
278 SetLastResult(E_SUCCESS);
283 Release(pTextObject);
289 TextObject::Draw(_CanvasImpl& canvasImpl)
291 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
293 if (__rect.width == 0.0f || __rect.height == 0.0f)
298 result r = E_SUCCESS;
299 TextLine* pTextLine = null;
300 FloatRectangle clipRect;
301 FloatRectangle lineBounds;
302 FloatRectangle targetBounds;
303 float totalHeight = 0;
304 float slidingWidth = 0;
306 SysTryReturn(NID_GRP, __rect.width > 0.0f && __rect.height > 0.0f, E_INVALID_STATE, E_INVALID_STATE
307 , "[E_INVALID_STATE] This instance is not constructed yet. (width = %0.6f, height = %0.6f)", __rect.width, __rect.height);
309 TextBidiHint bidiHint = _GetTextBidiHint();
310 _SetTextBidiHint(__bidiHint);
313 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
315 if (__pTextColumn->GetTotalLineCount() <= 1)
317 __pTextColumn->SetFirstDisplayLineIndex(0);
318 __pTextColumn->SetFirstDisplayPositionY(0.0f);
321 targetBounds = __rect;
323 if (__action == TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT)
325 if (__pTextColumn->GetTotalLineCount() == 0)
330 totalHeight = TextUtility::GetFontMaxHeightF(__pDefaultFont);
334 totalHeight = __pTextColumn->GetTotalHeightF();
337 if (totalHeight == 0)
342 if (totalHeight < targetBounds.height)
344 switch (__align & TEXT_ALIGNMASK_VERT)
346 case TEXT_OBJECT_ALIGNMENT_TOP:
351 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
352 targetBounds.y += (targetBounds.height - totalHeight) / 2.0f;
355 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
356 targetBounds.y += targetBounds.height - totalHeight;
362 if (targetBounds.height < totalHeight)
364 if (__action == TEXT_OBJECT_ACTION_TYPE_ABBREV)
367 int lineCount = __pTextColumn->GetTotalLineCount();
371 totalHeight = targetBounds.height;
375 float lineHeight = __pTextColumn->GetLineHeightAtF(0);
377 if (targetBounds.height < lineHeight)
379 totalHeight = targetBounds.height;
385 for (i = 0; i < lineCount; i++)
387 lineHeight += __pTextColumn->GetLineHeightAtF(i);
388 if (targetBounds.height < lineHeight)
390 lineHeight -= __pTextColumn->GetLineHeightAtF(i);
395 totalHeight = lineHeight;
409 switch (__align & TEXT_ALIGNMASK_VERT)
411 case TEXT_OBJECT_ALIGNMENT_TOP:
416 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
417 targetBounds.y += (targetBounds.height - totalHeight) / 2.0f;
420 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
421 targetBounds.y += targetBounds.height - totalHeight;
424 targetBounds.height = totalHeight;
428 FloatRectangle finalClipRect;
429 clipRect = canvasImpl.GetClipBoundsF();
431 finalClipRect.x = (clipRect.x > __rect.x) ? clipRect.x : __rect.x;
432 finalClipRect.y = (clipRect.y > __rect.y) ? clipRect.y: __rect.y;
433 finalClipRect.width = (clipRect.x + clipRect.width > __rect.x + __rect.width) ? (__rect.x + __rect.width) - finalClipRect.x : (clipRect.x + clipRect.width) - finalClipRect.x;
434 finalClipRect.height = (clipRect.y + clipRect.height > __rect.y + __rect.height) ? (__rect.y + __rect.height) - finalClipRect.y : (clipRect.y + clipRect.height) - finalClipRect.y;
436 if (__isDisplayBoundsExpandEnabled == true)
438 finalClipRect.y = clipRect.y;
439 finalClipRect.height = clipRect.height;
442 SysTryReturn(NID_GRP, 0.0f <= finalClipRect.width && 0.0f <= finalClipRect.height, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get clip rectangle.");
444 canvasImpl.SetClipBounds(finalClipRect);
448 case TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT:
449 pTextLine = __pTextColumn->GetTextLine(0);
450 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
452 lineBounds = pTextLine->GetBoundsF();
453 __pTextColumn->SetDisplayLineCount(1);
454 __pTextColumn->SetDisplayHeight(lineBounds.height);
456 slidingWidth = (__pTextColumn->GetSlidingDimension().width > __rect.width) ? __pTextColumn->GetSlidingDimension().width : __rect.width;
460 FloatRectangle slidingRect;
462 targetBounds.width = lineBounds.width;
463 targetBounds.height = lineBounds.height;
465 slidingRect = targetBounds;
467 slidingRect.x += __pTextColumn->GetSlidingPositionF();
468 FloatDimension slidingDim = __pTextColumn->GetSlidingDimensionF();
469 slidingRect.width = slidingDim.width;
470 slidingRect.height = slidingDim.height;
472 __pCompositeText->Draw(canvasImpl, slidingRect, 0, __pCompositeText->GetTextLength(),
473 (TextObjectAlignment)(__align & TEXT_ALIGNMASK_HORIZ), TEXT_OBJECT_ACTION_TYPE_NONE);
475 slidingRect.x += slidingDim.width + __slidingGap;
476 if (slidingRect.x < targetBounds.x + targetBounds.width)
478 slidingRect.width = targetBounds.x + targetBounds.width - slidingRect.x;
479 __pCompositeText->Draw(canvasImpl, slidingRect, 0, __pCompositeText->GetTextLength()
480 ,(TextObjectAlignment)(__align & TEXT_ALIGNMASK_HORIZ), TEXT_OBJECT_ACTION_TYPE_NONE);
485 pTextLine->Draw(canvasImpl, targetBounds, 0, pTextLine->GetTextLength(),
486 (TextObjectAlignment)(__align & TEXT_ALIGNMASK_HORIZ), TEXT_OBJECT_ACTION_TYPE_NONE);
490 case TEXT_OBJECT_ACTION_TYPE_SLIDE_UP:
492 FloatRectangle slidingRect = targetBounds;
493 slidingRect.y += __pTextColumn->GetSlidingPositionF();
495 int lineCount = __pTextColumn->GetTotalLineCount();
496 for (int i = 0; i < lineCount; i++)
498 pTextLine = __pTextColumn->GetTextLine(i);
499 if (pTextLine != null)
501 lineBounds = pTextLine->GetBoundsF();
502 slidingRect.height = lineBounds.height;
503 if ((slidingRect.y + slidingRect.height >= targetBounds.y) && (slidingRect.y < targetBounds.y + targetBounds.height))
505 pTextLine->Draw(canvasImpl, slidingRect, 0, pTextLine->GetTextLength(),
506 (TextObjectAlignment)(__align & TEXT_ALIGNMASK_HORIZ), TEXT_OBJECT_ACTION_TYPE_NONE);
509 slidingRect.y += slidingRect.height;
514 case TEXT_OBJECT_ACTION_TYPE_ABBREV:
515 if (__pCompositeText->IsTextAbbreviationEnabled())
517 __pCompositeText->DrawAbbrev(canvasImpl, targetBounds, __align);
521 DrawByLine(canvasImpl, targetBounds);
525 case TEXT_OBJECT_ACTION_TYPE_NONE:
528 DrawByLine(canvasImpl, targetBounds);
532 canvasImpl.SetClipBounds(clipRect);
533 _SetTextBidiHint(bidiHint);
539 TextObject::GetChangedLineRange(int& startChangedLineIndex, int& endChangedLineIndex)
541 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
543 result r = E_SUCCESS;
546 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
548 startChangedLineIndex = __sweepInfo.sweepRegionStartLineIndex;
549 endChangedLineIndex = __sweepInfo.sweepRegionStartLineIndex + __sweepInfo.sweepRegionLineCount - 1;
555 TextObject::DrawLine(_CanvasImpl& canvasImpl, int lineIndex)
557 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
559 SysTryReturn(NID_GRP, lineIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
561 result r = E_SUCCESS;
562 TextLine* pTextLine = null;
563 FloatRectangle lineBounds;
564 float firstDisplayY = __pTextColumn->GetFirstDisplayPositionYF();
566 TextBidiHint bidiHint = _GetTextBidiHint();
567 _SetTextBidiHint(__bidiHint);
570 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
572 pTextLine = __pTextColumn->GetTextLine(lineIndex);
573 if (pTextLine == null)
575 SysLog(NID_GRP, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d, total line count = %d)"
576 , lineIndex, __pTextColumn->GetTotalLineCount());
578 return E_INVALID_ARG;
581 lineBounds = pTextLine->GetBoundsF();
582 lineBounds.y = lineBounds.y - firstDisplayY + __rect.y;
584 int length = pTextLine->GetTextLength();
585 pTextLine->Draw(canvasImpl, lineBounds, 0, length, __align, TEXT_OBJECT_ACTION_TYPE_NONE);
587 _SetTextBidiHint(bidiHint);
593 TextObject::DrawWithOffset(_CanvasImpl& canvasImpl)
595 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
597 SysTryReturn(NID_GRP, __isActionOn, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Action is off.");
599 float slidingStartIndex = __pTextColumn->GetSlidingPositionF();
600 FloatDimension slidingDim = __pTextColumn->GetSlidingDimensionF();
604 case TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT:
605 if (__rect.width < slidingDim.width)
607 slidingDim.width = (slidingDim.width > __rect.width) ? slidingDim.width: __rect.width;
609 if (__slidingStep < slidingStartIndex + slidingDim.width + __slidingGap)
611 slidingStartIndex -= __slidingStep;
615 slidingStartIndex += slidingDim.width + __slidingGap;
622 if (0.0f < slidingStartIndex + slidingDim.width)
624 slidingStartIndex -= __slidingStep;
628 slidingStartIndex = __rect.width + __slidingGap + slidingStartIndex;
631 __pTextColumn->SetSlidingPosition(slidingStartIndex);
634 case TEXT_OBJECT_ACTION_TYPE_SLIDE_UP:
635 if (slidingStartIndex + slidingDim.height >= 0.0f)
637 slidingStartIndex -= __slidingStep;
641 slidingStartIndex = __rect.height;
643 __pTextColumn->SetSlidingPosition(slidingStartIndex);
646 case TEXT_OBJECT_ACTION_TYPE_ABBREV:
648 case TEXT_OBJECT_ACTION_TYPE_NONE:
654 return Draw(canvasImpl);
658 TextObject::UpdateChangedInfo(int startTextIndex, int textLength)
660 result r = E_SUCCESS;
662 if (startTextIndex >= 0)
664 r = __pTextColumn->SetChangeAction(TextColumn::TEXT_CHANGE_UNKONWN, startTextIndex, 0);
665 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
670 if (IsPartialComposingModeEnabled())
672 __pCompositeText->InitPartialComposeMode();
679 TextObject::IsChanged(void) const
681 IF_NOT_CONSTRUCTED(return false);
687 TextObject::SetPartialComposingModeEnabled(bool enable)
689 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
691 __pCompositeText->SetPartialComposingModeEnabled(enable);
697 TextObject::IsPartialComposingModeEnabled(void) const
699 IF_NOT_CONSTRUCTED(return false);
701 return __pCompositeText->IsPartialComposingModeEnabled();
705 TextObject::Compose(void)
707 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
709 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.");
711 TextBidiHint bidiHint = _GetTextBidiHint();
712 _SetTextBidiHint(__bidiHint);
715 FloatRectangle rect = __rect;
716 FloatRectangle lineBounds;
718 if (__pCompositeText->IsPartialComposingModeEnabled())
720 if (__pCompositeText->IsComposeDone() || !__isFirstDisplayPositionYChanged)
722 if (GetTotalLineCount() != 0)
730 if (!__isChanged || __pTextColumn->GetChangeActionEventCount() == 0)
736 __isActionOn = false;
738 if (__pTextColumn->GetTotalLineCount() == 0)
740 __pTextColumn->SetChangeAction(TextColumn::TEXT_CHANGE_UNKONWN, 0, 0);
741 __pTextColumn->SetFirstDisplayLineIndex(0);
742 __pTextColumn->SetFirstDisplayPositionY(0.0f);
743 __pTextColumn->SetFirstDisplayPositionX(0.0f);
747 lineCount = __pCompositeText->Compose(rect, __pTextColumn);
751 case TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT:
753 TextLine* pTextLine = __pTextColumn->GetTextLine(0);
754 if (pTextLine != null)
756 FloatRectangle lineBounds = pTextLine->GetBoundsF();
757 int lineLength = pTextLine->GetTextLength();
758 int totalLength = __pCompositeText->GetTextLength();
760 if (lineLength < totalLength || __rect.width < lineBounds.width)
763 __pTextColumn->SetSlidingPosition(0.0f);
765 FloatDimension slidingDim;
766 FloatDimension lineTextSize;
768 __pCompositeText->GetRegion(0, totalLength, slidingDim.width, slidingDim.height);
769 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
770 lineBounds = pTextLine->GetBoundsF();
772 __pTextColumn->SetSlidingDimension(slidingDim);
774 lineBounds.height = slidingDim.height;
775 lineTextSize.width = lineBounds.width;
777 pTextLine->SetBounds(lineBounds);
778 pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
784 case TEXT_OBJECT_ACTION_TYPE_SLIDE_UP:
786 __pTextColumn->SetSlidingPosition(0.0f);
788 float totalHeight = __pTextColumn->GetTotalHeightF();
789 FloatDimension slidingDim;
790 slidingDim.width = __rect.width;
791 slidingDim.height = totalHeight;
793 __pTextColumn->SetSlidingDimension(slidingDim);
795 if (__rect.height < totalHeight)
802 case TEXT_OBJECT_ACTION_TYPE_ABBREV:
804 case TEXT_OBJECT_ACTION_TYPE_NONE:
812 _SetTextBidiHint(bidiHint);
818 TextObject::GetText(wchar_t* pCopiedText, int textLength) const
820 IF_NOT_CONSTRUCTED(return -1);
822 SysTryReturn(NID_GRP, pCopiedText, -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
823 SysTryReturn(NID_GRP, textLength > 0, -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
825 int textElementCount = 0;
827 int outLength = textLength;
828 int copiedLength = 0;
829 TextElement* pTextElement = null;
830 wchar_t* pSrcText = null;
831 wchar_t* pDstText = null;
833 textElementCount = __pCompositeText->GetElementCount();
834 pDstText = pCopiedText;
836 for (int i = 0; i < textElementCount && totalLength < outLength; i++)
838 pTextElement = __pCompositeText->GetElementAtElementIndex(i);
839 if (pTextElement == null)
844 TextElementType objectType = pTextElement->GetType();
845 if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK)
847 int elementTextLength = pTextElement->GetTextLength();
848 TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
849 if (pSimpleText != null)
851 copiedLength = (elementTextLength > outLength - totalLength) ? outLength - totalLength : elementTextLength;
852 SysTryReturn(NID_GRP, 0 <= copiedLength, -1, E_SYSTEM, "[E_SYSTEM] Fail to string copy.");
854 pSrcText = (wchar_t*)pSimpleText->GetText();
856 result r = TextUtility::CopyText(pDstText, pSrcText, copiedLength);
857 SysTryReturn(NID_GRP, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
859 pDstText += copiedLength;
860 totalLength += copiedLength;
865 SetLastResult(E_SUCCESS);
871 TextObject::SetFirstDisplayLineIndex(int lineIndex)
873 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
875 if (lineIndex == 0 && __pTextColumn->GetTotalLineCount() == 0)
880 result r = E_SUCCESS;
881 FloatRectangle lineBounds;
882 TextLine* pTextLine = null;
883 float firstDisplayPositionY = 0.0f;
884 float rollbackFirstDisplayPositionY = 0.0f;
885 int rollbackFirstDisplayLineIndex = 0;
887 rollbackFirstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
888 rollbackFirstDisplayLineIndex = __pTextColumn->GetFirstDisplayLineIndex();
890 __pTextColumn->SetFirstDisplayLineIndex(lineIndex);
892 pTextLine = __pTextColumn->GetTextLine(lineIndex);
893 SysTryCatch(NID_GRP, pTextLine, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
895 lineBounds = pTextLine->GetBoundsF();
896 firstDisplayPositionY = lineBounds.y;
898 __pTextColumn->SetFirstDisplayPositionY(firstDisplayPositionY);
903 __pTextColumn->SetFirstDisplayLineIndex(rollbackFirstDisplayLineIndex);
904 __pTextColumn->SetFirstDisplayPositionY(rollbackFirstDisplayPositionY);
910 TextObject::SetFirstDisplayPositionX(int x)
912 return SetFirstDisplayPositionX(_CoordinateSystemUtils::ConvertToFloat(x));
916 TextObject::SetFirstDisplayPositionX(float x)
918 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
919 SysTryReturn(NID_GRP, __wrap == TEXT_OBJECT_WRAP_TYPE_NONE
920 , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] The argument is invalid.");
922 TextLine* pTextLine = __pTextColumn->GetTextLine(0);
923 SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
925 FloatRectangle lineBounds = pTextLine->GetBoundsF();
932 __pTextColumn->SetFirstDisplayPositionX(x);
938 TextObject::GetFirstDisplayPositionX(void) const
940 return _CoordinateSystemUtils::ConvertToInteger(GetFirstDisplayPositionXF());
944 TextObject::GetFirstDisplayPositionXF(void) const
946 IF_NOT_CONSTRUCTED(return -1);
948 return __pTextColumn->GetFirstDisplayPositionX();
952 TextObject::SetFirstDisplayPositionY(int y)
954 return SetFirstDisplayPositionY(_CoordinateSystemUtils::ConvertToFloat(y));
958 TextObject::SetFirstDisplayPositionY(float y)
960 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
962 result r = E_SUCCESS;
964 if (IsPartialComposingModeEnabled())
966 __isFirstDisplayPositionYChanged = true;
968 if (__pCompositeText->GetTotalComposedHeight() <= (y + __rect.height))
970 __pCompositeText->SetComposePartialLimitHeight(y + __rect.height - GetTotalComposedHeight());
973 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
977 __isFirstDisplayPositionYChanged = false;
978 __pTextColumn->SetFirstDisplayPositionY(y);
983 __isFirstDisplayPositionYChanged = false;
988 TextObject::GetMaxLineHeight(void) const
990 return _CoordinateSystemUtils::ConvertToInteger(GetMaxLineHeightF());
994 TextObject::GetMaxLineHeightF(void) const
996 IF_NOT_CONSTRUCTED(return -1);
998 float lineMaxHeight = __pCompositeText->GetMaxLineHeightF();
999 float fontMaxHeight = TextUtility::GetFontMaxHeightF(__pDefaultFont);
1001 return (lineMaxHeight > fontMaxHeight) ? lineMaxHeight: fontMaxHeight;
1005 TextObject::IsDisplayedAtStartPosition(void) const
1007 IF_NOT_CONSTRUCTED(return false);
1009 float firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
1011 bool isDisplayedAtStartPosition = (firstDisplayPositionY == 0.0f) ? true : false;
1013 return isDisplayedAtStartPosition;
1017 TextObject::IsDisplayedAtEndPosition(void) const
1019 IF_NOT_CONSTRUCTED(return false);
1021 float totalHeight = 0.0f;
1022 float firstDisplayPositionY = 0.0f;
1024 firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
1025 totalHeight = __pTextColumn->GetTotalHeightF();
1027 bool isDisplayedAtEndPosition = ((totalHeight - firstDisplayPositionY) <= __rect.height) ? true : false;
1029 return isDisplayedAtEndPosition;
1033 TextObject::IsDisplayedFirstLine(void) const
1035 IF_NOT_CONSTRUCTED(return false);
1037 float firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
1038 float firstLineHeight = GetLineHeightAtF(0);
1040 bool isDisplayedFirstLine = false;
1041 if(firstDisplayPositionY == 0.0f || firstDisplayPositionY < firstLineHeight)
1043 isDisplayedFirstLine = true;
1046 return isDisplayedFirstLine;
1050 TextObject::IsDisplayedLastLine(void) const
1052 IF_NOT_CONSTRUCTED(return false);
1054 float totalHeight = 0.0f;
1055 float firstDisplayPositionY = 0.0f;
1056 bool isDisplayedLastLine = false;
1058 firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
1059 totalHeight = __pTextColumn->GetTotalHeightF();
1061 float lastLineHeight = GetLineHeightAtF(GetTotalLineCount()-1);
1063 float remainingHeight = totalHeight - firstDisplayPositionY;
1064 if (remainingHeight - __rect.height < lastLineHeight || remainingHeight <= __rect.height)
1066 isDisplayedLastLine = true;
1069 return isDisplayedLastLine;
1073 TextObject::SetAction(TextObjectActionType action)
1075 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1077 SysTryReturn(NID_GRP, TEXT_OBJECT_ACTION_TYPE_NONE <= action && action < TEXT_OBJECT_ACTION_TYPE_MAX
1078 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1080 if (__action != action)
1082 if ((__action == TEXT_OBJECT_ACTION_TYPE_NONE && action == TEXT_OBJECT_ACTION_TYPE_ABBREV) ||
1083 (__action == TEXT_OBJECT_ACTION_TYPE_ABBREV && action == TEXT_OBJECT_ACTION_TYPE_NONE))
1086 UpdateChangedInfo(0, 0);
1091 UpdateChangedInfo(0, 0);
1097 bool isAbbreviationEnable = (__action == TEXT_OBJECT_ACTION_TYPE_ABBREV) ? true : false;
1098 __pCompositeText->SetTextAbbreviationEnabled(isAbbreviationEnable);
1104 TextObject::SetAlignment(TextObjectAlignment alignment)
1106 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1108 SysTryReturn(NID_GRP, TEXT_OBJECT_ALIGNMENT_LEFT <= alignment && alignment < TEXT_OBJECT_ALIGNMENT_INVALID
1109 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. alignment(%d)", alignment);
1111 if (__align != alignment)
1113 __align = alignment;
1114 UpdateChangedInfo(0, 0);
1121 TextObject::SetBounds(const Rectangle& rect)
1123 return SetBounds(_CoordinateSystemUtils::ConvertToFloat(rect));
1127 TextObject::SetBounds(const FloatRectangle& rect)
1129 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1131 SysTryReturn(NID_GRP, (rect.width >= 0.0f) && (rect.height >= 0.0f), E_OUT_OF_RANGE, E_OUT_OF_RANGE
1132 , "[E_OUT_OF_RANGE] The given rectangle(width:%0.6f,height:%0.6f) is out of range.\n", rect.width, rect.height);
1134 if (__rect.width != rect.width)
1136 UpdateChangedInfo(0, 0);
1145 TextObject::SetLineSpace(int lineSpacing)
1147 return SetLineSpace(_CoordinateSystemUtils::ConvertToFloat(lineSpacing));
1151 TextObject::SetLineSpace(float lineSpacing)
1153 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1155 SysTryReturn(NID_GRP, lineSpacing >= 0.0f, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. lineSpacing(%0.6f)", lineSpacing);
1157 if (__pCompositeText->GetLineSpace() != lineSpacing)
1159 __pCompositeText->SetLineSpace(lineSpacing);
1167 TextObject::SetElementVerticalAlignment(TextObjectAlignment alignment)
1169 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1171 SysTryReturn(NID_GRP
1172 , (alignment & TEXT_OBJECT_ALIGNMENT_TOP) || (alignment & TEXT_OBJECT_ALIGNMENT_MIDDLE) || (alignment & TEXT_OBJECT_ALIGNMENT_BOTTOM) || (alignment & TEXT_OBJECT_ALIGNMENT_BASELINE)
1173 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. alignment(%d)", alignment);
1175 if (__pCompositeText->GetElementVerticalAlignment() == alignment)
1180 __pCompositeText->SetElementVerticalAlignment(alignment);
1187 TextObject::GetTextExtent(int startTextIndex, int textLength) const
1189 return _CoordinateSystemUtils::ConvertToInteger(GetTextExtentF(startTextIndex,textLength));
1193 TextObject::GetTextExtentF(int startTextIndex, int textLength) const
1195 IF_NOT_CONSTRUCTED(return FloatDimension(-1, -1));
1197 TextBidiHint bidiHint = _GetTextBidiHint();
1198 _SetTextBidiHint(__bidiHint);
1200 FloatDimension textSize;
1201 result r = __pCompositeText->GetRegion(startTextIndex, textLength, textSize.width, textSize.height);
1202 SysTryReturn(NID_GRP, r == E_SUCCESS, FloatDimension(-1, -1), r, "[%s] Propagating.", GetErrorMessage(r));
1204 _SetTextBidiHint(bidiHint);
1206 SetLastResult(E_SUCCESS);
1212 TextObject::GetTextExtent(void) const
1214 return _CoordinateSystemUtils::ConvertToInteger(GetTextExtentF());
1218 TextObject::GetTextExtentF(void) const
1220 IF_NOT_CONSTRUCTED(return FloatDimension(-1, -1));
1222 TextBidiHint bidiHint = _GetTextBidiHint();
1223 _SetTextBidiHint(__bidiHint);
1225 TextLine* pTextLine = null;
1226 FloatDimension textSize(0.0f, 0.0f);
1227 FloatDimension lineSize(0.0f, 0.0f);
1228 int lineCount = GetTotalLineCount();
1230 for (int i = 0; i < lineCount; i++)
1232 pTextLine = __pTextColumn->GetTextLine(i);
1233 SysTryReturn(NID_GRP, pTextLine, FloatDimension(-1, -1), E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
1235 pTextLine->GetRegion(0, pTextLine->GetTextLength(), lineSize.width, lineSize.height);
1237 if (textSize.width < lineSize.width)
1239 textSize.width = lineSize.width;
1243 textSize.height = GetTotalHeightF();
1245 _SetTextBidiHint(bidiHint);
1247 SetLastResult(E_SUCCESS);
1253 TextObject::AppendElement(TextElement& textElement)
1255 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1257 result r = E_SUCCESS;
1258 TextElementType objecType = textElement.GetType();
1259 if (objecType == TEXT_ELEMENT_TYPE_CUTLINK)
1261 TextCutLink* pLinkText = dynamic_cast < TextCutLink* >(&textElement);
1262 if (pLinkText != null)
1264 switch (pLinkText->GetCutLinkType())
1267 if (__isUrlLinkColorDefined)
1269 pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_NORMAL], __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_SELECT]);
1273 case LINK_TYPE_EMAIL:
1274 if (__isEmailLinkColorDefined)
1276 pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_NORMAL], __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_SELECT]);
1280 case LINK_TYPE_TEL_NUM:
1281 if (__isPhoneNumberLinkColorDefined)
1283 pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_NORMAL],
1284 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_SELECT]);
1294 int textIndex = __pCompositeText->GetTextLength();
1295 int elementTextLength = textElement.GetTextLength();
1297 r = __pCompositeText->AppendElement(textElement);
1298 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1300 int elementCount = __pCompositeText->GetElementCount();
1301 if (elementCount > 0)
1303 __pCompositeText->Optimize(elementCount-1, elementCount-1);
1306 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
1308 UpdateChangedInfo(0, 0);
1312 NotifyTextAdded(textIndex, elementTextLength);
1319 TextObject::InsertElementAt(int textIndex, TextElement& textElement)
1321 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1323 result r = E_SUCCESS;
1324 TextElementType objecType = textElement.GetType();
1326 if (objecType == TEXT_ELEMENT_TYPE_CUTLINK)
1328 TextCutLink* pLinkText = dynamic_cast < TextCutLink* >(&textElement);
1329 if (pLinkText != null)
1331 switch (pLinkText->GetCutLinkType())
1334 if (__isUrlLinkColorDefined)
1336 pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_NORMAL],
1337 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_SELECT]);
1341 case LINK_TYPE_EMAIL:
1342 if (__isEmailLinkColorDefined)
1344 pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_NORMAL],
1345 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_SELECT]);
1349 case LINK_TYPE_TEL_NUM:
1350 if (__isPhoneNumberLinkColorDefined)
1352 pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_NORMAL],
1353 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_SELECT]);
1363 r = __pCompositeText->InsertElementAt(textElement, textIndex);
1364 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Fail to insert element.", GetErrorMessage(r));
1366 int elementIndex = __pCompositeText->GetElementIndexOf(textElement);
1367 if (elementIndex != -1)
1369 __pCompositeText->Optimize(elementIndex, elementIndex);
1372 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
1374 UpdateChangedInfo(0, 0);
1378 NotifyTextAdded(textIndex, textElement.GetTextLength());
1385 TextObject::RemoveAll(bool deallocate)
1387 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1389 result r = __pTextColumn->RemoveAllLines();
1390 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1392 r = __pCompositeText->RemoveAllElements(deallocate);
1393 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1395 UpdateChangedInfo(0);
1397 __isActionOn = false;
1403 TextObject::Remove(int startTextIndex, int textLength)
1405 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1407 SysTryReturn(NID_GRP, startTextIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1409 result r = __pTextColumn->RemoveAllLines();
1410 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1412 r = __pCompositeText->Remove(startTextIndex, textLength);
1413 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1415 UpdateChangedInfo(0);
1421 TextObject::RemoveElement(TextElement& textElement, bool deallocate)
1423 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1425 result r = E_SUCCESS;
1426 int elementIndex = 0;
1428 int elementTextLength = 0;
1429 TextElement* pCurrentTextElement = null;
1431 elementIndex = __pCompositeText->GetElementIndexOf(textElement);
1432 SysTryReturn(NID_GRP, 0 <= elementIndex, E_INVALID_ARG, E_INVALID_ARG, "[E_SYSTEM] The argument is invalid.");
1434 for (int i = 0; i < elementIndex; i++)
1436 pCurrentTextElement = __pCompositeText->GetElementAtElementIndex(i);
1437 if (pCurrentTextElement != null)
1439 textIndex += pCurrentTextElement->GetTextLength();
1443 elementTextLength = textElement.GetTextLength();
1445 r = __pCompositeText->RemoveElementAt(elementIndex, deallocate);
1446 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1448 NotifyTextDeleted(textIndex, elementTextLength);
1450 if (__pCompositeText->GetElementCount() == 0 || GetTextLength() == 0)
1452 __pTextColumn->RemoveAllLines();
1459 TextObject::GetElementAtTextIndex(int textIndex) const
1461 IF_NOT_CONSTRUCTED(return null);
1463 TextElement* pTextElement = null;
1464 int elementTextLength = 0;
1465 int textIndexFromElementOffset = 0;
1466 int elementIndex = 0;
1467 int elementOffset = 0;
1469 pTextElement = __pCompositeText->GetElementAtTextIndex(textIndex, elementOffset, elementIndex, elementTextLength,textIndexFromElementOffset);
1470 SysTryCatch(NID_GRP, pTextElement, , E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
1472 SetLastResult(E_SUCCESS);
1473 return pTextElement;
1482 TextObject::SetFont(Font* pFont, int startTextIndex, int textLength)
1484 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1486 SysTryReturn(NID_GRP, pFont, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. pFont is null.");
1487 SysTryReturn(NID_GRP, startTextIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1489 result r = E_SUCCESS;
1490 Font* pTmpFont = null;
1492 pTmpFont = _FontImpl::CloneN(const_cast < Font& >(*pFont));
1493 r = GetLastResult();
1494 SysTryReturn(NID_GRP, pTmpFont, r, r, "[%s] Propagating.", GetErrorMessage(r));
1496 Release(__pDefaultFont);
1498 __pDefaultFont = pTmpFont;
1500 __pCompositeText->SetRange(startTextIndex, textLength);
1501 r = __pCompositeText->SetFont(__pDefaultFont);
1502 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1504 UpdateChangedInfo(__pCompositeText->GetWorkStart(), 0);
1510 TextObject::GetFont(int textIndex) const
1512 IF_NOT_CONSTRUCTED(return null);
1514 Font* pFont = __pCompositeText->GetFont(textIndex);
1517 pFont = __pDefaultFont;
1520 SetLastResult(E_SUCCESS);
1525 TextObject::SetDefaultFontSize(int size)
1527 return SetDefaultFontSize(_CoordinateSystemUtils::ConvertToFloat(size));
1531 TextObject::SetDefaultFontSize(float size)
1533 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1535 _FontImpl::GetInstance(*__pDefaultFont)->SetSize(size);
1541 TextObject::GetDefaultFontSize(void) const
1543 return _CoordinateSystemUtils::ConvertToInteger(GetDefaultFontSizeF());
1547 TextObject::GetDefaultFontSizeF(void) const
1549 IF_NOT_CONSTRUCTED(return -1);
1551 return _FontImpl::GetInstance(*__pDefaultFont)->GetSizeF();
1555 TextObject::SetFontSize(int size, int startTextIndex, int textLength)
1557 return SetFontSize(_CoordinateSystemUtils::ConvertToFloat(size), startTextIndex, textLength);
1561 TextObject::SetFontSize(float size, int startTextIndex, int textLength)
1563 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1565 SysTryReturn(NID_GRP
1566 , startTextIndex >= 0
1567 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1569 __pCompositeText->SetRange(startTextIndex, textLength);
1570 __pCompositeText->SetFontSize(size);
1571 UpdateChangedInfo(0, 0);
1577 TextObject::GetFontSize(int textIndex) const
1579 return _CoordinateSystemUtils::ConvertToInteger(GetFontSizeF(textIndex));
1583 TextObject::GetFontSizeF(int textIndex) const
1585 IF_NOT_CONSTRUCTED(return -1);
1587 SysTryReturn(NID_GRP
1589 , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1591 return __pCompositeText->GetFontSizeF(textIndex);
1595 TextObject::SetDefaultFontStyle(int style)
1597 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1599 _FontImpl::GetInstance(*__pDefaultFont)->SetStyle(style);
1605 TextObject::GetDefaultFontStyle(void) const
1607 IF_NOT_CONSTRUCTED(return FONT_STYLE_MIN);
1609 return _FontImpl::GetInstance(*__pDefaultFont)->GetStyle();
1613 TextObject::SetFontStyle(int style, int startTextIndex, int textLength)
1615 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1617 SysTryReturn(NID_GRP
1618 , startTextIndex >= 0
1619 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1621 __pCompositeText->SetRange(startTextIndex, textLength);
1622 __pCompositeText->SetFontStyle(style);
1623 UpdateChangedInfo(0, 0);
1629 TextObject::GetFontStyle(int textIndex) const
1631 IF_NOT_CONSTRUCTED(return -1);
1633 SysTryReturn(NID_GRP
1635 , FONT_STYLE_MIN, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1637 return __pCompositeText->GetFontStyle(textIndex);
1641 TextObject::SetDefaultForegroundColor(const Color& color)
1643 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1645 __defaultForegroundColor = color;
1651 TextObject::GetDefaultForegroundColor(void) const
1653 IF_NOT_CONSTRUCTED(return Color::GetColor(COLOR_ID_BLACK));
1655 return __defaultForegroundColor;
1659 TextObject::SetForegroundColor(const Color& color, int startTextIndex, int textLength)
1661 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1663 SysTryReturn(NID_GRP, startTextIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1665 __defaultForegroundColor = color;
1667 __pCompositeText->SetRange(startTextIndex, textLength);
1668 __pCompositeText->SetForegroundColor(color);
1674 TextObject::GetForegroundColor(int textIndex) const
1676 IF_NOT_CONSTRUCTED(return Color::GetColor(COLOR_ID_BLACK));
1678 SysTryReturn(NID_GRP, textIndex >= 0, __defaultForegroundColor, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1680 return __pCompositeText->GetForegroundColor(textIndex);
1684 TextObject::SetBackgroundColor(const Color& color, int startTextIndex, int textLength)
1686 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1688 SysTryReturn(NID_GRP, startTextIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1690 __defaultBackgroundColor = color;
1692 __pCompositeText->SetRange(startTextIndex, textLength);
1693 __pCompositeText->SetBackgroundColor(color);
1699 TextObject::GetBackgroundColor(int textIndex) const
1701 IF_NOT_CONSTRUCTED(return Color::GetColor(COLOR_ID_BLACK));
1703 SysTryReturn(NID_GRP, textIndex >= 0, __defaultBackgroundColor, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1705 return __pCompositeText->GetBackgroundColor(textIndex);
1709 TextObject::SetOutlineColor(const Color& color, int startTextIndex, int textLength)
1711 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1713 SysTryReturn(NID_GRP, startTextIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1715 __defaultOutlineColor = color;
1717 __pCompositeText->SetRange(startTextIndex, textLength);
1718 __pCompositeText->SetOutlineColor(color);
1724 TextObject::GetOutlineColor(int textIndex) const
1726 IF_NOT_CONSTRUCTED(return Color::GetColor(COLOR_ID_BLACK));
1728 SysTryReturn(NID_GRP, textIndex >= 0, __defaultOutlineColor, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1730 return __pCompositeText->GetOutlineColor(textIndex);
1734 TextObject::SetBlockColor(const Color& color)
1736 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1738 __pCompositeText->SetBlockColor(color);
1744 TextObject::GetBlockColor(void) const
1746 IF_NOT_CONSTRUCTED(return Color::GetColor(COLOR_ID_BLACK));
1748 return __pCompositeText->GetBlockColor();
1752 TextObject::SetDisplayBitmap(const Bitmap* pBitmap, int startTextIndex, int textLength)
1754 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1756 SysTryReturn(NID_GRP, startTextIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1758 __pCompositeText->SetRange(startTextIndex, textLength);
1759 __pCompositeText->SetDisplayBitmap(pBitmap);
1760 UpdateChangedInfo(0, 0);
1766 TextObject::GetDisplayBitmap(int textIndex) const
1768 IF_NOT_CONSTRUCTED(return null);
1770 return __pCompositeText->GetDisplayBitmap(textIndex);
1774 TextObject::SetWrap(TextObjectWrapType wrap)
1776 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1783 result r = __pCompositeText->SetWrap(wrap);
1784 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1787 UpdateChangedInfo(0, 0);
1793 TextObject::InsertElementAt(int textIndex, Bitmap& bitmap, TextElementSourceType sourceType)
1795 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1797 TextImage* pImageText = new (std::nothrow)TextImage(bitmap, sourceType, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP));
1798 SysTryReturn(NID_GRP, pImageText, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1800 int addedTextLength = pImageText->GetTextLength();
1801 __pCompositeText->InsertElementAt(*pImageText, textIndex);
1802 int startTextIndex = __pCompositeText->GetWorkStart();
1803 NotifyTextAdded(startTextIndex, addedTextLength);
1809 TextObject::AppendElement(Bitmap& bitmap, TextElementSourceType sourceType)
1811 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1813 result r = E_SUCCESS;
1814 TextImage* pImageText = new (std::nothrow)TextImage(bitmap, sourceType, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP));
1815 SysTryReturn(NID_GRP, pImageText, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1817 r = __pCompositeText->AppendElement(*pImageText);
1818 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1820 int startTextIndex = __pCompositeText->GetWorkStart();
1821 int elementTextLength = pImageText->GetTextLength();
1823 NotifyTextAdded(startTextIndex, elementTextLength);
1829 TextObject::SetAlternateLookEnabled(bool enable)
1831 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1833 TextElement* pTextElement = null;
1835 __isAlternateLookEnabled = enable;
1836 int elementCount = __pCompositeText->GetElementCount();
1838 for (int i = 0; i < elementCount; i++)
1840 pTextElement = __pCompositeText->GetElementAtElementIndex(i);
1841 if (pTextElement != null)
1843 pTextElement->SetAlternateLookEnabled(enable);
1851 TextObject::SetAlternativeForegroundColor(const Color& color)
1853 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1855 TextElement* pTextElement = null;
1856 int elementCount = __pCompositeText->GetElementCount();
1858 for (int i = 0; i < elementCount; i++)
1860 pTextElement = __pCompositeText->GetElementAtElementIndex(i);
1861 SysTryReturn(NID_GRP, pTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
1863 pTextElement->SetAlternativeForegroundColor(color);
1870 TextObject::ChangeTextOffset(wchar_t* pText, int textIndex, int gap)
1872 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1874 result r = E_SUCCESS;
1875 int elementStartTextIndex = 0;
1876 int elementIndex = 0;
1877 int elementTextLength = 0;
1878 int textIndexFromElementOffset = 0;
1880 TextElement* pTextElement = __pCompositeText->GetElementAtTextIndex(textIndex, elementStartTextIndex,
1881 elementIndex, elementTextLength, textIndexFromElementOffset);
1883 SysTryReturn(NID_GRP, pTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
1885 r = __pCompositeText->ChangeTextOffset(pText, elementIndex, gap);
1886 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1892 TextObject::NotifyTextChanged(wchar_t* pText, int textOffset, int textLength, int gap)
1894 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1896 result r = E_SUCCESS;
1897 int startTextIndex = __pCompositeText->GetWorkStart();
1898 r = __pCompositeText->NotifyTextChanged(pText, textOffset, textLength, gap, __pDefaultFont,
1899 __defaultForegroundColor, __defaultBackgroundColor, __defaultOutlineColor);
1901 SysTryCatch(NID_GRP, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Fail to update change information.");
1903 if (__wrap != TEXT_OBJECT_WRAP_TYPE_NONE)
1907 NotifyTextAdded(startTextIndex, gap);
1910 InputText(startTextIndex);
1915 NotifyTextDeleted(startTextIndex, -gap);
1919 RemoveText(startTextIndex);
1924 UpdateChangedInfo(startTextIndex, 0);
1926 ChangeText(startTextIndex);
1931 UpdateChangedInfo(startTextIndex, 0);
1937 if (__pCompositeText->GetElementCount() == 0)
1940 TextSimple* pSimpleText = new (std::nothrow)TextSimple(pText, textLength, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1941 AppendElement(*pSimpleText);
1944 UpdateChangedInfo(0, 0);
1951 TextObject::GetTextIndexFromPosition(int x, int y, bool cursorMode) const
1953 return GetTextIndexFromPosition(_CoordinateSystemUtils::ConvertToFloat(x), _CoordinateSystemUtils::ConvertToFloat(y), cursorMode);
1957 TextObject::GetTextIndexFromPosition(float x, float y, bool cursorMode) const
1959 IF_NOT_CONSTRUCTED(return -1);
1961 int lineCount = __pTextColumn->GetTotalLineCount();
1967 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
1969 return GetTextIndexFromPositionInNoneWrap(x, y, !cursorMode);
1973 return GetTextIndexFromPositionInWrap(x, y, !cursorMode);
1978 TextObject::GetTextIndexFromPosition(float x, float y, int& row, int& column, bool cursorMode) const
1980 IF_NOT_CONSTRUCTED(return -1);
1982 int lineCount = __pTextColumn->GetTotalLineCount();
1988 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
1990 return GetTextIndexFromPositionInNoneWrap(x, y, row, column, !cursorMode);
1994 return GetTextIndexFromPositionInWrap(x, y, row, column, !cursorMode);
1999 TextObject::GetTextIndexFromPositionAtLine(int lineIndex, int x, bool cursorMode) const
2001 return GetTextIndexFromPositionAtLine(lineIndex, _CoordinateSystemUtils::ConvertToFloat(x), cursorMode);
2005 TextObject::GetTextIndexFromPositionAtLine(int lineIndex, float x, bool cursorMode) const
2007 IF_NOT_CONSTRUCTED(return -1);
2009 SysTryReturn(NID_GRP, lineIndex >= 0, -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
2011 TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex);
2012 SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2014 int lineOffset = pTextLine->GetTextOffset();
2015 int lineLength = pTextLine->GetTextLength();
2017 TextElementType objectType;
2018 FloatRectangle lineBounds = pTextLine->GetBoundsF();
2019 FloatDimension lineTextSize;
2020 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
2022 switch (__align & TEXT_ALIGNMASK_HORIZ)
2024 case TEXT_OBJECT_ALIGNMENT_LEFT:
2027 case TEXT_OBJECT_ALIGNMENT_CENTER:
2028 x -= (lineBounds.width - lineTextSize.width) / 2.0f;
2031 case TEXT_OBJECT_ALIGNMENT_RIGHT:
2032 x -= (lineBounds.width - lineTextSize.width);
2036 x = (x < 0.0f) ? 0.0f : x;
2037 __pCompositeText->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
2043 __pCompositeText->ForwardAnalyzeWithFocusedObjectType(lineOffset, lineLength, x, length, objectType);
2047 endType = __pCompositeText->ForwardAnalyzeInNoneCursorMode(lineOffset, lineLength, x, length);
2050 __pCompositeText->SetWrap(__wrap);
2060 int index = pTextLine->GetTextOffset() + length;
2061 if (pTextLine->GetEndType() == TEXT_RETBY_LINEFEED && lineLength == length && pTextLine->GetTextOffset() < index)
2066 if (index != GetTextLength() && index == lineOffset + lineLength)
2068 TextElement* pTextElement = GetElementAtTextIndex(index-1);
2069 if (pTextElement != null)
2071 const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pTextElement);
2072 if (pSimpleText != null)
2074 const wchar_t* pText = pSimpleText->GetText();
2075 SysTryReturn(NID_GRP, pText, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text.");
2077 int i = index - 1 - pSimpleText->GetTextOffset();
2078 SysTryReturn(NID_GRP, i >= 0 && i < pSimpleText->GetTextLength(), -1, E_OUT_OF_RANGE
2079 , "[E_OUT_OF_RANGE] text index(%d) must greater than 0 and must be less than total string length(%d)",i, pSimpleText->GetTextLength());
2081 if (pText[i] == L' ' || pText[i] == TEXT_JAPANESE_SPACE)
2089 SetLastResult(E_SUCCESS);
2095 TextObject::SetFirstDisplayLineIndexFromTextIndex(int textIndex)
2097 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2099 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
2101 return SetFirstDisplayLineIndexFromTextIndexInNoneWrap(textIndex);
2105 return SetFirstDisplayLineIndexFromTextIndexInWrap(textIndex);
2110 TextObject::SetCutLinkViewMode(bool enable)
2112 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2114 if (__linkViewModeEnabled == enable)
2119 __linkViewModeEnabled = enable;
2124 TextObject::GetCutLinkIndexFromPositionData(int x, int y) const
2126 return GetCutLinkIndexFromPositionData(_CoordinateSystemUtils::ConvertToFloat(x), _CoordinateSystemUtils::ConvertToFloat(y));
2130 TextObject::GetCutLinkIndexFromPositionData(float x, float y) const
2132 IF_NOT_CONSTRUCTED(return -1);
2134 result r = E_SUCCESS;
2136 TextBidiHint bidiHint = _GetTextBidiHint();
2137 _SetTextBidiHint(__bidiHint);
2139 int lineCount = __pTextColumn->GetTotalLineCount();
2147 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
2149 textIndex = GetTextIndexFromPositionInNoneWrap(x, y, false);
2153 textIndex = GetTextIndexFromPositionInWrap(x, y, false);
2162 float height = 0.0f;
2163 FloatPoint absPoint;
2164 FloatPoint relPoint;
2166 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
2168 r = GetTextPositionInfoInNoneWrapAt(textIndex, width, height, absPoint.x, absPoint.y, relPoint.x, relPoint.y);
2172 r = GetTextPositionInfoInWrapAt(textIndex, width, height, absPoint.x, absPoint.y, relPoint.x, relPoint.y);
2174 SysTryReturn(NID_GRP, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
2175 SysTryReturn(NID_GRP, y + __rect.y >= relPoint.y, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text position information");
2177 int elementIndex = __pCompositeText->GetCutLinkElementIndexAt(textIndex);
2179 _SetTextBidiHint(bidiHint);
2181 return elementIndex;
2185 TextObject::GetCutLinkElementAtCutLinkElementIndex(int linkIndex) const
2187 IF_NOT_CONSTRUCTED(return null);
2189 return __pCompositeText->GetCutLinkElementAtCutLinkElementIndex(linkIndex);
2193 TextObject::SetCutLinkColor(LinkType linkType, const Color& color, const Color& colorInSelect)
2195 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2197 SysTryReturn(NID_GRP, LINK_TYPE_NONE < linkType && linkType < LINK_TYPE_MAX, E_INVALID_ARG, E_INVALID_ARG
2198 , "[E_INVALID_ARG] The argument is invalid.");
2203 __isUrlLinkColorDefined = true;
2204 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_NORMAL] = color;
2205 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_SELECT] = colorInSelect;
2208 case LINK_TYPE_EMAIL:
2209 __isEmailLinkColorDefined = true;
2210 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_NORMAL] = color;
2211 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_SELECT] = colorInSelect;
2214 case LINK_TYPE_TEL_NUM:
2215 __isPhoneNumberLinkColorDefined = true;
2216 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_NORMAL] = color;
2217 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_SELECT] = colorInSelect;
2224 int totalCutlinkTextCount = __pCompositeText->GetCutLinkElementCount();
2225 for (int i = 0; i < totalCutlinkTextCount; i++)
2227 TextCutLink* pCutlinkText = dynamic_cast < TextCutLink* >(__pCompositeText->GetCutLinkElementAtCutLinkElementIndex(i));
2228 SysTryReturn(NID_GRP, pCutlinkText, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to convert to cutlink element.");
2230 if (pCutlinkText->GetCutLinkType() == linkType)
2232 pCutlinkText->SetUserColor(color, colorInSelect);
2240 TextObject::ResetCutLinkColor(LinkType linkType)
2242 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2244 SysTryReturn(NID_GRP, LINK_TYPE_NONE < linkType && linkType < LINK_TYPE_MAX, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
2249 __isUrlLinkColorDefined = false;
2252 case LINK_TYPE_EMAIL:
2253 __isEmailLinkColorDefined = false;
2256 case LINK_TYPE_TEL_NUM:
2257 __isPhoneNumberLinkColorDefined = false;
2264 int totalCutlinkTextCount = __pCompositeText->GetCutLinkElementCount();
2265 for (int i = 0; i < totalCutlinkTextCount; i++)
2267 TextCutLink* pCutlinkText = dynamic_cast < TextCutLink* >(__pCompositeText->GetCutLinkElementAtCutLinkElementIndex(i));
2268 SysTryReturn(NID_GRP, pCutlinkText, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to convert to cutlink element.");
2270 if (pCutlinkText->GetCutLinkType() == linkType)
2272 pCutlinkText->ResetUserColor();
2280 TextObject::GetCutLinkBounds(int cutLinkIndex, Point& startPoint, Point& endPoint) const
2282 FloatPoint startPointF = _CoordinateSystemUtils::ConvertToFloat(startPoint);
2283 FloatPoint endPointF = _CoordinateSystemUtils::ConvertToFloat(endPoint);
2285 result r = GetCutLinkBounds(cutLinkIndex, startPointF, endPointF);
2286 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2288 startPoint = _CoordinateSystemUtils::ConvertToInteger(startPointF);
2289 endPoint = _CoordinateSystemUtils::ConvertToInteger(endPointF);
2295 TextObject::GetCutLinkBounds(int cutLinkIndex, FloatPoint& startPoint, FloatPoint& endPoint) const
2297 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2299 result r = E_SUCCESS;
2303 float heigth = 0.0f;
2304 FloatPoint tempPoint;
2306 r = __pCompositeText->GetCutLinkObjectInfo(cutLinkIndex, textIndex, textLength);
2307 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2309 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
2311 r = GetTextPositionInfoInNoneWrapAt(textIndex, width, heigth, tempPoint.x, tempPoint.y, startPoint.x, startPoint.y);
2312 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2314 r = GetTextPositionInfoInNoneWrapAt(textIndex + textLength - 1, width, heigth, tempPoint.x, tempPoint.y, endPoint.x, endPoint.y);
2315 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2319 r = GetTextPositionInfoInWrapAt(textIndex, width, heigth, tempPoint.x, tempPoint.y, startPoint.x, startPoint.y);
2320 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2322 r = GetTextPositionInfoInWrapAt(textIndex + textLength - 1, width, heigth, tempPoint.x, tempPoint.y, endPoint.x, endPoint.y);
2323 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2326 endPoint.x = endPoint.x + width;
2327 endPoint.y = endPoint.y + heigth;
2341 TextObject::GetTextPositionInfoAt(int textIndex, int& width, int& height, int& absX, int& absY, int& logicalX, int& logicalY) const
2343 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2345 float widthF = _CoordinateSystemUtils::ConvertToFloat(width);
2346 float heightF = _CoordinateSystemUtils::ConvertToFloat(height);
2347 float absXF = _CoordinateSystemUtils::ConvertToFloat(absX);
2348 float absYF = _CoordinateSystemUtils::ConvertToFloat(absY);
2349 float logicalXF = _CoordinateSystemUtils::ConvertToFloat(logicalX);
2350 float logicalYF = _CoordinateSystemUtils::ConvertToFloat(logicalY);
2352 result r = GetTextPositionInfoAt(textIndex, widthF, heightF, absXF, absYF, logicalXF, logicalYF);
2353 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2355 width = _CoordinateSystemUtils::ConvertToInteger(widthF);
2356 height = _CoordinateSystemUtils::ConvertToInteger(heightF);
2357 absX = _CoordinateSystemUtils::ConvertToInteger(absXF);
2358 absY = _CoordinateSystemUtils::ConvertToInteger(absYF);
2359 logicalX = _CoordinateSystemUtils::ConvertToInteger(logicalXF);
2360 logicalY = _CoordinateSystemUtils::ConvertToInteger(logicalYF);
2366 TextObject::GetTextPositionInfoAt(int textIndex, float& width, float& height, float& absX, float& absY, float& logicalX, float& logicalY) const
2368 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2370 result r = E_SUCCESS;
2371 TextBidiHint bidiHint = _GetTextBidiHint();
2372 _SetTextBidiHint(__bidiHint);
2374 int lineCount = __pTextColumn->GetTotalLineCount();
2378 _FontImpl* pFont = _FontImpl::GetInstance(*__pDefaultFont);
2379 SysTryReturn(NID_GRP, pFont, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
2381 float maxHeight = TextUtility::GetFontMaxHeightF(pFont);
2387 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
2389 switch (__align & TEXT_ALIGNMASK_VERT)
2391 case TEXT_OBJECT_ALIGNMENT_TOP:
2394 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
2395 posY += (__rect.height - maxHeight) / 2.0f;
2398 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
2399 posY += (__rect.height - maxHeight);
2402 logicalY = __rect.y + posY;
2404 switch (__align & TEXT_ALIGNMASK_HORIZ)
2406 case TEXT_OBJECT_ALIGNMENT_LEFT:
2409 case TEXT_OBJECT_ALIGNMENT_CENTER:
2410 posX += __rect.width / 2.0f;
2413 case TEXT_OBJECT_ALIGNMENT_RIGHT:
2414 posX += __rect.width;
2417 logicalX = __rect.x + posX;
2421 float lineHeight = maxHeight + __pCompositeText->GetLineSpaceF();
2422 TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment();
2423 switch (alignment & TEXT_ALIGNMASK_VERT)
2425 case TEXT_OBJECT_ALIGNMENT_TOP:
2430 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
2431 posY += (lineHeight - maxHeight) / 2.0f;
2434 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
2435 posY += lineHeight - maxHeight;
2439 switch (__align & TEXT_ALIGNMASK_HORIZ)
2441 case TEXT_OBJECT_ALIGNMENT_LEFT:
2444 case TEXT_OBJECT_ALIGNMENT_CENTER:
2445 posX += __rect.width / 2.0f;
2448 case TEXT_OBJECT_ALIGNMENT_RIGHT:
2449 posX += __rect.width;
2453 logicalX = posX + __rect.x;
2454 logicalY = posY + __rect.y;
2464 r = (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE) ? GetTextPositionInfoInNoneWrapAt(textIndex, width, height, absX, absY, logicalX, logicalY)
2465 : GetTextPositionInfoInWrapAt(textIndex, width, height, absX, absY, logicalX, logicalY);
2466 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2469 _SetTextBidiHint(bidiHint);
2475 TextObject::GetTextPositionInfoAt(int row, int column, float& width, float& height, float& absX, float& absY, float& logicalX, float& logicalY) const
2477 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2479 result r = E_SUCCESS;
2480 TextBidiHint bidiHint = _GetTextBidiHint();
2481 _SetTextBidiHint(__bidiHint);
2483 int lineCount = __pTextColumn->GetTotalLineCount();
2487 _FontImpl* pFont = _FontImpl::GetInstance(*__pDefaultFont);
2488 SysTryReturn(NID_GRP, pFont, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
2490 float maxHeight = TextUtility::GetFontMaxHeightF(pFont);
2496 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
2498 switch (__align & TEXT_ALIGNMASK_VERT)
2500 case TEXT_OBJECT_ALIGNMENT_TOP:
2503 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
2504 posY += (__rect.height - maxHeight) / 2.0f;
2507 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
2508 posY += (__rect.height - maxHeight);
2511 logicalY = __rect.y + posY;
2513 switch (__align & TEXT_ALIGNMASK_HORIZ)
2515 case TEXT_OBJECT_ALIGNMENT_LEFT:
2518 case TEXT_OBJECT_ALIGNMENT_CENTER:
2519 posX += __rect.width / 2.0f;
2522 case TEXT_OBJECT_ALIGNMENT_RIGHT:
2523 posX += __rect.width;
2526 logicalX = __rect.x + posX;
2530 float lineHeight = maxHeight + __pCompositeText->GetLineSpaceF();
2531 TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment();
2532 switch (alignment & TEXT_ALIGNMASK_VERT)
2534 case TEXT_OBJECT_ALIGNMENT_TOP:
2539 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
2540 posY += (lineHeight - maxHeight) / 2.0f;
2543 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
2544 posY += lineHeight - maxHeight;
2548 switch (__align & TEXT_ALIGNMASK_HORIZ)
2550 case TEXT_OBJECT_ALIGNMENT_LEFT:
2553 case TEXT_OBJECT_ALIGNMENT_CENTER:
2554 posX += __rect.width / 2.0f;
2557 case TEXT_OBJECT_ALIGNMENT_RIGHT:
2558 posX += __rect.width;
2562 logicalX = posX + __rect.x;
2563 logicalY = posY + __rect.y;
2573 r = (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE) ? GetTextPositionInfoInNoneWrapAt(row, column, width, height, absX, absY, logicalX, logicalY)
2574 : GetTextPositionInfoInWrapAt(row, column, width, height, absX, absY, logicalX, logicalY);
2575 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2578 _SetTextBidiHint(bidiHint);
2584 TextObject::GetBlockTextPositionInfoAt(int textIndex, int& width, int& height, int& absX, int& absY, int& logicalX, int& logicalY) const
2586 float widthF = _CoordinateSystemUtils::ConvertToFloat(width);
2587 float heightF = _CoordinateSystemUtils::ConvertToFloat(height);
2588 float absXF = _CoordinateSystemUtils::ConvertToFloat(absX);
2589 float absYF = _CoordinateSystemUtils::ConvertToFloat(absY);
2590 float logicalXF = _CoordinateSystemUtils::ConvertToFloat(logicalX);
2591 float logicalYF = _CoordinateSystemUtils::ConvertToFloat(logicalY);
2593 result r = GetBlockTextPositionInfoAt(textIndex, widthF, heightF, absXF, absYF, logicalXF, logicalYF);
2594 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2596 width = _CoordinateSystemUtils::ConvertToInteger(widthF);
2597 height = _CoordinateSystemUtils::ConvertToInteger(heightF);
2598 absX = _CoordinateSystemUtils::ConvertToInteger(absXF);
2599 absY = _CoordinateSystemUtils::ConvertToInteger(absYF);
2600 logicalX = _CoordinateSystemUtils::ConvertToInteger(logicalXF);
2601 logicalY = _CoordinateSystemUtils::ConvertToInteger(logicalYF);
2607 TextObject::GetBlockTextPositionInfoAt(int textIndex, float& width, float& height, float& absX, float& absY, float& logicalX, float& logicalY) const
2609 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2611 result r = E_SUCCESS;
2612 TextBidiHint bidiHint = _GetTextBidiHint();
2613 _SetTextBidiHint(__bidiHint);
2615 int lineCount = __pTextColumn->GetTotalLineCount();
2619 _FontImpl* pFont =_FontImpl::GetInstance(*__pDefaultFont);
2620 SysTryReturn(NID_GRP, pFont, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
2622 float maxHeight = TextUtility::GetFontMaxHeightF(pFont);
2628 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
2630 switch (__align & TEXT_ALIGNMASK_VERT)
2632 case TEXT_OBJECT_ALIGNMENT_TOP:
2635 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
2636 posY += (__rect.height - maxHeight) / 2.0f;
2639 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
2640 posY += (__rect.height - maxHeight);
2643 logicalY = __rect.y + posY;
2645 switch (__align & TEXT_ALIGNMASK_HORIZ)
2647 case TEXT_OBJECT_ALIGNMENT_LEFT:
2650 case TEXT_OBJECT_ALIGNMENT_CENTER:
2651 posX += __rect.width / 2.0f;
2654 case TEXT_OBJECT_ALIGNMENT_RIGHT:
2655 posX += __rect.width;
2658 logicalX = __rect.x + posX;
2662 float lineHeight = maxHeight + __pCompositeText->GetLineSpace();
2663 TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment();
2664 switch (alignment & TEXT_ALIGNMASK_VERT)
2666 case TEXT_OBJECT_ALIGNMENT_TOP:
2671 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
2672 posY += (lineHeight - maxHeight) / 2.0f;
2675 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
2676 posY += lineHeight - maxHeight;
2680 logicalX = __rect.x;
2681 logicalY = posY + __rect.y;
2691 r = (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE) ? GetTextPositionInfoInNoneWrapAt(textIndex, width, height, absX, absY, logicalX, logicalY)
2692 : GetBlockTextPositionInfoInWrapAt(textIndex, width, height, absX, absY, logicalX, logicalY);
2693 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2696 _SetTextBidiHint(bidiHint);
2702 TextObject::SetTextObjectEllipsisType(TextObjectEllipsisType type)
2704 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2706 SysTryReturn(NID_GRP, TEXT_OBJECT_ELLIPSIS_TYPE_INVALID < type && type < TEXT_OBJECT_ELLIPSIS_TYPE_MAX
2707 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
2709 __textObjectEllipsisType = type;
2710 __pCompositeText->SetTextObjectEllipsisType(type);
2716 TextObject::NotifyTextAdded(int textIndex, int textLength)
2718 result r = E_SUCCESS;
2720 r = __pTextColumn->SetChangeAction(TextColumn::TEXT_CHANGE_INSERT, textIndex, textLength);
2721 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2729 TextObject::NotifyTextDeleted(int textIndex, int textLength)
2731 result r = E_SUCCESS;
2733 r = __pTextColumn->SetChangeAction(TextColumn::TEXT_CHANGE_REMOVE, textIndex, textLength);
2734 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2742 TextObject::DrawByLine(_CanvasImpl& canvasImpl, const Rectangle& displayRect)
2744 return DrawByLine(canvasImpl, _CoordinateSystemUtils::ConvertToFloat(displayRect));
2748 TextObject::DrawByLine(_CanvasImpl& canvasImpl, const FloatRectangle& displayRect)
2750 FloatRectangle targetBounds = displayRect;
2752 return __pTextColumn->Draw(canvasImpl, targetBounds, 0, __pTextColumn->GetTextLength(), __align, __action);
2756 TextObject::GetTextIndexFromPositionInWrap(int x, int y, bool cursorMode) const
2758 return GetTextIndexFromPositionInWrap(_CoordinateSystemUtils::ConvertToFloat(x), _CoordinateSystemUtils::ConvertToFloat(y), cursorMode);
2762 TextObject::GetTextIndexFromPositionInWrap(float x, float y, bool cursorMode) const
2764 TextLine* pTextLine = null;
2765 FloatRectangle lineBounds;
2766 int firstDisplayLineIndex = __pTextColumn->GetFirstDisplayLineIndex();
2767 float firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
2768 int lineCount = __pTextColumn->GetTotalLineCount();
2770 float totalHeight = __pTextColumn->GetTotalHeightF();
2772 TextBidiHint bidiHint = _GetTextBidiHint();
2773 _SetTextBidiHint(__bidiHint);
2775 switch (__align & TEXT_ALIGNMASK_VERT)
2777 case TEXT_OBJECT_ALIGNMENT_TOP:
2780 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
2781 y -= (__rect.height - totalHeight) / 2.0f;
2784 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
2785 y -= (__rect.height - totalHeight);
2789 for (lineIndex = firstDisplayLineIndex; lineIndex < lineCount; lineIndex++)
2791 pTextLine = __pTextColumn->GetTextLine(lineIndex);
2792 SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2794 lineBounds = pTextLine->GetBoundsF();
2796 if (lineIndex == firstDisplayLineIndex)
2798 if (y < lineBounds.y - firstDisplayPositionY)
2804 if ((lineBounds.y - firstDisplayPositionY <= y) && (y < lineBounds.y + lineBounds.height - firstDisplayPositionY))
2809 if (lineIndex == lineCount - 1)
2813 return pTextLine->GetTextLength() + pTextLine->GetTextOffset();
2822 SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2824 int lineLength = pTextLine->GetTextLength();
2825 Dimension lineTextSize;
2826 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
2828 switch (__align & TEXT_ALIGNMASK_HORIZ)
2830 case TEXT_OBJECT_ALIGNMENT_LEFT:
2833 case TEXT_OBJECT_ALIGNMENT_CENTER:
2834 x -= (lineBounds.width - lineTextSize.width) / 2.0f;
2837 case TEXT_OBJECT_ALIGNMENT_RIGHT:
2838 x -= (lineBounds.width - lineTextSize.width);
2847 int index = pTextLine->GetTextIndexFromPosition(x);
2849 _SetTextBidiHint(bidiHint);
2851 SetLastResult(E_SUCCESS);
2857 TextObject::GetTextIndexFromPositionInWrap(float x, float y, int& row, int& column, bool cursorMode) const
2859 TextLine* pTextLine = null;
2860 FloatRectangle lineBounds;
2861 int firstDisplayLineIndex = __pTextColumn->GetFirstDisplayLineIndex();
2862 float firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
2863 int lineCount = __pTextColumn->GetTotalLineCount();
2865 float totalHeight = __pTextColumn->GetTotalHeightF();
2867 TextBidiHint bidiHint = _GetTextBidiHint();
2868 _SetTextBidiHint(__bidiHint);
2870 switch (__align & TEXT_ALIGNMASK_VERT)
2872 case TEXT_OBJECT_ALIGNMENT_TOP:
2875 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
2876 y -= (__rect.height - totalHeight) / 2.0f;
2879 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
2880 y -= (__rect.height - totalHeight);
2884 for (lineIndex = firstDisplayLineIndex; lineIndex < lineCount; lineIndex++)
2886 pTextLine = __pTextColumn->GetTextLine(lineIndex);
2887 SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2889 lineBounds = pTextLine->GetBoundsF();
2891 if (lineIndex == firstDisplayLineIndex)
2893 if (y < lineBounds.y - firstDisplayPositionY)
2899 if ((lineBounds.y - firstDisplayPositionY <= y) && (y < lineBounds.y + lineBounds.height - firstDisplayPositionY))
2904 if (lineIndex == lineCount - 1)
2908 return pTextLine->GetTextLength() + pTextLine->GetTextOffset();
2917 SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2919 int lineLength = pTextLine->GetTextLength();
2920 Dimension lineTextSize;
2921 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
2923 switch (__align & TEXT_ALIGNMASK_HORIZ)
2925 case TEXT_OBJECT_ALIGNMENT_LEFT:
2928 case TEXT_OBJECT_ALIGNMENT_CENTER:
2929 x -= (lineBounds.width - lineTextSize.width) / 2.0f;
2932 case TEXT_OBJECT_ALIGNMENT_RIGHT:
2933 x -= (lineBounds.width - lineTextSize.width);
2942 int index = pTextLine->GetTextIndexFromPosition(x);
2943 row = pTextLine->GetIndex();
2944 column = index - pTextLine->GetTextOffset();
2946 int endType = pTextLine->GetEndType();
2947 if (endType == TEXT_RETBY_LINEFEED && column == lineLength)
2953 _SetTextBidiHint(bidiHint);
2955 SetLastResult(E_SUCCESS);
2961 TextObject::GetTextIndexFromPositionInNoneWrap(int x, int y, bool cursorMode) const
2963 return GetTextIndexFromPositionInNoneWrap(_CoordinateSystemUtils::ConvertToFloat(x), _CoordinateSystemUtils::ConvertToFloat(y), cursorMode);
2967 TextObject::GetTextIndexFromPositionInNoneWrap(float x, float y, bool cursorMode) const
2969 FloatDimension lineTextSize;
2970 FloatRectangle lineBounds;
2973 float firstDisplayPositionX = __pTextColumn->GetFirstDisplayPositionX();
2974 TextLine* pTextLine = null;
2976 pTextLine = __pTextColumn->GetTextLine(0);
2977 SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2979 TextBidiHint bidiHint = _GetTextBidiHint();
2980 _SetTextBidiHint(__bidiHint);
2982 lineOffset = pTextLine->GetTextOffset();
2983 lineLength = pTextLine->GetTextLength();
2984 lineBounds = pTextLine->GetBoundsF();
2985 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
2987 x += firstDisplayPositionX;
2989 switch (__align & TEXT_ALIGNMASK_HORIZ)
2991 case TEXT_OBJECT_ALIGNMENT_LEFT:
2994 case TEXT_OBJECT_ALIGNMENT_CENTER:
2995 x -= (lineBounds.width - lineTextSize.width) / 2.0f;
2998 case TEXT_OBJECT_ALIGNMENT_RIGHT:
2999 x -= (lineBounds.width - lineTextSize.width);
3003 switch (__align & TEXT_ALIGNMASK_VERT)
3005 case TEXT_OBJECT_ALIGNMENT_TOP:
3008 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3009 y -= (__rect.height - lineTextSize.height) / 2.0f;
3012 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3013 y -= (__rect.height - lineTextSize.height);
3022 int index = pTextLine->GetTextIndexFromPosition(x);
3024 _SetTextBidiHint(bidiHint);
3026 SetLastResult(E_SUCCESS);
3031 TextObject::GetTextIndexFromPositionInNoneWrap(float x, float y, int& row, int& column, bool cursorMode) const
3033 FloatDimension lineTextSize;
3034 FloatRectangle lineBounds;
3037 float firstDisplayPositionX = __pTextColumn->GetFirstDisplayPositionX();
3038 TextLine* pTextLine = null;
3040 pTextLine = __pTextColumn->GetTextLine(0);
3041 SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3043 TextBidiHint bidiHint = _GetTextBidiHint();
3044 _SetTextBidiHint(__bidiHint);
3046 lineOffset = pTextLine->GetTextOffset();
3047 lineLength = pTextLine->GetTextLength();
3048 lineBounds = pTextLine->GetBoundsF();
3049 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
3051 x += firstDisplayPositionX;
3053 switch (__align & TEXT_ALIGNMASK_HORIZ)
3055 case TEXT_OBJECT_ALIGNMENT_LEFT:
3058 case TEXT_OBJECT_ALIGNMENT_CENTER:
3059 x -= (lineBounds.width - lineTextSize.width) / 2.0f;
3062 case TEXT_OBJECT_ALIGNMENT_RIGHT:
3063 x -= (lineBounds.width - lineTextSize.width);
3067 switch (__align & TEXT_ALIGNMASK_VERT)
3069 case TEXT_OBJECT_ALIGNMENT_TOP:
3072 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3073 y -= (__rect.height - lineTextSize.height) / 2.0f;
3076 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3077 y -= (__rect.height - lineTextSize.height);
3086 int index = pTextLine->GetTextIndexFromPosition(x);
3090 _SetTextBidiHint(bidiHint);
3092 SetLastResult(E_SUCCESS);
3097 TextObject::SetFirstDisplayLineIndexFromTextIndexInWrap(int textIndex)
3099 result r = E_SUCCESS;
3100 FloatRectangle lineBounds;
3101 float firstDisplayPositionY = 0.0f;
3102 int currentTextIndex = textIndex;
3103 int firstDisplayLineIndex = 0;
3106 float remainingHeight = 0.0f;
3107 TextLine* pTextLine = null;
3108 bool isChanged = false;
3110 lineCount = __pTextColumn->GetTotalLineCount();
3111 lineIndex = __pTextColumn->GetLineIndexAtTextIndex(currentTextIndex);
3112 firstDisplayLineIndex = __pTextColumn->GetFirstDisplayLineIndex();
3114 if (lineIndex == -1 && 0 < currentTextIndex && currentTextIndex == __pCompositeText->GetTextLength())
3117 lineIndex = __pTextColumn->GetLineIndexAtTextIndex(currentTextIndex);
3120 pTextLine = __pTextColumn->GetTextLine(lineIndex);
3121 SysTryReturn(NID_GRP, pTextLine, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3123 lineBounds = pTextLine->GetBoundsF();
3125 if (firstDisplayLineIndex < lineIndex)
3127 TextLine* pTextLine = null;
3128 int currentLineIndex = 0;
3129 int displayLineCount = 0;
3131 currentLineIndex = firstDisplayLineIndex;
3132 pTextLine = __pTextColumn->GetTextLine(currentLineIndex);
3133 SysTryReturn(NID_GRP, pTextLine, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3135 remainingHeight = __rect.height;
3137 while ((remainingHeight != 0.0f) && firstDisplayLineIndex < lineCount)
3139 if (remainingHeight < 0.0f)
3144 lineBounds = pTextLine->GetBoundsF();
3146 remainingHeight -= lineBounds.height;
3150 pTextLine = __pTextColumn->GetTextLine(currentLineIndex);
3151 if (pTextLine == null)
3157 if (lineIndex < firstDisplayLineIndex + displayLineCount)
3159 if (0.0f < remainingHeight && 0 < firstDisplayLineIndex)
3161 pTextLine = __pTextColumn->GetTextLine(firstDisplayLineIndex - 1);
3162 SysTryReturn(NID_GRP, pTextLine, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3164 while (remainingHeight && pTextLine)
3166 lineBounds = pTextLine->GetBoundsF();
3167 remainingHeight -= lineBounds.height;
3169 if (remainingHeight < 0.0f)
3171 firstDisplayPositionY = lineBounds.y + remainingHeight;
3173 firstDisplayLineIndex--;
3178 firstDisplayPositionY = lineBounds.y;
3182 firstDisplayLineIndex--;
3184 pTextLine = __pTextColumn->GetTextLine(firstDisplayLineIndex - 1);
3189 else if (remainingHeight < 0.0f && (lineIndex == firstDisplayLineIndex + displayLineCount - 1))
3191 pTextLine = __pTextColumn->GetTextLine(lineIndex);
3192 SysTryReturn(NID_GRP, pTextLine, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3194 lineBounds = pTextLine->GetBoundsF();
3195 remainingHeight = __rect.height;
3197 firstDisplayLineIndex = lineIndex;
3198 firstDisplayPositionY = lineBounds.y;
3199 remainingHeight -= lineBounds.height;
3201 int currentLineIndex = lineIndex - 1;
3202 pTextLine = __pTextColumn->GetTextLine(currentLineIndex);
3204 while ((pTextLine != null) && 0 < firstDisplayLineIndex && 0.0f < remainingHeight)
3206 lineBounds = pTextLine->GetBoundsF();
3208 if (remainingHeight < lineBounds.height)
3210 firstDisplayLineIndex--;
3211 firstDisplayPositionY = lineBounds.y + (lineBounds.height - remainingHeight);
3216 remainingHeight -= lineBounds.height;
3217 firstDisplayLineIndex--;
3218 firstDisplayPositionY = lineBounds.y;
3220 pTextLine = __pTextColumn->GetTextLine(currentLineIndex);
3228 pTextLine = __pTextColumn->GetTextLine(lineIndex);
3229 SysTryReturn(NID_GRP, pTextLine, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3231 lineBounds = pTextLine->GetBoundsF();
3233 remainingHeight = __rect.height;
3235 firstDisplayLineIndex = lineIndex;
3236 firstDisplayPositionY = lineBounds.y;
3237 remainingHeight -= lineBounds.height;
3239 int currentLineIndex = lineIndex - 1;
3240 pTextLine = __pTextColumn->GetTextLine(currentLineIndex);
3242 while (pTextLine && 0 < firstDisplayLineIndex && 0.0f < remainingHeight)
3244 lineBounds = pTextLine->GetBoundsF();
3246 if (remainingHeight < lineBounds.height)
3248 firstDisplayLineIndex--;
3249 firstDisplayPositionY = lineBounds.y + (lineBounds.height - remainingHeight);
3254 remainingHeight -= lineBounds.height;
3255 firstDisplayLineIndex--;
3256 firstDisplayPositionY = lineBounds.y;
3258 pTextLine = __pTextColumn->GetTextLine(currentLineIndex);
3266 lineBounds = pTextLine->GetBoundsF();
3267 firstDisplayLineIndex = lineIndex;
3268 firstDisplayPositionY = lineBounds.y;
3272 if (isChanged == true)
3274 __pTextColumn->SetFirstDisplayLineIndex(firstDisplayLineIndex);
3275 __pTextColumn->SetFirstDisplayPositionY(firstDisplayPositionY);
3282 TextObject::SetFirstDisplayLineIndexFromTextIndexInNoneWrap(int textIndex)
3285 int lineEndIndex = 0;
3288 float firstDisplayPositionX = __pTextColumn->GetFirstDisplayPositionX();
3289 FloatRectangle lineBounds;
3290 FloatDimension lineTextSize;
3291 FloatDimension currentLinetextSize;
3292 FloatDimension prevTextSize;
3294 _FontImpl* pFont = _FontImpl::GetInstance(*__pDefaultFont);
3295 SysTryReturn(NID_GRP, pFont, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
3297 TextLine* pTextLine = __pTextColumn->GetTextLine(0);
3298 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3300 lineOffset = pTextLine->GetTextOffset();
3301 lineLength = pTextLine->GetTextLength();
3302 lineEndIndex = pTextLine->GetTextOffset() + pTextLine->GetTextLength();
3303 lineBounds = pTextLine->GetBoundsF();
3305 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
3307 __pCompositeText->ForwardAnalyze(lineOffset, textIndex, lineBounds.width, __wrap, count, currentLinetextSize.width, currentLinetextSize.height);
3311 __pCompositeText->ForwardAnalyze(lineOffset, textIndex - 1, lineBounds.width,__wrap, count, prevTextSize.width, prevTextSize.height);
3314 if (prevTextSize.width < firstDisplayPositionX)
3316 SetFirstDisplayPositionX(prevTextSize.width);
3318 pTextLine->SetBounds(lineBounds);
3319 pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
3320 pTextLine->SetTextLength(lineLength);
3321 __pCompositeText->GetTextExtentList(pTextLine);
3323 else if (firstDisplayPositionX + __rect.width <= currentLinetextSize.width) // 글자가 display 영역 뒤로 계속 쓸 때
3325 float tempWidth = 0.0f;
3326 float tempHeight = 0.0f;
3329 __pCompositeText->ForwardAnalyze(0, textIndex, lineBounds.width, __wrap, textCount, tempWidth, tempHeight);
3330 SetFirstDisplayPositionX(tempWidth - __rect.width);
3332 pTextLine->SetBounds(lineBounds);
3333 pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
3334 pTextLine->SetTextOffset(0);
3335 pTextLine->SetTextLength(lineLength);
3336 __pCompositeText->GetTextExtentList(pTextLine);
3338 else if (lineBounds.width < firstDisplayPositionX + __rect.width && lineLength <= textIndex) // 글 꽉 채운 후 한글자씩 지울 때
3340 float tempWidth = 0.0f;
3341 float tempHeight = 0.0f;
3344 __pCompositeText->ForwardAnalyze(0, textIndex, lineBounds.width, __wrap, textCount, tempWidth, tempHeight);
3345 SetFirstDisplayPositionX(tempWidth - __rect.width);
3347 pTextLine->SetBounds(lineBounds);
3348 pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
3349 pTextLine->SetTextOffset(0);
3350 pTextLine->SetTextLength(lineLength);
3351 __pCompositeText->GetTextExtentList(pTextLine);
3353 else if (lineBounds.width < firstDisplayPositionX + __rect.width) // 글 꽉 채운 후에, 중간에 글자를 지울 때,
3355 float tempWidth = 0.0f;
3356 float tempHeight = 0.0f;
3359 float gap = __rect.width - (lineBounds.width - currentLinetextSize.width);
3361 __pCompositeText->ForwardAnalyze(0, textIndex, lineBounds.width, __wrap, textCount, tempWidth, tempHeight);
3362 SetFirstDisplayPositionX(tempWidth - gap);
3364 pTextLine->SetBounds(lineBounds);
3365 pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
3366 pTextLine->SetTextOffset(0);
3367 pTextLine->SetTextLength(lineLength);
3368 __pCompositeText->GetTextExtentList(pTextLine);
3371 __pTextColumn->SetFirstDisplayLineIndex(0);
3372 __pTextColumn->SetFirstDisplayPositionY(0.0f);
3378 TextObject::GetTextPositionInfoInWrapAt(int textIndex, int& width, int& height, int& absX, int& absY,
3379 int& logicalX, int& logicalY) const
3381 float widthF = _CoordinateSystemUtils::ConvertToFloat(width);
3382 float heightF = _CoordinateSystemUtils::ConvertToFloat(height);
3383 float absXF = _CoordinateSystemUtils::ConvertToFloat(absX);
3384 float absYF = _CoordinateSystemUtils::ConvertToFloat(absY);
3385 float logicalXF = _CoordinateSystemUtils::ConvertToFloat(logicalX);
3386 float logicalYF = _CoordinateSystemUtils::ConvertToFloat(logicalY);
3388 result r = GetTextPositionInfoInWrapAt(textIndex, widthF, heightF, absXF, absYF, logicalXF, logicalYF);
3389 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3391 width = _CoordinateSystemUtils::ConvertToInteger(widthF);
3392 height = _CoordinateSystemUtils::ConvertToInteger(heightF);
3393 absX = _CoordinateSystemUtils::ConvertToInteger(absXF);
3394 absY = _CoordinateSystemUtils::ConvertToInteger(absYF);
3395 logicalX = _CoordinateSystemUtils::ConvertToInteger(logicalXF);
3396 logicalY = _CoordinateSystemUtils::ConvertToInteger(logicalYF);
3402 TextObject::GetTextPositionInfoInWrapAt(int textIndex, float& width, float& height, float& absX, float& absY,
3403 float& logicalX, float& logicalY) const
3405 TextLine* pTextLine = null;
3406 FloatRectangle lineBounds;
3407 float firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
3408 int lineCount = __pTextColumn->GetTotalLineCount();
3412 int textIndexFromLineOffset = 0;
3417 _FontImpl* pFont = _FontImpl::GetInstance(*__pDefaultFont);
3418 SysTryReturn(NID_GRP, pFont, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
3420 for (lineIndex = 0; lineIndex < lineCount; lineIndex++)
3422 pTextLine = __pTextColumn->GetTextLine(lineIndex);
3423 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3425 lineBounds = pTextLine->GetBoundsF();
3426 lineOffset = pTextLine->GetTextOffset();
3427 lineLength = pTextLine->GetTextLength();
3429 if (lineOffset <= textIndex && textIndex < lineOffset + lineLength)
3434 if (lineIndex + 1 < lineCount)
3436 lineY += lineBounds.height;
3440 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3442 if (lineIndex == lineCount)
3444 textIndexFromLineOffset = lineLength;
3448 textIndexFromLineOffset = textIndex - lineOffset;
3451 FloatDimension lineTextSize;
3452 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
3454 if (lineTextSize.height == 0)
3456 lineTextSize.height = TextUtility::GetFontMaxHeightF(pFont);
3459 switch (__align & TEXT_ALIGNMASK_HORIZ)
3461 case TEXT_OBJECT_ALIGNMENT_LEFT:
3464 case TEXT_OBJECT_ALIGNMENT_CENTER:
3465 posX += (lineBounds.width - lineTextSize.width) / 2.0f;
3468 case TEXT_OBJECT_ALIGNMENT_RIGHT:
3469 posX += (lineBounds.width - lineTextSize.width);
3473 switch (__align & TEXT_ALIGNMASK_VERT)
3475 case TEXT_OBJECT_ALIGNMENT_TOP:
3478 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3479 posY += (__rect.height - __pTextColumn->GetDisplayHeightF()) / 2.0f;
3482 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3483 posY += (__rect.height - __pTextColumn->GetDisplayHeightF());
3497 FloatRectangle textExtent = pTextLine->GetTextExtentF(textIndexFromLineOffset, 1);
3499 if (lineIndex == lineCount)
3501 textExtent.width = 0.0f;
3506 Font* pTextFont = __pCompositeText->GetFont(textIndex - 1);
3507 textExtent.height = TextUtility::GetFontMaxHeightF(pTextFont);
3510 if (textExtent.height < 0.0f)
3512 textExtent.height = TextUtility::GetFontMaxHeightF(pFont);
3515 TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment();
3516 switch (alignment & TEXT_ALIGNMASK_VERT)
3518 case TEXT_OBJECT_ALIGNMENT_TOP:
3523 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3524 lineY = lineY + (lineBounds.height - textExtent.height) / 2.0f;
3527 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3528 lineY = lineY + (lineBounds.height - textExtent.height);
3532 width = textExtent.width;
3533 height = textExtent.height;
3534 absX = posX + textExtent.x;
3535 logicalX = absX + __rect.x;
3537 logicalY = absY - firstDisplayPositionY + __rect.y + posY;
3543 TextObject::GetTextPositionInfoInWrapAt(int row, int column, float& width, float& height, float& absX, float& absY,
3544 float& logicalX, float& logicalY) const
3546 TextLine* pTextLine = null;
3547 float firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
3548 int lineCount = __pTextColumn->GetTotalLineCount();
3552 _FontImpl* pFont = _FontImpl::GetInstance(*__pDefaultFont);
3553 SysTryReturn(NID_GRP, pFont, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
3555 pTextLine = __pTextColumn->GetTextLine(row);
3556 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3558 FloatRectangle lineBounds = pTextLine->GetBoundsF();
3559 int lineOffset = pTextLine->GetTextOffset();
3560 int lineLength = pTextLine->GetTextLength();
3561 int textIndex = pTextLine->GetTextOffset() + column;
3562 float lineY = lineBounds.y;
3564 SysTryReturn(NID_GRP, lineOffset <= textIndex && textIndex <= lineOffset + lineLength
3565 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (row = %d, column = %d)", row, column);
3567 FloatDimension lineTextSize;
3568 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
3570 if (lineTextSize.height == 0)
3572 lineTextSize.height = TextUtility::GetFontMaxHeightF(pFont);
3575 switch (__align & TEXT_ALIGNMASK_HORIZ)
3577 case TEXT_OBJECT_ALIGNMENT_LEFT:
3580 case TEXT_OBJECT_ALIGNMENT_CENTER:
3581 posX += (lineBounds.width - lineTextSize.width) / 2.0f;
3584 case TEXT_OBJECT_ALIGNMENT_RIGHT:
3585 posX += (lineBounds.width - lineTextSize.width);
3589 switch (__align & TEXT_ALIGNMASK_VERT)
3591 case TEXT_OBJECT_ALIGNMENT_TOP:
3594 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3595 posY += (__rect.height - __pTextColumn->GetDisplayHeightF()) / 2.0f;
3598 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3599 posY += (__rect.height - __pTextColumn->GetDisplayHeightF());
3613 FloatRectangle textExtent = pTextLine->GetTextExtentF(column, 1);
3615 if (row == lineCount)
3617 textExtent.width = 0.0f;
3622 Font* pTextFont = __pCompositeText->GetFont(textIndex - 1);
3623 textExtent.height = TextUtility::GetFontMaxHeightF(pTextFont);
3626 if (textExtent.height < 0.0f)
3628 textExtent.height = TextUtility::GetFontMaxHeightF(pFont);
3631 TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment();
3632 switch (alignment & TEXT_ALIGNMASK_VERT)
3634 case TEXT_OBJECT_ALIGNMENT_TOP:
3639 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3640 lineY = lineY + (lineBounds.height - textExtent.height) / 2.0f;
3643 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3644 lineY = lineY + (lineBounds.height - textExtent.height);
3648 width = textExtent.width;
3649 height = textExtent.height;
3650 absX = posX + textExtent.x;
3651 logicalX = absX + __rect.x;
3653 logicalY = absY - firstDisplayPositionY + __rect.y + posY;
3659 TextObject::GetBlockTextPositionInfoInWrapAt(int textIndex, int& width, int& height, int& absX, int& absY,
3660 int& logicalX, int& logicalY) const
3662 float widthF = _CoordinateSystemUtils::ConvertToFloat(width);
3663 float heightF = _CoordinateSystemUtils::ConvertToFloat(height);
3664 float absXF = _CoordinateSystemUtils::ConvertToFloat(absX);
3665 float absYF = _CoordinateSystemUtils::ConvertToFloat(absY);
3666 float logicalXF = _CoordinateSystemUtils::ConvertToFloat(logicalX);
3667 float logicalYF = _CoordinateSystemUtils::ConvertToFloat(logicalY);
3669 result r = GetBlockTextPositionInfoInWrapAt(textIndex, widthF, heightF, absXF, absYF, logicalXF, logicalYF);
3670 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3672 width = _CoordinateSystemUtils::ConvertToInteger(widthF);
3673 height = _CoordinateSystemUtils::ConvertToInteger(heightF);
3674 absX = _CoordinateSystemUtils::ConvertToInteger(absXF);
3675 absY = _CoordinateSystemUtils::ConvertToInteger(absYF);
3676 logicalX = _CoordinateSystemUtils::ConvertToInteger(logicalXF);
3677 logicalY = _CoordinateSystemUtils::ConvertToInteger(logicalYF);
3683 TextObject::GetBlockTextPositionInfoInWrapAt(int textIndex, float& width, float& height, float& absX, float& absY,
3684 float& logicalX, float& logicalY) const
3686 TextLine* pTextLine = null;
3687 FloatRectangle lineBounds;
3688 float firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
3689 int lineCount = __pTextColumn->GetTotalLineCount();
3693 int textIndexFromLineOffset = 0;
3698 _FontImpl* pFont = _FontImpl::GetInstance(*__pDefaultFont);
3699 SysTryReturn(NID_GRP, pFont, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
3701 for (lineIndex = 0; lineIndex < lineCount; lineIndex++)
3703 pTextLine = __pTextColumn->GetTextLine(lineIndex);
3704 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3706 lineBounds = pTextLine->GetBoundsF();
3707 lineOffset = pTextLine->GetTextOffset();
3708 lineLength = pTextLine->GetTextLength();
3710 if (lineOffset <= textIndex && textIndex <= lineOffset + lineLength)
3715 if (lineIndex + 1 < lineCount)
3717 lineY += lineBounds.height;
3721 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3723 if (lineIndex == lineCount)
3725 textIndexFromLineOffset = lineLength;
3729 textIndexFromLineOffset = textIndex - lineOffset;
3732 FloatDimension lineTextSize;
3733 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
3735 if (lineTextSize.height == 0.0f)
3737 lineTextSize.height = TextUtility::GetFontMaxHeightF(pFont);
3740 switch (__align & TEXT_ALIGNMASK_HORIZ)
3742 case TEXT_OBJECT_ALIGNMENT_LEFT:
3745 case TEXT_OBJECT_ALIGNMENT_CENTER:
3746 posX += (lineBounds.width - lineTextSize.width) / 2.0f;
3749 case TEXT_OBJECT_ALIGNMENT_RIGHT:
3750 posX += (lineBounds.width - lineTextSize.width);
3754 switch (__align & TEXT_ALIGNMASK_VERT)
3756 case TEXT_OBJECT_ALIGNMENT_TOP:
3759 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3760 posY += (__rect.height - __pTextColumn->GetDisplayHeightF()) / 2.0f;
3763 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3764 posY += (__rect.height - __pTextColumn->GetDisplayHeightF());
3778 FloatRectangle textExtent = pTextLine->GetBlockTextExtentF(textIndexFromLineOffset, 1);
3780 if (lineIndex == lineCount)
3782 textExtent.width = 0.0f;
3787 Font* pTextFont = __pCompositeText->GetFont(textIndex - 1);
3788 textExtent.height = TextUtility::GetFontMaxHeightF(pTextFont);
3791 if (textExtent.height < 0)
3793 textExtent.height = TextUtility::GetFontMaxHeightF(pFont);
3796 TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment();
3797 switch (alignment & TEXT_ALIGNMASK_VERT)
3799 case TEXT_OBJECT_ALIGNMENT_TOP:
3804 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3805 lineY = lineY + (lineBounds.height - textExtent.height) / 2.0f;
3808 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3809 lineY = lineY + (lineBounds.height - textExtent.height);
3813 width = textExtent.width;
3814 height = textExtent.height;
3815 absX = posX + textExtent.x;
3816 logicalX = absX + __rect.x;
3818 logicalY = absY - firstDisplayPositionY + __rect.y + posY;
3824 TextObject::GetTextPositionInfoInNoneWrapAt(int textIndex, int& width, int& height, int& absX, int& absY,
3825 int& logicalX, int& logicalY) const
3827 float widthF = _CoordinateSystemUtils::ConvertToFloat(width);
3828 float heightF = _CoordinateSystemUtils::ConvertToFloat(height);
3829 float absXF = _CoordinateSystemUtils::ConvertToFloat(absX);
3830 float absYF = _CoordinateSystemUtils::ConvertToFloat(absY);
3831 float logicalXF = _CoordinateSystemUtils::ConvertToFloat(logicalX);
3832 float logicalYF = _CoordinateSystemUtils::ConvertToFloat(logicalY);
3834 result r = GetTextPositionInfoInNoneWrapAt(textIndex, widthF, heightF, absXF, absYF, logicalXF, logicalYF);
3835 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3837 width = _CoordinateSystemUtils::ConvertToInteger(widthF);
3838 height = _CoordinateSystemUtils::ConvertToInteger(heightF);
3839 absX = _CoordinateSystemUtils::ConvertToInteger(absXF);
3840 absY = _CoordinateSystemUtils::ConvertToInteger(absYF);
3841 logicalX = _CoordinateSystemUtils::ConvertToInteger(logicalXF);
3842 logicalY = _CoordinateSystemUtils::ConvertToInteger(logicalYF);
3848 TextObject::GetTextPositionInfoInNoneWrapAt(int textIndex, float& width, float& height, float& absX, float& absY,
3849 float& logicalX, float& logicalY) const
3851 TextLine* pTextLine = null;
3852 pTextLine = __pTextColumn->GetTextLine(0);
3853 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3855 int lineLength = pTextLine->GetTextLength();
3856 float firstDisplayPositionX = __pTextColumn->GetFirstDisplayPositionX();
3860 _FontImpl* pFont = _FontImpl::GetInstance(*__pDefaultFont);
3861 SysTryReturn(NID_GRP, pFont, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
3863 FloatDimension lineTextSize;
3864 FloatRectangle lineBounds;
3865 lineBounds = pTextLine->GetBoundsF();
3866 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
3868 if (lineTextSize.height == 0.0f || pTextLine->GetTextLength() == 0.0f)
3870 lineTextSize.height = TextUtility::GetFontMaxHeightF(pFont);
3873 switch (__align & TEXT_ALIGNMASK_HORIZ)
3875 case TEXT_OBJECT_ALIGNMENT_LEFT:
3878 case TEXT_OBJECT_ALIGNMENT_CENTER:
3879 posX += (lineBounds.width - lineTextSize.width) / 2.0f;
3882 case TEXT_OBJECT_ALIGNMENT_RIGHT:
3883 posX += (lineBounds.width - lineTextSize.width);
3887 switch (__align & TEXT_ALIGNMASK_VERT)
3889 case TEXT_OBJECT_ALIGNMENT_TOP:
3892 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3893 posY += (__rect.height - lineTextSize.height) / 2.0f;
3896 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3897 posY += (__rect.height - lineTextSize.height);
3901 posX = (posX < 0.0f) ? 0.0f : posX;
3902 posY = (posY < 0.0f) ? 0.0f : posY;
3904 FloatRectangle textExtent = pTextLine->GetTextExtentF(textIndex - pTextLine->GetTextOffset(), 1);
3908 Font* pTextFont = __pCompositeText->GetFont(textIndex - 1);
3909 textExtent.height = TextUtility::GetFontMaxHeightF(pTextFont);
3912 if (textExtent.height < 0.0f)
3914 textExtent.height = TextUtility::GetFontMaxHeightF(pFont);
3917 TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment();
3918 switch (alignment & TEXT_ALIGNMASK_VERT)
3920 case TEXT_OBJECT_ALIGNMENT_TOP:
3925 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3926 posY = posY + (lineBounds.height - textExtent.height) / 2.0f;
3929 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3930 posY = posY + (lineBounds.height - textExtent.height);
3934 absX = posX + textExtent.x - firstDisplayPositionX;
3935 logicalX = (absX >= 0.0f) ? absX + __rect.x : absX;
3937 logicalY = absY + __rect.y;
3938 width = textExtent.width;
3939 height = textExtent.height;
3945 TextObject::GetTextPositionInfoInNoneWrapAt(int row, int column, float& width, float& height, float& absX, float& absY,
3946 float& logicalX, float& logicalY) const
3948 TextLine* pTextLine = null;
3949 pTextLine = __pTextColumn->GetTextLine(row);
3950 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3952 int lineLength = pTextLine->GetTextLength();
3953 float firstDisplayPositionX = __pTextColumn->GetFirstDisplayPositionX();
3957 SysTryReturn(NID_GRP, 0 <= column && column <= lineLength, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (row = %d, column = %d)", row, column);
3959 _FontImpl* pFont = _FontImpl::GetInstance(*__pDefaultFont);
3960 SysTryReturn(NID_GRP, pFont, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
3962 FloatDimension lineTextSize;
3963 FloatRectangle lineBounds;
3964 lineBounds = pTextLine->GetBoundsF();
3965 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
3967 if (lineTextSize.height == 0.0f || pTextLine->GetTextLength() == 0.0f)
3969 lineTextSize.height = TextUtility::GetFontMaxHeightF(pFont);
3972 switch (__align & TEXT_ALIGNMASK_HORIZ)
3974 case TEXT_OBJECT_ALIGNMENT_LEFT:
3977 case TEXT_OBJECT_ALIGNMENT_CENTER:
3978 posX += (lineBounds.width - lineTextSize.width) / 2.0f;
3981 case TEXT_OBJECT_ALIGNMENT_RIGHT:
3982 posX += (lineBounds.width - lineTextSize.width);
3986 switch (__align & TEXT_ALIGNMASK_VERT)
3988 case TEXT_OBJECT_ALIGNMENT_TOP:
3991 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3992 posY += (__rect.height - lineTextSize.height) / 2.0f;
3995 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3996 posY += (__rect.height - lineTextSize.height);
4000 posX = (posX < 0.0f) ? 0.0f : posX;
4001 posY = (posY < 0.0f) ? 0.0f : posY;
4003 FloatRectangle textExtent = pTextLine->GetTextExtentF(column - pTextLine->GetTextOffset(), 1);
4007 Font* pTextFont = __pCompositeText->GetFont(column - 1);
4008 textExtent.height = TextUtility::GetFontMaxHeightF(pTextFont);
4011 if (textExtent.height < 0.0f)
4013 textExtent.height = TextUtility::GetFontMaxHeightF(pFont);
4016 TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment();
4017 switch (alignment & TEXT_ALIGNMASK_VERT)
4019 case TEXT_OBJECT_ALIGNMENT_TOP:
4024 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
4025 posY = posY + (lineBounds.height - textExtent.height) / 2.0f;
4028 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
4029 posY = posY + (lineBounds.height - textExtent.height);
4033 absX = posX + textExtent.x - firstDisplayPositionX;
4034 logicalX = (absX >= 0.0f) ? absX + __rect.x : absX;
4036 logicalY = absY + __rect.y;
4037 width = textExtent.width;
4038 height = textExtent.height;
4044 TextObject::GetTotalComposedHeight(void) const
4046 return _CoordinateSystemUtils::ConvertToInteger(GetTotalComposedHeightF());
4050 TextObject::GetTotalComposedHeightF(void) const
4052 return __pCompositeText->GetTotalComposedHeightF();
4056 TextObject::GetLineWidthAt(int lineIndex) const
4058 return _CoordinateSystemUtils::ConvertToInteger(GetLineWidthAtF(lineIndex));
4062 TextObject::GetLineWidthAtF(int lineIndex) const
4064 IF_NOT_CONSTRUCTED(return -1);
4066 result r = E_SUCCESS;
4067 TextLine* pTextLine = null;
4068 FloatDimension lineTextSize;
4071 pTextLine = __pTextColumn->GetTextLine(lineIndex);
4072 SysTryCatch(NID_GRP, pTextLine, , E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
4074 lineLength = pTextLine->GetTextLength();
4075 r = pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
4076 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4078 SetLastResult(E_SUCCESS);
4079 return lineTextSize.width;
4086 TextObject::GetTotalHeight(void) const
4088 return _CoordinateSystemUtils::ConvertToInteger(GetTotalHeightF());
4092 TextObject::GetTotalHeightF(void) const
4094 IF_NOT_CONSTRUCTED(return -1);
4096 float height = 0.0f;
4097 if (IsPartialComposingModeEnabled())
4099 height = __pCompositeText->GetAnalysedTotalHeightF();
4103 height = __pTextColumn->GetTotalHeightF();
4110 TextObject::GetElementIndexOf(TextElement& textElement) const
4112 IF_NOT_CONSTRUCTED(return -1);
4114 return __pCompositeText->GetElementIndexOf(textElement);
4118 TextObject::RemoveElementAt(int elementIndex, bool deallocate)
4120 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4122 return __pCompositeText->RemoveElementAt(elementIndex, deallocate);
4126 TextObject::HideFrontSpace(TextObjectSpaceHideType mode)
4128 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4130 __pCompositeText->HideFrontSpace(mode);
4136 TextObject::HideRearSpace(TextObjectSpaceHideType mode)
4138 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4140 __pCompositeText->HideRearSpace(mode);
4146 TextObject::GetSlidingStep(void) const
4148 return _CoordinateSystemUtils::ConvertToInteger(GetSlidingStepF());
4152 TextObject::GetSlidingStepF(void) const
4154 IF_NOT_CONSTRUCTED(return -1.0f);
4156 return __slidingStep;
4161 TextObject::SetSlidingStep(int slidingStep)
4163 return SetSlidingStep(_CoordinateSystemUtils::ConvertToFloat(slidingStep));
4167 TextObject::SetSlidingStep(float slidingStep)
4169 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4171 __slidingStep = slidingStep;
4177 TextObject::GetTotalLineCount(void) const
4179 IF_NOT_CONSTRUCTED(return -1);
4181 return __pTextColumn->GetTotalLineCount();
4185 TextObject::GetLineIndexAtTextIndex(int textIndex) const
4187 IF_NOT_CONSTRUCTED(return -1);
4189 return __pTextColumn->GetLineIndexAtTextIndex(textIndex);
4193 TextObject::GetLineHeightAt(int lineIndex) const
4195 return _CoordinateSystemUtils::ConvertToInteger(GetLineHeightAtF(lineIndex));
4199 TextObject::GetLineHeightAtF(int lineIndex) const
4201 IF_NOT_CONSTRUCTED(return -1);
4203 SysTryReturn(NID_GRP, lineIndex >= 0, -1, E_INVALID_ARG
4204 , "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4206 return __pTextColumn->GetLineHeightAtF(lineIndex);
4210 TextObject::GetDisplayLineCount(void) const
4212 IF_NOT_CONSTRUCTED(return -1);
4214 return __pTextColumn->GetDisplayLineCount();
4218 TextObject::GetFirstDisplayLineIndex(void) const
4220 IF_NOT_CONSTRUCTED(return -1);
4222 return __pTextColumn->GetFirstDisplayLineIndex();
4226 TextObject::GetFirstDisplayPositionY(void) const
4228 return _CoordinateSystemUtils::ConvertToInteger(GetFirstDisplayPositionYF());
4232 TextObject::GetFirstDisplayPositionYF(void) const
4234 IF_NOT_CONSTRUCTED(return -1);
4236 return __pTextColumn->GetFirstDisplayPositionYF();
4240 TextObject::GetLineIndexAtPositionY(int y) const
4242 return GetLineIndexAtPositionY(_CoordinateSystemUtils::ConvertToFloat(y));
4246 TextObject::GetLineIndexAtPositionY(float y) const
4248 IF_NOT_CONSTRUCTED(return -1);
4250 return __pTextColumn->GetLineIndexAtPositionY(y);
4254 TextObject::GetFirstTextIndexAt(int lineIndex) const
4256 IF_NOT_CONSTRUCTED(return -1);
4258 SysTryReturn(NID_GRP, lineIndex >= 0, -1, E_INVALID_ARG
4259 , "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4261 return __pTextColumn->GetFirstTextIndexAt(lineIndex);
4265 TextObject::GetTextLengthAt(int lineIndex) const
4267 IF_NOT_CONSTRUCTED(return -1);
4269 SysTryReturn(NID_GRP, lineIndex >= 0, -1, E_INVALID_ARG
4270 , "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4272 return __pTextColumn->GetTextLengthAt(lineIndex);
4276 TextObject::GetBounds(void) const
4278 IF_NOT_CONSTRUCTED(return Rectangle(0, 0, 0, 0));
4280 return _CoordinateSystemUtils::ConvertToInteger(__rect);
4284 TextObject::GetBoundsF(void) const
4290 TextObject::GetLineSpace(void) const
4292 IF_NOT_CONSTRUCTED(return -1);
4294 return _CoordinateSystemUtils::ConvertToInteger(GetLineSpaceF());
4298 TextObject::GetLineSpaceF(void) const
4300 IF_NOT_CONSTRUCTED(return -1);
4302 return __pCompositeText->GetLineSpaceF();
4306 TextObject::GetTextLength(void) const
4308 IF_NOT_CONSTRUCTED(return -1);
4310 return __pCompositeText->GetTextLength();
4314 TextObject::GetElementVerticalAlignment(void) const
4316 IF_NOT_CONSTRUCTED(return TEXT_OBJECT_ALIGNMENT_INVALID);
4318 return __pCompositeText->GetElementVerticalAlignment();
4321 TextObjectActionType
4322 TextObject::GetAction(void) const
4324 IF_NOT_CONSTRUCTED(return TEXT_OBJECT_ACTION_TYPE_NONE);
4330 TextObject::GetAlignment(void) const
4332 IF_NOT_CONSTRUCTED(return TEXT_OBJECT_ALIGNMENT_INVALID);
4338 TextObject::GetElementCount(void) const
4340 IF_NOT_CONSTRUCTED(return -1);
4342 return __pCompositeText->GetElementCount();
4346 TextObject::GetElementAtElementIndex(int elementIndex) const
4348 IF_NOT_CONSTRUCTED(return null);
4350 return __pCompositeText->GetElementAtElementIndex(elementIndex);
4354 TextObject::SetRange(int startTextIndex, int textLength)
4356 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4358 return __pCompositeText->SetRange(startTextIndex, textLength);
4362 TextObject::GetRange(int& startTextIndex, int& textLength) const
4364 IF_NOT_CONSTRUCTED(return);
4366 return __pCompositeText->GetRange(startTextIndex, textLength);
4370 TextObject::GetWrap(void) const
4372 IF_NOT_CONSTRUCTED(return TEXT_OBJECT_WRAP_TYPE_NONE);
4378 TextObject::SetCursorIndex(int cursorIndex)
4380 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4382 SysTryReturn(NID_GRP, cursorIndex >= 0, E_INVALID_ARG, E_INVALID_ARG
4383 , "[E_INVALID_ARG] The argument is invalid.");
4385 __pCompositeText->SetCursorIndex(cursorIndex);
4391 TextObject::GetCursorIndex(void) const
4393 IF_NOT_CONSTRUCTED(return -1);
4395 return __pCompositeText->GetCursorIndex();
4399 TextObject::SetBlock(bool enable)
4401 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4403 __pCompositeText->SetBlock(enable);
4409 TextObject::GetBlock(void) const
4411 IF_NOT_CONSTRUCTED(return false);
4413 return __pCompositeText->GetBlock();
4417 TextObject::SetBlockRange(int startTextIndex, int textLength)
4419 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4421 result r = E_SUCCESS;
4422 r = __pCompositeText->SetRange(startTextIndex, textLength);
4423 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4429 TextObject::GetBlockRange(int& startTextIndex, int& textLength)
4431 IF_NOT_CONSTRUCTED(return);
4433 __pCompositeText->GetRange(startTextIndex, textLength);
4437 TextObject::IsAlternateLookEnabled(void) const
4439 IF_NOT_CONSTRUCTED(return false);
4441 return __isAlternateLookEnabled;
4445 TextObject::GetTotalCutLinkElementCount(void) const
4447 IF_NOT_CONSTRUCTED(return -1);
4449 return __pCompositeText->GetCutLinkElementCount();
4453 TextObject::ChangeCutLinkState(int linkIndex, bool select)
4455 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4457 return __pCompositeText->ChangeCutLinkState(linkIndex, select);
4461 TextObject::ResetAllCutLinkElementsState(void)
4463 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4465 return __pCompositeText->ResetAllCutLinkElementsState();
4469 TextObject::IsActionOn(void) const
4471 IF_NOT_CONSTRUCTED(return false);
4473 return __isActionOn;
4476 TextObjectEllipsisType
4477 TextObject::GetTextObjectEllipsisType(void) const
4479 IF_NOT_CONSTRUCTED(return TEXT_OBJECT_ELLIPSIS_TYPE_INVALID);
4481 return __textObjectEllipsisType;
4485 TextObject::ChangeText(int textIndex)
4487 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4489 if (__sweepInfo.isValid)
4491 __sweepInfo.isValid = false;
4492 return E_INVALID_STATE;
4495 __sweepInfo.isValid = true;
4496 __sweepInfo.sweepType = TEXT_OBJECT_SWEEP_TYPE_REPLACE;
4497 __sweepInfo.sweepEventType = TEXT_OBJECT_SWEEP_EVENT_INSERT;
4498 __sweepInfo.anchorTextIndex = textIndex;
4499 __sweepInfo.sweepRegionStartLineIndex = GetLineIndexAtTextIndex(textIndex);
4500 __sweepInfo.sweepRegionLineCount = 1;
4501 __sweepInfo.anchorLineIndex = __sweepInfo.sweepRegionStartLineIndex;
4502 __sweepInfo.widthChanged = 0;
4504 __pCompositeText->SetTextSweepInfo(&__sweepInfo);
4510 TextObject::InputText(int textIndex)
4512 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4514 if (__sweepInfo.isValid == true)
4516 __sweepInfo.isValid = false;
4517 return E_INVALID_STATE;
4520 __sweepInfo.isValid = true;
4521 __sweepInfo.sweepType = TEXT_OBJECT_SWEEP_TYPE_KEYINPUT;
4522 __sweepInfo.sweepEventType = TEXT_OBJECT_SWEEP_EVENT_INSERT;
4523 __sweepInfo.anchorTextIndex = textIndex;
4524 __sweepInfo.prevAnchorLineIndex = GetLineIndexAtTextIndex(textIndex);
4526 if (__sweepInfo.prevAnchorLineIndex == -1)
4528 __sweepInfo.prevAnchorLineIndex = __pTextColumn->GetTotalLineCount()-1;
4531 __pCompositeText->SetTextSweepInfo(&__sweepInfo);
4537 TextObject::RemoveText(int textIndex)
4539 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4541 if (__sweepInfo.isValid == true)
4543 __sweepInfo.isValid = false;
4544 return E_INVALID_STATE;
4547 __sweepInfo.isValid = true;
4548 __sweepInfo.sweepEventType = TEXT_OBJECT_SWEEP_EVENT_REMOVE;
4549 __sweepInfo.anchorTextIndex = textIndex;
4550 __sweepInfo.prevAnchorLineIndex = GetLineIndexAtTextIndex(textIndex);
4552 if (__sweepInfo.prevAnchorLineIndex == -1)
4554 __sweepInfo.prevAnchorLineIndex = __pTextColumn->GetTotalLineCount()-1;
4557 __pCompositeText->SetTextSweepInfo(&__sweepInfo);
4563 TextObject::ResetSweepInfo(void)
4565 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4567 __sweepInfo.isValid = false;
4573 TextObject::GetSweepInfo(void) const
4575 TextObjectSweepInfo textSweepInfo;
4576 textSweepInfo.isValid = false;
4577 textSweepInfo.sweepType = TEXT_OBJECT_SWEEP_TYPE_NONE;
4578 textSweepInfo.sweepEventType = TEXT_OBJECT_SWEEP_EVENT_NONE;
4579 textSweepInfo.anchorTextIndex = -1;
4580 textSweepInfo.anchorLineIndex = -1;
4581 textSweepInfo.prevAnchorLineIndex = -1;
4582 textSweepInfo.sweepRegionStartLineIndex = -1;
4583 textSweepInfo.sweepRegionLineCount = -1;
4584 textSweepInfo.insertedLineCount = -1;
4585 textSweepInfo.deletedLineCount = -1;
4586 textSweepInfo.widthChanged = -1;
4588 IF_NOT_CONSTRUCTED(return textSweepInfo);
4590 textSweepInfo.isValid = __sweepInfo.isValid;
4591 textSweepInfo.sweepType = __sweepInfo.sweepType;
4592 textSweepInfo.sweepEventType = __sweepInfo.sweepEventType;
4593 textSweepInfo.anchorTextIndex = __sweepInfo.anchorTextIndex;
4594 textSweepInfo.anchorLineIndex = __sweepInfo.anchorLineIndex;
4595 textSweepInfo.prevAnchorLineIndex = __sweepInfo.prevAnchorLineIndex;
4596 textSweepInfo.sweepRegionStartLineIndex = __sweepInfo.sweepRegionStartLineIndex;
4597 textSweepInfo.sweepRegionLineCount = __sweepInfo.sweepRegionLineCount;
4598 textSweepInfo.insertedLineCount = __sweepInfo.insertedLineCount;
4599 textSweepInfo.deletedLineCount = __sweepInfo.deletedLineCount;
4600 textSweepInfo.widthChanged = __sweepInfo.widthChanged;
4602 return textSweepInfo;
4606 TextObject::GetSweepComposeLineInfo(int lineIndex, TextObjectSweepComposeLineInfo& textSweepComposeLineInfo) const
4608 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4610 SysTryReturn(NID_GRP, lineIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4612 TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex);
4613 SysTryReturn(NID_GRP, pTextLine, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4615 textSweepComposeLineInfo = pTextLine->GetSweepComposeInfo();
4621 TextObject::GetTextOffsetAtLine(int lineIndex) const
4623 IF_NOT_CONSTRUCTED(return -1);
4625 SysTryReturn(NID_GRP, lineIndex >= 0, -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4627 TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex);
4628 SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
4630 return pTextLine->GetTextOffset();
4634 TextObject::GetTextLengthAtLine(int lineIndex) const
4636 IF_NOT_CONSTRUCTED(return -1);
4638 SysTryReturn(NID_GRP, lineIndex >= 0, -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4640 TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex);
4641 SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
4643 return pTextLine->GetTextLength();
4647 TextObject::GetBoundsAtLine(int lineIndex) const
4649 return _CoordinateSystemUtils::ConvertToInteger(GetBoundsAtLineF(lineIndex));
4653 TextObject::GetBoundsAtLineF(int lineIndex) const
4655 IF_NOT_CONSTRUCTED(return FloatRectangle(-1, -1, -1, -1));
4657 SysTryReturn(NID_GRP, lineIndex >= 0, FloatRectangle(-1, -1, -1, -1), E_INVALID_ARG
4658 , "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4660 TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex);
4661 SysTryReturn(NID_GRP, pTextLine, FloatRectangle(-1, -1, -1, -1), E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
4663 FloatRectangle lineBounds = pTextLine->GetBoundsF();
4669 TextObject::GetDisplayPositionAtLine(int lineIndex, int textIndexFromLineOffset)
4671 return _CoordinateSystemUtils::ConvertToInteger(GetDisplayPositionAtLineF(lineIndex, textIndexFromLineOffset));
4675 TextObject::GetDisplayPositionAtLineF(int lineIndex, int textIndexFromLineOffset)
4677 IF_NOT_CONSTRUCTED(return FloatPoint(-1.0f, -1.0f));
4679 SysTryReturn(NID_GRP, lineIndex >= 0, FloatPoint(-1.0f, -1.0f), E_INVALID_ARG
4680 , "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4682 TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex);
4683 SysTryReturn(NID_GRP, pTextLine, FloatPoint(-1.0f, -1.0f), E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
4685 int lineOffset = pTextLine->GetTextOffset();
4686 int lineLength = pTextLine->GetTextLength();
4687 FloatDimension lineTextSize;
4688 FloatDimension extentDim;
4689 FloatRectangle lineBounds;
4692 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
4693 lineBounds = pTextLine->GetBoundsF();
4695 __pCompositeText->ForwardAnalyze(lineOffset, textIndexFromLineOffset, lineTextSize.width, __wrap, textCount, extentDim.width, extentDim.height);
4697 switch (__align & TEXT_ALIGNMASK_HORIZ)
4699 case TEXT_OBJECT_ALIGNMENT_LEFT:
4702 case TEXT_OBJECT_ALIGNMENT_CENTER:
4703 extentDim.width += (lineBounds.width - lineTextSize.width) / 2.0f;
4706 case TEXT_OBJECT_ALIGNMENT_RIGHT:
4707 extentDim.width += (lineBounds.width - lineTextSize.width);
4711 if (extentDim.width < 0.0f)
4713 extentDim.width = 0.0f;
4716 return FloatPoint(extentDim.width + __rect.x, lineBounds.y - __pTextColumn->GetFirstDisplayPositionYF() + __rect.y);
4720 TextObject::GetDisplayableText(void)
4722 IF_NOT_CONSTRUCTED(return -1);
4724 return __pCompositeText->GetDisplayableText(__rect, __action);
4728 TextObject::WordExceedsWidthAt(int lineIndex) const
4730 IF_NOT_CONSTRUCTED(return false);
4732 SysTryReturn(NID_GRP, lineIndex >= 0, false, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4734 TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex);
4735 SysTryReturn(NID_GRP, pTextLine, false, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
4737 bool hasOneWord = (pTextLine->GetEndType() == TEXT_RETBY_LIMITWIDTH) ? true : false;
4743 TextObject::SetTextBidiHint(TextBidiHint bidiHint)
4745 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4749 case TEXT_BIDI_HINT_NONE:
4750 case TEXT_BIDI_HINT_LTR:
4751 case TEXT_BIDI_HINT_RTL:
4752 __bidiHint = bidiHint;
4760 TextObject::GetTextBidiHint(void) const
4762 IF_NOT_CONSTRUCTED(return TEXT_BIDI_HINT_NONE);
4768 TextObject::ConvertToRowColumn(int textIndex, int& row, int& column) const
4770 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4772 SysTryReturn(NID_GRP, textIndex >= 0 && textIndex <= GetTextLength(), E_INVALID_ARG, E_INVALID_ARG
4773 , "[E_INVALID_ARG] The argument is invalid. (textIndex = %d)", textIndex);
4775 TextLine* pTextLine = null;
4779 int lineCount = GetTotalLineCount();
4781 for (lineIndex = 0; lineIndex < lineCount; lineIndex++)
4783 pTextLine = __pTextColumn->GetTextLine(lineIndex);
4784 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
4786 lineOffset = pTextLine->GetTextOffset();
4787 lineLength = pTextLine->GetTextLength();
4789 if (lineOffset <= textIndex && textIndex < lineOffset + lineLength)
4795 column = (lineIndex == lineCount) ? lineLength : textIndex - lineOffset;
4796 row = (lineIndex == lineCount) ? lineIndex - 1 : lineIndex;
4802 TextObject::ConvertToTextIndex(int row, int column) const
4804 IF_NOT_CONSTRUCTED(return -1);
4806 TextLine* pTextLine = __pTextColumn->GetTextLine(row);
4807 SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
4809 int lineOffset = pTextLine->GetTextOffset();
4810 int lineLength = pTextLine->GetTextLength();
4812 SysTryReturn(NID_GRP, column <= lineLength, -1, E_INVALID_ARG
4813 , "[E_INVALID_ARG] The argument is invalid. (row = %d, column = %d)", row, column);
4815 SetLastResult(E_SUCCESS);
4817 return lineOffset + column;
4821 TextObject::SetDisplayBoundsExpandEnabled(bool enable)
4823 IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4825 __isDisplayBoundsExpandEnabled = enable;
4831 TextObject::IsDisplayBoundsExpandEnabled(void) const
4833 IF_NOT_CONSTRUCTED(return false);
4835 return __isDisplayBoundsExpandEnabled;
4839 TextObject::GetRepeatCount(void) const
4841 IF_NOT_CONSTRUCTED(return -1);
4843 return __repeatCount;
4846 }}} // Tizen::Graphics::_Text