modify button text on MessageBox, ProgressPopup
authorDongJinJeon <dongjin2193.jeon@samsung.com>
Mon, 22 Apr 2013 10:53:11 +0000 (19:53 +0900)
committerDongJinJeon <dongjin2193.jeon@samsung.com>
Mon, 22 Apr 2013 10:57:06 +0000 (19:57 +0900)
Change-Id: I94a6e85fa25515d0ff1093912bbf4e2f51af3d5f
Signed-off-by: DongJinJeon <dongjin2193.jeon@samsung.com>
src/ui/controls/FUiCtrl_MessageBox.cpp
src/ui/controls/FUiCtrl_MessageBoxPresenter.cpp
src/ui/controls/FUiCtrl_ProgressPopup.cpp
src/ui/inc/FUiCtrl_MessageBox.h
src/ui/inc/FUiCtrl_MessageBoxPresenter.h
src/ui/inc/FUiCtrl_ProgressPopup.h

index bb5656c..bbb29f6 100644 (file)
@@ -23,6 +23,7 @@
 #include <FBaseSysLog.h>
 #include <FBaseErrorDefine.h>
 #include <FGrp_BitmapImpl.h>
+#include <FSys_SettingInfoImpl.h>
 #include "FUi_AccessibilityContainer.h"
 #include "FUi_AccessibilityElement.h"
 #include "FUi_CoordinateSystemUtils.h"
@@ -37,6 +38,7 @@
 
 using namespace Tizen::Base;
 using namespace Tizen::Graphics;
+using namespace Tizen::System;
 
 
 namespace Tizen { namespace Ui { namespace Controls
@@ -66,6 +68,8 @@ _MessageBox::~_MessageBox(void)
 
        delete _pOutlineBitmap;
        _pOutlineBitmap = null;
+
+       _SettingInfoImpl::RemoveSettingEventListener(*this);
 }
 
 _MessageBox*
@@ -146,6 +150,9 @@ _MessageBox::Initialize(const String& title, const String& text, MessageBoxStyle
 
        SetTouchPressThreshold(0.08);
 
+       r = _SettingInfoImpl::AddSettingEventListenerForInternal(*this);
+       SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
        return r;
 }
 
@@ -374,6 +381,16 @@ _MessageBox::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
        return __pMsgboxPresenter->OnTouchMoved(source, touchinfo);
 }
 
+void
+_MessageBox::OnSettingChanged(String& key)
+{
+       const wchar_t* LOCALE_LANGUAGE = L"http://tizen.org/setting/locale.language";
+
+       if (key == LOCALE_LANGUAGE)
+       {
+               __pMsgboxPresenter->UpdateButtonString();
+       }
+}
 
 }}} // Tizen::Ui::Controls
 
index 7b4d57d..f650236 100644 (file)
@@ -573,11 +573,9 @@ _MessageBoxPresenter::ProcessEvent(void)
        }
  }
 
