Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

CEGUIImageset.h

Go to the documentation of this file.
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     Crazy Eddie's GUI System (http://www.cegui.org.uk)
00010     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
00011 
00012     This library is free software; you can redistribute it and/or
00013     modify it under the terms of the GNU Lesser General Public
00014     License as published by the Free Software Foundation; either
00015     version 2.1 of the License, or (at your option) any later version.
00016 
00017     This library is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020     Lesser General Public License for more details.
00021 
00022     You should have received a copy of the GNU Lesser General Public
00023     License along with this library; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 *************************************************************************/
00026 #ifndef _CEGUIImageset_h_
00027 #define _CEGUIImageset_h_
00028 
00029 #include "CEGUIBase.h"
00030 #include "CEGUIString.h"
00031 #include "CEGUIRect.h"
00032 #include "CEGUIColourRect.h"
00033 #include "CEGUIImagesetManager.h"
00034 #include "CEGUIImage.h"
00035 #include "CEGUIIteratorBase.h"
00036 
00037 #include <map>
00038 
00039 
00040 #if defined(_MSC_VER)
00041 #       pragma warning(push)
00042 #       pragma warning(disable : 4251)
00043 #endif
00044 
00045 
00046 // Start of CEGUI namespace section
00047 namespace CEGUI
00048 {
00049 
00058 class CEGUIBASE_API Imageset
00059 {
00060         friend class Imageset_xmlHandler;
00061 private:
00062         typedef std::map<String, Image> ImageRegistry;
00063 
00064         /*************************************************************************
00065                 Friends to allow access to constructors and destructors
00066         *************************************************************************/
00067         friend Imageset*        ImagesetManager::createImageset(const String& name, Texture* texture);
00068         friend Imageset*        ImagesetManager::createImageset(const String& filename, const String& resourceGroup);
00069         friend void                     ImagesetManager::destroyImageset(const String& name);
00070 
00071 
00072         /*************************************************************************
00073                 Construction and Destruction (private, only ImagesetManager can 
00074                 create and destroy Imageset objects).
00075         *************************************************************************/
00083         Imageset(const String& name, Texture* texture);
00084 
00085 
00099         Imageset(const String& filename, const String& resourceGroup);
00100 
00101 
00102 public: // For luabind support
00107         ~Imageset(void);
00108 
00109 
00110 public:
00111         typedef ConstBaseIterator<ImageRegistry>        ImageIterator;  
00112 
00113         /*************************************************************************
00114                 Public interface
00115         *************************************************************************/
00123         Texture*        getTexture(void) const                                          {return d_texture;}
00124 
00125 
00133         const String&   getName(void) const                                             {return d_name;}
00134 
00135 
00143         uint      getImageCount(void) const               {return (uint)d_images.size();}
00144 
00145  
00156         bool            isImageDefined(const String& name) const        {return d_images.find(name) != d_images.end();}
00157 
00158  
00171         const Image&    getImage(const String& name) const;
00172 
00173 
00183         void    undefineImage(const String& name);
00184 
00185 
00193         void    undefineAllImages(void);
00194 
00195 
00208         Size    getImageSize(const String& name) const                  {return getImage(name).getSize();}
00209 
00210 
00223         float   getImageWidth(const String& name) const                 {return getImage(name).getWidth();}
00224 
00225 
00238         float   getImageHeight(const String& name) const                {return getImage(name).getHeight();}
00239 
00240 
00253         Point   getImageOffset(const String& name) const                {return getImage(name).getOffsets();}
00254 
00255 
00268         float   getImageOffsetX(const String& name) const               {return getImage(name).getOffsetX();}
00269 
00270 
00283         float   getImageOffsetY(const String& name) const               {return getImage(name).getOffsetY();}
00284 
00285         
00307         void    defineImage(const String& name, const Point& position, const Size& size, const Point& render_offset)
00308         {
00309                 defineImage(name, Rect(position.d_x, position.d_y, position.d_x + size.d_width, position.d_y + size.d_height), render_offset);
00310         }
00311 
00312 
00331         void    defineImage(const String& name, const Rect& image_rect, const Point& render_offset);
00332 
00333 
00359         void    draw(const Rect& source_rect, const Rect& dest_rect, float z, const Rect& clip_rect,const ColourRect& colours, QuadSplitMode quad_split_mode) const;
00360 
00361 
00396         void    draw(const Rect& source_rect, const Rect& dest_rect, float z, const Rect& clip_rect, const colour& top_left_colour = -1, const colour& top_right_colour = -1,  const colour& bottom_left_colour = -1, const colour& bottom_right_colour = -1, QuadSplitMode quad_split_mode = TopLeftToBottomRight) const
00397         {
00398                 draw(source_rect, dest_rect, z, clip_rect, ColourRect(top_left_colour, top_right_colour, bottom_left_colour, bottom_right_colour), quad_split_mode);
00399         }
00400 
00401 
00409         bool    isAutoScaled(void) const                {return d_autoScale;}
00410 
00411 
00419         Size    getNativeResolution(void) const {return Size(d_nativeHorzRes, d_nativeVertRes);}
00420 
00421 
00432         void    setAutoScalingEnabled(bool setting);
00433 
00434 
00445         void    setNativeResolution(const Size& size);
00446 
00447 
00458         void    notifyScreenResolution(const Size& size);
00459 
00460 
00465         ImageIterator   getIterator(void) const;
00466 
00467 
00468 protected:
00469         /*************************************************************************
00470                 Implementation Constants
00471         *************************************************************************/
00472         static const char       ImagesetSchemaName[];                   
00473 
00474 
00475         /*************************************************************************
00476                 Implementation Functions
00477         *************************************************************************/
00494         void    load(const String& filename, const String& resourceGroup);
00495 
00496 
00501         void    unload(void);
00502 
00503 
00516         void    setTexture(Texture* texture);
00517 
00518 
00526         void    updateImageScalingFactors(void);
00527 
00528         /*************************************************************************
00529                 Implementation Data
00530         *************************************************************************/
00531         String                  d_name;                                         
00532         ImageRegistry   d_images;                                       
00533         Texture*                d_texture;                                      
00534 
00535         // auto-scaling fields
00536         bool    d_autoScale;                    
00537         float   d_horzScaling;                  
00538         float   d_vertScaling;                  
00539         float   d_nativeHorzRes;                
00540         float   d_nativeVertRes;                
00541 };
00542 
00543 } // End of  CEGUI namespace section
00544 
00545 #if defined(_MSC_VER)
00546 #       pragma warning(pop)
00547 #endif
00548 
00549 #endif  // end of guard _CEGUIImageset_h_

Generated on Wed Feb 16 12:41:06 2005 for Crazy Eddies GUI System by  doxygen 1.3.9.1