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 FGrpTextElement.cpp
20 * @brief This is the cpp file for TextElement class.
25 #include <FGrpTextElement.h>
26 #include <FBaseString.h>
29 #include <FBaseSysLog.h>
31 #include "FGrp_TextElementImpl.h"
32 #include "FGrp_ResUtil.h"
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Collection;
36 using namespace Tizen::Base::Utility;
38 #define CHECK_NOT_CONSTRUCTED \
39 SysTryReturnResult(NID_GRP, this->__pImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Fails to allocate memory.") \
40 SysAssertf(!this->__pImpl->IsConstructed(), \
41 "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
43 #define CHECK_CONSTRUCTED \
44 SysAssertf((this->__pImpl != null) && this->__pImpl->IsConstructed(), \
45 "Not yet constructed! Construct() should be called before use.");
47 #define CHECK_CONSTRUCTED_EX(_result) \
48 SysAssertf((this->__pImpl != null) && this->__pImpl->IsConstructed(), \
49 "Not yet constructed! Construct() should be called before use.");
51 namespace Tizen { namespace Graphics
54 TextElement::TextElement()
56 __pImpl = new (std::nothrow) _TextElementImpl;
59 TextElement::~TextElement()
69 TextElement::Construct(const Tizen::Base::String& text)
71 CHECK_NOT_CONSTRUCTED;
73 result r = __pImpl->Construct(text);
74 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r));
80 TextElement::Construct(const Tizen::Base::String& text, const Tizen::Graphics::Canvas& canvas)
82 CHECK_NOT_CONSTRUCTED;
84 result r = __pImpl->Construct(text, canvas);
85 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r));
91 TextElement::Construct(void)
93 CHECK_NOT_CONSTRUCTED;
95 result r = __pImpl->Construct();
96 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r));
102 TextElement::Construct(const Tizen::Base::String& text, Tizen::Base::Utility::LinkType linkType, const Tizen::Base::String& link)
104 CHECK_NOT_CONSTRUCTED;
106 result r = __pImpl->Construct(text, linkType, link);
107 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r));
113 TextElement::Construct(const Tizen::Base::String& text, unsigned long autoLink)
115 CHECK_NOT_CONSTRUCTED;
117 result r = __pImpl->Construct(text, autoLink);
118 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r));
124 TextElement::Construct(const Tizen::Base::String& text, Tizen::Base::Utility::LinkType linkType, const Tizen::Base::String& link,
125 const Tizen::Graphics::Canvas& canvas)
127 CHECK_NOT_CONSTRUCTED;
129 result r = __pImpl->Construct(text, linkType, link, canvas);
130 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r));
136 TextElement::Construct(const Tizen::Base::String& text, unsigned long autoLink, const Tizen::Graphics::Canvas& canvas)
138 CHECK_NOT_CONSTRUCTED;
140 result r = __pImpl->Construct(text, autoLink, canvas);
141 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r));
147 TextElement::GetLink(void) const
149 CHECK_CONSTRUCTED_EX(String());
151 return __pImpl->GetLink();
154 Tizen::Base::Utility::LinkType
155 TextElement::GetLinkType(void) const
157 CHECK_CONSTRUCTED_EX(LINK_TYPE_NONE);
159 return __pImpl->GetLinkType();
163 TextElement::SetText(const Tizen::Base::String& text)
167 return __pImpl->SetText(text);
171 TextElement::SetFont(const Tizen::Graphics::Font& font)
175 result r = __pImpl->SetFont(font);
176 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r));
182 TextElement::SetTextColor(const Tizen::Graphics::Color& color)
186 return __pImpl->SetTextColor(color);
190 TextElement::SetBackgroundColor(const Tizen::Graphics::Color& color)
194 return __pImpl->SetBackgroundColor(color);
198 TextElement::SetOutlineColor(const Tizen::Graphics::Color& color)
202 return __pImpl->SetOutlineColor(color);
206 TextElement::GetText() const
208 CHECK_CONSTRUCTED_EX(String());
210 return __pImpl->GetText();
213 Tizen::Graphics::Color
214 TextElement::GetTextColor() const
216 CHECK_CONSTRUCTED_EX(Color::GetColor(COLOR_ID_BLACK));
218 return __pImpl->GetTextColor();
221 Tizen::Graphics::Color
222 TextElement::GetBackgroundColor() const
224 CHECK_CONSTRUCTED_EX(Color::GetColor(COLOR_ID_BLACK));
226 return __pImpl->GetBackgroundColor();
229 Tizen::Graphics::Color
230 TextElement::GetOutlineColor() const
232 CHECK_CONSTRUCTED_EX(Color::GetColor(COLOR_ID_BLACK));
234 return __pImpl->GetOutlineColor();
237 }} // Tizen::Graphics