Crazy Eddies GUI System  0.7.9
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
CEGUIImageset.h
1 /***********************************************************************
2  filename: CEGUIImageset.h
3  created: 21/2/2004
4  author: Paul D Turner
5 
6  purpose: Defines the interface for the Imageset class
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUIImageset_h_
31 #define _CEGUIImageset_h_
32 
33 #include "CEGUIBase.h"
34 #include "CEGUIString.h"
35 #include "CEGUIRect.h"
36 #include "CEGUIColourRect.h"
37 #include "CEGUIImagesetManager.h"
38 #include "CEGUIImage.h"
39 #include "CEGUIIteratorBase.h"
40 #include "CEGUIXMLSerializer.h"
41 
42 #include <map>
43 
44 
45 #if defined(_MSC_VER)
46 # pragma warning(push)
47 # pragma warning(disable : 4251)
48 #endif
49 
50 
51 // Start of CEGUI namespace section
52 namespace CEGUI
53 {
54 
63 class CEGUIEXPORT Imageset
64 {
65  typedef std::map<String, Image, String::FastLessCompare> ImageRegistry;
66 
67 public:
75  Imageset(const String& name, Texture& texture);
76 
102  Imageset(const String& name, const String& filename, const String& resourceGroup);
103 
108  ~Imageset(void);
109 
110 
112 
113  /*************************************************************************
114  Public interface
115  *************************************************************************/
123  Texture* getTexture(void) const {return d_texture;}
124 
125 
133  const String& getName(void) const {return d_name;}
134 
135 
143  uint getImageCount(void) const {return (uint)d_images.size();}
144 
145 
156  bool isImageDefined(const String& name) const {return d_images.find(name) != d_images.end();}
157 
158 
171  const Image& getImage(const String& name) const;
172 
173 
183  void undefineImage(const String& name);
184 
192  void undefineAllImages(void);
193 
194 
207  Size getImageSize(const String& name) const {return getImage(name).getSize();}
208 
209 
222  float getImageWidth(const String& name) const {return getImage(name).getWidth();}
223 
224 
237  float getImageHeight(const String& name) const {return getImage(name).getHeight();}
238 
239 
252  Point getImageOffset(const String& name) const {return getImage(name).getOffsets();}
253 
254 
267  float getImageOffsetX(const String& name) const {return getImage(name).getOffsetX();}
268 
269 
282  float getImageOffsetY(const String& name) const {return getImage(name).getOffsetY();}
283 
284 
306  void defineImage(const String& name, const Point& position, const Size& size, const Point& render_offset)
307  {
308  defineImage(name, Rect(position.d_x, position.d_y, position.d_x + size.d_width, position.d_y + size.d_height), render_offset);
309  }
310 
311 
330  void defineImage(const String& name, const Rect& image_rect, const Point& render_offset);
331 
332 
365  void draw(GeometryBuffer& buffer, const Rect& source_rect,
366  const Rect& dest_rect, const Rect* clip_rect,
367  const ColourRect& colours, QuadSplitMode quad_split_mode) const;
368 
409  void draw(GeometryBuffer& buffer, const Rect& source_rect,
410  const Rect& dest_rect, const Rect* clip_rect,
411  const colour& top_left_colour = 0xFFFFFFFF,
412  const colour& top_right_colour = 0xFFFFFFFF,
413  const colour& bottom_left_colour = 0xFFFFFFFF,
414  const colour& bottom_right_colour = 0xFFFFFFFF,
415  QuadSplitMode quad_split_mode = TopLeftToBottomRight) const
416  {
417  draw(buffer, source_rect, dest_rect, clip_rect,
418  ColourRect(top_left_colour, top_right_colour,
419  bottom_left_colour, bottom_right_colour),
420  quad_split_mode);
421  }
422 
430  bool isAutoScaled(void) const {return d_autoScale;}
431 
432 
440  Size getNativeResolution(void) const {return Size(d_nativeHorzRes, d_nativeVertRes);}
441 
442 
453  void setAutoScalingEnabled(bool setting);
454 
455 
466  void setNativeResolution(const Size& size);
467 
468 
476  void notifyDisplaySizeChanged(const Size& size);
477 
478 
483  ImageIterator getIterator(void) const;
484 
485 
499  void writeXMLToStream(XMLSerializer& xml_stream) const;
500 
511  static void setDefaultResourceGroup(const String& resourceGroup)
512  { d_defaultResourceGroup = resourceGroup; }
513 
522  static const String& getDefaultResourceGroup()
523  { return d_defaultResourceGroup; }
524 
525 protected:
526  /*************************************************************************
527  Implementation Functions
528  *************************************************************************/
533  void unload(void);
534 
535 
548  void setTexture(Texture* texture);
549 
550 
558  void updateImageScalingFactors(void);
559 
560  /*************************************************************************
561  Implementation Data
562  *************************************************************************/
564  ImageRegistry d_images;
567 
568  // auto-scaling fields
569  bool d_autoScale;
575 };
576 
577 } // End of CEGUI namespace section
578 
579 #if defined(_MSC_VER)
580 # pragma warning(pop)
581 #endif
582 
583 #endif // end of guard _CEGUIImageset_h_