diff options
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CGUIButton.h')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/CGUIButton.h | 286 |
1 files changed, 143 insertions, 143 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CGUIButton.h b/libraries/irrlicht-1.8/source/Irrlicht/CGUIButton.h index 86e6954..6206bd7 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/CGUIButton.h +++ b/libraries/irrlicht-1.8/source/Irrlicht/CGUIButton.h | |||
@@ -1,143 +1,143 @@ | |||
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 | #ifndef __C_GUI_BUTTON_H_INCLUDED__ | 5 | #ifndef __C_GUI_BUTTON_H_INCLUDED__ |
6 | #define __C_GUI_BUTTON_H_INCLUDED__ | 6 | #define __C_GUI_BUTTON_H_INCLUDED__ |
7 | 7 | ||
8 | #include "IrrCompileConfig.h" | 8 | #include "IrrCompileConfig.h" |
9 | #ifdef _IRR_COMPILE_WITH_GUI_ | 9 | #ifdef _IRR_COMPILE_WITH_GUI_ |
10 | 10 | ||
11 | #include "IGUIButton.h" | 11 | #include "IGUIButton.h" |
12 | #include "IGUISpriteBank.h" | 12 | #include "IGUISpriteBank.h" |
13 | #include "SColor.h" | 13 | #include "SColor.h" |
14 | 14 | ||
15 | namespace irr | 15 | namespace irr |
16 | { | 16 | { |
17 | namespace gui | 17 | namespace gui |
18 | { | 18 | { |
19 | 19 | ||
20 | class CGUIButton : public IGUIButton | 20 | class CGUIButton : public IGUIButton |
21 | { | 21 | { |
22 | public: | 22 | public: |
23 | 23 | ||
24 | //! constructor | 24 | //! constructor |
25 | CGUIButton(IGUIEnvironment* environment, IGUIElement* parent, | 25 | CGUIButton(IGUIEnvironment* environment, IGUIElement* parent, |
26 | s32 id, core::rect<s32> rectangle, bool noclip=false); | 26 | s32 id, core::rect<s32> rectangle, bool noclip=false); |
27 | 27 | ||
28 | //! destructor | 28 | //! destructor |
29 | virtual ~CGUIButton(); | 29 | virtual ~CGUIButton(); |
30 | 30 | ||
31 | //! called if an event happened. | 31 | //! called if an event happened. |
32 | virtual bool OnEvent(const SEvent& event); | 32 | virtual bool OnEvent(const SEvent& event); |
33 | 33 | ||
34 | //! draws the element and its children | 34 | //! draws the element and its children |
35 | virtual void draw(); | 35 | virtual void draw(); |
36 | 36 | ||
37 | //! sets another skin independent font. if this is set to zero, the button uses the font of the skin. | 37 | //! sets another skin independent font. if this is set to zero, the button uses the font of the skin. |
38 | virtual void setOverrideFont(IGUIFont* font=0); | 38 | virtual void setOverrideFont(IGUIFont* font=0); |
39 | 39 | ||
40 | //! Gets the override font (if any) | 40 | //! Gets the override font (if any) |
41 | virtual IGUIFont* getOverrideFont() const; | 41 | virtual IGUIFont* getOverrideFont() const; |
42 | 42 | ||
43 | //! Get the font which is used right now for drawing | 43 | //! Get the font which is used right now for drawing |
44 | virtual IGUIFont* getActiveFont() const; | 44 | virtual IGUIFont* getActiveFont() const; |
45 | 45 | ||
46 | //! Sets an image which should be displayed on the button when it is in normal state. | 46 | //! Sets an image which should be displayed on the button when it is in normal state. |
47 | virtual void setImage(video::ITexture* image=0); | 47 | virtual void setImage(video::ITexture* image=0); |
48 | 48 | ||
49 | //! Sets an image which should be displayed on the button when it is in normal state. | 49 | //! Sets an image which should be displayed on the button when it is in normal state. |
50 | virtual void setImage(video::ITexture* image, const core::rect<s32>& pos); | 50 | virtual void setImage(video::ITexture* image, const core::rect<s32>& pos); |
51 | 51 | ||
52 | //! Sets an image which should be displayed on the button when it is in pressed state. | 52 | //! Sets an image which should be displayed on the button when it is in pressed state. |
53 | virtual void setPressedImage(video::ITexture* image=0); | 53 | virtual void setPressedImage(video::ITexture* image=0); |
54 | 54 | ||
55 | //! Sets an image which should be displayed on the button when it is in pressed state. | 55 | //! Sets an image which should be displayed on the button when it is in pressed state. |
56 | virtual void setPressedImage(video::ITexture* image, const core::rect<s32>& pos); | 56 | virtual void setPressedImage(video::ITexture* image, const core::rect<s32>& pos); |
57 | 57 | ||
58 | //! Sets the sprite bank used by the button | 58 | //! Sets the sprite bank used by the button |
59 | virtual void setSpriteBank(IGUISpriteBank* bank=0); | 59 | virtual void setSpriteBank(IGUISpriteBank* bank=0); |
60 | 60 | ||
61 | //! Sets the animated sprite for a specific button state | 61 | //! Sets the animated sprite for a specific button state |
62 | /** \param index: Number of the sprite within the sprite bank, use -1 for no sprite | 62 | /** \param index: Number of the sprite within the sprite bank, use -1 for no sprite |
63 | \param state: State of the button to set the sprite for | 63 | \param state: State of the button to set the sprite for |
64 | \param index: The sprite number from the current sprite bank | 64 | \param index: The sprite number from the current sprite bank |
65 | \param color: The color of the sprite | 65 | \param color: The color of the sprite |
66 | */ | 66 | */ |
67 | virtual void setSprite(EGUI_BUTTON_STATE state, s32 index, | 67 | virtual void setSprite(EGUI_BUTTON_STATE state, s32 index, |
68 | video::SColor color=video::SColor(255,255,255,255), bool loop=false); | 68 | video::SColor color=video::SColor(255,255,255,255), bool loop=false); |
69 | 69 | ||
70 | //! Sets if the button should behave like a push button. Which means it | 70 | //! Sets if the button should behave like a push button. Which means it |
71 | //! can be in two states: Normal or Pressed. With a click on the button, | 71 | //! can be in two states: Normal or Pressed. With a click on the button, |
72 | //! the user can change the state of the button. | 72 | //! the user can change the state of the button. |
73 | virtual void setIsPushButton(bool isPushButton=true); | 73 | virtual void setIsPushButton(bool isPushButton=true); |
74 | 74 | ||
75 | //! Checks whether the button is a push button | 75 | //! Checks whether the button is a push button |
76 | virtual bool isPushButton() const; | 76 | virtual bool isPushButton() const; |
77 | 77 | ||
78 | //! Sets the pressed state of the button if this is a pushbutton | 78 | //! Sets the pressed state of the button if this is a pushbutton |
79 | virtual void setPressed(bool pressed=true); | 79 | virtual void setPressed(bool pressed=true); |
80 | 80 | ||
81 | //! Returns if the button is currently pressed | 81 | //! Returns if the button is currently pressed |
82 | virtual bool isPressed() const; | 82 | virtual bool isPressed() const; |
83 | 83 | ||
84 | //! Sets if the button should use the skin to draw its border | 84 | //! Sets if the button should use the skin to draw its border |
85 | virtual void setDrawBorder(bool border=true); | 85 | virtual void setDrawBorder(bool border=true); |
86 | 86 | ||
87 | //! Checks if the button face and border are being drawn | 87 | //! Checks if the button face and border are being drawn |
88 | virtual bool isDrawingBorder() const; | 88 | virtual bool isDrawingBorder() const; |
89 | 89 | ||
90 | //! Sets if the alpha channel should be used for drawing images on the button (default is false) | 90 | //! Sets if the alpha channel should be used for drawing images on the button (default is false) |
91 | virtual void setUseAlphaChannel(bool useAlphaChannel=true); | 91 | virtual void setUseAlphaChannel(bool useAlphaChannel=true); |
92 | 92 | ||
93 | //! Checks if the alpha channel should be used for drawing images on the button | 93 | //! Checks if the alpha channel should be used for drawing images on the button |
94 | virtual bool isAlphaChannelUsed() const; | 94 | virtual bool isAlphaChannelUsed() const; |
95 | 95 | ||
96 | //! Sets if the button should scale the button images to fit | 96 | //! Sets if the button should scale the button images to fit |
97 | virtual void setScaleImage(bool scaleImage=true); | 97 | virtual void setScaleImage(bool scaleImage=true); |
98 | 98 | ||
99 | //! Checks whether the button scales the used images | 99 | //! Checks whether the button scales the used images |
100 | virtual bool isScalingImage() const; | 100 | virtual bool isScalingImage() const; |
101 | 101 | ||
102 | //! Writes attributes of the element. | 102 | //! Writes attributes of the element. |
103 | virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; | 103 | virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; |
104 | 104 | ||
105 | //! Reads attributes of the element | 105 | //! Reads attributes of the element |
106 | virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); | 106 | virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); |
107 | 107 | ||
108 | private: | 108 | private: |
109 | 109 | ||
110 | struct ButtonSprite | 110 | struct ButtonSprite |
111 | { | 111 | { |
112 | s32 Index; | 112 | s32 Index; |
113 | video::SColor Color; | 113 | video::SColor Color; |
114 | bool Loop; | 114 | bool Loop; |
115 | }; | 115 | }; |
116 | 116 | ||
117 | ButtonSprite ButtonSprites[EGBS_COUNT]; | 117 | ButtonSprite ButtonSprites[EGBS_COUNT]; |
118 | 118 | ||
119 | IGUISpriteBank* SpriteBank; | 119 | IGUISpriteBank* SpriteBank; |
120 | IGUIFont* OverrideFont; | 120 | IGUIFont* OverrideFont; |
121 | 121 | ||
122 | video::ITexture* Image; | 122 | video::ITexture* Image; |
123 | video::ITexture* PressedImage; | 123 | video::ITexture* PressedImage; |
124 | 124 | ||
125 | core::rect<s32> ImageRect; | 125 | core::rect<s32> ImageRect; |
126 | core::rect<s32> PressedImageRect; | 126 | core::rect<s32> PressedImageRect; |
127 | 127 | ||
128 | u32 ClickTime, HoverTime, FocusTime; | 128 | u32 ClickTime, HoverTime, FocusTime; |
129 | 129 | ||
130 | bool IsPushButton; | 130 | bool IsPushButton; |
131 | bool Pressed; | 131 | bool Pressed; |
132 | bool UseAlphaChannel; | 132 | bool UseAlphaChannel; |
133 | bool DrawBorder; | 133 | bool DrawBorder; |
134 | bool ScaleImage; | 134 | bool ScaleImage; |
135 | }; | 135 | }; |
136 | 136 | ||
137 | } // end namespace gui | 137 | } // end namespace gui |
138 | } // end namespace irr | 138 | } // end namespace irr |
139 | 139 | ||
140 | #endif // _IRR_COMPILE_WITH_GUI_ | 140 | #endif // _IRR_COMPILE_WITH_GUI_ |
141 | 141 | ||
142 | #endif // __C_GUI_BUTTON_H_INCLUDED__ | 142 | #endif // __C_GUI_BUTTON_H_INCLUDED__ |
143 | 143 | ||