00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #include "QmitkApplicationCursor.h" 00019 00020 #include <qapplication.h> 00021 #include <qcursor.h> 00022 #include <qpixmap.h> 00023 00024 #include <iostream> 00025 00026 QmitkApplicationCursor::QmitkApplicationCursor() 00027 { 00028 mitk::ApplicationCursor::RegisterImplementation(this); 00029 } 00030 00031 void QmitkApplicationCursor::PushCursor(const char* XPM[], int hotspotX, int hotspotY) 00032 { 00033 QPixmap pixmap( XPM ); 00034 QCursor cursor( pixmap, hotspotX, hotspotY ); // no test for validity in QPixmap(xpm)! 00035 QApplication::setOverrideCursor( cursor ); 00036 } 00037 00038 void QmitkApplicationCursor::PopCursor() 00039 { 00040 QApplication::restoreOverrideCursor(); 00041 } 00042 00043 const mitk::Point2I QmitkApplicationCursor::GetCursorPosition() 00044 { 00045 mitk::Point2I mp; 00046 QPoint qp = QCursor::pos(); 00047 mp[0] = qp.x(); 00048 mp[1] = qp.y(); 00049 return mp; 00050 } 00051 00052 void QmitkApplicationCursor::SetCursorPosition(const mitk::Point2I& p) 00053 { 00054 static bool selfCall = false; 00055 if (selfCall) return; // this is to avoid recursive calls 00056 selfCall = true; 00057 QCursor::setPos( p[0], p[1] ); 00058 selfCall = false; 00059 } 00060 00061