guiImageList.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _GUIIMAGELIST_H_
  23. #define _GUIIMAGELIST_H_
  24. #ifndef _PLATFORM_H_
  25. #include "platform/platform.h"
  26. #endif
  27. #ifndef _MPOINT_H_
  28. #include "math/mPoint.h"
  29. #endif
  30. #ifndef _MRECT_H_
  31. #include "math/mRect.h"
  32. #endif
  33. #ifndef _COLOR_H_
  34. #include "graphics/color.h"
  35. #endif
  36. #ifndef _SIMBASE_H_
  37. #include "sim/simBase.h"
  38. #endif
  39. #ifndef _GUITYPES_H_
  40. #include "gui/guiTypes.h"
  41. #endif
  42. #ifndef _EVENT_H_
  43. #include "platform/event.h"
  44. #endif
  45. class GuiImageList : public SimObject
  46. {
  47. private:
  48. typedef SimObject Parent;
  49. public:
  50. typedef struct tag_TextureEntry
  51. {
  52. StringTableEntry TexturePath;
  53. TextureHandle Handle;
  54. TextureObject* Object;
  55. U32 id;
  56. }TextureEntry,*PTextureEntry;
  57. Vector<PTextureEntry> mTextures;
  58. protected:
  59. U32 mUniqueId;
  60. public:
  61. GuiImageList();
  62. DECLARE_CONOBJECT(GuiImageList);
  63. static void initPersistFields();
  64. // Image managing functions
  65. bool Clear();
  66. inline U32 Count() { return (U32)mTextures.size(); };
  67. U32 Insert( const char* texturePath , TextureHandle::TextureHandleType type = TextureHandle::BitmapTexture );
  68. bool FreeTextureEntry( U32 Index );
  69. bool FreeTextureEntry( PTextureEntry Entry );
  70. TextureObject *GetTextureObject( U32 Index );
  71. TextureObject *GetTextureObject( const char* TexturePath );
  72. TextureHandle GetTextureHandle( U32 Index );
  73. TextureHandle GetTextureHandle( const char* TexturePath );
  74. const char * GetTexturePath( U32 Index );
  75. U32 IndexFromId ( U32 Id );
  76. U32 IndexFromPath ( const char* Path );
  77. };
  78. #endif //_GUIIMAGELISTCTRL_H_