-result
-_MessageBoxPresenter::CreateButtons(void)
+void
+_MessageBoxPresenter::GetButtonString(void)
 {
-       String buttonText[3];
-
        switch (__pMessageBox->GetMsgBoxStyle())
        {
        case MSGBOX_STYLE_NONE:
@@ -586,56 +584,73 @@ _MessageBoxPresenter::CreateButtons(void)
 
        case MSGBOX_STYLE_OK:
                __buttonNum = 1;
-               GET_STRING_CONFIG(IDS_COM_SK_OK, buttonText[0]);
+               GET_STRING_CONFIG(IDS_COM_SK_OK, __buttonText[0]);
                break;
 
        case MSGBOX_STYLE_CANCEL:
                __buttonNum = 1;
-               GET_STRING_CONFIG(IDS_COM_SK_CANCEL, buttonText[0]);
+               GET_STRING_CONFIG(IDS_COM_SK_CANCEL, __buttonText[0]);
                break;
 
        case MSGBOX_STYLE_OKCANCEL:
                __buttonNum = 2;
-               GET_STRING_CONFIG(IDS_COM_SK_OK, buttonText[0]);
-               GET_STRING_CONFIG(IDS_COM_SK_CANCEL, buttonText[1]);
+               GET_STRING_CONFIG(IDS_COM_SK_OK, __buttonText[0]);
+               GET_STRING_CONFIG(IDS_COM_SK_CANCEL, __buttonText[1]);
                break;
 
        case MSGBOX_STYLE_YESNO:
                __buttonNum = 2;
-               GET_STRING_CONFIG(IDS_COM_SK_YES, buttonText[0]);
-               GET_STRING_CONFIG(IDS_COM_SK_NO, buttonText[1]);
+               GET_STRING_CONFIG(IDS_COM_SK_YES, __buttonText[0]);
+               GET_STRING_CONFIG(IDS_COM_SK_NO, __buttonText[1]);
                break;
 
        case MSGBOX_STYLE_YESNOCANCEL:
                __buttonNum = 3;
-               GET_STRING_CONFIG(IDS_COM_SK_YES, buttonText[0]);
-               GET_STRING_CONFIG(IDS_COM_SK_NO, buttonText[1]);
-               GET_STRING_CONFIG(IDS_COM_SK_CANCEL, buttonText[2]);
+               GET_STRING_CONFIG(IDS_COM_SK_YES, __buttonText[0]);
+               GET_STRING_CONFIG(IDS_COM_SK_NO, __buttonText[1]);
+               GET_STRING_CONFIG(IDS_COM_SK_CANCEL, __buttonText[2]);
                break;
 
        case MSGBOX_STYLE_ABORTRETRYIGNORE:
                __buttonNum = 3;
-               GET_STRING_CONFIG(IDS_COM_SK_ABORT, buttonText[0]);
-               GET_STRING_CONFIG(IDS_COM_SK_RETRY, buttonText[1]);
-               GET_STRING_CONFIG(IDS_COM_SK_IGNORE, buttonText[2]);
+               GET_STRING_CONFIG(IDS_COM_SK_ABORT, __buttonText[0]);
+               GET_STRING_CONFIG(IDS_COM_SK_RETRY, __buttonText[1]);
+               GET_STRING_CONFIG(IDS_COM_SK_IGNORE, __buttonText[2]);
                break;
 
        case MSGBOX_STYLE_CANCELTRYCONTINUE:
                __buttonNum = 3;
-               GET_STRING_CONFIG(IDS_COM_SK_CANCEL, buttonText[0]);
-               GET_STRING_CONFIG(IDS_COM_SK_TRY, buttonText[1]);
-               GET_STRING_CONFIG(IDS_COM_BODY_CONTINUE, buttonText[2]);
+               GET_STRING_CONFIG(IDS_COM_SK_CANCEL, __buttonText[0]);
+               GET_STRING_CONFIG(IDS_COM_SK_TRY, __buttonText[1]);
+               GET_STRING_CONFIG(IDS_COM_BODY_CONTINUE, __buttonText[2]);
                break;
 
        case MSGBOX_STYLE_RETRYCANCEL:
                __buttonNum = 2;
-               GET_STRING_CONFIG(IDS_COM_SK_RETRY, buttonText[0]);
-               GET_STRING_CONFIG(IDS_COM_SK_CANCEL, buttonText[1]);
+               GET_STRING_CONFIG(IDS_COM_SK_RETRY, __buttonText[0]);
+               GET_STRING_CONFIG(IDS_COM_SK_CANCEL, __buttonText[1]);
                break;
 
        default:
                break;
        }
+}
+
+void
+_MessageBoxPresenter::UpdateButtonString(void)
+{
+       GetButtonString();
+
+       for (int i = 0; i < __buttonNum; i++)
+       {
+               __pButtons[i]->SetText(__buttonText[i]);
+       }
+}
+
+result
+_MessageBoxPresenter::CreateButtons(void)
+{
+       GetButtonString();
 
        __pButtonListener = new (std::nothrow) _MessageBoxButtonListener();
        SysTryReturn(NID_UI_CTRL, __pButtonListener != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
@@ -653,7 +668,7 @@ _MessageBoxPresenter::CreateButtons(void)
                r = __pButtons[i]->Construct(CalculateButtonPositionAndSize(i));
                SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
 
-               __pButtons[i]->SetText(buttonText[i]);
+               __pButtons[i]->SetText(__buttonText[i]);
                __pButtons[i]->AddTouchEventListener(*__pButtonListener);
 
                pImpl = _ControlImpl::GetInstance(*__pButtons[i]);
index 80a35ff..6bc1e8b 100644 (file)
@@ -24,6 +24,7 @@
 #include <FBaseErrorDefine.h>
 #include <FUiCtrlButton.h>
 #include <FGrp_BitmapImpl.h>
+#include <FSys_SettingInfoImpl.h>
 #include "FUi_AccessibilityContainer.h"
 #include "FUi_AccessibilityElement.h"
 #include "FUi_CoordinateSystemUtils.h"
@@ -42,7 +43,7 @@ using namespace Tizen::Graphics;
 using namespace Tizen::Ui;
 using namespace Tizen::Ui::Animations;
 using namespace Tizen::Base;
-
+using namespace Tizen::System;
 
 namespace Tizen { namespace Ui { namespace Controls
 {
@@ -91,6 +92,8 @@ _ProgressPopup::~_ProgressPopup(void)
                __pTextAccessibilityElement->Activate(false);
                __pTextAccessibilityElement = null;
        }
+
+       _SettingInfoImpl::RemoveSettingEventListener(*this);
 }
 
 _ProgressPopup*
@@ -160,7 +163,11 @@ _ProgressPopup::Initialize(bool cancelButton, bool transparent, const FloatRecta
                __pButton = new (std::nothrow) Button();
                SysTryCatch(NID_UI_CTRL, __pButton != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
 
-               r = __pButton->Construct(pPresenter->GetButtonBounds(), L"Cancel");
+               String buttonText;
+
+               GET_STRING_CONFIG(IDS_COM_SK_CANCEL, buttonText);
+
+               r = __pButton->Construct(pPresenter->GetButtonBounds(), buttonText);
                SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
 
                _ControlImpl* pImpl = _ControlImpl::GetInstance(*__pButton);
@@ -181,6 +188,9 @@ _ProgressPopup::Initialize(bool cancelButton, bool transparent, const FloatRecta
                InitializeAccessibilityElement();
        }
 
+       r = _SettingInfoImpl::AddSettingEventListenerForInternal(*this);
+       SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
        return r;
 
 CATCH:
@@ -689,6 +699,19 @@ _ProgressPopup::OnTouchReleased(const _Control& source, const _TouchInfo& touchi
        return __pProgressPopupPresenter->OnTouchReleased(source, touchinfo);
 }
 
+void
+_ProgressPopup::OnSettingChanged(String& key)
+{
+       const wchar_t* LOCALE_LANGUAGE = L"http://tizen.org/setting/locale.language";
+
+       if ((key == LOCALE_LANGUAGE) && (__pButton != null))
+       {
+               String buttonText;
+
+               GET_STRING_CONFIG(IDS_COM_SK_CANCEL, buttonText);
+               __pButton->SetText(buttonText);
+       }
+}
 
 }}} // Tizen::Ui::Controls
 
index c984604..459314a 100644 (file)
 #ifndef _FUI_CTRL_INTERNAL_MESSAGEBOX_H_
 #define _FUI_CTRL_INTERNAL_MESSAGEBOX_H_
 
-
+#include <FSysISettingEventListener.h>
 #include <FUiCtrlMessageBox.h>
 #include "FUiCtrl_Popup.h"
 
 
 namespace Tizen { namespace Ui { namespace Controls
 {
-
 class _MessageBoxPresenter;
 
 /**
@@ -49,6 +48,7 @@ class _OSP_EXPORT_ _MessageBox
        , virtual public Tizen::Base::Runtime::IEventListener
        , virtual public _IUiEventListener
        , virtual public _IUiEventPreviewer
+       , virtual public Tizen::System::ISettingEventListener
 {
 // Lifecycle
 public:
@@ -76,7 +76,7 @@ public:
        virtual void OnChangeLayout(_ControlOrientation orientation);
 
        virtual void OnBoundsChanged(void);
-
+       virtual void OnSettingChanged(Tizen::Base::String& key);
 
 // Accessors
 public:
@@ -113,7 +113,6 @@ private:
        Tizen::Base::String __text;
 
        unsigned long __timeout;
-
 };  // _MessageBox
 
 
index 618f9ef..6cf2474 100644 (file)
@@ -82,6 +82,8 @@ public:
        virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
        virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
 
+       void UpdateButtonString(void);
+
 //Accessor
 public:
        float GetBodyTextHeight(void) const;
@@ -109,6 +111,8 @@ private:
        float GetLabelHeight(Tizen::Graphics::_Text::TextObject* textObject, wchar_t* text, int length, float fontSize, FloatRectangle bounds);
        float GetLeftRightLabelMargin(void);
 
+       void GetButtonString(void);
+
 // Inner class
 private:
        class _MessageBoxButtonListener
@@ -161,7 +165,10 @@ private:
        _MessageBoxButtonListener* __pButtonListener;
        MessageBoxModalResult __msgboxResult;
 
-       Tizen::Ui::Controls::Button* __pButtons[3];
+       static const int MSGBOX_MAX_BUTTON_NUM = 3;
+
+       Tizen::Ui::Controls::Button* __pButtons[MSGBOX_MAX_BUTTON_NUM];
+       Tizen::Base::String __buttonText[MSGBOX_MAX_BUTTON_NUM];
 
     Tizen::Ui::_AccessibilityElement* __pTextAccessibilityElement;
 
index acde66e..810c91e 100644 (file)
@@ -25,7 +25,7 @@
 #ifndef _FUI_CTRL_INTERNAL_PROGRESS_POPUP_H_
 #define _FUI_CTRL_INTERNAL_PROGRESS_POPUP_H_
 
-
+#include <FSysISettingEventListener.h>
 #include <FUiCtrlProgressPopup.h>
 #include "FUiCtrl_Popup.h"
 #include "FUiCtrl_IActionEventListener.h"
@@ -54,6 +54,7 @@ class _ProgressPopup
        , virtual public Tizen::Base::Runtime::IEventListener
        , virtual public _IUiEventListener
        , virtual public _IUiEventPreviewer
+       , virtual public Tizen::System::ISettingEventListener
 {
 
 //Lifecycle
@@ -87,6 +88,7 @@ public:
        virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
        virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
        virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
+       virtual void OnSettingChanged(Tizen::Base::String& key);
 
 public:
        result AddProgressPopupEventListener(const Tizen::Ui::Controls::_IProgressPopupEventListener& listener);