fixed bug (N_SE-37335/P130506-5860)
authorChulheon <ch.jeong47@samsung.com>
Tue, 7 May 2013 04:58:31 +0000 (13:58 +0900)
committerChulheon <ch.jeong47@samsung.com>
Tue, 7 May 2013 05:01:48 +0000 (14:01 +0900)
Change-Id: Ia0b3424cd4930920feeb809f5bc4333ca311f1ce

src/ui/controls/FUiCtrl_Edit.cpp
src/ui/controls/FUiCtrl_EditPresenter.cpp
src/ui/controls/FUiCtrl_TextBoxImpl.cpp
src/ui/inc/FUiCtrl_Edit.h
src/ui/inc/FUiCtrl_TextBoxImpl.h

index e40f97a..765de9f 100644 (file)
@@ -558,81 +558,27 @@ _Edit::GetPresenter(void) const
        return _pEditPresenter;
 }
 
-Dimension
-_Edit::GetContentSizeInternal(void) const
+FloatDimension
+_Edit::GetContentSizeInternalF(void) const
 {
-       Dimension dimension(0,0);
-       int leftMargin = 0;
-       int rightMargin = 0;
-       int textTopMargin = 0;
-       int textBottomMargin = 0;
-
-       _ControlOrientation orientation = GetOrientation();
-       GET_SHAPE_CONFIG(EDIT::AREA_LEFT_MARGIN, orientation, leftMargin);
-       GET_SHAPE_CONFIG(EDIT::AREA_RIGHT_MARGIN, orientation, rightMargin);
-       GET_SHAPE_CONFIG(EDIT::AREA_TEXT_TOP_MARGIN, orientation, textTopMargin);
-       GET_SHAPE_CONFIG(EDIT::AREA_TEXT_BOTTOM_MARGIN, orientation, textBottomMargin);
-
-       TextObject* pTextObject = _pEditPresenter->GetTextObject();
-
-       if (!pTextObject)
-       {
-               return dimension;
-       }
-
-       // store
-       TextObjectActionType previousActionType = pTextObject->GetAction();
-       TextObjectWrapType previousWrapType = pTextObject->GetWrap();
-       Rectangle previousRect = pTextObject->GetBounds();
-       Rectangle newRect = previousRect;
-
-       if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
+       if (!GetTextLength())
        {
-       newRect.width = _ControlManager::GetInstance()->GetScreenSize().width;
+               return FloatDimension(GetBoundsF().width, GetBoundsF().height);
        }
-       else
-       {
-               newRect.width = _ControlManager::GetInstance()->GetScreenSize().height;
-       }
-
-
-       pTextObject->SetBounds(newRect);
-       pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE);
-       pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
-       pTextObject->Compose();
-
-       dimension = pTextObject->GetTextExtent(0, pTextObject->GetTextLength());
-       if (dimension.width > newRect.width)
-       {
-               dimension.width = newRect.width;
-       }
-
-       dimension.height = pTextObject->GetTotalHeight();
-
-       // restore
-       pTextObject->SetBounds(previousRect);
-       pTextObject->SetAction(previousActionType);
-       pTextObject->SetWrap(previousWrapType);
-       pTextObject->Compose();
 
-       dimension.width += leftMargin + rightMargin;
-       dimension.height += textTopMargin + textBottomMargin;
-
-       return  dimension;
-}
-
-FloatDimension
-_Edit::GetContentSizeInternalF(void) const
-{
        FloatDimension dimension(0.0f,0.0f);
        float leftMargin = 0.0f;
        float rightMargin = 0.0f;
+       float textLeftMargin = 0.0f;
+       float textRightMargin = 0.0f;
        float textTopMargin = 0.0f;
        float textBottomMargin = 0.0f;
 
        _ControlOrientation orientation = GetOrientation();
        GET_SHAPE_CONFIG(EDIT::AREA_LEFT_MARGIN, orientation, leftMargin);
        GET_SHAPE_CONFIG(EDIT::AREA_RIGHT_MARGIN, orientation, rightMargin);
+       GET_SHAPE_CONFIG(EDIT::AREA_TEXT_LEFT_MARGIN, orientation, textLeftMargin);
+       GET_SHAPE_CONFIG(EDIT::AREA_TEXT_RIGHT_MARGIN, orientation, textRightMargin);
        GET_SHAPE_CONFIG(EDIT::AREA_TEXT_TOP_MARGIN, orientation, textTopMargin);
        GET_SHAPE_CONFIG(EDIT::AREA_TEXT_BOTTOM_MARGIN, orientation, textBottomMargin);
 
@@ -640,7 +586,7 @@ _Edit::GetContentSizeInternalF(void) const
 
        if (!pTextObject)
        {
-               return dimension;
+               return FloatDimension(GetBoundsF().width, GetBoundsF().height);
        }
 
        // store
@@ -649,37 +595,85 @@ _Edit::GetContentSizeInternalF(void) const
        FloatRectangle previousRect = pTextObject->GetBoundsF();
        FloatRectangle newRect = previousRect;
 
-       if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
+       bool fitToHorizontal = false;
+       bool fitToVertical = true;
+
+       if (fitToHorizontal)
        {
-       newRect.width = _ControlManager::GetInstance()->GetScreenSizeF().width;
+               if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
+               {
+                       newRect.width = _ControlManager::GetInstance()->GetScreenSizeF().width;
+               }
+               else
+               {
+                       newRect.width = _ControlManager::GetInstance()->GetScreenSizeF().height;
+               }
+               newRect.width -= (GetBoundsF().x + leftMargin + rightMargin);
        }
-       else
+       if (fitToVertical)
        {
-               newRect.width = _ControlManager::GetInstance()->GetScreenSizeF().height;
+               if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
+               {
+                       newRect.height = _ControlManager::GetInstance()->GetScreenSizeF().height;
+               }
+               else
+               {
+                       newRect.height = _ControlManager::GetInstance()->GetScreenSizeF().width;
+               }
+               newRect.height -= (GetBoundsF().y + textTopMargin + textBottomMargin);
        }
 
-
        pTextObject->SetBounds(newRect);
        pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE);
        pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
        pTextObject->Compose();
 
