Crazy Eddies GUI System  0.6.2
CEGUIImage.h
1 /***********************************************************************
2  filename: CEGUIImage.h
3  created: 13/3/2004
4  author: Paul D Turner
5 
6  purpose: Defines interface for Image 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 _CEGUIImage_h_
31 #define _CEGUIImage_h_
32 
33 #include "CEGUIBase.h"
34 #include "CEGUIString.h"
35 #include "CEGUIRect.h"
36 #include "CEGUIColourRect.h"
37 #include "CEGUIVector.h"
38 #include "CEGUISize.h"
39 #include "CEGUIRenderer.h"
40 #include "CEGUIXMLSerializer.h"
41 #include <map>
42 
43 
44 #if defined(_MSC_VER)
45 # pragma warning(push)
46 # pragma warning(disable : 4251)
47 #endif
48 
49 
50 // Start of CEGUI namespace section
51 namespace CEGUI
52 {
57 class CEGUIEXPORT Image
58 {
59 public:
67  Size getSize(void) const {return Size(d_scaledWidth, d_scaledHeight);}
68 
69 
77  float getWidth(void) const {return d_scaledWidth;}
78 
79 
87  float getHeight(void) const {return d_scaledHeight;}
88 
89 
97  Point getOffsets(void) const {return d_scaledOffset;}
98 
99 
107  float getOffsetX(void) const {return d_scaledOffset.d_x;}
108 
109 
117  float getOffsetY(void) const {return d_scaledOffset.d_y;}
118 
119 
127  const String& getName(void) const;
128 
129 
137  const String& getImagesetName(void) const;
138 
146  const Imageset* getImageset(void) const {return d_owner;}
147 
156  const Rect& getSourceTextureArea(void) const;
157 
195  void draw(const Vector3& position, const Size& size, 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
196  {
197  draw(Rect(position.d_x, position.d_y, position.d_x + size.d_width, position.d_y + size.d_height), position.d_z, clip_rect,
198  ColourRect(top_left_colour, top_right_colour, bottom_left_colour, bottom_right_colour), quad_split_mode);
199  }
200 
201 
239  void draw(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
240  {
241  draw(dest_rect, z, clip_rect, ColourRect(top_left_colour, top_right_colour, bottom_left_colour, bottom_right_colour), quad_split_mode);
242  }
243 
244 
273  void draw(const Vector3& position, const Size& size, const Rect& clip_rect, const ColourRect& colours, QuadSplitMode quad_split_mode = TopLeftToBottomRight) const
274  {
275  draw(Rect(position.d_x, position.d_y, position.d_x + size.d_width, position.d_y + size.d_height), position.d_z, clip_rect, colours, quad_split_mode);
276  }
277 
278 
307  void draw(const Vector3& position, const Rect& clip_rect, const ColourRect& colours, QuadSplitMode quad_split_mode = TopLeftToBottomRight) const
308  {
309  draw(Rect(position.d_x, position.d_y, position.d_x + getWidth(), position.d_y + getHeight()), position.d_z, clip_rect, colours, quad_split_mode);
310  }
311 
312 
347  void draw(const Vector3& position, 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
348  {
349  draw(Rect(position.d_x, position.d_y, position.d_x + getWidth(), position.d_y + getHeight()), position.d_z, clip_rect, ColourRect(top_left_colour, top_right_colour, bottom_left_colour, bottom_right_colour), quad_split_mode);
350  }
351 
352 
381  void draw(const Rect& dest_rect, float z, const Rect& clip_rect,const ColourRect& colours, QuadSplitMode quad_split_mode = TopLeftToBottomRight) const;
382 
383 
395  void writeXMLToStream(XMLSerializer& xml_stream) const;
396 
397 
398  friend class std::map<String, Image, String::FastLessCompare>;
399  friend struct std::pair<const String, Image>;
400 
401 
402  /*************************************************************************
403  Construction and Destruction
404  *************************************************************************/
409  Image(void) {}
410 
411 
436  Image(const Imageset* owner, const String& name, const Rect& area, const Point& render_offset, float horzScaling = 1.0f, float vertScaling = 1.0f);
437 
438 
439 
444  Image(const Image& image);
445 
446 
451  ~Image(void);
452 
453 
454 private:
455  /*************************************************************************
456  Friends
457  *************************************************************************/
458  friend class Imageset;
459 
460 
461  /*************************************************************************
462  Implementation Methods
463  *************************************************************************/
474  void setHorzScaling(float factor);
475 
476 
487  void setVertScaling(float factor);
488 
489 
490  /*************************************************************************
491  Implementation Data
492  *************************************************************************/
493  const Imageset* d_owner;
494  Rect d_area;
495  Point d_offset;
496 
497  // image auto-scaling fields.
498  float d_scaledWidth;
499  float d_scaledHeight;
500  Point d_scaledOffset;
501  String d_name;
502 };
503 
504 } // End of CEGUI namespace section
505 
506 #if defined(_MSC_VER)
507 # pragma warning(pop)
508 #endif
509 
510 #endif // end of guard _CEGUIImage_h_