00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef PG_WIDGETDND_H
00030 #define PG_WIDGETDND_H
00031
00032 #include "pgwidget.h"
00033
00044 class DECLSPEC PG_WidgetDnD : public PG_Widget {
00045 public:
00046
00049 PG_WidgetDnD(PG_Widget* parent, int dndID, const PG_Rect& r);
00050
00053 PG_WidgetDnD(PG_Widget* parent, int dndID, const PG_Rect& r, bool bCreateSurface);
00054
00057 ~PG_WidgetDnD();
00058
00060 bool GetDrop();
00061
00063 bool GetDrag();
00064
00066 void RemoveObjectDnD(PG_WidgetDnD* obj);
00067
00069 void SetDrop(bool drop);
00070
00072 void SetDrag(bool drag);
00073
00075 void updateDragArea(PG_Point pt, SDL_Surface* image);
00076
00078 void drawDragArea(PG_Point pt, SDL_Surface* image);
00079
00080 protected:
00081
00083 PG_WidgetDnD* FindDropTarget(PG_Point pt);
00084
00086 bool eventMouseButtonDown(const SDL_MouseButtonEvent* button);
00087
00089 bool eventMouseMotion(const SDL_MouseMotionEvent* motion);
00090
00092 bool eventMouseButtonUp(const SDL_MouseButtonEvent* button);
00093
00095 virtual bool AcceptDrop(PG_WidgetDnD* source, int dndID);
00096
00098 virtual bool eventDragStart();
00099
00101 virtual bool eventDragDrop(PG_WidgetDnD* source, int dndID);
00102
00104 virtual bool eventDragCancel();
00105
00107 virtual SDL_Surface* eventQueryDragImage();
00108
00110 virtual SDL_Surface* eventQueryDropImage(SDL_Surface* dragimage = NULL);
00111
00112 PG_WidgetDnD* dnd_next;
00113 static PG_WidgetDnD* dnd_objectlist;
00114
00115 private:
00116
00118 DLLLOCAL void cacheDragArea(PG_Point p);
00119
00121 DLLLOCAL void restoreDragArea(PG_Point p);
00122
00124 DLLLOCAL void CheckCursorPos(int& x, int& y);
00125
00127 DLLLOCAL void slideDragImage(PG_Point start, PG_Point end, int steps, SDL_Surface* image);
00128
00129 bool CanDrag;
00130
00131 bool CanDrop;
00132
00133 bool Draging;
00134
00135 PG_Point dragPointStart;
00136
00137 PG_Point dragPointOld;
00138
00139 PG_Point dragPointCurrent;
00140
00141 SDL_Surface* dragimage;
00142
00143 SDL_Surface* dragimagecache;
00144
00145 private:
00146
00147 PG_WidgetDnD(const PG_WidgetDnD&);
00148 PG_WidgetDnD& operator=(const PG_WidgetDnD&);
00149
00150 };
00151
00152 #endif // PG_WIDGETDND_H