From: stv Date: Mon, 14 Nov 2005 07:19:19 +0000 (+0000) Subject: no message X-Git-Tag: V3_1_0a3~22 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=28c48fd075ed1645ab11d042f3fcbb26c032d19e;p=modules%2Fgui.git no message --- diff --git a/src/SUIT/SUIT_Tools.cxx b/src/SUIT/SUIT_Tools.cxx index be7dabfc7..5c6906628 100755 --- a/src/SUIT/SUIT_Tools.cxx +++ b/src/SUIT/SUIT_Tools.cxx @@ -37,9 +37,7 @@ void SUIT_Tools::trace( const char* lpszLog, const char* lpszFormat, ... ) */ QRect SUIT_Tools::makeRect( const int x1, const int y1, const int x2, const int y2 ) { - QRect aRect; - aRect.setRect( QMIN( x1, x2 ), QMIN( y1, y2 ), QABS( x2 - x1 ), QABS( y2 - y1 ) ); - return aRect; + return QRect( QMIN( x1, x2 ), QMIN( y1, y2 ), QABS( x2 - x1 ), QABS( y2 - y1 ) ); } /*! @@ -61,52 +59,10 @@ QString SUIT_Tools::fontToString( const QFont& font ) return font.toString(); } -void SUIT_Tools::centerWidget( QWidget* src, const QWidget* ref ) -{ - SUIT_Tools::alignWidget(src, ref, Qt::AlignCenter); -} - /*! - Aligns widget 'w' as refered to widget 'ref' [ static ] + Center widget 'src' relative to widget 'ref'. */ -void SUIT_Tools::alignWidget ( QWidget* src, const QWidget* ref, int alignFlags ) +void SUIT_Tools::centerWidget( QWidget* src, const QWidget* ref ) { - if ( !src || !ref || !alignFlags ) return; - - QPoint srcOri = src->mapToGlobal( QPoint( 1, 1 ) ); - QPoint refOri = ref->mapToGlobal( QPoint( 1, 1 ) ); - - int x = srcOri.x(), y = srcOri.y(); - int refWidth = ref->width(), refHei = ref->height(); - int srcWidth = src->width(), srcHei = src->height(); - if ( srcWidth <= 1 ) - srcWidth = src->sizeHint().width(); - if ( srcHei <= 1 ) - srcHei = src->sizeHint().height(); - - if ( alignFlags & AlignLeft ) - x = refOri.x(); - if ( alignFlags & AlignRight ) - x = refOri.x() + refWidth - srcWidth; - if ( alignFlags & AlignTop ) - y = refOri.y(); - if ( alignFlags & AlignBottom ) - y = refOri.y() + refHei - srcHei; - if ( alignFlags & AlignHCenter ) - x = refOri.x() + ( refWidth - srcWidth ) / 2; - if ( alignFlags & AlignVCenter ) - y = refOri.y() + ( refHei - srcHei ) / 2; - - if ( src->parentWidget() && /* we move a widget inside its parent */ - !src->inherits( "QDialog" )) /* dialogs use global coordinates */ - { - QPoint pos = src->parentWidget()->mapFromGlobal( QPoint(x,y) ); - x = pos.x(); y = pos.y(); - } -#ifdef WNT - x -= 4; /* - frame border width ( approx. ) */ - y -= 30; /* - caption height ( approx. ) */ -#endif - - src->move( x, y ); + SUIT_Tools::alignWidget( src, ref, Qt::AlignCenter ); } diff --git a/src/SUIT/SUIT_Tools.h b/src/SUIT/SUIT_Tools.h index ec7c4c898..f78df6a94 100755 --- a/src/SUIT/SUIT_Tools.h +++ b/src/SUIT/SUIT_Tools.h @@ -8,10 +8,7 @@ #include #include #include -#include -/*! \class Qtx - * For more information see QT documentation. - */ + class SUIT_EXPORT SUIT_Tools : public Qtx { public: @@ -22,8 +19,6 @@ public: static QFont stringToFont( const QString& fontDescription ); static void centerWidget( QWidget* src, const QWidget* ref ); - static void alignWidget ( QWidget* src, const QWidget* ref, int alignFlags = AlignCenter ); - }; #endif