Crazy Eddies GUI System  0.7.1
CEGUIDragContainer.h
1 /***********************************************************************
2  filename: CEGUIDragContainer.h
3  created: 14/2/2005
4  author: Paul D Turner
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  ***************************************************************************/
28 #ifndef _CEGUIDragContainer_h_
29 #define _CEGUIDragContainer_h_
30 
31 #include "../CEGUIWindow.h"
32 #include "../CEGUIWindowFactory.h"
33 #include "CEGUIDragContainerProperties.h"
34 
35 
36 #if defined(_MSC_VER)
37 # pragma warning(push)
38 # pragma warning(disable : 4251)
39 #endif
40 
41 // Start of CEGUI namespace section
42 namespace CEGUI
43 {
48  class CEGUIEXPORT DragContainer : public Window
49  {
50  public:
51  /*************************************************************************
52  Constants
53  *************************************************************************/
54  static const String WidgetTypeName;
55  static const String EventNamespace;
56  static const String EventDragStarted;
57  static const String EventDragEnded;
64 
65  /*************************************************************************
66  Object Construction and Destruction
67  *************************************************************************/
72  DragContainer(const String& type, const String& name);
73 
78  virtual ~DragContainer(void);
79 
80  /*************************************************************************
81  Public Interface to DragContainer
82  *************************************************************************/
91  bool isDraggingEnabled(void) const;
92 
104  void setDraggingEnabled(bool setting);
105 
114  bool isBeingDragged(void) const;
115 
127  float getPixelDragThreshold(void) const;
128 
143  void setPixelDragThreshold(float pixels);
144 
153  float getDragAlpha(void) const;
154 
170  void setDragAlpha(float alpha);
171 
180  const Image* getDragCursorImage(void) const;
181 
196  void setDragCursorImage(const Image* image);
197 
212  void setDragCursorImage(MouseCursorImage image);
213 
234  void setDragCursorImage(const String& imageset, const String& image);
235 
247  Window* getCurrentDropTarget(void) const;
248 
257  bool isStickyModeEnabled() const;
258 
267  void setStickyModeEnabled(bool setting);
268 
285  bool pickUp(const bool force_sticky = false);
286 
300  void setFixedDragOffset(const UVector2& offset);
301 
315  const UVector2& getFixedDragOffset() const;
316 
327  void setUsingFixedDragOffset(const bool enable);
328 
339  bool isUsingFixedDragOffset() const;
340 
341  // Window class overrides.
342  void getRenderingContext_impl(RenderingContext& ctx) const;
343 
344  protected:
345  /*************************************************************************
346  Protected Implementation Methods
347  *************************************************************************/
360  bool isDraggingThresholdExceeded(const Point& local_mouse);
361 
369  void initialiseDragging(void);
370 
381  void doDragging(const Point& local_mouse);
382 
387  void updateActiveMouseCursor(void) const;
388 
389 
400  virtual bool testClassName_impl(const String& class_name) const
401  {
402  if (class_name=="DragContainer") return true;
403  return Window::testClassName_impl(class_name);
404  }
405 
406 
407  /*************************************************************************
408  Overrides of methods in Window
409  *************************************************************************/
410 
411  /*************************************************************************
412  Overrides for Event handler methods
413  *************************************************************************/
414  virtual void onMouseButtonDown(MouseEventArgs& e);
415  virtual void onMouseButtonUp(MouseEventArgs& e);
416  virtual void onMouseMove(MouseEventArgs& e);
417  virtual void onCaptureLost(WindowEventArgs& e);
418  virtual void onAlphaChanged(WindowEventArgs& e);
419  virtual void onClippingChanged(WindowEventArgs& e);/*Window::drawSelf(z);*/
420  virtual void onMoved(WindowEventArgs& e);
421 
422  /*************************************************************************
423  New Event handler methods
424  *************************************************************************/
435  virtual void onDragStarted(WindowEventArgs& e);
436 
447  virtual void onDragEnded(WindowEventArgs& e);
448 
459  virtual void onDragPositionChanged(WindowEventArgs& e);
460 
469  virtual void onDragEnabledChanged(WindowEventArgs& e);
470 
479  virtual void onDragAlphaChanged(WindowEventArgs& e);
480 
489  virtual void onDragMouseCursorChanged(WindowEventArgs& e);
490 
499  virtual void onDragThresholdChanged(WindowEventArgs& e);
500 
516  virtual void onDragDropTargetChanged(DragDropEventArgs& e);
517 
518  /*************************************************************************
519  Data
520  *************************************************************************/
523  bool d_dragging;
527  float d_dragAlpha;
532  bool d_dropflag;
533 
541 
542  private:
543  /*************************************************************************
544  Static properties for the Spinner widget
545  *************************************************************************/
546  static DragContainerProperties::DragAlpha d_dragAlphaProperty;
547  static DragContainerProperties::DragCursorImage d_dragCursorImageProperty;
548  static DragContainerProperties::DraggingEnabled d_dragEnabledProperty;
549  static DragContainerProperties::DragThreshold d_dragThresholdProperty;
550  static DragContainerProperties::StickyMode d_stickyModeProperty;
551  static DragContainerProperties::FixedDragOffset d_fixedDragOffsetProperty;
552  static DragContainerProperties::UseFixedDragOffset d_useFixedDragOffsetProperty;
553 
554  /*************************************************************************
555  Implementation methods
556  *************************************************************************/
564  void addDragContainerProperties(void);
565  };
566 
567 } // End of CEGUI namespace section
568 
569 
570 #if defined(_MSC_VER)
571 # pragma warning(pop)
572 #endif
573 
574 #endif // end of guard _CEGUIDragContainer_h_