Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: 21/2/2004 00003 author: Paul D Turner 00004 00005 purpose: Defines interface for the MouseCursor class 00006 *************************************************************************/ 00007 /*************************************************************************** 00008 * Copyright (C) 2004 - 2012 Paul D Turner & The CEGUI Development Team 00009 * 00010 * Permission is hereby granted, free of charge, to any person obtaining 00011 * a copy of this software and associated documentation files (the 00012 * "Software"), to deal in the Software without restriction, including 00013 * without limitation the rights to use, copy, modify, merge, publish, 00014 * distribute, sublicense, and/or sell copies of the Software, and to 00015 * permit persons to whom the Software is furnished to do so, subject to 00016 * the following conditions: 00017 * 00018 * The above copyright notice and this permission notice shall be 00019 * included in all copies or substantial portions of the Software. 00020 * 00021 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00022 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00023 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00024 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00025 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00026 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00027 * OTHER DEALINGS IN THE SOFTWARE. 00028 ***************************************************************************/ 00029 #ifndef _CEGUIMouseCursor_h_ 00030 #define _CEGUIMouseCursor_h_ 00031 00032 #include "CEGUI/Base.h" 00033 #include "CEGUI/String.h" 00034 #include "CEGUI/Vector.h" 00035 #include "CEGUI/Rect.h" 00036 #include "CEGUI/EventSet.h" 00037 #include "CEGUI/InputEvent.h" 00038 #include "CEGUI/UDim.h" 00039 00040 00041 #if defined(_MSC_VER) 00042 # pragma warning(push) 00043 # pragma warning(disable : 4275) 00044 # pragma warning(disable : 4251) 00045 #endif 00046 00047 // Start of CEGUI namespace section 00048 namespace CEGUI 00049 { 00051 class CEGUIEXPORT MouseCursor : 00052 public EventSet, 00053 public AllocatedObject<MouseCursor> 00054 { 00055 public: 00057 static const String EventNamespace; 00058 00065 static const String EventImageChanged; 00066 00074 static const String EventDefaultImageChanged; 00075 00080 MouseCursor(void); 00081 00082 00087 ~MouseCursor(void); 00088 00089 00102 void setImage(const String& name); 00103 00104 00109 void setImage(const Image* image); 00110 00111 00118 const Image* getImage(void) const {return d_cursorImage;} 00119 00128 void setDefaultImage(const Image* image); 00129 00140 void setDefaultImage(const String& name); 00141 00151 const Image* getDefaultImage() const; 00152 00153 00161 void draw(void) const; 00162 00163 00171 void setPosition(const Vector2f& position); 00172 00173 00184 void offsetPosition(const Vector2f& offset); 00185 00186 00199 void setConstraintArea(const Rectf* area); 00200 00201 00214 void setUnifiedConstraintArea(const URect* area); 00215 00216 00224 void hide(void) {d_visible = false;} 00225 00226 00234 void show(void) {d_visible = true;} 00235 00236 00247 void setVisible(bool visible) {d_visible = visible;} 00248 00249 00257 bool isVisible(void) const {return d_visible;} 00258 00259 00267 Vector2f getPosition(void) const 00268 { return d_position; } 00269 00270 00278 Rectf getConstraintArea(void) const; 00279 00280 00288 const URect& getUnifiedConstraintArea(void) const; 00289 00290 00300 Vector2f getDisplayIndependantPosition(void) const; 00301 00313 void notifyDisplaySizeChanged(const Sizef& new_size); 00314 00330 void setExplicitRenderSize(const Sizef& size); 00331 00337 const Sizef& getExplicitRenderSize() const; 00338 00353 static void setInitialMousePosition(const Vector2f& position); 00354 00360 void invalidate(); 00361 00362 protected: 00363 /************************************************************************* 00364 New event handlers 00365 *************************************************************************/ 00367 virtual void onImageChanged(MouseCursorEventArgs& e); 00369 virtual void onDefaultImageChanged(MouseCursorEventArgs& e); 00370 00371 00372 private: 00373 /************************************************************************* 00374 Implementation Methods 00375 *************************************************************************/ 00380 void constrainPosition(void); 00381 00383 void cacheGeometry() const; 00384 00386 void calculateCustomOffset() const; 00387 00388 /************************************************************************* 00389 Implementation Data 00390 *************************************************************************/ 00392 const Image* d_cursorImage; 00394 const Image* d_defaultCursorImage; 00395 Vector2f d_position; 00396 bool d_visible; 00397 URect d_constraints; 00398 00399 GeometryBuffer* d_geometry; 00401 Sizef d_customSize; 00403 mutable Vector2f d_customOffset; 00405 static bool s_initialPositionSet; 00407 static Vector2f 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_