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 FUiCtrlTextBox.cpp
20 * @brief This is the implementation file for TextBox class.
23 #include <FUiCtrlTextBox.h>
24 #include <FBaseSysLog.h>
25 #include "FUiCtrl_TextBoxImpl.h"
27 using namespace Tizen::Base;
28 using namespace Tizen::Graphics;
29 using namespace Tizen::Ui;
31 namespace Tizen { namespace Ui { namespace Controls
34 TextBox::TextBox(void)
38 TextBox::~TextBox(void)
43 TextBox::Construct(const Rectangle& rect, TextBoxBorder border)
45 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
46 SysAssertf(pTextBoxImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
48 pTextBoxImpl = _TextBoxImpl::CreateTextBoxImplN(this);
49 result r = GetLastResult();
50 SysTryReturn(NID_UI_CTRL, pTextBoxImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
52 _pControlImpl = pTextBoxImpl;
54 r = SetBounds(rect.x, rect.y, rect.width, rect.height);
55 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
57 r = pTextBoxImpl->Initialize(border);
58 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
65 TextBox::SetAutoLinkMask(unsigned long autoLinks)
67 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
68 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
70 return pTextBoxImpl->SetAutoLinkMask(autoLinks);
74 TextBox::GetAutoLinkMask(void) const
76 const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
77 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
79 return pTextBoxImpl->GetAutoLinkMask();
83 TextBox::AddUiLinkEventListener(IUiLinkEventListener& listener)
85 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
86 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
88 result r = pTextBoxImpl->AddUiLinkEventListener(listener);
89 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
93 TextBox::RemoveUiLinkEventListener(IUiLinkEventListener& listener)
95 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
96 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
98 result r = pTextBoxImpl->RemoveUiLinkEventListener(listener);
99 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
103 TextBox::AppendCharacter(const Character& character)
105 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
106 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
108 return pTextBoxImpl->AppendCharacter(character);
112 TextBox::AppendText(const String& text)
114 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
115 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
117 return pTextBoxImpl->AppendText(text);
123 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
124 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
126 return pTextBoxImpl->Clear();
130 TextBox::GetLineCount(void) const
132 const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
133 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
135 return pTextBoxImpl->GetLineCount();
139 TextBox::GetText(void) const
141 const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
142 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
144 return pTextBoxImpl->GetText();
148 TextBox::GetText(int start, int end) const
150 const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
151 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
153 return pTextBoxImpl->GetText(start, end);
157 TextBox::GetTextLength(void) const
159 const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
160 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
162 return pTextBoxImpl->GetTextLength();
166 TextBox::InsertCharacterAt(int index, const Character& character)
168 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
169 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
171 return pTextBoxImpl->InsertCharacterAt(index, character);
175 TextBox::InsertTextAt(int index, const String& text)
177 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
178 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
180 return pTextBoxImpl->InsertTextAt(index, text);
184 TextBox::SetText(const String& text)
186 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
187 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
189 return pTextBoxImpl->SetText(text);
193 TextBox::GetLineSpacing(void) const
195 const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
196 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
198 return pTextBoxImpl->GetLineSpacing();
202 TextBox::SetLineSpacing(int multiplier, int extra)
204 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
205 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
207 return pTextBoxImpl->SetLineSpacing(multiplier, extra);
211 TextBox::GetTextAlignment(void) const
213 const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
214 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
216 return pTextBoxImpl->GetTextAlignment();
220 TextBox::SetTextAlignment(HorizontalAlignment alignment)
222 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
223 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
225 return pTextBoxImpl->SetTextAlignment(alignment);
229 TextBox::GetTextSize(void) const
231 const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
232 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
234 return pTextBoxImpl->GetTextSize();
238 TextBox::SetTextSize(int size)
240 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
241 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
243 return pTextBoxImpl->SetTextSize(size);
247 TextBox::GetFontType(String& typefaceName, unsigned long& styleMask) const
249 const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
250 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
252 return pTextBoxImpl->GetFontType(typefaceName, styleMask);
256 TextBox::SetFontType(const String& typefaceName, unsigned long styleMask)
258 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
259 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
261 return pTextBoxImpl->SetFontType(typefaceName, styleMask);
265 TextBox::GetTextStyle(void) const
267 const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
268 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
270 return pTextBoxImpl->GetTextStyle();
274 TextBox::SetTextStyle(unsigned long style)
276 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
277 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
279 return pTextBoxImpl->SetTextStyle(style);
283 TextBox::SetFont(const Font& font)
285 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
286 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
288 return pTextBoxImpl->SetFont(font);
292 TextBox::ReleaseBlock(void)
294 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
295 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
298 return pTextBoxImpl->ReleaseBlock();
302 TextBox::GetBlockRange(int& start, int& end) const
304 const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
305 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
307 return pTextBoxImpl->GetBlockRange(start, end);
311 TextBox::SetBlockRange(int start, int end)
313 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
314 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
316 return pTextBoxImpl->SetBlockRange(start, end);
320 TextBox::AddTextBlockEventListener(ITextBlockEventListener& listener)
322 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
323 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
325 result r = pTextBoxImpl->AddTextBlockEventListener(listener);
326 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
330 TextBox::RemoveTextBlockEventListener(ITextBlockEventListener& listener)
332 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
333 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
335 result r = pTextBoxImpl->RemoveTextBlockEventListener(listener);
336 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
340 TextBox::GetColor(TextBoxStatus status) const
342 const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
343 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
345 return pTextBoxImpl->GetColor(status);
349 TextBox::GetTextColor(TextBoxTextColor type) const
351 const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
352 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
354 return pTextBoxImpl->GetTextColor(type);
358 TextBox::SetColor(TextBoxStatus status, const Color& color)
360 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
361 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
363 return pTextBoxImpl->SetColor(status, color);
367 TextBox::SetTextColor(TextBoxTextColor type, const Color& color)
369 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
370 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
372 return pTextBoxImpl->SetTextColor(type, color);
376 TextBox::SetBackgroundBitmap(TextBoxStatus status, const Bitmap& bitmap)
378 _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this);
379 SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use.");
381 return pTextBoxImpl->SetBackgroundBitmap(status, bitmap);
384 }}} // Tizen::Ui::Controls