Crazy Eddie's GUI System  0.8.7
DragContainer.h
1 /***********************************************************************
2  created: 14/2/2005
3  author: Paul D Turner
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  ***************************************************************************/
27 #ifndef _CEGUIDragContainer_h_
28 #define _CEGUIDragContainer_h_
29 
30 #include "../Window.h"
31 #include "../WindowFactory.h"
32 
33 #if defined(_MSC_VER)
34 # pragma warning(push)
35 # pragma warning(disable : 4251)
36 #endif
37 
38 // Start of CEGUI namespace section
39 namespace CEGUI
40 {
45  class CEGUIEXPORT DragContainer : public Window
46  {
47  public:
48  /*************************************************************************
49  Constants
50  *************************************************************************/
51  static const String WidgetTypeName;
52  static const String EventNamespace;
53 
58  static const String EventDragStarted;
64  static const String EventDragEnded;
102 
103  /*************************************************************************
104  Object Construction and Destruction
105  *************************************************************************/
110  DragContainer(const String& type, const String& name);
111 
116  virtual ~DragContainer(void);
117 
118  /*************************************************************************
119  Public Interface to DragContainer
120  *************************************************************************/
129  bool isDraggingEnabled(void) const;
130 
142  void setDraggingEnabled(bool setting);
143 
152  bool isBeingDragged(void) const;
153 
165  float getPixelDragThreshold(void) const;
166 
181  void setPixelDragThreshold(float pixels);
182 
191  float getDragAlpha(void) const;
192 
208  void setDragAlpha(float alpha);
209 
218  const Image* getDragCursorImage(void) const;
219 
234  void setDragCursorImage(const Image* image);
235 
252  void setDragCursorImage(const String& name);
253 
266 
275  bool isStickyModeEnabled() const;
276 
285  void setStickyModeEnabled(bool setting);
286 
303  bool pickUp(const bool force_sticky = false);
304 
318  void setFixedDragOffset(const UVector2& offset);
319 
333  const UVector2& getFixedDragOffset() const;
334 
345  void setUsingFixedDragOffset(const bool enable);
346 
358 
359  // Window class overrides.
361 
362  protected:
363  /*************************************************************************
364  Protected Implementation Methods
365  *************************************************************************/
378  bool isDraggingThresholdExceeded(const Vector2f& local_mouse);
379 
387  void initialiseDragging(void);
388 
399  void doDragging(const Vector2f& local_mouse);
400 
405  void updateActiveMouseCursor(void) const;
406 
407  /*************************************************************************
408  Overrides of methods in Window
409  *************************************************************************/
410 
411  /*************************************************************************
412  Overrides for Event handler methods
413  *************************************************************************/
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(ElementEventArgs& e);
421 
422  /*************************************************************************
423  New Event handler methods
424  *************************************************************************/
435  virtual void onDragStarted(WindowEventArgs& e);
436 
447  virtual void onDragEnded(WindowEventArgs& e);
448 
460 
470 
480 
490 
500 
517 
518  /*************************************************************************
519  Data
520  *************************************************************************/
523  bool d_dragging;
527  float d_dragAlpha;
532  bool d_dropflag;
533  bool d_stickyMode;
541 
542  private:
543  /*************************************************************************
544  Implementation methods
545  *************************************************************************/
553  void addDragContainerProperties(void);
554  };
555 
556 } // End of CEGUI namespace section
557 
558 
559 #if defined(_MSC_VER)
560 # pragma warning(pop)
561 #endif
562 
563 #endif // end of guard _CEGUIDragContainer_h_
CEGUI::DragContainer::d_pickedUp
bool d_pickedUp
true after been picked-up / dragged via sticky mode
Definition: DragContainer.h:536
CEGUI::DragContainer::d_dragPoint
UVector2 d_dragPoint
point we are being dragged at.
Definition: DragContainer.h:524
CEGUI::DragContainer::EventDragPositionChanged
static const String EventDragPositionChanged
Definition: DragContainer.h:70
CEGUI::DragContainer::EventDragAlphaChanged
static const String EventDragAlphaChanged
Definition: DragContainer.h:82
CEGUI::DragContainer::d_dragging
bool d_dragging
true when being dragged.
Definition: DragContainer.h:523
CEGUI::DragContainer::d_dropflag
bool d_dropflag
Definition: DragContainer.h:532
CEGUI::DragContainer
Generic drag & drop enabled window class.
Definition: DragContainer.h:46
CEGUI::DragContainer::getDragCursorImage
const Image * getDragCursorImage(void) const
Return the Image currently set to be used for the mouse cursor when a drag operation is in progress.
CEGUI::DragContainer::setDragCursorImage
void setDragCursorImage(const Image *image)
Set the Image to be used for the mouse cursor when a drag operation is in progress.
CEGUI::DragContainer::setUsingFixedDragOffset
void setUsingFixedDragOffset(const bool enable)
Set whether the fixed dragging offset - as set with the setFixedDragOffset - function will be used,...
CEGUI::DragContainer::getRenderingContext_impl
void getRenderingContext_impl(RenderingContext &ctx) const
implementation of the default getRenderingContext logic.
CEGUI::DragContainer::updateActiveMouseCursor
void updateActiveMouseCursor(void) const
Method to update mouse cursor image.
CEGUI::DragContainer::setFixedDragOffset
void setFixedDragOffset(const UVector2 &offset)
Set the fixed mouse cursor dragging offset to be used for this DragContainer.
CEGUI::DragContainer::onDragMouseCursorChanged
virtual void onDragMouseCursorChanged(WindowEventArgs &e)
Method called when the mouse cursor to use when dragging is changed.
CEGUI::DragContainer::d_usingFixedDragOffset
bool d_usingFixedDragOffset
true if fixed mouse offset is used for dragging position.
Definition: DragContainer.h:538
CEGUI::DragContainer::d_storedAlpha
float d_storedAlpha
Alpha value to re-set when dragging ends.
Definition: DragContainer.h:528
CEGUI::DragContainer::onAlphaChanged
virtual void onAlphaChanged(WindowEventArgs &e)
Handler called when the window's alpha blend value is changed.
CEGUI::DragContainer::doDragging
void doDragging(const Vector2f &local_mouse)
Update state for window dragging.
CEGUI::ElementEventArgs
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: Element.h:211
CEGUI::RenderingContext
struct that holds some context relating to a RenderingSurface object.
Definition: RenderingContext.h:41
CEGUI::DragContainer::initialiseDragging
void initialiseDragging(void)
CEGUI::DragContainer::onDragStarted
virtual void onDragStarted(WindowEventArgs &e)
Method called when dragging commences.
CEGUI::DragContainer::EventNamespace
static const String EventNamespace
Namespace for global events.
Definition: DragContainer.h:52
CEGUI::DragContainer::onClippingChanged
virtual void onClippingChanged(WindowEventArgs &e)
Handler called when the window's setting for being clipped by it's parent is changed.
CEGUI::DragContainer::DragContainer
DragContainer(const String &type, const String &name)
Constructor for DragContainer objects.
CEGUI::DragContainer::EventDragEnabledChanged
static const String EventDragEnabledChanged
Definition: DragContainer.h:76
CEGUI::DragContainer::setDraggingEnabled
void setDraggingEnabled(bool setting)
Set whether dragging is currently enabled for this DragContainer.
CEGUI::DragDropEventArgs
EventArgs based class used for certain drag/drop notifications.
Definition: InputEvent.h:342
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::DragContainer::onDragThresholdChanged
virtual void onDragThresholdChanged(WindowEventArgs &e)
Method called when the movement threshold required to trigger dragging is changed.
CEGUI::MouseEventArgs
EventArgs based class that is used for objects passed to input event handlers concerning mouse input.
Definition: InputEvent.h:281
CEGUI::DragContainer::isUsingFixedDragOffset
bool isUsingFixedDragOffset() const
Return whether the fixed dragging offset - as set with the setFixedDragOffset function - will be used...
CEGUI::DragContainer::d_leftMouseDown
bool d_leftMouseDown
True when left mouse button is down.
Definition: DragContainer.h:522
CEGUI::DragContainer::isDraggingThresholdExceeded
bool isDraggingThresholdExceeded(const Vector2f &local_mouse)
Return whether the required minimum movement threshold before initiating dragging has been exceeded.
CEGUI::DragContainer::getFixedDragOffset
const UVector2 & getFixedDragOffset() const
Return the fixed mouse cursor dragging offset to be used for this DragContainer.
CEGUI::Vector2< UDim >
CEGUI::WindowEventArgs
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: InputEvent.h:252
CEGUI::DragContainer::d_storedClipState
bool d_storedClipState
Parent clip state to re-set.
Definition: DragContainer.h:529
CEGUI::DragContainer::EventDragStarted
static const String EventDragStarted
Definition: DragContainer.h:58
CEGUI::DragContainer::onCaptureLost
virtual void onCaptureLost(WindowEventArgs &e)
Handler called when this window loses capture of mouse inputs.
CEGUI::DragContainer::setPixelDragThreshold
void setPixelDragThreshold(float pixels)
Set the current drag threshold in pixels.
CEGUI::DragContainer::WidgetTypeName
static const String WidgetTypeName
Type name for DragContainer.
Definition: DragContainer.h:51
CEGUI::DragContainer::onDragDropTargetChanged
virtual void onDragDropTargetChanged(DragDropEventArgs &e)
Method called when the current drop target of this DragContainer changes.
CEGUI::DragContainer::EventDragThresholdChanged
static const String EventDragThresholdChanged
Definition: DragContainer.h:94
CEGUI::DragContainer::pickUp
bool pickUp(const bool force_sticky=false)
Immediately pick up the DragContainer and optionally set the sticky mode in order to allow this to ha...
CEGUI::DragContainer::d_dragThreshold
float d_dragThreshold
Pixels mouse must move before dragging commences.
Definition: DragContainer.h:526
CEGUI::DragContainer::onMouseMove
virtual void onMouseMove(MouseEventArgs &e)
Handler called when the mouse cursor has been moved within this window's area.
CEGUI::DragContainer::getDragAlpha
float getDragAlpha(void) const
Return the alpha value that will be set on the DragContainer while a drag operation is in progress.
CEGUI::DragContainer::d_dragCursorImage
const Image * d_dragCursorImage
Image to use for mouse cursor when dragging.
Definition: DragContainer.h:531
CEGUI::DragContainer::isBeingDragged
bool isBeingDragged(void) const
Return whether the DragContainer is currently being dragged.
CEGUI::DragContainer::setStickyModeEnabled
void setStickyModeEnabled(bool setting)
Enable or disable sticky mode.
CEGUI::DragContainer::d_startPosition
UVector2 d_startPosition
position prior to dragging.
Definition: DragContainer.h:525
CEGUI::DragContainer::onDragEnded
virtual void onDragEnded(WindowEventArgs &e)
Method called when dragging ends.
CEGUI::DragContainer::getCurrentDropTarget
Window * getCurrentDropTarget(void) const
Return the Window object that is the current drop target for the DragContainer.
CEGUI::DragContainer::getPixelDragThreshold
float getPixelDragThreshold(void) const
Return the current drag threshold in pixels.
CEGUI::DragContainer::onMoved
virtual void onMoved(ElementEventArgs &e)
Handler called when the window's position changes.
CEGUI::DragContainer::d_dragAlpha
float d_dragAlpha
Alpha value to set when dragging.
Definition: DragContainer.h:527
CEGUI::Window
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:151
CEGUI::DragContainer::onDragAlphaChanged
virtual void onDragAlphaChanged(WindowEventArgs &e)
Method called when the alpha value to use when dragging is changed.
CEGUI::DragContainer::EventDragDropTargetChanged
static const String EventDragDropTargetChanged
Definition: DragContainer.h:101
CEGUI::DragContainer::onMouseButtonUp
virtual void onMouseButtonUp(MouseEventArgs &e)
Handler called when a mouse button has been released within this window's area.
CEGUI::DragContainer::onMouseButtonDown
virtual void onMouseButtonDown(MouseEventArgs &e)
Handler called when a mouse button has been depressed within this window's area.
CEGUI::DragContainer::d_draggingEnabled
bool d_draggingEnabled
True when dragging is enabled.
Definition: DragContainer.h:521
CEGUI::String
String class used within the GUI system.
Definition: String.h:64
CEGUI::DragContainer::isStickyModeEnabled
bool isStickyModeEnabled() const
Return whether sticky mode is enable or disabled.
CEGUI::DragContainer::setDragAlpha
void setDragAlpha(float alpha)
Set the alpha value to be set on the DragContainer when a drag operation is in progress.
CEGUI::DragContainer::EventDragEnded
static const String EventDragEnded
Definition: DragContainer.h:64
CEGUI::Image
Interface for Image.
Definition: Image.h:161
CEGUI::DragContainer::EventDragMouseCursorChanged
static const String EventDragMouseCursorChanged
Definition: DragContainer.h:88
CEGUI::DragContainer::d_dropTarget
Window * d_dropTarget
Target window for possible drop operation.
Definition: DragContainer.h:530
CEGUI::DragContainer::d_fixedDragOffset
UVector2 d_fixedDragOffset
current fixed mouse offset value.
Definition: DragContainer.h:540
CEGUI::DragContainer::onDragPositionChanged
virtual void onDragPositionChanged(WindowEventArgs &e)
Method called when the dragged object position is changed.
CEGUI::DragContainer::~DragContainer
virtual ~DragContainer(void)
Destructor for DragContainer objects.
CEGUI::DragContainer::isDraggingEnabled
bool isDraggingEnabled(void) const
Return whether dragging is currently enabled for this DragContainer.
CEGUI::DragContainer::onDragEnabledChanged
virtual void onDragEnabledChanged(WindowEventArgs &e)
Method called when the dragging state is enabled or disabled.