/*
- * Copyright (c) 2007-2013, Arnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
+ * Copyright (c) 2007-2013, Arnaud Giersch <arnaud.giersch@univ-fcomte.fr>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
/*! \class DrawingWindow
* \brief Fenêtre de dessin.
*
- * \author Arnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
+ * \author Arnaud Giersch <arnaud.giersch@univ-fcomte.fr>
* \date 2007-2013
*
* Cette classe décrit un widget Qt permettant d'écrire des
unsigned long time)
{
bool pressed;
- safeLock(mouseMutex);
+ safeLock(inputMutex);
if (terminateThread) {
pressed = false;
} else {
- pressed = mouseCondition.wait(&mouseMutex, time) && !terminateThread;
+ pressed = inputCondition.wait(&inputMutex, time) && !terminateThread;
if (pressed) {
x = mousePos.x();
y = mousePos.y();
button = 0;
}
}
- safeUnlock(mouseMutex);
+ safeUnlock(inputMutex);
return pressed;
}
DrawingThread::usleep(usecs);
}
+//--- DrawingWindow (protected methods) --------------------------------
+//! \cond show_protected
+
/*!
* \see QWidget
*/
timer.stop();
thread->exit();
syncMutex.lock();
- mouseMutex.lock();
+ inputMutex.lock();
terminateThread = true; // this flag is needed for the case
// where the following wakeAll() call
// occurs between the
// mutex lock in safeLock() called
// from sync()
syncCondition.wakeAll();
- mouseCondition.wakeAll();
- mouseMutex.unlock();
+ inputCondition.wakeAll();
+ inputMutex.unlock();
syncMutex.unlock();
QWidget::closeEvent(ev);
if (!thread->wait(250)) {
*/
void DrawingWindow::mousePressEvent(QMouseEvent *ev)
{
- mouseMutex.lock();
+ inputMutex.lock();
mousePos = ev->pos();
mouseButton = ev->button();
ev->accept();
- mouseCondition.wakeAll();
- mouseMutex.unlock();
+ inputCondition.wakeAll();
+ inputMutex.unlock();
}
/*!
*/
void DrawingWindow::keyPressEvent(QKeyEvent *ev)
{
- bool accept = true;
- switch (ev->key()) {
- case Qt::Key_Escape:
+ if (ev->key() == Qt::Key_Escape) {
+ ev->accept();
close();
- break;
- default:
- accept = false;
- break;
}
- if (accept)
- ev->accept();
}
/*!
}
}
+// \endcond
+
//--- DrawingWindow (private methods) ----------------------------------
//! Fonction d'initialisation.