SFMLWidget.hpp
1 #ifndef CPP3DS_SFMLWIDGET_HPP
2 #define CPP3DS_SFMLWIDGET_HPP
3 
4 #include <queue>
5 #include <QWidget>
6 #include <QTimer>
7 #include <QResizeEvent>
8 #include <QMouseEvent>
9 #include <SFML/Graphics.hpp>
10 
11 class QSFMLCanvas: public QWidget, public sf::RenderWindow
12 {
13 public :
14  QSFMLCanvas(QWidget* Parent);
15  virtual ~QSFMLCanvas();
16 
17  bool pollEvent(sf::Event& event);
18 
19 private :
20  virtual QPaintEngine* paintEngine() const;
21 
22  virtual void showEvent(QShowEvent*);
23  virtual void resizeEvent (QResizeEvent* event);
24  virtual void paintEvent(QPaintEvent*);
25  virtual void mousePressEvent(QMouseEvent* event);
26  virtual void mouseReleaseEvent(QMouseEvent* event);
27  virtual void mouseMoveEvent(QMouseEvent* event);
28  virtual void keyPressEvent(QKeyEvent *);
29  virtual void keyReleaseEvent(QKeyEvent *);
30  virtual int heightForWidth(int w);
31 
32  void pushEvent(const sf::Event& event);
33 
34  bool myInitialized;
35  int paintCount;
36  std::queue<sf::Event> m_events;
37 };
38 
39 #endif
40