X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/graphlib.git/blobdiff_plain/220646505f3b9d7a22749f7491ecc6c15bfec4f3..HEAD:/DrawingWindow.cpp diff --git a/DrawingWindow.cpp b/DrawingWindow.cpp index d1ef81b..78a6296 100644 --- a/DrawingWindow.cpp +++ b/DrawingWindow.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2013, Arnaud Giersch + * Copyright (c) 2007-2013, Arnaud Giersch * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -36,7 +36,7 @@ /*! \class DrawingWindow * \brief Fenêtre de dessin. * - * \author Arnaud Giersch + * \author Arnaud Giersch * \date 2007-2013 * * Cette classe décrit un widget Qt permettant d'écrire des @@ -665,11 +665,11 @@ bool DrawingWindow::waitMousePress(int &x, int &y, int &button, 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(); @@ -683,7 +683,7 @@ bool DrawingWindow::waitMousePress(int &x, int &y, int &button, button = 0; } } - safeUnlock(mouseMutex); + safeUnlock(inputMutex); return pressed; } @@ -745,6 +745,9 @@ void DrawingWindow::usleep(unsigned long usecs) DrawingThread::usleep(usecs); } +//--- DrawingWindow (protected methods) -------------------------------- +//! \cond show_protected + /*! * \see QWidget */ @@ -753,7 +756,7 @@ void DrawingWindow::closeEvent(QCloseEvent *ev) 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 @@ -761,8 +764,8 @@ void DrawingWindow::closeEvent(QCloseEvent *ev) // 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)) { @@ -797,12 +800,12 @@ void DrawingWindow::customEvent(QEvent *ev) */ 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(); } /*! @@ -810,17 +813,10 @@ void DrawingWindow::mousePressEvent(QMouseEvent *ev) */ 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(); } /*! @@ -861,6 +857,8 @@ void DrawingWindow::timerEvent(QTimerEvent *ev) } } +// \endcond + //--- DrawingWindow (private methods) ---------------------------------- //! Fonction d'initialisation.