viewButtonArea.h 1.26 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
#ifndef _VIEWBUTTONAREA_H_
#define _VIEWBUTTONAREA_H_

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

#include <iostream>

namespace CGoGN
{

namespace SCHNApps
{

class View;
struct Texture;

class ViewButton : public QObject
{
	Q_OBJECT

public:
	ViewButton(const QString& image, View* view);
	~ViewButton();

	QSize getSize();

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

	static const int SIZE = 24;
	static const int SPACE = 4;

protected:
	QString m_img;
	View* m_view;
	Texture* m_tex;

signals:
	void clicked(int x, int y, int globalX, int globalY);
};

class ViewButtonArea : public QObject
{
	Q_OBJECT

public:
	ViewButtonArea(View* view) :
		m_view(view),
		m_form(0,0,0,0)
	{}

	~ViewButtonArea()
	{
//		foreach(ViewButton* b, l_buttons)
//			delete b;
	}

	void addButton(ViewButton* button);
	void removeButton(ViewButton* button);

	bool isClicked(int x, int y);
	void clickButton(int x, int y, int globalX, int globalY);

	const QRect& getForm() { return m_form; }

	void setTopRightPosition(int x, int y);

Sylvain Thery's avatar
Sylvain Thery committed
72 73
	void setTopLeftPosition(int x, int y);

Pierre Kraemer's avatar
Pierre Kraemer committed
74 75 76 77 78 79 80 81 82 83 84 85 86
	void draw();

protected:
	View* m_view;
	QRect m_form;
	QList<ViewButton*> l_buttons;
};

} // namespace SCHNApps

} // namespace CGoGN

#endif