Crazy Eddies GUI System  0.6.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 "elements/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 
249  protected:
250  /*************************************************************************
251  Protected Implementation Methods
252  *************************************************************************/
265  bool isDraggingThresholdExceeded(const Point& local_mouse);
266 
274  void initialiseDragging(void);
275 
286  void doDragging(const Point& local_mouse);
287 
292  void updateActiveMouseCursor(void) const;
293 
294 
305  virtual bool testClassName_impl(const String& class_name) const
306  {
307  if (class_name=="DragContainer") return true;
308  return Window::testClassName_impl(class_name);
309  }
310 
311 
312  /*************************************************************************
313  Overrides of methods in Window
314  *************************************************************************/
315 
316  /*************************************************************************
317  Overrides for Event handler methods
318  *************************************************************************/
319  virtual void onMouseButtonDown(MouseEventArgs& e);
320  virtual void onMouseButtonUp(MouseEventArgs& e);
321  virtual void onMouseMove(MouseEventArgs& e);
322  virtual void onCaptureLost(WindowEventArgs& e);
323  virtual void onAlphaChanged(WindowEventArgs& e);
324  virtual void onClippingChanged(WindowEventArgs& e);/*Window::drawSelf(z);*/
325  virtual void onMoved(WindowEventArgs& e);
326 
327  /*************************************************************************
328  New Event handler methods
329  *************************************************************************/
340  virtual void onDragStarted(WindowEventArgs& e);
341 
352  virtual void onDragEnded(WindowEventArgs& e);
353 
364  virtual void onDragPositionChanged(WindowEventArgs& e);
365 
374  virtual void onDragEnabledChanged(WindowEventArgs& e);
375 
384  virtual void onDragAlphaChanged(WindowEventArgs& e);
385 
394  virtual void onDragMouseCursorChanged(WindowEventArgs& e);
395 
404  virtual void onDragThresholdChanged(WindowEventArgs& e);
405 
421  virtual void onDragDropTargetChanged(DragDropEventArgs& e);
422 
423  /*************************************************************************
424  Data
425  *************************************************************************/
428  bool d_dragging;
432  float d_dragAlpha;
437  bool d_dropflag;
438 
439  private:
440  /*************************************************************************
441  Static properties for the Spinner widget
442  *************************************************************************/
443  static DragContainerProperties::DragAlpha d_dragAlphaProperty;
444  static DragContainerProperties::DragCursorImage d_dragCursorImageProperty;
445  static DragContainerProperties::DraggingEnabled d_dragEnabledProperty;
446  static DragContainerProperties::DragThreshold d_dragThresholdProperty;
447 
448  /*************************************************************************
449  Implementation methods
450  *************************************************************************/
458  void addDragContainerProperties(void);
459  };
460 
461 } // End of CEGUI namespace section
462 
463 
464 #if defined(_MSC_VER)
465 # pragma warning(pop)
466 #endif
467 
468 #endif // end of guard _CEGUIDragContainer_h_