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 FGrpEnrichedText.cpp
20 * @brief This is the cpp file for EnrichedText class.
25 #include <FGrpEnrichedText.h>
26 #include <FBaseString.h>
28 #include <FBaseUtilTypes.h>
30 #include <FBaseSysLog.h>
32 #include "FGrp_EnrichedTextImpl.h"
33 #include "FGrp_ResUtil.h"
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::Graphics;
38 using namespace Tizen::Base::Utility;
40 #define CHECK_NOT_CONSTRUCTED \
41 SysTryReturnResult(NID_GRP, this->__pImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Fails to allocate memory.") \
42 SysAssertf(!this->__pImpl->IsConstructed(), \
43 "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
45 #define CHECK_CONSTRUCTED \
47 SysAssertf((this->__pImpl != null) && this->__pImpl->IsConstructed(), \
48 "Not yet constructed. Construct() should be called before use.");
50 #define CHECK_CONSTRUCTED_EX(_result) \
52 SysAssertf((this->__pImpl != null) && this->__pImpl->IsConstructed(), \
53 "Not yet constructed. Construct() should be called before use.");
55 #define CHECK_CONSTRUCTED_VOID \
57 SysAssertf((this->__pImpl != null) && this->__pImpl->IsConstructed(), \
58 "Not yet constructed. Construct() should be called before use.");
60 namespace Tizen { namespace Graphics
63 EnrichedText::EnrichedText()
65 __pImpl = new (std::nothrow) _EnrichedTextImpl;
68 EnrichedText::~EnrichedText()
78 EnrichedText::Construct(const Tizen::Graphics::Dimension& dim)
80 CHECK_NOT_CONSTRUCTED;
82 result r = __pImpl->Construct(dim);
83 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r));
89 EnrichedText::InsertAt(int elementIndex, Tizen::Graphics::TextElement& element)
93 return __pImpl->InsertAt(elementIndex, element);
97 EnrichedText::RemoveAt(int elementIndex, bool deallocate)
101 return __pImpl->RemoveAt(elementIndex, deallocate);
105 EnrichedText::Remove(Tizen::Graphics::TextElement& element, bool deallocate)
109 return __pImpl->Remove(element, deallocate);
113 EnrichedText::Add(Tizen::Graphics::TextElement& element)
117 return __pImpl->Add(element);
121 EnrichedText::RemoveAllTextElements(bool deallocate)
125 return __pImpl->RemoveAllTextElements(deallocate);
129 EnrichedText::RemoveAll(bool deallocate)
133 return __pImpl->RemoveAll(deallocate);
137 EnrichedText::GetTextElementAt(int elementIndex) const
139 CHECK_CONSTRUCTED_EX(null);
141 return __pImpl->GetTextElementAt(elementIndex);
145 EnrichedText::GetTextElementCount(void) const
147 CHECK_CONSTRUCTED_EX(0);
149 return __pImpl->GetTextElementCount();
153 EnrichedText::SetSize(const Tizen::Graphics::Dimension& size)
157 return __pImpl->SetSize(size);
161 EnrichedText::SetSize(int width, int height)
165 return __pImpl->SetSize(width, height);
168 Tizen::Graphics::Dimension
169 EnrichedText::GetSize(void) const
171 CHECK_CONSTRUCTED_EX(Dimension(0, 0));
173 return __pImpl->GetSize();
177 EnrichedText::GetSize(int& width, int& height) const
179 CHECK_CONSTRUCTED_VOID;
181 return __pImpl->GetSize(width, height);
185 EnrichedText::GetWidth(void) const
187 CHECK_CONSTRUCTED_EX(0);
189 return __pImpl->GetWidth();
193 EnrichedText::GetHeight(void) const
195 CHECK_CONSTRUCTED_EX(0);
197 return __pImpl->GetHeight();
201 EnrichedText::SetVerticalAlignment(TextVerticalAlignment alignment)
205 return __pImpl->SetVerticalAlignment(alignment);
209 EnrichedText::SetHorizontalAlignment(TextHorizontalAlignment alignment)
213 return __pImpl->SetHorizontalAlignment(alignment);
216 TextVerticalAlignment
217 EnrichedText::GetVerticalAlignment(void) const
219 CHECK_CONSTRUCTED_EX(TEXT_ALIGNMENT_VERTICAL_MIN);
221 return __pImpl->GetVerticalAlignment();
224 TextHorizontalAlignment
225 EnrichedText::GetHorizontalAlignment(void) const
227 CHECK_CONSTRUCTED_EX(TEXT_ALIGNMENT_HORIZONTAL_MIN);
229 return __pImpl->GetHorizontalAlignment();
233 EnrichedText::SetTextWrapStyle(TextWrap wrap)
237 return __pImpl->SetTextWrapStyle(wrap);
241 EnrichedText::GetTextWrapStyle(void) const
243 CHECK_CONSTRUCTED_EX(TEXT_WRAP_MIN);
245 return __pImpl->GetTextWrapStyle();
249 EnrichedText::SetTextAbbreviationEnabled(bool enable)
253 return __pImpl->SetTextAbbreviationEnabled(enable);
257 EnrichedText::IsTextAbbreviationEnabled(void) const
259 CHECK_CONSTRUCTED_EX(false);
261 return __pImpl->IsTextAbbreviationEnabled();
265 EnrichedText::SetLineSpace(int lineSpace)
269 return __pImpl->SetLineSpace(lineSpace);
273 EnrichedText::GetLineSpace(void) const
275 CHECK_CONSTRUCTED_EX(0);
277 return __pImpl->GetLineSpace();
281 EnrichedText::Refresh(void)
283 CHECK_CONSTRUCTED_VOID;
285 return __pImpl->Refresh();
289 EnrichedText::GetTotalLineCount(void) const
291 CHECK_CONSTRUCTED_EX(0);
293 return __pImpl->GetTotalLineCount();
297 EnrichedText::GetTotalLineHeight(void) const
299 CHECK_CONSTRUCTED_EX(0);
301 return __pImpl->GetTotalLineHeight();
305 EnrichedText::GetDisplayLineCount(void) const
307 CHECK_CONSTRUCTED_EX(0);
309 return __pImpl->GetDisplayLineCount();
313 EnrichedText::GetLineLength(int lineIndex) const
315 CHECK_CONSTRUCTED_EX(0);
317 return __pImpl->GetLineLength(lineIndex);
321 EnrichedText::GetFirstTextIndex(int lineIndex) const
323 CHECK_CONSTRUCTED_EX(0);
325 return __pImpl->GetFirstTextIndex(lineIndex);
329 EnrichedText::GetLineIndex(int textIndex) const
331 CHECK_CONSTRUCTED_EX(0);
333 return __pImpl->GetLineIndex(textIndex);
337 EnrichedText::GetLineHeight(int lineIndex) const
339 CHECK_CONSTRUCTED_EX(0);
341 return __pImpl->GetLineHeight(lineIndex);
345 EnrichedText::GetTextLength(void) const
347 CHECK_CONSTRUCTED_EX(0);
349 return __pImpl->GetTextLength();
353 EnrichedText::GetTextExtent(int startTextIndex, int textLength, int& width, int& height, int& actualLength) const
357 return __pImpl->GetTextExtent(startTextIndex, textLength, width, height, actualLength);
361 EnrichedText::GetTextExtent(int startTextIndex, int textLength, Tizen::Graphics::Dimension& size, int& actualLength) const
365 return __pImpl->GetTextExtent(startTextIndex, textLength, size, actualLength);
368 Tizen::Graphics::Dimension
369 EnrichedText::GetTextExtent(void) const
371 CHECK_CONSTRUCTED_EX(Dimension(-1, -1));
373 return __pImpl->GetTextExtent();
377 EnrichedText::Add(const Tizen::Graphics::Bitmap& bitmap)
381 return __pImpl->Add(bitmap);
385 EnrichedText::InsertAt(int elementIndex, const Tizen::Graphics::Bitmap& bitmap)
389 return __pImpl->InsertAt(elementIndex, bitmap);
393 EnrichedText::GetLinkInfoFromPosition(const Point& point, Tizen::Base::Utility::LinkInfo& linkInfo) const
397 return __pImpl->GetLinkInfoFromPosition(point, linkInfo);
401 EnrichedText::GetLinkInfoFromPosition(int x, int y, Tizen::Base::Utility::LinkInfo& linkInfo) const
405 return __pImpl->GetLinkInfoFromPosition(x, y, linkInfo);
408 TextVerticalAlignment
409 EnrichedText::GetElementVerticalAlignment(void) const
411 CHECK_CONSTRUCTED_EX(TEXT_ALIGNMENT_VERTICAL_MIN);
413 return __pImpl->GetElementVerticalAlignment();
417 EnrichedText::SetElementVerticalAlignment(TextVerticalAlignment alignment)
421 return __pImpl->SetElementVerticalAlignment(alignment);
424 }} // Tizen::Graphics