Crazy Eddies GUI System
0.7.6
|
00001 /*********************************************************************** 00002 filename: CEGUIImage.h 00003 created: 13/3/2004 00004 author: Paul D Turner 00005 00006 purpose: Defines interface for Image class 00007 *************************************************************************/ 00008 /*************************************************************************** 00009 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00010 * 00011 * Permission is hereby granted, free of charge, to any person obtaining 00012 * a copy of this software and associated documentation files (the 00013 * "Software"), to deal in the Software without restriction, including 00014 * without limitation the rights to use, copy, modify, merge, publish, 00015 * distribute, sublicense, and/or sell copies of the Software, and to 00016 * permit persons to whom the Software is furnished to do so, subject to 00017 * the following conditions: 00018 * 00019 * The above copyright notice and this permission notice shall be 00020 * included in all copies or substantial portions of the Software. 00021 * 00022 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00023 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00024 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00025 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00026 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00027 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00028 * OTHER DEALINGS IN THE SOFTWARE. 00029 ***************************************************************************/ 00030 #ifndef _CEGUIImage_h_ 00031 #define _CEGUIImage_h_ 00032 00033 #include "CEGUIBase.h" 00034 #include "CEGUIString.h" 00035 #include "CEGUIRect.h" 00036 #include "CEGUIColourRect.h" 00037 #include "CEGUIVector.h" 00038 #include "CEGUISize.h" 00039 #include "CEGUIRenderer.h" 00040 #include "CEGUIXMLSerializer.h" 00041 #include <map> 00042 00043 00044 #if defined(_MSC_VER) 00045 # pragma warning(push) 00046 # pragma warning(disable : 4251) 00047 #endif 00048 00049 00050 // Start of CEGUI namespace section 00051 namespace CEGUI 00052 { 00057 class CEGUIEXPORT Image 00058 { 00059 public: 00067 Size getSize(void) const {return Size(d_scaledWidth, d_scaledHeight);} 00068 00069 00077 float getWidth(void) const {return d_scaledWidth;} 00078 00079 00087 float getHeight(void) const {return d_scaledHeight;} 00088 00089 00097 Point getOffsets(void) const {return d_scaledOffset;} 00098 00099 00107 float getOffsetX(void) const {return d_scaledOffset.d_x;} 00108 00109 00117 float getOffsetY(void) const {return d_scaledOffset.d_y;} 00118 00119 00127 const String& getName(void) const; 00128 00129 00137 const String& getImagesetName(void) const; 00138 00146 const Imageset* getImageset(void) const {return d_owner;} 00147 00156 const Rect& getSourceTextureArea(void) const; 00157 00204 void draw(GeometryBuffer& buffer, const Vector2& position, const Size& size, 00205 const Rect* clip_rect, 00206 const colour& top_left_colour = 0xFFFFFFFF, 00207 const colour& top_right_colour = 0xFFFFFFFF, 00208 const colour& bottom_left_colour = 0xFFFFFFFF, 00209 const colour& bottom_right_colour = 0xFFFFFFFF, 00210 QuadSplitMode quad_split_mode = TopLeftToBottomRight) const 00211 { 00212 draw(buffer, Rect(position.d_x, position.d_y, 00213 position.d_x + size.d_width, 00214 position.d_y + size.d_height), 00215 clip_rect, 00216 ColourRect(top_left_colour, top_right_colour, bottom_left_colour, 00217 bottom_right_colour), 00218 quad_split_mode); 00219 } 00220 00265 void draw(GeometryBuffer& buffer, const Rect& dest_rect, 00266 const Rect* clip_rect, 00267 const colour& top_left_colour = 0xFFFFFFFF, 00268 const colour& top_right_colour = 0xFFFFFFFF, 00269 const colour& bottom_left_colour = 0xFFFFFFFF, 00270 const colour& bottom_right_colour = 0xFFFFFFFF, 00271 QuadSplitMode quad_split_mode = TopLeftToBottomRight) const 00272 { 00273 draw(buffer, dest_rect, clip_rect, 00274 ColourRect(top_left_colour, top_right_colour, 00275 bottom_left_colour, bottom_right_colour), 00276 quad_split_mode); 00277 } 00278 00317 void draw(GeometryBuffer& buffer, const Vector2& position, const Size& size, 00318 const Rect* clip_rect, const ColourRect& colours, 00319 QuadSplitMode quad_split_mode = TopLeftToBottomRight) const 00320 { 00321 draw(buffer, Rect(position.d_x, position.d_y, 00322 position.d_x + size.d_width, 00323 position.d_y + size.d_height), 00324 clip_rect, colours, quad_split_mode); 00325 } 00326 00365 void draw(GeometryBuffer& buffer, const Vector2& position, 00366 const Rect* clip_rect, const ColourRect& colours, 00367 QuadSplitMode quad_split_mode = TopLeftToBottomRight) const 00368 { 00369 draw(buffer, Rect(position.d_x, position.d_y, 00370 position.d_x + getWidth(), 00371 position.d_y + getHeight()), 00372 clip_rect, colours, quad_split_mode); 00373 } 00374 00418 void draw(GeometryBuffer& buffer, const Vector2& position, 00419 const Rect* clip_rect, 00420 const colour& top_left_colour = 0xFFFFFFFF, 00421 const colour& top_right_colour = 0xFFFFFFFF, 00422 const colour& bottom_left_colour = 0xFFFFFFFF, 00423 const colour& bottom_right_colour = 0xFFFFFFFF, 00424 QuadSplitMode quad_split_mode = TopLeftToBottomRight) const 00425 { 00426 draw(buffer, Rect(position.d_x, position.d_y, 00427 position.d_x + getWidth(), 00428 position.d_y + getHeight()), 00429 clip_rect, 00430 ColourRect(top_left_colour, top_right_colour, 00431 bottom_left_colour, bottom_right_colour), 00432 quad_split_mode); 00433 } 00434 00471 void draw(GeometryBuffer& buffer, const Rect& dest_rect, 00472 const Rect* clip_rect, const ColourRect& colours, 00473 QuadSplitMode quad_split_mode = TopLeftToBottomRight) const; 00474 00486 void writeXMLToStream(XMLSerializer& xml_stream) const; 00487 00488 00489 friend class std::map<String, Image, String::FastLessCompare>; 00490 friend struct std::pair<const String, Image>; 00491 00492 00493 /************************************************************************* 00494 Construction and Destruction 00495 *************************************************************************/ 00500 Image(void) {} 00501 00502 00527 Image(const Imageset* owner, const String& name, const Rect& area, const Point& render_offset, float horzScaling = 1.0f, float vertScaling = 1.0f); 00528 00529 00530 00535 Image(const Image& image); 00536 00537 00542 ~Image(void); 00543 00544 00545 private: 00546 /************************************************************************* 00547 Friends 00548 *************************************************************************/ 00549 friend class Imageset; 00550 00551 00552 /************************************************************************* 00553 Implementation Methods 00554 *************************************************************************/ 00565 void setHorzScaling(float factor); 00566 00567 00578 void setVertScaling(float factor); 00579 00580 00581 /************************************************************************* 00582 Implementation Data 00583 *************************************************************************/ 00584 const Imageset* d_owner; 00585 Rect d_area; 00586 Point d_offset; 00587 00588 // image auto-scaling fields. 00589 float d_scaledWidth; 00590 float d_scaledHeight; 00591 Point d_scaledOffset; 00592 String d_name; 00593 }; 00594 00595 } // End of CEGUI namespace section 00596 00597 #if defined(_MSC_VER) 00598 # pragma warning(pop) 00599 #endif 00600 00601 #endif // end of guard _CEGUIImage_h_