Tizen 2.1 base
[framework/osp/uifw.git] / src / graphics / text / FGrp_TextTextComposite.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_TextTextComposite.h
20  * @brief       This file contains the declarations of TextComposite class.
21  */
22
23 #ifndef _FGRP_INTERNAL_TEXT_COMPOSITE_H_
24 #define _FGRP_INTERNAL_TEXT_COMPOSITE_H_
25
26 #include <FBaseColLinkedList.h>
27 #include "FGrp_TextCommon.h"
28 #include "FGrp_TextTextElement.h"
29
30 namespace Tizen { namespace Graphics
31 {
32 class _CanvasImpl;
33
34 namespace _Text
35 {
36
37 class TextSimple;
38 class TextCutLink;
39 class TextLine;
40 class TextColumn;
41 class TextCutLinkListInfo;
42 class TextWidthManager;
43 struct NoneWrapComposeInfo;
44
45 class TextComposite
46 {
47 public:
48         TextComposite(TextElement* pTextElement = null);
49
50         virtual ~TextComposite(void);
51
52 public:
53         virtual int ForwardAnalyze(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap,
54                                                                                 int& actualLength, int& width, int& height);
55
56         virtual int ForwardAnalyzeWithBaseline(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap,
57                                                                                 int& actualLength, int& width, int& height, int& baseline);
58
59         virtual int ForwardAnalyzeWithFocusedObjectType(int textIndex, int textLength, int maxWidth,
60                                                                                 int& cursorIndex, TextElementType& type);
61
62         virtual result Draw(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment alignment,
63                         const TextObjectActionType action);
64
65         virtual result GetRegion(int textIndex, int textLength, int& width, int& height) const;
66
67         virtual int GetHeight(int textIndex) const;
68
69         virtual int GetTextLength(void) const;
70
71         virtual int Compose(Rectangle& rect, TextColumn* pTextColumn);
72
73         result DrawWithBaseline(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment alignment,
74                         const TextObjectActionType action, int baseline);
75
76         result InsertElementAt(TextElement& textElement, int textIndex);
77
78         result AppendElement(TextElement& textElement);
79
80         result RemoveElementAt(int elementIndex, bool deallocate = true);
81
82         result RemoveAllElements(bool deallocate = true);
83
84         result DrawLine(_CanvasImpl& canvasImpl, TextLine* pTextLine, const Rectangle& displayRect, const TextObjectAlignment align, const TextObjectActionType action);
85
86         result DrawPartial(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength);
87
88         result DrawAbbrev(_CanvasImpl& canvasImpl, const Rectangle& displayRect, const TextObjectAlignment align);
89
90         result GetText(TextComposite* pTargetCompsiteText, int textIndex, int textLength);
91
92         result Optimize(int startElementIndex, int endElementIndex);
93
94         bool IsComposeDone(void) const;
95
96         result ChangeTextOffset(wchar_t* pText, int elementIndex, int gap);
97
98         result NotifyTextChanged(wchar_t* pText, int startTextIndex, int textLength, int gap, Font* pFont,
99                                    const Color& fgColor, const Color& bgColor, const Color& outlineColor);
100
101         void HideFrontSpace(TextObjectSpaceHideType mode);
102
103         void HideRearSpace(TextObjectSpaceHideType mode);
104
105         result GetValue(TextElement* pTextElement, TextComponentInfoValueType type, unsigned int* value) const;
106
107         int GetElementCount(void) const;
108
109         int GetElementIndexOf(TextElement& textElement) const;
110
111         TextElement* GetElementAtElementIndex(int elementIndex) const;
112
113         TextElement* GetElementAtTextIndex(int textIndex, int& elementTextOffset, int& elementIndex, int& elementTextLength,
114                                                                            int& textIndexFromElementOffset) const;
115
116         TextElement* GetElementAtTextIndex(int textIndex) const;
117
118         result SetFont(Font* pFont);
119
120         Font* GetFont(int textIndex)  const;
121
122         result SetForegroundColor(const Color& color);
123
124         Color GetForegroundColor(int textIndex) const;
125
126         result SetBackgroundColor(const Color& color);
127
128         Color GetBackgroundColor(int textIndex) const;
129
130         result SetOutlineColor(const Color& color);
131
132         Color GetOutlineColor(int textIndex) const;
133
134         Color GetAlternativeForegroundColor(int textIndex) const;
135
136         result SetRange(int textStartIndex, int textLength);
137
138         void GetRange(int& startTextIndex, int& textLength) const;
139
140         void SetLineSpace(int gap);
141
142         int GetLineSpace(void) const;
143
144         void SetElementVerticalAlignment(TextObjectAlignment alignment);
145
146         TextObjectAlignment GetElementVerticalAlignment(void) const;
147
148         result SetWrap(TextObjectWrapType wrap);
149
150         TextObjectWrapType GetWrap(void) const;
151
152         void SetBlock(bool enable);
153
154         bool GetBlock(void) const;
155
156         result SetImageAlign(TextObjectAlignment align);
157
158         TextObjectAlignment GetImageAlign(int textIndex) const;
159
160         void SetCursorIndex(int cursorIndex);
161
162         int GetCursorIndex(void) const;
163
164         void SetTextAbbreviationEnabled(bool enable);
165
166         bool IsTextAbbreviationEnabled(void) const;
167
168         void SetPartialComposingModeEnabled(bool enable);
169
170         bool IsPartialComposingModeEnabled(void) const;
171
172         void SetComposePartialLimitHeight(int limitHeight);
173
174         int GetComposePartialLimitHeight(void) const;
175
176         void SetWidthManagerEnabled(bool widthManagerEnable);
177
178         bool IsWidthManagerEnabled(void) const;
179
180         void SetTextObjectEllipsisType(TextObjectEllipsisType type);
181
182         TextObjectEllipsisType GetTextObjectEllipsisType(void) const;
183
184         int ForwardAnalyzeInNoneCursorMode(int startTextIndex, int textLength, int maxWidth, int& textIndex);
185
186         int GetTotalComposedHeight(void) const;
187
188         int GetAnalysedTotalHeight(void) const;
189
190         bool IsChanged(void) const;
191
192         result ChangeCutLinkState(int linkIndex, bool select);
193
194         result ResetAllCutLinkElementsState(void);
195
196         int GetCutLinkElementCount(void) const;
197
198         int GetCutLinkElementIndexAt(int textIndex) const;
199
200         TextCutLink* GetCutLinkElementAtCutLinkElementIndex(int index) const;
201
202         result GetCutLinkObjectInfo(int cutLinkIndex, int& textStartIndex, int& textLength) const;
203
204         bool InitPartialComposeMode(void);
205
206         void SetTextWidthManager(TextWidthManager* pTextWidthManager);
207
208         TextElement* SearchTextElement(TextElementType type, int textIndex, int& elementTextOffset) const;
209
210         TextElementType GetObjectType(int textIndex) const;
211
212         int GetMaxLineHeight(void) const;
213
214         int GetWorkStart(void) const;
215
216         int GetWorkLength(void) const;
217
218         result SetAlternateLookEnabled(bool enable);
219
220         result SetWorkWidth(Font* pFont, wchar_t* pText, int workStart, int textLength);
221
222         int GetWorkWidth(void);
223
224         void SetTextSweepInfo(TextObjectSweepInfo* pTextSweepInfo);
225
226         void GetTextSweepInfo(TextObjectSweepInfo& textSweepInfo);
227
228         void UpdateTextSweepInfo(TextObjectSweepInfo* pTextSweepInfo);
229
230         void SetBlockColor(const Color& color);
231
232         Color GetBlockColor(void) const;
233
234 private:
235         int ComposeInNoneWrap(Rectangle& rect, NoneWrapComposeInfo* pNoneWrapComposeInfo = null);
236
237         int ComposeInNormalWrap(Rectangle& rect);
238
239         int ComposeInWordWrap(Rectangle& rect);
240
241         int ComposeInWrap(Rectangle& rect);
242
243         int ComposeInWrapByTextWidth(Rectangle& rect);
244
245         int ComposeInNoneWrapMiddleEllipsis(Rectangle& rect);
246
247         int ComposeInNoneWrapHeadEllipsis(Rectangle& rect);
248
249         int ComposeInPartialMode(Rectangle& rect);
250
251         bool BackwardAnalyze(int startTextIndex, int maxWidth, int* actualLength, int* width, int* height);
252
253         result DrawAbbrevInMiddleEllipsis(_CanvasImpl& canvasImpl, const Rectangle& displayRect, const TextObjectAlignment alignment);
254
255         result DrawAbbrevInHeadEllipsis(_CanvasImpl& canvasImpl, const Rectangle& displayRect, const TextObjectAlignment alignmen);
256
257         result SetValueToAllTextElements(TextComponentInfoValueType type, unsigned int value);
258
259         bool SetAbbrevObjectFontInfo(TextSimple* pSimpleTextElement);
260
261         result GetValue(int textIndex, TextComponentInfoValueType type, unsigned int* value) const;
262
263         int GetFirstTextIndexAt(int elementIndex) const;
264
265 private:
266         bool __isChanged;
267         TextObjectWrapType __wrap;
268         int __length;
269         Tizen::Base::Collection::LinkedList* __pTextElementList;
270         Color __defaultBlockColor;
271         bool __displayBlock;
272         int __workStart;
273         int __workLength;
274         int __workWidth;
275         int __cursorIndex;
276         bool __ignoreRearBlank;
277         bool __ignoreFrontBlank;
278         TextObjectSpaceHideType __rearSpaceHideMode;
279         TextObjectSpaceHideType __frontSpaceHideMode;
280         int __lineSpacing;
281         TextObjectAlignment __elementVertialAlignment;
282         TextColumn* __pCurrentTextColumn;
283         TextSimple* __pAbbrevTextElement;
284         bool __partialComposingModeEnabled;
285         int __lineIndexCompositeDone;
286         int __totalComposedHeight;
287         int __composePartialLimitHeight;
288         TextCutLinkListInfo* __pCutLinkListInfo;
289         TextObjectEllipsisType __TextObjectEllipsisType;
290         bool __drawAbbrevText;
291         bool __drawTextEllipsis;
292         int __middleEllipsisTextLengthInHead;
293         int __middleEllipsisHeadWidth;
294         int __middleEllipsisWidth;
295         int __middleEllipsisTextLengthInTail;
296         int __headEllipsisWidth;
297         int __headEllipsisTextLength;
298         TextWidthManager* __pTextWidthManager;
299         bool __widthManagerEnabled;
300
301         TextObjectSweepInfo* __pSweepInfo;
302
303 private:
304         TextComposite(const TextComposite&); // NOT IMPLMENTED
305
306         TextComposite& operator =(const TextComposite&); // NOT IMPLMENTED
307
308 }; // TextComposite
309
310 }}} // Tizen::Graphics::_Text
311
312 #endif // _FGRP_INTERNAL_TEXT_COMPOSITE_H_