2011-04-08 07:10:00 +02:00
|
|
|
/* The MIT License
|
|
|
|
*
|
|
|
|
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef UIBUTTON_H
|
|
|
|
#define UIBUTTON_H
|
|
|
|
|
2011-04-17 21:14:24 +02:00
|
|
|
#include <prerequisites.h>
|
|
|
|
#include <ui/uielement.h>
|
|
|
|
#include <graphics/borderedimage.h>
|
2011-04-08 07:10:00 +02:00
|
|
|
|
2011-04-22 15:49:46 +02:00
|
|
|
class UIButton;
|
|
|
|
typedef boost::shared_ptr<UIButton> UIButtonPtr;
|
|
|
|
|
2011-04-08 07:10:00 +02:00
|
|
|
class UIButton : public UIElement
|
|
|
|
{
|
|
|
|
public:
|
2011-05-09 22:38:01 +02:00
|
|
|
enum ButtonState
|
|
|
|
{
|
|
|
|
ButtonUp,
|
|
|
|
ButtonDown,
|
|
|
|
ButtonMouseOver
|
|
|
|
};
|
|
|
|
|
2011-04-11 22:06:03 +02:00
|
|
|
UIButton() :
|
|
|
|
UIElement(UI::Button),
|
2011-05-09 22:38:01 +02:00
|
|
|
m_state(ButtonUp) { }
|
2011-04-08 11:50:26 +02:00
|
|
|
|
2011-04-11 06:08:56 +02:00
|
|
|
void onInputEvent(const InputEvent& event);
|
2011-04-09 21:07:35 +02:00
|
|
|
|
2011-04-10 22:40:44 +02:00
|
|
|
void setText(const std::string& text) { m_text = text; }
|
2011-05-03 00:48:41 +02:00
|
|
|
std::string getText() const { return m_text; }
|
2011-04-10 22:40:44 +02:00
|
|
|
|
2011-05-09 22:38:01 +02:00
|
|
|
ButtonState getState() { return m_state; }
|
2011-04-08 11:50:26 +02:00
|
|
|
|
2011-04-22 00:44:30 +02:00
|
|
|
virtual const char *getScriptableName() const { return "UIButton"; }
|
|
|
|
|
2011-04-08 11:50:26 +02:00
|
|
|
private:
|
|
|
|
std::string m_text;
|
2011-05-09 22:38:01 +02:00
|
|
|
ButtonState m_state;
|
2011-04-08 07:10:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // UIBUTTON_H
|