, public Tizen::Ui::Controls::IFormBackEventListener
, public Tizen::Ui::Scenes::ISceneEventListener
, public Tizen::Shell::IAppWidgetViewEventListener
+ , public Tizen::Ui::IPropagatedTouchEventListener
{
public:
ViewForm(void);
bool Initialize();
virtual result OnInitializing(void);
virtual result OnTerminating(void);
+ virtual bool OnTouchPressed(Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo){}
+ virtual bool OnTouchReleased(Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo){}
+ virtual bool OnTouchMoved(Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo){}
+ virtual bool OnTouchCanceled(Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo){}
+ virtual bool OnPreviewTouchPressed(Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
+ virtual bool OnPreviewTouchReleased(Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo){}
+ virtual bool OnPreviewTouchMoved(Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
private:
void CreateAppWidgetView(const Tizen::Base::String& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& userInfo);
Tizen::Ui::Controls::ContextMenu* __pContextMenu;
Tizen::Base::Collection::IList* __pSizeInfoList;
static const int ID_FOOTER_ITEM1 = 1001;
+ static const int ID_FOOTER_BUTTON1 = 1002;
+ int __prevX;
+ int __prevY;
+ int __FooterItemIndex;
+ bool __isMoveMode;
+ Tizen::Ui::Controls::FooterItem* __pFooterItem;
}; // ViewForm
#endif // _VIEW_FORM_H_
: __pAppWidgetView(null)
, __pContextMenu(null)
, __pSizeInfoList(null)
+ , __prevX(0)
+ , __prevY(0)
+ , __FooterItemIndex(1)
+ , __isMoveMode(false)
+ , __pFooterItem(null)
{
}
SetFormBackEventListener(this);
Footer* pFooter = GetFooter();
pFooter->AddActionEventListener(*this);
+ SetPropagatedTouchEventListener(this);
+
+ __pFooterItem = new FooterItem();
+ __pFooterItem->Construct(ID_FOOTER_BUTTON1);
+ __pFooterItem->SetText(L"Move");
+ pFooter->AddItem(*__pFooterItem);
return r;
}
ViewForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
{
AppLog("(%d)", actionId);
-
+ if(actionId == ID_FOOTER_BUTTON1)
+ {
+ Footer* pFooter = GetFooter();
+ String str = L"";
+ if (pFooter && __pFooterItem)
+ {
+ pFooter->RemoveItemAt(__FooterItemIndex);
+ }
+ if (__isMoveMode == false)
+ {
+ str = L"Done";
+ __isMoveMode = true;
+ }
+ else
+ {
+ str = L"Move";
+ __isMoveMode = false;
+ }
+ __pFooterItem = new FooterItem();
+ __pFooterItem->Construct(ID_FOOTER_BUTTON1);
+ __pFooterItem->SetText(str);
+ pFooter->AddItem(*__pFooterItem);
+ Invalidate(true);
+ return;
+ }
if (actionId == ID_FOOTER_ITEM1)
{
if (__pContextMenu && (__pContextMenu->GetItemCount() > 0))
if (__pAppWidgetView)
{
- __pAppWidgetView->SetSize(pSizeInfo->GetSize());
+ FloatDimension dim = pSizeInfo->GetSize();
+ Rectangle Rect = __pAppWidgetView->GetBounds();
+ Rectangle ClientRect = GetClientAreaBounds();
+ int newX = Rect.x;
+ int newY = Rect.y;
+ if(Rect.x + dim.width > ClientRect.width)
+ {
+ newX = ClientRect.width - dim.width;
+ }
+ if(Rect.y + dim.height > ClientRect.height)
+ {
+ newY = ClientRect.height - dim.height;
+ }
+
+ __pAppWidgetView->SetBounds(Rectangle(newX,newY,dim.width,dim.height));
}
}
}
notiMgr.NotifyTextMessage(L"AppWidget provider is removed due to provider error.");
}
+bool
+ViewForm::OnPreviewTouchPressed(Control& source, const TouchEventInfo& touchEventInfo)
+{
+ Point curPos(touchEventInfo.GetCurrentPosition().x,touchEventInfo.GetCurrentPosition().y);
+ if (&source == __pAppWidgetView)
+ {
+ __prevX = curPos.x;
+ __prevY = curPos.y;
+ }
+ return true;
+}
+
+bool
+ViewForm::OnPreviewTouchMoved(Control& source, const TouchEventInfo& touchEventInfo)
+{
+ if (&source == __pAppWidgetView && __isMoveMode == true)
+ {
+ Touch touch;
+ Point curPos(touchEventInfo.GetCurrentPosition().x,touchEventInfo.GetCurrentPosition().y);
+
+ int gapX = curPos.x - __prevX;
+ int gapY = curPos.y - __prevY;
+
+ Point appWidgetPos = __pAppWidgetView->GetPosition();
+ Rectangle frameRec = __pAppWidgetView->GetBounds();
+ Rectangle clientRect = GetClientAreaBounds();
+
+ int newX = appWidgetPos.x + gapX;
+ int newY = appWidgetPos.y + gapY;
+
+ if(newX + frameRec.width > clientRect.width)
+ {
+ newX = clientRect.width - frameRec.width;
+ }
+ if(newX < 0)
+ {
+ newX = 0;
+ }
+ if (newY + frameRec.height > clientRect.height)
+ {
+ newY = clientRect.height - frameRec.height;
+ }
+ if (newY < 0)
+ {
+ newY = 0;
+ }
+ __pAppWidgetView->SetPosition(newX, newY);
+ __prevX = curPos.x;
+ __prevY = curPos.y;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+
+}