#include "FUiCtrl_TableView.h"
#include "FUi_Window.h"
+#define EDIT_DRAG_AND_DROP_ENABLED 0
using namespace Tizen::Base::Runtime;
using namespace Tizen::Base::Utility;
return pAnimation;
}
+class _EditDragAndDropWindow
+ : public Tizen::Ui::_Window
+{
+public:
+ _EditDragAndDropWindow(void);
+ virtual ~_EditDragAndDropWindow(void);
+
+ virtual result OnAttachedToMainTree(void);
+ void SetLabel(_Label* pLabel);
+private:
+ _Label* __pLabel;
+}; // _EditDragAndDropWindow
+
+_EditDragAndDropWindow::_EditDragAndDropWindow(void)
+: __pLabel(null)
+{
+}
+
+_EditDragAndDropWindow::~_EditDragAndDropWindow(void)
+{
+ if (__pLabel)
+ {
+ DetachChild(*__pLabel);
+ delete __pLabel;
+ __pLabel = null;
+ }
+}
+
+result
+_EditDragAndDropWindow::OnAttachedToMainTree(void)
+{
+ AcquireHandle();
+
+ return E_SUCCESS;
+}
+
+void
+_EditDragAndDropWindow::SetLabel(_Label* pLabel)
+{
+ __pLabel = pLabel;
+}
+
_EditPresenter::_EditPresenter(void)
: __pTitleSlidingTimer(null)
, __pEdit(null)
, __isPasswordVisible(false)
, __needToCreateCopyPastePopup(false)
, __calculatedCursorBounds(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
+ , __dragAndDropStarted(false)
+ , __dragAndDropString("")
{
}
bool
_EditPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
{
+ if (__dragAndDropStarted)
+ {
+ __dragAndDropStarted = false;
+ __pEdit->DragAndDropDrop();
+
+ return true;
+ }
+
if (__isCopyPasteManagerExist)
{
if (__isTouchPressed && !__isCopyPastePopupMoving)
bool
_EditPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
{
+ if (__dragAndDropStarted)
+ {
+ _Window* pDragWindow = __pEdit->GetDragWindow();
+ if (pDragWindow)
+ {
+ FloatPoint dragPoint = touchInfo.GetCurrentPosition();
+ dragPoint.x += __pEdit->GetAbsoluteBoundsF(true).x;
+ dragPoint.y += __pEdit->GetAbsoluteBoundsF(true).y;
+ pDragWindow->SetPosition(FloatPoint(dragPoint.x - pDragWindow->GetBoundsF().width/2.0f, dragPoint.y - pDragWindow->GetBoundsF().height/2.0f));
+ }
+ return true;
+ }
+
if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
{
return false;
if (__isCopyPasteManagerExist)
{
+
+#if EDIT_DRAG_AND_DROP_ENABLED
+ if (IsBlocked())
+ {
+ int start = -1;
+ int end = -1;
+ GetBlockRange(start, end);
+ __dragAndDropString = GetText(start, end-1);
+ _DragAndDropItem* pDragAndDropItem = _DragAndDropItem::CreateInstanceN(_DRAG_AND_DROP_TYPE_TEXT, __dragAndDropString);
+ SysTryReturn(NID_UI_CTRL, pDragAndDropItem, false, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ __pEdit->DragAndDropBegin(*pDragAndDropItem);
+ delete pDragAndDropItem;
+
+ __dragAndDropStarted = true;
+ InitializeCopyPasteManager();
+ }
+#endif
return true;
}
else if (IsCurrentFocused() == false)
return r;
}
+_Window*
+_EditPresenter::OnDragAndDropBeginning(void)
+{
+ SysLog(NID_UI_CTRL, "Drag & Drop Callback is called");
+
+ result r = E_SUCCESS;
+ _Label* pLabel = null;
+ FloatDimension dragWindowDimension;
+ _ControlOrientation orientation = __pEdit->GetOrientation();
+
+ GET_SHAPE_CONFIG(EDIT::DRAG_AND_DROP_WINDOW_WIDTH, orientation, dragWindowDimension.width);
+ GET_SHAPE_CONFIG(EDIT::DRAG_AND_DROP_WINDOW_HEIGHT, orientation, dragWindowDimension.height);
+
+ FloatRectangle bounds(__pressedAbsolutePoint.x-dragWindowDimension.width/2.0f, __pressedAbsolutePoint.y-dragWindowDimension.height/2.0f, dragWindowDimension.width, dragWindowDimension.height);
+
+ _EditDragAndDropWindow* pDragWindow = new (std::nothrow) _EditDragAndDropWindow();
+ SysTryReturn(NID_UI_CTRL, pDragWindow, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
+
+ r = pDragWindow->CreateRootVisualElement(_WINDOW_TYPE_SUB);
+ SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+ pDragWindow->SetBackgroundColor(Color(0, 0, 0, 0));
+ pDragWindow->SetActivationEnabled(false);
+ pDragWindow->SetBounds(bounds);
+
+ pLabel = _Label::CreateLabelN();
+ SysTryCatch(NID_UI_CTRL, pLabel, , E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(r));
+
+ pLabel->SetBackgroundColor(Color(0, 0, 0, 0));
+ pLabel->SetBounds(FloatRectangle(0, 0, bounds.width, bounds.height));
+ pLabel->SetText(__dragAndDropString);
+ pLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
+
+ pDragWindow->AttachChild(*pLabel);
+ pDragWindow->SetLabel(pLabel);
+
+ pDragWindow->SetZOrderGroup(WINDOW_Z_ORDER_GROUP_HIGH);
+ pDragWindow->Open();
+
+ return pDragWindow;
+
+CATCH:
+ delete pDragWindow;
+
+ return null;
+}
+
+void
+_EditPresenter::OnDragAndDropDropping(void)
+{
+ SysLog(NID_UI_CTRL, "Drag & Drop Callback is called");
+
+ _Window* pDragWindow = __pEdit->GetDragWindow();
+ if (pDragWindow)
+ {
+ pDragWindow->Close();
+ delete pDragWindow;
+ }
+ return;
+}
+
+void
+_EditPresenter::OnDragAndDropEntered(void)
+{
+ SysLog(NID_UI_CTRL, "Drag & Drop Callback is called");
+ if (!IsViewModeEnabled() && !IsCurrentFocused())
+ {
+ _Window* pWindow = null;
+ _ControlManager* pControlManager = _ControlManager::GetInstance();
+ SysTryReturnVoidResult(NID_UI, pControlManager, E_SYSTEM, "[E_SYSTEM] System error occurred.");
+
+ pWindow = pControlManager->GetCurrentFrame();
+ if (pWindow)
+ {
+ _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
+ SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] System error occurred.");
+
+ bool visible = pEcoreEvas->IsWindowVisible(*pWindow);
+ bool activationEnabled = pEcoreEvas->IsWindowActivationEnabled(*pWindow);
+
+ if ((visible == true) && (activationEnabled == true))
+ {
+ pEcoreEvas->ActivateWindow(*pWindow);
+ }
+ }
+ __pEdit->SetFocused();
+ }
+ return;
+}
+
+void
+_EditPresenter::OnDragAndDropMoved(const Tizen::Graphics::FloatPoint& position)
+{
+ SysLog(NID_UI_CTRL, "Drag & Drop Callback is called");
+
+ if (IsViewModeEnabled())
+ {
+ return;
+ }
+
+ FloatRectangle clientBounds = __pEdit->GetBoundsF();
+ clientBounds.x = 0.0f;
+ clientBounds.y = 0.0f;
+ if (clientBounds.Contains(position))
+ {
+ int rowIndex;
+ int columnIndex;
+ int cursorPos = GetCursorPositionAt(position, rowIndex,columnIndex);
+ if (cursorPos != -1)
+ {
+ SetCursorPosition(cursorPos, rowIndex, columnIndex);
+ }
+ else
+ {
+ if ((__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) == false)
+ {
+ SetCursorPosition(GetTextLength());
+ }
+ }
+ InitializeCursor();
+ }
+ return;
+}
+
+void
+_EditPresenter::OnDragAndDropLeft(void)
+{
+ SysLog(NID_UI_CTRL, "Drag & Drop Callback is called");
+ return;
+}
+
+void
+_EditPresenter::OnDragAndDropDropped(const _DragAndDropItem& dragAndDropItem)
+{
+ SysLog(NID_UI_CTRL, "Drag & Drop Callback is called");
+
+ if (IsViewModeEnabled())
+ {
+ return;
+ }
+
+ if (IsUnsupportedChracterExist(GetKeypadStyle(), dragAndDropItem.GetData()))
+ {
+ return;
+ }
+
+ InsertTextAt(__cursorPos, dragAndDropItem.GetData());
+ DrawText();
+ return;
+}
+
}}} // Tizen::Ui::Controls