Init Tizen 2.2.1
[framework/osp/web.git] / src / controls / FWebCtrl_SelectBox.cpp
index b1e8462..ac80e60 100755 (executable)
@@ -42,6 +42,7 @@
 #include <FSys_SystemResource.h>
 #include <FUi_ResourceManager.h>
 #include "FWebCtrl_SelectBox.h"
+#include "FWebCtrl_WebImpl.h"
 
 
 using namespace Tizen::Base;
@@ -151,6 +152,7 @@ _SelectBox::_SelectBox(void)
        , __pWebView(null)
        , __pToggledArray(null)
        , __url(L"")
+       , __pImpl(null)
 {
 }
 
@@ -168,7 +170,7 @@ _SelectBox::~_SelectBox(void)
 
 
 result
-_SelectBox::Construct(bool isMultiSelect, const String& title, int listCount, Evas_Object* pWebView, const String& url)
+_SelectBox::Construct(Tizen::Web::Controls::_WebImpl* pImpl, bool isMultiSelect, const String& title, int listCount, Evas_Object* pWebView, const String& url)
 {
        result r = E_SUCCESS;
        Rectangle rect;
@@ -179,6 +181,7 @@ _SelectBox::Construct(bool isMultiSelect, const String& title, int listCount, Ev
 
        __pWebView = pWebView;
        __url = const_cast< String& >(url);
+       __pImpl = pImpl;
 
        GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_HEIGHT, __orientation, listItemHeight);
 
@@ -187,7 +190,7 @@ _SelectBox::Construct(bool isMultiSelect, const String& title, int listCount, Ev
        _WebPopupData* pPopupData = _WebPopup::GetPopupData();
        SysTryReturn(NID_WEB_CTRL, pPopupData, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
 
-       listMaxHeihgt = listCount * listItemHeight + pPopupData->btnDim.height + pPopupData->spacePad;
+       listMaxHeihgt = listCount * listItemHeight;
 
        rect.height = listMaxHeihgt;
        rect.width = pPopupData->popupDim.width;
@@ -221,42 +224,32 @@ _SelectBox::Construct(bool isMultiSelect, const String& title, int listCount, Ev
 
        __pListView = pListView.release();
 
-       Panel* pButtonPanel = CreateAndAddPanel();
-       SysTryReturn(NID_WEB_CTRL, pButtonPanel, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
+       if (__multiSelection)
+       {
+               Panel* pButtonPanel = CreateAndAddPanel();
+               SysTryReturn(NID_WEB_CTRL, pButtonPanel, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
 
-       _SystemResource* pSysResource = _SystemResource::GetInstance();
-       SysAssertf(pSysResource != null, "Failed to get _SystemResource instance");
+               _SystemResource* pSysResource = _SystemResource::GetInstance();
+               SysAssertf(pSysResource != null, "Failed to get _SystemResource instance");
 
-       ArrayList idList;
-       r = idList.Construct();
-       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+               ArrayList idList;
+               r = idList.Construct();
+               SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       idList.Add(*(new Integer(ID_BUTTON_CANCEL)));
-       if (__multiSelection)
-       {
                idList.Add(*(new Integer(ID_BUTTON_SELECTION)));
-       }
 
-       ArrayList titleList;
-       r = titleList.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));
 
-       titleList.Add(*(new String(pSysResource->GetString("sys_string", "IDS_TPLATFORM_BUTTON_CANCEL_ABB"))));
-       if (__multiSelection)
-       {
-               titleList.Add(*(new String(pSysResource->GetString("sys_string", "IDS_TPLATFORM_BUTTON_OK"))));
+               titleList.Add(*(new String(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_TPLATFORM_BUTTON_OK"))));
 
                __pToggledArray = eina_inarray_new(sizeof(int), 0);
                SysTryReturnResult(NID_WEB_CTRL, __pToggledArray, E_OUT_OF_MEMORY, "Memory Allocation failed.");
-       }
-
-       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* >(GetLayoutN()));
-       SysTryReturn(NID_WEB_CTRL, pLayout.get(), r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
 
-       pLayout->SetSpacing(*pButtonPanel,  pPopupData->spacePad);
+               r = CreateAndAddButtons(idList, titleList, pButtonPanel);
+               SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
 
        SetPropagatedKeyEventListener(this);
        
@@ -450,6 +443,8 @@ _SelectBox::OnListViewItemStateChanged(ListView& listView, int index, int elemen
 
                result r = HidePopup();
                SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+               
+               __pImpl->SendUserEvent(ID_USER_SCRIPT_SELECTBOX_CLOSE, null);
        }
 }
 
@@ -492,6 +487,8 @@ _SelectBox::OnActionPerformed(const Control& source, int actionId)
                        SysAssertf(false, "Invalid Action ID");
                }
        }
+
+       __pImpl->SendUserEvent(ID_USER_SCRIPT_SELECTBOX_CLOSE, null);
 }
 
 bool
@@ -521,7 +518,9 @@ _SelectBox::OnKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
                        {
                                ewk_view_popup_menu_select(__pWebView, __prevIndex);
                        }
-               }               
+               }
+
+               __pImpl->SendUserEvent(ID_USER_SCRIPT_SELECTBOX_CLOSE, null);
        }
 
        return false;