From: ouv Date: Tue, 6 Feb 2007 14:22:44 +0000 (+0000) Subject: To fit the tooltip rectangle in the screen borders X-Git-Tag: CTH_V12~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e570710974290cf765e64098e14b44b02ca42471;p=modules%2Fgui.git To fit the tooltip rectangle in the screen borders --- diff --git a/src/GLViewer/GLViewer_ViewPort2d.cxx b/src/GLViewer/GLViewer_ViewPort2d.cxx index 3055726ec..cf065aa64 100644 --- a/src/GLViewer/GLViewer_ViewPort2d.cxx +++ b/src/GLViewer/GLViewer_ViewPort2d.cxx @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -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 ); } } }