Crazy Eddies GUI System  0.7.2
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 
61  static const String EventDragStarted;
67  static const String EventDragEnded;
105 
106  /*************************************************************************
107  Object Construction and Destruction
108  *************************************************************************/
113  DragContainer(const String& type, const String& name);
114 
119  virtual ~DragContainer(void);
120 
121  /*************************************************************************
122  Public Interface to DragContainer
123  *************************************************************************/
132  bool isDraggingEnabled(void) const;
133 
145  void setDraggingEnabled(bool setting);
146 
155  bool isBeingDragged(void) const;
156 
168  float getPixelDragThreshold(void) const;
169 
184  void setPixelDragThreshold(float pixels);
185 
194  float getDragAlpha(void) const;
195 
211  void setDragAlpha(float alpha);
212 
221  const Image* getDragCursorImage(void) const;
222 
237  void setDragCursorImage(const Image* image);
238 
253  void setDragCursorImage(MouseCursorImage image);
254 
275  void setDragCursorImage(const String& imageset, const String& image);
276 
288  Window* getCurrentDropTarget(void) const;
289 
298  bool isStickyModeEnabled() const;
299 
308  void setStickyModeEnabled(bool setting);
309 
326  bool pickUp(const bool force_sticky = false);
327 
341  void setFixedDragOffset(const UVector2& offset);
342 
356  const UVector2& getFixedDragOffset() const;
357 
368  void setUsingFixedDragOffset(const bool enable);
369 
380  bool isUsingFixedDragOffset() const;
381 
382  // Window class overrides.
383  void getRenderingContext_impl(RenderingContext& ctx) const;
384 
385  protected:
386  /*************************************************************************
387  Protected Implementation Methods
388  *************************************************************************/
401  bool isDraggingThresholdExceeded(const Point& local_mouse);
402 
410  void initialiseDragging(void);
411 
422  void doDragging(const Point& local_mouse);
423 
428  void updateActiveMouseCursor(void) const;
429 
430 
441  virtual bool testClassName_impl(const String& class_name) const
442  {
443  if (class_name=="DragContainer") return true;
444  return Window::testClassName_impl(class_name);
445  }
446 
447 
448  /*************************************************************************
449  Overrides of methods in Window
450  *************************************************************************/
451 
452  /*************************************************************************
453  Overrides for Event handler methods
454  *************************************************************************/
455  virtual void onMouseButtonDown(MouseEventArgs& e);
456  virtual void onMouseButtonUp(MouseEventArgs& e);
457  virtual void onMouseMove(MouseEventArgs& e);
458  virtual void onCaptureLost(WindowEventArgs& e);
459  virtual void onAlphaChanged(WindowEventArgs& e);
460  virtual void onClippingChanged(WindowEventArgs& e);/*Window::drawSelf(z);*/
461  virtual void onMoved(WindowEventArgs& e);
462 
463  /*************************************************************************
464  New Event handler methods
465  *************************************************************************/
476  virtual void onDragStarted(WindowEventArgs& e);
477 
488  virtual void onDragEnded(WindowEventArgs& e);
489 
500  virtual void onDragPositionChanged(WindowEventArgs& e);
501 
510  virtual void onDragEnabledChanged(WindowEventArgs& e);
511 
520  virtual void onDragAlphaChanged(WindowEventArgs& e);
521 
530  virtual void onDragMouseCursorChanged(WindowEventArgs& e);
531 
540  virtual void onDragThresholdChanged(WindowEventArgs& e);
541 
557  virtual void onDragDropTargetChanged(DragDropEventArgs& e);
558 
559  /*************************************************************************
560  Data
561  *************************************************************************/
564  bool d_dragging;
568  float d_dragAlpha;
573  bool d_dropflag;
574 
582 
583  private:
584  /*************************************************************************
585  Static properties for the Spinner widget
586  *************************************************************************/
587  static DragContainerProperties::DragAlpha d_dragAlphaProperty;
588  static DragContainerProperties::DragCursorImage d_dragCursorImageProperty;
589  static DragContainerProperties::DraggingEnabled d_dragEnabledProperty;
590  static DragContainerProperties::DragThreshold d_dragThresholdProperty;
591  static DragContainerProperties::StickyMode d_stickyModeProperty;
592  static DragContainerProperties::FixedDragOffset d_fixedDragOffsetProperty;
593  static DragContainerProperties::UseFixedDragOffset d_useFixedDragOffsetProperty;
594 
595  /*************************************************************************
596  Implementation methods
597  *************************************************************************/
605  void addDragContainerProperties(void);
606  };
607 
608 } // End of CEGUI namespace section
609 
610 
611 #if defined(_MSC_VER)
612 # pragma warning(pop)
613 #endif
614 
615 #endif // end of guard _CEGUIDragContainer_h_