From 011ba6943294c30bb4989f0a375dbade92f33987 Mon Sep 17 00:00:00 2001 From: "rajeev.ran" Date: Wed, 16 Oct 2013 13:54:30 +0530 Subject: [PATCH] Derived InputPickerPopup from Webpopup and ColorPicker popup issue fixed Change-Id: Ia551ba6fc2e1ada3d164e4fe67efb09e5080d096 Signed-off-by: rajeev.ran --- src/controls/FWebCtrl_InputPickerPopup.cpp | 223 ++++++++++++++--------------- src/controls/FWebCtrl_InputPickerPopup.h | 16 +-- src/controls/FWebCtrl_WebImpl.cpp | 6 +- src/controls/FWebCtrl_WebNotification.cpp | 43 +++--- src/controls/FWebCtrl_WebPopup.cpp | 21 ++- 5 files changed, 147 insertions(+), 162 deletions(-) diff --git a/src/controls/FWebCtrl_InputPickerPopup.cpp b/src/controls/FWebCtrl_InputPickerPopup.cpp index 1f44ee0..b528c42 100755 --- a/src/controls/FWebCtrl_InputPickerPopup.cpp +++ b/src/controls/FWebCtrl_InputPickerPopup.cpp @@ -31,18 +31,21 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include "FWebCtrl_WebImpl.h" #include "FWebCtrl_InputPickerPopup.h" using namespace Tizen::Base; +using namespace Tizen::Base::Collection; using namespace Tizen::Graphics; using namespace Tizen::Locales; using namespace Tizen::System; @@ -58,15 +61,14 @@ static const int DATE_POPUP_BUTTON_WIDTH = 250; _InputPickerPopup::_InputPickerPopup(void) - : __pPopup(null) - , __pEditDate(null) + : __pEditDate(null) , __pEditTime(null) , __pSelectionBtn(null) - , __modal(0) - , __isModal(false) + , __pColorPicker(null) + , __pButtonPanel(null) , __popupHeight(0) , __popupWidth(0) - , __btnHeight(0) + , __panelHeight(0) , __inputType(EWK_INPUT_TYPE_TIME) { } @@ -74,7 +76,7 @@ _InputPickerPopup::_InputPickerPopup(void) _InputPickerPopup::~_InputPickerPopup(void) { - if (__isModal == true) + if (IsModalPopup()) { HidePopup(); } @@ -90,6 +92,7 @@ _InputPickerPopup::Construct(const String& strDate, Ewk_Input_Type inputType, Ti int dateHeight = 0; int dateWidth = 0; int sideMargin = 0; + int internalGap = 0; DateTime inputDateTime; __inputPickerMode = INPUT_MODE_DATE; @@ -104,14 +107,19 @@ _InputPickerPopup::Construct(const String& strDate, Ewk_Input_Type inputType, Ti _ControlOrientation orientation = _CONTROL_ORIENTATION_PORTRAIT; + _WebPopupData* pPopupData = _WebPopup::GetPopupData(); + SysTryReturn(NID_WEB_CTRL, pPopupData, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r)); + GET_SHAPE_CONFIG(EDITDATE::WIDTH, orientation, dateWidth); GET_SHAPE_CONFIG(EDITDATE::HEIGHT, orientation, dateHeight); GET_SHAPE_CONFIG(POPUP::SIDE_BORDER, orientation, sideMargin); GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, orientation, __popupWidth); GET_SHAPE_CONFIG(MESSAGEBOX::MIN_HEIGHT, orientation, __popupHeight); - GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_HEIGHT, orientation, __btnHeight); + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_INTERNAL_GAP, orientation, internalGap); + + __panelHeight = pPopupData->panelHeight; - __popupWidth -= 2*sideMargin; + __popupWidth += sideMargin; std::unique_ptr pEditDate(new (std::nothrow) EditDate()); SysTryReturnResult(NID_WEB_CTRL, pEditDate.get(), E_OUT_OF_MEMORY, "Memory Allocation Failed."); @@ -119,20 +127,22 @@ _InputPickerPopup::Construct(const String& strDate, Ewk_Input_Type inputType, Ti std::unique_ptr pEditTime(new (std::nothrow) EditTime()); SysTryReturnResult(NID_WEB_CTRL, pEditTime.get(), E_OUT_OF_MEMORY, "Memory Allocation Failed."); + int space = dateHeight/4; + switch (__inputType) { case EWK_INPUT_TYPE_TIME : - __popupHeight = __popupHeight + dateHeight + __btnHeight; + __popupHeight = dateHeight + space + __panelHeight; r = CreatePopup(); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - __pPopup->SetTitleText("Select time"); + SetTitleText("Select time"); r = pEditTime->Construct(Point(0, 0), L"Time (Default format) :"); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - r = __pPopup->AddControl(*pEditTime); + r = AddControl(*pEditTime); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); pEditTime->SetTime(inputDateTime); __pEditTime = pEditTime.release(); @@ -143,11 +153,11 @@ _InputPickerPopup::Construct(const String& strDate, Ewk_Input_Type inputType, Ti case EWK_INPUT_TYPE_DATETIMELOCAL : - __popupHeight = __popupHeight + 2*dateHeight + __btnHeight; + __popupHeight = 2*dateHeight + space + __panelHeight + internalGap; r = CreatePopup(); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - __pPopup->SetTitleText("Select datetime"); + SetTitleText("Select datetime"); r = pEditDate->Construct(Point(0, 0), L"Date (Default format) :"); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); @@ -155,13 +165,13 @@ _InputPickerPopup::Construct(const String& strDate, Ewk_Input_Type inputType, Ti r = pEditTime->Construct(Point(0, 0), L"Time (Default format) :"); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - r = __pPopup->AddControl(*pEditTime); + r = AddControl(*pEditTime); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); pEditTime->SetTime(inputDateTime); __pEditTime = pEditTime.release(); - r = __pPopup->AddControl(*pEditDate); + r = AddControl(*pEditDate); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); pEditDate->SetDate(inputDateTime); @@ -176,15 +186,15 @@ _InputPickerPopup::Construct(const String& strDate, Ewk_Input_Type inputType, Ti //fall through case EWK_INPUT_TYPE_MONTH : - __popupHeight = __popupHeight + dateHeight + __btnHeight; + __popupHeight = dateHeight + space + __panelHeight; r = CreatePopup(); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - __pPopup->SetTitleText("Select date"); + SetTitleText("Select date"); r = pEditDate->Construct(Point(0, 0), L"Date (Default format) :"); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - r = __pPopup->AddControl(*pEditDate); + r = AddControl(*pEditDate); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); pEditDate->SetDate(inputDateTime); @@ -197,28 +207,50 @@ _InputPickerPopup::Construct(const String& strDate, Ewk_Input_Type inputType, Ti return r; } - r = AddButton(ID_BUTTON_INPUT_DATE_SELECTION); + __pButtonPanel = CreateAndAddPanel(); + SysTryReturn(NID_WEB_CTRL, __pButtonPanel, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + ArrayList idList; + r = idList.Construct(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + ArrayList titleList; + r = titleList.Construct(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + idList.Add(*(new Integer(ID_BUTTON_INPUT_DATE_SELECTION))); + + _SystemResource* pSysResource = _SystemResource::GetInstance(); + SysAssertf(pSysResource != null, "Failed to get _SystemResource instance"); + + titleList.Add(*(new String(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_TPLATFORM_BUTTON_OK")))); + + r = CreateAndAddButtons(idList, titleList, __pButtonPanel); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - __pPopup->SetPropagatedKeyEventListener(this); - - std::unique_ptr pLayout(dynamic_cast< VerticalBoxLayout* >(__pPopup->GetLayoutN())); + SetPropagatedKeyEventListener(this); + + std::unique_ptr pLayout(dynamic_cast< VerticalBoxLayout* >(GetLayoutN())); SysTryReturnResult(NID_WEB_CTRL, pLayout.get(), E_OUT_OF_MEMORY, "Memory Allocation Failed."); if (__pEditDate) { + __pEditDate->SetSize(__popupWidth,__pEditDate->GetSize().height); pLayout->SetHorizontalAlignment(*__pEditDate, LAYOUT_HORIZONTAL_ALIGN_LEFT); pLayout->SetSpacing(*__pEditDate, sideMargin); } if (__pEditTime) { + __pEditTime->SetSize(__popupWidth,__pEditTime->GetSize().height); pLayout->SetHorizontalAlignment(*__pEditTime, LAYOUT_HORIZONTAL_ALIGN_LEFT); pLayout->SetSpacing(*__pEditTime, sideMargin); } - pLayout->SetHorizontalAlignment(*__pSelectionBtn, LAYOUT_HORIZONTAL_ALIGN_CENTER); - pLayout->SetSpacing(*__pSelectionBtn, sideMargin); + if (__pButtonPanel) + { + pLayout->SetSpacing(*__pButtonPanel, space); + } return E_SUCCESS; } @@ -233,12 +265,11 @@ _InputPickerPopup::Construct(const Color& color, Tizen::Web::Controls::_WebImpl* _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); - CalculateColorPickerPopupSize(orientation); - - r = CreatePopup(); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + _SystemResource* pSysResource = _SystemResource::GetInstance(); + SysAssertf(pSysResource != null, "Failed to get _SystemResource instance"); - __pPopup->SetTitleText("Select color"); + _WebPopupData* pPopupData = _WebPopup::GetPopupData(); + SysTryReturn(NID_WEB_CTRL, pPopupData, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r)); std::unique_ptr pColorPicker(new (std::nothrow) ColorPicker()); SysTryReturnResult(NID_WEB_CTRL, pColorPicker.get(), E_OUT_OF_MEMORY, "Memory Allocation Failed."); @@ -248,25 +279,46 @@ _InputPickerPopup::Construct(const Color& color, Tizen::Web::Controls::_WebImpl* pColorPicker->SetColor(color); - __pPopup->SetPropagatedKeyEventListener(this); - r = __pPopup->AddControl(*pColorPicker); + CalculateColorPickerPopupSize(orientation); + + r = CreatePopup(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetTitleText("Select color"); + + SetPropagatedKeyEventListener(this); + + r = AddControl(*pColorPicker); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); __pColorPicker = pColorPicker.release(); - r = AddButton(ID_BUTTON_INPUT_COLOR_SELECTION); + + __pButtonPanel = CreateAndAddPanel(); + SysTryReturn(NID_WEB_CTRL, __pButtonPanel, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + ArrayList idList; + r = idList.Construct(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + ArrayList titleList; + r = titleList.Construct(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + idList.Add(*(new Integer(ID_BUTTON_INPUT_COLOR_SELECTION))); + titleList.Add(*(new String(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_TPLATFORM_BUTTON_OK")))); + + r = CreateAndAddButtons(idList, titleList, __pButtonPanel); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - std::unique_ptr pLayout(dynamic_cast< VerticalBoxLayout* >(__pPopup->GetLayoutN())); + std::unique_ptr pLayout(dynamic_cast< VerticalBoxLayout* >(GetLayoutN())); SysTryReturnResult(NID_WEB_CTRL, pLayout.get(), E_OUT_OF_MEMORY, "Memory Allocation Failed."); pLayout->SetHorizontalAlignment(*__pColorPicker, LAYOUT_HORIZONTAL_ALIGN_LEFT); - pLayout->SetHorizontalAlignment(*__pSelectionBtn, LAYOUT_HORIZONTAL_ALIGN_CENTER); int sideMargin = 0; GET_SHAPE_CONFIG(POPUP::SIDE_BORDER, orientation, sideMargin); pLayout->SetSpacing(*__pColorPicker, sideMargin); - pLayout->SetSpacing(*__pSelectionBtn, sideMargin); return E_SUCCESS; @@ -278,17 +330,16 @@ _InputPickerPopup::CalculateColorPickerPopupSize(_ControlOrientation orientation { int sideMargin = 0; Dimension dim; + _WebPopupData* pPopupData = _WebPopup::GetPopupData(); GET_SHAPE_CONFIG(POPUP::SIDE_BORDER, orientation, sideMargin); - GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, orientation, __popupWidth); - GET_SHAPE_CONFIG(MESSAGEBOX::MIN_HEIGHT, orientation, __popupHeight); - GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_HEIGHT, orientation, __btnHeight); + __panelHeight = pPopupData->panelHeight; GET_DIMENSION_CONFIG(COLORPICKER::DEFAULT_SIZE, orientation, dim); dim.width += sideMargin; __popupWidth = dim.width; - __popupHeight = __popupHeight + dim.height + __btnHeight; + __popupHeight = dim.height + __panelHeight; } @@ -296,51 +347,14 @@ result _InputPickerPopup::CreatePopup(void) { result r = E_SUCCESS; + bool hasTitle = true; - VerticalBoxLayout layout; - r = layout.Construct(VERTICAL_DIRECTION_DOWNWARD); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - - std::unique_ptr pPopup(new (std::nothrow) Popup()); - SysTryReturnResult(NID_WEB_CTRL, pPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation Failed."); - - r = pPopup->Construct(layout, layout, true, Dimension(__popupWidth, __popupHeight)); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - - __pPopup = std::move(pPopup); - - return E_SUCCESS; -} - - -result -_InputPickerPopup::AddButton(_InputPickerButtonId buttonId) -{ - result r = E_SUCCESS; - - String buttonStr; - - _SystemResource* pSysResource = _SystemResource::GetInstance(); - SysAssertf(pSysResource != null, "Failed to get _SystemResource instance"); - - buttonStr = pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_TPLATFORM_BUTTON_OK"); - - std::unique_ptr