]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/CGUIImage.h
Drop _IRR_COMPILE_WITH_GUI_
[irrlicht.git] / source / Irrlicht / CGUIImage.h
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
4 \r
5 #ifndef __C_GUI_IMAGE_H_INCLUDED__\r
6 #define __C_GUI_IMAGE_H_INCLUDED__\r
7 \r
8 #include "IrrCompileConfig.h"\r
9 #include "IGUIImage.h"\r
10 \r
11 namespace irr\r
12 {\r
13 namespace gui\r
14 {\r
15 \r
16         class CGUIImage : public IGUIImage\r
17         {\r
18         public:\r
19 \r
20                 //! constructor\r
21                 CGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle);\r
22 \r
23                 //! destructor\r
24                 virtual ~CGUIImage();\r
25 \r
26                 //! sets an image\r
27                 void setImage(video::ITexture* image) override;\r
28 \r
29                 //! Gets the image texture\r
30                 video::ITexture* getImage() const override;\r
31 \r
32                 //! sets the color of the image\r
33                 void setColor(video::SColor color) override;\r
34 \r
35                 //! sets if the image should scale to fit the element\r
36                 void setScaleImage(bool scale) override;\r
37 \r
38                 //! draws the element and its children\r
39                 void draw() override;\r
40 \r
41                 //! sets if the image should use its alpha channel to draw itself\r
42                 void setUseAlphaChannel(bool use) override;\r
43 \r
44                 //! Gets the color of the image\r
45                 video::SColor getColor() const override;\r
46 \r
47                 //! Returns true if the image is scaled to fit, false if not\r
48                 bool isImageScaled() const override;\r
49 \r
50                 //! Returns true if the image is using the alpha channel, false if not\r
51                 bool isAlphaChannelUsed() const override;\r
52 \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
55 \r
56                 //! Returns the customized source rectangle of the image to be used.\r
57                 core::rect<s32> getSourceRect() const override;\r
58 \r
59                 //! Restrict drawing-area.\r
60                 void setDrawBounds(const core::rect<f32>& drawBoundUVs) override;\r
61 \r
62                 //! Get drawing-area restrictions.\r
63                 core::rect<f32> getDrawBounds() const override;\r
64 \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
67                 {\r
68                         DrawBackground = draw;\r
69                 }\r
70 \r
71                 //! Checks if a background is drawn when no texture is set\r
72                 bool isDrawBackgroundEnabled() const  override\r
73                 {\r
74                         return DrawBackground;\r
75                 }\r
76 \r
77         protected:\r
78                 void checkBounds(core::rect<s32>& rect)\r
79                 {\r
80                         f32 clipWidth = (f32)rect.getWidth();\r
81                         f32 clipHeight = (f32)rect.getHeight();\r
82 \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
87                 }\r
88 \r
89         private:\r
90                 video::ITexture* Texture;\r
91                 video::SColor Color;\r
92                 bool UseAlphaChannel;\r
93                 bool ScaleImage;\r
94                 core::rect<s32> SourceRect;\r
95                 core::rect<f32> DrawBounds;\r
96                 bool DrawBackground;\r
97         };\r
98 \r
99 \r
100 } // end namespace gui\r
101 } // end namespace irr\r
102 \r
103 #endif // __C_GUI_IMAGE_H_INCLUDED__\r