#include <qdockarea.h>
#include <qstatusbar.h>
#include <qapplication.h>
+#include <qhbox.h>
+#include <qlabel.h>
+#include <qstyle.h>
+
+/*!
+ Class: LogoBox
+ Level: Internal
+*/
+
+class LogoBox : public QHBox
+{
+public:
+ LogoBox( QWidget* parent = 0, const char* name = 0, WFlags f = 0 ) : QHBox( parent, name, f )
+ {
+ setFrameStyle( Plain | NoFrame );
+ setMargin( 0 ); setSpacing( 2 );
+ }
+ void addSpacing( int spacing )
+ {
+ QApplication::sendPostedEvents( this, QEvent::ChildInserted );
+ ((QHBoxLayout*)layout())->addSpacing( spacing );
+ }
+protected:
+ void drawContents( QPainter* p )
+ {
+ if ( parentWidget()->inherits( "QMenuBar" ) )
+ style().drawControl( QStyle::CE_MenuBarEmptyArea, p, this, contentsRect(), colorGroup() );
+ else
+ QHBox::drawContents( p );
+ }
+};
+
+/*!
+ Class: SUIT_Desktop::LogoManager
+ Level: Internal
+*/
+
+SUIT_Desktop::LogoManager::LogoManager( SUIT_Desktop* desktop)
+: myDesktop( desktop ), myId( 0 )
+{
+}
+
+void SUIT_Desktop::LogoManager::addLogo( const QString& logoID, const QPixmap& logo )
+{
+ if ( !myDesktop || logo.isNull() )
+ return;
+ myLogoMap[ logoID ] = logo;
+ generateLogo();
+}
+
+void SUIT_Desktop::LogoManager::removeLogo( const QString& logoID )
+{
+ if ( !myDesktop || myLogoMap.find( logoID ) == myLogoMap.end() )
+ return;
+ myLogoMap.remove( logoID );
+ generateLogo();
+}
+
+void SUIT_Desktop::LogoManager::clearLogo()
+{
+ myLogoMap.clear();
+ generateLogo();
+}
+
+void SUIT_Desktop::LogoManager::generateLogo()
+{
+ if ( !myDesktop ) return;
+
+ if ( myId )
+ myDesktop->menuBar()->removeItem( myId );
+ myId = 0;
+
+ if ( !myLogoMap.count() )
+ return;
+
+ LogoBox* cnt = new LogoBox( myDesktop );
+
+ QMap<QString, QPixmap>::Iterator it;
+ for ( it = myLogoMap.begin(); it != myLogoMap.end(); ++it ) {
+ QLabel* logoLab = new QLabel( cnt );
+ logoLab->setPixmap( *it );
+ logoLab->setAlignment( QLabel::AlignCenter );
+ logoLab->setScaledContents( false );
+ }
+ cnt->addSpacing( 2 );
+
+ myId = myDesktop->menuBar()->insertItem( cnt );
+ QApplication::sendPostedEvents( myDesktop->menuBar()->parentWidget(), QEvent::LayoutHint );
+ QApplication::postEvent( myDesktop->menuBar()->parentWidget(), new QEvent( QEvent::LayoutHint ) );
+}
+
/*!\class SUIT_Desktop
* Provide desktop management:\n
* \li windows
*/
+
/*!
Constructor.
*/
SUIT_Desktop::SUIT_Desktop()
-: QtxMainWindow()
+: QtxMainWindow(), myLogoMan( this )
{
myMenuMgr = new QtxActionMenuMgr( this );
myToolMgr = new QtxActionToolMgr( this );
{
return myToolMgr;
}
+
+/*!
+ Adds new logo to the menu bar area
+*/
+void SUIT_Desktop::addLogo( const QString& logoID, const QPixmap& logo )
+{
+ myLogoMan.addLogo( logoID, logo );
+}
+
+/*!
+ Removes a logo
+*/
+void SUIT_Desktop::removeLogo( const QString& logoID )
+{
+ myLogoMan.removeLogo( logoID );
+}
+
+/*!
+ Removes all logos
+*/
+void SUIT_Desktop::clearLogo()
+{
+ myLogoMan.clearLogo();
+}
+
+
#include "SUIT.h"
+#include <qmap.h>
#include <QtxMainWindow.h>
class QPopupMenu;
{
Q_OBJECT
+ class LogoManager
+ {
+ public:
+ LogoManager( SUIT_Desktop* );
+ void addLogo( const QString&, const QPixmap& );
+ void removeLogo( const QString& );
+ void clearLogo();
+
+ private:
+ void generateLogo();
+
+ private:
+ SUIT_Desktop* myDesktop;
+ QMap<QString, QPixmap> myLogoMap;
+ int myId;
+ };
+
public:
SUIT_Desktop();
virtual ~SUIT_Desktop();
virtual SUIT_ViewWindow* activeWindow() const = 0;
virtual QPtrList<SUIT_ViewWindow> windows() const = 0;
+ void addLogo( const QString&, const QPixmap& );
+ void removeLogo( const QString& );
+ void clearLogo();
+
signals:
void activated();
void deactivated();
private:
QtxActionMenuMgr* myMenuMgr;
QtxActionToolMgr* myToolMgr;
+ LogoManager myLogoMan;
};
#endif