Tizen 2.1 base
[framework/osp/uifw.git] / src / graphics / text / FGrp_TextTextWidthManager.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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_TextTextWidthManager.h
20  * @brief       This is the header file for the TextWidthManager class.
21  *
22  * This header file contains the declarations of the %TextWidthManager class.
23  */
24
25 #ifndef _FGRP_INTERNAL_TEXT_WIDTH_MANAGER_H_
26 #define _FGRP_INTERNAL_TEXT_WIDTH_MANAGER_H_
27
28 #include "FGrp_TextCommon.h"
29 #include "FGrp_TextTextElement.h"
30 #include "FGrp_TextTextSimpleList.h"
31
32 namespace Tizen { namespace Graphics
33 {
34
35 namespace _Text
36 {
37
38 struct TextWidthCommonInfo;
39 struct WordTextWidthInfo;
40
41 struct TextLineComposeInfo
42 {
43         int length;
44         int width;
45         int height;
46         int endType;
47 };
48
49 class TextWidthManager
50 {
51 public:
52         TextWidthManager(TextComposite* pCompositeText);
53
54         virtual ~TextWidthManager(void);
55
56 public:
57         bool Initialize(int textLength);
58
59         bool Finalize(void);
60
61         bool StartCompose(int textIndex);
62
63         bool GetCurrentLineInfo(int lineWidth, TextLineComposeInfo& textLineComposeInfo);
64
65         bool EndCompose(void);
66
67         bool InformTextInsert(int textIndex, int textLength);
68
69         bool InformTextRemove(int textIndex, int textLength);
70
71 private:
72         SimpleNode* SplitWidthInfo(SimpleNode* pOrginalTextWidhtInfoNode, int splitStartIndex, TextWidthCommonInfo* pTextWidthInfo);
73
74         WordTextWidthInfo* SplitCurrentWordWidthInfo(int limitWidth, bool& isNextKoreanStart);
75
76         WordTextWidthInfo* SplitWordWidthInfo(SimpleNode* pCurrentWordWidthInfoNode, TextElement* pCurrentTextElement, int strCurrentRelIndex, int strCurrentLength, int limitWidth, bool& isNextKoreanStart);
77
78         bool Seek(int textLength);
79
80         bool AnalyzeCurrentUnKnownTextWidthInfo(int limitWidth);
81
82         SimpleNode* AnalyzeUnKnownTextWidthInfo(SimpleNode* pCurrentWordWidthInfoNode, TextElement* pCurrentTextElement, int strCurrentRelIndex, int strCurrentLength, int limitWidth);
83
84         bool AnalyzeNextTextWidthInfo(int limitWidth, bool& wordoverWidth, int& widthAnlyzed, int& strLengthAalyzed, int& heightAnalzyed, bool& isnextKorean, bool& meetCutlink);
85
86         bool UpdateCachedTextWidhtInfo(int widthInfoTextOffset, SimpleNode* pTextWidthInfoNode);
87
88         SimpleNode* SearchTextWidthInfo(int textIndex, int& widthInfoTextOffset);
89
90         bool IsKorean(wchar_t strChar);
91
92         int GetTextWidthInfoLength(TextWidthCommonInfo* pTextWidthCommonInfo);
93
94 private:
95         TextComposite* __pCompositeText;
96         TextElement* __pCurrentComposeTextElement;
97         TextElementType __currentTextElementType;
98         int __currentComposeTextElementIndex;
99         SimpleNode* __pCurrentWordWidthInfoNode;
100         SimpleNode* __pCachedWordWidthInfoNode;
101         SimpleList* __pTextWidthInfoList;
102         bool __isInitialized;
103         bool __isComposing;
104         int __length;
105         int __currentTextIndex;
106         int __strCurrentRelIndex;
107         int __currentTextElementLength;
108         int __textOffsetOfCurrentWidthInfo;
109         int __textOffsetOfCachedWidthInfo;
110
111 private:
112         TextWidthManager(const TextWidthManager& other); // NOT IMPLMENTED
113
114         TextWidthManager& operator =(const TextWidthManager& rhs); // NOT IMPLMENTED
115
116 }; // TextWidthManager
117
118 }}} // Tizen::Graphics::_Text
119
120 #endif // _FGRP_INTERNAL_TEXT_WIDTH_MANAGER_H_