From: stv Date: Mon, 30 May 2005 04:44:19 +0000 (+0000) Subject: no message X-Git-Tag: T3_0_0_a1~85 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4d7899038653ed1ada6764e0afb3683bcdb47105;p=modules%2Fgui.git no message --- diff --git a/src/Qtx/Makefile.in b/src/Qtx/Makefile.in index 54a54311a..726818f95 100755 --- a/src/Qtx/Makefile.in +++ b/src/Qtx/Makefile.in @@ -35,6 +35,7 @@ EXPORT_HEADERS= Qtx.h \ QtxToolBar.h \ QtxToolTip.h \ QtxParser.h \ + QtxPopupMenu.h \ QtxActionMgr.h \ QtxActionMenuMgr.h \ QtxActionToolMgr.h \ @@ -77,6 +78,7 @@ LIB_SRC= \ QtxToolTip.cxx \ QtxOperations.cxx \ QtxParser.cxx \ + QtxPopupMenu.cxx \ QtxActionMgr.cxx \ QtxActionMenuMgr.cxx \ QtxActionToolMgr.cxx \ @@ -103,6 +105,7 @@ LIB_MOC = \ QtxMRUAction.h \ QtxPathDialog.h \ QtxPopupMgr.h \ + QtxPopupMenu.h \ QtxToolBar.h \ QtxToolTip.h \ QtxActionMgr.h \ diff --git a/src/Qtx/QtxDockWindow.cxx b/src/Qtx/QtxDockWindow.cxx index 3053938de..0432faa5c 100644 --- a/src/Qtx/QtxDockWindow.cxx +++ b/src/Qtx/QtxDockWindow.cxx @@ -121,10 +121,8 @@ void QtxDockWindow::Watcher::updateVisibility() } } - if ( vis ) - myCont->show(); - else - myCont->hide(); + if ( vis != myCont->isVisibleTo( myCont->parentWidget() ) ) + vis ? myCont->show() : myCont->hide(); } void QtxDockWindow::Watcher::updateIcon() diff --git a/src/Qtx/QtxPopupMenu.cxx b/src/Qtx/QtxPopupMenu.cxx new file mode 100644 index 000000000..f041f5db1 --- /dev/null +++ b/src/Qtx/QtxPopupMenu.cxx @@ -0,0 +1,237 @@ +#include "QtxPopupMenu.h" + +#include + +/*! + Class: QtxPopupMenu::TitleMenuItem [Internal] + Descr: Custom menu item for popup title. +*/ + +class QtxPopupMenu::TitleMenuItem : public QCustomMenuItem +{ +public: + TitleMenuItem( const QString&, const QIconSet&, const int ); + virtual ~TitleMenuItem(); + + virtual bool fullSpan() const; + virtual bool isSeparator() const; + virtual void setFont( const QFont& ); + + virtual void paint( QPainter*, const QColorGroup&, bool, bool, int, int, int, int ); + virtual QSize sizeHint(); + +private: + QString myText; + QIconSet myIcon; + QFont myFont; + int myAlign; +}; + +QtxPopupMenu::TitleMenuItem::TitleMenuItem( const QString& txt, const QIconSet& ico, const int align ) +: QCustomMenuItem(), +myText( txt ), +myIcon( ico ), +myAlign( align ) +{ +} + +QtxPopupMenu::TitleMenuItem::~TitleMenuItem() +{ +} + +bool QtxPopupMenu::TitleMenuItem::fullSpan() const +{ + return true; +} + +bool QtxPopupMenu::TitleMenuItem::isSeparator() const +{ + return false; +} + +void QtxPopupMenu::TitleMenuItem::setFont( const QFont& font ) +{ + myFont = font; + myFont.setBold( true ); +} + +void QtxPopupMenu::TitleMenuItem::paint( QPainter* p, const QColorGroup& cg, + bool act, bool enabled, int x, int y, int w, int h ) +{ + QFont f = p->font(); + p->setFont( myFont ); + + p->fillRect( x, y, w, h, cg.brush( QColorGroup::Mid ) ); + + p->setPen( cg.shadow() ); + p->drawRect( x, y, w, h ); + + int m = 3; + int s = 3; + int iw = p->fontMetrics().width( myText ) + ( myIcon.isNull() ? 0 : myIcon.pixmap().width() + s ); + int ih = QMAX( ( myIcon.isNull() ? 0 : myIcon.pixmap().height() ), p->fontMetrics().height() ); + + int ix = x; + int iy = y + m; + + if ( myAlign & AlignLeft ) + ix = x; + else if ( myAlign & AlignRight ) + ix = x + ( w - iw ); + else if ( myAlign & AlignHCenter ) + ix = x + ( w - iw ) / 2; + + if ( myAlign & AlignTop ) + iy = y; + else if ( myAlign & AlignBottom ) + iy = y + ( h - ih - m ); + else if ( myAlign & AlignVCenter ) + iy = y + ( h - ih ) / 2; + + if ( !myIcon.isNull() ) + { + p->drawPixmap( ix, iy + ( ih - myIcon.pixmap().height() ) / 2, myIcon.pixmap() ); + ix += myIcon.pixmap().width() + s; + } + + p->setPen( cg.brightText() ); + p->drawText( ix, iy + ( ih - p->fontMetrics().height() ) / 2 + + p->fontMetrics().ascent(), myText, 0, -1 ); + + p->setFont( f ); +} + +QSize QtxPopupMenu::TitleMenuItem::sizeHint() +{ + QFontMetrics fM( myFont ); + + int m = 3; + int s = 3; + int w = fM.width( myText ) + ( myIcon.isNull() ? 0 : myIcon.pixmap().width() + s ); + int h = QMAX( ( myIcon.isNull() ? 0 : myIcon.pixmap().height() ), fM.height() ) + 2 * m; + + return QSize( w, h ); +} + +/*! + Class: QtxPopupMenu [Public] + Descr: Popup menu item with title. +*/ + +QtxPopupMenu::QtxPopupMenu( QWidget* parent, const char* name ) +: QPopupMenu( parent, name ), +myId( -1 ), +myPolicy( TitleAuto ), +myAlign( AlignCenter ) +{ +} + +QtxPopupMenu::~QtxPopupMenu() +{ +} + +QString QtxPopupMenu::titleText() const +{ + return myText; +} + +QIconSet QtxPopupMenu::titleIcon() const +{ + return myIcon; +} + +int QtxPopupMenu::titlePolicy() const +{ + return myPolicy; +} + +int QtxPopupMenu::titleAlignment() const +{ + return myAlign; +} + +void QtxPopupMenu::setTitleText( const QString& txt ) +{ + if ( myText == txt ) + return; + + myText = txt; + + updateTitle(); +} + +void QtxPopupMenu::setTitleIcon( const QIconSet& ico ) +{ + myIcon = ico; + + updateTitle(); +} + +void QtxPopupMenu::setTitlePolicy( const int p ) +{ + if ( myPolicy == p ) + return; + + myPolicy = p; + + updateTitle(); +} + +void QtxPopupMenu::setTitleAlignment( const int a ) +{ + if ( myAlign == a ) + return; + + myAlign = a; + + updateTitle(); +} + +void QtxPopupMenu::show() +{ + insertTitle(); + + QPopupMenu::show(); +} + +void QtxPopupMenu::hide() +{ + QPopupMenu::hide(); + + removeTitle(); +} + +QtxPopupMenu::TitleMenuItem* QtxPopupMenu::createTitleItem( const QString& txt, const QIconSet& ico, + const int align ) const +{ + return new TitleMenuItem( txt, ico, align ); +} + +void QtxPopupMenu::insertTitle() +{ + if ( myId != -1 || titlePolicy() == TitleOff || + ( titlePolicy() == TitleAuto && titleText().stripWhiteSpace().isEmpty() ) ) + return; + + TitleMenuItem* item = createTitleItem( titleText(), titleIcon(), titleAlignment() ); + + myId = insertItem( item, -1, 0 ); +} + +void QtxPopupMenu::removeTitle() +{ + if ( myId == -1 ) + return; + + removeItem( myId ); + myId = -1; +} + +void QtxPopupMenu::updateTitle() +{ + if ( myId != -1 ) + { + removeTitle(); + insertTitle(); + } +} diff --git a/src/Qtx/QtxPopupMenu.h b/src/Qtx/QtxPopupMenu.h new file mode 100644 index 000000000..2ddb1b3b7 --- /dev/null +++ b/src/Qtx/QtxPopupMenu.h @@ -0,0 +1,56 @@ +#ifndef QTXPOPUPMENU_H +#define QTXPOPUPMENU_H + +#include "Qtx.h" + +#include +#include +#include + +class QTX_EXPORT QtxPopupMenu : public QPopupMenu +{ + Q_OBJECT + +protected: + class TitleMenuItem; + +public: + enum { TitleAuto, TitleOn, TitleOff }; + +public: + QtxPopupMenu( QWidget* = 0, const char* = 0 ); + virtual ~QtxPopupMenu(); + + QString titleText() const; + QIconSet titleIcon() const; + + int titlePolicy() const; + int titleAlignment() const; + + virtual void setTitleText( const QString& ); + virtual void setTitleIcon( const QIconSet& ); + + virtual void setTitlePolicy( const int ); + virtual void setTitleAlignment( const int ); + +public slots: + virtual void show(); + virtual void hide(); + +protected: + virtual TitleMenuItem* createTitleItem( const QString&, const QIconSet&, const int ) const; + +private: + void updateTitle(); + void insertTitle(); + void removeTitle(); + +private: + int myId; + QString myText; + QIconSet myIcon; + int myAlign; + int myPolicy; +}; + +#endif diff --git a/src/Qtx/QtxToolBar.cxx b/src/Qtx/QtxToolBar.cxx index b132fe9b0..094923942 100644 --- a/src/Qtx/QtxToolBar.cxx +++ b/src/Qtx/QtxToolBar.cxx @@ -143,10 +143,8 @@ void QtxToolBar::Watcher::updateVisibility() } } - if ( vis ) - myCont->show(); - else - myCont->hide(); + if ( vis != myCont->isVisibleTo( myCont->parentWidget() ) ) + vis ? myCont->show() : myCont->hide(); } void QtxToolBar::Watcher::updateIcon() diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index eccdfc90d..41392ffa9 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -68,10 +68,15 @@ void STD_Application::onDesktopClosing( SUIT_Desktop*, QCloseEvent* e ) } SUIT_Study* study = activeStudy(); + + if ( study ) + study->closeDocument(); + setActiveStudy( 0 ); delete study; setDesktop( 0 ); + closeApplication(); } @@ -303,13 +308,9 @@ void STD_Application::onCloseDoc() } afterCloseDoc(); - closeApplication(); -} -void STD_Application::closeApplication() -{ if ( !desktop() ) - emit applicationClosed( this ); + closeApplication(); } bool STD_Application::isPossibleToClose() diff --git a/src/STD/STD_Application.h b/src/STD/STD_Application.h index 77349a098..1e2427e57 100755 --- a/src/STD/STD_Application.h +++ b/src/STD/STD_Application.h @@ -35,7 +35,6 @@ public: virtual QString applicationName() const; virtual bool isPossibleToClose(); - virtual void closeApplication(); virtual void useFile( const QString& ); virtual void createEmptyStudy(); diff --git a/src/SUIT/SUIT_Application.cxx b/src/SUIT/SUIT_Application.cxx index f14f1947e..22e16df1d 100755 --- a/src/SUIT/SUIT_Application.cxx +++ b/src/SUIT/SUIT_Application.cxx @@ -33,6 +33,11 @@ bool SUIT_Application::isPossibleToClose() return true; } +void SUIT_Application::closeApplication() +{ + emit applicationClosed( this ); +} + SUIT_Study* SUIT_Application::activeStudy() const { return myStudy; diff --git a/src/SUIT/SUIT_Application.h b/src/SUIT/SUIT_Application.h index 52e545116..bcf33bae3 100755 --- a/src/SUIT/SUIT_Application.h +++ b/src/SUIT/SUIT_Application.h @@ -37,6 +37,8 @@ public: This method called by SUIT_Session whin closing of application was requested. */ virtual bool isPossibleToClose(); + virtual void closeApplication(); + //! Returns active Study. If Application supports wirking with several studies this method should be redefined virtual SUIT_Study* activeStudy() const; diff --git a/src/SUIT/SUIT_Session.cxx b/src/SUIT/SUIT_Session.cxx index d2c547c1d..08d85b0f4 100755 --- a/src/SUIT/SUIT_Session.cxx +++ b/src/SUIT/SUIT_Session.cxx @@ -191,12 +191,14 @@ void SUIT_Session::onApplicationClosed( SUIT_Application* theApp ) */ void SUIT_Session::closeSession() { - for ( AppListIterator it( myAppList ); it.current(); ++it ) + while ( !myAppList.isEmpty() ) { - if ( !it.current()->isPossibleToClose() ) + SUIT_Application* app = myAppList.getFirst(); + if ( !app->isPossibleToClose() ) return; + + app->closeApplication(); } - qApp->quit(); } SUIT_ExceptionHandler* SUIT_Session::handler() const diff --git a/src/TOOLSGUI/ToolsGUI.h b/src/TOOLSGUI/ToolsGUI.h index 25b884d53..08cf540f2 100755 --- a/src/TOOLSGUI/ToolsGUI.h +++ b/src/TOOLSGUI/ToolsGUI.h @@ -29,6 +29,8 @@ #ifndef ToolsGUI_HeaderFile #define ToolsGUI_HeaderFile +#include "utilities.h" + #ifndef _Standard_HeaderFile #include #endif diff --git a/src/VTKViewer/VTKViewer_ConvexTool.cxx b/src/VTKViewer/VTKViewer_ConvexTool.cxx index 58a755f5b..5d0736baa 100644 --- a/src/VTKViewer/VTKViewer_ConvexTool.cxx +++ b/src/VTKViewer/VTKViewer_ConvexTool.cxx @@ -18,7 +18,6 @@ #include #include -#include static float FACE_TOLERANCE = 0; diff --git a/src/VTKViewer/VTKViewer_ConvexTool.h b/src/VTKViewer/VTKViewer_ConvexTool.h index baac7e163..f305140b0 100644 --- a/src/VTKViewer/VTKViewer_ConvexTool.h +++ b/src/VTKViewer/VTKViewer_ConvexTool.h @@ -17,13 +17,6 @@ // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // -// -// -// File : VTKViewer_ConvexTool.h -// Author : Eugeny Nikolaev -// Module : SALOME -// $Header$ - #ifndef _VTKViewer_ConvexTool_H #define _VTKViewer_ConvexTool_H @@ -36,10 +29,9 @@ typedef std::vector TCell; // ptsIds typedef std::map TCellArray; // CellId, TCell -namespace CONVEX_TOOL{ - +namespace CONVEX_TOOL +{ void GetPolygonalFaces(vtkUnstructuredGrid* theCell,int cellId,TCellArray &outputCellArray); } #endif // _VTKViewer_ConvexTool_H -