Tizen 2.1 base
[framework/osp/uifw.git] / src / graphics / text / FGrp_TextTextColumn.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_TextTextColumn.h
20  * @brief       This file contains the declarations of TextColumn class.
21 */
22
23 #ifndef _FGRP_INTERNAL_TEXT_COLUMN_H_
24 #define _FGRP_INTERNAL_TEXT_COLUMN_H_
25
26 #include "FGrp_TextCommon.h"
27 #include "FGrp_TextTextSimpleList.h"
28
29 namespace Tizen { namespace Graphics
30 {
31 class _CanvasImpl;
32
33 namespace _Text
34 {
35 class TextComposite;
36 class TextLine;
37 struct ChangeActionEventInfo;
38
39 class TextColumn
40 {
41 public:
42         enum ChangeAction
43         {
44                 TEXT_CHANGE_INSERT = 0,
45                 TEXT_CHANGE_REMOVE,
46                 TEXT_CHANGE_REPLACE,
47                 TEXT_CHANGE_UNKONWN
48         };
49
50         enum ActionProcessResult
51         {
52                 BEFORE_ACTION = 0,
53                 AFTER_ACTION,
54                 MERGE_ACTION,
55                 MERGE_AND_BEFORE_ACTION,
56                 MERGE_AND_AFTER_ACTION,
57                 COLLAPSE_ACTION,
58                 ERROR_ACTION
59         };
60
61         enum KeyInputResult
62         {
63                 NOT_CHANGED = 0,
64                 FORWARD_SWEEP,
65                 BACKWARD_SWEEP
66         };
67
68 public:
69         TextColumn(TextComposite* pCompositeText = null);
70
71         virtual ~TextColumn(void);
72
73 public:
74         virtual result Draw(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex,
75                                                         int textLength, const TextObjectAlignment alignment, const TextObjectActionType action);
76
77         virtual result GetRegion(int textIndex, int textLength, int& width, int& height) const;
78
79         virtual int GetHeight(int textIndex) const;
80
81         virtual int GetTextLength(void) const;
82
83         virtual int ForwardAnalyze(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap,
84                                                                                 int& actualLength, int& width, int& height);
85
86         result Append(TextLine* pTextLine);
87
88         result AddLineDuringCompose(TextLine* pTextLine);
89
90         result Remove(TextLine* pTextLine);
91
92         result RemoveAllLines(void);
93
94         result PrepareCompose(void);
95
96         result FinishCompose(bool isUpdateSweepInfo = true);
97
98         bool IsComposeDone(void);
99
100         int GetTotalHeight(void) const;
101
102         int GetLineHeightAt(int index) const;
103
104         int GetTotalLineCount(void) const;
105
106         int GetLineIndexAtTextIndex(int textIndex) const;
107
108         int GetLineIndexAtPositionY(int y);
109
110         TextLine* GetTextLine(int lineIndex) const;
111
112         SimpleNode* GetTextLineNode(int lineIndex) const;
113
114         void SetFirstDisplayLineIndex(int lineIndex);
115
116         int GetFirstDisplayLineIndex(void) const;
117
118         void SetDisplayLineCount(int displayLineCount);
119
120         int GetDisplayLineCount(void) const;
121
122         void SetDisplayHeight(int height);
123
124         int GetDisplayHeight(void) const;
125
126         void SetFirstDisplayPositionY(int y);
127
128         int GetFirstDisplayPositionY(void) const;
129
130         int GetTextLengthAt(int lineIndex) const;
131
132         int GetFirstTextIndexAt(int lineIndex) const;
133
134         result SetSlidingDimension(Tizen::Graphics::Dimension& slidingDimension);
135
136         Tizen::Graphics::Dimension GetSlidingDimension(void) const;
137
138         void SetSlidingPosition(int slidingPosition);
139
140         int GetSlidingPosition(void) const;
141
142         TextLine* GetPrevLineChangedStartLine(void) const;
143
144         int GetChangeActionEventCount(void) const;
145
146         void SetChangedStartLineIndex(int changedStartLineIndex);
147
148         int GetChangedStartLineIndex(void) const;
149
150         void SetChangedLastLineIndex(int changedLastLineIndex);
151
152         int GetChangedLastLineIndex(void) const;
153
154         int GetChangedStrStartIndex(void) const;
155
156         result SetChangeAction(ChangeAction changeAction, int textIndex, int textLength);
157
158         result RemoveAllKeepLines(void);
159
160         TextObjectSweepType GetTextSweepType(void);
161
162         result UpdateSweepInfo(void);
163
164         result UpdateSweepInfoFirstLine(void);
165
166         result SetKeyInputLine(int changedStartlineIndex, int lineCount);
167
168         result CompareDeletedLine(void);
169
170 private:
171         result RemoveLines(int lineIndex, int lineCount);
172
173         result RemoveLinesFrom(int lineIndex);
174
175         void RemoveAllChangeActions(void);
176
177         result UpdateCompositionInfo(int changedStartTextIndex, int changedEndTextIndex, int changedTextLength, bool existUnkownAction);
178
179         result GetTextChangedInfo(int& changedStartTextIndex, int& changedEndTextIndex, int& changedTextLength, bool& existUnkownAction) const;
180
181         ActionProcessResult DoProcessTextAction(ChangeAction inputAction, int textIndex, int textLength,
182                                                                                                 ChangeActionEventInfo* pCurrentStrActionEventInfo, int& changedStartTextIndex,
183                                                                                                 int& strOutputChangedNum);
184
185         ActionProcessResult DoProcessUnknownThroughUnknown(int textIndex, ChangeActionEventInfo* pCurrentActionEventInfo);
186
187         ActionProcessResult DoProcessUnkownThroughInsert(int textIndex, ChangeActionEventInfo* pCurrentActionEventInfo,
188                                                                                                            int& strOutputStartIndex);
189
190         ActionProcessResult DoProcessUnkownThroughRemove(int textIndex, ChangeActionEventInfo* pCurrentActionEventInfo,
191                                                                                                            int& changedStartTextIndex);
192
193         ActionProcessResult DoProcessInsertThroughUnkown(int textIndex, ChangeActionEventInfo* pCurrentActionEventInfo);
194
195         ActionProcessResult DoProcessInsertThroughInsert(int textIndex, int textLength,
196                                                                                                                   ChangeActionEventInfo* pCurrentActionEventInfo, int& changedStartTextIndex);
197
198         ActionProcessResult DoProcessInsertThroughRemove(int textIndex, ChangeActionEventInfo* pCurrentActionEventInfo,
199                                                                                                                   int& changedStartTextIndex);
200
201         ActionProcessResult DoProcessRemoveThroughUnkown(int textIndex, ChangeActionEventInfo* pCurrentActionEventInfo);
202
203         ActionProcessResult DoProcessRemoveThroughInsert(int textIndex, int textLength,
204                                                                                                                   ChangeActionEventInfo* pCurrentActionEventInfo, int& changedStartTextIndex,
205                                                                                                                   int& strOutputChangedNum);
206
207         ActionProcessResult DoProcessRemoveThroughRemove(int textIndex, ChangeActionEventInfo* pCurrentActionEventInfo,
208                                                                                                                   int& changedStartTextIndex);
209
210         result KeepLines(int lineIndex, int lineCount);
211
212 private:
213         TextComposite* __pCompositeText;
214         SimpleList* __pLines;
215         SimpleList* __pTextChangeActionList;
216         int __totalLineCount;
217         int __firstDisplayLineIndex;
218         int __firstDisplayPositionY;
219         int __displayLineCount;
220         int __displayHeight;
221         Tizen::Graphics::Dimension __slidingDimension;
222         int __slidingPosition;
223         bool __setChangeAction;
224         ChangeAction __textChangeAction;
225         int __chagedStartTextIndex;
226         int __changedTextLength;
227         int __changedStartLineIndex;
228         int __changedLastLineIndex;
229         int __prevLineIndexBeforeChangedStartLine;
230         int __nextLineIndexAfterChangedLastLine;
231         int __textOffsetOfNextLineAfterChangedLine;
232         int __currentLineIndexToAddDuringCompose;
233         bool __isComposeDone;
234         SimpleNode* __pCachedLineNode;
235         int __cachedLineIndex;
236         int __cachedLinePositionY;
237
238         SimpleList* __pKeepLines;
239         int __keepLineCount;
240         int __insertedLineCountDuringCompose;
241
242 private:
243         TextColumn(const TextColumn& other); // NOT IMPLMENTED
244
245         TextColumn& operator =(const TextColumn& rhs); // NOT IMPLMENTED
246
247 }; // TextColumn
248
249 }}} // Tizen::Graphics::_Text
250
251 #endif // _FGRP_INTERNAL_TEXT_COLUMN_H_