-       dimension = pTextObject->GetTextExtentF(0, pTextObject->GetTextLength());
-       if (dimension.width > newRect.width)
+       if (fitToHorizontal && fitToVertical)
        {
+               dimension = pTextObject->GetTextExtentF(0, pTextObject->GetTextLength());
+               float height = pTextObject->GetTotalHeightF();
+               if (height < newRect.height)
+               {
+                       dimension.height = height;
+               }
+               else
+               {
+                       dimension.height = newRect.height;
+               }
+       }
+       else if (fitToHorizontal)
+       {
+               dimension = pTextObject->GetTextExtentF(0, pTextObject->GetTextLength());
+               dimension.height = GetBoundsF().height;
+       }
+       else if (fitToVertical)
+       {
+               float height = pTextObject->GetTotalHeightF();
+               if (height < newRect.height)
+               {
+                       dimension.height = height;
+               }
+               else
+               {
+                       dimension.height = newRect.height;
+               }
                dimension.width = newRect.width;
        }
 
-       dimension.height = pTextObject->GetTotalHeightF();
-
        // restore
        pTextObject->SetBounds(previousRect);
        pTextObject->SetAction(previousActionType);
        pTextObject->SetWrap(previousWrapType);
        pTextObject->Compose();
 
-       dimension.width += leftMargin + rightMargin;
-       dimension.height += textTopMargin + textBottomMargin;
+       if (fitToHorizontal)
+       {
+               dimension.width += leftMargin + rightMargin + textLeftMargin + textRightMargin;
+       }
+       if (fitToVertical)
+       {
+               dimension.height += textTopMargin + textBottomMargin;
+       }
 
        return  dimension;
 }
index 2a5687d..6e6aa8b 100644 (file)
@@ -948,6 +948,17 @@ _EditPresenter::OnClipboardPopupBoundsChanged(Tizen::Graphics::Dimension& clipbo
 
                        __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
                }
+
+               if (__rotated) // Command button should be relocated after rotation in case of no keypad.
+               {
+                       if (__isCopyPasteManagerExist)
+                       {
+                               __pCopyPasteManager->CreateHandle();
+                               __pCopyPasteManager->CreateCopyPastePopup();
+                               __pCopyPasteManager->Show();
+                       }
+                       __rotated = false;
+               }
        }
 
        return;
@@ -2141,7 +2152,7 @@ _EditPresenter::Draw(Canvas& canvas)
                }
        }
 
-       if (__rotated) // Command button should be relocated after rotation in case of no keypad.
+       if (__rotated && !__clipboardConnected) // Command button should be relocated after rotation in case of no keypad.
        {
                if (__isCopyPasteManagerExist)
                {
@@ -3935,7 +3946,6 @@ _EditPresenter::OnTapGestureDetected(void)
                __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
                SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, false, E_SYSTEM, "[EDIT] Unable to create _EditCopyPasteManager instance.");
                __pCopyPasteManager->AddCopyPasteEventListener(*this);
-               __pCopyPasteManager->CreateCopyPastePopup();
                __pCopyPasteManager->Show();
                __isCopyPasteManagerExist = true;
 
index befa903..e9b4d84 100644 (file)
@@ -604,13 +604,12 @@ _TextBoxImpl::OnTextBlockSelected(_Control& source, int start, int end)
        }
 }
 
-Dimension
-_TextBoxImpl::GetContentSize(void) const
+FloatDimension
+_TextBoxImpl::GetContentSizeF(void) const
 {
-       return __pEdit->GetContentSizeInternal();
+       return __pEdit->GetContentSizeInternalF();
 }
 
-
 _TextBoxImpl*
 _TextBoxImpl::GetInstance(TextBox& textBox)
 {
index 7fd1a85..f8259ee 100644 (file)
@@ -493,7 +493,6 @@ public:
        virtual void OnSettingChanged(Tizen::Base::String& key);
 
        _EditPresenter* GetPresenter(void) const;
-       Tizen::Graphics::Dimension GetContentSizeInternal(void) const;
        Tizen::Graphics::FloatDimension GetContentSizeInternalF(void) const;
        bool IsInternalFocused(void) const;
        bool ValidatePastedText(const Tizen::Base::String& pastedText, Tizen::Base::String& replacedText);
index 2a8d4ea..daba4dd 100644 (file)
@@ -617,7 +617,7 @@ public:
         */
        result RemoveTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener);
 
-       virtual Tizen::Graphics::Dimension GetContentSize(void) const;
+       virtual Tizen::Graphics::FloatDimension GetContentSizeF(void) const;
 
 // Operation
 public: