2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FGrp_TextTextLine.cpp
20 * @brief This is the implementation file for TextLine class.
24 #include <FBaseSysLog.h>
25 #include "FGrp_CanvasImpl.h"
26 #include "FGrp_TextCommon.h"
27 #include "FGrp_TextTextComposite.h"
28 #include "FGrp_TextTextLine.h"
30 namespace Tizen { namespace Graphics
36 TextLine::TextLine(TextComposite* pCompositeText)
49 __pCompositeText = pCompositeText;
52 __sweepComposeLineInfo.isValid = false;
53 __sweepComposeLineInfo.prevLineTextOffset = 0;
54 __sweepComposeLineInfo.prevLineTextLength = 0;
55 __sweepComposeLineInfo.prevLineWidth = 0;
56 __sweepComposeLineInfo.currentLineTextOffset = 0;
57 __sweepComposeLineInfo.currentLineTextLength = 0;
58 __sweepComposeLineInfo.currentLineWidth = 0;
63 __isKeyInputChanged = false;
64 __keyInputTextIndex = 0;
65 __keyInputTextLength = 0;
68 TextLine::~TextLine(void)
74 TextLine::GetRegion(int textIndex, int textLength, int& width, int& height) const
76 if (textIndex != 0 || textLength != __textLength)
78 return __pCompositeText->GetRegion(textIndex + __textOffset, textIndex + textLength + __textOffset, width, height);
89 TextLine::GetHeight(int textIndex) const
95 else if (textIndex >= 0 && textIndex < __textLength)
97 return __pCompositeText->GetHeight(textIndex + __textOffset);
106 TextLine::Draw(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment align,
107 const TextObjectActionType action)
110 , startTextIndex == 0 && textLength == __textLength && __pCompositeText != null
111 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
113 return __pCompositeText->DrawLine(canvasImpl, this, displayRect, align, action);
117 TextLine::DrawPartial(_CanvasImpl& canvasImpl, int startTextIndex, int textLength, Rectangle& displayRect)
120 , __pCompositeText != null
121 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
123 int textIndexAtLine = GetTextOffset() + startTextIndex;
125 return __pCompositeText->DrawPartial(canvasImpl, displayRect, textIndexAtLine, textLength);
129 TextLine::CopyN(void)
131 TextLine* pTextLine = null;
133 pTextLine = new (std::nothrow) TextLine(__pCompositeText);
137 , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
139 pTextLine->__index = __index;
140 pTextLine->__textOffset = __textOffset;
141 pTextLine->__textLength = __textLength;
142 pTextLine->__width = __width;
143 pTextLine->__height = __height;
144 pTextLine->__endType = __endType;
145 pTextLine->__rect.x = __rect.x;
146 pTextLine->__rect.y = __rect.y;
147 pTextLine->__rect.height = __rect.height;
148 pTextLine->__rect.width = __rect.width;
154 TextLine::GetBounds(void) const
161 TextLine::GetTextLength(void) const
167 TextLine::SetTextLength(int length)
169 __textLength = length;
173 TextLine::SetIndex(int index)
179 TextLine::GetIndex(void) const
185 TextLine::SetTextOffset(int textOffset)
187 __textOffset = textOffset;
193 TextLine::GetTextOffset(void) const
199 TextLine::SetBounds(const Rectangle& rect)
207 TextLine::SetEndType(int endType)
213 TextLine::GetEndType(void) const
219 TextLine::SetRegion(int width, int height)
226 TextLine::SetBaseline(int baseline)
228 __baseline = baseline;
232 TextLine::GetBaseline(void) const
238 TextLine::ForwardAnalyze(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap,
239 int& actualLength, int& width, int& height)
245 TextLine::ResetSweepInfo(void)
247 __sweepComposeLineInfo.isValid = false;
253 TextLine::SetSweepComposeInfo(TextObjectSweepComposeLineInfo& textSweepComposeLineInfo)
255 __sweepComposeLineInfo.isValid = textSweepComposeLineInfo.isValid;
256 __sweepComposeLineInfo.prevLineTextOffset = textSweepComposeLineInfo.prevLineTextOffset;
257 __sweepComposeLineInfo.prevLineTextLength = textSweepComposeLineInfo.prevLineTextLength;
258 __sweepComposeLineInfo.prevLineWidth = textSweepComposeLineInfo.prevLineWidth;
259 __sweepComposeLineInfo.currentLineTextOffset = textSweepComposeLineInfo.currentLineTextOffset;
260 __sweepComposeLineInfo.currentLineTextLength = textSweepComposeLineInfo.currentLineTextLength;
261 __sweepComposeLineInfo.currentLineWidth = textSweepComposeLineInfo.currentLineWidth;
264 TextObjectSweepComposeLineInfo
265 TextLine::GetSweepComposeInfo(void) const
267 TextObjectSweepComposeLineInfo textSweepComposeLineInfo;
269 textSweepComposeLineInfo.isValid = __sweepComposeLineInfo.isValid;
270 textSweepComposeLineInfo.prevLineTextOffset = __sweepComposeLineInfo.prevLineTextOffset;
271 textSweepComposeLineInfo.prevLineTextLength = __sweepComposeLineInfo.prevLineTextLength;
272 textSweepComposeLineInfo.prevLineWidth = __sweepComposeLineInfo.prevLineWidth;
273 textSweepComposeLineInfo.currentLineTextOffset = __sweepComposeLineInfo.currentLineTextOffset;
274 textSweepComposeLineInfo.currentLineTextLength = __sweepComposeLineInfo.currentLineTextLength;
275 textSweepComposeLineInfo.currentLineWidth = __sweepComposeLineInfo.currentLineWidth;
277 return textSweepComposeLineInfo;
281 TextLine::SetSweepIn(int sweepIn)
287 TextLine::GetSweepIn(void) const
293 TextLine::SetSweepOut(int sweepOut)
295 __sweepOut = sweepOut;
299 TextLine::GetSweepOut(void) const
305 TextLine::SetKeyInputResult(int keyInputResult)
307 __sweepType = keyInputResult;
311 TextLine::GetKeyInputResult(void) const
317 TextLine::NotifyLineChanged(bool isChanged)
319 __isKeyInputChanged = isChanged;
323 TextLine::isChanged(void) const
325 return __isKeyInputChanged;
329 TextLine::SetKeyInputOffset(int keyInputTextIndex)
331 __keyInputTextIndex = keyInputTextIndex;
335 TextLine::GetKeyInputOffset(void) const
337 return __keyInputTextIndex;
341 TextLine::SetKeyInputLength(int keyInputTextLength)
343 __keyInputTextLength = keyInputTextLength;
347 TextLine::GetKeyInputLength(void)
349 return __keyInputTextLength;
352 }}} // Tizen::Graphics::_Text