00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _CEGUIDragContainer_h_
00025 #define _CEGUIDragContainer_h_
00026
00027 #include "CEGUIWindow.h"
00028 #include "CEGUIWindowFactory.h"
00029 #include "elements/CEGUIDragContainerProperties.h"
00030
00031
00032 #if defined(_MSC_VER)
00033 # pragma warning(push)
00034 # pragma warning(disable : 4251)
00035 #endif
00036
00037
00038 namespace CEGUI
00039 {
00044 class CEGUIEXPORT DragContainer : public Window
00045 {
00046 public:
00047
00048
00049
00050 static const String WidgetTypeName;
00051 static const String EventNamespace;
00052 static const String EventDragStarted;
00053 static const String EventDragEnded;
00054 static const String EventDragPositionChanged;
00055 static const String EventDragEnabledChanged;
00056 static const String EventDragAlphaChanged;
00057 static const String EventDragMouseCursorChanged;
00058 static const String EventDragThresholdChanged;
00059 static const String EventDragDropTargetChanged;
00060
00061
00062
00063
00068 DragContainer(const String& type, const String& name);
00069
00074 virtual ~DragContainer(void);
00075
00076
00077
00078
00087 bool isDraggingEnabled(void) const;
00088
00100 void setDraggingEnabled(bool setting);
00101
00110 bool isBeingDragged(void) const;
00111
00123 float getPixelDragThreshold(void) const;
00124
00139 void setPixelDragThreshold(float pixels);
00140
00149 float getDragAlpha(void) const;
00150
00166 void setDragAlpha(float alpha);
00167
00176 const Image* getDragCursorImage(void) const;
00177
00192 void setDragCursorImage(const Image* image);
00193
00208 void setDragCursorImage(MouseCursorImage image);
00209
00230 void setDragCursorImage(const String& imageset, const String& image);
00231
00243 Window* getCurrentDropTarget(void) const;
00244
00245 protected:
00246
00247
00248
00256 void addDragContainerEvents(void);
00257
00270 bool isDraggingThresholdExceeded(const Point& local_mouse);
00271
00279 void initialiseDragging(void);
00280
00291 void doDragging(const Point& local_mouse);
00292
00297 void updateActiveMouseCursor(void) const;
00298
00299
00310 virtual bool testClassName_impl(const String& class_name) const
00311 {
00312 if (class_name==(const utf8*)"DragContainer") return true;
00313 return Window::testClassName_impl(class_name);
00314 }
00315
00316
00317
00318
00319
00320 void drawSelf(float z);
00321
00322
00323
00324
00325
00326
00327
00328
00329 virtual void onMouseButtonDown(MouseEventArgs& e);
00330 virtual void onMouseButtonUp(MouseEventArgs& e);
00331 virtual void onMouseMove(MouseEventArgs& e);
00332 virtual void onCaptureLost(WindowEventArgs& e);
00333 virtual void onAlphaChanged(WindowEventArgs& e);
00334 virtual void onClippingChanged(WindowEventArgs& e);
00335
00336
00337
00338
00349 virtual void onDragStarted(WindowEventArgs& e);
00350
00361 virtual void onDragEnded(WindowEventArgs& e);
00362
00373 virtual void onDragPositionChanged(WindowEventArgs& e);
00374
00383 virtual void onDragEnabledChanged(WindowEventArgs& e);
00384
00393 virtual void onDragAlphaChanged(WindowEventArgs& e);
00394
00403 virtual void onDragMouseCursorChanged(WindowEventArgs& e);
00404
00413 virtual void onDragThresholdChanged(WindowEventArgs& e);
00414
00430 virtual void onDragDropTargetChanged(DragDropEventArgs& e);
00431
00432
00433
00434
00435 bool d_draggingEnabled;
00436 bool d_leftMouseDown;
00437 bool d_dragging;
00438 Point d_dragPoint;
00439 Point d_startPosition;
00440 float d_dragThreshold;
00441 float d_dragAlpha;
00442 float d_storedAlpha;
00443 bool d_storedClipState;
00444 Window* d_dropTarget;
00445 const Image* d_dragCursorImage;
00446
00447 private:
00448
00449
00450
00451 static DragContainerProperties::DragAlpha d_dragAlphaProperty;
00452 static DragContainerProperties::DragCursorImage d_dragCursorImageProperty;
00453 static DragContainerProperties::DraggingEnabled d_dragEnabledProperty;
00454 static DragContainerProperties::DragThreshold d_dragThresholdProperty;
00455
00456
00457
00458
00466 void addDragContainerProperties(void);
00467 };
00468
00473 class DragContainerFactory : public WindowFactory
00474 {
00475 public:
00476 DragContainerFactory(void) : WindowFactory(DragContainer::WidgetTypeName) { }
00477 ~DragContainerFactory(void){}
00478
00479 Window* createWindow(const String& name)
00480 {
00481 DragContainer* wnd = new DragContainer(d_type, name);
00482 return wnd;
00483 }
00484
00485 void destroyWindow(Window* window)
00486 {
00487 if (window->getType() == d_type)
00488 delete window;
00489 }
00490
00491 };
00492
00493
00494 }
00495
00496
00497 #if defined(_MSC_VER)
00498 # pragma warning(pop)
00499 #endif
00500
00501 #endif // end of guard _CEGUIDragContainer_h_