Back to index

salome-gui  6.5.0
SUIT_Desktop.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include "SUIT_Desktop.h"
00024 
00025 #include "SUIT_ViewWindow.h"
00026 
00027 #include <QtxLogoMgr.h>
00028 #include <QtxActionMenuMgr.h>
00029 #include <QtxActionToolMgr.h>
00030 
00031 #include <QPointer>
00032 #include <QCloseEvent>
00033 #include <QApplication>
00034 
00042 class SUIT_Desktop::ReparentEvent : public QEvent
00043 {
00044 public:
00045   ReparentEvent( Type t, QObject* obj ) : QEvent( t ), myObj( obj ) {};
00046 
00047   QObject* object() const { return myObj; }
00048 
00049 private:
00050   QPointer<QObject> myObj;
00051 };
00052 
00056 SUIT_Desktop::SUIT_Desktop()
00057 : QtxMainWindow()
00058 {
00059   myMenuMgr = new QtxActionMenuMgr( this );
00060   myToolMgr = new QtxActionToolMgr( this );
00061   myLogoMgr = new QtxLogoMgr( menuBar() );
00062 }
00063 
00067 SUIT_Desktop::~SUIT_Desktop()
00068 {
00069 }
00070 
00074 bool SUIT_Desktop::event( QEvent* e )
00075 {
00076   if ( !e )
00077     return false;
00078 
00079   switch ( e->type() )
00080   {
00081   case QEvent::WindowActivate:
00082     emit activated();
00083     break;
00084   case QEvent::WindowDeactivate:
00085     emit deactivated();
00086     break;
00087   default:
00088     break;
00089   }
00090 
00091   return QtxMainWindow::event( e );
00092 }
00093 
00097 void SUIT_Desktop::closeEvent( QCloseEvent* e )
00098 {
00099   emit closing( this, e );
00100   e->ignore();
00101 }
00102 
00106 void SUIT_Desktop::childEvent( QChildEvent* e )
00107 {
00108   if ( e->type() == QEvent::ChildAdded && e->child()->isWidgetType() )
00109     QApplication::postEvent( this, new ReparentEvent( QEvent::Type( Reparent ), e->child() ) );
00110   else
00111     QtxMainWindow::childEvent( e );
00112 }
00113 
00114 void SUIT_Desktop::customEvent( QEvent* e )
00115 {
00116   if ( (int)e->type() != Reparent )
00117     return;
00118 
00119   ReparentEvent* re = (ReparentEvent*)e;
00120   SUIT_ViewWindow* wid = ::qobject_cast<SUIT_ViewWindow*>( re->object() );
00121   if ( wid )
00122   {
00123     bool invis = wid->testAttribute( Qt::WA_WState_ExplicitShowHide ) &&
00124                  wid->testAttribute( Qt::WA_WState_Hidden );
00125 
00126     addWindow( wid );
00127     wid->setShown( !invis );
00128   }
00129 }
00130 
00134 QtxActionMenuMgr* SUIT_Desktop::menuMgr() const
00135 {
00136   return myMenuMgr;
00137 }
00138 
00142 QtxActionToolMgr* SUIT_Desktop::toolMgr() const
00143 {
00144   return myToolMgr;
00145 }
00146 
00150 QtxLogoMgr* SUIT_Desktop::logoMgr() const
00151 {
00152   return myLogoMgr;
00153 }
00154 
00158 int SUIT_Desktop::logoCount() const
00159 {
00160   return 0;
00161 
00162   if ( !myLogoMgr )
00163     return 0;
00164   else
00165     return myLogoMgr->count();
00166 }
00167 
00171 void SUIT_Desktop::logoInsert( const QString& logoID, QMovie* logo, const int idx )
00172 {
00173   if ( myLogoMgr )
00174     myLogoMgr->insert( logoID, logo, idx );
00175 }
00176 
00180 void SUIT_Desktop::logoInsert( const QString& logoID, const QPixmap& logo, const int idx )
00181 {
00182   if ( myLogoMgr )
00183     myLogoMgr->insert( logoID, logo, idx );
00184 }
00185 
00189 void SUIT_Desktop::logoRemove( const QString& logoID )
00190 {
00191   if ( myLogoMgr )
00192     myLogoMgr->remove( logoID );
00193 }
00194 
00198 void SUIT_Desktop::logoClear()
00199 {
00200   if ( myLogoMgr )
00201     myLogoMgr->clear();
00202 }
00203 
00207 void SUIT_Desktop::emitActivated()
00208 {
00209   emit activated();
00210 }
00211 
00215 void SUIT_Desktop::emitMessage( const QString& theMessage )
00216 {
00217   emit message( theMessage );
00218 }