Tizen 2.2.1
[framework/osp/web.git] / src / controls / FWebCtrl_WebPopup.cpp
old mode 100644 (file)
new mode 100755 (executable)
index 5b4948b..c9b6769
  */
 #include <FBaseColIList.h>
 #include <FBaseSysLog.h>
+#include <FGrpColor.h>
 #include <FUiCtrlButton.h>
 #include <FUiCtrlPanel.h>
 #include <FUiVerticalBoxLayout.h>
 #include <FUi_ResourceManager.h>
+#include "FWebCtrl_WebManager.h"
 #include "FWebCtrl_WebPopup.h"
 
 
@@ -50,6 +52,13 @@ _WebPopup::_WebPopup(void)
 
 _WebPopup::~_WebPopup(void)
 {
+       _WebManager* pWebManager = _WebManager::GetInstance();
+       pWebManager->RemoveActivePopup(this);
+
+       if (IsModalPopup())
+       {
+               HidePopup();
+       }
        __pWebPopupData.reset();
 }
 
@@ -60,7 +69,6 @@ _WebPopup::Construct(bool hasTitle, const Dimension& popupDim)
        VerticalBoxLayout layout;
 
        Dimension dim(popupDim);
-       dim.height += __pWebPopupData->bottomMargin;
 
        if (hasTitle)
        {
@@ -99,6 +107,9 @@ _WebPopup::ShowPopup(void)
 {
        result r = E_SUCCESS;
 
+       _WebManager* pWebManager = _WebManager::GetInstance();
+       pWebManager->SetActivePopup(this);
+
        r = SetShowState(true);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
@@ -122,7 +133,8 @@ _WebPopup::HidePopup(int modalResult)
                __modal = modalResult;
                __isModal = false;
 
-               return EndModal(__modal);
+               r = EndModal(__modal);
+               SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
        }
 
        return E_SUCCESS;
@@ -132,6 +144,9 @@ _WebPopup::HidePopup(int modalResult)
 result
 _WebPopup::ShowAndWait(int& modalResult)
 {
+       _WebManager* pWebManager = _WebManager::GetInstance();
+       pWebManager->SetActivePopup(this);
+
        __isModal = true;
 
        return DoModal(modalResult);
@@ -144,11 +159,15 @@ _WebPopup::CreateAndAddPanel(void)
        std::unique_ptr<Panel> pPanel(new (std::nothrow) Panel());
        SysTryReturn(NID_WEB_CTRL, pPanel.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-       Rectangle panelRect(0, 0, __pWebPopupData->popupDim.width, __pWebPopupData->btnDim.height);
+       Rectangle panelRect(0, 0, GetSize().width, __pWebPopupData->panelHeight);
 
-       result r = pPanel->Construct(panelRect);
+       result r = pPanel->Construct(panelRect, GROUP_STYLE_BOTTOM);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
+       Color buttonBgColor(0x00000000);
+       GET_COLOR_CONFIG(MESSAGEBOX::BOTTOM_BG_NORMAL, buttonBgColor);
+       pPanel->SetBackgroundColor(buttonBgColor);
+
        r = AddControl(*pPanel);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
@@ -169,9 +188,56 @@ _WebPopup::CreateAndAddButtons(const IList& buttonIds, const IList& buttonTitles
        SysTryReturnResult(NID_WEB_CTRL, idCount > 0 && titleCount > 0 && idCount == titleCount, E_INVALID_DATA, "[E_INVALID_DATA] mismatch in count of Ids and Ttitles.");
 
        int buttonMargin = __pWebPopupData->spacePad/2;
-       int buttonWidth = (__pWebPopupData->popupDim.width - buttonMargin*(idCount+1)) / idCount;
+       if (idCount == 1)
+       {
+               GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_SIDE_MARGIN_01, _CONTROL_ORIENTATION_PORTRAIT, buttonMargin);
+       }
+       int buttonWidth = (GetSize().width - buttonMargin*(idCount+1)) / idCount;
+       int buttonTopMargin = (__pWebPopupData->panelHeight - __pWebPopupData->btnDim.height)/2;
 
        result r = E_SUCCESS;
+
+       //Button Colors
+       Color buttonColorNormal(0x00000000);
+       Color buttonColorPressed(0x00000000);
+       Color buttonColorDisabled(0x00000000);
+       Color buttonColorHighlighted(0x00000000);
+       Color buttonTextNormal(0x00000000);
+       Color buttonTextPressed(0x00000000);
+       Color buttonTextDisabled(0x00000000);
+       Color buttonTextHighlighted(0x00000000);
+
+       Bitmap* pComposedButtonBgNormal = null;
+       Bitmap* pComposedButtonBgPressed = null;
+       Bitmap* pComposedButtonBgDisabled = null;
+       Bitmap* pComposedButtonBgHighlighted = null;
+
+       GET_COLOR_CONFIG(MESSAGEBOX::BOTTOM_BUTTON_BG_NORMAL, buttonColorNormal);
+       GET_COLOR_CONFIG(MESSAGEBOX::BOTTOM_BUTTON_BG_PRESSED, buttonColorPressed);
+       GET_COLOR_CONFIG(MESSAGEBOX::BOTTOM_BUTTON_BG_DISABLED, buttonColorDisabled);
+       GET_COLOR_CONFIG(MESSAGEBOX::BOTTOM_BUTTON_BG_HIGHLIGHTED, buttonColorHighlighted);
+
+       GET_COLOR_CONFIG(MESSAGEBOX::BOTTOM_BUTTON_TEXT_NORMAL, buttonTextNormal);
+       GET_COLOR_CONFIG(MESSAGEBOX::BOTTOM_BUTTON_TEXT_PRESSED, buttonTextPressed);
+       GET_COLOR_CONFIG(MESSAGEBOX::BOTTOM_BUTTON_TEXT_DISABLED, buttonTextDisabled);
+       GET_COLOR_CONFIG(MESSAGEBOX::BOTTOM_BUTTON_TEXT_HIGHLIGHTED, buttonTextHighlighted);
+
+       r = GET_REPLACED_BITMAP_CONFIG_N(MESSAGEBOX::BOTTOM_BUTTON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, buttonColorNormal, pComposedButtonBgNormal);
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       std::unique_ptr< Bitmap > pComposedBtnBgNormal(pComposedButtonBgNormal);
+
+       r = GET_REPLACED_BITMAP_CONFIG_N(MESSAGEBOX::BOTTOM_BUTTON_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, buttonColorPressed, pComposedButtonBgPressed);
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       std::unique_ptr< Bitmap > pComposedBtnBgPressed(pComposedButtonBgPressed);
+
+       r = GET_REPLACED_BITMAP_CONFIG_N(MESSAGEBOX::BOTTOM_BUTTON_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, buttonColorDisabled, pComposedButtonBgDisabled);
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       std::unique_ptr< Bitmap > pComposedBtnBgDisabled(pComposedButtonBgDisabled);
+
+       r = GET_REPLACED_BITMAP_CONFIG_N(MESSAGEBOX::BOTTOM_BUTTON_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, buttonColorHighlighted, pComposedButtonBgHighlighted);
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       std::unique_ptr< Bitmap > pComposedBtnBgHighlighted(pComposedButtonBgHighlighted);
+
        for (int i = 0; i < idCount; i++)
        {
                const Integer* pButtonId = static_cast<const Integer*>(buttonIds.GetAt(i));
@@ -182,11 +248,20 @@ _WebPopup::CreateAndAddButtons(const IList& buttonIds, const IList& buttonTitles
                std::unique_ptr<Button> pButton(new (std::nothrow) Button());
                SysTryReturnResult(NID_WEB_CTRL, pButton.get(), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory Allocation failed.");
 
-               r = pButton->Construct(Rectangle((buttonMargin*(i+1))+(buttonWidth*i), 0, buttonWidth, __pWebPopupData->btnDim.height), *pButtonTitle);
+               r = pButton->Construct(Rectangle((buttonMargin*(i+1))+(buttonWidth*i), buttonTopMargin, buttonWidth, __pWebPopupData->btnDim.height), *pButtonTitle);
                SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
                pButton->SetActionId(pButtonId->ToInt());
 
+               pButton->SetNormalBackgroundBitmap(*pComposedBtnBgNormal);
+               pButton->SetPressedBackgroundBitmap(*pComposedBtnBgPressed);
+               pButton->SetDisabledBackgroundBitmap(*pComposedBtnBgDisabled);
+               pButton->SetHighlightedBackgroundBitmap(*pComposedBtnBgHighlighted);
+               pButton->SetTextColor(buttonTextNormal);
+               pButton->SetPressedTextColor(buttonTextPressed);
+               pButton->SetDisabledTextColor(buttonTextDisabled);
+               pButton->SetHighlightedTextColor(buttonTextHighlighted);
+
                //Add button to panel
                r = pPanel->AddControl(*pButton);
                SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
@@ -229,6 +304,7 @@ _WebPopup::GetPopupData(bool refresh)
 
        GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_HEIGHT, orientation, __pWebPopupData->btnDim.height);
        GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_SIDE_MARGIN_02, orientation, __pWebPopupData->spacePad);
+       GET_SHAPE_CONFIG(MESSAGEBOX::BOTTOM_HEIGHT, orientation, __pWebPopupData->panelHeight);
 
        GET_SHAPE_CONFIG(LABEL::TEXT_FONT_SIZE, orientation, __pWebPopupData->labelFontSize);
        GET_DIMENSION_CONFIG(CHECKBUTTON::MIN_DIMENSION, orientation, __pWebPopupData->checkDim);
@@ -242,4 +318,11 @@ _WebPopup::GetPopupData(bool refresh)
 }
 
 
+result
+_WebPopup::OnTerminating(void)
+{
+       return E_SUCCESS;
+}
+
+
 }}} // Tizen::Web::Controls