CEGUIImage.h

00001 /***********************************************************************
00002         filename:       CEGUIImage.h
00003         created:        13/3/2004
00004         author:         Paul D Turner
00005         
00006         purpose:        Defines interface for Image 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 _CEGUIImage_h_
00031 #define _CEGUIImage_h_
00032 
00033 #include "CEGUIBase.h"
00034 #include "CEGUIString.h"
00035 #include "CEGUIRect.h"
00036 #include "CEGUIColourRect.h"
00037 #include "CEGUIVector.h"
00038 #include "CEGUISize.h"
00039 #include "CEGUIRenderer.h"
00040 #include "CEGUIXMLSerializer.h" 
00041 #include <map>
00042 
00043 
00044 #if defined(_MSC_VER)
00045 #       pragma warning(push)
00046 #       pragma warning(disable : 4251)
00047 #endif
00048 
00049 
00050 // Start of CEGUI namespace section
00051 namespace CEGUI
00052 {
00057 class CEGUIEXPORT Image
00058 {
00059 public:
00067         Size    getSize(void) const                     {return Size(d_scaledWidth, d_scaledHeight);}
00068         
00069 
00077         float   getWidth(void) const            {return d_scaledWidth;}
00078 
00079 
00087         float   getHeight(void) const           {return d_scaledHeight;}
00088 
00089 
00097         Point   getOffsets(void) const          {return d_scaledOffset;}
00098 
00099 
00107         float   getOffsetX(void) const          {return d_scaledOffset.d_x;}
00108 
00109 
00117         float   getOffsetY(void) const          {return d_scaledOffset.d_y;}
00118 
00119 
00127         const String&   getName(void) const;
00128 
00129 
00137         const String&   getImagesetName(void) const;
00138 
00146         const Imageset* getImageset(void) const {return d_owner;}
00147 
00156     const Rect& getSourceTextureArea(void) const;
00157 
00195         void    draw(const Vector3& position, const Size& size, 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
00196         {
00197                 draw(Rect(position.d_x, position.d_y, position.d_x + size.d_width, position.d_y + size.d_height), position.d_z, clip_rect, 
00198                         ColourRect(top_left_colour, top_right_colour, bottom_left_colour, bottom_right_colour), quad_split_mode);
00199         }
00200 
00201 
00239         void    draw(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
00240         {
00241                 draw(dest_rect, z, clip_rect, ColourRect(top_left_colour, top_right_colour, bottom_left_colour, bottom_right_colour), quad_split_mode);
00242         }
00243 
00244 
00273         void    draw(const Vector3& position, const Size& size, const Rect& clip_rect, const ColourRect& colours, QuadSplitMode quad_split_mode = TopLeftToBottomRight) const
00274         {
00275                 draw(Rect(position.d_x, position.d_y, position.d_x + size.d_width, position.d_y + size.d_height), position.d_z, clip_rect, colours, quad_split_mode);
00276         }
00277 
00278 
00307         void    draw(const Vector3& position, const Rect& clip_rect, const ColourRect& colours, QuadSplitMode quad_split_mode = TopLeftToBottomRight) const
00308         {
00309                 draw(Rect(position.d_x, position.d_y, position.d_x + getWidth(), position.d_y + getHeight()), position.d_z, clip_rect, colours, quad_split_mode);
00310         }
00311 
00312 
00347         void    draw(const Vector3& position, 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
00348         {
00349                 draw(Rect(position.d_x, position.d_y, position.d_x + getWidth(), position.d_y + getHeight()), position.d_z, clip_rect, ColourRect(top_left_colour, top_right_colour, bottom_left_colour, bottom_right_colour), quad_split_mode);
00350         }
00351 
00352 
00381         void    draw(const Rect& dest_rect, float z, const Rect& clip_rect,const ColourRect& colours, QuadSplitMode quad_split_mode = TopLeftToBottomRight) const;
00382 
00383 
00395     void writeXMLToStream(XMLSerializer& xml_stream) const;
00396 
00397 
00398         friend class std::map<String, Image, String::FastLessCompare>;
00399         friend struct std::pair<const String, Image>;
00400 
00401 
00402         /*************************************************************************
00403                 Construction and Destruction
00404         *************************************************************************/
00409         Image(void) {}
00410 
00411 
00436         Image(const Imageset* owner, const String& name, const Rect& area, const Point& render_offset, float horzScaling = 1.0f, float vertScaling = 1.0f);
00437 
00438 
00439 
00444         Image(const Image& image);
00445 
00446 
00451         ~Image(void);
00452 
00453 
00454 private:
00455         /*************************************************************************
00456                 Friends
00457         *************************************************************************/
00458         friend class Imageset;
00459 
00460                 
00461         /*************************************************************************
00462                 Implementation Methods
00463         *************************************************************************/
00474         void    setHorzScaling(float factor);
00475 
00476 
00487         void    setVertScaling(float factor);
00488 
00489 
00490         /*************************************************************************
00491                 Implementation Data
00492         *************************************************************************/
00493         const Imageset* d_owner;                
00494         Rect                    d_area;                 
00495         Point                   d_offset;               
00496 
00497         // image auto-scaling fields.
00498         float   d_scaledWidth;          
00499         float   d_scaledHeight;         
00500         Point   d_scaledOffset;         
00501         String  d_name;                         
00502 };
00503 
00504 } // End of  CEGUI namespace section
00505 
00506 #if defined(_MSC_VER)
00507 #       pragma warning(pop)
00508 #endif
00509 
00510 #endif  // end of guard _CEGUIImage_h_

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