#ifndef __C_GUI_BUTTON_H_INCLUDED__
#define __C_GUI_BUTTON_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIButton.h"
#include "IGUISpriteBank.h"
#include "SColor.h"
namespace irr
{
namespace gui
{
class CGUIButton : public IGUIButton
{
public:
CGUIButton(IGUIEnvironment* environment, IGUIElement* parent,
s32 id, core::rect<s32> rectangle, bool noclip=false);
virtual ~CGUIButton();
virtual bool OnEvent(const SEvent& event);
virtual void draw();
virtual void setOverrideFont(IGUIFont* font=0);
virtual void setImage(video::ITexture* image=0);
virtual void setImage(video::ITexture* image, const core::rect<s32>& pos);
virtual void setPressedImage(video::ITexture* image=0);
virtual void setPressedImage(video::ITexture* image, const core::rect<s32>& pos);
virtual void setSpriteBank(IGUISpriteBank* bank=0);
virtual void setSprite(EGUI_BUTTON_STATE state, s32 index,
video::SColor color=video::SColor(255,255,255,255), bool loop=false);
virtual void setIsPushButton(bool isPushButton=true);
virtual bool isPushButton() const;
virtual void setPressed(bool pressed=true);
virtual bool isPressed() const;
virtual void setDrawBorder(bool border=true);
virtual bool isDrawingBorder() const;
virtual void setUseAlphaChannel(bool useAlphaChannel=true);
virtual bool isAlphaChannelUsed() const;
virtual void setScaleImage(bool scaleImage=true);
virtual bool isScalingImage() const;
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
private:
struct ButtonSprite
{
s32 Index;
video::SColor Color;
bool Loop;
};
ButtonSprite ButtonSprites[EGBS_COUNT];
IGUISpriteBank* SpriteBank;
IGUIFont* OverrideFont;
video::ITexture* Image;
video::ITexture* PressedImage;
core::rect<s32> ImageRect;
core::rect<s32> PressedImageRect;
u32 ClickTime;
bool IsPushButton;
bool Pressed;
bool UseAlphaChannel;
bool DrawBorder;
bool ScaleImage;
};
}
}
#endif
#endif