2010-02-04 13:33:47 +02:00
|
|
|
/***************************************************************************
|
2011-10-23 17:43:56 +03:00
|
|
|
* Copyright (C) 2006 by Massimiliano Torromeo *
|
|
|
|
* massimiliano.torromeo@gmail.com *
|
2010-02-04 13:33:47 +02:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2011-10-23 17:43:56 +03:00
|
|
|
#ifndef BUTTON_H
|
|
|
|
#define BUTTON_H
|
2010-02-04 13:33:47 +02:00
|
|
|
|
|
|
|
#include "FastDelegate.h"
|
|
|
|
|
2011-10-23 17:43:56 +03:00
|
|
|
#include <SDL.h>
|
2010-02-04 13:33:47 +02:00
|
|
|
|
2011-10-23 17:43:56 +03:00
|
|
|
typedef fastdelegate::FastDelegate0<> ButtonAction;
|
2010-07-27 23:12:28 +03:00
|
|
|
class Touchscreen;
|
2010-02-04 13:33:47 +02:00
|
|
|
|
|
|
|
class Button {
|
|
|
|
protected:
|
2011-12-23 15:03:05 +02:00
|
|
|
Touchscreen &ts;
|
2010-02-04 13:33:47 +02:00
|
|
|
ButtonAction action;
|
|
|
|
SDL_Rect rect;
|
|
|
|
bool doubleClick;
|
|
|
|
int lastTick;
|
|
|
|
|
|
|
|
public:
|
2010-07-27 23:12:28 +03:00
|
|
|
Button(Touchscreen &ts, bool doubleClick = false);
|
2010-02-04 13:33:47 +02:00
|
|
|
virtual ~Button() {};
|
|
|
|
|
|
|
|
SDL_Rect getRect();
|
|
|
|
void setSize(int w, int h);
|
2010-05-03 23:21:36 +03:00
|
|
|
virtual void setPosition(int x, int y);
|
2010-02-04 13:33:47 +02:00
|
|
|
|
|
|
|
virtual void paint();
|
|
|
|
virtual bool paintHover();
|
|
|
|
|
|
|
|
bool isPressed();
|
|
|
|
bool isReleased();
|
|
|
|
bool handleTS();
|
2010-05-03 23:21:36 +03:00
|
|
|
|
2010-02-04 13:33:47 +02:00
|
|
|
void exec();
|
|
|
|
void voidAction() {};
|
|
|
|
void setAction(ButtonAction action);
|
|
|
|
};
|
|
|
|
|
2011-10-23 17:43:56 +03:00
|
|
|
#endif // BUTTON_H
|