Crazy Eddies GUI System: CEGUIDragContainer.h Source File

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

# CEGUIDragContainer.h

    00001 /************************************************************************
    00002         filename:       CEGUIDragContainer.h
    00003         created:        14/2/2005
    00004         author:         Paul D Turner
    00005 *************************************************************************/
    00006 /*************************************************************************
    00007     Crazy Eddie's GUI System (http://www.cegui.org.uk)
    00008     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
    00009
    00010     This library is free software; you can redistribute it and/or
    00011     modify it under the terms of the GNU Lesser General Public
    00012     License as published by the Free Software Foundation; either
    00013     version 2.1 of the License, or (at your option) any later version.
    00014
    00015     This library is distributed in the hope that it will be useful,
    00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00018     Lesser General Public License for more details.
    00019
    00020     You should have received a copy of the GNU Lesser General Public
    00021     License along with this library; if not, write to the Free Software
    00022     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00023 *************************************************************************/
    00024 #ifndef _CEGUIDragContainer_h_
    00025 #define _CEGUIDragContainer_h_
    00026
    00027 #include "CEGUIWindow.h"
    00028 #include "CEGUIWindowFactory.h"
    00029 #include "elements/CEGUIDragContainerProperties.h"
    00030
    00031
    00032 #if defined(_MSC_VER)
    00033 #       pragma warning(push)
    00034 #       pragma warning(disable : 4251)
    00035 #endif
    00036
    00037 // Start of CEGUI namespace section
    00038 namespace CEGUI
    00039 {
    00044     class CEGUIEXPORT DragContainer : public Window
    00045     {
    00046     public:
    00047         /*************************************************************************
    00048             Constants
    00049         *************************************************************************/
    00050         static const String WidgetTypeName;
    00051         static const String EventNamespace;
    00052         static const String EventDragStarted;
    00053         static const String EventDragEnded;
    00054         static const String EventDragPositionChanged;
    00055         static const String EventDragEnabledChanged;
    00056         static const String EventDragAlphaChanged;
    00057         static const String EventDragMouseCursorChanged;
    00058         static const String EventDragThresholdChanged;
    00059         static const String EventDragDropTargetChanged;
    00060
    00061         /*************************************************************************
    00062             Object Construction and Destruction
    00063         *************************************************************************/
    00068         DragContainer(const String& type, const String& name);
    00069
    00074         virtual ~DragContainer(void);
    00075
    00076         /*************************************************************************
    00077                 Public Interface to DragContainer
    00078         *************************************************************************/
    00087         bool isDraggingEnabled(void) const;
    00088
    00100         void setDraggingEnabled(bool setting);
    00101
    00110         bool isBeingDragged(void) const;
    00111
    00123         float getPixelDragThreshold(void) const;
    00124
    00139         void setPixelDragThreshold(float pixels);
    00140
    00149         float getDragAlpha(void) const;
    00150
    00166         void setDragAlpha(float alpha);
    00167
    00176         const Image* getDragCursorImage(void) const;
    00177
    00192         void setDragCursorImage(const Image* image);
    00193
    00208         void setDragCursorImage(MouseCursorImage image);
    00209
    00230         void setDragCursorImage(const String& imageset, const String& image);
    00231
    00243         Window* getCurrentDropTarget(void) const;
    00244
    00245     protected:
    00246         /*************************************************************************
    00247                 Protected Implementation Methods
    00248         *************************************************************************/
    00256         void addDragContainerEvents(void);
    00257
    00270         bool isDraggingThresholdExceeded(const Point& local_mouse);
    00271
    00279         void initialiseDragging(void);
    00280
    00291         void doDragging(const Point& local_mouse);
    00292
    00297         void updateActiveMouseCursor(void) const;
    00298
    00299
    00310                 virtual bool    testClassName_impl(const String& class_name) const
    00311                 {
    00312                         if (class_name==(const utf8*)"DragContainer")   return true;
    00313                         return Window::testClassName_impl(class_name);
    00314                 }
    00315
    00316
    00317         /*************************************************************************
    00318                 Implementation of abstract methods in Window
    00319         *************************************************************************/
    00320         void drawSelf(float z);
    00321
    00322         /*************************************************************************
    00323                 Overrides of methods in Window
    00324         *************************************************************************/
    00325
    00326         /*************************************************************************
    00327                 Overrides for Event handler methods
    00328         *************************************************************************/
    00329         virtual void onMouseButtonDown(MouseEventArgs& e);
    00330         virtual void onMouseButtonUp(MouseEventArgs& e);
    00331         virtual void onMouseMove(MouseEventArgs& e);
    00332         virtual void onCaptureLost(WindowEventArgs& e);
    00333         virtual void onAlphaChanged(WindowEventArgs& e);
    00334         virtual void onClippingChanged(WindowEventArgs& e);/*Window::drawSelf(z);*/
    00335
    00336         /*************************************************************************
    00337                 New Event handler methods
    00338         *************************************************************************/
    00349         virtual void onDragStarted(WindowEventArgs& e);
    00350
    00361         virtual void onDragEnded(WindowEventArgs& e);
    00362
    00373         virtual void onDragPositionChanged(WindowEventArgs& e);
    00374
    00383         virtual void onDragEnabledChanged(WindowEventArgs& e);
    00384
    00393         virtual void onDragAlphaChanged(WindowEventArgs& e);
    00394
    00403         virtual void onDragMouseCursorChanged(WindowEventArgs& e);
    00404
    00413         virtual void onDragThresholdChanged(WindowEventArgs& e);
    00414
    00430         virtual void onDragDropTargetChanged(DragDropEventArgs& e);
    00431
    00432         /*************************************************************************
    00433                 Data
    00434         *************************************************************************/
    00435         bool    d_draggingEnabled;
    00436         bool    d_leftMouseDown;
    00437         bool    d_dragging;
    00438         Point   d_dragPoint;
    00439         Point   d_startPosition;
    00440         float   d_dragThreshold;
    00441         float   d_dragAlpha;
    00442         float   d_storedAlpha;
    00443         bool    d_storedClipState;
    00444         Window* d_dropTarget;
    00445         const Image* d_dragCursorImage;
    00446
    00447     private:
    00448         /*************************************************************************
    00449             Static properties for the Spinner widget
    00450         *************************************************************************/
    00451         static DragContainerProperties::DragAlpha       d_dragAlphaProperty;
    00452         static DragContainerProperties::DragCursorImage d_dragCursorImageProperty;
    00453         static DragContainerProperties::DraggingEnabled d_dragEnabledProperty;
    00454         static DragContainerProperties::DragThreshold   d_dragThresholdProperty;
    00455
    00456         /*************************************************************************
    00457                 Implementation methods
    00458         *************************************************************************/
    00466         void addDragContainerProperties(void);
    00467     };
    00468
    00473     class DragContainerFactory : public WindowFactory
    00474     {
    00475     public:
    00476         DragContainerFactory(void) : WindowFactory(DragContainer::WidgetTypeName) { }
    00477         ~DragContainerFactory(void){}
    00478
    00479         Window* createWindow(const String& name)
    00480         {
    00481             DragContainer* wnd = new DragContainer(d_type, name);
    00482             return wnd;
    00483         }
    00484
    00485         void destroyWindow(Window* window)
    00486         {
    00487             if (window->getType() == d_type)
    00488                 delete window;
    00489         }
    00490
    00491     };
    00492
    00493
    00494 } // End of  CEGUI namespace section
    00495
    00496
    00497 #if defined(_MSC_VER)
    00498 #       pragma warning(pop)
    00499 #endif
    00500
    00501 #endif  // end of guard _CEGUIDragContainer_h_