CEGUIImageset.h

00001 /***********************************************************************
00002         filename:       CEGUIImageset.h
00003         created:        21/2/2004
00004         author:         Paul D Turner
00005         
00006         purpose:        Defines the interface for the Imageset class
00007 *************************************************************************/
00008 /***************************************************************************
00009  *   Copyright (C) 2004 - 2006 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 _CEGUIImageset_h_
00031 #define _CEGUIImageset_h_
00032 
00033 #include "CEGUIBase.h"
00034 #include "CEGUIString.h"
00035 #include "CEGUIRect.h"
00036 #include "CEGUIColourRect.h"
00037 #include "CEGUIImagesetManager.h"
00038 #include "CEGUIImage.h"
00039 #include "CEGUIIteratorBase.h"
00040 #include "CEGUIXMLSerializer.h" 
00041 
00042 #include <map>
00043 
00044 
00045 #if defined(_MSC_VER)
00046 #       pragma warning(push)
00047 #       pragma warning(disable : 4251)
00048 #endif
00049 
00050 
00051 // Start of CEGUI namespace section
00052 namespace CEGUI
00053 {
00054 
00063 class CEGUIEXPORT Imageset
00064 {
00065         friend class Imageset_xmlHandler;
00066 private:
00067         typedef std::map<String, Image, String::FastLessCompare>        ImageRegistry;
00068 
00069         /*************************************************************************
00070                 Friends to allow access to constructors and destructors
00071         *************************************************************************/
00072         friend Imageset*        ImagesetManager::createImageset(const String& name, Texture* texture);
00073         friend Imageset*        ImagesetManager::createImageset(const String& filename, const String& resourceGroup);
00074         friend Imageset*        ImagesetManager::createImagesetFromImageFile(const String& name, const String& filename, const String& resourceGroup);
00075         friend void                     ImagesetManager::destroyImageset(const String& name);
00076 
00077 
00078         /*************************************************************************
00079                 Construction and Destruction (private, only ImagesetManager can 
00080                 create and destroy Imageset objects).
00081         *************************************************************************/
00089         Imageset(const String& name, Texture* texture);
00090 
00091 
00105         Imageset(const String& filename, const String& resourceGroup);
00106 
00107 
00133     Imageset(const String& name, const String& filename, const String& resourceGroup);
00134 
00135 
00136 public: // For luabind support
00141         ~Imageset(void);
00142 
00143 
00144 public:
00145         typedef ConstBaseIterator<ImageRegistry>        ImageIterator;  
00146 
00147         /*************************************************************************
00148                 Public interface
00149         *************************************************************************/
00157         Texture*        getTexture(void) const                                          {return d_texture;}
00158 
00159 
00167         const String&   getName(void) const                                             {return d_name;}
00168 
00169 
00177         uint      getImageCount(void) const               {return (uint)d_images.size();}
00178 
00179  
00190         bool            isImageDefined(const String& name) const        {return d_images.find(name) != d_images.end();}
00191 
00192  
00205         const Image&    getImage(const String& name) const;
00206 
00207 
00217         void    undefineImage(const String& name);
00218 
00226         void    undefineAllImages(void);
00227 
00228 
00241         Size    getImageSize(const String& name) const                  {return getImage(name).getSize();}
00242 
00243 
00256         float   getImageWidth(const String& name) const                 {return getImage(name).getWidth();}
00257 
00258 
00271         float   getImageHeight(const String& name) const                {return getImage(name).getHeight();}
00272 
00273 
00286         Point   getImageOffset(const String& name) const                {return getImage(name).getOffsets();}
00287 
00288 
00301         float   getImageOffsetX(const String& name) const               {return getImage(name).getOffsetX();}
00302 
00303 
00316         float   getImageOffsetY(const String& name) const               {return getImage(name).getOffsetY();}
00317 
00318         
00340         void    defineImage(const String& name, const Point& position, const Size& size, const Point& render_offset)
00341         {
00342                 defineImage(name, Rect(position.d_x, position.d_y, position.d_x + size.d_width, position.d_y + size.d_height), render_offset);
00343         }
00344 
00345 
00364         void    defineImage(const String& name, const Rect& image_rect, const Point& render_offset);
00365 
00366 
00392         void    draw(const Rect& source_rect, const Rect& dest_rect, float z, const Rect& clip_rect,const ColourRect& colours, QuadSplitMode quad_split_mode) const;
00393 
00394 
00429         void    draw(const Rect& source_rect, const Rect& dest_rect, float z, const Rect& clip_rect, const colour& top_left_colour = 0xFFFFFFFF, const colour& top_right_colour = 0xFFFFFFFF,  const colour& bottom_left_colour = 0xFFFFFFFF, const colour& bottom_right_colour = 0xFFFFFFFF, QuadSplitMode quad_split_mode = TopLeftToBottomRight) const
00430         {
00431                 draw(source_rect, dest_rect, z, clip_rect, ColourRect(top_left_colour, top_right_colour, bottom_left_colour, bottom_right_colour), quad_split_mode);
00432         }
00433 
00434 
00442         bool    isAutoScaled(void) const                {return d_autoScale;}
00443 
00444 
00452         Size    getNativeResolution(void) const {return Size(d_nativeHorzRes, d_nativeVertRes);}
00453 
00454 
00465         void    setAutoScalingEnabled(bool setting);
00466 
00467 
00478         void    setNativeResolution(const Size& size);
00479 
00480 
00491         void    notifyScreenResolution(const Size& size);
00492 
00493 
00498         ImageIterator   getIterator(void) const;
00499 
00500 
00514     void writeXMLToStream(XMLSerializer& xml_stream) const;
00515 
00526     static void setDefaultResourceGroup(const String& resourceGroup)
00527         { d_defaultResourceGroup = resourceGroup; }
00528 
00537     static const String& getDefaultResourceGroup()
00538         { return d_defaultResourceGroup; }
00539 
00540 protected:
00541         /*************************************************************************
00542                 Implementation Constants
00543         *************************************************************************/
00544         static const char       ImagesetSchemaName[];                   
00545 
00546 
00547         /*************************************************************************
00548                 Implementation Functions
00549         *************************************************************************/
00566         void    load(const String& filename, const String& resourceGroup);
00567 
00568 
00573         void    unload(void);
00574 
00575 
00588         void    setTexture(Texture* texture);
00589 
00590 
00598         void    updateImageScalingFactors(void);
00599 
00600         /*************************************************************************
00601                 Implementation Data
00602         *************************************************************************/
00603         String                  d_name;                                         
00604         ImageRegistry   d_images;                                       
00605         Texture*                d_texture;                                      
00606     String          d_textureFilename;          
00607 
00608         // auto-scaling fields
00609         bool    d_autoScale;                    
00610         float   d_horzScaling;                  
00611         float   d_vertScaling;                  
00612         float   d_nativeHorzRes;                
00613         float   d_nativeVertRes;                
00614     static String d_defaultResourceGroup;   
00615 };
00616 
00617 } // End of  CEGUI namespace section
00618 
00619 #if defined(_MSC_VER)
00620 #       pragma warning(pop)
00621 #endif
00622 
00623 #endif  // end of guard _CEGUIImageset_h_

Generated on Sat Jun 28 14:35:44 2008 for Crazy Eddies GUI System by  doxygen 1.5.4