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 
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_
float getImageWidth(const String &name) const
return the width of the named image.
Definition: CEGUIImageset.h:222
Class used as a two dimensional vector (aka a Point)
Definition: CEGUIVector.h:45
Point getImageOffset(const String &name) const
return the rendering offsets applied to the named image.
Definition: CEGUIImageset.h:252
float getImageHeight(const String &name) const
return the height of the named image.
Definition: CEGUIImageset.h:237
Class that represents a single Image of an Imageset.
Definition: CEGUIImage.h:57
float getImageOffsetX(const String &name) const
return the x rendering offset for the named image.
Definition: CEGUIImageset.h:267
Texture * d_texture
Texture object that handles imagery for this Imageset.
Definition: CEGUIImageset.h:565
Diagonal split goes from top-left to bottom-right.
Definition: CEGUIRenderer.h:47
const String & getName(void) const
return String object holding the name of the Imageset
Definition: CEGUIImageset.h:133
static void setDefaultResourceGroup(const String &resourceGroup)
Sets the default resource group to be used when loading imageset data.
Definition: CEGUIImageset.h:511
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: CEGUIGeometryBuffer.h:42
Class that holds the size (width &amp; height) of something.
Definition: CEGUISize.h:43
void draw(GeometryBuffer &buffer, const Rect &source_rect, const Rect &dest_rect, 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
Queues an area of the associated Texture the be drawn on the screen. Low-level routine to be used car...
Definition: CEGUIImageset.h:409
Class representing colour values within the system.
Definition: CEGUIcolour.h:45
Class that holds details of colours for the four corners of a rectangle.
Definition: CEGUIColourRect.h:44
Offers functions to define, access, and draw, a set of image components on a single graphical surface...
Definition: CEGUIImageset.h:63
void defineImage(const String &name, const Point &position, const Size &size, const Point &render_offset)
Define a new Image for this Imageset.
Definition: CEGUIImageset.h:306
Base class constant iterator used to offer iteration over various collections within the system...
Definition: CEGUIIteratorBase.h:47
Size getImageSize(const String &name) const
return a Size object describing the dimensions of the named image.
Definition: CEGUIImageset.h:207
float d_nativeHorzRes
native horizontal resolution for this Imageset.
Definition: CEGUIImageset.h:572
ConstBaseIterator< ImageRegistry > ImageIterator
Iterator type for this collection.
Definition: CEGUIImageset.h:111
QuadSplitMode
Enumerated type that contains the valid diagonal-mode that specify how a quad is split into triangles...
Definition: CEGUIRenderer.h:44
static String d_defaultResourceGroup
Default resource group specifically for Imagesets.
Definition: CEGUIImageset.h:574
Abstract base class specifying the required interface for Texture objects.
Definition: CEGUITexture.h:50
Size getNativeResolution(void) const
Return the native display size for this Imageset. This is only relevant if the Imageset is being auto...
Definition: CEGUIImageset.h:440
float d_nativeVertRes
native vertical resolution for this Imageset.
Definition: CEGUIImageset.h:573
bool isImageDefined(const String &name) const
return true if an Image with the specified name exists.
Definition: CEGUIImageset.h:156
float d_horzScaling
current horizontal scaling factor.
Definition: CEGUIImageset.h:570
String d_name
Holds the name of this imageset.
Definition: CEGUIImageset.h:563
static const String & getDefaultResourceGroup()
Returns the default resource group currently set for Imagesets.
Definition: CEGUIImageset.h:522
bool d_autoScale
true when auto-scaling is enabled.
Definition: CEGUIImageset.h:569
float getImageOffsetY(const String &name) const
return the y rendering offset for the named image.
Definition: CEGUIImageset.h:282
String d_textureFilename
String holding the name of the texture filename (if any).
Definition: CEGUIImageset.h:566
bool isAutoScaled(void) const
Return whether this Imageset is auto-scaled.
Definition: CEGUIImageset.h:430
uint getImageCount(void) const
return number of images defined for this Imageset
Definition: CEGUIImageset.h:143
float d_vertScaling
current vertical scaling factor.
Definition: CEGUIImageset.h:571
ImageRegistry d_images
Registry of Image objects for the images defined for this Imageset.
Definition: CEGUIImageset.h:564
Texture * getTexture(void) const
return Texture object for this Imageset
Definition: CEGUIImageset.h:123
Class used to create XML Document.
Definition: CEGUIXMLSerializer.h:86
Class encapsulating operations on a Rectangle.
Definition: CEGUIRect.h:44
String class used within the GUI system.
Definition: CEGUIString.h:57