2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0/
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::GetClientAreaBoundsF(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->GetClientBoundsF();
212 Form::GetFormStyle(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->GetFormStyle();
222 Form::GetOrientation(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->GetOrientation();
232 Form::GetOrientationStatus(void) 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->GetOrientationStatus();
242 Form::GetSoftkeyActionId(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->GetSoftkeyActionId(softkey);
252 Form::GetSoftkeyText(Softkey softkey) const
254 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
255 SysAssertf(pImpl != null,
256 "Not yet constructed. Construct() should be called before use.");
258 return pImpl->GetSoftkeyText(softkey);
262 Form::GetTab(void) const
264 _FormImpl* pImpl = const_cast <_FormImpl*>(_FormImpl::GetInstance(*this));
265 SysAssertf(pImpl != null,
266 "Not yet constructed. Construct() should be called before use.");
268 _TabImpl* pTabImpl = pImpl->GetTabImpl();
274 return pTabImpl->GetTab();
279 Form::GetTitleText(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->GetTitleText();
289 Form::GetTitleTextHorizontalAlignment(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->GetTitleTextHorizontalAlignment();
299 Form::HasIndicator(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->HasIndicator();
309 Form::HasOptionkey(void) 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->HasOptionkey();
319 Form::HasSoftkey(Softkey softkey) 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->HasSoftkey(softkey);
329 Form::HasTab(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->HasTab();
339 Form::HasTitle(void) 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->HasTitle();
349 Form::IsSoftkeyEnabled(Softkey softkey) const
351 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
352 SysAssertf(pImpl != null,
353 "Not yet constructed. Construct() should be called before use.");
355 return pImpl->IsSoftkeyEnabled(softkey);
359 Form::SetBackgroundColor(const Color& color)
361 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
362 SysAssertf(pImpl != null,
363 "Not yet constructed. Construct() should be called before use.");
365 pImpl->SetBackgroundColor(color);
369 Form::SetFormStyle(unsigned long formStyle)
371 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
372 SysAssertf(pImpl != null,
373 "Not yet constructed. Construct() should be called before use.");
375 pImpl->SetFormStyle(formStyle);
379 Form::SetOptionkeyActionId(int actionId)
381 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
382 SysAssertf(pImpl != null,
383 "Not yet constructed. Construct() should be called before use.");
385 pImpl->SetOptionkeyActionId(actionId);
389 Form::SetOrientation(Orientation orientation)
391 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
392 SysAssertf(pImpl != null,
393 "Not yet constructed. Construct() should be called before use.");
395 pImpl->SetOrientation(orientation);
399 Form::SetSoftkeyActionId(Softkey softkey, int actionId)
401 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
402 SysAssertf(pImpl != null,
403 "Not yet constructed. Construct() should be called before use.");
405 pImpl->SetSoftkeyActionId(softkey, actionId);
409 Form::SetSoftkeyEnabled(Softkey softkey, bool enable)
411 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
412 SysAssertf(pImpl != null,
413 "Not yet constructed. Construct() should be called before use.");
415 pImpl->SetSoftkeyEnabled(softkey, enable);
419 Form::SetTitleIcon(const Bitmap* pTitleBitmap)
421 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
422 SysAssertf(pImpl != null,
423 "Not yet constructed. Construct() should be called before use.");
425 return pImpl->SetTitleIcon(pTitleBitmap);
429 Form::SetTitleText(const String& title, HorizontalAlignment alignment)
431 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
432 SysAssertf(pImpl != null,
433 "Not yet constructed. Construct() should be called before use.");
435 return pImpl->SetTitleText(title, alignment);
439 Form::SetSoftkeyIcon(Softkey softkey, const Bitmap& normalBitmap, const Bitmap* pPressedBitmap)
441 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
442 SysAssertf(pImpl != null,
443 "Not yet constructed. Construct() should be called before use.");
445 pImpl->SetSoftkeyIcon(softkey, normalBitmap, pPressedBitmap);
449 Form::SetSoftkeyText(Softkey softkey, const String& text)
451 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
452 SysAssertf(pImpl != null,
453 "Not yet constructed. Construct() should be called before use.");
455 pImpl->SetSoftkeyText(softkey, text);
459 Form::GetFooter(void) const
461 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
462 SysAssertf(pImpl != null,
463 "Not yet constructed. Construct() should be called before use.");
465 _FooterImpl* pFooterImpl = pImpl->GetFooter();
471 return pFooterImpl->GetFooter();
475 Form::GetHeader(void) const
477 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
478 SysAssertf(pImpl != null,
479 "Not yet constructed. Construct() should be called before use.");
481 _HeaderImpl* pHeaderImpl = pImpl->GetHeader();
487 return pHeaderImpl->GetHeader();
491 Form::HasFooter(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->HasFooter();
501 Form::HasHeader(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->HasHeader();
511 Form::IsIndicatorVisible(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->IsIndicatorVisible();
521 Form::IsHeaderVisible(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->IsHeaderVisible();
531 Form::IsFooterVisible(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->IsFooterVisible();
541 Form::IsIndicatorTranslucent(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->IsIndicatorTranslucent();
551 Form::IsHeaderTranslucent(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->IsHeaderTranslucent();
561 Form::IsFooterTranslucent(void) const
563 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
564 SysAssertf(pImpl != null,
565 "Not yet constructed. Construct() should be called before use.");
567 return pImpl->IsFooterTranslucent();
571 Form::SetActionBarsTranslucent(unsigned long actionBars, bool translucent)
573 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
574 SysAssertf(pImpl != null,
575 "Not yet constructed. Construct() should be called before use.");
577 return pImpl->SetActionBarsTranslucent(actionBars, translucent);
581 Form::SetActionBarsVisible(unsigned long actionBars, bool visible)
583 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
584 SysAssertf(pImpl != null,
585 "Not yet constructed. Construct() should be called before use.");
587 return pImpl->SetActionBarsVisible(actionBars, visible);
591 Form::GetOverlayRegionN(const Rectangle& rect, OverlayRegionType regionType)
593 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
594 SysAssertf(pImpl != null,
595 "Not yet constructed. Construct() should be called before use.");
597 return pImpl->GetOverlayRegionN(rect, regionType);
601 Form::GetOverlayRegionN(const FloatRectangle& rect, OverlayRegionType regionType)
603 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
604 SysAssertf(pImpl != null,
605 "Not yet constructed. Construct() should be called before use.");
607 return pImpl->GetOverlayRegionN(rect, regionType);
611 Form::GetClientAreaCanvasN(void) 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->GetClientAreaCanvasN();
621 Form::TranslateToClientAreaPosition(const Point& position) const
623 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
624 SysAssertf(pImpl != null,
625 "Not yet constructed. Construct() should be called before use.");
627 return pImpl->TranslateToClientAreaPosition(position);
631 Form::TranslateToClientAreaPosition(const FloatPoint& position) 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->TranslateToClientAreaPosition(position);
642 Form::TranslateFromClientAreaPosition(const Point& clientPosition) const
644 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
645 SysAssertf(pImpl != null,
646 "Not yet constructed. Construct() should be called before use.");
648 return pImpl->TranslateFromClientAreaPosition(clientPosition);
652 Form::TranslateFromClientAreaPosition(const FloatPoint& clientPosition) const
654 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
655 SysAssertf(pImpl != null,
656 "Not yet constructed. Construct() should be called before use.");
658 return pImpl->TranslateFromClientAreaPosition(clientPosition);
662 Form::SetFormBackEventListener(IFormBackEventListener* pFormBackEventListener)
664 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
665 SysAssertf(pImpl != null,
666 "Not yet constructed. Construct() should be called before use.");
668 return pImpl->SetFormBackEventListener(pFormBackEventListener);
672 Form::SetFormMenuEventListener(IFormMenuEventListener* pFormMenuEventListener)
674 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
675 SysAssertf(pImpl != null,
676 "Not yet constructed. Construct() should be called before use.");
678 return pImpl->SetFormMenuEventListener(pFormMenuEventListener);
682 Form::GetDataBindingContextN(void) const
684 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
685 SysAssertf(pImpl != null,
686 "Not yet constructed. Construct() should be called before use.");
688 return pImpl->GetDataBindingContextN();
692 Form::SetNotificationTrayOpenEnabled(bool enable)
694 _FormImpl* pImpl = _FormImpl::GetInstance(*this);
695 SysAssertf(pImpl != null,
696 "Not yet constructed. Construct() should be called before use.");
698 return pImpl->SetNotificationTrayOpenEnabled(enable);
702 Form::IsNotificationTrayOpenEnabled(void) const
704 const _FormImpl* pImpl = _FormImpl::GetInstance(*this);
705 SysAssertf(pImpl != null,
706 "Not yet constructed. Construct() should be called before use.");
708 return pImpl->IsNotificationTrayOpenEnabled();
712 }}} // Tizen::Ui::Controls