CImageManager.hpp

Go to the documentation of this file.
00001 #ifndef __CImageManager__
00002 #define __CImageManager__
00003 
00004 //  ===========================================================================
00005 
00006 #include <Collections/TCountedPointerArray.hpp>
00007 #include <Basics/CString.hpp>
00008 #include "IImage.hpp"
00009 
00010 using Exponent::Basics::CString;
00011 using Exponent::Collections::TCountedPointerArray;
00012 using Exponent::GUI::Graphics::IImage;
00013 
00014 //  ===========================================================================
00015 
00016 namespace Exponent
00017 {
00018     namespace GUI
00019     {
00020         namespace Graphics
00021         {
00044             class CImageManager
00045             {
00046 
00047             public:
00048 
00049 //  ===========================================================================
00050 
00051                 const static char CIMAGE_MANAGER_XML_TAG_ROOT[];                            
00052                 const static char CIMAGE_MANAGER_XML_TAG_VERSION[];                         
00053                 const static char CIMAGE_MANAGER_XML_TAG_IMAGES[];                          
00054                 const static char CIMAGE_MANAGER_XML_TAG_ANIMATIONS[];                      
00056                 const static char CIMAGE_MANAGER_XML_TAG_CHILD_IMAGE[];                     
00057                 const static char CIMAGE_MANAGER_XML_ATTRIBUTE_IMAGE_RELATIVE_PATH[];       
00058                 const static char CIMAGE_MANAGER_XML_ATTRIBUTE_IMAGE_FILENAME[];            
00059                 const static char CIMAGE_MANAGER_XML_ATTRIBUTE_IMAGE_NAME[];                
00061                 const static char CIMAGE_MANAGER_XML_ATTRIBUTE_ANIMATION_FRAME_HEIGHT[];    
00062                 const static char CIMAGE_MANAGER_XML_ATTRIBUTE_ANIMATION_NUM_FRAMES[];      
00064 //  ===========================================================================
00065 
00070                 class CImageReference : public CCountedObject
00071                 {
00073                     EXPONENT_CLASS_DECLARATION;
00076                 public:
00077 
00078 //  ===========================================================================
00079 
00083                     CImageReference();
00084 
00090                     CImageReference(IImage *image, const CString &referenceName);
00091 
00095                     virtual ~CImageReference();
00096 
00097 //  ===========================================================================
00098 
00103                     void setImage(IImage *image) { EXCHANGE_COUNTED_OBJECTS(m_image, image); }
00104 
00109                     void setReferenceName(const CString &referenceName) { m_referenceName = referenceName; }
00110 
00111 //  ===========================================================================
00112 
00117                     IImage *getImage() { return m_image; }
00118 
00123                     const CString &getReferenceName() const { return m_referenceName; }
00124 
00125 //  ===========================================================================
00126 
00127                 protected:
00128 
00129 //  ===========================================================================
00130 
00131                     IImage *m_image;                
00132                     CString m_referenceName;        
00133                 };
00134 
00135 
00141                 class CAnimationReference: public CCountedObject
00142                 {
00144                     EXPONENT_CLASS_DECLARATION;
00147 //  ===========================================================================
00148 
00149                 public:
00150 
00151 //  ===========================================================================
00152 
00156                     CAnimationReference();
00157 
00165                     CAnimationReference(IImage *image, const CString &referenceName, const long frameHeight, const long numberOfFrames);
00166 
00170                     virtual ~CAnimationReference();
00171 
00172 //  ===========================================================================
00173 
00178                     void setImage(IImage *image) { m_image.setImage(image); }
00179 
00184                     void setReferenceName(const CString &referenceName) { m_image.setReferenceName(referenceName); }
00185 
00191                     void setAnimationSizes(const long frameHeight, const long numberOfFrames) { m_frameHeight = frameHeight; m_numberOfFrames = numberOfFrames; }
00192 
00193 //  ===========================================================================
00194 
00199                     IImage *getImage() { return m_image.getImage(); }
00200 
00205                     const CString &getReferenceName() const { return m_image.getReferenceName(); }
00206 
00212                     void getAnimationSizes(long &frameHeight, long &numberOfFrames) { frameHeight = m_frameHeight; numberOfFrames = m_numberOfFrames; }
00213 
00214 //  ===========================================================================
00215 
00216                 protected:
00217 
00218 //  ===========================================================================
00219 
00220                     CImageReference m_image;                                                    
00221                     long m_frameHeight;                                                         
00222                     long m_numberOfFrames;                                                      
00223                 };
00224 
00225 //  ===========================================================================
00226 
00231                 static void setDefaultPathToImages(const CSystemString &defaultPath);
00232 
00237                 static const CSystemString &getDefaultPathToImages() { return CIMAGE_MANAGER_DEFAULT_RESOURCE_PATH; }
00238 
00239 //  ===========================================================================
00240 
00248                 static bool addImage(const CSystemString &path, const CString &filename, const CString &referenceName);
00249 
00259                 static bool addAnimation(const CSystemString &path, const CString &filename, const CString &referenceName, const long frameHeight, const long numberOfFrames);
00260 
00261 //  ===========================================================================
00262 
00306                 static bool loadFromDefinitionFile(const CSystemString &filename);
00307 
00308 //  ===========================================================================
00309 
00315                 static IImage *getImage(const CString &referenceName);
00316 
00322                 static CString getReferenceNameForImage(const IImage *image);
00323 
00331                 static IImage *getAnimation(const CString &referenceName, long &frameHeight, long &numberOfFrames);
00332 
00338                 static CImageManager::CAnimationReference *getAnimation(const CString &referenceName);
00339 
00340 //  ===========================================================================
00341 
00345                 static void clearImageLibrary();
00346 
00347 //  ===========================================================================
00348                 
00354                 static IImage *getImageOnPath(const CSystemString &path);
00355 
00356 //  ===========================================================================
00357 
00358             protected:
00359 
00360 //  ===========================================================================
00361 
00367                 static bool readFromXML(const CSystemString &filename);
00368 
00369 //  ===========================================================================
00370 
00371                 static TCountedPointerArray<CImageReference> CIMAGE_MANAGER_IMAGES;             
00372                 static TCountedPointerArray<CAnimationReference> CIMAGE_MANAGER_ANIMATIONS;     
00373                 static CSystemString CIMAGE_MANAGER_DEFAULT_RESOURCE_PATH;                      
00374             };
00375         }
00376     }
00377 }
00378 #endif      // End of CImageManager.hpp

Infinity API - CImageManager.hpp Source File generated on 7 Mar 2007