Crazy Eddies GUI System: CEGUIMouseCursor.h Source File

Crazy Eddies GUI System 0.7.6

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

- File List

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  *   Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
    00010  *
    00011  *   Permission is hereby granted, free of charge, to any person obtaining
    00012  *   a copy of this software and associated documentation files (the
    00013  *   "Software"), to deal in the Software without restriction, including
    00014  *   without limitation the rights to use, copy, modify, merge, publish,
    00015  *   distribute, sublicense, and/or sell copies of the Software, and to
    00016  *   permit persons to whom the Software is furnished to do so, subject to
    00017  *   the following conditions:
    00018  *
    00019  *   The above copyright notice and this permission notice shall be
    00020  *   included in all copies or substantial portions of the Software.
    00021  *
    00022  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    00023  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    00024  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    00025  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
    00026  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
    00027  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
    00028  *   OTHER DEALINGS IN THE SOFTWARE.
    00029  ***************************************************************************/
    00030 #ifndef _CEGUIMouseCursor_h_
    00031 #define _CEGUIMouseCursor_h_
    00032
    00033 #include "CEGUIBase.h"
    00034 #include "CEGUIString.h"
    00035 #include "CEGUISingleton.h"
    00036 #include "CEGUIVector.h"
    00037 #include "CEGUIRect.h"
    00038 #include "CEGUIEventSet.h"
    00039 #include "CEGUIInputEvent.h"
    00040 #include "CEGUIUDim.h"
    00041
    00042
    00043 #if defined(_MSC_VER)
    00044 #       pragma warning(push)
    00045 #       pragma warning(disable : 4275)
    00046 #       pragma warning(disable : 4251)
    00047 #endif
    00048
    00049
    00050 // Start of CEGUI namespace section
    00051 namespace CEGUI
    00052 {
    00057 enum MouseCursorImage
    00058 {
    00059         BlankMouseCursor        = 0,
    00060         DefaultMouseCursor      = -1
    00061 };
    00062
    00063
    00070 class CEGUIEXPORT MouseCursor : public EventSet, public Singleton<MouseCursor>
    00071 {
    00072 public:
    00073         static const String EventNamespace;
    00074
    00075         /*************************************************************************
    00076                 Event name constants
    00077         *************************************************************************/
    00078         // generated internally by MouseCursor
    00085         static const String EventImageChanged;
    00086
    00087
    00092         MouseCursor(void);
    00093
    00094
    00099         ~MouseCursor(void);
    00100
    00101
    00109         static  MouseCursor&    getSingleton(void);
    00110
    00111
    00119         static  MouseCursor*    getSingletonPtr(void);
    00120
    00121
    00137         void    setImage(const String& imageset, const String& image_name);
    00138
    00139
    00144         void    setImage(const Image* image);
    00145
    00146
    00153         const Image*    getImage(void) const    {return d_cursorImage;}
    00154
    00155
    00163         void    draw(void) const;
    00164
    00165
    00173         void    setPosition(const Point& position);
    00174
    00175
    00186         void    offsetPosition(const Point& offset);
    00187
    00188
    00201         void    setConstraintArea(const Rect* area);
    00202
    00203
    00216         void    setUnifiedConstraintArea(const URect* area);
    00217
    00218
    00226         void    hide(void)              {d_visible = false;}
    00227
    00228
    00236         void    show(void)              {d_visible = true;}
    00237
    00238
    00249     void    setVisible(bool visible)    {d_visible = visible;}
    00250
    00251
    00259         bool    isVisible(void) const   {return d_visible;}
    00260
    00261
    00269         Point   getPosition(void) const
    00270     { return d_position; }
    00271
    00272
    00280         Rect    getConstraintArea(void) const;
    00281
    00282
    00290         const URect& getUnifiedConstraintArea(void) const;
    00291
    00292
    00302         Point   getDisplayIndependantPosition(void) const;
    00303
    00315     void notifyDisplaySizeChanged(const Size& new_size);
    00316
    00332     void setExplicitRenderSize(const Size& size);
    00333
    00339     const Size& getExplicitRenderSize() const;
    00340
    00355     static void setInitialMousePosition(const Point& position);
    00356
    00362     void invalidate();
    00363
    00364 protected:
    00365         /*************************************************************************
    00366                 New event handlers
    00367         *************************************************************************/
    00372         virtual void    onImageChanged(MouseCursorEventArgs& e);
    00373
    00374
    00375 private:
    00376         /*************************************************************************
    00377                 Implementation Methods
    00378         *************************************************************************/
    00383         void    constrainPosition(void);
    00384
    00386     void cacheGeometry() const;
    00387
    00389     void calculateCustomOffset() const;
    00390
    00391         /*************************************************************************
    00392                 Implementation Data
    00393         *************************************************************************/
    00394         const Image*    d_cursorImage;
    00395         Vector2 d_position;
    00396         bool    d_visible;
    00397         URect   d_constraints;
    00398
    00399     GeometryBuffer* d_geometry;
    00401     Size d_customSize;
    00403     mutable Point d_customOffset;
    00405     static bool s_initialPositionSet;
    00407     static Point s_initialPosition;
    00409     mutable bool d_cachedGeometryValid;
    00410 };
    00411
    00412 } // End of  CEGUI namespace section
    00413
    00414 #if defined(_MSC_VER)
    00415 #       pragma warning(pop)
    00416 #endif
    00417
    00418 #endif  // end of guard _CEGUIMouseCursor_h_