mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
0883940b2a
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1082 4e206d99-4929-0410-ac5d-dfc041789085
82 lines
2.9 KiB
C++
82 lines
2.9 KiB
C++
|
|
#ifndef QSFMLCANVAS_HPP
|
|
#define QSFMLCANVAS_HPP
|
|
|
|
////////////////////////////////////////////////////////////
|
|
// Headers
|
|
////////////////////////////////////////////////////////////
|
|
#include <SFML/Graphics.hpp>
|
|
#include <Qt/qwidget.h>
|
|
#include <Qt/qtimer.h>
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// QSFMLCanvas allows to run SFML in a Qt control
|
|
////////////////////////////////////////////////////////////
|
|
class QSFMLCanvas : public QWidget, public sf::RenderWindow
|
|
{
|
|
public :
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// Construct the QSFMLCanvas
|
|
///
|
|
/// \param Parent : Parent of the widget
|
|
/// \param Position : Position of the widget
|
|
/// \param Size : Size of the widget
|
|
/// \param FrameTime : Frame duration, in milliseconds (0 by default)
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
QSFMLCanvas(QWidget* Parent, const QPoint& Position, const QSize& Size, unsigned int FrameTime = 0);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// Destructor
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
virtual ~QSFMLCanvas();
|
|
|
|
private :
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// Notification for the derived class that moment is good
|
|
/// for doing initializations
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
virtual void OnInit();
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// Notification for the derived class that moment is good
|
|
/// for doing its update and drawing stuff
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
virtual void OnUpdate();
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// Return the paint engine used by the widget to draw itself
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
virtual QPaintEngine* paintEngine() const;
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// Called when the widget is shown ;
|
|
/// we use it to initialize our SFML window
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
virtual void showEvent(QShowEvent*);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
/// Called when the widget needs to be painted ;
|
|
/// we use it to display a new frame
|
|
///
|
|
////////////////////////////////////////////////////////////
|
|
virtual void paintEvent(QPaintEvent*);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
// Member data
|
|
////////////////////////////////////////////////////////////
|
|
QTimer myTimer; ///< Timer used to update the view
|
|
bool myInitialized; ///< Tell whether the SFML window has been initialized or not
|
|
};
|
|
|
|
|
|
#endif // QSFMLCANVAS_HPP
|