This repository has been archived on 2023-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
MyGameFramework/lib/gwen/controls/gwen_button.h
Gered c5cdddbeaa initial commit
current versions of all of my basic framework sources, build configurations/scripts, and supporting assets
2013-01-31 12:53:05 -05:00

89 lines
2.3 KiB
C++

/*
GWEN
Copyright (c) 2010 Facepunch Studios
See license in Gwen.h
*/
#pragma once
#ifndef GWEN_CONTROLS_BUTTON_H
#define GWEN_CONTROLS_BUTTON_H
#include "gwen_base.h"
#include "gwen_label.h"
#include "../gwen_texture.h"
namespace Gwen
{
namespace Controls
{
class ImagePanel;
class GWEN_EXPORT Button : public Label
{
public:
GWEN_CONTROL( Button, Label );
virtual void Render( Skin::Base* skin );
virtual void OnMouseClickLeft( int x, int y, bool bDown );
virtual void OnMouseClickRight( int x, int y, bool bDown );
virtual void OnMouseDoubleClickLeft( int x, int y );
virtual bool OnKeySpace( bool bDown );
virtual void OnPress();
virtual void OnRightPress();
virtual void AcceleratePressed();
virtual bool IsDepressed() const { return m_bDepressed; }
virtual void SetDepressed( bool b );
//
// Buttons can be toggle type, which means that it is
// toggled on and off. Its toggle status is in IsDepressed.
//
virtual void SetIsToggle( bool b ){ m_bToggle = b; }
virtual bool IsToggle() const { return m_bToggle; }
virtual bool GetToggleState() const { return m_bToggleStatus; }
virtual void SetToggleState( bool b );
virtual void Toggle(){ SetToggleState( !GetToggleState() ); }
virtual void SetImage( const Texture& texture, bool bCenter = false );
virtual void SetImage( const Texture& texture, float u1, float v1, float u2, float v2, bool bCenter = false );
virtual void SetImage( const TextObject& strName, bool bCenter = false );
virtual void SizeToContents();
virtual void PostLayout( Skin::Base* pSkin );
virtual void UpdateColours();
virtual void SetImageAlpha( float fMultiply );
virtual void DoAction(){ OnPress(); }
virtual void SetAction( Event::Handler* pObject, Handler::FunctionWithInformation pFunction, const Gwen::Event::Packet& packet );
public:
Gwen::Event::Caller onPress;
Gwen::Event::Caller onRightPress;
Gwen::Event::Caller onDown;
Gwen::Event::Caller onUp;
Gwen::Event::Caller onDoubleClick;
Gwen::Event::Caller onToggle;
Gwen::Event::Caller onToggleOn;
Gwen::Event::Caller onToggleOff;
protected:
ImagePanel* m_Image;
bool m_bDepressed;
bool m_bToggle;
bool m_bToggleStatus;
bool m_bCenterImage;
};
}
}
#endif