add patch
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_SearchBarPresenter.cpp
index a6b9500..01a0588 100644 (file)
@@ -64,41 +64,23 @@ _SearchBarPresenter::~_SearchBarPresenter(void)
        delete __pSearchBarModel;
        __pSearchBarModel = null;
 
-       if (__pReplacedSearchFieldNormalBitmap)
-       {
-               delete __pReplacedSearchFieldNormalBitmap;
-               __pReplacedSearchFieldNormalBitmap = null;
-       }
+       delete __pReplacedSearchFieldNormalBitmap;
+       __pReplacedSearchFieldNormalBitmap = null;
 
-       if (__pReplacedSearchFieldDisabledBitmap)
-       {
-               delete __pReplacedSearchFieldDisabledBitmap;
-               __pReplacedSearchFieldDisabledBitmap = null;
-       }
+       delete __pReplacedSearchFieldDisabledBitmap;
+       __pReplacedSearchFieldDisabledBitmap = null;
 
-       if (__pReplacedSearchBarBitmap)
-       {
-               delete __pReplacedSearchBarBitmap;
-               __pReplacedSearchBarBitmap = null;
-       }
+       delete __pReplacedSearchBarBitmap;
+       __pReplacedSearchBarBitmap = null;
 
-       if (__pSearchBarBitmap)
-       {
-               delete __pSearchBarBitmap;
-               __pSearchBarBitmap = null;
-       }
+       delete __pSearchBarBitmap;
+       __pSearchBarBitmap = null;
 
-       if (__pSearchFieldEffectBitmap)
-       {
-               delete __pSearchFieldEffectBitmap;
-               __pSearchFieldEffectBitmap = null;
-       }
+       delete __pSearchFieldEffectBitmap;
+       __pSearchFieldEffectBitmap = null;
 
-       if (__pSearchBarEffectBitmap)
-       {
-               delete __pSearchBarEffectBitmap;
-               __pSearchBarEffectBitmap = null;
-       }
+       delete __pSearchBarEffectBitmap;
+       __pSearchBarEffectBitmap = null;
 }
 
 result
@@ -154,7 +136,7 @@ _SearchBarPresenter::Construct(const _SearchBar& searchBar)
        return r;
 
 CATCH:
-       if (__pIconElement)
+       if (__pIconElement != null)
        {
                __pIconElement->Destroy();
                __pIconElement = null;
@@ -291,7 +273,7 @@ _SearchBarPresenter::IsModeLocked(void) const
 }
 
 result
-_SearchBarPresenter::SetMode(SearchBarMode mode)
+_SearchBarPresenter::SetMode(SearchBarMode mode, bool isCalledByApp)
 {
        SysTryReturn(NID_UI_CTRL, IsModeLocked() == false, E_INVALID_OPERATION, E_INVALID_OPERATION,
                     "[E_INVALID_OPERATION] The searchbar mode is locked.");
@@ -303,7 +285,7 @@ _SearchBarPresenter::SetMode(SearchBarMode mode)
 
        __pSearchBarModel->SetMode(mode);
 
-       result r = ChangeMode(mode);
+       result r = ChangeMode(mode, isCalledByApp);
        SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
                     "[E_SYSTEM] A system error has occurred. Failed to change the mode of searchbar.");
 
@@ -327,7 +309,7 @@ _SearchBarPresenter::Draw(void)
 
        Bitmap* pBackgroundBitmap = __pSearchBar->GetBackgroundBitmap();
 
-       if (!pBackgroundBitmap)
+       if (pBackgroundBitmap == null)
        {
                r = DrawSearchBarDefaultBitmap();
                SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
@@ -435,7 +417,7 @@ _SearchBarPresenter::DrawSearchBarDefaultBitmap(void)
 void
 _SearchBarPresenter::SetCancelButtonVisible(bool visible)
 {
-       if ((__pSearchBar->IsUsableCancelButton() == false) && visible)
+       if ((!__pSearchBar->IsUsableCancelButton()) && visible)
        {
                return;
        }
@@ -551,7 +533,7 @@ _SearchBarPresenter::DrawIcon(void)
 
 
 result
-_SearchBarPresenter::ChangeMode(SearchBarMode mode)
+_SearchBarPresenter::ChangeMode(SearchBarMode mode, bool isCalledByApp)
 {
        result r = E_SUCCESS;
 
@@ -562,7 +544,7 @@ _SearchBarPresenter::ChangeMode(SearchBarMode mode)
                SetCancelButtonVisible(false);
                SetContainerVisible(false);
 
-               if (__pEdit)
+               if (__pEdit != null)
                {
                        __pEdit->ClearText();
                        __pEdit->SetBounds(__searchFieldBounds);
@@ -586,20 +568,23 @@ _SearchBarPresenter::ChangeMode(SearchBarMode mode)
                SetCancelButtonVisible(true);
                __pSearchBar->SetContentDimming();
 
-               if (__pEdit)
+               if (__pEdit != null)
                {
                        float buttonWidth = 0.0f;
                        _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
                        GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
 
                        float cancelButtonWidth = 0.0f;
-                       cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightTouchMarginF() + __pCancelButton->GetLeftTouchMarginF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF();
+                       cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF();
 
                        if (cancelButtonWidth <= buttonWidth)
                        {
                                __pEdit->SetBounds(__searchFieldBounds);
                        }
-                       __pEdit->ShowKeypad();
+                       if (isCalledByApp)
+                       {
+                               __pEdit->ShowKeypad();
+                       }
                }
                __pSearchBar->SetContentsArea();
 
@@ -619,7 +604,7 @@ _SearchBarPresenter::InitializeInputModeLayout(void)
 {
        InitializeViewModeLayout();
 
-       if (__pSearchBar->IsUsableCancelButton() == false)
+       if (!__pSearchBar->IsUsableCancelButton())
        {
                return;
        }
@@ -655,7 +640,7 @@ _SearchBarPresenter::InitializeInputModeLayout(void)
        __searchFieldBounds.width = (__pSearchBar->GetBoundsF().width > searchFieldMinWidth) ? __searchFieldBounds.width : searchFieldMinWidth;
 
        float cancelButtonWidth = 0.0f;
-       cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightTouchMarginF() + __pCancelButton->GetLeftTouchMarginF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF();
+       cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF();
 
        if (cancelButtonWidth > buttonWidth)
        {
@@ -727,7 +712,7 @@ _SearchBarPresenter::OnBoundsChanged(void)
                r = __pSearchBar->ResizeCancelButton();
                SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.",GetErrorMessage(r));
 
-               cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightTouchMarginF() + __pCancelButton->GetLeftTouchMarginF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF();
+               cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF();
        }
 
        r = __pEdit->SetBounds(__searchFieldBounds);
@@ -751,12 +736,21 @@ _SearchBarPresenter::OnBoundsChanged(void)
        return;
 }
 
+void
+_SearchBarPresenter::OnTouchReleased(const _Control& source)
+{
+       if (&source == __pEdit)
+       {
+               __pEdit->ShowKeypad();
+       }
+}
+
 Canvas*
 _SearchBarPresenter::OnCanvasRequestedN(const FloatRectangle& bounds)
 {
        Canvas* pCanvas = null;
 
-       if (__lazyDecode == true)
+       if (__lazyDecode)
        {
                Bitmap* pBackgroundBitmap = __pSearchBar->GetBackgroundBitmap();
                SysTryReturn(NID_UI_CTRL, pBackgroundBitmap != null, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get the background bitmap.");