aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/source/Irrlicht/CGUIButton.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CGUIButton.h')
-rw-r--r--src/others/irrlicht-1.8.1/source/Irrlicht/CGUIButton.h143
1 files changed, 143 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CGUIButton.h b/src/others/irrlicht-1.8.1/source/Irrlicht/CGUIButton.h
new file mode 100644
index 0000000..86e6954
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CGUIButton.h
@@ -0,0 +1,143 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5#ifndef __C_GUI_BUTTON_H_INCLUDED__
6#define __C_GUI_BUTTON_H_INCLUDED__
7
8#include "IrrCompileConfig.h"
9#ifdef _IRR_COMPILE_WITH_GUI_
10
11#include "IGUIButton.h"
12#include "IGUISpriteBank.h"
13#include "SColor.h"
14
15namespace irr
16{
17namespace gui
18{
19
20 class CGUIButton : public IGUIButton
21 {
22 public:
23
24 //! constructor
25 CGUIButton(IGUIEnvironment* environment, IGUIElement* parent,
26 s32 id, core::rect<s32> rectangle, bool noclip=false);
27
28 //! destructor
29 virtual ~CGUIButton();
30
31 //! called if an event happened.
32 virtual bool OnEvent(const SEvent& event);
33
34 //! draws the element and its children
35 virtual void draw();
36
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);
39
40 //! Gets the override font (if any)
41 virtual IGUIFont* getOverrideFont() const;
42
43 //! Get the font which is used right now for drawing
44 virtual IGUIFont* getActiveFont() const;
45
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);
48
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);
51
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);
54
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);
57
58 //! Sets the sprite bank used by the button
59 virtual void setSpriteBank(IGUISpriteBank* bank=0);
60
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
63 \param state: State of the button to set the sprite for
64 \param index: The sprite number from the current sprite bank
65 \param color: The color of the sprite
66 */
67 virtual void setSprite(EGUI_BUTTON_STATE state, s32 index,
68 video::SColor color=video::SColor(255,255,255,255), bool loop=false);
69
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,
72 //! the user can change the state of the button.
73 virtual void setIsPushButton(bool isPushButton=true);
74
75 //! Checks whether the button is a push button
76 virtual bool isPushButton() const;
77
78 //! Sets the pressed state of the button if this is a pushbutton
79 virtual void setPressed(bool pressed=true);
80
81 //! Returns if the button is currently pressed
82 virtual bool isPressed() const;
83
84 //! Sets if the button should use the skin to draw its border
85 virtual void setDrawBorder(bool border=true);
86
87 //! Checks if the button face and border are being drawn
88 virtual bool isDrawingBorder() const;
89
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);
92
93 //! Checks if the alpha channel should be used for drawing images on the button
94 virtual bool isAlphaChannelUsed() const;
95
96 //! Sets if the button should scale the button images to fit
97 virtual void setScaleImage(bool scaleImage=true);
98
99 //! Checks whether the button scales the used images
100 virtual bool isScalingImage() const;
101
102 //! Writes attributes of the element.
103 virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
104
105 //! Reads attributes of the element
106 virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
107
108 private:
109
110 struct ButtonSprite
111 {
112 s32 Index;
113 video::SColor Color;
114 bool Loop;
115 };
116
117 ButtonSprite ButtonSprites[EGBS_COUNT];
118
119 IGUISpriteBank* SpriteBank;
120 IGUIFont* OverrideFont;
121
122 video::ITexture* Image;
123 video::ITexture* PressedImage;
124
125 core::rect<s32> ImageRect;
126 core::rect<s32> PressedImageRect;
127
128 u32 ClickTime, HoverTime, FocusTime;
129
130 bool IsPushButton;
131 bool Pressed;
132 bool UseAlphaChannel;
133 bool DrawBorder;
134 bool ScaleImage;
135 };
136
137} // end namespace gui
138} // end namespace irr
139
140#endif // _IRR_COMPILE_WITH_GUI_
141
142#endif // __C_GUI_BUTTON_H_INCLUDED__
143