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 #include "IGUIImage.h"
\r
16 class CGUIImage : public IGUIImage
\r
21 CGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle);
\r
24 virtual ~CGUIImage();
\r
27 void setImage(video::ITexture* image) override;
\r
29 //! Gets the image texture
\r
30 video::ITexture* getImage() const override;
\r
32 //! sets the color of the image
\r
33 void setColor(video::SColor color) override;
\r
35 //! sets if the image should scale to fit the element
\r
36 void setScaleImage(bool scale) override;
\r
38 //! draws the element and its children
\r
39 void draw() override;
\r
41 //! sets if the image should use its alpha channel to draw itself
\r
42 void setUseAlphaChannel(bool use) override;
\r
44 //! Gets the color of the image
\r
45 video::SColor getColor() const override;
\r
47 //! Returns true if the image is scaled to fit, false if not
\r
48 bool isImageScaled() const override;
\r
50 //! Returns true if the image is using the alpha channel, false if not
\r
51 bool isAlphaChannelUsed() const override;
\r
53 //! Sets the source rectangle of the image. By default the full image is used.
\r
54 void setSourceRect(const core::rect<s32>& sourceRect) override;
\r
56 //! Returns the customized source rectangle of the image to be used.
\r
57 core::rect<s32> getSourceRect() const override;
\r
59 //! Restrict drawing-area.
\r
60 void setDrawBounds(const core::rect<f32>& drawBoundUVs) override;
\r
62 //! Get drawing-area restrictions.
\r
63 core::rect<f32> getDrawBounds() const override;
\r
65 //! Sets whether to draw a background color (EGDC_3D_DARK_SHADOW) when no texture is set
\r
66 void setDrawBackground(bool draw) override
\r
68 DrawBackground = draw;
\r
71 //! Checks if a background is drawn when no texture is set
\r
72 bool isDrawBackgroundEnabled() const override
\r
74 return DrawBackground;
\r
78 void checkBounds(core::rect<s32>& rect)
\r
80 f32 clipWidth = (f32)rect.getWidth();
\r
81 f32 clipHeight = (f32)rect.getHeight();
\r
83 rect.UpperLeftCorner.X += core::round32(DrawBounds.UpperLeftCorner.X*clipWidth);
\r
84 rect.UpperLeftCorner.Y += core::round32(DrawBounds.UpperLeftCorner.Y*clipHeight);
\r
85 rect.LowerRightCorner.X -= core::round32((1.f-DrawBounds.LowerRightCorner.X)*clipWidth);
\r
86 rect.LowerRightCorner.Y -= core::round32((1.f-DrawBounds.LowerRightCorner.Y)*clipHeight);
\r
90 video::ITexture* Texture;
\r
91 video::SColor Color;
\r
92 bool UseAlphaChannel;
\r
94 core::rect<s32> SourceRect;
\r
95 core::rect<f32> DrawBounds;
\r
96 bool DrawBackground;
\r
100 } // end namespace gui
\r
101 } // end namespace irr
\r
103 #endif // __C_GUI_IMAGE_H_INCLUDED__
\r