#ifndef GL_WIDGET3_H
#define GL_WIDGET3_H

#include "./../../lib/GLee/GLee.h"	//GL header file, including extensions

#include <string>
#include <vector>
using namespace std;

#include <QGLWidget>
#include <QMouseEvent>
#include <QWheelEvent>
#include <QTimer>
#include <QGLPixelBuffer>
#include <QGLContext>

#include <qtableview.h>
#include <QStandardItemModel>
#include <QModelIndex>
#include <qpushbutton.h>

#include "./openGlSupport/VBOmanager.h"
#include "./openGlSupport/OpenGLwrapper.h"
#include "./texture/TextureManager.h"
#include "./apps/AbstractAPP.h"

#include "./dtit/DTITsupport.h"

#include "./Context/QtContext.h"
#include "./QtWindow/Window2/QtComponents.h"


typedef unsigned int key_code;





class GLwidget3 : public QGLWidget
{
	Q_OBJECT

private:
	AbstractAPP* app;
	QContext *qContext;
	QTimer oneSecondTimer;
	unsigned int loop;

	UiAssistant *uiAssistant;
	static const unsigned int SCREEN_WIDTH_RES = 640;
	static const unsigned int SCREEN_HEIGHT_RES = 480;

	bool initialized;

public:
	void setApp( AbstractAPP* app );
	

	GLwidget3( QWidget *parent = 0 );
	void initializeGL(void);
	void mouseReleaseEvent( QMouseEvent *e );
	void mousePressEvent( QMouseEvent *e );
	void mouseMoveEvent( QMouseEvent *e );
	void keyPressEvent( QKeyEvent *e);
	void keyReleaseEvent( QKeyEvent *e);
	void wheelEvent( QWheelEvent *e );
	void paintGL(void);
	void focusOutEvent( QFocusEvent *e );
	Context* getContext(void);

	void setAssistant( UiAssistant *uiAssistant );


	bool isInitialized(void);

public slots:
	virtual void updateGL();
	void oneSecondTimeout();

signals:
	void lostFocusSignal(void);
	void refresh(void);	//emited when paintGL() called

	void mouseReleaseEventSignal( QMouseEvent *e );
	void mousePressEventSignal( QMouseEvent *e );
	void mouseMoveEventSignal( QMouseEvent *e );
	void keyPressEventSignal( QKeyEvent *e);
	void keyReleaseEventSignal( QKeyEvent *e);
	void wheelEventSignal( QWheelEvent *e );
};


#endif