# CEGUIMouseCursor.h

    00001 /************************************************************************
    00002         filename:       CEGUIMouseCursor.h
    00003         created:        21/2/2004
    00004         author:         Paul D Turner
    00005
    00006         purpose:        Defines interface for the MouseCursor class
    00007 *************************************************************************/
    00008 /*************************************************************************
    00009     Crazy Eddie's GUI System (http://www.cegui.org.uk)
    00010     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
    00011
    00012     This library is free software; you can redistribute it and/or
    00013     modify it under the terms of the GNU Lesser General Public
    00014     License as published by the Free Software Foundation; either
    00015     version 2.1 of the License, or (at your option) any later version.
    00016
    00017     This library is distributed in the hope that it will be useful,
    00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00020     Lesser General Public License for more details.
    00021
    00022     You should have received a copy of the GNU Lesser General Public
    00023     License along with this library; if not, write to the Free Software
    00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00025 *************************************************************************/
    00026 #ifndef _CEGUIMouseCursor_h_
    00027 #define _CEGUIMouseCursor_h_
    00028
    00029 #include "CEGUIBase.h"
    00030 #include "CEGUIString.h"
    00031 #include "CEGUISingleton.h"
    00032 #include "CEGUIVector.h"
    00033 #include "CEGUIRect.h"
    00034 #include "CEGUIEventSet.h"
    00035 #include "CEGUIInputEvent.h"
    00036 #include "CEGUIUDim.h"
    00037
    00038
    00039 #if defined(_MSC_VER)
    00040 #       pragma warning(push)
    00041 #       pragma warning(disable : 4275)
    00042 #       pragma warning(disable : 4251)
    00043 #endif
    00044
    00045
    00046 // Start of CEGUI namespace section
    00047 namespace CEGUI
    00048 {
    00049
    00054 enum MouseCursorImage
    00055 {
    00056         BlankMouseCursor        = 0,
    00057         DefaultMouseCursor      = -1
    00058 };
    00059
    00060
    00067 class CEGUIEXPORT MouseCursor : public EventSet, public Singleton<MouseCursor>
    00068 {
    00069 public:
    00070         static const String EventNamespace;
    00071
    00072         /*************************************************************************
    00073                 Event name constants
    00074         *************************************************************************/
    00075         // generated internally by MouseCursor
    00076         static const String EventImageChanged;
    00077
    00078
    00083         MouseCursor(void);
    00084
    00085
    00090         ~MouseCursor(void);
    00091
    00092
    00100         static  MouseCursor&    getSingleton(void);
    00101
    00102
    00110         static  MouseCursor*    getSingletonPtr(void);
    00111
    00112
    00128         void    setImage(const String& imageset, const String& image_name);
    00129
    00130
    00135         void    setImage(const Image* image);
    00136
    00137
    00144         const Image*    getImage(void) const    {return d_cursorImage;}
    00145
    00146
    00154         void    draw(void) const;
    00155
    00156
    00164         void    setPosition(const Point& position);
    00165
    00166
    00177         void    offsetPosition(const Point& offset);
    00178
    00179
    00192         void    setConstraintArea(const Rect* area);
    00193
    00194
    00207         void    setUnifiedConstraintArea(const URect* area);
    00208
    00209
    00217         void    hide(void)              {d_visible = false;}
    00218
    00219
    00227         void    show(void)              {d_visible = true;}
    00228
    00229
    00237         bool    isVisible(void) const   {return d_visible;}
    00238
    00239
    00247         Point   getPosition(void) const         {return Point(d_position.d_x, d_position.d_y);}
    00248
    00249
    00257         Rect    getConstraintArea(void) const;
    00258
    00259
    00267         const URect& getUnifiedConstraintArea(void) const;
    00268
    00269
    00279         Point   getDisplayIndependantPosition(void) const;
    00280
    00281
    00282 protected:
    00283         /*************************************************************************
    00284                 New event handlers
    00285         *************************************************************************/
    00290         virtual void    onImageChanged(MouseCursorEventArgs& e);
    00291
    00292
    00293         /*************************************************************************
    00294                 Implementation Functions
    00295         *************************************************************************/
    00300         void    addMouseCursorEvents(void);
    00301
    00302
    00303 private:
    00304         /*************************************************************************
    00305                 Implementation Methods
    00306         *************************************************************************/
    00311         void    constrainPosition(void);
    00312
    00313
    00314         /*************************************************************************
    00315                 Implementation Data
    00316         *************************************************************************/
    00317         const Image*    d_cursorImage;
    00318         Vector3 d_position;
    00319         bool    d_visible;
    00320         URect   d_constraints;
    00321 };
    00322
    00323 } // End of  CEGUI namespace section
    00324
    00325 #if defined(_MSC_VER)
    00326 #       pragma warning(pop)
    00327 #endif
    00328
    00329 #endif  // end of guard _CEGUIMouseCursor_h_