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 FUiCtrlForm.cpp
19 * @brief This is the implementation file for Form class.
23 #include <unique_ptr.h>
24 #include <FUiCtrlForm.h>
25 #include <FBaseSysLog.h>
26 #include "FUi_UiBuilder.h"
27 #include "FUiCtrl_FormImpl.h"
28 #include "FUiCtrl_HeaderImpl.h"
29 #include "FUiCtrl_FooterImpl.h"
30 #include "FUiCtrl_TabImpl.h"
33 using namespace Tizen::Ui;
34 using namespace Tizen::Graphics;
35 using namespace Tizen::Base;
37 namespace Tizen { namespace Ui { namespace Controls
49 Form::Construct(unsigned long formStyle)
53 SysAssertf(_FormImpl::GetInstance(*this) == null,
54 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
56 _FormImpl* pImpl = _FormImpl::CreateFormImplN(this);
57 SysTryReturn(NID_UI_CTRL, pImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
59 _pControlImpl = pImpl;
61 pImpl->SetFormStyle(formStyle);
63 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
69 Form::Construct(const Tizen::Base::String& resourceId)
73 // Parse UiBuilder XML file
74 unique_ptr<_UiBuilder> pBuilder(new _UiBuilder());
75 SysTryReturn(NID_UI_CTRL, pBuilder, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
76 result r = pBuilder->Construct(resourceId, this);
77 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
78 r = pBuilder->Parse();
79 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
85 Form::Construct(const Layout& layout, unsigned long formStyle)
89 SysAssertf(_FormImpl::GetInstance(*this) == null,
90 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
92 r = Construct(layout, layout, formStyle);
93 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
99 Form::Construct(const Layout& portraitLayout, const Layout& landscapeLayout, unsigned long formStyle)
101 result r = E_SUCCESS;
103 SysAssertf(_FormImpl::GetInstance(*this) == null,
104 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
106 Layout* pPortraitLayout = const_cast <Layout*>(&portraitLayout);
107 Layout* pLandscapeLayout = const_cast <Layout*>(&landscapeLayout);
109 _FormImpl* pImpl = _FormImpl::CreateFormImplN(this, pPortraitLayout, pLandscapeLayout);
110 SysTryReturn(NID_UI_CTRL, pImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
112 _pControlImpl = pImpl;
114 pImpl->SetFormStyle(formStyle);
116 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
122 Form::AddOrientationEventListener(IOrientationEventListener& listener)
124 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
125 SysAssertf(pImpl != null,
126 "Not yet constructed. Construct() should be called before use.");
128 pImpl->AddOrientationEventListener(listener);
132 Form::AddOptionkeyActionListener(IActionEventListener& listener)
134 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
135 SysAssertf(pImpl != null,
136 "Not yet constructed. Construct() should be called before use.");
138 pImpl->AddOptionkeyActionListener(listener);
142 Form::AddSoftkeyActionListener(Softkey softkey, IActionEventListener& listener)
144 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
145 SysAssertf(pImpl != null,
146 "Not yet constructed. Construct() should be called before use.");
148 pImpl->AddSoftkeyActionListener(softkey, listener);
152 Form::RemoveOptionkeyActionListener(IActionEventListener& listener)
154 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
155 SysAssertf(pImpl != null,
156 "Not yet constructed. Construct() should be called before use.");
158 pImpl->RemoveOptionkeyActionListener(listener);
162 Form::RemoveOrientationEventListener(IOrientationEventListener& listener)
164 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
165 SysAssertf(pImpl != null,
166 "Not yet constructed. Construct() should be called before use.");
168 pImpl->RemoveOrientationEventListener(listener);
172 Form::RemoveSoftkeyActionListener(Softkey softkey, IActionEventListener& listener)
174 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
175 SysAssertf(pImpl != null,
176 "Not yet constructed. Construct() should be called before use.");
178 pImpl->RemoveSoftkeyActionListener(softkey, listener);
182 Form::GetBackgroundColor(void) const
184 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
185 SysAssertf(pImpl != null,
186 "Not yet constructed. Construct() should be called before use.");
188 return pImpl->GetBackgroundColor();
192 Form::GetClientAreaBounds(void) const
194 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
195 SysAssertf(pImpl != null,
196 "Not yet constructed. Construct() should be called before use.");
198 return pImpl->GetClientBounds();
202 Form::GetFormStyle(void) const
204 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
205 SysAssertf(pImpl != null,
206 "Not yet constructed. Construct() should be called before use.");
208 return pImpl->GetFormStyle();
212 Form::GetOrientation(void) const
214 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
215 SysAssertf(pImpl != null,
216 "Not yet constructed. Construct() should be called before use.");
218 return pImpl->GetOrientation();
222 Form::GetOrientationStatus(void) const
224 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
225 SysAssertf(pImpl != null,
226 "Not yet constructed. Construct() should be called before use.");
228 return pImpl->GetOrientationStatus();
232 Form::GetSoftkeyActionId(Softkey softkey) const
234 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
235 SysAssertf(pImpl != null,
236 "Not yet constructed. Construct() should be called before use.");
238 return pImpl->GetSoftkeyActionId(softkey);
242 Form::GetSoftkeyText(Softkey softkey) const
244 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
245 SysAssertf(pImpl != null,
246 "Not yet constructed. Construct() should be called before use.");
248 return pImpl->GetSoftkeyText(softkey);
252 Form::GetTab(void) const
254 _FormImpl* pImpl = const_cast <_FormImpl*>(_FormImpl::GetInstance(*this));
255 SysAssertf(pImpl != null,
256 "Not yet constructed. Construct() should be called before use.");
258 _TabImpl* pTabImpl = pImpl->GetTabImpl();
264 return pTabImpl->GetTab();
269 Form::GetTitleText(void) const
271 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
272 SysAssertf(pImpl != null,
273 "Not yet constructed. Construct() should be called before use.");
275 return pImpl->GetTitleText();
279 Form::GetTitleTextHorizontalAlignment(void) const
281 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
282 SysAssertf(pImpl != null,
283 "Not yet constructed. Construct() should be called before use.");
285 return pImpl->GetTitleTextHorizontalAlignment();
289 Form::HasIndicator(void) const
291 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
292 SysAssertf(pImpl != null,
293 "Not yet constructed. Construct() should be called before use.");
295 return pImpl->HasIndicator();
299 Form::HasOptionkey(void) const
301 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
302 SysAssertf(pImpl != null,
303 "Not yet constructed. Construct() should be called before use.");
305 return pImpl->HasOptionkey();
309 Form::HasSoftkey(Softkey softkey) const
311 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
312 SysAssertf(pImpl != null,
313 "Not yet constructed. Construct() should be called before use.");
315 return pImpl->HasSoftkey(softkey);
319 Form::HasTab(void) const
321 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
322 SysAssertf(pImpl != null,
323 "Not yet constructed. Construct() should be called before use.");
325 return pImpl->HasTab();
329 Form::HasTitle(void) const
331 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
332 SysAssertf(pImpl != null,
333 "Not yet constructed. Construct() should be called before use.");
335 return pImpl->HasTitle();
339 Form::IsSoftkeyEnabled(Softkey softkey) const
341 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
342 SysAssertf(pImpl != null,
343 "Not yet constructed. Construct() should be called before use.");
345 return pImpl->IsSoftkeyEnabled(softkey);
349 Form::SetBackgroundColor(const Color& color)
351 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
352 SysAssertf(pImpl != null,
353 "Not yet constructed. Construct() should be called before use.");
355 pImpl->SetBackgroundColor(color);
359 Form::SetFormStyle(unsigned long formStyle)
361 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
362 SysAssertf(pImpl != null,
363 "Not yet constructed. Construct() should be called before use.");
365 pImpl->SetFormStyle(formStyle);
369 Form::SetOptionkeyActionId(int actionId)
371 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
372 SysAssertf(pImpl != null,
373 "Not yet constructed. Construct() should be called before use.");
375 pImpl->SetOptionkeyActionId(actionId);
379 Form::SetOrientation(Orientation orientation)
381 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
382 SysAssertf(pImpl != null,
383 "Not yet constructed. Construct() should be called before use.");
385 pImpl->SetOrientation(orientation);
389 Form::SetSoftkeyActionId(Softkey softkey, int actionId)
391 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
392 SysAssertf(pImpl != null,
393 "Not yet constructed. Construct() should be called before use.");
395 pImpl->SetSoftkeyActionId(softkey, actionId);
399 Form::SetSoftkeyEnabled(Softkey softkey, bool enable)
401 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
402 SysAssertf(pImpl != null,
403 "Not yet constructed. Construct() should be called before use.");
405 pImpl->SetSoftkeyEnabled(softkey, enable);
409 Form::SetTitleIcon(const Bitmap* pTitleBitmap)
411 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
412 SysAssertf(pImpl != null,
413 "Not yet constructed. Construct() should be called before use.");
415 return pImpl->SetTitleIcon(pTitleBitmap);
419 Form::SetTitleText(const String& title, HorizontalAlignment alignment)
421 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
422 SysAssertf(pImpl != null,
423 "Not yet constructed. Construct() should be called before use.");
425 return pImpl->SetTitleText(title, alignment);
429 Form::SetSoftkeyIcon(Softkey softkey, const Bitmap& normalBitmap, const Bitmap* pPressedBitmap)
431 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
432 SysAssertf(pImpl != null,
433 "Not yet constructed. Construct() should be called before use.");
435 pImpl->SetSoftkeyIcon(softkey, normalBitmap, pPressedBitmap);
439 Form::SetSoftkeyText(Softkey softkey, const String& text)
441 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
442 SysAssertf(pImpl != null,
443 "Not yet constructed. Construct() should be called before use.");
445 pImpl->SetSoftkeyText(softkey, text);
449 Form::GetFooter(void) const
451 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
452 SysAssertf(pImpl != null,
453 "Not yet constructed. Construct() should be called before use.");
455 _FooterImpl* pFooterImpl = pImpl->GetFooter();
461 return pFooterImpl->GetFooter();
465 Form::GetHeader(void) const
467 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
468 SysAssertf(pImpl != null,
469 "Not yet constructed. Construct() should be called before use.");
471 _HeaderImpl* pHeaderImpl = pImpl->GetHeader();
477 return pHeaderImpl->GetHeader();
481 Form::HasFooter(void) const
483 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
484 SysAssertf(pImpl != null,
485 "Not yet constructed. Construct() should be called before use.");
487 return pImpl->HasFooter();
491 Form::HasHeader(void) const
493 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
494 SysAssertf(pImpl != null,
495 "Not yet constructed. Construct() should be called before use.");
497 return pImpl->HasHeader();
501 Form::IsIndicatorVisible(void) const
503 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
504 SysAssertf(pImpl != null,
505 "Not yet constructed. Construct() should be called before use.");
507 return pImpl->IsIndicatorVisible();
511 Form::IsHeaderVisible(void) const
513 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
514 SysAssertf(pImpl != null,
515 "Not yet constructed. Construct() should be called before use.");
517 return pImpl->IsHeaderVisible();
521 Form::IsFooterVisible(void) const
523 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
524 SysAssertf(pImpl != null,
525 "Not yet constructed. Construct() should be called before use.");
527 return pImpl->IsFooterVisible();
531 Form::IsIndicatorTranslucent(void) const
533 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
534 SysAssertf(pImpl != null,
535 "Not yet constructed. Construct() should be called before use.");
537 return pImpl->IsIndicatorTranslucent();
541 Form::IsHeaderTranslucent(void) const
543 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
544 SysAssertf(pImpl != null,
545 "Not yet constructed. Construct() should be called before use.");
547 return pImpl->IsHeaderTranslucent();
551 Form::IsFooterTranslucent(void) const
553 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
554 SysAssertf(pImpl != null,
555 "Not yet constructed. Construct() should be called before use.");
557 return pImpl->IsFooterTranslucent();
561 Form::SetActionBarsTranslucent(unsigned long actionBars, bool translucent)
563 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
564 SysAssertf(pImpl != null,
565 "Not yet constructed. Construct() should be called before use.");
567 return pImpl->SetActionBarsTranslucent(actionBars, translucent);
571 Form::SetActionBarsVisible(unsigned long actionBars, bool visible)
573 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
574 SysAssertf(pImpl != null,
575 "Not yet constructed. Construct() should be called before use.");
577 return pImpl->SetActionBarsVisible(actionBars, visible);
581 Form::GetOverlayRegionN(const Rectangle& rect, OverlayRegionType regionType)
583 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
584 SysAssertf(pImpl != null,
585 "Not yet constructed. Construct() should be called before use.");
587 return pImpl->GetOverlayRegionN(rect, regionType);
591 Form::GetClientAreaCanvasN(void) const
593 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
594 SysAssertf(pImpl != null,
595 "Not yet constructed. Construct() should be called before use.");
597 return pImpl->GetClientAreaCanvasN();
601 Form::TranslateToClientAreaPosition(const Point& position) const
603 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
604 SysAssertf(pImpl != null,
605 "Not yet constructed. Construct() should be called before use.");
607 return pImpl->TranslateToClientAreaPosition(position);
611 Form::TranslateFromClientAreaPosition(const Point& clientPosition) const
613 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
614 SysAssertf(pImpl != null,
615 "Not yet constructed. Construct() should be called before use.");
617 return pImpl->TranslateFromClientAreaPosition(clientPosition);
621 Form::SetFormBackEventListener(IFormBackEventListener* pFormBackEventListener)
623 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
624 SysAssertf(pImpl != null,
625 "Not yet constructed. Construct() should be called before use.");
627 return pImpl->SetFormBackEventListener(pFormBackEventListener);
631 Form::GetDataBindingContextN(void) const
633 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
634 SysAssertf(pImpl != null,
635 "Not yet constructed. Construct() should be called before use.");
637 return pImpl->GetDataBindingContextN();
640 }}} // Tizen::Ui::Controls