Mercurial > hg > easaier-soundaccess
view data/model/SDLWidget.cpp @ 167:2ac52ea3c1c4
video mouse events are in SDL now.
The code is really better now, but there is a display bug when you zoom in, zoom out
author | benoitrigolleau |
---|---|
date | Fri, 16 Nov 2007 15:18:44 +0000 |
parents | 46688275b5d4 |
children |
line wrap: on
line source
#include <vector> #include <cstdlib> #include <ctime> #include "SDLWidget.h" SDLWidget::SDLWidget() :windowInitialized(false), screen(0),m_width(0), m_height(0) { setAttribute(Qt::WA_PaintOnScreen); setAttribute(Qt::WA_NoSystemBackground); connect(this,SIGNAL(initSizeChanged()),this,SLOT(updateMinSize())); } SDLWidget::~SDLWidget() { SDL_Quit(); } void SDLWidget::setInitSize(int w, int h){ m_width = w; m_height =h; emit(initSizeChanged()); } void SDLWidget::updateMinSize() { setMinimumSize( m_width,m_height); setMaximumSize( m_width,m_height); } void SDLWidget::showEvent(QShowEvent *e) { (void)e; //QWidget::showEvent(e); if(!windowInitialized) { // it's here the link between SDL and QT char windowid[64]; #ifdef Q_WS_WIN sprintf(windowid, "SDL_WINDOWID=0x%lx", reinterpret_cast<qlonglong>(winId())); #elif defined Q_WS_X11 sprintf(windowid, "SDL_WINDOWID=0x%lx", winId()); #else qFatal("uncorrect window ID"); #endif SDL_putenv(windowid); //SDL_Init(SDL_INIT_VIDEO); //screen = SDL_SetVideoMode(width(), height(), 32, SDL_SWSURFACE); windowInitialized = true; } }