Merge "Removed exception" into tizen_2.1
[platform/framework/native/uifw.git] / src / graphics / text / FGrp_TextTextObject.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
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.
16 //
17
18 /*
19  * @file        FGrp_TextTextObject.cpp
20  * @brief       This is the implementation file for TextObject class.
21  */
22
23 #include <new>
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"
41
42 namespace // unnamed
43 {
44         const int DEFAULT_FONT_SIZE = 42;
45 }
46
47 #define IF_NOT_CONSTRUCTED(code) if (this->__pCompositeText == null || this->__pTextColumn == null) \
48         { \
49                 code; \
50         }
51
52 #define Release(x) \
53         if (x) \
54         { \
55                 delete x; \
56                 x = null; \
57         }
58
59 using namespace Tizen::Base::Utility;
60 using namespace Tizen::Base;
61
62 namespace Tizen { namespace Graphics
63 {
64
65 namespace _Text
66 {
67
68 TextObject::TextObject(void)
69 {
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;
73         __isActionOn = false;
74         __isChanged = false;
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;
81         __pTextColumn = null;
82         __textObjectEllipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_TAIL;
83         __isFirstDisplayPositionYChanged = false;
84         __rect.x = 0;
85         __rect.y = 0;
86         __rect.width = 0;
87         __rect.height = 0;
88         __slidingGap = CoordinateSystem::ConvertToLogicalX(30.0f);
89         __slidingStep = CoordinateSystem::ConvertToLogicalX(2.0f);
90         __linkViewModeEnabled = false;
91         __isUrlLinkColorDefined = false;
92         __isEmailLinkColorDefined = false;
93         __isPhoneNumberLinkColorDefined = false;
94         __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_NORMAL] = Color::GetColor(COLOR_ID_BLUE);
95         __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_SELECT] = Color::GetColor(COLOR_ID_BLUE);
96         __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_NORMAL] = Color::GetColor(COLOR_ID_BLUE);
97         __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_SELECT] = Color::GetColor(COLOR_ID_BLUE);
98         __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_NORMAL] = Color::GetColor(COLOR_ID_BLUE);
99         __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_SELECT] = Color::GetColor(COLOR_ID_BLUE);
100         __bidiHint = TEXT_BIDI_HINT_NONE;
101         __isDisplayBoundsExpandEnabled = false;
102
103         __sweepInfo.isValid = false;
104         __sweepInfo.sweepType = TEXT_OBJECT_SWEEP_TYPE_NONE;
105         __sweepInfo.sweepEventType = TEXT_OBJECT_SWEEP_EVENT_INSERT;
106         __sweepInfo.anchorTextIndex = 0;
107         __sweepInfo.anchorLineIndex = 0;
108         __sweepInfo.prevAnchorLineIndex = 0;
109         __sweepInfo.sweepRegionStartLineIndex = 0;
110         __sweepInfo.sweepRegionLineCount = 0;
111         __sweepInfo.insertedLineCount = 0;
112         __sweepInfo.deletedLineCount = 0;
113         __sweepInfo.widthChanged = 0;
114 }
115
116 TextObject::~TextObject(void)
117 {
118         Release(__pCompositeText);
119         Release(__pTextColumn);
120         Release(__pDefaultFont);
121 }
122
123 result
124 TextObject::Construct(void)
125 {
126         result r = E_SUCCESS;
127
128         __action = TEXT_OBJECT_ACTION_TYPE_NONE;
129         __align = (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
130         __wrap = TEXT_OBJECT_WRAP_TYPE_WORD;
131         __isActionOn = false;
132         __isChanged = false;
133         __defaultForegroundColor = Color::GetColor(COLOR_ID_BLACK);
134         __defaultBackgroundColor = Color::GetColor(COLOR_ID_WHITE);
135         __defaultOutlineColor = Color::GetColor(COLOR_ID_WHITE);
136         __isAlternateLookEnabled = false;
137         __linkViewModeEnabled = false;
138         __bidiHint = TEXT_BIDI_HINT_NONE;
139
140         __pCompositeText = new (std::nothrow)TextComposite();
141         SysTryCatch(NID_GRP, __pCompositeText, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
142
143         __pTextColumn = new (std::nothrow)TextColumn(__pCompositeText);
144         SysTryCatch(NID_GRP, __pTextColumn, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
145
146         __pDefaultFont = new (std::nothrow)Font();
147         SysTryCatch(NID_GRP, __pDefaultFont, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
148
149         r = __pDefaultFont->Construct(FONT_STYLE_PLAIN, DEFAULT_FONT_SIZE);
150         SysTryCatch(NID_GRP, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Fail to set font.");
151
152         __pCompositeText->SetWrap(__wrap);
153         __pCompositeText->SetTextSweepInfo(&__sweepInfo);
154
155         return E_SUCCESS;
156
157 CATCH:
158         Release(__pDefaultFont);
159         Release(__pCompositeText);
160         Release(__pTextColumn);
161
162         return r;
163 }
164
165 result
166 TextObject::Construct(const Rectangle& rect)
167 {
168         result r = E_SUCCESS;
169
170         __action = TEXT_OBJECT_ACTION_TYPE_NONE;
171         __align = (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
172         __wrap = TEXT_OBJECT_WRAP_TYPE_WORD;
173         __isActionOn = false;
174         __isChanged = false;
175         __defaultForegroundColor = Color::GetColor(COLOR_ID_BLACK);
176         __defaultBackgroundColor = Color::GetColor(COLOR_ID_WHITE);
177         __defaultOutlineColor = Color::GetColor(COLOR_ID_WHITE);
178         __isAlternateLookEnabled = false;
179         __linkViewModeEnabled = false;
180         __bidiHint = TEXT_BIDI_HINT_NONE;
181         __rect = _CoordinateSystemUtils::ConvertToFloat(rect);
182
183         __pCompositeText = new (std::nothrow)TextComposite();
184         SysTryCatch(NID_GRP, __pCompositeText, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
185
186         __pTextColumn = new (std::nothrow)TextColumn(__pCompositeText);
187         SysTryCatch(NID_GRP, __pTextColumn, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
188
189         __pDefaultFont = new (std::nothrow)Font();
190         SysTryCatch(NID_GRP, __pTextColumn, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
191
192         r = __pDefaultFont->Construct(FONT_STYLE_PLAIN, DEFAULT_FONT_SIZE);
193         SysTryCatch(NID_GRP, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Fail to set font.");
194
195         __pCompositeText->SetWrap(__wrap);
196         __pCompositeText->SetTextSweepInfo(&__sweepInfo);
197
198         return E_SUCCESS;
199
200 CATCH:
201         Release(__pDefaultFont);
202         Release(__pCompositeText);
203         Release(__pTextColumn);
204
205         return r;
206 }
207
208 result
209 TextObject::Construct(const FloatRectangle& rect)
210 {
211         result r = E_SUCCESS;
212
213         __action = TEXT_OBJECT_ACTION_TYPE_NONE;
214         __align = (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
215         __wrap = TEXT_OBJECT_WRAP_TYPE_WORD;
216         __isActionOn = false;
217         __isChanged = false;
218         __defaultForegroundColor = Color::GetColor(COLOR_ID_BLACK);
219         __defaultBackgroundColor = Color::GetColor(COLOR_ID_WHITE);
220         __defaultOutlineColor = Color::GetColor(COLOR_ID_WHITE);
221         __isAlternateLookEnabled = false;
222         __linkViewModeEnabled = false;
223         __bidiHint = TEXT_BIDI_HINT_NONE;
224         __rect = rect;
225
226         __pCompositeText = new (std::nothrow)TextComposite();
227         SysTryCatch(NID_GRP, __pCompositeText, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
228
229         __pTextColumn = new (std::nothrow)TextColumn(__pCompositeText);
230         SysTryCatch(NID_GRP, __pTextColumn, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
231
232         __pDefaultFont = new (std::nothrow)Font();
233         SysTryCatch(NID_GRP, __pTextColumn, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
234
235         r = __pDefaultFont->Construct(FONT_STYLE_PLAIN, DEFAULT_FONT_SIZE);
236         SysTryCatch(NID_GRP, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Fail to set font.");
237
238         __pCompositeText->SetWrap(__wrap);
239         __pCompositeText->SetTextSweepInfo(&__sweepInfo);
240
241         return E_SUCCESS;
242
243 CATCH:
244         Release(__pDefaultFont);
245         Release(__pCompositeText);
246         Release(__pTextColumn);
247
248         return r;
249 }
250
251 TextObject*
252 TextObject::CloneN(void)
253 {
254         IF_NOT_CONSTRUCTED(return null);
255
256         result r = E_SUCCESS;
257         TextObject* pTextObject = null;
258         TextElement* pTextElement = null;
259         TextElement* pCloneTextElement = null;
260         int count = __pCompositeText->GetElementCount();
261
262         pTextObject = new (std::nothrow)TextObject();
263         SysTryReturn(NID_GRP, pTextObject, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
264
265         r = pTextObject->Construct();
266         SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
267
268         for (int i=0; i < count; i++)
269         {
270                 pTextElement = __pCompositeText->GetElementAtElementIndex(i);
271                 SysTryCatch(NID_GRP, pTextElement, , E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
272
273                 pCloneTextElement = pTextElement->CloneN(SET_ALLVALUE_CLONE,0);
274                 pTextObject->AppendElement(*pCloneTextElement);
275         }
276
277         SetLastResult(E_SUCCESS);
278
279         return pTextObject;
280
281 CATCH:
282         Release(pTextObject);
283
284         return null;
285 }
286
287 result
288 TextObject::Draw(_CanvasImpl& canvasImpl)
289 {
290         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
291
292         if (__rect.width == 0.0f || __rect.height == 0.0f)
293         {
294                 return E_SUCCESS;
295         }
296
297         result r = E_SUCCESS;
298         TextLine* pTextLine = null;
299         FloatRectangle clipRect;
300         FloatRectangle lineBounds;
301         FloatRectangle targetBounds;
302         float totalHeight = 0;
303         float slidingWidth = 0;
304
305         SysTryReturn(NID_GRP, __rect.width > 0.0f && __rect.height > 0.0f, E_INVALID_STATE, E_INVALID_STATE
306                         , "[E_INVALID_STATE] This instance is not constructed yet. (width = %d, height = %d)", __rect.width, __rect.height);
307
308         TextBidiHint bidiHint = _GetTextBidiHint();
309         _SetTextBidiHint(__bidiHint);
310
311         r = Compose();
312         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
313
314         if (__pTextColumn->GetTotalLineCount() <= 1)
315         {
316                 __pTextColumn->SetFirstDisplayLineIndex(0);
317                 __pTextColumn->SetFirstDisplayPositionY(0.0f);
318         }
319
320         targetBounds = __rect;
321
322         if (__action == TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT)
323         {
324                 if (__pTextColumn->GetTotalLineCount() == 0)
325                 {
326                         return E_SUCCESS;
327                 }
328
329                 totalHeight = TextUtility::GetFontMaxHeightF(__pDefaultFont);
330         }
331         else
332         {
333                 totalHeight = __pTextColumn->GetTotalHeightF();
334         }
335
336         if (totalHeight == 0)
337         {
338                 return E_SUCCESS;
339         }
340
341         if (totalHeight < targetBounds.height)
342         {
343                 switch (__align & TEXT_ALIGNMASK_VERT)
344                 {
345                 case TEXT_OBJECT_ALIGNMENT_TOP:
346                         // fall through
347                 default:
348                         break;
349
350                 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
351                         targetBounds.y += (targetBounds.height - totalHeight) / 2.0f;
352                         break;
353
354                 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
355                         targetBounds.y += targetBounds.height - totalHeight;
356                         break;
357                 }
358         }
359         else
360         {
361                 if (targetBounds.height < totalHeight)
362                 {
363                         if (__action == TEXT_OBJECT_ACTION_TYPE_ABBREV)
364                         {
365                                 int i = 0;
366                                 int lineCount = __pTextColumn->GetTotalLineCount();
367
368                                 if (lineCount == 1)
369                                 {
370                                         totalHeight = targetBounds.height;
371                                 }
372                                 else
373                                 {
374                                         float lineHeight = __pTextColumn->GetLineHeightAtF(0);
375
376                                         if (targetBounds.height < lineHeight)
377                                         {
378                                                 totalHeight = targetBounds.height;
379                                         }
380                                         else
381                                         {
382                                                 lineHeight = 0;
383
384                                                 for (i = 0; i < lineCount; i++)
385                                                 {
386                                                         lineHeight += __pTextColumn->GetLineHeightAtF(i);
387                                                         if (targetBounds.height < lineHeight)
388                                                         {
389                                                                 lineHeight -= __pTextColumn->GetLineHeightAtF(i);
390                                                                 break;
391                                                         }
392                                                 }
393
394                                                 totalHeight = lineHeight;
395                                         }
396                                 }
397                         }
398                         else
399                         {
400                                 goto CONTINUE_PROC;
401                         }
402                 }
403                 else
404                 {
405                         goto CONTINUE_PROC;
406                 }
407
408                 switch (__align & TEXT_ALIGNMASK_VERT)
409                 {
410                 case TEXT_OBJECT_ALIGNMENT_TOP:
411                         // fall through
412                 default:
413                         break;
414
415                 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
416                         targetBounds.y += (targetBounds.height - totalHeight) / 2.0f;
417                         break;
418
419                 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
420                         targetBounds.y += targetBounds.height - totalHeight;
421                         break;
422                 }
423                 targetBounds.height = totalHeight;
424         }
425
426 CONTINUE_PROC:
427         FloatRectangle finalClipRect;
428         clipRect = canvasImpl.GetClipBoundsF();
429
430         finalClipRect.x = (clipRect.x > __rect.x) ? clipRect.x : __rect.x;
431         finalClipRect.y = (clipRect.y > __rect.y) ? clipRect.y: __rect.y;
432         finalClipRect.width = (clipRect.x + clipRect.width > __rect.x + __rect.width) ? (__rect.x + __rect.width) - finalClipRect.x : (clipRect.x + clipRect.width) - finalClipRect.x;
433         finalClipRect.height = (clipRect.y + clipRect.height > __rect.y + __rect.height) ? (__rect.y + __rect.height) - finalClipRect.y : (clipRect.y + clipRect.height) - finalClipRect.y;
434
435         if (__isDisplayBoundsExpandEnabled == true)
436         {
437                 finalClipRect.y = clipRect.y;
438                 finalClipRect.height = clipRect.height;
439         }
440
441         SysTryReturn(NID_GRP, 0.0f <= finalClipRect.width && 0.0f <= finalClipRect.height, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get clip rectangle.");
442
443         canvasImpl.SetClipBounds(finalClipRect);
444
445         switch (__action)
446         {
447         case TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT:
448                 pTextLine = __pTextColumn->GetTextLine(0);
449                 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
450
451                 lineBounds = pTextLine->GetBoundsF();
452                 __pTextColumn->SetDisplayLineCount(1);
453                 __pTextColumn->SetDisplayHeight(lineBounds.height);
454
455                 slidingWidth = (__pTextColumn->GetSlidingDimension().width > __rect.width) ? __pTextColumn->GetSlidingDimension().width : __rect.width;
456
457                 if (__isActionOn)
458                 {
459                         FloatRectangle slidingRect;
460
461                         targetBounds.width = lineBounds.width;
462                         targetBounds.height = lineBounds.height;
463
464                         slidingRect = targetBounds;
465
466                         slidingRect.x += __pTextColumn->GetSlidingPositionF();
467                         FloatDimension slidingDim = __pTextColumn->GetSlidingDimensionF();
468                         slidingRect.width = slidingDim.width;
469                         slidingRect.height = slidingDim.height;
470
471                         __pCompositeText->Draw(canvasImpl, slidingRect, 0, __pCompositeText->GetTextLength(),
472                                         (TextObjectAlignment)(__align & TEXT_ALIGNMASK_HORIZ), TEXT_OBJECT_ACTION_TYPE_NONE);
473
474                         slidingRect.x += slidingDim.width + __slidingGap;
475                         if (slidingRect.x < targetBounds.x + targetBounds.width)
476                         {
477                                 slidingRect.width = targetBounds.x + targetBounds.width - slidingRect.x;
478                                 __pCompositeText->Draw(canvasImpl, slidingRect, 0, __pCompositeText->GetTextLength()
479                                                 ,(TextObjectAlignment)(__align & TEXT_ALIGNMASK_HORIZ), TEXT_OBJECT_ACTION_TYPE_NONE);
480                         }
481                 }
482                 else
483                 {
484                         pTextLine->Draw(canvasImpl, targetBounds, 0, pTextLine->GetTextLength(),
485                                         (TextObjectAlignment)(__align & TEXT_ALIGNMASK_HORIZ), TEXT_OBJECT_ACTION_TYPE_NONE);
486                 }
487                 break;
488
489         case TEXT_OBJECT_ACTION_TYPE_SLIDE_UP:
490         {
491                 FloatRectangle slidingRect = targetBounds;
492                 slidingRect.y += __pTextColumn->GetSlidingPositionF();
493
494                 int lineCount = __pTextColumn->GetTotalLineCount();
495                 for (int i = 0; i < lineCount; i++)
496                 {
497                         pTextLine = __pTextColumn->GetTextLine(i);
498                         if (pTextLine != null)
499                         {
500                                 lineBounds = pTextLine->GetBoundsF();
501                                 slidingRect.height = lineBounds.height;
502                                 if ((slidingRect.y + slidingRect.height >= targetBounds.y) && (slidingRect.y < targetBounds.y + targetBounds.height))
503                                 {
504                                         pTextLine->Draw(canvasImpl, slidingRect, 0, pTextLine->GetTextLength(),
505                                                         (TextObjectAlignment)(__align & TEXT_ALIGNMASK_HORIZ), TEXT_OBJECT_ACTION_TYPE_NONE);
506                                 }
507                         }
508                         slidingRect.y += slidingRect.height;
509                 }
510         }
511                 break;
512
513         case TEXT_OBJECT_ACTION_TYPE_ABBREV:
514                 if (__pCompositeText->IsTextAbbreviationEnabled())
515                 {
516                         __pCompositeText->DrawAbbrev(canvasImpl, targetBounds, __align);
517                 }
518                 else
519                 {
520                         DrawByLine(canvasImpl, targetBounds);
521                 }
522                 break;
523
524         case TEXT_OBJECT_ACTION_TYPE_NONE:
525                 // fall through
526         default:
527                 DrawByLine(canvasImpl, targetBounds);
528                 break;
529         }
530
531         canvasImpl.SetClipBounds(clipRect);
532         _SetTextBidiHint(bidiHint);
533
534         return E_SUCCESS;
535 }
536
537 result
538 TextObject::GetChangedLineRange(int& startChangedLineIndex, int& endChangedLineIndex)
539 {
540         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
541
542         result r = E_SUCCESS;
543
544         r = Compose();
545         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
546
547         startChangedLineIndex = __sweepInfo.sweepRegionStartLineIndex;
548         endChangedLineIndex =  __sweepInfo.sweepRegionStartLineIndex + __sweepInfo.sweepRegionLineCount - 1;
549
550         return E_SUCCESS;
551 }
552
553 result
554 TextObject::DrawLine(_CanvasImpl& canvasImpl, int lineIndex)
555 {
556         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
557
558         SysTryReturn(NID_GRP, lineIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
559
560         result r = E_SUCCESS;
561         TextLine* pTextLine = null;
562         FloatRectangle lineBounds;
563         float firstDisplayY = __pTextColumn->GetFirstDisplayPositionYF();
564
565         TextBidiHint bidiHint = _GetTextBidiHint();
566         _SetTextBidiHint(__bidiHint);
567
568         r = Compose();
569         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
570
571         pTextLine = __pTextColumn->GetTextLine(lineIndex);
572         if (pTextLine == null)
573         {
574                 SysLog(NID_GRP, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d, total line count = %d)"
575                                 , lineIndex, __pTextColumn->GetTotalLineCount());
576
577                 return E_INVALID_ARG;
578         }
579
580         lineBounds = pTextLine->GetBoundsF();
581         lineBounds.y = lineBounds.y - firstDisplayY + __rect.y;
582
583         int length = pTextLine->GetTextLength();
584         pTextLine->Draw(canvasImpl, lineBounds, 0, length, __align, TEXT_OBJECT_ACTION_TYPE_NONE);
585
586         _SetTextBidiHint(bidiHint);
587
588         return E_SUCCESS;
589 }
590
591 result
592 TextObject::DrawWithOffset(_CanvasImpl& canvasImpl)
593 {
594         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
595
596         SysTryReturn(NID_GRP, __isActionOn, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Action is off.");
597
598         float slidingStartIndex = __pTextColumn->GetSlidingPositionF();
599         FloatDimension slidingDim = __pTextColumn->GetSlidingDimensionF();
600
601         switch (__action)
602         {
603         case TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT:
604                 if (__rect.width < slidingDim.width)
605                 {
606                         slidingDim.width = (slidingDim.width > __rect.width) ? slidingDim.width: __rect.width;
607
608                         if (__slidingStep < slidingStartIndex + slidingDim.width + __slidingGap)
609                         {
610                                 slidingStartIndex -= __slidingStep;
611                         }
612                         else
613                         {
614                                 slidingStartIndex += slidingDim.width + __slidingGap;
615                         }
616                 }
617                 else
618                 {
619                         if (0.0f < slidingStartIndex + slidingDim.width)
620                         {
621                                 slidingStartIndex -= __slidingStep;
622                         }
623                         else
624                         {
625                                 slidingStartIndex = __rect.width + __slidingGap + slidingStartIndex;
626                         }
627                 }
628                 __pTextColumn->SetSlidingPosition(slidingStartIndex);
629                 break;
630
631         case TEXT_OBJECT_ACTION_TYPE_SLIDE_UP:
632                 if (slidingStartIndex + slidingDim.height >= 0.0f)
633                 {
634                         slidingStartIndex -= __slidingStep;
635                 }
636                 else
637                 {
638                         slidingStartIndex = __rect.height;
639                 }
640                 __pTextColumn->SetSlidingPosition(slidingStartIndex);
641                 break;
642
643         case TEXT_OBJECT_ACTION_TYPE_ABBREV:
644                 // fall through
645         case TEXT_OBJECT_ACTION_TYPE_NONE:
646                 // fall through
647         default:
648                 break;
649         }
650
651         return Draw(canvasImpl);
652 }
653
654 result
655 TextObject::UpdateChangedInfo(int startTextIndex, int textLength)
656 {
657         result r = E_SUCCESS;
658
659         if (startTextIndex >= 0)
660         {
661                 r = __pTextColumn->SetChangeAction(TextColumn::TEXT_CHANGE_UNKONWN, startTextIndex, 0);
662                 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
663         }
664
665         __isChanged = true;
666
667         if (IsPartialComposingModeEnabled())
668         {
669                 __pCompositeText->InitPartialComposeMode();
670         }
671
672         return E_SUCCESS;
673 }
674
675 bool
676 TextObject::IsChanged(void) const
677 {
678         IF_NOT_CONSTRUCTED(return false);
679
680         return __isChanged;
681 }
682
683 result
684 TextObject::SetPartialComposingModeEnabled(bool enable)
685 {
686         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
687
688         __pCompositeText->SetPartialComposingModeEnabled(enable);
689
690         return E_SUCCESS;
691 }
692
693 bool
694 TextObject::IsPartialComposingModeEnabled(void) const
695 {
696         IF_NOT_CONSTRUCTED(return false);
697
698         return __pCompositeText->IsPartialComposingModeEnabled();
699 }
700
701 result
702 TextObject::Compose(void)
703 {
704         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
705
706         SysTryReturn(NID_GRP, __rect.width >= 0.0f && __rect.height >= 0.0f, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet.");
707
708         TextBidiHint bidiHint = _GetTextBidiHint();
709         _SetTextBidiHint(__bidiHint);
710
711         int lineCount = 0;
712         FloatRectangle rect = __rect;
713         FloatRectangle lineBounds;
714
715         if (__pCompositeText->IsPartialComposingModeEnabled())
716         {
717                 if (__pCompositeText->IsComposeDone() || !__isFirstDisplayPositionYChanged)
718                 {
719                         if (GetTotalLineCount() != 0)
720                         {
721                                 return E_SUCCESS;
722                         }
723                 }
724         }
725         else
726         {
727                 if (!__isChanged || __pTextColumn->GetChangeActionEventCount() == 0)
728                 {
729                         return E_SUCCESS;
730                 }
731         }
732
733         __isActionOn = false;
734
735         if (__pTextColumn->GetTotalLineCount() == 0)
736         {
737                 __pTextColumn->SetChangeAction(TextColumn::TEXT_CHANGE_UNKONWN, 0, 0);
738                 __pTextColumn->SetFirstDisplayLineIndex(0);
739                 __pTextColumn->SetFirstDisplayPositionY(0.0f);
740         }
741
742         ResetSweepInfo();
743         lineCount = __pCompositeText->Compose(rect, __pTextColumn);
744
745         switch (__action)
746         {
747         case TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT:
748         {
749                 TextLine* pTextLine = __pTextColumn->GetTextLine(0);
750                 if (pTextLine != null)
751                 {
752                         int lineLength = pTextLine->GetTextLength();
753                         int totalLength = __pCompositeText->GetTextLength();
754
755                         if (lineLength < totalLength)
756                         {
757                                 __isActionOn = true;
758                                 __pTextColumn->SetSlidingPosition(0.0f);
759
760                                 FloatDimension slidingDim;
761                                 FloatDimension lineTextSize;
762
763                                 __pCompositeText->GetRegion(0, totalLength, slidingDim.width, slidingDim.height);
764                                 pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
765                                 lineBounds = pTextLine->GetBoundsF();
766
767                                 __pTextColumn->SetSlidingDimension(slidingDim);
768
769                                 lineBounds.height = slidingDim.height;
770                                 lineTextSize.width = lineBounds.width;
771
772                                 pTextLine->SetBounds(lineBounds);
773                                 pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
774                         }
775                 }
776         }
777         break;
778
779         case TEXT_OBJECT_ACTION_TYPE_SLIDE_UP:
780         {
781                 __pTextColumn->SetSlidingPosition(0.0f);
782
783                 float totalHeight = __pTextColumn->GetTotalHeightF();
784                 FloatDimension slidingDim;
785                 slidingDim.width = __rect.width;
786                 slidingDim.height = totalHeight;
787
788                 __pTextColumn->SetSlidingDimension(slidingDim);
789
790                 if (__rect.height < totalHeight)
791                 {
792                         __isActionOn = true;
793                 }
794         }
795         break;
796
797         case TEXT_OBJECT_ACTION_TYPE_ABBREV:
798                 // fall through
799         case TEXT_OBJECT_ACTION_TYPE_NONE:
800                 // fall through
801         default:
802                 break;
803         }
804
805         __isChanged = false;
806
807         _SetTextBidiHint(bidiHint);
808
809         return E_SUCCESS;
810 }
811
812 int
813 TextObject::GetText(wchar_t* pCopiedText, int textLength) const
814 {
815         IF_NOT_CONSTRUCTED(return -1);
816
817         SysTryReturn(NID_GRP, pCopiedText, -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
818         SysTryReturn(NID_GRP, textLength > 0, -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
819
820         int textElementCount = 0;
821         int totalLength = 0;
822         int outLength = textLength;
823         int copiedLength = 0;
824         TextElement* pTextElement = null;
825         wchar_t* pSrcText = null;
826         wchar_t* pDstText = null;
827
828         textElementCount = __pCompositeText->GetElementCount();
829         pDstText = pCopiedText;
830
831         for (int i = 0; i < textElementCount && totalLength < outLength; i++)
832         {
833                 pTextElement = __pCompositeText->GetElementAtElementIndex(i);
834                 if (pTextElement == null)
835                 {
836                         return totalLength;
837                 }
838
839                 TextElementType objectType = pTextElement->GetType();
840                 if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK)
841                 {
842                         int elementTextLength = pTextElement->GetTextLength();
843                         TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
844                         if (pSimpleText != null)
845                         {
846                                 copiedLength = (elementTextLength > outLength - totalLength) ? outLength - totalLength : elementTextLength;
847                                 SysTryReturn(NID_GRP, 0 <= copiedLength, -1, E_SYSTEM, "[E_SYSTEM] Fail to string copy.");
848
849                                 pSrcText = (wchar_t*)pSimpleText->GetText();
850
851                                 result r = TextUtility::CopyText(pDstText, pSrcText, copiedLength);
852                                 SysTryReturn(NID_GRP, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
853
854                                 pDstText += copiedLength;
855                                 totalLength += copiedLength;
856                         }
857                 }
858         }
859
860         SetLastResult(E_SUCCESS);
861
862         return totalLength;
863 }
864
865 result
866 TextObject::SetFirstDisplayLineIndex(int lineIndex)
867 {
868         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
869
870         if (lineIndex == 0 && __pTextColumn->GetTotalLineCount() == 0)
871         {
872                 return E_SUCCESS;
873         }
874
875         result r = E_SUCCESS;
876         FloatRectangle lineBounds;
877         TextLine* pTextLine = null;
878         float firstDisplayPositionY = 0.0f;
879         float rollbackFirstDisplayPositionY = 0.0f;
880         int rollbackFirstDisplayLineIndex = 0;
881
882         rollbackFirstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
883         rollbackFirstDisplayLineIndex = __pTextColumn->GetFirstDisplayLineIndex();
884
885         __pTextColumn->SetFirstDisplayLineIndex(lineIndex);
886
887         pTextLine = __pTextColumn->GetTextLine(lineIndex);
888         SysTryCatch(NID_GRP, pTextLine, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
889
890         lineBounds = pTextLine->GetBoundsF();
891         firstDisplayPositionY = lineBounds.y;
892
893         __pTextColumn->SetFirstDisplayPositionY(firstDisplayPositionY);
894
895         return E_SUCCESS;
896
897 CATCH:
898         __pTextColumn->SetFirstDisplayLineIndex(rollbackFirstDisplayLineIndex);
899         __pTextColumn->SetFirstDisplayPositionY(rollbackFirstDisplayPositionY);
900
901         return r;
902 }
903
904 result
905 TextObject::SetFirstDisplayPositionY(int y)
906 {
907         return SetFirstDisplayPositionY(_CoordinateSystemUtils::ConvertToFloat(y));
908 }
909
910 result
911 TextObject::SetFirstDisplayPositionY(float y)
912 {
913         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
914
915         result r = E_SUCCESS;
916
917         if (IsPartialComposingModeEnabled())
918         {
919                 __isFirstDisplayPositionYChanged = true;
920
921                 if (__pCompositeText->GetTotalComposedHeight() <= (y + __rect.height))
922                 {
923                         __pCompositeText->SetComposePartialLimitHeight(y + __rect.height - GetTotalComposedHeight());
924
925                         r = Compose();
926                         SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
927                 }
928         }
929
930         __isFirstDisplayPositionYChanged = false;
931         __pTextColumn->SetFirstDisplayPositionY(y);
932
933         return E_SUCCESS;
934
935 CATCH:
936         __isFirstDisplayPositionYChanged = false;
937         return r;
938 }
939
940 int
941 TextObject::GetMaxLineHeight(void) const
942 {
943         return _CoordinateSystemUtils::ConvertToInteger(GetMaxLineHeightF());
944 }
945
946 float
947 TextObject::GetMaxLineHeightF(void) const
948 {
949         IF_NOT_CONSTRUCTED(return -1);
950
951         float lineMaxHeight = __pCompositeText->GetMaxLineHeightF();
952         float fontMaxHeight = TextUtility::GetFontMaxHeightF(__pDefaultFont);
953
954         return (lineMaxHeight > fontMaxHeight) ? lineMaxHeight: fontMaxHeight;
955 }
956
957 bool
958 TextObject::IsDisplayedAtStartPosition(void) const
959 {
960         IF_NOT_CONSTRUCTED(return false);
961
962         float firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
963
964         bool isDisplayedAtStartPosition = (firstDisplayPositionY == 0.0f) ? true : false;
965
966         return isDisplayedAtStartPosition;
967 }
968
969 bool
970 TextObject::IsDisplayedAtEndPosition(void) const
971 {
972         IF_NOT_CONSTRUCTED(return false);
973
974         float totalHeight = 0.0f;
975         float firstDisplayPositionY = 0.0f;
976
977         firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
978         totalHeight = __pTextColumn->GetTotalHeightF();
979
980         bool isDisplayedAtEndPosition = ((totalHeight - firstDisplayPositionY) <= __rect.height) ? true : false;
981
982         return isDisplayedAtEndPosition;
983 }
984
985 bool
986 TextObject::IsDisplayedFirstLine(void) const
987 {
988         IF_NOT_CONSTRUCTED(return false);
989
990         float firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
991         float firstLineHeight = GetLineHeightAtF(0);
992
993         bool isDisplayedFirstLine = false;
994         if(firstDisplayPositionY == 0.0f || firstDisplayPositionY < firstLineHeight)
995         {
996                 isDisplayedFirstLine = true;
997         }
998
999         return isDisplayedFirstLine;
1000 }
1001
1002 bool
1003 TextObject::IsDisplayedLastLine(void) const
1004 {
1005         IF_NOT_CONSTRUCTED(return false);
1006
1007         float totalHeight = 0.0f;
1008         float firstDisplayPositionY = 0.0f;
1009         bool isDisplayedLastLine = false;
1010
1011         firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
1012         totalHeight = __pTextColumn->GetTotalHeightF();
1013
1014         float lastLineHeight = GetLineHeightAtF(GetTotalLineCount()-1);
1015
1016         float remainingHeight = totalHeight - firstDisplayPositionY;
1017         if (remainingHeight - __rect.height < lastLineHeight || remainingHeight <= __rect.height)
1018         {
1019                 isDisplayedLastLine = true;
1020         }
1021
1022         return isDisplayedLastLine;
1023 }
1024
1025 result
1026 TextObject::SetAction(TextObjectActionType action)
1027 {
1028         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1029
1030         SysTryReturn(NID_GRP, TEXT_OBJECT_ACTION_TYPE_NONE <= action && action < TEXT_OBJECT_ACTION_TYPE_MAX
1031                 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1032
1033         if (__action != action)
1034         {
1035                 if ((__action == TEXT_OBJECT_ACTION_TYPE_NONE && action == TEXT_OBJECT_ACTION_TYPE_ABBREV) ||
1036                         (__action == TEXT_OBJECT_ACTION_TYPE_ABBREV && action == TEXT_OBJECT_ACTION_TYPE_NONE))
1037                 {
1038                         __action = action;
1039                         UpdateChangedInfo(0, 0);
1040                 }
1041                 else
1042                 {
1043                         __action = action;
1044                         UpdateChangedInfo(0, 0);
1045                 }
1046         }
1047
1048         bool isAbbreviationEnable = (__action == TEXT_OBJECT_ACTION_TYPE_ABBREV) ? true : false;
1049         __pCompositeText->SetTextAbbreviationEnabled(isAbbreviationEnable);
1050
1051         return E_SUCCESS;
1052 }
1053
1054 result
1055 TextObject::SetAlignment(TextObjectAlignment alignment)
1056 {
1057         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1058
1059         SysTryReturn(NID_GRP, TEXT_OBJECT_ALIGNMENT_LEFT <= alignment && alignment < TEXT_OBJECT_ALIGNMENT_INVALID
1060                 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. alignment(%d)", alignment);
1061
1062         if (__align != alignment)
1063         {
1064                 __align = alignment;
1065                 UpdateChangedInfo(0, 0);
1066         }
1067
1068         return E_SUCCESS;
1069 }
1070
1071 result
1072 TextObject::SetBounds(const Rectangle& rect)
1073 {
1074         return SetBounds(_CoordinateSystemUtils::ConvertToFloat(rect));
1075 }
1076
1077 result
1078 TextObject::SetBounds(const FloatRectangle& rect)
1079 {
1080         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1081
1082         SysTryReturn(NID_GRP, (rect.width >= 0.0f) && (rect.height >= 0.0f), E_OUT_OF_RANGE, E_OUT_OF_RANGE
1083                         , "[E_OUT_OF_RANGE] The given rectangle(width:%d,height:%d) is out of range.\n", rect.width, rect.height);
1084
1085         if (__rect.width != rect.width)
1086         {
1087                 UpdateChangedInfo(0, 0);
1088         }
1089
1090         __rect = rect;
1091
1092         return E_SUCCESS;
1093 }
1094
1095 result
1096 TextObject::SetLineSpace(int lineSpacing)
1097 {
1098         return SetLineSpace(_CoordinateSystemUtils::ConvertToFloat(lineSpacing));
1099 }
1100
1101 result
1102 TextObject::SetLineSpace(float lineSpacing)
1103 {
1104         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1105
1106         SysTryReturn(NID_GRP, lineSpacing >= 0.0f, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. lineSpacing(%d)", lineSpacing);
1107
1108         if (__pCompositeText->GetLineSpace() != lineSpacing)
1109         {
1110                 __pCompositeText->SetLineSpace(lineSpacing);
1111                 __isChanged = true;
1112         }
1113
1114         return E_SUCCESS;
1115 }
1116
1117 result
1118 TextObject::SetElementVerticalAlignment(TextObjectAlignment alignment)
1119 {
1120         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1121
1122         SysTryReturn(NID_GRP
1123                         , (alignment & TEXT_OBJECT_ALIGNMENT_TOP) || (alignment & TEXT_OBJECT_ALIGNMENT_MIDDLE) || (alignment & TEXT_OBJECT_ALIGNMENT_BOTTOM) || (alignment & TEXT_OBJECT_ALIGNMENT_BASELINE)
1124                 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. alignment(%d)", alignment);
1125
1126         if (__pCompositeText->GetElementVerticalAlignment() == alignment)
1127         {
1128                 return E_SUCCESS;
1129         }
1130
1131         __pCompositeText->SetElementVerticalAlignment(alignment);
1132         __isChanged = true;
1133
1134         return E_SUCCESS;
1135 }
1136
1137 Dimension
1138 TextObject::GetTextExtent(int startTextIndex, int textLength) const
1139 {
1140         return _CoordinateSystemUtils::ConvertToInteger(GetTextExtentF(startTextIndex,textLength));
1141 }
1142
1143 FloatDimension
1144 TextObject::GetTextExtentF(int startTextIndex, int textLength) const
1145 {
1146         IF_NOT_CONSTRUCTED(return FloatDimension(-1, -1));
1147
1148         TextBidiHint bidiHint = _GetTextBidiHint();
1149         _SetTextBidiHint(__bidiHint);
1150
1151         FloatDimension textSize;
1152         result r = __pCompositeText->GetRegion(startTextIndex, textLength, textSize.width, textSize.height);
1153         SysTryReturn(NID_GRP, r == E_SUCCESS, FloatDimension(-1, -1), r, "[%s] Propagating.", GetErrorMessage(r));
1154
1155         _SetTextBidiHint(bidiHint);
1156
1157         SetLastResult(E_SUCCESS);
1158
1159         return textSize;
1160 }
1161
1162 Dimension
1163 TextObject::GetTextExtent(void) const
1164 {
1165         return _CoordinateSystemUtils::ConvertToInteger(GetTextExtentF());
1166 }
1167
1168 FloatDimension
1169 TextObject::GetTextExtentF(void) const
1170 {
1171         IF_NOT_CONSTRUCTED(return FloatDimension(-1, -1));
1172
1173         TextBidiHint bidiHint = _GetTextBidiHint();
1174         _SetTextBidiHint(__bidiHint);
1175
1176         TextLine* pTextLine = null;
1177         FloatDimension textSize(0.0f, 0.0f);
1178         FloatDimension lineSize(0.0f, 0.0f);
1179         int lineCount = GetTotalLineCount();
1180
1181         for (int i = 0; i < lineCount; i++)
1182         {
1183                 pTextLine = __pTextColumn->GetTextLine(i);
1184                 SysTryReturn(NID_GRP, pTextLine, FloatDimension(-1, -1), E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
1185
1186                 pTextLine->GetRegion(0, pTextLine->GetTextLength(), lineSize.width, lineSize.height);
1187
1188                 if (textSize.width < lineSize.width)
1189                 {
1190                         textSize.width = lineSize.width;
1191                 }
1192         }
1193
1194         textSize.height = GetTotalHeightF();
1195
1196         _SetTextBidiHint(bidiHint);
1197
1198         SetLastResult(E_SUCCESS);
1199
1200         return textSize;
1201 }
1202
1203 result
1204 TextObject::AppendElement(TextElement& textElement)
1205 {
1206         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1207
1208         result r = E_SUCCESS;
1209         TextElementType objecType = textElement.GetType();
1210         if (objecType == TEXT_ELEMENT_TYPE_CUTLINK)
1211         {
1212                 TextCutLink* pLinkText = dynamic_cast < TextCutLink* >(&textElement);
1213                 if (pLinkText != null)
1214                 {
1215                         switch (pLinkText->GetCutLinkType())
1216                         {
1217                         case LINK_TYPE_URL:
1218                                 if (__isUrlLinkColorDefined)
1219                                 {
1220                                         pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_NORMAL], __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_SELECT]);
1221                                 }
1222                                 break;
1223
1224                         case LINK_TYPE_EMAIL:
1225                                 if (__isEmailLinkColorDefined)
1226                                 {
1227                                         pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_NORMAL], __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_SELECT]);
1228                                 }
1229                                 break;
1230
1231                         case LINK_TYPE_TEL_NUM:
1232                                 if (__isPhoneNumberLinkColorDefined)
1233                                 {
1234                                         pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_NORMAL],
1235                                                         __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_SELECT]);
1236                                 }
1237                                 break;
1238
1239                         default:
1240                                 break;
1241                         }
1242                 }
1243         }
1244
1245         int textIndex = __pCompositeText->GetTextLength();
1246         int elementTextLength = textElement.GetTextLength();
1247
1248         r = __pCompositeText->AppendElement(textElement);
1249         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1250
1251         int elementCount = __pCompositeText->GetElementCount();
1252         if (elementCount > 0)
1253         {
1254                 __pCompositeText->Optimize(elementCount-1, elementCount-1);
1255         }
1256
1257         if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
1258         {
1259                 UpdateChangedInfo(0, 0);
1260         }
1261         else
1262         {
1263                 NotifyTextAdded(textIndex, elementTextLength);
1264         }
1265
1266         return r;
1267 }
1268
1269 result
1270 TextObject::InsertElementAt(int textIndex, TextElement& textElement)
1271 {
1272         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1273
1274         result r = E_SUCCESS;
1275         TextElementType objecType = textElement.GetType();
1276
1277         if (objecType == TEXT_ELEMENT_TYPE_CUTLINK)
1278         {
1279                 TextCutLink* pLinkText = dynamic_cast < TextCutLink* >(&textElement);
1280                 if (pLinkText != null)
1281                 {
1282                         switch (pLinkText->GetCutLinkType())
1283                         {
1284                         case LINK_TYPE_URL:
1285                                 if (__isUrlLinkColorDefined)
1286                                 {
1287                                         pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_NORMAL],
1288                                                         __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_SELECT]);
1289                                 }
1290                                 break;
1291
1292                         case LINK_TYPE_EMAIL:
1293                                 if (__isEmailLinkColorDefined)
1294                                 {
1295                                         pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_NORMAL],
1296                                                         __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_SELECT]);
1297                                 }
1298                                 break;
1299
1300                         case LINK_TYPE_TEL_NUM:
1301                                 if (__isPhoneNumberLinkColorDefined)
1302                                 {
1303                                         pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_NORMAL],
1304                                                         __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_SELECT]);
1305                                 }
1306                                 break;
1307
1308                         default:
1309                                 break;
1310                         }
1311                 }
1312         }
1313
1314         r = __pCompositeText->InsertElementAt(textElement, textIndex);
1315         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Fail to insert element.", GetErrorMessage(r));
1316
1317         int elementIndex = __pCompositeText->GetElementIndexOf(textElement);
1318         if (elementIndex != -1)
1319         {
1320                 __pCompositeText->Optimize(elementIndex, elementIndex);
1321         }
1322
1323         if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
1324         {
1325                 UpdateChangedInfo(0, 0);
1326         }
1327         else
1328         {
1329                 NotifyTextAdded(textIndex, textElement.GetTextLength());
1330         }
1331
1332         return r;
1333 }
1334
1335 result
1336 TextObject::RemoveAll(bool deallocate)
1337 {
1338         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1339
1340         result r = __pTextColumn->RemoveAllLines();
1341         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1342
1343         r = __pCompositeText->RemoveAllElements(deallocate);
1344         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1345
1346         UpdateChangedInfo(0);
1347
1348         __isActionOn = false;
1349
1350         return r;
1351 }
1352
1353 result
1354 TextObject::Remove(int startTextIndex, int textLength)
1355 {
1356         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1357
1358         SysTryReturn(NID_GRP, startTextIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1359
1360         result r = __pTextColumn->RemoveAllLines();
1361         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1362
1363         r = __pCompositeText->Remove(startTextIndex, textLength);
1364         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1365
1366         UpdateChangedInfo(0);
1367
1368         return r;
1369 }
1370
1371 result
1372 TextObject::RemoveElement(TextElement& textElement, bool deallocate)
1373 {
1374         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1375
1376         result r = E_SUCCESS;
1377         int elementIndex = 0;
1378         int textIndex = 0;
1379         int elementTextLength = 0;
1380         TextElement* pCurrentTextElement = null;
1381
1382         elementIndex = __pCompositeText->GetElementIndexOf(textElement);
1383         SysTryReturn(NID_GRP, 0 <= elementIndex, E_INVALID_ARG, E_INVALID_ARG, "[E_SYSTEM] The argument is invalid.");
1384
1385         for (int i = 0; i < elementIndex; i++)
1386         {
1387                 pCurrentTextElement = __pCompositeText->GetElementAtElementIndex(i);
1388                 if (pCurrentTextElement != null)
1389                 {
1390                         textIndex += pCurrentTextElement->GetTextLength();
1391                 }
1392         }
1393
1394         elementTextLength = textElement.GetTextLength();
1395
1396         r = __pCompositeText->RemoveElementAt(elementIndex, deallocate);
1397         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1398
1399         NotifyTextDeleted(textIndex, elementTextLength);
1400
1401         if (__pCompositeText->GetElementCount() == 0 || GetTextLength() == 0)
1402         {
1403                 __pTextColumn->RemoveAllLines();
1404         }
1405
1406         return r;
1407 }
1408
1409 TextElement*
1410 TextObject::GetElementAtTextIndex(int textIndex) const
1411 {
1412         IF_NOT_CONSTRUCTED(return null);
1413
1414         TextElement* pTextElement = null;
1415         int elementTextLength = 0;
1416         int textIndexFromElementOffset = 0;
1417         int elementIndex = 0;
1418         int elementOffset = 0;
1419
1420         pTextElement = __pCompositeText->GetElementAtTextIndex(textIndex, elementOffset, elementIndex, elementTextLength,textIndexFromElementOffset);
1421         SysTryCatch(NID_GRP, pTextElement, , E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
1422
1423         SetLastResult(E_SUCCESS);
1424         return pTextElement;
1425
1426 CATCH:
1427         elementOffset = 0;
1428         elementIndex = 0;
1429         return null;
1430 }
1431
1432 result
1433 TextObject::SetFont(Font* pFont, int startTextIndex, int textLength)
1434 {
1435         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1436
1437         SysTryReturn(NID_GRP, pFont, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1438         SysTryReturn(NID_GRP, startTextIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1439
1440         result r = E_SUCCESS;
1441         Font* pTmpFont = null;
1442
1443         pTmpFont = _FontImpl::CloneN(const_cast < Font& >(*pFont));
1444         r = GetLastResult();
1445         SysTryReturn(NID_GRP, pTmpFont, r, r, "[%s] Propagating.", GetErrorMessage(r));
1446
1447         Release(__pDefaultFont);
1448
1449         __pDefaultFont = pTmpFont;
1450
1451         __pCompositeText->SetRange(startTextIndex, textLength);
1452         r = __pCompositeText->SetFont(__pDefaultFont);
1453         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1454
1455         UpdateChangedInfo(__pCompositeText->GetWorkStart(), 0);
1456
1457         return E_SUCCESS;
1458 }
1459
1460 const Font*
1461 TextObject::GetFont(int textIndex) const
1462 {
1463         IF_NOT_CONSTRUCTED(return null);
1464
1465         Font* pFont = __pCompositeText->GetFont(textIndex);
1466         if (pFont == null)
1467         {
1468                 pFont = __pDefaultFont;
1469         }
1470
1471         SetLastResult(E_SUCCESS);
1472         return pFont;
1473 }
1474
1475 result
1476 TextObject::SetDefaultFontSize(int size)
1477 {
1478         return SetDefaultFontSize(_CoordinateSystemUtils::ConvertToFloat(size));
1479 }
1480
1481 result
1482 TextObject::SetDefaultFontSize(float size)
1483 {
1484         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1485
1486         _FontImpl::GetInstance(*__pDefaultFont)->SetSize(size);
1487
1488         return E_SUCCESS;
1489 }
1490
1491 int
1492 TextObject::GetDefaultFontSize(void) const
1493 {
1494         return _CoordinateSystemUtils::ConvertToInteger(GetDefaultFontSizeF());
1495 }
1496
1497 float
1498 TextObject::GetDefaultFontSizeF(void) const
1499 {
1500         IF_NOT_CONSTRUCTED(return -1);
1501
1502         return _FontImpl::GetInstance(*__pDefaultFont)->GetSizeF();
1503 }
1504
1505 result
1506 TextObject::SetFontSize(int size, int startTextIndex, int textLength)
1507 {
1508         return SetFontSize(_CoordinateSystemUtils::ConvertToFloat(size), startTextIndex, textLength);
1509 }
1510
1511 result
1512 TextObject::SetFontSize(float size, int startTextIndex, int textLength)
1513 {
1514         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1515
1516         SysTryReturn(NID_GRP
1517                 , startTextIndex >= 0
1518                 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1519
1520         __pCompositeText->SetRange(startTextIndex, textLength);
1521         __pCompositeText->SetFontSize(size);
1522         UpdateChangedInfo(0, 0);
1523
1524         return E_SUCCESS;
1525 }
1526
1527 int
1528 TextObject::GetFontSize(int textIndex) const
1529 {
1530         return _CoordinateSystemUtils::ConvertToInteger(GetFontSizeF(textIndex));
1531 }
1532
1533 float
1534 TextObject::GetFontSizeF(int textIndex) const
1535 {
1536         IF_NOT_CONSTRUCTED(return -1);
1537
1538         SysTryReturn(NID_GRP
1539                 , textIndex >= 0
1540                 , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1541
1542         return __pCompositeText->GetFontSizeF(textIndex);
1543 }
1544
1545 result
1546 TextObject::SetDefaultFontStyle(int style)
1547 {
1548         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1549
1550         _FontImpl::GetInstance(*__pDefaultFont)->SetStyle(style);
1551
1552         return E_SUCCESS;
1553 }
1554
1555 int
1556 TextObject::GetDefaultFontStyle(void) const
1557 {
1558         IF_NOT_CONSTRUCTED(return FONT_STYLE_MIN);
1559
1560         return _FontImpl::GetInstance(*__pDefaultFont)->GetStyle();
1561 }
1562
1563 result
1564 TextObject::SetFontStyle(int style, int startTextIndex, int textLength)
1565 {
1566         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1567
1568         SysTryReturn(NID_GRP
1569                 , startTextIndex >= 0
1570                 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1571
1572         __pCompositeText->SetRange(startTextIndex, textLength);
1573         __pCompositeText->SetFontStyle(style);
1574         UpdateChangedInfo(0, 0);
1575
1576         return E_SUCCESS;
1577 }
1578
1579 int
1580 TextObject::GetFontStyle(int textIndex) const
1581 {
1582         IF_NOT_CONSTRUCTED(return -1);
1583
1584         SysTryReturn(NID_GRP
1585                 , textIndex >= 0
1586                 , FONT_STYLE_MIN, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1587
1588         return __pCompositeText->GetFontStyle(textIndex);
1589 }
1590
1591 result
1592 TextObject::SetDefaultForegroundColor(const Color& color)
1593 {
1594         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1595
1596         __defaultForegroundColor = color;
1597
1598         return E_SUCCESS;
1599 }
1600
1601 Color
1602 TextObject::GetDefaultForegroundColor(void) const
1603 {
1604         IF_NOT_CONSTRUCTED(return Color::GetColor(COLOR_ID_BLACK));
1605
1606         return __defaultForegroundColor;
1607 }
1608
1609 result
1610 TextObject::SetForegroundColor(const Color& color, int startTextIndex, int textLength)
1611 {
1612         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1613
1614         SysTryReturn(NID_GRP, startTextIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1615
1616         __defaultForegroundColor = color;
1617
1618         __pCompositeText->SetRange(startTextIndex, textLength);
1619         __pCompositeText->SetForegroundColor(color);
1620
1621         return E_SUCCESS;
1622 }
1623
1624 Color
1625 TextObject::GetForegroundColor(int textIndex) const
1626 {
1627         IF_NOT_CONSTRUCTED(return Color::GetColor(COLOR_ID_BLACK));
1628
1629         SysTryReturn(NID_GRP, textIndex >= 0, __defaultForegroundColor, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1630
1631         return __pCompositeText->GetForegroundColor(textIndex);
1632 }
1633
1634 result
1635 TextObject::SetBackgroundColor(const Color& color, int startTextIndex, int textLength)
1636 {
1637         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1638
1639         SysTryReturn(NID_GRP, startTextIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1640
1641         __defaultBackgroundColor = color;
1642
1643         __pCompositeText->SetRange(startTextIndex, textLength);
1644         __pCompositeText->SetBackgroundColor(color);
1645
1646         return E_SUCCESS;
1647 }
1648
1649 Color
1650 TextObject::GetBackgroundColor(int textIndex) const
1651 {
1652         IF_NOT_CONSTRUCTED(return Color::GetColor(COLOR_ID_BLACK));
1653
1654         SysTryReturn(NID_GRP, textIndex >= 0, __defaultBackgroundColor, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1655
1656         return __pCompositeText->GetBackgroundColor(textIndex);
1657 }
1658
1659 result
1660 TextObject::SetOutlineColor(const Color& color, int startTextIndex, int textLength)
1661 {
1662         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1663
1664         SysTryReturn(NID_GRP, startTextIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1665
1666         __defaultOutlineColor = color;
1667
1668         __pCompositeText->SetRange(startTextIndex, textLength);
1669         __pCompositeText->SetOutlineColor(color);
1670
1671         return E_SUCCESS;
1672 }
1673
1674 Color
1675 TextObject::GetOutlineColor(int textIndex) const
1676 {
1677         IF_NOT_CONSTRUCTED(return Color::GetColor(COLOR_ID_BLACK));
1678
1679         SysTryReturn(NID_GRP, textIndex >= 0, __defaultOutlineColor, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1680
1681         return __pCompositeText->GetOutlineColor(textIndex);
1682 }
1683
1684 result
1685 TextObject::SetBlockColor(const Color& color)
1686 {
1687         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1688
1689         __pCompositeText->SetBlockColor(color);
1690
1691         return E_SUCCESS;
1692 }
1693
1694 Color
1695 TextObject::GetBlockColor(void) const
1696 {
1697         IF_NOT_CONSTRUCTED(return Color::GetColor(COLOR_ID_BLACK));
1698
1699         return __pCompositeText->GetBlockColor();
1700 }
1701
1702 result
1703 TextObject::SetDisplayBitmap(const Bitmap* pBitmap, int startTextIndex, int textLength)
1704 {
1705         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1706
1707         SysTryReturn(NID_GRP, startTextIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1708
1709         __pCompositeText->SetRange(startTextIndex, textLength);
1710         __pCompositeText->SetDisplayBitmap(pBitmap);
1711         UpdateChangedInfo(0, 0);
1712
1713         return E_SUCCESS;
1714 }
1715
1716 const Bitmap*
1717 TextObject::GetDisplayBitmap(int textIndex) const
1718 {
1719         IF_NOT_CONSTRUCTED(return null);
1720
1721         return __pCompositeText->GetDisplayBitmap(textIndex);
1722 }
1723
1724 result
1725 TextObject::SetWrap(TextObjectWrapType wrap)
1726 {
1727         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1728
1729         if (__wrap == wrap)
1730         {
1731                 return E_SUCCESS;
1732         }
1733
1734         result r = __pCompositeText->SetWrap(wrap);
1735         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1736
1737         __wrap = wrap;
1738         UpdateChangedInfo(0, 0);
1739
1740         return E_SUCCESS;
1741 }
1742
1743 result
1744 TextObject::InsertElementAt(int textIndex, Bitmap& bitmap, TextElementSourceType sourceType)
1745 {
1746         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1747
1748         TextImage* pImageText = new (std::nothrow)TextImage(bitmap, sourceType, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP));
1749         SysTryReturn(NID_GRP, pImageText, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
1750
1751         int addedTextLength = pImageText->GetTextLength();
1752         __pCompositeText->InsertElementAt(*pImageText, textIndex);
1753         int startTextIndex = __pCompositeText->GetWorkStart();
1754         NotifyTextAdded(startTextIndex, addedTextLength);
1755
1756         return E_SUCCESS;
1757 }
1758
1759 result
1760 TextObject::AppendElement(Bitmap& bitmap, TextElementSourceType sourceType)
1761 {
1762         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1763
1764         result r = E_SUCCESS;
1765         TextImage* pImageText = new (std::nothrow)TextImage(bitmap, sourceType, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP));
1766         SysTryReturn(NID_GRP, pImageText, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
1767
1768         r = __pCompositeText->AppendElement(*pImageText);
1769         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1770
1771         int startTextIndex = __pCompositeText->GetWorkStart();
1772         int elementTextLength = pImageText->GetTextLength();
1773
1774         NotifyTextAdded(startTextIndex, elementTextLength);
1775
1776         return E_SUCCESS;
1777 }
1778
1779 result
1780 TextObject::SetAlternateLookEnabled(bool enable)
1781 {
1782         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1783
1784         TextElement* pTextElement = null;
1785
1786         __isAlternateLookEnabled = enable;
1787         int elementCount = __pCompositeText->GetElementCount();
1788
1789         for (int i = 0; i < elementCount; i++)
1790         {
1791                 pTextElement = __pCompositeText->GetElementAtElementIndex(i);
1792                 if (pTextElement != null)
1793                 {
1794                         pTextElement->SetAlternateLookEnabled(enable);
1795                 }
1796         }
1797
1798         return E_SUCCESS;
1799 }
1800
1801 result
1802 TextObject::SetAlternativeForegroundColor(const Color& color)
1803 {
1804         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1805
1806         TextElement* pTextElement = null;
1807         int elementCount = __pCompositeText->GetElementCount();
1808
1809         for (int i = 0; i < elementCount; i++)
1810         {
1811                 pTextElement = __pCompositeText->GetElementAtElementIndex(i);
1812                 SysTryReturn(NID_GRP, pTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
1813
1814                 pTextElement->SetAlternativeForegroundColor(color);
1815         }
1816
1817         return E_SUCCESS;
1818 }
1819
1820 result
1821 TextObject::ChangeTextOffset(wchar_t* pText, int textIndex, int gap)
1822 {
1823         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1824
1825         result r = E_SUCCESS;
1826         int elementStartTextIndex = 0;
1827         int elementIndex = 0;
1828         int elementTextLength = 0;
1829         int textIndexFromElementOffset = 0;
1830
1831         TextElement* pTextElement = __pCompositeText->GetElementAtTextIndex(textIndex, elementStartTextIndex,
1832                         elementIndex, elementTextLength, textIndexFromElementOffset);
1833
1834         SysTryReturn(NID_GRP, pTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
1835
1836         r = __pCompositeText->ChangeTextOffset(pText, elementIndex, gap);
1837         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1838
1839         return E_SUCCESS;
1840 }
1841
1842 result
1843 TextObject::NotifyTextChanged(wchar_t* pText, int textOffset, int textLength, int gap)
1844 {
1845         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
1846
1847         result r = E_SUCCESS;
1848         int startTextIndex = __pCompositeText->GetWorkStart();
1849         r = __pCompositeText->NotifyTextChanged(pText, textOffset, textLength, gap, __pDefaultFont,
1850                                                                    __defaultForegroundColor, __defaultBackgroundColor, __defaultOutlineColor);
1851
1852         SysTryCatch(NID_GRP, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Fail to update change information.");
1853
1854         if (__wrap != TEXT_OBJECT_WRAP_TYPE_NONE)
1855         {
1856                 if (gap > 0)
1857                 {
1858                         NotifyTextAdded(startTextIndex, gap);
1859                         if (gap == 1)
1860                         {
1861                                 InputText(startTextIndex);
1862                         }
1863                 }
1864                 else if (gap < 0)
1865                 {
1866                         NotifyTextDeleted(startTextIndex, -gap);
1867
1868                         if (gap == -1)
1869                         {
1870                                 RemoveText(startTextIndex);
1871                         }
1872                 }
1873                 else
1874                 {
1875                         UpdateChangedInfo(startTextIndex, 0);
1876
1877                         ChangeText(startTextIndex);
1878                 }
1879         }
1880         else
1881         {
1882                 UpdateChangedInfo(startTextIndex, 0);
1883         }
1884
1885         return E_SUCCESS;
1886
1887 CATCH:
1888         if (__pCompositeText->GetElementCount() == 0)
1889         {
1890                 RemoveAll();
1891                 TextSimple* pSimpleText = new (std::nothrow)TextSimple(pText, textLength, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1892                 AppendElement(*pSimpleText);
1893
1894                 SetCursorIndex(0);
1895                 UpdateChangedInfo(0, 0);
1896         }
1897
1898         return E_SUCCESS;
1899 }
1900
1901 int
1902 TextObject::GetTextIndexFromPosition(int x, int y, bool cursorMode) const
1903 {
1904         return GetTextIndexFromPosition(_CoordinateSystemUtils::ConvertToFloat(x), _CoordinateSystemUtils::ConvertToFloat(y), cursorMode);
1905 }
1906
1907 int
1908 TextObject::GetTextIndexFromPosition(float x, float y, bool cursorMode) const
1909 {
1910         IF_NOT_CONSTRUCTED(return -1);
1911
1912         int lineCount = __pTextColumn->GetTotalLineCount();
1913         if (lineCount <= 0)
1914         {
1915                 return -1;
1916         }
1917
1918         if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
1919         {
1920                 return GetTextIndexFromPositionInNoneWrap(x, y, !cursorMode);
1921         }
1922         else
1923         {
1924                 return GetTextIndexFromPositionInWrap(x, y, !cursorMode);
1925         }
1926 }
1927
1928 int
1929 TextObject::GetTextIndexFromPositionAtLine(int lineIndex, int x, bool cursorMode) const
1930 {
1931         return GetTextIndexFromPositionAtLine(lineIndex, _CoordinateSystemUtils::ConvertToFloat(x), cursorMode);
1932 }
1933
1934 int
1935 TextObject::GetTextIndexFromPositionAtLine(int lineIndex, float x, bool cursorMode) const
1936 {
1937         IF_NOT_CONSTRUCTED(return -1);
1938
1939         SysTryReturn(NID_GRP, lineIndex >= 0, -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
1940
1941         TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex);
1942         SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
1943
1944         int lineOffset = pTextLine->GetTextOffset();
1945         int lineLength = pTextLine->GetTextLength();
1946         int length = 0;
1947         TextElementType objectType;
1948         FloatRectangle lineBounds = pTextLine->GetBoundsF();
1949         FloatDimension lineTextSize;
1950         pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
1951
1952         switch (__align & TEXT_ALIGNMASK_HORIZ)
1953         {
1954         case TEXT_OBJECT_ALIGNMENT_LEFT:
1955                 break;
1956
1957         case TEXT_OBJECT_ALIGNMENT_CENTER:
1958                 x -= (lineBounds.width - lineTextSize.width) / 2.0f;
1959                 break;
1960
1961         case TEXT_OBJECT_ALIGNMENT_RIGHT:
1962                 x -= (lineBounds.width - lineTextSize.width);
1963                 break;
1964         }
1965
1966         x = (x < 0.0f) ? 0.0f : x;
1967         __pCompositeText->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
1968
1969         int endType = 0;
1970
1971         if (cursorMode)
1972         {
1973                 __pCompositeText->ForwardAnalyzeWithFocusedObjectType(lineOffset, lineLength, x, length, objectType);
1974         }
1975         else
1976         {
1977                 endType = __pCompositeText->ForwardAnalyzeInNoneCursorMode(lineOffset, lineLength, x, length);
1978         }
1979
1980         __pCompositeText->SetWrap(__wrap);
1981
1982         if (!cursorMode)
1983         {
1984                 if (endType == -1)
1985                 {
1986                         return -1;
1987                 }
1988         }
1989
1990         int index = pTextLine->GetTextOffset() + length;
1991         if (pTextLine->GetEndType() == TEXT_RETBY_LINEFEED && lineLength == length && pTextLine->GetTextOffset() < index)
1992         {
1993                 index--;
1994         }
1995
1996         if (index != GetTextLength() && index == lineOffset + lineLength)
1997         {
1998                 TextElement* pTextElement = GetElementAtTextIndex(index-1);
1999                 if (pTextElement != null)
2000                 {
2001                         const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pTextElement);
2002                         if (pSimpleText != null)
2003                         {
2004                                 const wchar_t* pText = pSimpleText->GetText();
2005                                 SysTryReturn(NID_GRP, pText, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text.");
2006
2007                                 int i = index - 1 - pSimpleText->GetTextOffset();
2008                                 SysTryReturn(NID_GRP, i >= 0 && i < pSimpleText->GetTextLength(), -1, E_OUT_OF_RANGE
2009                                                 , "[E_OUT_OF_RANGE] text index(%d) must greater than 0 and must be less than total string length(%d)",i, pSimpleText->GetTextLength());
2010
2011                                 if (pText[i] == L' ' || pText[i] == TEXT_JAPANESE_SPACE)
2012                                 {
2013                                         index--;
2014                                 }
2015                         }
2016                 }
2017         }
2018
2019         SetLastResult(E_SUCCESS);
2020
2021         return index;
2022 }
2023
2024 result
2025 TextObject::SetFirstDisplayLineIndexFromTextIndex(int textIndex)
2026 {
2027         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2028
2029         if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
2030         {
2031                 return SetFirstDisplayLineIndexFromTextIndexInNoneWrap(textIndex);
2032         }
2033         else
2034         {
2035                 return SetFirstDisplayLineIndexFromTextIndexInWrap(textIndex);
2036         }
2037 }
2038
2039 result
2040 TextObject::SetCutLinkViewMode(bool enable)
2041 {
2042         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2043
2044         if (__linkViewModeEnabled == enable)
2045         {
2046                 return E_SUCCESS;
2047         }
2048
2049         __linkViewModeEnabled = enable;
2050         return E_SUCCESS;
2051 }
2052
2053 int
2054 TextObject::GetCutLinkIndexFromPositionData(int x, int y) const
2055 {
2056         return GetCutLinkIndexFromPositionData(_CoordinateSystemUtils::ConvertToFloat(x), _CoordinateSystemUtils::ConvertToFloat(y));
2057 }
2058
2059 int
2060 TextObject::GetCutLinkIndexFromPositionData(float x, float y) const
2061 {
2062         IF_NOT_CONSTRUCTED(return -1);
2063
2064         result r = E_SUCCESS;
2065
2066         TextBidiHint bidiHint = _GetTextBidiHint();
2067         _SetTextBidiHint(__bidiHint);
2068
2069         int lineCount = __pTextColumn->GetTotalLineCount();
2070         if (lineCount <= 0)
2071         {
2072                 return -1;
2073         }
2074
2075         int textIndex = 0;
2076
2077         if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
2078         {
2079                 textIndex = GetTextIndexFromPositionInNoneWrap(x, y, false);
2080         }
2081         else
2082         {
2083                 textIndex = GetTextIndexFromPositionInWrap(x, y, false);
2084         }
2085
2086         if (textIndex < 0)
2087         {
2088                 return -1;
2089         }
2090
2091         float width = 0.0f;
2092         float height = 0.0f;
2093         FloatPoint absPoint;
2094         FloatPoint relPoint;
2095
2096         if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
2097         {
2098                 r = GetTextPositionInfoInNoneWrapAt(textIndex, width, height, absPoint.x, absPoint.y, relPoint.x, relPoint.y);
2099         }
2100         else
2101         {
2102                 r = GetTextPositionInfoInWrapAt(textIndex, width, height, absPoint.x, absPoint.y, relPoint.x, relPoint.y);
2103         }
2104         SysTryReturn(NID_GRP, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
2105         SysTryReturn(NID_GRP, y + __rect.y >= relPoint.y, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text position information");
2106
2107         int elementIndex =  __pCompositeText->GetCutLinkElementIndexAt(textIndex);
2108
2109         _SetTextBidiHint(bidiHint);
2110
2111         return elementIndex;
2112 }
2113
2114 TextElement*
2115 TextObject::GetCutLinkElementAtCutLinkElementIndex(int linkIndex) const
2116 {
2117         IF_NOT_CONSTRUCTED(return null);
2118
2119         return __pCompositeText->GetCutLinkElementAtCutLinkElementIndex(linkIndex);
2120 }
2121
2122 result
2123 TextObject::SetCutLinkColor(LinkType linkType, const Color& color, const Color& colorInSelect)
2124 {
2125         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2126
2127         SysTryReturn(NID_GRP, LINK_TYPE_NONE < linkType && linkType < LINK_TYPE_MAX, E_INVALID_ARG, E_INVALID_ARG
2128                         , "[E_INVALID_ARG] The argument is invalid.");
2129
2130         switch (linkType)
2131         {
2132         case LINK_TYPE_URL:
2133                 __isUrlLinkColorDefined = true;
2134                 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_NORMAL] = color;
2135                 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_SELECT] = colorInSelect;
2136                 break;
2137
2138         case LINK_TYPE_EMAIL:
2139                 __isEmailLinkColorDefined = true;
2140                 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_NORMAL] = color;
2141                 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_SELECT] = colorInSelect;
2142                 break;
2143
2144         case LINK_TYPE_TEL_NUM:
2145                 __isPhoneNumberLinkColorDefined = true;
2146                 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_NORMAL] = color;
2147                 __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_SELECT] = colorInSelect;
2148                 break;
2149
2150         default:
2151                 break;
2152         }
2153
2154         int totalCutlinkTextCount = __pCompositeText->GetCutLinkElementCount();
2155         for (int i = 0; i < totalCutlinkTextCount; i++)
2156         {
2157                 TextCutLink* pCutlinkText = dynamic_cast < TextCutLink* >(__pCompositeText->GetCutLinkElementAtCutLinkElementIndex(i));
2158                 SysTryReturn(NID_GRP, pCutlinkText, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to convert to cutlink element.");
2159
2160                 if (pCutlinkText->GetCutLinkType() == linkType)
2161                 {
2162                         pCutlinkText->SetUserColor(color, colorInSelect);
2163                 }
2164         }
2165
2166         return E_SUCCESS;
2167 }
2168
2169 result
2170 TextObject::ResetCutLinkColor(LinkType linkType)
2171 {
2172         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2173
2174         SysTryReturn(NID_GRP, LINK_TYPE_NONE < linkType && linkType < LINK_TYPE_MAX, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
2175
2176         switch (linkType)
2177         {
2178         case LINK_TYPE_URL:
2179                 __isUrlLinkColorDefined = false;
2180                 break;
2181
2182         case LINK_TYPE_EMAIL:
2183                 __isEmailLinkColorDefined = false;
2184                 break;
2185
2186         case LINK_TYPE_TEL_NUM:
2187                 __isPhoneNumberLinkColorDefined = false;
2188                 break;
2189
2190         default:
2191                 break;
2192         }
2193
2194         int totalCutlinkTextCount = __pCompositeText->GetCutLinkElementCount();
2195         for (int i = 0; i < totalCutlinkTextCount; i++)
2196         {
2197                 TextCutLink* pCutlinkText = dynamic_cast < TextCutLink* >(__pCompositeText->GetCutLinkElementAtCutLinkElementIndex(i));
2198                 SysTryReturn(NID_GRP, pCutlinkText, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to convert to cutlink element.");
2199
2200                 if (pCutlinkText->GetCutLinkType() == linkType)
2201                 {
2202                         pCutlinkText->ResetUserColor();
2203                 }
2204         }
2205
2206         return E_SUCCESS;
2207 }
2208
2209 result
2210 TextObject::GetCutLinkBounds(int cutLinkIndex, Point& startPoint, Point& endPoint) const
2211 {
2212         FloatPoint startPointF = _CoordinateSystemUtils::ConvertToFloat(startPoint);
2213         FloatPoint endPointF =  _CoordinateSystemUtils::ConvertToFloat(endPoint);
2214
2215         result r = GetCutLinkBounds(cutLinkIndex, startPointF, endPointF);
2216         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2217
2218         startPoint = _CoordinateSystemUtils::ConvertToInteger(startPointF);
2219         endPoint = _CoordinateSystemUtils::ConvertToInteger(endPointF);
2220
2221         return E_SUCCESS;
2222 }
2223
2224 result
2225 TextObject::GetCutLinkBounds(int cutLinkIndex, FloatPoint& startPoint, FloatPoint& endPoint) const
2226 {
2227         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2228
2229         result r = E_SUCCESS;
2230         int textIndex = 0;
2231         int textLength = 0;
2232         float width = 0.0f;
2233         float heigth = 0.0f;
2234         FloatPoint tempPoint;
2235
2236         r = __pCompositeText->GetCutLinkObjectInfo(cutLinkIndex, textIndex, textLength);
2237         SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2238
2239         if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
2240         {
2241                 r = GetTextPositionInfoInNoneWrapAt(textIndex, width, heigth, tempPoint.x, tempPoint.y, startPoint.x, startPoint.y);
2242                 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2243
2244                 r = GetTextPositionInfoInNoneWrapAt(textIndex + textLength - 1, width, heigth, tempPoint.x, tempPoint.y, endPoint.x, endPoint.y);
2245                 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2246         }
2247         else
2248         {
2249                 r = GetTextPositionInfoInWrapAt(textIndex, width, heigth, tempPoint.x, tempPoint.y, startPoint.x, startPoint.y);
2250                 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2251
2252                 r = GetTextPositionInfoInWrapAt(textIndex + textLength - 1, width, heigth, tempPoint.x, tempPoint.y, endPoint.x, endPoint.y);
2253                 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2254         }
2255
2256         endPoint.x = endPoint.x + width;
2257         endPoint.y = endPoint.y + heigth;
2258
2259         return E_SUCCESS;
2260
2261 CATCH:
2262         startPoint.x = -1;
2263         startPoint.y = -1;
2264         endPoint.x = -1;
2265         endPoint.y = -1;
2266
2267         return r;
2268 }
2269
2270 result
2271 TextObject::GetTextPositionInfoAt(int textIndex, int& width, int& height, int& absX, int& absY, int& logicalX, int& logicalY) const
2272 {
2273         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2274
2275         float widthF = _CoordinateSystemUtils::ConvertToFloat(width);
2276         float heightF =  _CoordinateSystemUtils::ConvertToFloat(height);
2277         float absXF = _CoordinateSystemUtils::ConvertToFloat(absX);
2278         float absYF = _CoordinateSystemUtils::ConvertToFloat(absY);
2279         float logicalXF = _CoordinateSystemUtils::ConvertToFloat(logicalX);
2280         float logicalYF = _CoordinateSystemUtils::ConvertToFloat(logicalY);
2281
2282         result r = GetTextPositionInfoAt(textIndex, widthF, heightF, absXF, absYF, logicalXF, logicalYF);
2283         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2284
2285         width = _CoordinateSystemUtils::ConvertToInteger(widthF);
2286         height = _CoordinateSystemUtils::ConvertToInteger(heightF);
2287         absX = _CoordinateSystemUtils::ConvertToInteger(absXF);
2288         absY = _CoordinateSystemUtils::ConvertToInteger(absYF);
2289         logicalX = _CoordinateSystemUtils::ConvertToInteger(logicalXF);
2290         logicalY = _CoordinateSystemUtils::ConvertToInteger(logicalYF);
2291
2292         return E_SUCCESS;
2293 }
2294
2295 result
2296 TextObject::GetTextPositionInfoAt(int textIndex, float& width, float& height, float& absX, float& absY, float& logicalX, float& logicalY) const
2297 {
2298         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2299
2300         result r = E_SUCCESS;
2301         TextBidiHint bidiHint = _GetTextBidiHint();
2302         _SetTextBidiHint(__bidiHint);
2303
2304         int lineCount = __pTextColumn->GetTotalLineCount();
2305
2306         if (lineCount < 1)
2307         {
2308                 _FontImpl* pFont = _FontImpl::GetInstance(*__pDefaultFont);
2309                 SysTryReturn(NID_GRP, pFont, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
2310
2311                 float maxHeight = TextUtility::GetFontMaxHeightF(pFont);
2312                 float posX = 0.0f;
2313                 float posY = 0.0f;
2314                 absX = 0.0f;
2315                 absY = 0.0f;
2316
2317                 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
2318                 {
2319                         switch (__align & TEXT_ALIGNMASK_VERT)
2320                         {
2321                         case TEXT_OBJECT_ALIGNMENT_TOP:
2322                                 break;
2323
2324                         case TEXT_OBJECT_ALIGNMENT_MIDDLE:
2325                                 posY += (__rect.height - maxHeight) / 2.0f;
2326                                 break;
2327
2328                         case TEXT_OBJECT_ALIGNMENT_BOTTOM:
2329                                 posY += (__rect.height - maxHeight);
2330                                 break;
2331                         }
2332                         logicalY = __rect.y + posY;
2333
2334                         switch (__align & TEXT_ALIGNMASK_HORIZ)
2335                         {
2336                         case TEXT_OBJECT_ALIGNMENT_LEFT:
2337                                 break;
2338
2339                         case TEXT_OBJECT_ALIGNMENT_CENTER:
2340                                 posX += __rect.width / 2.0f;
2341                                 break;
2342
2343                         case TEXT_OBJECT_ALIGNMENT_RIGHT:
2344                                 posX += __rect.width;
2345                                 break;
2346                         }
2347                         logicalX = __rect.x + posX;
2348                 }
2349                 else
2350                 {
2351                         float lineHeight = maxHeight + __pCompositeText->GetLineSpaceF();
2352                         TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment();
2353                         switch (alignment & TEXT_ALIGNMASK_VERT)
2354                         {
2355                         case TEXT_OBJECT_ALIGNMENT_TOP:
2356                                 // fall through
2357                         default:
2358                                 break;
2359
2360                         case TEXT_OBJECT_ALIGNMENT_MIDDLE:
2361                                 posY += (lineHeight - maxHeight) / 2.0f;
2362                                 break;
2363
2364                         case TEXT_OBJECT_ALIGNMENT_BOTTOM:
2365                                 posY += lineHeight - maxHeight;
2366                                 break;
2367                         }
2368
2369                         switch (__align & TEXT_ALIGNMASK_HORIZ)
2370                         {
2371                         case TEXT_OBJECT_ALIGNMENT_LEFT:
2372                                 break;
2373
2374                         case TEXT_OBJECT_ALIGNMENT_CENTER:
2375                                 posX += __rect.width / 2.0f;
2376                                 break;
2377
2378                         case TEXT_OBJECT_ALIGNMENT_RIGHT:
2379                                 posX += __rect.width;
2380                                 break;
2381                         }
2382
2383                         logicalX = posX + __rect.x;
2384                         logicalY = posY + __rect.y;
2385                 }
2386
2387                 width = 0.0f;
2388                 height = maxHeight;
2389                 absX = posX;
2390                 absY = posY;
2391         }
2392         else
2393         {
2394                 r = (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE) ? GetTextPositionInfoInNoneWrapAt(textIndex, width, height, absX, absY, logicalX, logicalY)
2395                                 : GetTextPositionInfoInWrapAt(textIndex, width, height, absX, absY, logicalX, logicalY);
2396                 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2397         }
2398
2399         _SetTextBidiHint(bidiHint);
2400
2401         return E_SUCCESS;
2402 }
2403
2404 result
2405 TextObject::GetBlockTextPositionInfoAt(int textIndex, int& width, int& height, int& absX, int& absY, int& logicalX, int& logicalY) const
2406 {
2407         float widthF = _CoordinateSystemUtils::ConvertToFloat(width);
2408         float heightF =  _CoordinateSystemUtils::ConvertToFloat(height);
2409         float absXF = _CoordinateSystemUtils::ConvertToFloat(absX);
2410         float absYF = _CoordinateSystemUtils::ConvertToFloat(absY);
2411         float logicalXF = _CoordinateSystemUtils::ConvertToFloat(logicalX);
2412         float logicalYF = _CoordinateSystemUtils::ConvertToFloat(logicalY);
2413
2414         result r = GetBlockTextPositionInfoAt(textIndex, widthF, heightF, absXF, absYF, logicalXF, logicalYF);
2415         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2416
2417         width = _CoordinateSystemUtils::ConvertToInteger(widthF);
2418         height = _CoordinateSystemUtils::ConvertToInteger(heightF);
2419         absX = _CoordinateSystemUtils::ConvertToInteger(absXF);
2420         absY = _CoordinateSystemUtils::ConvertToInteger(absYF);
2421         logicalX = _CoordinateSystemUtils::ConvertToInteger(logicalXF);
2422         logicalY = _CoordinateSystemUtils::ConvertToInteger(logicalYF);
2423
2424         return E_SUCCESS;
2425 }
2426
2427 result
2428 TextObject::GetBlockTextPositionInfoAt(int textIndex, float& width, float& height, float& absX, float& absY, float& logicalX, float& logicalY) const
2429 {
2430         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2431
2432         result r = E_SUCCESS;
2433         TextBidiHint bidiHint = _GetTextBidiHint();
2434         _SetTextBidiHint(__bidiHint);
2435
2436         int lineCount = __pTextColumn->GetTotalLineCount();
2437
2438         if (lineCount < 1)
2439         {
2440                 _FontImpl* pFont =_FontImpl::GetInstance(*__pDefaultFont);
2441                 SysTryReturn(NID_GRP, pFont, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
2442
2443                 float maxHeight = TextUtility::GetFontMaxHeightF(pFont);
2444                 float posX = 0.0f;
2445                 float posY = 0.0f;
2446                 absX = 0.0f;
2447                 absY = 0.0f;
2448
2449                 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
2450                 {
2451                         switch (__align & TEXT_ALIGNMASK_VERT)
2452                         {
2453                         case TEXT_OBJECT_ALIGNMENT_TOP:
2454                                 break;
2455
2456                         case TEXT_OBJECT_ALIGNMENT_MIDDLE:
2457                                 posY += (__rect.height - maxHeight) / 2.0f;
2458                                 break;
2459
2460                         case TEXT_OBJECT_ALIGNMENT_BOTTOM:
2461                                 posY += (__rect.height - maxHeight);
2462                                 break;
2463                         }
2464                         logicalY = __rect.y + posY;
2465
2466                         switch (__align & TEXT_ALIGNMASK_HORIZ)
2467                         {
2468                         case TEXT_OBJECT_ALIGNMENT_LEFT:
2469                                 break;
2470
2471                         case TEXT_OBJECT_ALIGNMENT_CENTER:
2472                                 posX += __rect.width / 2.0f;
2473                                 break;
2474
2475                         case TEXT_OBJECT_ALIGNMENT_RIGHT:
2476                                 posX += __rect.width;
2477                                 break;
2478                         }
2479                         logicalX = __rect.x + posX;
2480                 }
2481                 else
2482                 {
2483                         float lineHeight = maxHeight + __pCompositeText->GetLineSpace();
2484                         TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment();
2485                         switch (alignment & TEXT_ALIGNMASK_VERT)
2486                         {
2487                         case TEXT_OBJECT_ALIGNMENT_TOP:
2488                                 // fall through
2489                         default:
2490                                 break;
2491
2492                         case TEXT_OBJECT_ALIGNMENT_MIDDLE:
2493                                 posY += (lineHeight - maxHeight) / 2.0f;
2494                                 break;
2495
2496                         case TEXT_OBJECT_ALIGNMENT_BOTTOM:
2497                                 posY += lineHeight - maxHeight;
2498                                 break;
2499                         }
2500
2501                         logicalX = __rect.x;
2502                         logicalY = posY + __rect.y;
2503                 }
2504
2505                 width = 0.0f;
2506                 height = maxHeight;
2507                 absX = posX;
2508                 absY = posY;
2509         }
2510         else
2511         {
2512                 r = (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE) ? GetTextPositionInfoInNoneWrapAt(textIndex, width, height, absX, absY, logicalX, logicalY)
2513                                 : GetBlockTextPositionInfoInWrapAt(textIndex, width, height, absX, absY, logicalX, logicalY);
2514                 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2515         }
2516
2517         _SetTextBidiHint(bidiHint);
2518
2519         return E_SUCCESS;
2520 }
2521
2522 result
2523 TextObject::SetTextObjectEllipsisType(TextObjectEllipsisType type)
2524 {
2525         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
2526
2527         SysTryReturn(NID_GRP, TEXT_OBJECT_ELLIPSIS_TYPE_INVALID < type && type < TEXT_OBJECT_ELLIPSIS_TYPE_MAX
2528                 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
2529
2530         __textObjectEllipsisType = type;
2531         __pCompositeText->SetTextObjectEllipsisType(type);
2532
2533         return E_SUCCESS;
2534 }
2535
2536 result
2537 TextObject::NotifyTextAdded(int textIndex, int textLength)
2538 {
2539         result r = E_SUCCESS;
2540
2541         r = __pTextColumn->SetChangeAction(TextColumn::TEXT_CHANGE_INSERT, textIndex, textLength);
2542         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2543
2544         __isChanged = true;
2545
2546         return E_SUCCESS;
2547 }
2548
2549 result
2550 TextObject::NotifyTextDeleted(int textIndex, int textLength)
2551 {
2552         result r = E_SUCCESS;
2553
2554         r = __pTextColumn->SetChangeAction(TextColumn::TEXT_CHANGE_REMOVE, textIndex, textLength);
2555         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2556
2557         __isChanged = true;
2558
2559         return E_SUCCESS;
2560 }
2561
2562 result
2563 TextObject::DrawByLine(_CanvasImpl& canvasImpl, const Rectangle& displayRect)
2564 {
2565         return DrawByLine(canvasImpl, _CoordinateSystemUtils::ConvertToFloat(displayRect));
2566 }
2567
2568 result
2569 TextObject::DrawByLine(_CanvasImpl& canvasImpl, const FloatRectangle& displayRect)
2570 {
2571         FloatRectangle targetBounds = displayRect;
2572
2573         return __pTextColumn->Draw(canvasImpl, targetBounds, 0, __pTextColumn->GetTextLength(), __align, __action);
2574 }
2575
2576 int
2577 TextObject::GetTextIndexFromPositionInWrap(int x, int y, bool cursorMode) const
2578 {
2579         return GetTextIndexFromPositionInWrap(_CoordinateSystemUtils::ConvertToFloat(x), _CoordinateSystemUtils::ConvertToFloat(y), cursorMode);
2580 }
2581
2582 int
2583 TextObject::GetTextIndexFromPositionInWrap(float x, float y, bool cursorMode) const
2584 {
2585         TextLine* pTextLine = null;
2586         FloatRectangle lineBounds;
2587         int firstDisplayLineIndex = __pTextColumn->GetFirstDisplayLineIndex();
2588         float firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
2589         int lineCount = __pTextColumn->GetTotalLineCount();
2590         int lineIndex = 0;
2591         float totalHeight = __pTextColumn->GetTotalHeightF();
2592
2593         TextBidiHint bidiHint = _GetTextBidiHint();
2594         _SetTextBidiHint(__bidiHint);
2595
2596         switch (__align & TEXT_ALIGNMASK_VERT)
2597         {
2598         case TEXT_OBJECT_ALIGNMENT_TOP:
2599                 break;
2600
2601         case TEXT_OBJECT_ALIGNMENT_MIDDLE:
2602                 y -= (__rect.height - totalHeight) / 2.0f;
2603                 break;
2604
2605         case TEXT_OBJECT_ALIGNMENT_BOTTOM:
2606                 y -= (__rect.height - totalHeight);
2607                 break;
2608         }
2609
2610         for (lineIndex = firstDisplayLineIndex; lineIndex < lineCount; lineIndex++)
2611         {
2612                 pTextLine = __pTextColumn->GetTextLine(lineIndex);
2613                 SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2614
2615                 lineBounds = pTextLine->GetBoundsF();
2616
2617                 if (lineIndex == firstDisplayLineIndex)
2618                 {
2619                         if (y < lineBounds.y - firstDisplayPositionY)
2620                         {
2621                                 return -1;
2622                         }
2623                 }
2624
2625                 if ((lineBounds.y - firstDisplayPositionY <= y) && (y < lineBounds.y + lineBounds.height - firstDisplayPositionY))
2626                 {
2627                         break;
2628                 }
2629
2630                 if (lineIndex == lineCount - 1)
2631                 {
2632                         if (cursorMode)
2633                         {
2634                                 return pTextLine->GetTextLength() + pTextLine->GetTextOffset();
2635                         }
2636                         else
2637                         {
2638                                 return -1;
2639                         }
2640                 }
2641         }
2642
2643         SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2644
2645         int lineLength = pTextLine->GetTextLength();
2646         Dimension lineTextSize;
2647         pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
2648
2649         switch (__align & TEXT_ALIGNMASK_HORIZ)
2650         {
2651         case TEXT_OBJECT_ALIGNMENT_LEFT:
2652                 break;
2653
2654         case TEXT_OBJECT_ALIGNMENT_CENTER:
2655                 x -= (lineBounds.width - lineTextSize.width) / 2.0f;
2656                 break;
2657
2658         case TEXT_OBJECT_ALIGNMENT_RIGHT:
2659                 x -= (lineBounds.width - lineTextSize.width);
2660                 break;
2661         }
2662
2663         if (x < 0.0f)
2664         {
2665                 x = 0.0f;
2666         }
2667
2668         int index = pTextLine->GetTextIndexFromPosition(x);
2669
2670         _SetTextBidiHint(bidiHint);
2671
2672         SetLastResult(E_SUCCESS);
2673
2674         return index;
2675 }
2676
2677 int
2678 TextObject::GetTextIndexFromPositionInNoneWrap(int x, int y, bool cursorMode) const
2679 {
2680         return GetTextIndexFromPositionInNoneWrap(_CoordinateSystemUtils::ConvertToFloat(x), _CoordinateSystemUtils::ConvertToFloat(y), cursorMode);
2681 }
2682
2683 int
2684 TextObject::GetTextIndexFromPositionInNoneWrap(float x, float y, bool cursorMode) const
2685 {
2686         FloatDimension lineTextSize;
2687         FloatRectangle lineBounds;
2688         int lineOffset = 0;
2689         int lineLength = 0;
2690         TextLine* pTextLine = null;
2691
2692         pTextLine = __pTextColumn->GetTextLine(0);
2693         SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2694
2695         TextBidiHint bidiHint = _GetTextBidiHint();
2696         _SetTextBidiHint(__bidiHint);
2697
2698         lineOffset = pTextLine->GetTextOffset();
2699         lineLength = pTextLine->GetTextLength();
2700         lineBounds = pTextLine->GetBoundsF();
2701         pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
2702
2703         switch (__align & TEXT_ALIGNMASK_HORIZ)
2704         {
2705         case TEXT_OBJECT_ALIGNMENT_LEFT:
2706                 break;
2707
2708         case TEXT_OBJECT_ALIGNMENT_CENTER:
2709                 x -= (lineBounds.width - lineTextSize.width) / 2.0f;
2710                 break;
2711
2712         case TEXT_OBJECT_ALIGNMENT_RIGHT:
2713                 x -= (lineBounds.width - lineTextSize.width);
2714                 break;
2715         }
2716
2717         switch (__align & TEXT_ALIGNMASK_VERT)
2718         {
2719         case TEXT_OBJECT_ALIGNMENT_TOP:
2720                 break;
2721
2722         case TEXT_OBJECT_ALIGNMENT_MIDDLE:
2723                 y -= (__rect.height - lineTextSize.height) / 2.0f;
2724                 break;
2725
2726         case TEXT_OBJECT_ALIGNMENT_BOTTOM:
2727                 y -= (__rect.height - lineTextSize.height);
2728                 break;
2729         }
2730
2731         if (x < 0.0f)
2732         {
2733                 x = 0.0f;
2734         }
2735
2736         int index = pTextLine->GetTextIndexFromPosition(x);
2737
2738         _SetTextBidiHint(bidiHint);
2739
2740         SetLastResult(E_SUCCESS);
2741         return index;
2742 }
2743
2744 result
2745 TextObject::SetFirstDisplayLineIndexFromTextIndexInWrap(int textIndex)
2746 {
2747         result r = E_SUCCESS;
2748         FloatRectangle lineBounds;
2749         float firstDisplayPositionY = 0.0f;
2750         int currentTextIndex = textIndex;
2751         int firstDisplayLineIndex = 0;
2752         int lineIndex = 0;
2753         int lineCount = 0;
2754         float remainingHeight = 0.0f;
2755         TextLine* pTextLine = null;
2756         bool isChanged = false;
2757
2758         lineCount = __pTextColumn->GetTotalLineCount();
2759         lineIndex = __pTextColumn->GetLineIndexAtTextIndex(currentTextIndex);
2760         firstDisplayLineIndex = __pTextColumn->GetFirstDisplayLineIndex();
2761
2762         if (lineIndex == -1 && 0 < currentTextIndex && currentTextIndex == __pCompositeText->GetTextLength())
2763         {
2764                 currentTextIndex--;
2765                 lineIndex = __pTextColumn->GetLineIndexAtTextIndex(currentTextIndex);
2766         }
2767
2768         pTextLine = __pTextColumn->GetTextLine(lineIndex);
2769         SysTryReturn(NID_GRP, pTextLine, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2770
2771         lineBounds = pTextLine->GetBoundsF();
2772
2773         if (firstDisplayLineIndex < lineIndex)
2774         {
2775                 TextLine* pTextLine = null;
2776                 int currentLineIndex = 0;
2777                 int displayLineCount = 0;
2778
2779                 currentLineIndex = firstDisplayLineIndex;
2780                 pTextLine = __pTextColumn->GetTextLine(currentLineIndex);
2781                 SysTryReturn(NID_GRP, pTextLine, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2782
2783                 remainingHeight = __rect.height;
2784
2785                 while ((remainingHeight != 0.0f) && firstDisplayLineIndex < lineCount)
2786                 {
2787                         if (remainingHeight < 0.0f)
2788                         {
2789                                 break;
2790                         }
2791
2792                         lineBounds = pTextLine->GetBoundsF();
2793
2794                         remainingHeight -= lineBounds.height;
2795                         displayLineCount++;
2796                         currentLineIndex++;
2797
2798                         pTextLine = __pTextColumn->GetTextLine(currentLineIndex);
2799                         if (pTextLine == null)
2800                         {
2801                                 break;
2802                         }
2803                 }
2804
2805                 if (lineIndex < firstDisplayLineIndex + displayLineCount)
2806                 {
2807                         if (0.0f < remainingHeight && 0 < firstDisplayLineIndex)
2808                         {
2809                                 pTextLine = __pTextColumn->GetTextLine(firstDisplayLineIndex - 1);
2810                                 SysTryReturn(NID_GRP, pTextLine, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2811
2812                                 while (remainingHeight && pTextLine)
2813                                 {
2814                                         lineBounds = pTextLine->GetBoundsF();
2815                                         remainingHeight -= lineBounds.height;
2816
2817                                         if (remainingHeight < 0.0f)
2818                                         {
2819                                                 firstDisplayPositionY = lineBounds.y + remainingHeight;
2820                                                 displayLineCount++;
2821                                                 firstDisplayLineIndex--;
2822                                                 break;
2823                                         }
2824                                         else
2825                                         {
2826                                                 firstDisplayPositionY = lineBounds.y;
2827                                         }
2828
2829                                         displayLineCount++;
2830                                         firstDisplayLineIndex--;
2831
2832                                         pTextLine = __pTextColumn->GetTextLine(firstDisplayLineIndex - 1);
2833                                 }
2834
2835                                 isChanged = true;
2836                         }
2837                         else if (remainingHeight < 0.0f && (lineIndex == firstDisplayLineIndex + displayLineCount - 1))
2838                         {
2839                                 pTextLine = __pTextColumn->GetTextLine(lineIndex);
2840                                 SysTryReturn(NID_GRP, pTextLine, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2841
2842                                 lineBounds = pTextLine->GetBoundsF();
2843                                 remainingHeight = __rect.height;
2844
2845                                 firstDisplayLineIndex = lineIndex;
2846                                 firstDisplayPositionY = lineBounds.y;
2847                                 remainingHeight -= lineBounds.height;
2848
2849                                 int currentLineIndex = lineIndex - 1;
2850                                 pTextLine = __pTextColumn->GetTextLine(currentLineIndex);
2851
2852                                 while ((pTextLine != null) && 0 < firstDisplayLineIndex && 0.0f < remainingHeight)
2853                                 {
2854                                         lineBounds = pTextLine->GetBoundsF();
2855
2856                                         if (remainingHeight < lineBounds.height)
2857                                         {
2858                                                 firstDisplayLineIndex--;
2859                                                 firstDisplayPositionY = lineBounds.y + (lineBounds.height - remainingHeight);
2860                                                 break;
2861                                         }
2862                                         else
2863                                         {
2864                                                 remainingHeight -= lineBounds.height;
2865                                                 firstDisplayLineIndex--;
2866                                                 firstDisplayPositionY = lineBounds.y;
2867                                                 currentLineIndex--;
2868                                                 pTextLine = __pTextColumn->GetTextLine(currentLineIndex);
2869                                         }
2870                                 }
2871                                 isChanged = true;
2872                         }
2873                 }
2874                 else
2875                 {
2876                         pTextLine = __pTextColumn->GetTextLine(lineIndex);
2877                         SysTryReturn(NID_GRP, pTextLine, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2878
2879                         lineBounds = pTextLine->GetBoundsF();
2880
2881                         remainingHeight = __rect.height;
2882
2883                         firstDisplayLineIndex = lineIndex;
2884                         firstDisplayPositionY = lineBounds.y;
2885                         remainingHeight -= lineBounds.height;
2886
2887                         int currentLineIndex = lineIndex - 1;
2888                         pTextLine = __pTextColumn->GetTextLine(currentLineIndex);
2889
2890                         while (pTextLine && 0 < firstDisplayLineIndex && 0.0f < remainingHeight)
2891                         {
2892                                 lineBounds = pTextLine->GetBoundsF();
2893
2894                                 if (remainingHeight < lineBounds.height)
2895                                 {
2896                                         firstDisplayLineIndex--;
2897                                         firstDisplayPositionY = lineBounds.y + (lineBounds.height - remainingHeight);
2898                                         break;
2899                                 }
2900                                 else
2901                                 {
2902                                         remainingHeight -= lineBounds.height;
2903                                         firstDisplayLineIndex--;
2904                                         firstDisplayPositionY = lineBounds.y;
2905                                         currentLineIndex--;
2906                                         pTextLine = __pTextColumn->GetTextLine(currentLineIndex);
2907                                 }
2908                         }
2909                         isChanged = true;
2910                 }
2911         }
2912         else
2913         {
2914                 lineBounds = pTextLine->GetBoundsF();
2915                 firstDisplayLineIndex = lineIndex;
2916                 firstDisplayPositionY = lineBounds.y;
2917                 isChanged = true;
2918         }
2919
2920         if (isChanged == true)
2921         {
2922                 __pTextColumn->SetFirstDisplayLineIndex(firstDisplayLineIndex);
2923                 __pTextColumn->SetFirstDisplayPositionY(firstDisplayPositionY);
2924         }
2925
2926         return E_SUCCESS;
2927 }
2928
2929 result
2930 TextObject::SetFirstDisplayLineIndexFromTextIndexInNoneWrap(int textIndex)
2931 {
2932         result r = E_SUCCESS;
2933         int currentTextIndex = textIndex;
2934         int lineOffset = 0;
2935         int lineEndIndex = 0;
2936         int lineLength = 0;
2937         FloatRectangle lineBounds;
2938         FloatDimension lineTextSize;
2939
2940         _FontImpl* pFont = _FontImpl::GetInstance(*__pDefaultFont);
2941         SysTryReturn(NID_GRP, pFont, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
2942
2943         TextLine* pTextLine = __pTextColumn->GetTextLine(0);
2944         SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
2945
2946         lineOffset = pTextLine->GetTextOffset();
2947         lineLength = pTextLine->GetTextLength();
2948         lineEndIndex = pTextLine->GetTextOffset() + pTextLine->GetTextLength();
2949
2950         lineBounds = pTextLine->GetBoundsF();
2951         pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
2952
2953         if (currentTextIndex < pTextLine->GetTextOffset() + 1)
2954         {
2955                 lineOffset = currentTextIndex;
2956                 pTextLine->SetTextOffset(lineOffset);
2957                 lineOffset = pTextLine->GetTextOffset();
2958                 if (lineOffset > 0)
2959                 {
2960                         lineOffset--;
2961                         pTextLine->SetTextOffset(lineOffset);
2962                 }
2963
2964                 __pCompositeText->ForwardAnalyze(lineOffset, __pCompositeText->GetTextLength() - lineOffset, lineBounds.width,
2965                                                                                 __wrap, lineLength, lineTextSize.width, lineTextSize.height);
2966
2967                 lineBounds.height = (lineBounds.height > lineTextSize.height) ? lineBounds.height : lineTextSize.height;
2968                 if (lineBounds.height == 0.0f)
2969                 {
2970                         lineBounds.height = TextUtility::GetFontMaxHeightF(pFont);
2971                 }
2972
2973                 pTextLine->SetBounds(lineBounds);
2974                 pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
2975                 pTextLine->SetTextLength(lineLength);
2976                 __pCompositeText->GetTextExtentList(pTextLine);
2977         }
2978         else if (lineEndIndex <= currentTextIndex)
2979         {
2980                 float gapWidth = 0.0f;
2981                 float gapHeight = 0.0f;
2982                 float tempWidth = 0.0f;
2983                 int textCount = 0;
2984
2985                 r = __pCompositeText->GetRegion(lineEndIndex, currentTextIndex - lineEndIndex, gapWidth, gapHeight);
2986                 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2987
2988                 gapWidth -= lineBounds.width - lineTextSize.width;
2989
2990                 __pCompositeText->ForwardAnalyze(lineOffset, __pCompositeText->GetTextLength() - lineOffset, gapWidth, __wrap,
2991                                 textCount, tempWidth, gapHeight);
2992
2993                 if (tempWidth < gapWidth)
2994                 {
2995                         lineOffset += (textCount + 1);
2996                 }
2997                 else
2998                 {
2999                         lineOffset += textCount;
3000                 }
3001
3002                 __pCompositeText->ForwardAnalyze(lineOffset, __pCompositeText->GetTextLength() - lineOffset, lineBounds.width,
3003                                                                                 __wrap, lineLength, lineTextSize.width, lineTextSize.height);
3004
3005                 lineBounds.height = (lineBounds.height > lineTextSize.height) ? lineBounds.height: lineTextSize.height;
3006                 if (lineBounds.height == 0.0f)
3007                 {
3008                         lineBounds.height = TextUtility::GetFontMaxHeightF(pFont);
3009                 }
3010
3011                 pTextLine->SetBounds(lineBounds);
3012                 pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
3013                 pTextLine->SetTextOffset(lineOffset);
3014                 pTextLine->SetTextLength(lineLength);
3015                 __pCompositeText->GetTextExtentList(pTextLine);
3016         }
3017
3018         __pTextColumn->SetFirstDisplayLineIndex(0);
3019         __pTextColumn->SetFirstDisplayPositionY(0.0f);
3020
3021         return E_SUCCESS;
3022 }
3023
3024 result
3025 TextObject::GetTextPositionInfoInWrapAt(int textIndex, int& width, int& height, int& absX, int& absY,
3026                                                                                                                                         int& logicalX, int& logicalY) const
3027 {
3028         float widthF = _CoordinateSystemUtils::ConvertToFloat(width);
3029         float heightF =  _CoordinateSystemUtils::ConvertToFloat(height);
3030         float absXF = _CoordinateSystemUtils::ConvertToFloat(absX);
3031         float absYF = _CoordinateSystemUtils::ConvertToFloat(absY);
3032         float logicalXF = _CoordinateSystemUtils::ConvertToFloat(logicalX);
3033         float logicalYF = _CoordinateSystemUtils::ConvertToFloat(logicalY);
3034
3035         result r = GetTextPositionInfoInWrapAt(textIndex, widthF, heightF, absXF, absYF, logicalXF, logicalYF);
3036         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3037
3038         width = _CoordinateSystemUtils::ConvertToInteger(widthF);
3039         height = _CoordinateSystemUtils::ConvertToInteger(heightF);
3040         absX = _CoordinateSystemUtils::ConvertToInteger(absXF);
3041         absY = _CoordinateSystemUtils::ConvertToInteger(absYF);
3042         logicalX = _CoordinateSystemUtils::ConvertToInteger(logicalXF);
3043         logicalY = _CoordinateSystemUtils::ConvertToInteger(logicalYF);
3044
3045         return E_SUCCESS;
3046 }
3047
3048 result
3049 TextObject::GetTextPositionInfoInWrapAt(int textIndex, float& width, float& height, float& absX, float& absY,
3050                                                                                                                                         float& logicalX, float& logicalY) const
3051 {
3052         TextLine* pTextLine = null;
3053         FloatRectangle lineBounds;
3054         float firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
3055         int lineCount = __pTextColumn->GetTotalLineCount();
3056         int lineIndex = 0;
3057         int lineOffset = 0;
3058         int lineLength = 0;
3059         int textIndexFromLineOffset = 0;
3060         float lineY = 0.0f;
3061         float posX = 0.0f;
3062         float posY = 0.0f;
3063
3064         _FontImpl* pFont = _FontImpl::GetInstance(*__pDefaultFont);
3065         SysTryReturn(NID_GRP, pFont, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
3066
3067         for (lineIndex = 0; lineIndex < lineCount; lineIndex++)
3068         {
3069                 pTextLine = __pTextColumn->GetTextLine(lineIndex);
3070                 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3071
3072                 lineBounds = pTextLine->GetBoundsF();
3073                 lineOffset = pTextLine->GetTextOffset();
3074                 lineLength = pTextLine->GetTextLength();
3075
3076                 if (lineOffset <= textIndex && textIndex < lineOffset + lineLength)
3077                 {
3078                         break;
3079                 }
3080
3081                 if (lineIndex + 1 < lineCount)
3082                 {
3083                         lineY += lineBounds.height;
3084                 }
3085         }
3086
3087         SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3088
3089         if (lineIndex == lineCount)
3090         {
3091                 textIndexFromLineOffset = lineLength;
3092         }
3093         else
3094         {
3095                 textIndexFromLineOffset = textIndex - lineOffset;
3096         }
3097
3098         FloatDimension lineTextSize;
3099         pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
3100
3101         if (lineTextSize.height == 0)
3102         {
3103                 lineTextSize.height = TextUtility::GetFontMaxHeightF(pFont);
3104         }
3105
3106         switch (__align & TEXT_ALIGNMASK_HORIZ)
3107         {
3108         case TEXT_OBJECT_ALIGNMENT_LEFT:
3109                 break;
3110
3111         case TEXT_OBJECT_ALIGNMENT_CENTER:
3112                 posX += (lineBounds.width - lineTextSize.width) / 2.0f;
3113                 break;
3114
3115         case TEXT_OBJECT_ALIGNMENT_RIGHT:
3116                 posX += (lineBounds.width - lineTextSize.width);
3117                 break;
3118         }
3119
3120         switch (__align & TEXT_ALIGNMASK_VERT)
3121         {
3122         case TEXT_OBJECT_ALIGNMENT_TOP:
3123                 break;
3124
3125         case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3126                 posY += (__rect.height - __pTextColumn->GetDisplayHeightF()) / 2.0f;
3127                 break;
3128
3129         case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3130                 posY += (__rect.height - __pTextColumn->GetDisplayHeightF());
3131                 break;
3132         }
3133
3134         if (posX < 0.0f)
3135         {
3136                 posX = 0.0f;
3137         }
3138
3139         if (posY < 0.0f)
3140         {
3141                 posY = 0.0f;
3142         }
3143
3144         FloatRectangle textExtent = pTextLine->GetTextExtentF(textIndexFromLineOffset, 1);
3145
3146         if (lineIndex == lineCount)
3147         {
3148                 textExtent.width = 0.0f;
3149         }
3150
3151         if (textIndex >= 1)
3152         {
3153                 Font* pTextFont = __pCompositeText->GetFont(textIndex - 1);
3154                 textExtent.height = TextUtility::GetFontMaxHeightF(pTextFont);
3155         }
3156
3157         if (textExtent.height < 0.0f)
3158         {
3159                 textExtent.height = TextUtility::GetFontMaxHeightF(pFont);
3160         }
3161
3162         TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment();
3163         switch (alignment & TEXT_ALIGNMASK_VERT)
3164         {
3165         case TEXT_OBJECT_ALIGNMENT_TOP:
3166                 // fall through
3167         default:
3168                 break;
3169
3170         case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3171                 lineY = lineY + (lineBounds.height - textExtent.height) / 2.0f;
3172                 break;
3173
3174         case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3175                 lineY = lineY + (lineBounds.height - textExtent.height);
3176                 break;
3177         }
3178
3179         width =  textExtent.width;
3180         height =  textExtent.height;
3181         absX = posX + textExtent.x;
3182         logicalX = absX + __rect.x;
3183         absY = lineY;
3184         logicalY = absY - firstDisplayPositionY + __rect.y + posY;
3185
3186         return E_SUCCESS;
3187 }
3188
3189 result
3190 TextObject::GetBlockTextPositionInfoInWrapAt(int textIndex, int& width, int& height, int& absX, int& absY,
3191                                                                                                                                         int& logicalX, int& logicalY) const
3192 {
3193         float widthF = _CoordinateSystemUtils::ConvertToFloat(width);
3194         float heightF =  _CoordinateSystemUtils::ConvertToFloat(height);
3195         float absXF = _CoordinateSystemUtils::ConvertToFloat(absX);
3196         float absYF = _CoordinateSystemUtils::ConvertToFloat(absY);
3197         float logicalXF = _CoordinateSystemUtils::ConvertToFloat(logicalX);
3198         float logicalYF = _CoordinateSystemUtils::ConvertToFloat(logicalY);
3199
3200         result r = GetBlockTextPositionInfoInWrapAt(textIndex, widthF, heightF, absXF, absYF, logicalXF, logicalYF);
3201         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3202
3203         width = _CoordinateSystemUtils::ConvertToInteger(widthF);
3204         height = _CoordinateSystemUtils::ConvertToInteger(heightF);
3205         absX = _CoordinateSystemUtils::ConvertToInteger(absXF);
3206         absY = _CoordinateSystemUtils::ConvertToInteger(absYF);
3207         logicalX = _CoordinateSystemUtils::ConvertToInteger(logicalXF);
3208         logicalY = _CoordinateSystemUtils::ConvertToInteger(logicalYF);
3209
3210         return E_SUCCESS;
3211 }
3212
3213 result
3214 TextObject::GetBlockTextPositionInfoInWrapAt(int textIndex, float& width, float& height, float& absX, float& absY,
3215                                                                                                                                         float& logicalX, float& logicalY) const
3216 {
3217         TextLine* pTextLine = null;
3218         FloatRectangle lineBounds;
3219         float firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionYF();
3220         int lineCount = __pTextColumn->GetTotalLineCount();
3221         int lineIndex = 0;
3222         int lineOffset = 0;
3223         int lineLength = 0;
3224         int textIndexFromLineOffset = 0;
3225         float lineY = 0.0f;
3226         float posX = 0.0f;
3227         float posY = 0.0f;
3228
3229         _FontImpl* pFont = _FontImpl::GetInstance(*__pDefaultFont);
3230         SysTryReturn(NID_GRP, pFont, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
3231
3232         for (lineIndex = 0; lineIndex < lineCount; lineIndex++)
3233         {
3234                 pTextLine = __pTextColumn->GetTextLine(lineIndex);
3235                 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3236
3237                 lineBounds = pTextLine->GetBoundsF();
3238                 lineOffset = pTextLine->GetTextOffset();
3239                 lineLength = pTextLine->GetTextLength();
3240
3241                 if (lineOffset <= textIndex && textIndex <= lineOffset + lineLength)
3242                 {
3243                         break;
3244                 }
3245
3246                 if (lineIndex + 1 < lineCount)
3247                 {
3248                         lineY += lineBounds.height;
3249                 }
3250         }
3251
3252         SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3253
3254         if (lineIndex == lineCount)
3255         {
3256                 textIndexFromLineOffset = lineLength;
3257         }
3258         else
3259         {
3260                 textIndexFromLineOffset = textIndex - lineOffset;
3261         }
3262
3263         FloatDimension lineTextSize;
3264         pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
3265
3266         if (lineTextSize.height == 0.0f)
3267         {
3268                 lineTextSize.height = TextUtility::GetFontMaxHeightF(pFont);
3269         }
3270
3271         switch (__align & TEXT_ALIGNMASK_HORIZ)
3272         {
3273         case TEXT_OBJECT_ALIGNMENT_LEFT:
3274                 break;
3275
3276         case TEXT_OBJECT_ALIGNMENT_CENTER:
3277                 posX += (lineBounds.width - lineTextSize.width) / 2.0f;
3278                 break;
3279
3280         case TEXT_OBJECT_ALIGNMENT_RIGHT:
3281                 posX += (lineBounds.width - lineTextSize.width);
3282                 break;
3283         }
3284
3285         switch (__align & TEXT_ALIGNMASK_VERT)
3286         {
3287         case TEXT_OBJECT_ALIGNMENT_TOP:
3288                 break;
3289
3290         case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3291                 posY += (__rect.height - __pTextColumn->GetDisplayHeightF()) / 2.0f;
3292                 break;
3293
3294         case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3295                 posY += (__rect.height - __pTextColumn->GetDisplayHeightF());
3296                 break;
3297         }
3298
3299         if (posX < 0.0f)
3300         {
3301                 posX = 0.0f;
3302         }
3303
3304         if (posY < 0.0f)
3305         {
3306                 posY = 0.0f;
3307         }
3308
3309         FloatRectangle textExtent = pTextLine->GetBlockTextExtentF(textIndexFromLineOffset, 1);
3310
3311         if (lineIndex == lineCount)
3312         {
3313                 textExtent.width = 0.0f;
3314         }
3315
3316         if (textIndex >= 1)
3317         {
3318                 Font* pTextFont = __pCompositeText->GetFont(textIndex - 1);
3319                 textExtent.height = TextUtility::GetFontMaxHeightF(pTextFont);
3320         }
3321
3322         if (textExtent.height < 0)
3323         {
3324                 textExtent.height = TextUtility::GetFontMaxHeightF(pFont);
3325         }
3326
3327         TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment();
3328         switch (alignment & TEXT_ALIGNMASK_VERT)
3329         {
3330         case TEXT_OBJECT_ALIGNMENT_TOP:
3331                 // fall through
3332         default:
3333                 break;
3334
3335         case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3336                 lineY = lineY + (lineBounds.height - textExtent.height) / 2.0f;
3337                 break;
3338
3339         case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3340                 lineY = lineY + (lineBounds.height - textExtent.height);
3341                 break;
3342         }
3343
3344         width =  textExtent.width;
3345         height =  textExtent.height;
3346         absX = posX + textExtent.x;
3347         logicalX = absX + __rect.x;
3348         absY = lineY;
3349         logicalY = absY - firstDisplayPositionY + __rect.y + posY;
3350
3351         return E_SUCCESS;
3352 }
3353
3354 result
3355 TextObject::GetTextPositionInfoInNoneWrapAt(int textIndex, int& width, int& height, int& absX, int& absY,
3356                                                                                                                                 int& logicalX, int& logicalY) const
3357 {
3358         float widthF = _CoordinateSystemUtils::ConvertToFloat(width);
3359         float heightF =  _CoordinateSystemUtils::ConvertToFloat(height);
3360         float absXF = _CoordinateSystemUtils::ConvertToFloat(absX);
3361         float absYF = _CoordinateSystemUtils::ConvertToFloat(absY);
3362         float logicalXF = _CoordinateSystemUtils::ConvertToFloat(logicalX);
3363         float logicalYF = _CoordinateSystemUtils::ConvertToFloat(logicalY);
3364
3365         result r = GetTextPositionInfoInNoneWrapAt(textIndex, widthF, heightF, absXF, absYF, logicalXF, logicalYF);
3366         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3367
3368         width = _CoordinateSystemUtils::ConvertToInteger(widthF);
3369         height = _CoordinateSystemUtils::ConvertToInteger(heightF);
3370         absX = _CoordinateSystemUtils::ConvertToInteger(absXF);
3371         absY = _CoordinateSystemUtils::ConvertToInteger(absYF);
3372         logicalX = _CoordinateSystemUtils::ConvertToInteger(logicalXF);
3373         logicalY = _CoordinateSystemUtils::ConvertToInteger(logicalYF);
3374
3375         return E_SUCCESS;
3376 }
3377
3378 result
3379 TextObject::GetTextPositionInfoInNoneWrapAt(int textIndex, float& width, float& height, float& absX, float& absY,
3380                                                                                                                                 float& logicalX, float& logicalY) const
3381 {
3382         TextLine* pTextLine = null;
3383         pTextLine = __pTextColumn->GetTextLine(0);
3384         SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3385
3386         int lineLength = pTextLine->GetTextLength();
3387         float posX = 0.0f;
3388         float posY = 0.0f;
3389
3390         _FontImpl* pFont = _FontImpl::GetInstance(*__pDefaultFont);
3391         SysTryReturn(NID_GRP, pFont, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
3392
3393         FloatDimension lineTextSize;
3394         FloatRectangle lineBounds;
3395         lineBounds = pTextLine->GetBoundsF();
3396         pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
3397
3398         if (lineTextSize.height == 0.0f || pTextLine->GetTextLength() == 0.0f)
3399         {
3400                 lineTextSize.height = TextUtility::GetFontMaxHeightF(pFont);
3401         }
3402
3403         switch (__align & TEXT_ALIGNMASK_HORIZ)
3404         {
3405         case TEXT_OBJECT_ALIGNMENT_LEFT:
3406                 break;
3407
3408         case TEXT_OBJECT_ALIGNMENT_CENTER:
3409                 posX += (lineBounds.width - lineTextSize.width) / 2.0f;
3410                 break;
3411
3412         case TEXT_OBJECT_ALIGNMENT_RIGHT:
3413                 posX += (lineBounds.width - lineTextSize.width);
3414                 break;
3415         }
3416
3417         switch (__align & TEXT_ALIGNMASK_VERT)
3418         {
3419         case TEXT_OBJECT_ALIGNMENT_TOP:
3420                 break;
3421
3422         case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3423                 posY += (__rect.height - lineTextSize.height) / 2.0f;
3424                 break;
3425
3426         case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3427                 posY += (__rect.height - lineTextSize.height);
3428                 break;
3429         }
3430
3431         posX = (posX < 0.0f) ? 0.0f : posX;
3432         posY = (posY < 0.0f) ? 0.0f : posY;
3433
3434         FloatRectangle textExtent = pTextLine->GetTextExtentF(textIndex - pTextLine->GetTextOffset(), 1);
3435
3436         if (textIndex >= 1)
3437         {
3438                 Font* pTextFont = __pCompositeText->GetFont(textIndex - 1);
3439                 textExtent.height = TextUtility::GetFontMaxHeightF(pTextFont);
3440         }
3441
3442         if (textExtent.height < 0.0f)
3443         {
3444                 textExtent.height = TextUtility::GetFontMaxHeightF(pFont);
3445         }
3446
3447         TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment();
3448         switch (alignment & TEXT_ALIGNMASK_VERT)
3449         {
3450         case TEXT_OBJECT_ALIGNMENT_TOP:
3451                 // fall through
3452         default:
3453                 break;
3454
3455         case TEXT_OBJECT_ALIGNMENT_MIDDLE:
3456                 posY = posY + (lineBounds.height - textExtent.height) / 2.0f;
3457                 break;
3458
3459         case TEXT_OBJECT_ALIGNMENT_BOTTOM:
3460                 posY = posY + (lineBounds.height - textExtent.height);
3461                 break;
3462         }
3463
3464         absX = posX + textExtent.x;
3465         logicalX = (absX >= 0.0f) ? absX + __rect.x : absX;
3466         absY = posY;
3467         logicalY = absY + __rect.y;
3468         width = textExtent.width;
3469         height = textExtent.height;
3470
3471         return E_SUCCESS;
3472 }
3473
3474 int
3475 TextObject::GetTotalComposedHeight(void) const
3476 {
3477         return _CoordinateSystemUtils::ConvertToInteger(GetTotalComposedHeightF());
3478 }
3479
3480 float
3481 TextObject::GetTotalComposedHeightF(void) const
3482 {
3483         return __pCompositeText->GetTotalComposedHeightF();
3484 }
3485
3486 int
3487 TextObject::GetLineWidthAt(int lineIndex) const
3488 {
3489         return _CoordinateSystemUtils::ConvertToInteger(GetLineWidthAtF(lineIndex));
3490 }
3491
3492 float
3493 TextObject::GetLineWidthAtF(int lineIndex) const
3494 {
3495         IF_NOT_CONSTRUCTED(return -1);
3496
3497         result r = E_SUCCESS;
3498         TextLine* pTextLine = null;
3499         FloatDimension lineTextSize;
3500         int lineLength = 0;
3501
3502         pTextLine = __pTextColumn->GetTextLine(lineIndex);
3503         SysTryCatch(NID_GRP, pTextLine, , E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
3504
3505         lineLength = pTextLine->GetTextLength();
3506         r = pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
3507         SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3508
3509         SetLastResult(E_SUCCESS);
3510         return lineTextSize.width;
3511
3512 CATCH:
3513         return -1;
3514 }
3515
3516 int
3517 TextObject::GetTotalHeight(void) const
3518 {
3519         return _CoordinateSystemUtils::ConvertToInteger(GetTotalHeightF());
3520 }
3521
3522 float
3523 TextObject::GetTotalHeightF(void) const
3524 {
3525         IF_NOT_CONSTRUCTED(return -1);
3526
3527         float height = 0.0f;
3528         if (IsPartialComposingModeEnabled())
3529         {
3530                 height = __pCompositeText->GetAnalysedTotalHeightF();
3531         }
3532         else
3533         {
3534                 height = __pTextColumn->GetTotalHeightF();
3535         }
3536
3537         return height;
3538 }
3539
3540 int
3541 TextObject::GetElementIndexOf(TextElement& textElement) const
3542 {
3543         IF_NOT_CONSTRUCTED(return -1);
3544
3545         return __pCompositeText->GetElementIndexOf(textElement);
3546 }
3547
3548 result
3549 TextObject::RemoveElementAt(int elementIndex, bool deallocate)
3550 {
3551         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3552
3553         return __pCompositeText->RemoveElementAt(elementIndex, deallocate);
3554 }
3555
3556 result
3557 TextObject::HideFrontSpace(TextObjectSpaceHideType mode)
3558 {
3559         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3560
3561         __pCompositeText->HideFrontSpace(mode);
3562
3563         return E_SUCCESS;
3564 }
3565
3566 result
3567 TextObject::HideRearSpace(TextObjectSpaceHideType mode)
3568 {
3569         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3570
3571         __pCompositeText->HideRearSpace(mode);
3572
3573         return E_SUCCESS;
3574 }
3575
3576 int
3577 TextObject::GetSlidingStep(void) const
3578 {
3579         return _CoordinateSystemUtils::ConvertToInteger(GetSlidingStepF());
3580 }
3581
3582 float
3583 TextObject::GetSlidingStepF(void) const
3584 {
3585         IF_NOT_CONSTRUCTED(return -1.0f);
3586
3587         return __slidingStep;
3588 }
3589
3590
3591 result
3592 TextObject::SetSlidingStep(int slidingStep)
3593 {
3594         return SetSlidingStep(_CoordinateSystemUtils::ConvertToFloat(slidingStep));
3595 }
3596
3597 result
3598 TextObject::SetSlidingStep(float slidingStep)
3599 {
3600         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3601
3602         __slidingStep = slidingStep;
3603
3604         return E_SUCCESS;
3605 }
3606
3607 int
3608 TextObject::GetTotalLineCount(void) const
3609 {
3610         IF_NOT_CONSTRUCTED(return -1);
3611
3612         return __pTextColumn->GetTotalLineCount();
3613 }
3614
3615 int
3616 TextObject::GetLineIndexAtTextIndex(int textIndex)  const
3617 {
3618         IF_NOT_CONSTRUCTED(return -1);
3619
3620         return __pTextColumn->GetLineIndexAtTextIndex(textIndex);
3621 }
3622
3623 int
3624 TextObject::GetLineHeightAt(int lineIndex)  const
3625 {
3626         return _CoordinateSystemUtils::ConvertToInteger(GetLineHeightAtF(lineIndex));
3627 }
3628
3629 float
3630 TextObject::GetLineHeightAtF(int lineIndex) const
3631 {
3632         IF_NOT_CONSTRUCTED(return -1);
3633
3634         SysTryReturn(NID_GRP, lineIndex >= 0, -1, E_INVALID_ARG
3635                         , "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
3636
3637         return __pTextColumn->GetLineHeightAtF(lineIndex);
3638 }
3639
3640 int
3641 TextObject::GetDisplayLineCount(void)  const
3642 {
3643         IF_NOT_CONSTRUCTED(return -1);
3644
3645         return __pTextColumn->GetDisplayLineCount();
3646 }
3647
3648 int
3649 TextObject::GetFirstDisplayLineIndex(void) const
3650 {
3651         IF_NOT_CONSTRUCTED(return -1);
3652
3653         return __pTextColumn->GetFirstDisplayLineIndex();
3654 }
3655
3656 int
3657 TextObject::GetFirstDisplayPositionY(void) const
3658 {
3659         return _CoordinateSystemUtils::ConvertToInteger(GetFirstDisplayPositionYF());
3660 }
3661
3662 float
3663 TextObject::GetFirstDisplayPositionYF(void) const
3664 {
3665         IF_NOT_CONSTRUCTED(return -1);
3666
3667         return __pTextColumn->GetFirstDisplayPositionYF();
3668 }
3669
3670 int
3671 TextObject::GetLineIndexAtPositionY(int y) const
3672 {
3673         return GetLineIndexAtPositionY(_CoordinateSystemUtils::ConvertToFloat(y));
3674 }
3675
3676 int
3677 TextObject::GetLineIndexAtPositionY(float y) const
3678 {
3679         IF_NOT_CONSTRUCTED(return -1);
3680
3681         return __pTextColumn->GetLineIndexAtPositionY(y);
3682 }
3683
3684 int
3685 TextObject::GetFirstTextIndexAt(int lineIndex) const
3686 {
3687         IF_NOT_CONSTRUCTED(return -1);
3688
3689         SysTryReturn(NID_GRP, lineIndex >= 0, -1, E_INVALID_ARG
3690                         , "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
3691
3692         return __pTextColumn->GetFirstTextIndexAt(lineIndex);
3693 }
3694
3695 int
3696 TextObject::GetTextLengthAt(int lineIndex) const
3697 {
3698         IF_NOT_CONSTRUCTED(return -1);
3699
3700         SysTryReturn(NID_GRP, lineIndex >= 0, -1, E_INVALID_ARG
3701                         , "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
3702
3703         return __pTextColumn->GetTextLengthAt(lineIndex);
3704 }
3705
3706 Rectangle
3707 TextObject::GetBounds(void) const
3708 {
3709         IF_NOT_CONSTRUCTED(return Rectangle(0, 0, 0, 0));
3710
3711         return _CoordinateSystemUtils::ConvertToInteger(__rect);
3712 }
3713
3714 FloatRectangle
3715 TextObject::GetBoundsF(void) const
3716 {
3717         return __rect;
3718 }
3719
3720 int
3721 TextObject::GetLineSpace(void) const
3722 {
3723         IF_NOT_CONSTRUCTED(return -1);
3724
3725         return _CoordinateSystemUtils::ConvertToInteger(GetLineSpaceF());
3726 }
3727
3728 float
3729 TextObject::GetLineSpaceF(void) const
3730 {
3731         IF_NOT_CONSTRUCTED(return -1);
3732
3733         return __pCompositeText->GetLineSpaceF();
3734 }
3735
3736 int
3737 TextObject::GetTextLength(void) const
3738 {
3739         IF_NOT_CONSTRUCTED(return -1);
3740
3741         return __pCompositeText->GetTextLength();
3742 }
3743
3744 TextObjectAlignment
3745 TextObject::GetElementVerticalAlignment(void) const
3746 {
3747         IF_NOT_CONSTRUCTED(return TEXT_OBJECT_ALIGNMENT_INVALID);
3748
3749         return __pCompositeText->GetElementVerticalAlignment();
3750 }
3751
3752 TextObjectActionType
3753 TextObject::GetAction(void) const
3754 {
3755         IF_NOT_CONSTRUCTED(return TEXT_OBJECT_ACTION_TYPE_NONE);
3756
3757         return __action;
3758 }
3759
3760 TextObjectAlignment
3761 TextObject::GetAlignment(void) const
3762 {
3763         IF_NOT_CONSTRUCTED(return TEXT_OBJECT_ALIGNMENT_INVALID);
3764
3765         return __align;
3766 }
3767
3768 int
3769 TextObject::GetElementCount(void) const
3770 {
3771         IF_NOT_CONSTRUCTED(return -1);
3772
3773         return __pCompositeText->GetElementCount();
3774 }
3775
3776 TextElement*
3777 TextObject::GetElementAtElementIndex(int elementIndex) const
3778 {
3779         IF_NOT_CONSTRUCTED(return null);
3780
3781         return __pCompositeText->GetElementAtElementIndex(elementIndex);
3782 }
3783
3784 result
3785 TextObject::SetRange(int startTextIndex, int textLength)
3786 {
3787         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3788
3789         return __pCompositeText->SetRange(startTextIndex, textLength);
3790 }
3791
3792 void
3793 TextObject::GetRange(int& startTextIndex, int& textLength) const
3794 {
3795         IF_NOT_CONSTRUCTED(return);
3796
3797         return __pCompositeText->GetRange(startTextIndex, textLength);
3798 }
3799
3800 TextObjectWrapType
3801 TextObject::GetWrap(void) const
3802 {
3803         IF_NOT_CONSTRUCTED(return TEXT_OBJECT_WRAP_TYPE_NONE);
3804
3805         return __wrap;
3806 }
3807
3808 result
3809 TextObject::SetCursorIndex(int cursorIndex)
3810 {
3811         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3812
3813         SysTryReturn(NID_GRP, cursorIndex >= 0, E_INVALID_ARG, E_INVALID_ARG
3814                         , "[E_INVALID_ARG] The argument is invalid.");
3815
3816         __pCompositeText->SetCursorIndex(cursorIndex);
3817
3818         return E_SUCCESS;
3819 }
3820
3821 int
3822 TextObject::GetCursorIndex(void) const
3823 {
3824         IF_NOT_CONSTRUCTED(return -1);
3825
3826         return __pCompositeText->GetCursorIndex();
3827 }
3828
3829 result
3830 TextObject::SetBlock(bool enable)
3831 {
3832         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3833
3834         __pCompositeText->SetBlock(enable);
3835
3836         return E_SUCCESS;
3837 }
3838
3839 bool
3840 TextObject::GetBlock(void) const
3841 {
3842         IF_NOT_CONSTRUCTED(return false);
3843
3844         return __pCompositeText->GetBlock();
3845 }
3846
3847 result
3848 TextObject::SetBlockRange(int startTextIndex, int textLength)
3849 {
3850         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3851
3852         result r = E_SUCCESS;
3853         r = __pCompositeText->SetRange(startTextIndex, textLength);
3854         SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3855
3856         return E_SUCCESS;
3857 }
3858
3859 void
3860 TextObject::GetBlockRange(int& startTextIndex, int& textLength)
3861 {
3862         IF_NOT_CONSTRUCTED(return);
3863
3864         __pCompositeText->GetRange(startTextIndex, textLength);
3865 }
3866
3867 bool
3868 TextObject::IsAlternateLookEnabled(void) const
3869 {
3870         IF_NOT_CONSTRUCTED(return false);
3871
3872         return __isAlternateLookEnabled;
3873 }
3874
3875 int
3876 TextObject::GetTotalCutLinkElementCount(void) const
3877 {
3878         IF_NOT_CONSTRUCTED(return -1);
3879
3880         return __pCompositeText->GetCutLinkElementCount();
3881 }
3882
3883 result
3884 TextObject::ChangeCutLinkState(int linkIndex, bool select)
3885 {
3886         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3887
3888         return __pCompositeText->ChangeCutLinkState(linkIndex, select);
3889 }
3890
3891 result
3892 TextObject::ResetAllCutLinkElementsState(void)
3893 {
3894         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3895
3896         return __pCompositeText->ResetAllCutLinkElementsState();
3897 }
3898
3899 bool
3900 TextObject::IsActionOn(void) const
3901 {
3902         IF_NOT_CONSTRUCTED(return false);
3903
3904         return __isActionOn;
3905 }
3906
3907 TextObjectEllipsisType
3908 TextObject::GetTextObjectEllipsisType(void) const
3909 {
3910         IF_NOT_CONSTRUCTED(return TEXT_OBJECT_ELLIPSIS_TYPE_INVALID);
3911
3912         return __textObjectEllipsisType;
3913 }
3914
3915 result
3916 TextObject::ChangeText(int textIndex)
3917 {
3918         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3919
3920         if (__sweepInfo.isValid)
3921         {
3922                 __sweepInfo.isValid = false;
3923                 return E_INVALID_STATE;
3924         }
3925
3926         __sweepInfo.isValid = true;
3927         __sweepInfo.sweepType = TEXT_OBJECT_SWEEP_TYPE_REPLACE;
3928         __sweepInfo.sweepEventType = TEXT_OBJECT_SWEEP_EVENT_INSERT;
3929         __sweepInfo.anchorTextIndex = textIndex;
3930         __sweepInfo.sweepRegionStartLineIndex = GetLineIndexAtTextIndex(textIndex);
3931         __sweepInfo.sweepRegionLineCount = 1;
3932         __sweepInfo.anchorLineIndex = __sweepInfo.sweepRegionStartLineIndex;
3933         __sweepInfo.widthChanged = 0;
3934
3935         __pCompositeText->SetTextSweepInfo(&__sweepInfo);
3936
3937         return E_SUCCESS;
3938 }
3939
3940 result
3941 TextObject::InputText(int textIndex)
3942 {
3943         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3944
3945         if (__sweepInfo.isValid == true)
3946         {
3947                 __sweepInfo.isValid = false;
3948                 return E_INVALID_STATE;
3949         }
3950
3951         __sweepInfo.isValid = true;
3952         __sweepInfo.sweepType = TEXT_OBJECT_SWEEP_TYPE_KEYINPUT;
3953         __sweepInfo.sweepEventType = TEXT_OBJECT_SWEEP_EVENT_INSERT;
3954         __sweepInfo.anchorTextIndex = textIndex;
3955         __sweepInfo.prevAnchorLineIndex = GetLineIndexAtTextIndex(textIndex);
3956
3957         if (__sweepInfo.prevAnchorLineIndex == -1)
3958         {
3959                 __sweepInfo.prevAnchorLineIndex = __pTextColumn->GetTotalLineCount()-1;
3960         }
3961
3962         __pCompositeText->SetTextSweepInfo(&__sweepInfo);
3963
3964         return E_SUCCESS;
3965 }
3966
3967 result
3968 TextObject::RemoveText(int textIndex)
3969 {
3970         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3971
3972         if (__sweepInfo.isValid == true)
3973         {
3974                 __sweepInfo.isValid = false;
3975                 return E_INVALID_STATE;
3976         }
3977
3978         __sweepInfo.isValid = true;
3979         __sweepInfo.sweepEventType = TEXT_OBJECT_SWEEP_EVENT_REMOVE;
3980         __sweepInfo.anchorTextIndex = textIndex;
3981         __sweepInfo.prevAnchorLineIndex = GetLineIndexAtTextIndex(textIndex);
3982
3983         if (__sweepInfo.prevAnchorLineIndex == -1)
3984         {
3985                 __sweepInfo.prevAnchorLineIndex = __pTextColumn->GetTotalLineCount()-1;
3986         }
3987
3988         __pCompositeText->SetTextSweepInfo(&__sweepInfo);
3989
3990         return E_SUCCESS;
3991 }
3992
3993 result
3994 TextObject::ResetSweepInfo(void)
3995 {
3996         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
3997
3998         __sweepInfo.isValid = false;
3999
4000         return E_SUCCESS;
4001 }
4002
4003 TextObjectSweepInfo
4004 TextObject::GetSweepInfo(void) const
4005 {
4006         TextObjectSweepInfo textSweepInfo;
4007         textSweepInfo.isValid = false;
4008         textSweepInfo.sweepType = TEXT_OBJECT_SWEEP_TYPE_NONE;
4009         textSweepInfo.sweepEventType = TEXT_OBJECT_SWEEP_EVENT_NONE;
4010         textSweepInfo.anchorTextIndex = -1;
4011         textSweepInfo.anchorLineIndex = -1;
4012         textSweepInfo.prevAnchorLineIndex = -1;
4013         textSweepInfo.sweepRegionStartLineIndex = -1;
4014         textSweepInfo.sweepRegionLineCount = -1;
4015         textSweepInfo.insertedLineCount = -1;
4016         textSweepInfo.deletedLineCount = -1;
4017         textSweepInfo.widthChanged = -1;
4018
4019         IF_NOT_CONSTRUCTED(return textSweepInfo);
4020
4021         textSweepInfo.isValid = __sweepInfo.isValid;
4022         textSweepInfo.sweepType = __sweepInfo.sweepType;
4023         textSweepInfo.sweepEventType = __sweepInfo.sweepEventType;
4024         textSweepInfo.anchorTextIndex = __sweepInfo.anchorTextIndex;
4025         textSweepInfo.anchorLineIndex = __sweepInfo.anchorLineIndex;
4026         textSweepInfo.prevAnchorLineIndex = __sweepInfo.prevAnchorLineIndex;
4027         textSweepInfo.sweepRegionStartLineIndex = __sweepInfo.sweepRegionStartLineIndex;
4028         textSweepInfo.sweepRegionLineCount = __sweepInfo.sweepRegionLineCount;
4029         textSweepInfo.insertedLineCount = __sweepInfo.insertedLineCount;
4030         textSweepInfo.deletedLineCount = __sweepInfo.deletedLineCount;
4031         textSweepInfo.widthChanged = __sweepInfo.widthChanged;
4032
4033         return textSweepInfo;
4034 }
4035
4036 result
4037 TextObject::GetSweepComposeLineInfo(int lineIndex, TextObjectSweepComposeLineInfo& textSweepComposeLineInfo) const
4038 {
4039         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4040
4041         SysTryReturn(NID_GRP, lineIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4042
4043         TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex);
4044         SysTryReturn(NID_GRP, pTextLine, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4045
4046         textSweepComposeLineInfo = pTextLine->GetSweepComposeInfo();
4047
4048         return E_SUCCESS;
4049 }
4050
4051 int
4052 TextObject::GetTextOffsetAtLine(int lineIndex) const
4053 {
4054         IF_NOT_CONSTRUCTED(return -1);
4055
4056         SysTryReturn(NID_GRP, lineIndex >= 0, -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4057
4058         TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex);
4059         SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
4060
4061         return pTextLine->GetTextOffset();
4062 }
4063
4064 int
4065 TextObject::GetTextLengthAtLine(int lineIndex) const
4066 {
4067         IF_NOT_CONSTRUCTED(return -1);
4068
4069         SysTryReturn(NID_GRP, lineIndex >= 0, -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4070
4071         TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex);
4072         SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
4073
4074         return pTextLine->GetTextLength();
4075 }
4076
4077 Rectangle
4078 TextObject::GetBoundsAtLine(int lineIndex) const
4079 {
4080         return _CoordinateSystemUtils::ConvertToInteger(GetBoundsAtLineF(lineIndex));
4081 }
4082
4083 FloatRectangle
4084 TextObject::GetBoundsAtLineF(int lineIndex) const
4085 {
4086         IF_NOT_CONSTRUCTED(return FloatRectangle(-1, -1, -1, -1));
4087
4088         SysTryReturn(NID_GRP, lineIndex >= 0, FloatRectangle(-1, -1, -1, -1), E_INVALID_ARG
4089                         , "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4090
4091         TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex);
4092         SysTryReturn(NID_GRP, pTextLine, FloatRectangle(-1, -1, -1, -1), E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
4093
4094         FloatRectangle lineBounds = pTextLine->GetBoundsF();
4095
4096         return lineBounds;
4097 }
4098
4099 Point
4100 TextObject::GetDisplayPositionAtLine(int lineIndex, int textIndexFromLineOffset)
4101 {
4102         return _CoordinateSystemUtils::ConvertToInteger(GetDisplayPositionAtLineF(lineIndex, textIndexFromLineOffset));
4103 }
4104
4105 FloatPoint
4106 TextObject::GetDisplayPositionAtLineF(int lineIndex, int textIndexFromLineOffset)
4107 {
4108         IF_NOT_CONSTRUCTED(return FloatPoint(-1.0f, -1.0f));
4109
4110         SysTryReturn(NID_GRP, lineIndex >= 0, FloatPoint(-1.0f, -1.0f), E_INVALID_ARG
4111                         , "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4112
4113         TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex);
4114         SysTryReturn(NID_GRP, pTextLine, FloatPoint(-1.0f, -1.0f), E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
4115
4116         int lineOffset = pTextLine->GetTextOffset();
4117         int lineLength = pTextLine->GetTextLength();
4118         FloatDimension lineTextSize;
4119         FloatDimension extentDim;
4120         FloatRectangle lineBounds;
4121         int textCount = 0;
4122
4123         pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
4124         lineBounds = pTextLine->GetBoundsF();
4125
4126         __pCompositeText->ForwardAnalyze(lineOffset, textIndexFromLineOffset, lineTextSize.width, __wrap, textCount, extentDim.width, extentDim.height);
4127
4128         switch (__align & TEXT_ALIGNMASK_HORIZ)
4129         {
4130         case TEXT_OBJECT_ALIGNMENT_LEFT:
4131                 break;
4132
4133         case TEXT_OBJECT_ALIGNMENT_CENTER:
4134                 extentDim.width += (lineBounds.width - lineTextSize.width) / 2.0f;
4135                 break;
4136
4137         case TEXT_OBJECT_ALIGNMENT_RIGHT:
4138                 extentDim.width += (lineBounds.width - lineTextSize.width);
4139                 break;
4140         }
4141
4142         if (extentDim.width < 0.0f)
4143         {
4144                 extentDim.width = 0.0f;
4145         }
4146
4147         return FloatPoint(extentDim.width + __rect.x, lineBounds.y - __pTextColumn->GetFirstDisplayPositionYF() + __rect.y);
4148 }
4149
4150 Tizen::Base::String
4151 TextObject::GetDisplayableText(void)
4152 {
4153         IF_NOT_CONSTRUCTED(return -1);
4154
4155         return __pCompositeText->GetDisplayableText(__rect, __action);
4156 }
4157
4158 bool
4159 TextObject::WordExceedsWidthAt(int lineIndex) const
4160 {
4161         IF_NOT_CONSTRUCTED(return false);
4162
4163         SysTryReturn(NID_GRP, lineIndex >= 0, false, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex);
4164
4165         TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex);
4166         SysTryReturn(NID_GRP, pTextLine, false, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
4167
4168         bool hasOneWord = (pTextLine->GetEndType() == TEXT_RETBY_LIMITWIDTH) ? true : false;
4169
4170         return hasOneWord;
4171 }
4172
4173 void
4174 TextObject::SetTextBidiHint(TextBidiHint bidiHint)
4175 {
4176         switch (bidiHint)
4177         {
4178         case TEXT_BIDI_HINT_NONE:
4179         case TEXT_BIDI_HINT_LTR:
4180         case TEXT_BIDI_HINT_RTL:
4181                 __bidiHint = bidiHint;
4182                 break;
4183         }
4184 }
4185
4186 TextBidiHint
4187 TextObject::GetTextBidiHint(void) const
4188 {
4189         return __bidiHint;
4190 }
4191
4192 result
4193 TextObject::SetDisplayBoundsExpandEnabled(bool enable)
4194 {
4195         IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
4196
4197         __isDisplayBoundsExpandEnabled = enable;
4198
4199         return E_SUCCESS;
4200 }
4201
4202 bool
4203 TextObject::IsDisplayBoundsExpandEnabled(void) const
4204 {
4205         IF_NOT_CONSTRUCTED(return false);
4206
4207         return __isDisplayBoundsExpandEnabled;
4208 }
4209
4210 }}} // Tizen::Graphics::_Text