]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
To fit the tooltip rectangle in the screen borders
authorouv <ouv@opencascade.com>
Tue, 6 Feb 2007 14:22:44 +0000 (14:22 +0000)
committerouv <ouv@opencascade.com>
Tue, 6 Feb 2007 14:22:44 +0000 (14:22 +0000)
src/GLViewer/GLViewer_ViewPort2d.cxx

index 3055726ec0eca88903758397465ce623d648825c..cf065aa64dc0f03cbb9f026b620fb7bfe128e312 100644 (file)
@@ -41,6 +41,7 @@
 #include <qpopupmenu.h>
 #include <qtooltip.h>
 #include <qapplication.h>
+#include <qdesktopwidget.h>
 #include <qclipboard.h>
 #include <qpainter.h>
 #include <qbitmap.h>
@@ -1388,6 +1389,13 @@ void GLViewer_ViewPort2d::onMaybeTip( QPoint thePoint, QString& theText, QFont&
       theTextReg = QRect( thePoint.x(), thePoint.y() + cur_height,
                           aSize.width(), aSize.height() );
       theRegion = QRect( thePoint.x(), thePoint.y(), 1, 1 );
+
+      QPoint aBottomRightGlobal = mapToGlobal( theTextReg.bottomRight() );
+      int dx = aBottomRightGlobal.x() - QApplication::desktop()->screenGeometry().width();
+      int dy = aBottomRightGlobal.y() - QApplication::desktop()->screenGeometry().height();
+      dx = dx < 0 ? 0 : -dx;
+      dy = dy < 0 ? 0 : -dy;
+      theTextReg.moveBy( dx, dy );
     }
   }
 }