Crazy Eddies GUI System: CEGUIDragContainer.h Source File

Crazy Eddies GUI System 0.7.6

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

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 "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
    00061         static const String EventDragStarted;
    00067         static const String EventDragEnded;
    00073         static const String EventDragPositionChanged;
    00079         static const String EventDragEnabledChanged;
    00085         static const String EventDragAlphaChanged;
    00091         static const String EventDragMouseCursorChanged;
    00097         static const String EventDragThresholdChanged;
    00104         static const String EventDragDropTargetChanged;
    00105
    00106         /*************************************************************************
    00107             Object Construction and Destruction
    00108         *************************************************************************/
    00113         DragContainer(const String& type, const String& name);
    00114
    00119         virtual ~DragContainer(void);
    00120
    00121         /*************************************************************************
    00122                 Public Interface to DragContainer
    00123         *************************************************************************/
    00132         bool isDraggingEnabled(void) const;
    00133
    00145         void setDraggingEnabled(bool setting);
    00146
    00155         bool isBeingDragged(void) const;
    00156
    00168         float getPixelDragThreshold(void) const;
    00169
    00184         void setPixelDragThreshold(float pixels);
    00185
    00194         float getDragAlpha(void) const;
    00195
    00211         void setDragAlpha(float alpha);
    00212
    00221         const Image* getDragCursorImage(void) const;
    00222
    00237         void setDragCursorImage(const Image* image);
    00238
    00253         void setDragCursorImage(MouseCursorImage image);
    00254
    00275         void setDragCursorImage(const String& imageset, const String& image);
    00276
    00288         Window* getCurrentDropTarget(void) const;
    00289
    00298         bool isStickyModeEnabled() const;
    00299
    00308         void setStickyModeEnabled(bool setting);
    00309
    00326         bool pickUp(const bool force_sticky = false);
    00327
    00341         void setFixedDragOffset(const UVector2& offset);
    00342
    00356         const UVector2& getFixedDragOffset() const;
    00357
    00368         void setUsingFixedDragOffset(const bool enable);
    00369
    00380         bool isUsingFixedDragOffset() const;
    00381
    00382         // Window class overrides.
    00383         void getRenderingContext_impl(RenderingContext& ctx) const;
    00384
    00385     protected:
    00386         /*************************************************************************
    00387                 Protected Implementation Methods
    00388         *************************************************************************/
    00401         bool isDraggingThresholdExceeded(const Point& local_mouse);
    00402
    00410         void initialiseDragging(void);
    00411
    00422         void doDragging(const Point& local_mouse);
    00423
    00428         void updateActiveMouseCursor(void) const;
    00429
    00430
    00441                 virtual bool    testClassName_impl(const String& class_name) const
    00442                 {
    00443                         if (class_name=="DragContainer")        return true;
    00444                         return Window::testClassName_impl(class_name);
    00445                 }
    00446
    00447
    00448         /*************************************************************************
    00449                 Overrides of methods in Window
    00450         *************************************************************************/
    00451
    00452         /*************************************************************************
    00453                 Overrides for Event handler methods
    00454         *************************************************************************/
    00455         virtual void onMouseButtonDown(MouseEventArgs& e);
    00456         virtual void onMouseButtonUp(MouseEventArgs& e);
    00457         virtual void onMouseMove(MouseEventArgs& e);
    00458         virtual void onCaptureLost(WindowEventArgs& e);
    00459         virtual void onAlphaChanged(WindowEventArgs& e);
    00460         virtual void onClippingChanged(WindowEventArgs& e);/*Window::drawSelf(z);*/
    00461         virtual void onMoved(WindowEventArgs& e);
    00462
    00463         /*************************************************************************
    00464                 New Event handler methods
    00465         *************************************************************************/
    00476         virtual void onDragStarted(WindowEventArgs& e);
    00477
    00488         virtual void onDragEnded(WindowEventArgs& e);
    00489
    00500         virtual void onDragPositionChanged(WindowEventArgs& e);
    00501
    00510         virtual void onDragEnabledChanged(WindowEventArgs& e);
    00511
    00520         virtual void onDragAlphaChanged(WindowEventArgs& e);
    00521
    00530         virtual void onDragMouseCursorChanged(WindowEventArgs& e);
    00531
    00540         virtual void onDragThresholdChanged(WindowEventArgs& e);
    00541
    00557         virtual void onDragDropTargetChanged(DragDropEventArgs& e);
    00558
    00559         /*************************************************************************
    00560                 Data
    00561         *************************************************************************/
    00562         bool    d_draggingEnabled;
    00563         bool    d_leftMouseDown;
    00564         bool    d_dragging;
    00565         UVector2 d_dragPoint;
    00566         UVector2 d_startPosition;
    00567         float   d_dragThreshold;
    00568         float   d_dragAlpha;
    00569         float   d_storedAlpha;
    00570         bool    d_storedClipState;
    00571         Window* d_dropTarget;
    00572         const Image* d_dragCursorImage;
    00573         bool d_dropflag;
    00574
    00575         bool d_stickyMode;
    00577         bool d_pickedUp;
    00579         bool d_usingFixedDragOffset;
    00581         UVector2 d_fixedDragOffset;
    00582
    00583     private:
    00584         /*************************************************************************
    00585             Static properties for the Spinner widget
    00586         *************************************************************************/
    00587         static DragContainerProperties::DragAlpha       d_dragAlphaProperty;
    00588         static DragContainerProperties::DragCursorImage d_dragCursorImageProperty;
    00589         static DragContainerProperties::DraggingEnabled d_dragEnabledProperty;
    00590         static DragContainerProperties::DragThreshold   d_dragThresholdProperty;
    00591         static DragContainerProperties::StickyMode      d_stickyModeProperty;
    00592         static DragContainerProperties::FixedDragOffset d_fixedDragOffsetProperty;
    00593         static DragContainerProperties::UseFixedDragOffset d_useFixedDragOffsetProperty;
    00594
    00595         /*************************************************************************
    00596                 Implementation methods
    00597         *************************************************************************/
    00605         void addDragContainerProperties(void);
    00606     };
    00607
    00608 } // End of  CEGUI namespace section
    00609
    00610
    00611 #if defined(_MSC_VER)
    00612 #       pragma warning(pop)
    00613 #endif
    00614
    00615 #endif  // end of guard _CEGUIDragContainer_h_