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

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

#include <iostream>

Pierre Kraemer's avatar
Pierre Kraemer committed
12 13 14 15 16 17
namespace CGoGN
{

namespace SCHNApps
{

18
class View;
19
struct Texture;
20 21 22 23 24 25

class ViewButton : public QObject
{
	Q_OBJECT

public:
Pierre Kraemer's avatar
Pierre Kraemer committed
26 27
	ViewButton(const QString& image, View* view);
	~ViewButton();
28

29
	QSize getSize();
30

31
	void click(int x, int y, int globalX, int globalY);
32 33
	void drawAt(int x, int y);

Pierre Kraemer's avatar
Pierre Kraemer committed
34 35 36
	static const int SIZE = 24;
	static const int SPACE = 4;

37
protected:
38
	QString m_img;
Pierre Kraemer's avatar
Pierre Kraemer committed
39
	View* m_view;
40
	Texture* m_tex;
41 42

signals:
43
	void clicked(int x, int y, int globalX, int globalY);
44 45 46 47 48 49 50
};

class ViewButtonArea : public QObject
{
	Q_OBJECT

public:
Pierre Kraemer's avatar
Pierre Kraemer committed
51 52 53
	ViewButtonArea(View* view) :
		m_view(view),
		m_form(0,0,0,0)
54
	{}
Pierre Kraemer's avatar
Pierre Kraemer committed
55 56
	~ViewButtonArea()
	{}
57 58

	void addButton(ViewButton* button);
Pierre Kraemer's avatar
Pierre Kraemer committed
59
	void removeButton(ViewButton* button);
60

Pierre Kraemer's avatar
Pierre Kraemer committed
61
	bool isClicked(int x, int y);
62
	void clickButton(int x, int y, int globalX, int globalY);
63

Pierre Kraemer's avatar
Pierre Kraemer committed
64
	const QRect& getForm() { return m_form; }
65 66 67 68 69 70 71

	void setTopRightPosition(int x, int y);

	void draw();

protected:
	View* m_view;
Pierre Kraemer's avatar
Pierre Kraemer committed
72 73
	QRect m_form;
	QList<ViewButton*> l_buttons;
74 75
};

Pierre Kraemer's avatar
Pierre Kraemer committed
76 77 78 79
} // namespace SCHNApps

} // namespace CGoGN

80
#endif