arsa  2.7
IGUIButton.h
Go to the documentation of this file.
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 __I_GUI_BUTTON_H_INCLUDED__
6 #define __I_GUI_BUTTON_H_INCLUDED__
7 
8 #include "IGUIElement.h"
9 
10 namespace irr
11 {
12 
13 namespace video
14 {
15  class ITexture;
16 } // end namespace video
17 
18 namespace gui
19 {
20  class IGUIFont;
21  class IGUISpriteBank;
22 
29  {
46  };
47 
49  const c8* const GUIButtonStateNames[EGBS_COUNT+1] =
50  {
51  "buttonUp",
52  "buttonDown",
53  "buttonMouseOver",
54  "buttonMouseOff",
55  "buttonFocused",
56  "buttonNotFocused",
57  "buttonDisabled",
58  0 // count
59  };
60 
67  {
88  };
89 
92  {
93  "Image", // not "ImageUp" as it otherwise breaks serialization of old files
94  "ImageUpOver",
95  "ImageUpFocused",
96  "ImageUpFocusedOver",
97  "PressedImage", // not "ImageDown" as it otherwise breaks serialization of old files
98  "ImageDownOver",
99  "ImageDownFocused",
100  "ImageDownFocusedOver",
101  "ImageDisabled",
102  0 // count
103  };
104 
106 
109  class IGUIButton : public IGUIElement
110  {
111  public:
112 
114  IGUIButton(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
115  : IGUIElement(EGUIET_BUTTON, environment, parent, id, rectangle) {}
116 
118 
120  virtual void setOverrideFont(IGUIFont* font=0) = 0;
121 
123 
124  virtual IGUIFont* getOverrideFont(void) const = 0;
125 
127 
129  virtual IGUIFont* getActiveFont() const = 0;
130 
132 
136  virtual void setOverrideColor(video::SColor color) = 0;
137 
139 
140  virtual video::SColor getOverrideColor(void) const = 0;
141 
143 
146  virtual void enableOverrideColor(bool enable) = 0;
147 
149 
150  virtual bool isOverrideColorEnabled(void) const = 0;
151 
153 
160  virtual void setImage(EGUI_BUTTON_IMAGE_STATE state, video::ITexture* image=0, const core::rect<s32>& sourceRect=core::rect<s32>(0,0,0,0)) = 0;
161 
163 
165  virtual void setImage(video::ITexture* image=0) = 0;
166 
168 
172  virtual void setImage(video::ITexture* image, const core::rect<s32>& sourceRect) = 0;
173 
175 
179  virtual void setPressedImage(video::ITexture* image=0) = 0;
180 
182 
185  virtual void setPressedImage(video::ITexture* image, const core::rect<s32>& sourceRect) = 0;
186 
187 
189 
191  virtual void setSpriteBank(IGUISpriteBank* bank=0) = 0;
192 
194 
203  virtual void setSprite(EGUI_BUTTON_STATE state, s32 index,
204  video::SColor color=video::SColor(255,255,255,255), bool loop=false, bool scale=false) = 0;
205 
207  virtual s32 getSpriteIndex(EGUI_BUTTON_STATE state) const = 0;
208 
210  virtual video::SColor getSpriteColor(EGUI_BUTTON_STATE state) const = 0;
211 
213  virtual bool getSpriteLoop(EGUI_BUTTON_STATE state) const = 0;
214 
216  virtual bool getSpriteScale(EGUI_BUTTON_STATE state) const = 0;
217 
219 
221  virtual void setIsPushButton(bool isPushButton=true) = 0;
222 
224  virtual void setPressed(bool pressed=true) = 0;
225 
227  virtual bool isPressed() const = 0;
228 
230  virtual void setUseAlphaChannel(bool useAlphaChannel=true) = 0;
231 
233  virtual bool isAlphaChannelUsed() const = 0;
234 
236  virtual bool isPushButton() const = 0;
237 
239  virtual void setDrawBorder(bool border=true) = 0;
240 
242  virtual bool isDrawingBorder() const = 0;
243 
245  virtual void setScaleImage(bool scaleImage=true) = 0;
246 
248  virtual bool isScalingImage() const = 0;
249 
251 
252  virtual bool getClickShiftState() const = 0;
253 
255 
256  virtual bool getClickControlState() const = 0;
257  };
258 
259 
260 } // end namespace gui
261 } // end namespace irr
262 
263 #endif
264 
GLenum GLenum GLenum GLenum GLenum scale
virtual IGUIFont * getActiveFont() const =0
Get the font which is used right now for drawing.
virtual void enableOverrideColor(bool enable)=0
Sets if the button text should use the override color or the color in the gui skin.
GLuint id
When not set EGBIS_IMAGE_UP_MOUSEOVER is used.
Definition: IGUIButton.h:73
GUI Button interface.
Definition: IGUIButton.h:109
GLeglImageOES image
Definition: SDL_opengl.h:2148
not used, counts the number of enumerated items
Definition: IGUIButton.h:45
virtual bool isAlphaChannelUsed() const =0
Returns if the alpha channel should be used for drawing background images on the button.
Sprite bank interface.
virtual bool isPressed() const =0
Returns if the button is currently pressed.
When not set EGBIS_IMAGE_UP is used.
Definition: IGUIButton.h:71
const c8 *const GUIButtonStateNames[EGBS_COUNT+1]
Names for gui button state icons.
Definition: IGUIButton.h:49
The mouse cursor is over the button.
Definition: IGUIButton.h:35
The button is disabled All other states are ignored in that case.
Definition: IGUIButton.h:43
char c8
8 bit character variable.
Definition: irrTypes.h:35
virtual bool isOverrideColorEnabled(void) const =0
Checks if an override color is enabled.
The mouse cursor is not over the button.
Definition: IGUIButton.h:37
virtual video::SColor getSpriteColor(EGUI_BUTTON_STATE state) const =0
Get the sprite color for the given state. Color is only used when a sprite is set.
Everything in the Irrlicht Engine can be found in this namespace.
Definition: CARSADPad.h:6
When not set EGBIS_IMAGE_DOWN_MOUSEOVER is used.
Definition: IGUIButton.h:81
GUI Environment. Used as factory and manager of all other GUI elements.
The button is currently pressed down.
Definition: IGUIButton.h:33
virtual void setPressedImage(video::ITexture *image=0)=0
Sets a background image for the button when it is in pressed state.
virtual void setSprite(EGUI_BUTTON_STATE state, s32 index, video::SColor color=video::SColor(255, 255, 255, 255), bool loop=false, bool scale=false)=0
Sets the animated sprite for a specific button state.
virtual bool getClickShiftState() const =0
Get if the shift key was pressed in last EGET_BUTTON_CLICKED event.
virtual bool isDrawingBorder() const =0
Returns if the border and button face are being drawn using the skin.
const c8 *const GUIButtonImageStateNames[EGBIS_COUNT+1]
Names for gui button image states.
Definition: IGUIButton.h:91
EGUI_BUTTON_IMAGE_STATE
Definition: IGUIButton.h:66
Font interface.
Definition: IGUIFont.h:39
virtual void setImage(EGUI_BUTTON_IMAGE_STATE state, video::ITexture *image=0, const core::rect< s32 > &sourceRect=core::rect< s32 >(0, 0, 0, 0))=0
Sets an image which should be displayed on the button when it is in the given state.
virtual bool isScalingImage() const =0
Checks whether the button scales the used images.
signed int s32
32 bit signed variable.
Definition: irrTypes.h:70
virtual video::SColor getOverrideColor(void) const =0
Gets the override color.
When not set EGBIS_IMAGE_UP or EGBIS_IMAGE_DOWN are used (depending on button state).
Definition: IGUIButton.h:85
The button has the focus.
Definition: IGUIButton.h:39
The button doesn't have the focus.
Definition: IGUIButton.h:41
IGUIButton(IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect< s32 > rectangle)
constructor
Definition: IGUIButton.h:114
virtual void setSpriteBank(IGUISpriteBank *bank=0)=0
Sets the sprite bank used by the button.
virtual bool getSpriteLoop(EGUI_BUTTON_STATE state) const =0
Returns if the sprite in the given state does loop.
virtual bool isPushButton() const =0
Returns whether the button is a push button.
virtual void setUseAlphaChannel(bool useAlphaChannel=true)=0
Sets if the alpha channel should be used for drawing background images on the button (default is fals...
virtual bool getClickControlState() const =0
Get if the control key was pressed in last EGET_BUTTON_CLICKED event.
virtual s32 getSpriteIndex(EGUI_BUTTON_STATE state) const =0
Get the sprite-index for the given state or -1 when no sprite is set.
GLuint index
Class representing a 32 bit ARGB color.
Definition: SColor.h:316
Base class of all GUI elements.
Definition: IGUIElement.h:23
not used, counts the number of enumerated items
Definition: IGUIButton.h:87
virtual IGUIFont * getOverrideFont(void) const =0
Gets the override font (if any)
virtual bool getSpriteScale(EGUI_BUTTON_STATE state) const =0
Returns if the sprite in the given state is scaled.
GLboolean enable
virtual void setOverrideColor(video::SColor color)=0
Sets another color for the button text.
virtual void setOverrideFont(IGUIFont *font=0)=0
Sets another skin independent font.
GLuint color
The button is not pressed.
Definition: IGUIButton.h:31
EGUI_BUTTON_STATE
Definition: IGUIButton.h:28
Interface of a Video Driver dependent Texture.
Definition: ITexture.h:177
GLint GLint GLsizei GLsizei GLsizei GLint border
Definition: SDL_opengl.h:1572
virtual void setDrawBorder(bool border=true)=0
Sets if the button should use the skin to draw its border and button face (default is true)
When no other states have images they will all use this one.
Definition: IGUIButton.h:69
When not set EGBIS_IMAGE_UP_FOCUSED is used.
Definition: IGUIButton.h:75
When not set EGBIS_IMAGE_DOWN is used.
Definition: IGUIButton.h:79
virtual void setScaleImage(bool scaleImage=true)=0
Sets if the button should scale the button images to fit.
When not set EGBIS_IMAGE_DOWN_FOCUSED is used.
Definition: IGUIButton.h:83
When not set EGBIS_IMAGE_UP is used.
Definition: IGUIButton.h:77
virtual void setIsPushButton(bool isPushButton=true)=0
Sets if the button should behave like a push button.
A button (IGUIButton)
virtual void setPressed(bool pressed=true)=0
Sets the pressed state of the button if this is a pushbutton.