viewButtonArea.h 1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
#ifndef _VIEWBUTTONAREA_H_
#define _VIEWBUTTONAREA_H_

#include <QPixmap>
#include <QSize>
#include <QRect>
#include <QPainter>
#include <QList>

#include <iostream>

class View;
13
class Texture;
14 15 16 17 18 19

class ViewButton : public QObject
{
	Q_OBJECT

public:
Pierre Kraemer's avatar
Pierre Kraemer committed
20 21
	ViewButton(const QString& image, View* view);
	~ViewButton();
22

23
	QSize getSize();
24

25
	void click(int x, int y, int globalX, int globalY);
26 27 28
	void drawAt(int x, int y);

protected:
29
	QString m_img;
Pierre Kraemer's avatar
Pierre Kraemer committed
30
	View* m_view;
31
	Texture* m_tex;
32 33

signals:
34
	void clicked(int x, int y, int globalX, int globalY);
35 36 37 38 39 40 41 42 43
};

class ViewButtonArea : public QObject
{
	Q_OBJECT

public:
	ViewButtonArea(View* view) : m_view(view)
	{}
Pierre Kraemer's avatar
Pierre Kraemer committed
44 45
	~ViewButtonArea()
	{}
46 47

	void addButton(ViewButton* button);
Pierre Kraemer's avatar
Pierre Kraemer committed
48
	void removeButton(ViewButton* button);
49

Pierre Kraemer's avatar
Pierre Kraemer committed
50
	bool isClicked(int x, int y);
51
	void clickButton(int x, int y, int globalX, int globalY);
52

Pierre Kraemer's avatar
Pierre Kraemer committed
53
	const QRect& getForm() { return m_form; }
54 55 56 57 58 59 60

	void setTopRightPosition(int x, int y);

	void draw();

protected:
	View* m_view;
Pierre Kraemer's avatar
Pierre Kraemer committed
61 62
	QRect m_form;
	QList<ViewButton*> l_buttons;
63 64 65
};

#endif