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 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
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
00528
00533 void unload(void);
00534
00535
00548 void setTexture(Texture* texture);
00549
00550
00558 void updateImageScalingFactors(void);
00559
00560
00561
00562
00563 String d_name;
00564 ImageRegistry d_images;
00565 Texture* d_texture;
00566 String d_textureFilename;
00567
00568
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 }
00578
00579 #if defined(_MSC_VER)
00580 # pragma warning(pop)
00581 #endif
00582
00583 #endif // end of guard _CEGUIImageset_h_