diff options
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CGUIImage.cpp')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/CGUIImage.cpp | 328 |
1 files changed, 164 insertions, 164 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CGUIImage.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CGUIImage.cpp index 17d30e0..cb377e9 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/CGUIImage.cpp +++ b/libraries/irrlicht-1.8/source/Irrlicht/CGUIImage.cpp | |||
@@ -1,164 +1,164 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt | 1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt |
2 | // This file is part of the "Irrlicht Engine". | 2 | // This file is part of the "Irrlicht Engine". |
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | 3 | // For conditions of distribution and use, see copyright notice in irrlicht.h |
4 | 4 | ||
5 | #include "CGUIImage.h" | 5 | #include "CGUIImage.h" |
6 | #ifdef _IRR_COMPILE_WITH_GUI_ | 6 | #ifdef _IRR_COMPILE_WITH_GUI_ |
7 | 7 | ||
8 | #include "IGUISkin.h" | 8 | #include "IGUISkin.h" |
9 | #include "IGUIEnvironment.h" | 9 | #include "IGUIEnvironment.h" |
10 | #include "IVideoDriver.h" | 10 | #include "IVideoDriver.h" |
11 | 11 | ||
12 | namespace irr | 12 | namespace irr |
13 | { | 13 | { |
14 | namespace gui | 14 | namespace gui |
15 | { | 15 | { |
16 | 16 | ||
17 | 17 | ||
18 | //! constructor | 18 | //! constructor |
19 | CGUIImage::CGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) | 19 | CGUIImage::CGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) |
20 | : IGUIImage(environment, parent, id, rectangle), Texture(0), Color(255,255,255,255), | 20 | : IGUIImage(environment, parent, id, rectangle), Texture(0), Color(255,255,255,255), |
21 | UseAlphaChannel(false), ScaleImage(false) | 21 | UseAlphaChannel(false), ScaleImage(false) |
22 | { | 22 | { |
23 | #ifdef _DEBUG | 23 | #ifdef _DEBUG |
24 | setDebugName("CGUIImage"); | 24 | setDebugName("CGUIImage"); |
25 | #endif | 25 | #endif |
26 | } | 26 | } |
27 | 27 | ||
28 | 28 | ||
29 | //! destructor | 29 | //! destructor |
30 | CGUIImage::~CGUIImage() | 30 | CGUIImage::~CGUIImage() |
31 | { | 31 | { |
32 | if (Texture) | 32 | if (Texture) |
33 | Texture->drop(); | 33 | Texture->drop(); |
34 | } | 34 | } |
35 | 35 | ||
36 | 36 | ||
37 | //! sets an image | 37 | //! sets an image |
38 | void CGUIImage::setImage(video::ITexture* image) | 38 | void CGUIImage::setImage(video::ITexture* image) |
39 | { | 39 | { |
40 | if (image == Texture) | 40 | if (image == Texture) |
41 | return; | 41 | return; |
42 | 42 | ||
43 | if (Texture) | 43 | if (Texture) |
44 | Texture->drop(); | 44 | Texture->drop(); |
45 | 45 | ||
46 | Texture = image; | 46 | Texture = image; |
47 | 47 | ||
48 | if (Texture) | 48 | if (Texture) |
49 | Texture->grab(); | 49 | Texture->grab(); |
50 | } | 50 | } |
51 | 51 | ||
52 | //! Gets the image texture | 52 | //! Gets the image texture |
53 | video::ITexture* CGUIImage::getImage() const | 53 | video::ITexture* CGUIImage::getImage() const |
54 | { | 54 | { |
55 | return Texture; | 55 | return Texture; |
56 | } | 56 | } |
57 | 57 | ||
58 | //! sets the color of the image | 58 | //! sets the color of the image |
59 | void CGUIImage::setColor(video::SColor color) | 59 | void CGUIImage::setColor(video::SColor color) |
60 | { | 60 | { |
61 | Color = color; | 61 | Color = color; |
62 | } | 62 | } |
63 | 63 | ||
64 | //! Gets the color of the image | 64 | //! Gets the color of the image |
65 | video::SColor CGUIImage::getColor() const | 65 | video::SColor CGUIImage::getColor() const |
66 | { | 66 | { |
67 | return Color; | 67 | return Color; |
68 | } | 68 | } |
69 | 69 | ||
70 | //! draws the element and its children | 70 | //! draws the element and its children |
71 | void CGUIImage::draw() | 71 | void CGUIImage::draw() |
72 | { | 72 | { |
73 | if (!IsVisible) | 73 | if (!IsVisible) |
74 | return; | 74 | return; |
75 | 75 | ||
76 | IGUISkin* skin = Environment->getSkin(); | 76 | IGUISkin* skin = Environment->getSkin(); |
77 | video::IVideoDriver* driver = Environment->getVideoDriver(); | 77 | video::IVideoDriver* driver = Environment->getVideoDriver(); |
78 | 78 | ||
79 | if (Texture) | 79 | if (Texture) |
80 | { | 80 | { |
81 | if (ScaleImage) | 81 | if (ScaleImage) |
82 | { | 82 | { |
83 | const video::SColor Colors[] = {Color,Color,Color,Color}; | 83 | const video::SColor Colors[] = {Color,Color,Color,Color}; |
84 | 84 | ||
85 | driver->draw2DImage(Texture, AbsoluteRect, | 85 | driver->draw2DImage(Texture, AbsoluteRect, |
86 | core::rect<s32>(core::position2d<s32>(0,0), core::dimension2di(Texture->getOriginalSize())), | 86 | core::rect<s32>(core::position2d<s32>(0,0), core::dimension2di(Texture->getOriginalSize())), |
87 | &AbsoluteClippingRect, Colors, UseAlphaChannel); | 87 | &AbsoluteClippingRect, Colors, UseAlphaChannel); |
88 | } | 88 | } |
89 | else | 89 | else |
90 | { | 90 | { |
91 | driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, | 91 | driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, |
92 | core::rect<s32>(core::position2d<s32>(0,0), core::dimension2di(Texture->getOriginalSize())), | 92 | core::rect<s32>(core::position2d<s32>(0,0), core::dimension2di(Texture->getOriginalSize())), |
93 | &AbsoluteClippingRect, Color, UseAlphaChannel); | 93 | &AbsoluteClippingRect, Color, UseAlphaChannel); |
94 | } | 94 | } |
95 | } | 95 | } |
96 | else | 96 | else |
97 | { | 97 | { |
98 | skin->draw2DRectangle(this, skin->getColor(EGDC_3D_DARK_SHADOW), AbsoluteRect, &AbsoluteClippingRect); | 98 | skin->draw2DRectangle(this, skin->getColor(EGDC_3D_DARK_SHADOW), AbsoluteRect, &AbsoluteClippingRect); |
99 | } | 99 | } |
100 | 100 | ||
101 | IGUIElement::draw(); | 101 | IGUIElement::draw(); |
102 | } | 102 | } |
103 | 103 | ||
104 | 104 | ||
105 | //! sets if the image should use its alpha channel to draw itself | 105 | //! sets if the image should use its alpha channel to draw itself |
106 | void CGUIImage::setUseAlphaChannel(bool use) | 106 | void CGUIImage::setUseAlphaChannel(bool use) |
107 | { | 107 | { |
108 | UseAlphaChannel = use; | 108 | UseAlphaChannel = use; |
109 | } | 109 | } |
110 | 110 | ||
111 | 111 | ||
112 | //! sets if the image should use its alpha channel to draw itself | 112 | //! sets if the image should use its alpha channel to draw itself |
113 | void CGUIImage::setScaleImage(bool scale) | 113 | void CGUIImage::setScaleImage(bool scale) |
114 | { | 114 | { |
115 | ScaleImage = scale; | 115 | ScaleImage = scale; |
116 | } | 116 | } |
117 | 117 | ||
118 | 118 | ||
119 | //! Returns true if the image is scaled to fit, false if not | 119 | //! Returns true if the image is scaled to fit, false if not |
120 | bool CGUIImage::isImageScaled() const | 120 | bool CGUIImage::isImageScaled() const |
121 | { | 121 | { |
122 | _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; | 122 | _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; |
123 | return ScaleImage; | 123 | return ScaleImage; |
124 | } | 124 | } |
125 | 125 | ||
126 | //! Returns true if the image is using the alpha channel, false if not | 126 | //! Returns true if the image is using the alpha channel, false if not |
127 | bool CGUIImage::isAlphaChannelUsed() const | 127 | bool CGUIImage::isAlphaChannelUsed() const |
128 | { | 128 | { |
129 | _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; | 129 | _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; |
130 | return UseAlphaChannel; | 130 | return UseAlphaChannel; |
131 | } | 131 | } |
132 | 132 | ||
133 | 133 | ||
134 | //! Writes attributes of the element. | 134 | //! Writes attributes of the element. |
135 | void CGUIImage::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const | 135 | void CGUIImage::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const |
136 | { | 136 | { |
137 | IGUIImage::serializeAttributes(out,options); | 137 | IGUIImage::serializeAttributes(out,options); |
138 | 138 | ||
139 | out->addTexture ("Texture", Texture); | 139 | out->addTexture ("Texture", Texture); |
140 | out->addBool ("UseAlphaChannel", UseAlphaChannel); | 140 | out->addBool ("UseAlphaChannel", UseAlphaChannel); |
141 | out->addColor ("Color", Color); | 141 | out->addColor ("Color", Color); |
142 | out->addBool ("ScaleImage", ScaleImage); | 142 | out->addBool ("ScaleImage", ScaleImage); |
143 | 143 | ||
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | //! Reads attributes of the element | 147 | //! Reads attributes of the element |
148 | void CGUIImage::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) | 148 | void CGUIImage::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) |
149 | { | 149 | { |
150 | IGUIImage::deserializeAttributes(in,options); | 150 | IGUIImage::deserializeAttributes(in,options); |
151 | 151 | ||
152 | setImage(in->getAttributeAsTexture("Texture")); | 152 | setImage(in->getAttributeAsTexture("Texture")); |
153 | setUseAlphaChannel(in->getAttributeAsBool("UseAlphaChannel")); | 153 | setUseAlphaChannel(in->getAttributeAsBool("UseAlphaChannel")); |
154 | setColor(in->getAttributeAsColor("Color")); | 154 | setColor(in->getAttributeAsColor("Color")); |
155 | setScaleImage(in->getAttributeAsBool("ScaleImage")); | 155 | setScaleImage(in->getAttributeAsBool("ScaleImage")); |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | } // end namespace gui | 159 | } // end namespace gui |
160 | } // end namespace irr | 160 | } // end namespace irr |
161 | 161 | ||
162 | 162 | ||
163 | #endif // _IRR_COMPILE_WITH_GUI_ | 163 | #endif // _IRR_COMPILE_WITH_GUI_ |
164 | 164 | ||