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 SDLWIDGETDND_H
00030 #define SDLWIDGETDND_H
00031
00032 #ifdef SWIG
00033 %include "swigcommon.h"
00034 %module sdlwidgetdnd
00035 %{
00036 #include "sdlwidgetdnd.h"
00037 %}
00038 #endif
00039
00040 #include "sdlwidget.h"
00041
00052 class DECLSPEC SDLWidgetDnD : public SDLWidget {
00053 public:
00054
00055 SDLWidgetDnD(SDLWidget* parent, int dndID, SDL_Rect& r);
00056 ~SDLWidgetDnD();
00057
00059 bool GetDrop();
00060
00062 bool GetDrag();
00063
00065 void RemoveObjectDnD(SDLWidgetDnD* obj);
00066
00068 void SetDrop(bool drop);
00069
00071 void SetDrag(bool drag);
00072
00074 void updateDragArea(SDL_Point pt, SDL_Surface* image);
00075
00077 void drawDragArea(SDL_Point pt, SDL_Surface* image);
00078
00079 protected:
00080
00082 SDLWidgetDnD* FindDropTarget(SDL_Point pt);
00083
00085 bool eventMouseButtonDown(const SDL_MouseButtonEvent* button);
00086
00088 bool eventMouseMotion(const SDL_MouseMotionEvent* motion);
00089
00091 bool eventMouseButtonUp(const SDL_MouseButtonEvent* button);
00092
00094 virtual bool AcceptDrop(SDLWidgetDnD* source, int dndID);
00095
00097 virtual bool eventDragStart();
00098
00100 virtual bool eventDragDrop(SDLWidgetDnD* source, int dndID);
00101
00103 virtual bool eventDragCancel();
00104
00106 virtual SDL_Surface* eventQueryDragImage();
00107
00109 virtual SDL_Surface* eventQueryDropImage(SDL_Surface* dragimage = NULL);
00110
00111 SDLWidgetDnD* dnd_next;
00112 static SDLWidgetDnD* dnd_objectlist;
00113
00114 private:
00115
00117 void cacheDragArea(SDL_Point p);
00118
00120 void restoreDragArea(SDL_Point p);
00121
00123 void CheckCursorPos(int& x, int& y);
00124
00126 void slideDragImage(SDL_Point start, SDL_Point end, int steps, SDL_Surface* image);
00127
00128 bool CanDrag;
00129 bool CanDrop;
00130 bool Draging;
00131 SDL_Point dragPointStart;
00132 SDL_Point dragPointOld;
00133 SDL_Point dragPointCurrent;
00134 SDL_Surface* dragimage;
00135 SDL_Surface* dragimagecache;
00136
00137 private:
00138 SDLWidgetDnD(const SDLWidgetDnD&);
00139 SDLWidgetDnD& operator=(const SDLWidgetDnD&);
00140 };
00141
00142 #endif // SDLWIDGETDND_H