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