1 #include "SUIT_Desktop.h"
3 #include "SUIT_Tools.h"
4 #include "SUIT_ViewWindow.h"
6 #include <QtxActionMenuMgr.h>
7 #include <QtxActionToolMgr.h>
11 #include <qdockarea.h>
12 #include <qstatusbar.h>
13 #include <qapplication.h>
23 class LogoBox : public QHBox
26 LogoBox( QWidget* parent = 0, const char* name = 0, WFlags f = 0 ) : QHBox( parent, name, f )
28 setFrameStyle( Plain | NoFrame );
29 setMargin( 0 ); setSpacing( 2 );
31 void addSpacing( int spacing )
33 QApplication::sendPostedEvents( this, QEvent::ChildInserted );
34 ((QHBoxLayout*)layout())->addSpacing( spacing );
37 void drawContents( QPainter* p )
39 if ( parentWidget()->inherits( "QMenuBar" ) )
40 style().drawControl( QStyle::CE_MenuBarEmptyArea, p, this, contentsRect(), colorGroup() );
42 QHBox::drawContents( p );
47 Class: SUIT_Desktop::LogoManager
51 SUIT_Desktop::LogoManager::LogoManager( SUIT_Desktop* desktop)
52 : myDesktop( desktop ), myId( 0 )
56 void SUIT_Desktop::LogoManager::addLogo( const QString& logoID, const QPixmap& logo )
58 if ( !myDesktop || logo.isNull() )
60 myLogoMap[ logoID ] = logo;
64 void SUIT_Desktop::LogoManager::removeLogo( const QString& logoID )
66 if ( !myDesktop || myLogoMap.find( logoID ) == myLogoMap.end() )
68 myLogoMap.remove( logoID );
72 void SUIT_Desktop::LogoManager::clearLogo()
78 void SUIT_Desktop::LogoManager::generateLogo()
80 if ( !myDesktop ) return;
83 myDesktop->menuBar()->removeItem( myId );
86 if ( !myLogoMap.count() )
89 LogoBox* cnt = new LogoBox( myDesktop );
91 QMap<QString, QPixmap>::Iterator it;
92 for ( it = myLogoMap.begin(); it != myLogoMap.end(); ++it ) {
93 QLabel* logoLab = new QLabel( cnt );
94 logoLab->setPixmap( *it );
95 logoLab->setAlignment( QLabel::AlignCenter );
96 logoLab->setScaledContents( false );
100 myId = myDesktop->menuBar()->insertItem( cnt );
101 QApplication::sendPostedEvents( myDesktop->menuBar()->parentWidget(), QEvent::LayoutHint );
102 QApplication::postEvent( myDesktop->menuBar()->parentWidget(), new QEvent( QEvent::LayoutHint ) );
106 /*!\class SUIT_Desktop
107 * Provide desktop management:\n
117 SUIT_Desktop::SUIT_Desktop()
118 : QtxMainWindow(), myLogoMan( this )
120 myMenuMgr = new QtxActionMenuMgr( this );
121 myToolMgr = new QtxActionToolMgr( this );
127 SUIT_Desktop::~SUIT_Desktop()
134 bool SUIT_Desktop::event( QEvent* e )
141 case QEvent::WindowActivate:
144 case QEvent::WindowDeactivate:
149 return QMainWindow::event( e );
155 void SUIT_Desktop::closeEvent( QCloseEvent* e )
157 emit closing( this, e );
164 void SUIT_Desktop::childEvent( QChildEvent* e )
166 if ( e->type() == QEvent::ChildInserted && parentArea() &&
167 e->child()->isWidgetType() && e->child()->inherits( "SUIT_ViewWindow" ) )
168 ((QWidget*)e->child())->reparent( parentArea(), QPoint( 0, 0 ), true );
170 QtxMainWindow::childEvent( e );
176 QtxActionMenuMgr* SUIT_Desktop::menuMgr() const
184 QtxActionToolMgr* SUIT_Desktop::toolMgr() const
190 Adds new logo to the menu bar area
192 void SUIT_Desktop::addLogo( const QString& logoID, const QPixmap& logo )
194 myLogoMan.addLogo( logoID, logo );
200 void SUIT_Desktop::removeLogo( const QString& logoID )
202 myLogoMan.removeLogo( logoID );
208 void SUIT_Desktop::clearLogo()
210 myLogoMan.clearLogo();