Crazy Eddies GUI System
0.7.6
|
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 typedef std::map<String, Image, String::FastLessCompare> ImageRegistry; 00066 00067 public: 00075 Imageset(const String& name, Texture& texture); 00076 00102 Imageset(const String& name, const String& filename, const String& resourceGroup); 00103 00108 ~Imageset(void); 00109 00110 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 00192 void undefineAllImages(void); 00193 00194 00207 Size getImageSize(const String& name) const {return getImage(name).getSize();} 00208 00209 00222 float getImageWidth(const String& name) const {return getImage(name).getWidth();} 00223 00224 00237 float getImageHeight(const String& name) const {return getImage(name).getHeight();} 00238 00239 00252 Point getImageOffset(const String& name) const {return getImage(name).getOffsets();} 00253 00254 00267 float getImageOffsetX(const String& name) const {return getImage(name).getOffsetX();} 00268 00269 00282 float getImageOffsetY(const String& name) const {return getImage(name).getOffsetY();} 00283 00284 00306 void defineImage(const String& name, const Point& position, const Size& size, const Point& render_offset) 00307 { 00308 defineImage(name, Rect(position.d_x, position.d_y, position.d_x + size.d_width, position.d_y + size.d_height), render_offset); 00309 } 00310 00311 00330 void defineImage(const String& name, const Rect& image_rect, const Point& render_offset); 00331 00332 00365 void draw(GeometryBuffer& buffer, const Rect& source_rect, 00366 const Rect& dest_rect, const Rect* clip_rect, 00367 const ColourRect& colours, QuadSplitMode quad_split_mode) const; 00368 00409 void draw(GeometryBuffer& buffer, const Rect& source_rect, 00410 const Rect& dest_rect, const Rect* clip_rect, 00411 const colour& top_left_colour = 0xFFFFFFFF, 00412 const colour& top_right_colour = 0xFFFFFFFF, 00413 const colour& bottom_left_colour = 0xFFFFFFFF, 00414 const colour& bottom_right_colour = 0xFFFFFFFF, 00415 QuadSplitMode quad_split_mode = TopLeftToBottomRight) const 00416 { 00417 draw(buffer, source_rect, dest_rect, clip_rect, 00418 ColourRect(top_left_colour, top_right_colour, 00419 bottom_left_colour, bottom_right_colour), 00420 quad_split_mode); 00421 } 00422 00430 bool isAutoScaled(void) const {return d_autoScale;} 00431 00432 00440 Size getNativeResolution(void) const {return Size(d_nativeHorzRes, d_nativeVertRes);} 00441 00442 00453 void setAutoScalingEnabled(bool setting); 00454 00455 00466 void setNativeResolution(const Size& size); 00467 00468 00476 void notifyDisplaySizeChanged(const Size& size); 00477 00478 00483 ImageIterator getIterator(void) const; 00484 00485 00499 void writeXMLToStream(XMLSerializer& xml_stream) const; 00500 00511 static void setDefaultResourceGroup(const String& resourceGroup) 00512 { d_defaultResourceGroup = resourceGroup; } 00513 00522 static const String& getDefaultResourceGroup() 00523 { return d_defaultResourceGroup; } 00524 00525 protected: 00526 /************************************************************************* 00527 Implementation Functions 00528 *************************************************************************/ 00533 void unload(void); 00534 00535 00548 void setTexture(Texture* texture); 00549 00550 00558 void updateImageScalingFactors(void); 00559 00560 /************************************************************************* 00561 Implementation Data 00562 *************************************************************************/ 00563 String d_name; 00564 ImageRegistry d_images; 00565 Texture* d_texture; 00566 String d_textureFilename; 00567 00568 // auto-scaling fields 00569 bool d_autoScale; 00570 float d_horzScaling; 00571 float d_vertScaling; 00572 float d_nativeHorzRes; 00573 float d_nativeVertRes; 00574 static String d_defaultResourceGroup; 00575 }; 00576 00577 } // End of CEGUI namespace section 00578 00579 #if defined(_MSC_VER) 00580 # pragma warning(pop) 00581 #endif 00582 00583 #endif // end of guard _CEGUIImageset_h_