#include <FUiCtrlEditDate.h>
#include <FUiCtrlEditTime.h>
#include <FUiCtrlLabel.h>
+#include <FUiCtrlPanel.h>
#include <FUiIActionEventListener.h>
#include <FUiKeyEventInfo.h>
#include <FUiLayout.h>
#include <FUiVerticalBoxLayout.h>
#include <FWebCtrlAuthenticationChallenge.h>
#include <FSys_SystemResource.h>
+#include <FUi_ControlManager.h>
#include <FUi_ResourceManager.h>
#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;
_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)
{
}
_InputPickerPopup::~_InputPickerPopup(void)
{
- if (__isModal == true)
+ if (IsModalPopup())
{
HidePopup();
}
int dateHeight = 0;
int dateWidth = 0;
int sideMargin = 0;
+ int internalGap = 0;
DateTime inputDateTime;
__inputPickerMode = INPUT_MODE_DATE;
_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<EditDate> pEditDate(new (std::nothrow) EditDate());
SysTryReturnResult(NID_WEB_CTRL, pEditDate.get(), E_OUT_OF_MEMORY, "Memory Allocation Failed.");
std::unique_ptr<EditTime> 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();
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));
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);
//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);
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<VerticalBoxLayout> pLayout(dynamic_cast< VerticalBoxLayout* >(__pPopup->GetLayoutN()));
+ SetPropagatedKeyEventListener(this);
+
+ std::unique_ptr<VerticalBoxLayout> 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;
}
_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<ColorPicker> pColorPicker(new (std::nothrow) ColorPicker());
SysTryReturnResult(NID_WEB_CTRL, pColorPicker.get(), E_OUT_OF_MEMORY, "Memory Allocation Failed.");
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<VerticalBoxLayout> pLayout(dynamic_cast< VerticalBoxLayout* >(__pPopup->GetLayoutN()));
+ std::unique_ptr<VerticalBoxLayout> 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;
{
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;
}
_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<Popup> 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<Button> pSelectionBtn(new (std::nothrow) Button());
- SysTryReturnResult(NID_WEB_CTRL, pSelectionBtn.get(), E_OUT_OF_MEMORY, "Memory Allocation Failed.");
-
- r = pSelectionBtn->Construct(Rectangle(0, 0, DATE_POPUP_BUTTON_WIDTH, __btnHeight), buttonStr);
+ r = _WebPopup::Construct(hasTitle, Dimension(__popupWidth, __popupHeight));
SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
- pSelectionBtn->SetActionId(buttonId);
- __pPopup->AddControl(*pSelectionBtn);
- pSelectionBtn->AddActionEventListener(*this);
-
- __pSelectionBtn = pSelectionBtn.release();
-
return E_SUCCESS;
}
-
void
_InputPickerPopup::OnActionPerformed(const Control& source, int actionId)
{
int x = 0;
int y = 0;
+ _WebPopupData* __pWebPopupData = _WebPopup::GetPopupData();
Dimension screenRect = _ControlManager::GetInstance()->GetScreenSize();
CalculateColorPickerPopupSize(orientation);
+ __popupHeight += __pWebPopupData->titleHeight;
if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
{
y = (screenRect.width - __popupHeight) / 2;
}
- r = __pPopup->SetBounds(Rectangle(x, y, __popupWidth, __popupHeight));
+ r = SetBounds(Rectangle(x, y, __popupWidth, __popupHeight));
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ r = __pButtonPanel->SetSize(__popupWidth, __popupHeight);
SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+ int buttonMargin;
+ int idCount = 1;
+ GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_SIDE_MARGIN_01, _CONTROL_ORIENTATION_PORTRAIT, buttonMargin);
+
+ int buttonWidth = (__popupWidth - buttonMargin*(idCount+1)) / idCount;
+ int buttonTopMargin = (__pWebPopupData->panelHeight - __pWebPopupData->btnDim.height)/2;
+
+ if (__pButtonPanel->GetControl(0))
+ {
+ r = (__pButtonPanel->GetControl(0))->SetBounds(Rectangle(buttonMargin, buttonTopMargin, buttonWidth, __pWebPopupData->btnDim.height));
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+
return E_SUCCESS;
}
}
-result
-_InputPickerPopup::ShowPopup(void)
-{
- result r = E_SUCCESS;
-
- r = __pPopup->SetShowState(true);
- SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
-
- __isModal = true;
-
- r = __pPopup->DoModal(__modal);
- SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
-
- return E_SUCCESS;
-}
-
-
-result
-_InputPickerPopup::HidePopup(void)
-{
- result r = E_SUCCESS;
-
- r = __pPopup->SetShowState(false);
- SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
-
- __isModal = false;
-
- r = __pPopup->EndModal(__modal);
- SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
-
- return E_SUCCESS;
-}
-
bool
_InputPickerPopup::OnKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
{