My Project
IObjectDrag.h
1 //----------------------------------------------------------------------
2 // Interface: IObjectDrag
3 // Authors: Liu Weili
4 // Date: 2006.4.5
5 // Revised: by LiXizhi 2007.11.4
6 // desc:
7 // This interface is intended to provide a common interface for all objects
8 // which are intended to be dragged in some way.
9 // We don't need to know the actual type of the objects through this interface.
10 //-----------------------------------------------------------------------
11 
12 #pragma once
13 #include <string>
14 namespace ParaEngine
15 {
16  using std::vector;
17  class IObjectDrag;
18  struct CGUIPosition;
19  /*
20  This is a structure for drag-and-drop operation.
21  It stores necessary information for a dragging operation.
22  */
24  IObjectDrag* pSource; //where the drag begin, the dragging object's parent
25  IObjectDrag* pDestination; //where to drop
26  IObjectDrag* pDragging; //the dragging object which moves with the mouse cursor
27 
28  int nEvent; //which event triggers the dragging. If mouse,that is which button is pressed.
29  int startX, startY; // the absolute screen position when the drag start.
30  int nRelativeX,nRelativeY,nRelativeZ;//relative position of the dragging control's top-left point with respect to
31  // this is used to restore an UI object to its original position.
32  CGUIPosition* m_pOldPosition;
33  // if true, the pDragging is only a dragging candidates and is expect to receive all mouse event if the button is down.
34  bool m_bIsCandicateOnly;
35  //the mouse position when it starts dragging.
36  void (*pCleanUp)(); //call back function when dragging is over in order to do clean up jobs
37  //such as deleting the dragging object or change state of other objects.
38  void init();
39 
40  public:
42  void SetOldPosition(const CGUIPosition& vPos);
43 
46 
48  void CleanUpReceivers();
49 
53  void AddReceiver(const char* sName);
54 
56  bool HasReceiver(const char* sName);
57 
59  void SetDraggingCandidate(IObjectDrag* pDragging);
60  void UnsetDraggingCandidate();
61  private:
63  vector <string> m_receiverNames;
64  };
65 
67  {
68  public:
69  IObjectDrag():m_bCandrag(false) {};
70  virtual void SetCandrag(bool bCandrag)=0;
71  virtual bool GetCandrag()const=0;
79  virtual void BeginDrag(int nEvent, int x, int y, int z)=0;
88  virtual void EndDrag(int nEvent, int x, int y, int z)=0;
96  virtual BOOL IsOnObject(int x,int y, int z)=0;
97 
99  virtual void SetPositionI(const CGUIPosition& position){};
100 
104  static STRUCT_DRAG_AND_DROP DraggingObject;
105 
108  static bool CancelDrag(STRUCT_DRAG_AND_DROP* pdrag);
109  protected:
110  bool m_bCandrag;
111  };
112 }
Definition: IObjectDrag.h:23
different physics engine has different winding order.
Definition: EventBinding.h:32
void SetDraggingCandidate(IObjectDrag *pDragging)
a dragging candidate will receive all mouse event if the mouse button keeps pressed.
Definition: IObjectDrag.cpp:107
Definition: IObjectDrag.h:66
void SetOldPosition(const CGUIPosition &vPos)
set old position
Definition: IObjectDrag.cpp:72
CGUIPosition * GetOldPosition()
Get old position.
Definition: IObjectDrag.cpp:79
bool HasReceiver(const char *sName)
whether the current receiver list contains a given name.
Definition: IObjectDrag.cpp:96
void CleanUpReceivers()
we should clean up receivers, when a drag begins.
Definition: IObjectDrag.cpp:85
position of the GUI object
Definition: GUIPosition.h:34
void AddReceiver(const char *sName)
add an receiver to the current receiver list.
Definition: IObjectDrag.cpp:90
virtual void SetPositionI(const CGUIPosition &position)
restore to a given position.
Definition: IObjectDrag.h:99