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.
18 * @file FUiCtrlLabel.cpp
19 * @brief This is the implementation file for Label class.
22 #include <FUiCtrlLabel.h>
23 #include <FBaseSysLog.h>
24 #include "FUiCtrl_LabelImpl.h"
26 #define MINIMUM_VALUE 0
27 #define MAXIMUM_VALUE 65535
29 using namespace Tizen::Base;
30 using namespace Tizen::Graphics;
32 namespace Tizen { namespace Ui { namespace Controls
46 Label::Construct(const Rectangle& rect, const String& text)
48 SysTryReturn(NID_UI_CTRL, (rect.width >= MINIMUM_VALUE && rect.width <= MAXIMUM_VALUE), E_INVALID_ARG, E_INVALID_ARG,
49 "[E_INVALID_ARG] The width error occurred");
51 SysTryReturn(NID_UI_CTRL, (rect.height >= MINIMUM_VALUE && rect.height <= MAXIMUM_VALUE), E_INVALID_ARG, E_INVALID_ARG,
52 "[E_INVALID_ARG] The height error occurred");
55 _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this);
57 SysAssertf(pLabelImpl == null,
58 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
60 pLabelImpl = _LabelImpl::CreateLabelImplN(this, rect);
62 SysTryReturn(NID_UI_CTRL, pLabelImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
64 r = pLabelImpl->SetText(text);
65 SysAssert(r == E_SUCCESS); // [ToDo] Exception. Which exception can occur?
67 _pControlImpl = pLabelImpl;
73 Label::SetText(const String& text)
75 _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this);
76 SysAssertf(pLabelImpl != null,
77 "Not yet constructed. Construct() should be called before use.");
79 pLabelImpl->SetText(text);
85 Label::GetText(void) const
87 const _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this);
88 SysAssertf(pLabelImpl != null,
89 "Not yet constructed. Construct() should be called before use.");
91 return pLabelImpl->GetText();
95 Label::SetBackgroundBitmap(const Bitmap& bitmap)
97 _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this);
98 SysAssertf(pLabelImpl != null,
99 "Not yet constructed. Construct() should be called before use.");
101 pLabelImpl->SetBackgroundBitmap(bitmap);
107 Label::SetTextHorizontalAlignment(HorizontalAlignment alignment)
109 _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this);
110 SysAssertf(pLabelImpl != null,
111 "Not yet constructed. Construct() should be called before use.");
113 pLabelImpl->SetTextHorizontalAlignment(alignment);
119 Label::SetTextVerticalAlignment(VerticalAlignment alignment)
121 _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this);
122 SysAssertf(pLabelImpl != null,
123 "Not yet constructed. Construct() should be called before use.");
125 pLabelImpl->SetTextVerticalAlignment(alignment);
131 Label::GetTextHorizontalAlignment(void) const
133 const _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this);
134 SysAssertf(pLabelImpl != null,
135 "Not yet constructed. Construct() should be called before use.");
137 return pLabelImpl->GetTextHorizontalAlignment();
141 Label::GetTextVerticalAlignment(void) const
143 const _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this);
144 SysAssertf(pLabelImpl != null,
145 "Not yet constructed. Construct() should be called before use.");
147 return pLabelImpl->GetTextVerticalAlignment();
151 Label::SetBackgroundColor(const Color& color)
153 _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this);
154 SysAssertf(pLabelImpl != null,
155 "Not yet constructed. Construct() should be called before use.");
157 pLabelImpl->SetBackgroundColor(color);
163 Label::GetBackgroundColor(void) const
165 const _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this);
166 SysAssertf(pLabelImpl != null,
167 "Not yet constructed. Construct() should be called before use.");
169 return pLabelImpl->GetBackgroundColor();
173 Label::SetTextColor(const Color& color)
175 _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this);
176 SysAssertf(pLabelImpl != null,
177 "Not yet constructed. Construct() should be called before use.");
179 pLabelImpl->SetTextColor(color);
185 Label::GetTextColor(void) const
187 const _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this);
188 SysAssertf(pLabelImpl != null,
189 "Not yet constructed. Construct() should be called before use.");
191 return pLabelImpl->GetTextColor();
195 Label::SetTextConfig(int size, LabelTextStyle style)
197 _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this);
198 SysAssertf(pLabelImpl != null,
199 "Not yet constructed. Construct() should be called before use.");
201 pLabelImpl->SetTextConfig(size, style);
207 Label::GetTextSize(void) const
209 const _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this);
210 SysAssertf(pLabelImpl != null,
211 "Not yet constructed. Construct() should be called before use.");
213 return pLabelImpl->GetTextSize();
217 Label::GetTextStyle(void) const
219 const _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this);
220 SysAssertf(pLabelImpl != null,
221 "Not yet constructed. Construct() should be called before use.");
223 return pLabelImpl->GetTextStyle();
227 Label::SetMargin(int topMargin, int leftMargin)
229 _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this);
230 SysAssertf(pLabelImpl != null,
231 "Not yet constructed. Construct() should be called before use.");
233 result r = pLabelImpl->SetMargin(topMargin, leftMargin);
234 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
240 Label::GetTopMargin(void) const
242 const _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this);
243 SysAssertf(pLabelImpl != null,
244 "Not yet constructed. Construct() should be called before use.");
246 return pLabelImpl->GetTopMargin();
250 Label::GetLeftMargin(void) const
252 const _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this);
253 SysAssertf(pLabelImpl != null,
254 "Not yet constructed. Construct() should be called before use.");
256 return pLabelImpl->GetLeftMargin();
259 }}} // Tizen::Ui::Controls