Crazy Eddies GUI System  0.7.8
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 
204  void draw(GeometryBuffer& buffer, const Vector2& position, const Size& size,
205  const Rect* clip_rect,
206  const colour& top_left_colour = 0xFFFFFFFF,
207  const colour& top_right_colour = 0xFFFFFFFF,
208  const colour& bottom_left_colour = 0xFFFFFFFF,
209  const colour& bottom_right_colour = 0xFFFFFFFF,
210  QuadSplitMode quad_split_mode = TopLeftToBottomRight) const
211  {
212  draw(buffer, Rect(position.d_x, position.d_y,
213  position.d_x + size.d_width,
214  position.d_y + size.d_height),
215  clip_rect,
216  ColourRect(top_left_colour, top_right_colour, bottom_left_colour,
217  bottom_right_colour),
218  quad_split_mode);
219  }
220 
265  void draw(GeometryBuffer& buffer, const Rect& dest_rect,
266  const Rect* clip_rect,
267  const colour& top_left_colour = 0xFFFFFFFF,
268  const colour& top_right_colour = 0xFFFFFFFF,
269  const colour& bottom_left_colour = 0xFFFFFFFF,
270  const colour& bottom_right_colour = 0xFFFFFFFF,
271  QuadSplitMode quad_split_mode = TopLeftToBottomRight) const
272  {
273  draw(buffer, dest_rect, clip_rect,
274  ColourRect(top_left_colour, top_right_colour,
275  bottom_left_colour, bottom_right_colour),
276  quad_split_mode);
277  }
278 
317  void draw(GeometryBuffer& buffer, const Vector2& position, const Size& size,
318  const Rect* clip_rect, const ColourRect& colours,
319  QuadSplitMode quad_split_mode = TopLeftToBottomRight) const
320  {
321  draw(buffer, Rect(position.d_x, position.d_y,
322  position.d_x + size.d_width,
323  position.d_y + size.d_height),
324  clip_rect, colours, quad_split_mode);
325  }
326 
365  void draw(GeometryBuffer& buffer, const Vector2& position,
366  const Rect* clip_rect, const ColourRect& colours,
367  QuadSplitMode quad_split_mode = TopLeftToBottomRight) const
368  {
369  draw(buffer, Rect(position.d_x, position.d_y,
370  position.d_x + getWidth(),
371  position.d_y + getHeight()),
372  clip_rect, colours, quad_split_mode);
373  }
374 
418  void draw(GeometryBuffer& buffer, const Vector2& position,
419  const Rect* clip_rect,
420  const colour& top_left_colour = 0xFFFFFFFF,
421  const colour& top_right_colour = 0xFFFFFFFF,
422  const colour& bottom_left_colour = 0xFFFFFFFF,
423  const colour& bottom_right_colour = 0xFFFFFFFF,
424  QuadSplitMode quad_split_mode = TopLeftToBottomRight) const
425  {
426  draw(buffer, Rect(position.d_x, position.d_y,
427  position.d_x + getWidth(),
428  position.d_y + getHeight()),
429  clip_rect,
430  ColourRect(top_left_colour, top_right_colour,
431  bottom_left_colour, bottom_right_colour),
432  quad_split_mode);
433  }
434 
471  void draw(GeometryBuffer& buffer, const Rect& dest_rect,
472  const Rect* clip_rect, const ColourRect& colours,
473  QuadSplitMode quad_split_mode = TopLeftToBottomRight) const;
474 
486  void writeXMLToStream(XMLSerializer& xml_stream) const;
487 
488 
489  friend class std::map<String, Image, String::FastLessCompare>;
490  friend struct std::pair<const String, Image>;
491 
492 
493  /*************************************************************************
494  Construction and Destruction
495  *************************************************************************/
500  Image(void) {}
501 
502 
527  Image(const Imageset* owner, const String& name, const Rect& area, const Point& render_offset, float horzScaling = 1.0f, float vertScaling = 1.0f);
528 
529 
530 
535  Image(const Image& image);
536 
537 
542  ~Image(void);
543 
544 
545 private:
546  /*************************************************************************
547  Friends
548  *************************************************************************/
549  friend class Imageset;
550 
551 
552  /*************************************************************************
553  Implementation Methods
554  *************************************************************************/
565  void setHorzScaling(float factor);
566 
567 
578  void setVertScaling(float factor);
579 
580 
581  /*************************************************************************
582  Implementation Data
583  *************************************************************************/
584  const Imageset* d_owner;
585  Rect d_area;
586  Point d_offset;
587 
588  // image auto-scaling fields.
589  float d_scaledWidth;
590  float d_scaledHeight;
591  Point d_scaledOffset;
592  String d_name;
593 };
594 
595 } // End of CEGUI namespace section
596 
597 #if defined(_MSC_VER)
598 # pragma warning(pop)
599 #endif
600 
601 #endif // end of guard _CEGUIImage_h_