add patch
[framework/osp/web.git] / src / controls / FWebCtrl_InputPickerPopup.cpp
index 502e6e4..0826358 100755 (executable)
@@ -32,6 +32,7 @@
 #include <FUiCtrlEditTime.h>
 #include <FUiCtrlLabel.h>
 #include <FUiIActionEventListener.h>
+#include <FUiKeyEventInfo.h>
 #include <FUiLayout.h>
 #include <FUiVerticalBoxLayout.h>
 #include <FWebCtrlAuthenticationChallenge.h>
@@ -62,6 +63,7 @@ _InputPickerPopup::_InputPickerPopup(void)
        , __pEditTime(null)
        , __pSelectionBtn(null)
        , __modal(0)
+       , __isModal(false)
        , __popupHeight(0)
        , __popupWidth(0)
        , __btnHeight(0)
@@ -72,11 +74,15 @@ _InputPickerPopup::_InputPickerPopup(void)
 
 _InputPickerPopup::~_InputPickerPopup(void)
 {
+       if (__isModal == true)
+       {
+               HidePopup();
+       }
 }
 
 
 result
-_InputPickerPopup::Construct(const String& strDate, Ewk_Input_Type inputType)
+_InputPickerPopup::Construct(const String& strDate, Ewk_Input_Type inputType, Tizen::Web::Controls::_WebImpl* pImpl)
 {
        result r = E_SUCCESS;
 
@@ -194,6 +200,8 @@ _InputPickerPopup::Construct(const String& strDate, Ewk_Input_Type inputType)
        r = AddButton(ID_BUTTON_INPUT_DATE_SELECTION);
        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()));
        SysTryReturnResult(NID_WEB_CTRL, pLayout.get(), E_OUT_OF_MEMORY, "Memory Allocation Failed.");
 
@@ -217,7 +225,7 @@ _InputPickerPopup::Construct(const String& strDate, Ewk_Input_Type inputType)
 
 
 result
-_InputPickerPopup::Construct(const Color& color)
+_InputPickerPopup::Construct(const Color& color, Tizen::Web::Controls::_WebImpl* pImpl)
 {
        result r = E_SUCCESS;
 
@@ -240,6 +248,7 @@ _InputPickerPopup::Construct(const Color& color)
 
        pColorPicker->SetColor(color);
 
+       __pPopup->SetPropagatedKeyEventListener(this);
        r = __pPopup->AddControl(*pColorPicker);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
@@ -314,7 +323,7 @@ _InputPickerPopup::AddButton(_InputPickerButtonId buttonId)
        _SystemResource* pSysResource = _SystemResource::GetInstance();
        SysAssertf(pSysResource != null, "Failed to get _SystemResource instance");
 
-       buttonStr = pSysResource->GetString("sys_string", "IDS_COM_SK_OK");
+       buttonStr = pSysResource->GetString("sys_string", "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.");
@@ -474,6 +483,8 @@ _InputPickerPopup::ShowPopup(void)
        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));
 
@@ -489,12 +500,48 @@ _InputPickerPopup::HidePopup(void)
        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)
+{
+       return false;
+}
+
+bool
+_InputPickerPopup::OnKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
+{
+       if ((keyEventInfo.GetKeyCode() == KEY_ESC || keyEventInfo.GetKeyCode() == KEY_BACK) && source.GetShowState() == true)
+       {
+               HidePopup();
+       }
+
+       return false;
+}
+
+bool
+_InputPickerPopup::OnPreviewKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
+{
+       return false;
+}
+
+bool
+_InputPickerPopup::OnPreviewKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
+{
+       return false;
+}
+
+bool
+_InputPickerPopup::TranslateKeyEventInfo(Control& source, KeyEventInfo& keyEventInfo)
+{
+       return false;
+}
 
 String
 _InputPickerPopup::GetDate(void) const