Crazy Eddies GUI System: CEGUIImageset.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

# 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     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 CEGUIEXPORT 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 Imageset*        ImagesetManager::createImagesetFromImageFile(const String& name, const String& filename, const String& resourceGroup);
    00070         friend void                     ImagesetManager::destroyImageset(const String& name);
    00071
    00072
    00073         /*************************************************************************
    00074                 Construction and Destruction (private, only ImagesetManager can
    00075                 create and destroy Imageset objects).
    00076         *************************************************************************/
    00084         Imageset(const String& name, Texture* texture);
    00085
    00086
    00100         Imageset(const String& filename, const String& resourceGroup);
    00101
    00102
    00128     Imageset(const String& name, const String& filename, const String& resourceGroup);
    00129
    00130
    00131 public: // For luabind support
    00136         ~Imageset(void);
    00137
    00138
    00139 public:
    00140         typedef ConstBaseIterator<ImageRegistry>        ImageIterator;
    00141
    00142         /*************************************************************************
    00143                 Public interface
    00144         *************************************************************************/
    00152         Texture*        getTexture(void) const                                          {return d_texture;}
    00153
    00154
    00162         const String&   getName(void) const                                             {return d_name;}
    00163
    00164
    00172         uint      getImageCount(void) const               {return (uint)d_images.size();}
    00173
    00174
    00185         bool            isImageDefined(const String& name) const        {return d_images.find(name) != d_images.end();}
    00186
    00187
    00200         const Image&    getImage(const String& name) const;
    00201
    00202
    00212         void    undefineImage(const String& name);
    00213
    00214
    00222         void    undefineAllImages(void);
    00223
    00224
    00237         Size    getImageSize(const String& name) const                  {return getImage(name).getSize();}
    00238
    00239
    00252         float   getImageWidth(const String& name) const                 {return getImage(name).getWidth();}
    00253
    00254
    00267         float   getImageHeight(const String& name) const                {return getImage(name).getHeight();}
    00268
    00269
    00282         Point   getImageOffset(const String& name) const                {return getImage(name).getOffsets();}
    00283
    00284
    00297         float   getImageOffsetX(const String& name) const               {return getImage(name).getOffsetX();}
    00298
    00299
    00312         float   getImageOffsetY(const String& name) const               {return getImage(name).getOffsetY();}
    00313
    00314
    00336         void    defineImage(const String& name, const Point& position, const Size& size, const Point& render_offset)
    00337         {
    00338                 defineImage(name, Rect(position.d_x, position.d_y, position.d_x + size.d_width, position.d_y + size.d_height), render_offset);
    00339         }
    00340
    00341
    00360         void    defineImage(const String& name, const Rect& image_rect, const Point& render_offset);
    00361
    00362
    00388         void    draw(const Rect& source_rect, const Rect& dest_rect, float z, const Rect& clip_rect,const ColourRect& colours, QuadSplitMode quad_split_mode) const;
    00389
    00390
    00425         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
    00426         {
    00427                 draw(source_rect, dest_rect, z, clip_rect, ColourRect(top_left_colour, top_right_colour, bottom_left_colour, bottom_right_colour), quad_split_mode);
    00428         }
    00429
    00430
    00438         bool    isAutoScaled(void) const                {return d_autoScale;}
    00439
    00440
    00448         Size    getNativeResolution(void) const {return Size(d_nativeHorzRes, d_nativeVertRes);}
    00449
    00450
    00461         void    setAutoScalingEnabled(bool setting);
    00462
    00463
    00474         void    setNativeResolution(const Size& size);
    00475
    00476
    00487         void    notifyScreenResolution(const Size& size);
    00488
    00489
    00494         ImageIterator   getIterator(void) const;
    00495
    00496
    00507     void writeXMLToStream(OutStream& out_stream) const;
    00508
    00509
    00510 protected:
    00511         /*************************************************************************
    00512                 Implementation Constants
    00513         *************************************************************************/
    00514         static const char       ImagesetSchemaName[];
    00515
    00516
    00517         /*************************************************************************
    00518                 Implementation Functions
    00519         *************************************************************************/
    00536         void    load(const String& filename, const String& resourceGroup);
    00537
    00538
    00543         void    unload(void);
    00544
    00545
    00558         void    setTexture(Texture* texture);
    00559
    00560
    00568         void    updateImageScalingFactors(void);
    00569
    00570         /*************************************************************************
    00571                 Implementation Data
    00572         *************************************************************************/
    00573         String                  d_name;
    00574         ImageRegistry   d_images;
    00575         Texture*                d_texture;
    00576     String          d_textureFilename;
    00577
    00578         // auto-scaling fields
    00579         bool    d_autoScale;
    00580         float   d_horzScaling;
    00581         float   d_vertScaling;
    00582         float   d_nativeHorzRes;
    00583         float   d_nativeVertRes;
    00584 };
    00585
    00586 } // End of  CEGUI namespace section
    00587
    00588 #if defined(_MSC_VER)
    00589 #       pragma warning(pop)
    00590 #endif
    00591
    00592 #endif  // end of guard _CEGUIImageset_h_