1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
\r
2 // This file is part of the "Irrlicht Engine".
\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
\r
5 #ifndef __C_GUI_IMAGE_H_INCLUDED__
\r
6 #define __C_GUI_IMAGE_H_INCLUDED__
\r
8 #include "IrrCompileConfig.h"
\r
9 #ifdef _IRR_COMPILE_WITH_GUI_
\r
11 #include "IGUIImage.h"
\r
18 class CGUIImage : public IGUIImage
\r
23 CGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle);
\r
26 virtual ~CGUIImage();
\r
29 void setImage(video::ITexture* image) override;
\r
31 //! Gets the image texture
\r
32 video::ITexture* getImage() const override;
\r
34 //! sets the color of the image
\r
35 void setColor(video::SColor color) override;
\r
37 //! sets if the image should scale to fit the element
\r
38 void setScaleImage(bool scale) override;
\r
40 //! draws the element and its children
\r
41 void draw() override;
\r
43 //! sets if the image should use its alpha channel to draw itself
\r
44 void setUseAlphaChannel(bool use) override;
\r
46 //! Gets the color of the image
\r
47 video::SColor getColor() const override;
\r
49 //! Returns true if the image is scaled to fit, false if not
\r
50 bool isImageScaled() const override;
\r
52 //! Returns true if the image is using the alpha channel, false if not
\r
53 bool isAlphaChannelUsed() const override;
\r
55 //! Sets the source rectangle of the image. By default the full image is used.
\r
56 void setSourceRect(const core::rect<s32>& sourceRect) override;
\r
58 //! Returns the customized source rectangle of the image to be used.
\r
59 core::rect<s32> getSourceRect() const override;
\r
61 //! Restrict drawing-area.
\r
62 void setDrawBounds(const core::rect<f32>& drawBoundUVs) override;
\r
64 //! Get drawing-area restrictions.
\r
65 core::rect<f32> getDrawBounds() const override;
\r
67 //! Sets whether to draw a background color (EGDC_3D_DARK_SHADOW) when no texture is set
\r
68 void setDrawBackground(bool draw) override
\r
70 DrawBackground = draw;
\r
73 //! Checks if a background is drawn when no texture is set
\r
74 bool isDrawBackgroundEnabled() const override
\r
76 return DrawBackground;
\r
80 void checkBounds(core::rect<s32>& rect)
\r
82 f32 clipWidth = (f32)rect.getWidth();
\r
83 f32 clipHeight = (f32)rect.getHeight();
\r
85 rect.UpperLeftCorner.X += core::round32(DrawBounds.UpperLeftCorner.X*clipWidth);
\r
86 rect.UpperLeftCorner.Y += core::round32(DrawBounds.UpperLeftCorner.Y*clipHeight);
\r
87 rect.LowerRightCorner.X -= core::round32((1.f-DrawBounds.LowerRightCorner.X)*clipWidth);
\r
88 rect.LowerRightCorner.Y -= core::round32((1.f-DrawBounds.LowerRightCorner.Y)*clipHeight);
\r
92 video::ITexture* Texture;
\r
93 video::SColor Color;
\r
94 bool UseAlphaChannel;
\r
96 core::rect<s32> SourceRect;
\r
97 core::rect<f32> DrawBounds;
\r
98 bool DrawBackground;
\r
102 } // end namespace gui
\r
103 } // end namespace irr
\r
105 #endif // _IRR_COMPILE_WITH_GUI_
\r
107 #endif // __C_GUI_IMAGE_H_INCLUDED__
\r