00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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
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
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
00080
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:
00141 ~Imageset(void);
00142
00143
00144 public:
00145 typedef ConstBaseIterator<ImageRegistry> ImageIterator;
00146
00147
00148
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
00543
00544 static const char ImagesetSchemaName[];
00545
00546
00547
00548
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
00602
00603 String d_name;
00604 ImageRegistry d_images;
00605 Texture* d_texture;
00606 String d_textureFilename;
00607
00608
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 }
00618
00619 #if defined(_MSC_VER)
00620 # pragma warning(pop)
00621 #endif
00622
00623 #endif // end of guard _CEGUIImageset_h_