CEGUIDragContainer.h

00001 /***********************************************************************
00002         filename:       CEGUIDragContainer.h
00003         created:        14/2/2005
00004         author:         Paul D Turner
00005 *************************************************************************/
00006 /***************************************************************************
00007  *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
00008  *
00009  *   Permission is hereby granted, free of charge, to any person obtaining
00010  *   a copy of this software and associated documentation files (the
00011  *   "Software"), to deal in the Software without restriction, including
00012  *   without limitation the rights to use, copy, modify, merge, publish,
00013  *   distribute, sublicense, and/or sell copies of the Software, and to
00014  *   permit persons to whom the Software is furnished to do so, subject to
00015  *   the following conditions:
00016  *
00017  *   The above copyright notice and this permission notice shall be
00018  *   included in all copies or substantial portions of the Software.
00019  *
00020  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00021  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00022  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00023  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00024  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00025  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00026  *   OTHER DEALINGS IN THE SOFTWARE.
00027  ***************************************************************************/
00028 #ifndef _CEGUIDragContainer_h_
00029 #define _CEGUIDragContainer_h_
00030 
00031 #include "CEGUIWindow.h"
00032 #include "CEGUIWindowFactory.h"
00033 #include "elements/CEGUIDragContainerProperties.h"
00034 
00035 
00036 #if defined(_MSC_VER)
00037 #       pragma warning(push)
00038 #       pragma warning(disable : 4251)
00039 #endif
00040 
00041 // Start of CEGUI namespace section
00042 namespace CEGUI
00043 {
00048     class CEGUIEXPORT DragContainer : public Window
00049     {
00050     public:
00051         /*************************************************************************
00052             Constants
00053         *************************************************************************/
00054         static const String WidgetTypeName;     
00055         static const String EventNamespace;     
00056         static const String EventDragStarted;   
00057         static const String EventDragEnded;     
00058         static const String EventDragPositionChanged;   
00059         static const String EventDragEnabledChanged;    
00060         static const String EventDragAlphaChanged;      
00061         static const String EventDragMouseCursorChanged;
00062         static const String EventDragThresholdChanged;  
00063         static const String EventDragDropTargetChanged; 
00064 
00065         /*************************************************************************
00066             Object Construction and Destruction
00067         *************************************************************************/
00072         DragContainer(const String& type, const String& name);
00073 
00078         virtual ~DragContainer(void);
00079 
00080         /*************************************************************************
00081                 Public Interface to DragContainer
00082         *************************************************************************/
00091         bool isDraggingEnabled(void) const;
00092 
00104         void setDraggingEnabled(bool setting);
00105 
00114         bool isBeingDragged(void) const;
00115 
00127         float getPixelDragThreshold(void) const;
00128 
00143         void setPixelDragThreshold(float pixels);
00144 
00153         float getDragAlpha(void) const;
00154 
00170         void setDragAlpha(float alpha);
00171 
00180         const Image* getDragCursorImage(void) const;
00181 
00196         void setDragCursorImage(const Image* image);
00197 
00212         void setDragCursorImage(MouseCursorImage image);
00213 
00234         void setDragCursorImage(const String& imageset, const String& image);
00235 
00247         Window* getCurrentDropTarget(void) const;
00248 
00249     protected:
00250         /*************************************************************************
00251                 Protected Implementation Methods
00252         *************************************************************************/
00265         bool isDraggingThresholdExceeded(const Point& local_mouse);
00266 
00274         void initialiseDragging(void);
00275 
00286         void doDragging(const Point& local_mouse);
00287 
00292         void updateActiveMouseCursor(void) const;
00293 
00294 
00305                 virtual bool    testClassName_impl(const String& class_name) const
00306                 {
00307                         if (class_name=="DragContainer")        return true;
00308                         return Window::testClassName_impl(class_name);
00309                 }
00310 
00311 
00312         /*************************************************************************
00313                 Overrides of methods in Window
00314         *************************************************************************/
00315 
00316         /*************************************************************************
00317                 Overrides for Event handler methods
00318         *************************************************************************/
00319         virtual void onMouseButtonDown(MouseEventArgs& e);
00320         virtual void onMouseButtonUp(MouseEventArgs& e);
00321         virtual void onMouseMove(MouseEventArgs& e);
00322         virtual void onCaptureLost(WindowEventArgs& e);
00323         virtual void onAlphaChanged(WindowEventArgs& e);
00324         virtual void onClippingChanged(WindowEventArgs& e);/*Window::drawSelf(z);*/
00325         virtual void onMoved(WindowEventArgs& e);
00326 
00327         /*************************************************************************
00328                 New Event handler methods
00329         *************************************************************************/
00340         virtual void onDragStarted(WindowEventArgs& e);
00341 
00352         virtual void onDragEnded(WindowEventArgs& e);
00353 
00364         virtual void onDragPositionChanged(WindowEventArgs& e);
00365 
00374         virtual void onDragEnabledChanged(WindowEventArgs& e);
00375 
00384         virtual void onDragAlphaChanged(WindowEventArgs& e);
00385 
00394         virtual void onDragMouseCursorChanged(WindowEventArgs& e);
00395 
00404         virtual void onDragThresholdChanged(WindowEventArgs& e);
00405 
00421         virtual void onDragDropTargetChanged(DragDropEventArgs& e);
00422 
00423         /*************************************************************************
00424                 Data
00425         *************************************************************************/
00426         bool    d_draggingEnabled;  
00427         bool    d_leftMouseDown;    
00428         bool    d_dragging;         
00429         UVector2 d_dragPoint;       
00430         UVector2 d_startPosition;   
00431         float   d_dragThreshold;    
00432         float   d_dragAlpha;        
00433         float   d_storedAlpha;      
00434         bool    d_storedClipState;  
00435         Window* d_dropTarget;       
00436         const Image* d_dragCursorImage; 
00437         bool d_dropflag;            
00438 
00439     private:
00440         /*************************************************************************
00441             Static properties for the Spinner widget
00442         *************************************************************************/
00443         static DragContainerProperties::DragAlpha       d_dragAlphaProperty;
00444         static DragContainerProperties::DragCursorImage d_dragCursorImageProperty;
00445         static DragContainerProperties::DraggingEnabled d_dragEnabledProperty;
00446         static DragContainerProperties::DragThreshold   d_dragThresholdProperty;
00447 
00448         /*************************************************************************
00449                 Implementation methods
00450         *************************************************************************/
00458         void addDragContainerProperties(void);
00459     };
00460 
00461 } // End of  CEGUI namespace section
00462 
00463 
00464 #if defined(_MSC_VER)
00465 #       pragma warning(pop)
00466 #endif
00467 
00468 #endif  // end of guard _CEGUIDragContainer_h_

Generated on Sun Nov 5 14:35:28 2006 for Crazy Eddies GUI System by  doxygen 1.4.7