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 #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
00047 namespace CEGUI
00048 {
00049
00058 class CEGUIBASE_API Imageset
00059 {
00060 friend class Imageset_xmlHandler;
00061 private:
00062 typedef std::map<String, Image> ImageRegistry;
00063
00064
00065
00066
00067 friend Imageset* ImagesetManager::createImageset(const String& name, Texture* texture);
00068 friend Imageset* ImagesetManager::createImageset(const String& filename, const String& resourceGroup);
00069 friend void ImagesetManager::destroyImageset(const String& name);
00070
00071
00072
00073
00074
00075
00083 Imageset(const String& name, Texture* texture);
00084
00085
00099 Imageset(const String& filename, const String& resourceGroup);
00100
00101
00102 public:
00107 ~Imageset(void);
00108
00109
00110 public:
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
00185
00193 void undefineAllImages(void);
00194
00195
00208 Size getImageSize(const String& name) const {return getImage(name).getSize();}
00209
00210
00223 float getImageWidth(const String& name) const {return getImage(name).getWidth();}
00224
00225
00238 float getImageHeight(const String& name) const {return getImage(name).getHeight();}
00239
00240
00253 Point getImageOffset(const String& name) const {return getImage(name).getOffsets();}
00254
00255
00268 float getImageOffsetX(const String& name) const {return getImage(name).getOffsetX();}
00269
00270
00283 float getImageOffsetY(const String& name) const {return getImage(name).getOffsetY();}
00284
00285
00307 void defineImage(const String& name, const Point& position, const Size& size, const Point& render_offset)
00308 {
00309 defineImage(name, Rect(position.d_x, position.d_y, position.d_x + size.d_width, position.d_y + size.d_height), render_offset);
00310 }
00311
00312
00331 void defineImage(const String& name, const Rect& image_rect, const Point& render_offset);
00332
00333
00359 void draw(const Rect& source_rect, const Rect& dest_rect, float z, const Rect& clip_rect,const ColourRect& colours, QuadSplitMode quad_split_mode) const;
00360
00361
00396 void draw(const Rect& source_rect, const Rect& dest_rect, float z, const Rect& clip_rect, const colour& top_left_colour = -1, const colour& top_right_colour = -1, const colour& bottom_left_colour = -1, const colour& bottom_right_colour = -1, QuadSplitMode quad_split_mode = TopLeftToBottomRight) const
00397 {
00398 draw(source_rect, dest_rect, z, clip_rect, ColourRect(top_left_colour, top_right_colour, bottom_left_colour, bottom_right_colour), quad_split_mode);
00399 }
00400
00401
00409 bool isAutoScaled(void) const {return d_autoScale;}
00410
00411
00419 Size getNativeResolution(void) const {return Size(d_nativeHorzRes, d_nativeVertRes);}
00420
00421
00432 void setAutoScalingEnabled(bool setting);
00433
00434
00445 void setNativeResolution(const Size& size);
00446
00447
00458 void notifyScreenResolution(const Size& size);
00459
00460
00465 ImageIterator getIterator(void) const;
00466
00467
00468 protected:
00469
00470
00471
00472 static const char ImagesetSchemaName[];
00473
00474
00475
00476
00477
00494 void load(const String& filename, const String& resourceGroup);
00495
00496
00501 void unload(void);
00502
00503
00516 void setTexture(Texture* texture);
00517
00518
00526 void updateImageScalingFactors(void);
00527
00528
00529
00530
00531 String d_name;
00532 ImageRegistry d_images;
00533 Texture* d_texture;
00534
00535
00536 bool d_autoScale;
00537 float d_horzScaling;
00538 float d_vertScaling;
00539 float d_nativeHorzRes;
00540 float d_nativeVertRes;
00541 };
00542
00543 }
00544
00545 #if defined(_MSC_VER)
00546 # pragma warning(pop)
00547 #endif
00548
00549 #endif // end of guard _CEGUIImageset_h_