diff --git a/data/themes/default/style.css b/data/themes/default/style.css index 2f56963b1..1df96fa90 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -150,6 +150,14 @@ QToolButton:checked { padding: 3px 0px 0px 3px; } +SideBar { + background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop: 0 #66728c, stop: 1.0 #38404e); +} + +SideBar QToolButton { + font-size: 12px; +} + FxMixerView QPushButton, EffectRackView QPushButton, ControllerRackView QPushButton { font-size: 10px; } diff --git a/include/ResourceBrowser.h b/include/ResourceBrowser.h index c23ae6496..bebb354d3 100644 --- a/include/ResourceBrowser.h +++ b/include/ResourceBrowser.h @@ -29,7 +29,7 @@ #include "ResourceAction.h" #include "ResourcePreviewer.h" #include "ResourceTreeModel.h" -#include "side_bar_widget.h" +#include "SideBarWidget.h" class QAction; class QLabel; @@ -37,7 +37,7 @@ class ResourceItem; class ResourceTreeView; -class ResourceBrowser : public sideBarWidget +class ResourceBrowser : public SideBarWidget { Q_OBJECT public: diff --git a/include/SideBar.h b/include/SideBar.h new file mode 100644 index 000000000..9a544b8bb --- /dev/null +++ b/include/SideBar.h @@ -0,0 +1,57 @@ +/* + * SideBar.h - side-bar in LMMS' MainWindow + * + * Copyright (c) 2004-2009 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#ifndef _SIDE_BAR_H +#define _SIDE_BAR_H + +#include +#include +#include + +class QToolButton; +class SideBarWidget; + + +class SideBar : public QToolBar +{ + Q_OBJECT +public: + SideBar( Qt::Orientation _orientation, QWidget * _parent ); + virtual ~SideBar(); + + void appendTab( SideBarWidget * _sbw ); + + +private slots: + void toggleButton( QAbstractButton * _btn ); + + +private: + QButtonGroup m_btnGroup; + typedef QMap ButtonMap; + ButtonMap m_widgets; + +} ; + +#endif diff --git a/include/side_bar_widget.h b/include/SideBarWidget.h similarity index 78% rename from include/side_bar_widget.h rename to include/SideBarWidget.h index ab87882df..0efc0da9b 100644 --- a/include/side_bar_widget.h +++ b/include/SideBarWidget.h @@ -1,8 +1,8 @@ /* - * side_bar_widget.h - base-class for all side-bar-widgets + * SideBarWidget.h - base-class for all side-bar-widgets * * Copyright (c) 2004-2009 Tobias Doerffel - * + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -22,7 +22,6 @@ * */ - #ifndef _SIDE_BAR_WIDGET_H #define _SIDE_BAR_WIDGET_H @@ -31,41 +30,42 @@ #include -class sideBarWidget : public QWidget +class SideBarWidget : public QWidget { Q_OBJECT public: - sideBarWidget( const QString & _title, const QPixmap & _icon, + SideBarWidget( const QString & _title, const QPixmap & _icon, QWidget * _parent ); - virtual ~sideBarWidget(); + virtual ~SideBarWidget(); + inline const QPixmap & icon() const { - return( m_icon ); + return m_icon; } inline const QString & title() const { - return( m_title ); + return m_title; } protected: virtual void paintEvent( QPaintEvent * _pe ); virtual void resizeEvent( QResizeEvent * _re ); - inline virtual void contextMenuEvent( QContextMenuEvent * ) + virtual void contextMenuEvent( QContextMenuEvent * ) { } - inline QWidget * contentParent() + QWidget * contentParent() { return( m_contents ); } - inline void addContentWidget( QWidget * _w ) + void addContentWidget( QWidget * _w ) { m_layout->addWidget( _w ); } - inline void addContentLayout( QLayout * _l ) + void addContentLayout( QLayout * _l ) { m_layout->addLayout( _l ); } @@ -79,5 +79,4 @@ private: } ; - #endif diff --git a/include/kmultitabbar.h b/include/kmultitabbar.h deleted file mode 100644 index 3bec1ee9d..000000000 --- a/include/kmultitabbar.h +++ /dev/null @@ -1,309 +0,0 @@ -/*************************************************************************** - kmultitabbar.h - description - ------------------- - begin : 2001 - copyright : (C) 2001,2002,2003 by Joseph Wenninger - ***************************************************************************/ - -/*************************************************************************** - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - ***************************************************************************/ - -#ifndef _KMultitabbar_h_ -#define _KMultitabbar_h_ - -#include -#include -#include -#include - -class QPixmap; -class QPainter; -class QFrame; -class QMenu; - -class KMultiTabBarPrivate; -class KMultiTabBarTabPrivate; -class KMultiTabBarButtonPrivate; -class KMultiTabBarInternal; - -/** - * A Widget for horizontal and vertical tabs. - * It is possible to add normal buttons to the top/left - * The handling if only one tab at a time or multiple tabs - * should be raisable is left to the "user". - *@author Joseph Wenninger - */ -class KMultiTabBar: public QWidget -{ - Q_OBJECT -public: - enum KMultiTabBarMode{Horizontal, Vertical}; - enum KMultiTabBarPosition{Left, Right, Top, Bottom}; - - /** - * The list of available styles for KMultiTabBar - * - VSNET - Visual Studio .Net like (only show the text of active tabs - * - KDEV3 - Kdevelop 3 like (always show the text) - * - KONQSBC - konqy's classic sidebar style (unthemed) (currently disabled) - */ - enum KMultiTabBarStyle{VSNET=0, KDEV3=1, KONQSBC=2, KDEV3ICON=3,STYLELAST=0xffff}; - - KMultiTabBar(KMultiTabBarMode bm,QWidget *parent=0 ); - virtual ~KMultiTabBar(); - - /** - * append a new button to the button area. The button can later on be accessed with button(ID) - * eg for connecting signals to it - * @param pic a pixmap for the button - * @param id an arbitraty ID value. It will be emitted in the clicked signal for identifying the button - * if more than one button is connected to a signals. - * @param popup A popup menu which should be displayed if the button is clicked - * @param not_used_yet will be used for a popup text in the future - */ - int appendButton(const QPixmap &pic,int id=-1,QMenu* popup=0,const QString& not_used_yet=QString()); - /** - * remove a button with the given ID - */ - void removeButton(int id); - /** - * append a new tab to the tab area. It can be accessed lateron with tabb(id); - * @param pic a bitmap for the tab - * @param id an arbitrary ID which can be used later on to identify the tab - * @param text if a mode with text is used it will be the tab text, otherwise a mouse over hint - */ - int appendTab(const QPixmap &pic,int id=-1,const QString& text=QString()); - /** - * remove a tab with a given ID - */ - void removeTab(int id); - /** - * set a tab to "raised" - * @param id The ID of the tab to manipulate - * @param state true == activated/raised, false == not active - */ - void setTab(int id ,bool state); - /** - * return the state of a tab, identified by it's ID - */ - bool isTabRaised(int id) const; - /** - * get a pointer to a button within the button area identified by its ID - */ - class KMultiTabBarButton *button(int id) const; - - /** - * get a pointer to a tab within the tab area, identiifed by its ID - */ - class KMultiTabBarTab *tab(int id) const; - /** - * set the real position of the widget. - * @param pos if the mode is horizontal, only use top, bottom, if it is vertical use left or right - */ - void setPosition(KMultiTabBarPosition pos); - /** - * get the tabbar position. - * @return position - */ - KMultiTabBarPosition position() const; - /** - * set the display style of the tabs - */ - void setStyle(KMultiTabBarStyle style); - /** - * get the display style of the tabs - * @return display style - */ - KMultiTabBarStyle tabStyle() const; - /** - * be carefull, don't delete tabs yourself and don't delete the list itself - */ - QList* tabs(); - /** - * be carefull, don't delete buttons yourself and don't delete the list itself - */ - QList* buttons(); - - /** - * might vanish, not sure yet - */ - void showActiveTabTexts(bool show=true); -protected: - friend class KMultiTabBarButton; - virtual void fontChange( const QFont& ); - void updateSeparator(); -private: - class KMultiTabBarInternal *m_internal; - QBoxLayout *m_l; - QFrame *m_btnTabSep; - QList m_buttons; - KMultiTabBarPosition m_position; - KMultiTabBarPrivate *d; -}; - -/** - * This class should never be created except with the appendButton call of KMultiTabBar - */ -class KMultiTabBarButton: public QPushButton -{ - Q_OBJECT -public: - KMultiTabBarButton(const QPixmap& pic,const QString&, QMenu *popup, - int id,QWidget *parent, KMultiTabBar::KMultiTabBarPosition pos, KMultiTabBar::KMultiTabBarStyle style); - KMultiTabBarButton(const QString&, QMenu *popup, - int id,QWidget *parent, KMultiTabBar::KMultiTabBarPosition pos, KMultiTabBar::KMultiTabBarStyle style); - virtual ~KMultiTabBarButton(); - int id() const; - -public slots: - /** - * this is used internaly, but can be used by the user, if (s)he wants to - * It the according call of KMultiTabBar is invoked though this modifications will be overwritten - */ - void setPosition(KMultiTabBar::KMultiTabBarPosition); - /** - * this is used internaly, but can be used by the user, if (s)he wants to - * It the according call of KMultiTabBar is invoked though this modifications will be overwritten - */ - void setStyle(KMultiTabBar::KMultiTabBarStyle); - - /** - * modify the text of the button - */ - void setText(const QString &); - - QSize sizeHint() const; - -protected: - KMultiTabBar::KMultiTabBarPosition m_position; - KMultiTabBar::KMultiTabBarStyle m_style; - QString m_text; - virtual void hideEvent( class QHideEvent*); - virtual void showEvent( class QShowEvent*); -private: - int m_id; - KMultiTabBarButtonPrivate *d; -signals: - /** - * this is emitted if the button is clicked - * @param id the ID identifying the button - */ - void clicked(int id); -protected slots: - virtual void slotClicked(); -}; - -/** - * This class should never be created except with the appendTab call of KMultiTabBar - */ -class KMultiTabBarTab: public KMultiTabBarButton -{ - Q_OBJECT -public: - KMultiTabBarTab(const QPixmap& pic,const QString&,int id,QWidget *parent, - KMultiTabBar::KMultiTabBarPosition pos,KMultiTabBar::KMultiTabBarStyle style); - virtual ~KMultiTabBarTab(); - /** - * set the active state of the tab - * @param state true==active false==not active - */ - void setState(bool state); - /** - * choose if the text should always be displayed - * this is only used in classic mode if at all - */ - void showActiveTabText(bool show); - void resize(){ setSize( neededSize() ); } -private: - bool m_showActiveTabText; - int m_expandedSize; - KMultiTabBarTabPrivate *d; -protected: - friend class KMultiTabBarInternal; - void setSize(int); - int neededSize(); - void updateState(); - virtual void paintEvent(QPaintEvent *); - virtual void drawButton(QPainter *); - virtual void drawButtonLabel(QPainter *); - void drawButtonStyled(QPainter *); - void drawButtonClassic(QPainter *); -protected slots: - virtual void slotClicked(); - void setTabsPosition(KMultiTabBar::KMultiTabBarPosition); - -public slots: - virtual void setIcon(const QString&); - virtual void setIcon(const QPixmap&); -}; -/*************************************************************************** - kmultitabbar_p.h - description - ------------------- - begin : 2003 - copyright : (C) 2003 by Joseph Wenninger - ***************************************************************************/ - -/*************************************************************************** - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - ***************************************************************************/ - - -class KMultiTabBarInternal: public QWidget -{ - Q_OBJECT -public: - KMultiTabBarInternal(QWidget *parent,KMultiTabBar::KMultiTabBarMode bm); - int appendTab(const QPixmap &,int=-1,const QString& =QString()); - KMultiTabBarTab *tab(int) const; - void removeTab(int); - void setPosition(enum KMultiTabBar::KMultiTabBarPosition pos); - void setStyle(enum KMultiTabBar::KMultiTabBarStyle style); - void showActiveTabTexts(bool show); - QList* tabs(){return &m_tabs;} -private: - friend class KMultiTabBar; - QWidget *box; - QBoxLayout *mainLayout; - QList m_tabs; - enum KMultiTabBar::KMultiTabBarPosition m_position; - bool m_showActiveTabTexts; - enum KMultiTabBar::KMultiTabBarStyle m_style; - int m_expandedTabSize; - int m_lines; - KMultiTabBar::KMultiTabBarMode m_barMode; -protected: - virtual bool eventFilter(QObject *,QEvent*); -// virtual void paintEvent( QPaintEvent * ); - - virtual void resizeEvent(QResizeEvent *); -}; - - - -#endif diff --git a/include/plugin_browser.h b/include/plugin_browser.h index b0d66ae06..b0473b7f4 100644 --- a/include/plugin_browser.h +++ b/include/plugin_browser.h @@ -28,14 +28,14 @@ #include #include -#include "side_bar_widget.h" +#include "SideBarWidget.h" #include "Plugin.h" class trackContainer; -class pluginBrowser : public sideBarWidget +class pluginBrowser : public SideBarWidget { Q_OBJECT public: diff --git a/include/side_bar.h b/include/side_bar.h deleted file mode 100644 index 29fd4e6bc..000000000 --- a/include/side_bar.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * side_bar.h - code for side-bar in LMMS - * - * Copyright (c) 2004-2008 Tobias Doerffel - * - * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program (see COPYING); if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - */ - - -#ifndef _SIDE_BAR_H -#define _SIDE_BAR_H - -#include - -#include "kmultitabbar.h" -#include "side_bar_widget.h" - - -class sideBar : public KMultiTabBar -{ - Q_OBJECT -public: - sideBar( KMultiTabBarMode _m, QWidget * _parent ) : - KMultiTabBar( _m, _parent ) - { - } - - virtual ~sideBar() - { - } - - inline int appendTab( sideBarWidget * _sbw, int _id ) - { - int ret = KMultiTabBar::appendTab( _sbw->icon(), _id, - _sbw->title() ); - m_widgets[_id] = _sbw; - _sbw->hide(); - _sbw->setMinimumWidth( 200 ); - connect( tab( _id ), SIGNAL( clicked( int ) ), this, - SLOT( tabClicked( int ) ) ); - return( ret ); - } - - -private slots: - inline void tabClicked( int _id ) - { - // disable all other tabbar-buttons - QMap::Iterator it; - for( it = m_widgets.begin(); it != m_widgets.end(); ++it ) - { - if( it.key() != _id/* && isTabRaised(it.key()) == true*/ ) - { - setTab( it.key(), false ); - } - if( m_widgets[it.key()] != NULL ) - { - m_widgets[it.key()]->hide(); - } - } - if( m_widgets[_id] != NULL ) - { - if( isTabRaised( _id ) ) - { - m_widgets[_id]->show(); - } - else - { - m_widgets[_id]->hide(); - } - } - } - - -private: - QMap m_widgets; - -} ; - - -#endif diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index a12e0eded..8dc2874f5 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -53,7 +53,7 @@ #include "AboutDialog.h" #include "ControllerRackView.h" #include "plugin_browser.h" -#include "side_bar.h" +#include "SideBar.h" #include "config_mgr.h" #include "mixer.h" #include "project_notes.h" @@ -98,20 +98,17 @@ MainWindow::MainWindow() : hbox->setSpacing( 0 ); hbox->setMargin( 0 ); - sideBar * side_bar = new sideBar( sideBar::Vertical, w ); - side_bar->setStyle( sideBar::VSNET/*KDEV3ICON*/ ); - side_bar->setPosition( sideBar::Left ); + SideBar * sideBar = new SideBar( Qt::Vertical, w ); QSplitter * splitter = new QSplitter( Qt::Horizontal, w ); splitter->setChildrenCollapsible( false ); - int id = 0; QString wdir = configManager::inst()->workingDir(); - side_bar->appendTab( new pluginBrowser( splitter ), ++id ); + sideBar->appendTab( new pluginBrowser( splitter ) ); // add a resource browser to sidebar m_resourceBrowser = new ResourceBrowser( splitter ); - side_bar->appendTab( m_resourceBrowser, ++id ); + sideBar->appendTab( m_resourceBrowser ); m_workspace = new QMdiArea( splitter ); @@ -136,7 +133,7 @@ MainWindow::MainWindow() : m_workspace->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); m_workspace->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded ); - hbox->addWidget( side_bar ); + hbox->addWidget( sideBar ); hbox->addWidget( splitter ); diff --git a/src/gui/ResourceBrowser.cpp b/src/gui/ResourceBrowser.cpp index 9da44df58..c53f50a44 100644 --- a/src/gui/ResourceBrowser.cpp +++ b/src/gui/ResourceBrowser.cpp @@ -74,7 +74,7 @@ static ActionDesc resourceBrowserActions[] = ResourceBrowser::ResourceBrowser( QWidget * _parent ) : - sideBarWidget( tr( "Resource Browser" ), + SideBarWidget( tr( "Resource Browser" ), embed::getIconPixmap( "resource_browser" ), _parent ), m_previewer(), diff --git a/src/gui/plugin_browser.cpp b/src/gui/plugin_browser.cpp index 035266357..43194d78f 100644 --- a/src/gui/plugin_browser.cpp +++ b/src/gui/plugin_browser.cpp @@ -37,7 +37,7 @@ pluginBrowser::pluginBrowser( QWidget * _parent ) : - sideBarWidget( tr( "Instrument plugins" ), + SideBarWidget( tr( "Instrument plugins" ), embed::getIconPixmap( "plugins" ), _parent ) { setWindowTitle( tr( "Instrument browser" ) ); diff --git a/src/gui/widgets/SideBar.cpp b/src/gui/widgets/SideBar.cpp new file mode 100644 index 000000000..e99e0ee08 --- /dev/null +++ b/src/gui/widgets/SideBar.cpp @@ -0,0 +1,160 @@ +/* + * SideBar.cpp - side-bar in LMMS' MainWindow + * + * Copyright (c) 2004-2009 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#include +#include +#include + +#include "SideBar.h" +#include "SideBarWidget.h" + + +// internal helper class allowing to create QToolButtons with +// vertical orientation +class SideBarButton : public QToolButton +{ +public: + SideBarButton( Qt::Orientation _orientation, QWidget * _parent ) : + QToolButton( _parent ), + m_orientation( _orientation ) + { + } + virtual ~SideBarButton() + { + } + + Qt::Orientation orientation() const + { + return m_orientation; + } + + virtual QSize sizeHint() const + { + QSize s = QToolButton::sizeHint(); + s.setWidth( s.width() + 8 ); + if( orientation() == Qt::Horizontal ) + { + return s; + } + return QSize( s.height(), s.width() ); + } + + +protected: + virtual void paintEvent( QPaintEvent * ) + { + QStylePainter p( this ); + QStyleOptionToolButton opt; + initStyleOption( &opt ); + if( orientation() == Qt::Vertical ) + { + const QSize s = sizeHint(); + p.rotate( 270 ); + p.translate( -s.height(), 0 ); + opt.rect = QRect( 0, 0, s.height(), s.width() ); + } + p.drawComplexControl( QStyle::CC_ToolButton, opt ); + } + + +private: + Qt::Orientation m_orientation; + +} ; + + +SideBar::SideBar( Qt::Orientation _orientation, QWidget * _parent ) : + QToolBar( _parent ), + m_btnGroup( this ) +{ + setOrientation( _orientation ); + setIconSize( QSize( 16, 16 ) ); + + m_btnGroup.setExclusive( false ); + connect( &m_btnGroup, SIGNAL( buttonClicked( QAbstractButton * ) ), + this, SLOT( toggleButton( QAbstractButton * ) ) ); +} + + + + +SideBar::~SideBar() +{ +} + + + + +void SideBar::appendTab( SideBarWidget * _sbw ) +{ + SideBarButton * btn = new SideBarButton( orientation(), this ); + btn->setText( _sbw->title() ); + btn->setIcon( _sbw->icon() ); + btn->setCheckable( true ); + m_widgets[btn] = _sbw; + m_btnGroup.addButton( btn ); + addWidget( btn ); + + _sbw->hide(); + _sbw->setMinimumWidth( 200 ); +} + + + + +void SideBar::toggleButton( QAbstractButton * _btn ) +{ + QToolButton * toolButton = NULL; + QWidget * activeWidget = NULL; + for( ButtonMap::Iterator it = m_widgets.begin(); + it != m_widgets.end(); ++it ) + { + QToolButton * curBtn = it.key(); + if( curBtn != _btn ) + { + curBtn->setChecked( false ); + curBtn->setToolButtonStyle( Qt::ToolButtonIconOnly ); + } + else + { + toolButton = it.key(); + activeWidget = it.value(); + } + if( it.value() ) + { + it.value()->hide(); + } + } + + if( toolButton && activeWidget ) + { + activeWidget->setVisible( _btn->isChecked() ); + toolButton->setToolButtonStyle( _btn->isChecked() ? + Qt::ToolButtonTextBesideIcon : Qt::ToolButtonIconOnly ); + } +} + + +#include "moc_SideBar.cxx" + diff --git a/src/gui/widgets/side_bar_widget.cpp b/src/gui/widgets/SideBarWidget.cpp similarity index 80% rename from src/gui/widgets/side_bar_widget.cpp rename to src/gui/widgets/SideBarWidget.cpp index 73ecc1097..d9cf21b60 100644 --- a/src/gui/widgets/side_bar_widget.cpp +++ b/src/gui/widgets/SideBarWidget.cpp @@ -1,8 +1,8 @@ /* - * side_bar_widget.cpp - implementation of base-widget for side-bar + * SideBarWidget.cpp - implementation of base-widget for side-bar + * + * Copyright (c) 2004-2009 Tobias Doerffel * - * Copyright (c) 2004-2008 Tobias Doerffel - * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -22,17 +22,16 @@ * */ - #include #include #include -#include "side_bar_widget.h" +#include "SideBarWidget.h" #include "gui_templates.h" -sideBarWidget::sideBarWidget( const QString & _title, const QPixmap & _icon, +SideBarWidget::SideBarWidget( const QString & _title, const QPixmap & _icon, QWidget * _parent ) : QWidget( _parent ), m_title( _title ), @@ -47,14 +46,14 @@ sideBarWidget::sideBarWidget( const QString & _title, const QPixmap & _icon, -sideBarWidget::~sideBarWidget() +SideBarWidget::~SideBarWidget() { } -void sideBarWidget::paintEvent( QPaintEvent * ) +void SideBarWidget::paintEvent( QPaintEvent * ) { const int TITLE_FONT_HEIGHT = 13; @@ -77,7 +76,7 @@ void sideBarWidget::paintEvent( QPaintEvent * ) -void sideBarWidget::resizeEvent( QResizeEvent * ) +void SideBarWidget::resizeEvent( QResizeEvent * ) { const int MARGIN = 6; m_contents->setGeometry( MARGIN, 40 + MARGIN, width() - MARGIN * 2, @@ -86,6 +85,5 @@ void sideBarWidget::resizeEvent( QResizeEvent * ) -#include "moc_side_bar.cxx" -#include "moc_side_bar_widget.cxx" +#include "moc_SideBarWidget.cxx" diff --git a/src/gui/widgets/kmultitabbar.cpp b/src/gui/widgets/kmultitabbar.cpp deleted file mode 100644 index 750065a1c..000000000 --- a/src/gui/widgets/kmultitabbar.cpp +++ /dev/null @@ -1,917 +0,0 @@ -/* - * kmultitabbar.cpp - widget for horizontal and vertical tabs - * - * Copyright (c) 2001-2003 Joseph Wenninger - * Copyright (c) 2004-2007 Tobias Doerffel - * - * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program (see COPYING); if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - */ - - -#include "kmultitabbar.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "templates.h" -#include "tooltip.h" - -#define NEARBYINT(i) ((int(float(i) + 0.5))) - -class KMultiTabBarTabPrivate { -public: - QPixmap pix; -}; - - -KMultiTabBarInternal::KMultiTabBarInternal(QWidget *parent, KMultiTabBar::KMultiTabBarMode bm):QWidget(parent) -{ - m_expandedTabSize=-1; - m_showActiveTabTexts=false; - m_barMode=bm; - if (bm==KMultiTabBar::Vertical) - { - box=new QWidget(this); - mainLayout=new QVBoxLayout(box); - box->setFixedWidth(24); - setFixedWidth(24); - } - else - { - box=new QWidget(this); - mainLayout=new QHBoxLayout(box); - box->setFixedHeight(24); - setFixedHeight(24); - } - mainLayout->setMargin(0); - mainLayout->setSpacing(0); -} - -void KMultiTabBarInternal::setStyle(enum KMultiTabBar::KMultiTabBarStyle style) -{ - m_style=style; - for (int i=0;isetStyle(m_style); - - if ( (m_style==KMultiTabBar::KDEV3) || - (m_style==KMultiTabBar::KDEV3ICON ) ) { - delete mainLayout; - mainLayout=0; - resizeEvent(0); - } else if (mainLayout==0) { - if (m_barMode==KMultiTabBar::Vertical) - { - box=new QWidget(this); - mainLayout=new QVBoxLayout(box); - box->setFixedWidth(24); - setFixedWidth(24); - } - else - { - box=new QWidget(this); - mainLayout=new QHBoxLayout(box); - box->setFixedHeight(24); - setFixedHeight(24); - } - for (int i=0;iaddWidget(m_tabs.at(i)); - - } - update(); -} - - - -#define CALCDIFF(m_tabs,diff,i) if (m_lines>(int)lines) {\ - int ulen=0;\ - diff=0; \ - for (int i2=i;i2neededSize();\ - if ((ulen+l1)>(int)space){\ - if (ulen==0) diff=0;\ - else diff=((float)(space-ulen))/(i2-i);\ - break;\ - }\ - ulen+=l1;\ - }\ - } else {diff=0; } - - -void KMultiTabBarInternal::resizeEvent(QResizeEvent *ev) { - if (ev) QWidget::resizeEvent(ev); - - if ( (m_style==KMultiTabBar::KDEV3) || - (m_style==KMultiTabBar::KDEV3ICON) ){ - box->setGeometry(0,0,width(),height()); - int lines=1; - uint space; - float tmp=0; - if ((m_position==KMultiTabBar::Bottom) || (m_position==KMultiTabBar::Top)) - space=width(); - else - space=height(); - - int cnt=0; -//CALCULATE LINES - const int tabCount=m_tabs.count(); - for (int i=0;ineededSize(); - if (tmp>space) { - if (cnt>1)i--; - else if (i==(tabCount-1)) break; - cnt=0; - tmp=0; - lines++; - } - } -//SET SIZE & PLACE - float diff=0; - cnt=0; - - if ((m_position==KMultiTabBar::Bottom) || (m_position==KMultiTabBar::Top)) { - - setFixedHeight(lines*24); - box->setFixedHeight(lines*24); - m_lines=height()/24-1; - lines=0; - CALCDIFF(m_tabs,diff,0) - tmp=-diff; - - for (int i=0;ineededSize()+diff; - if (tmp>space) { - if (cnt>1) { - CALCDIFF(m_tabs,diff,i) - i--; - } - else { - tab->removeEventFilter(this); - tab->move(NEARBYINT(tmp-tab->neededSize()),lines*24); - tab->setFixedWidth(NEARBYINT(tmp+diff)-tab->x());; - tab->installEventFilter(this); - CALCDIFF(m_tabs,diff,(i+1)) - - } - tmp=-diff; - cnt=0; - lines++; - - } else { - tab->removeEventFilter(this); - tab->move(NEARBYINT(tmp-tab->neededSize()),lines*24); - tab->setFixedWidth(NEARBYINT(tmp+diff)-tab->x());; - - tab->installEventFilter(this); - - } - } - } - else { - setFixedWidth(lines*24); - box->setFixedWidth(lines*24); - m_lines=lines=width()/24; - lines=0; - CALCDIFF(m_tabs,diff,0) - tmp=-diff; - - for (int i=0;ineededSize()+diff; - if (tmp>space) { - if (cnt>1) { - CALCDIFF(m_tabs,diff,i); - tmp=-diff; - i--; - } - else { - tab->removeEventFilter(this); - tab->move(lines*24,NEARBYINT(tmp-tab->neededSize())); - tab->setFixedHeight(NEARBYINT(tmp+diff)-tab->y());; - tab->installEventFilter(this); - } - cnt=0; - tmp=-diff; - lines++; - } else { - tab->removeEventFilter(this); - tab->move(lines*24,NEARBYINT(tmp-tab->neededSize())); - tab->setFixedHeight(NEARBYINT(tmp+diff)-tab->y());; - tab->installEventFilter(this); - } - } - } - - - } else { - int size=0; /*move the calculation into another function and call it only on add tab and tab click events*/ - for (int i=0;i<(int)m_tabs.count();i++) - size+=(m_barMode==KMultiTabBar::Vertical?m_tabs.at(i)->height():m_tabs.at(i)->width()); - if ((m_position==KMultiTabBar::Bottom) || (m_position==KMultiTabBar::Top)) - box->setGeometry(0,0,size,height()); - else box->setGeometry(0,0,width(),size); - - } -} - - -void KMultiTabBarInternal::showActiveTabTexts(bool show) -{ - m_showActiveTabTexts=show; -} - - -KMultiTabBarTab* KMultiTabBarInternal::tab(int id) const -{ - for (QListIterator it(m_tabs);it.hasNext();it.next()){ - if (it.peekNext()->id()==id) return it.peekNext(); - } - return 0; -} - -bool KMultiTabBarInternal::eventFilter(QObject *, QEvent *e) { - if (e->type()==QEvent::Resize) resizeEvent(0); - return false; -} - -int KMultiTabBarInternal::appendTab(const QPixmap &pic ,int id,const QString& text) -{ - KMultiTabBarTab *tab; - m_tabs.append(tab= new KMultiTabBarTab(pic,text,id,box,m_position,m_style)); - mainLayout->addWidget( tab ); - tab->installEventFilter(this); - tab->showActiveTabText(m_showActiveTabTexts); - - if (m_style==KMultiTabBar::KONQSBC) - { - if (m_expandedTabSizeneededSize()) { - m_expandedTabSize=tab->neededSize(); - for (int i=0;isetSize(m_expandedTabSize); - - } else tab->setSize(m_expandedTabSize); - } else tab->updateState(); - tab->show(); - resizeEvent(0); - return 0; -} - -void KMultiTabBarInternal::removeTab(int id) -{ - for (int pos=0;posid()==id) - { - delete m_tabs.at(pos); - m_tabs.removeAt(pos); - resizeEvent(0); - break; - } - } -} - -void KMultiTabBarInternal::setPosition(enum KMultiTabBar::KMultiTabBarPosition pos) -{ - m_position=pos; - for (int i=0;isetTabsPosition(m_position); - update(); -} - -KMultiTabBarButton::KMultiTabBarButton(const QPixmap& pic,const QString& text, QMenu *popup, - int id,QWidget *parent,KMultiTabBar::KMultiTabBarPosition pos,KMultiTabBar::KMultiTabBarStyle style) - :QPushButton(QIcon(),text,parent),m_style(style) -{ - setIcon(pic); - setText(text); - m_position=pos; - if (popup) setMenu(popup); - setFlat(true); - setFixedHeight(24); - setFixedWidth(24); - m_id=id; - setToolTip(text); - connect(this,SIGNAL(clicked()),this,SLOT(slotClicked())); -} - -KMultiTabBarButton::KMultiTabBarButton(const QString& text, QMenu *popup, - int id,QWidget *parent,KMultiTabBar::KMultiTabBarPosition pos,KMultiTabBar::KMultiTabBarStyle style) - :QPushButton(QIcon(),text,parent),m_style(style) -{ - setText(text); - m_position=pos; - if (popup) setMenu(popup); - setFlat(true); - setFixedHeight(24); - setFixedWidth(24); - m_id=id; - setToolTip(text); - connect(this,SIGNAL(clicked()),this,SLOT(slotClicked())); -} - -KMultiTabBarButton::~KMultiTabBarButton() { -} - -int KMultiTabBarButton::id() const{ - return m_id; -} - -void KMultiTabBarButton::setText(const QString& text) -{ - QPushButton::setText(text); - m_text=text; - setToolTip(text); -} - -void KMultiTabBarButton::slotClicked() -{ - emit clicked(m_id); -} - -void KMultiTabBarButton::setPosition(KMultiTabBar::KMultiTabBarPosition pos) -{ - m_position=pos; - update(); -} - -void KMultiTabBarButton::setStyle(KMultiTabBar::KMultiTabBarStyle style) -{ - m_style=style; - update(); -} - -void KMultiTabBarButton::hideEvent( QHideEvent* he) { - QPushButton::hideEvent(he); - KMultiTabBar *tb=dynamic_cast(parentWidget()); - if (tb) tb->updateSeparator(); -} - -void KMultiTabBarButton::showEvent( QShowEvent* he) { - QPushButton::showEvent(he); - KMultiTabBar *tb=dynamic_cast(parentWidget()); - if (tb) tb->updateSeparator(); -} - - -QSize KMultiTabBarButton::sizeHint() const -{ - //constPolish(); - - int w = 0, h = 0; - - // calculate contents size... - int iw = 0, ih = 0; - if ( !icon().isNull() ) { - iw = 20; - ih = 16; - w += iw; - h = qMax( h, ih ); - } - QStyleOptionButton sob; - if ( menu() != 0 ) - w += style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &sob, this); - - QString s( text() ); - bool empty = s.isEmpty(); - if ( empty ) - s = QLatin1String("XXXX"); - QFontMetrics fm = fontMetrics(); - QSize sz = fm.size( Qt::TextShowMnemonic, s ); - if(!empty || !w) - w += sz.width(); - if(!empty || !h) - h = qMax(h, sz.height()); - - - QStyleOptionToolButton opt; - opt.init(this); - opt.rect = QRect(0, 0, w, h); - opt.subControls = QStyle::SC_All; - opt.activeSubControls = 0; - opt.text = text(); - opt.font = font(); - opt.icon = icon(); - opt.iconSize = QSize(iw, ih); - return (style()->sizeFromContents(QStyle::CT_ToolButton, &opt, QSize(w, h), this). - expandedTo(QApplication::globalStrut())); -} - - -KMultiTabBarTab::KMultiTabBarTab(const QPixmap& pic, const QString& text, - int id,QWidget *parent,KMultiTabBar::KMultiTabBarPosition pos, - KMultiTabBar::KMultiTabBarStyle style) - :KMultiTabBarButton(text,0,id,parent,pos,style), - m_showActiveTabText(false) -{ - d=new KMultiTabBarTabPrivate(); - setIcon(pic); - m_expandedSize=24; - setCheckable(true); - setAttribute( Qt::WA_OpaquePaintEvent, true ); -} - -KMultiTabBarTab::~KMultiTabBarTab() { - delete d; -} - - -void KMultiTabBarTab::setTabsPosition(KMultiTabBar::KMultiTabBarPosition pos) -{ - if ((pos!=m_position) && ((pos==KMultiTabBar::Left) || (pos==KMultiTabBar::Right))) { - if (!d->pix.isNull()) { - QMatrix temp;// (1.0F, 0.0F, 0.0F, -1.0F, 0.0F, 0.0F); - temp.rotate(180); - d->pix=d->pix.transformed(temp); - setIcon(d->pix); - } - } - setPosition(pos); -} - -void KMultiTabBarTab::setIcon(const QString& icon) -{ - QPixmap pic(icon); - setIcon(pic); -} - -void KMultiTabBarTab::setIcon(const QPixmap& icon) -{ - - if (m_style!=KMultiTabBar::KDEV3) { - if ((m_position==KMultiTabBar::Left) || (m_position==KMultiTabBar::Right)) { - QMatrix rotateMatrix; -/* if (m_position==KMultiTabBar::Left) - rotateMatrix.rotate(-270); - else*/ - rotateMatrix.rotate(90); - d->pix=icon.transformed(rotateMatrix); //TODO FIX THIS, THIS SHOWS WINDOW - KMultiTabBarButton::setIcon(d->pix); - } else KMultiTabBarButton::setIcon(icon); - } -} - -void KMultiTabBarTab::slotClicked() -{ - updateState(); - KMultiTabBarButton::slotClicked(); -} - -void KMultiTabBarTab::setState(bool b) -{ - setChecked(b); - updateState(); -} - -void KMultiTabBarTab::updateState() -{ - - if (m_style!=KMultiTabBar::KONQSBC) { - if ((m_style==KMultiTabBar::KDEV3) || (m_style==KMultiTabBar::KDEV3ICON) || (isChecked())) { - QPushButton::setText(m_text); - } else { - QPushButton::setText(QString()); - } - - if ((m_position==KMultiTabBar::Right || m_position==KMultiTabBar::Left)) { - setFixedWidth(24); - if ((m_style==KMultiTabBar::KDEV3) || (m_style==KMultiTabBar::KDEV3ICON) || (isChecked())) { - setFixedHeight(KMultiTabBarButton::sizeHint().width()); - } else setFixedHeight(36); - } else { - setFixedHeight(24); - if ((m_style==KMultiTabBar::KDEV3) || (m_style==KMultiTabBar::KDEV3ICON) || (isChecked())) { - setFixedWidth(KMultiTabBarButton::sizeHint().width()); - } else setFixedWidth(36); - } - } else { - if ((!isChecked()) || (!m_showActiveTabText)) - { - setFixedWidth(24); - setFixedHeight(24); - return; - } - if ((m_position==KMultiTabBar::Right || m_position==KMultiTabBar::Left)) - setFixedHeight(m_expandedSize); - else - setFixedWidth(m_expandedSize); - } -} - -int KMultiTabBarTab::neededSize() -{ - return (((m_style!=KMultiTabBar::KDEV3)?24:0)+QFontMetrics(QFont()).width(m_text)+6); -} - -void KMultiTabBarTab::setSize(int size) -{ - m_expandedSize=size; - updateState(); -} - -void KMultiTabBarTab::showActiveTabText(bool show) -{ - m_showActiveTabText=show; -} - -void KMultiTabBarTab::paintEvent(QPaintEvent *) { - QPainter painter(this); - drawButton(&painter); -} - -void KMultiTabBarTab::drawButtonLabel(QPainter *p) { - drawButton(p); -} -void KMultiTabBarTab::drawButton(QPainter *paint) -{ - if (m_style!=KMultiTabBar::KONQSBC) drawButtonStyled(paint); - else drawButtonClassic(paint); -} - -void KMultiTabBarTab::drawButtonStyled(QPainter *paint) { - - QSize sh; - const int width = 36; // rotated - const int height = 24; - if ((m_style==KMultiTabBar::KDEV3) || (m_style==KMultiTabBar::KDEV3ICON) || (isChecked())) { - if ((m_position==KMultiTabBar::Left) || (m_position==KMultiTabBar::Right)) - sh=QSize(this->height(),this->width());//KMultiTabBarButton::sizeHint(); - else sh=QSize(this->width(),this->height()); - } - else - sh=QSize(width,height); - - QPixmap pixmap( sh.width(),height); ///,sh.height()); - pixmap.fill(backgroundRole()); - QPainter painter(&pixmap); - - - QStyle::State st=QStyle::State_None; - - st|=QStyle::State_Enabled; - - if (isChecked()) st|=QStyle::State_On; - - QStyleOptionButton options; - options.init(this); - options.state = st; - options.rect = QRect(0,0,pixmap.width(),pixmap.height()); - options.palette = palette(); - options.text = text(); - options.icon = icon(); - options.iconSize = iconSize(); - - style()->drawControl(QStyle::CE_PushButton, &options, &painter, this); - - switch (m_position) { - case KMultiTabBar::Left: - paint->rotate(-90); - paint->drawPixmap(1-pixmap.width(),0,pixmap); - break; - case KMultiTabBar::Right: - paint->rotate(90); - paint->drawPixmap(0,1-pixmap.height(),pixmap); - break; - - default: - paint->drawPixmap(0,0,pixmap); - break; - } - -} - -void KMultiTabBarTab::drawButtonClassic(QPainter *paint) -{ - QPixmap pixmap; - if( !icon().isNull() ) - pixmap = icon().pixmap( 16, 16 ); - paint->fillRect(0, 0, 24, 24, palette().background().color()); - - if (!isChecked()) - { - - if (m_position==KMultiTabBar::Right) - { - paint->fillRect(0,0,21,21,QBrush(palette().background().color())); - - paint->setPen(palette().background().color().dark(150)); - paint->drawLine(0,22,23,22); - - paint->drawPixmap(12-pixmap.width()/2,12-pixmap.height()/2,pixmap); - - paint->setPen(palette().shadow().color()); - paint->drawLine(0,0,0,23); - paint->setPen(palette().background().color().dark(120)); - paint->drawLine(1,0,1,23); - - } - else - if ((m_position==KMultiTabBar::Bottom) || (m_position==KMultiTabBar::Top)) - { - paint->fillRect(0,1,23,22,QBrush(palette().background().color())); - - paint->drawPixmap(12-pixmap.width()/2,12-pixmap.height()/2,pixmap); - - paint->setPen(palette().background().color().dark(120)); - paint->drawLine(23,0,23,23); - - - paint->setPen(palette().light().color()); - paint->drawLine(0,22,23,22); - paint->drawLine(0,23,23,23); - paint->setPen(palette().shadow().color()); - paint->drawLine(0,0,23,0); - paint->setPen(palette().background().color().dark(120)); - paint->drawLine(0,1,23,1); - - } - else - { - paint->setPen(palette().background().color().dark(120)); - paint->drawLine(0,23,23,23); - paint->fillRect(0,0,23,21,QBrush(palette().background())); - paint->drawPixmap(12-pixmap.width()/2,12-pixmap.height()/2,pixmap); - - paint->setPen(palette().light().color()); - paint->drawLine(23,0,23,23); - paint->drawLine(22,0,22,23); - - paint->setPen(palette().shadow().color()); - paint->drawLine(0,0,0,23); - - } - - - } - else - { - if (m_position==KMultiTabBar::Right) - { - paint->setPen(palette().shadow().color()); - paint->drawLine(0,height()-1,23,height()-1); - paint->drawLine(0,height()-2,23,height()-2); - paint->drawLine(23,0,23,height()-1); - paint->drawLine(22,0,22,height()-1); - paint->fillRect(0,0,21,height()-3,QBrush(palette().light().color())); - paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap); - - if (m_showActiveTabText) - { - if (height()<25+4) return; - - QPixmap tpixmap(height()-25-3, width()-2); - QPainter painter(&tpixmap); - - painter.fillRect(0,0,tpixmap.width(),tpixmap.height(),QBrush(palette().light().color())); - - painter.setPen(palette().text().color()); - painter.drawText(0,+width()/2+QFontMetrics(QFont()).height()/2,m_text); - - paint->rotate(90); - paint->drawPixmap(25,-tpixmap.height()+1,tpixmap); - } - - } - else - if (m_position==KMultiTabBar::Top) - { - paint->fillRect(0,0,width()-1,23,QBrush(palette().light().color())); - paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap); - if (m_showActiveTabText) - { - paint->setPen(palette().text().color()); - paint->drawText(25,height()/2+QFontMetrics(QFont()).height()/2,m_text); - } - } - else - if (m_position==KMultiTabBar::Bottom) - { - paint->setPen(palette().shadow().color()); - paint->drawLine(0,23,width()-1,23); - paint->drawLine(0,22,width()-1,22); - paint->fillRect(0,0,width()-1,21,QBrush(palette().light().color())); - paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap); - if (m_showActiveTabText) - { - paint->setPen(palette().text().color()); - paint->drawText(25,height()/2+QFontMetrics(QFont()).height()/2,m_text); - } - - } - else - { - - - paint->setPen(palette().shadow().color()); - paint->drawLine(0,height()-1,23,height()-1); - paint->drawLine(0,height()-2,23,height()-2); - paint->fillRect(0,0,23,height()-3,QBrush(palette().light().color())); - paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap); - if (m_showActiveTabText) - { - - if (height()<25+4) return; - - QPixmap tpixmap(height()-25-3, width()-2); - QPainter painter(&tpixmap); - - painter.fillRect(0,0,tpixmap.width(),tpixmap.height(),QBrush(palette().light().color())); - - painter.setPen(palette().text().color()); - painter.drawText(tpixmap.width()-QFontMetrics(QFont()).width(m_text),+width()/2+QFontMetrics(QFont()).height()/2,m_text); - - paint->rotate(-90); - - paint->drawPixmap(-24-tpixmap.width(),2,tpixmap); - - } - - } - - } -} - -KMultiTabBar::KMultiTabBar(KMultiTabBarMode bm, QWidget *parent) - : QWidget(parent) -{ - if (bm==Vertical) - { - m_l=new QVBoxLayout(this); - setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding)); - } - else - { - m_l=new QHBoxLayout(this); - setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); - } - m_l->setMargin(0); - - m_internal=new KMultiTabBarInternal(this,bm); - setPosition((bm==KMultiTabBar::Vertical)?KMultiTabBar::Right:KMultiTabBar::Bottom); - setStyle(VSNET); - m_l->insertWidget(0,m_internal); - m_l->insertWidget(0,m_btnTabSep=new QFrame(this)); - m_btnTabSep->setFixedHeight(4); - m_btnTabSep->setFrameStyle(QFrame::Panel | QFrame::Sunken); - m_btnTabSep->setLineWidth(2); - m_btnTabSep->hide(); - - updateGeometry(); -} - -KMultiTabBar::~KMultiTabBar() { -} - -int KMultiTabBar::appendButton(const QPixmap &pic ,int id,QMenu *popup,const QString&) -{ - KMultiTabBarButton *btn; - m_buttons.append(btn= new KMultiTabBarButton(pic,QString(), - popup,id,this,m_position,m_internal->m_style)); - m_l->insertWidget(0,btn); - btn->show(); - m_btnTabSep->show(); - return 0; -} - -void KMultiTabBar::updateSeparator() { - bool hideSep=true; - for (QListIterator it(m_buttons);it.hasNext();){ - if (it.next()->isVisibleTo(this)) { - hideSep=false; - break; - } - } - if (hideSep) m_btnTabSep->hide(); - else m_btnTabSep->show(); - -} - -int KMultiTabBar::appendTab(const QPixmap &pic ,int id ,const QString& text) -{ - m_internal->appendTab(pic,id,text); - return 0; -} - -KMultiTabBarButton* KMultiTabBar::button(int id) const -{ - for (QListIterator it(m_buttons);it.hasNext();it.next()){ - if (it.peekNext()->id()==id) return it.peekNext(); - } - return 0; -} - -KMultiTabBarTab* KMultiTabBar::tab(int id) const -{ - return m_internal->tab(id); -} - - - -void KMultiTabBar::removeButton(int id) -{ - for (int pos=0;posid()==id) - { - m_buttons.at(pos)->deleteLater(); - m_buttons.removeAt(pos); - break; - } - } - if (m_buttons.count()==0) m_btnTabSep->hide(); -} - -void KMultiTabBar::removeTab(int id) -{ - m_internal->removeTab(id); -} - -void KMultiTabBar::setTab(int id,bool state) -{ - KMultiTabBarTab *ttab=tab(id); - if (ttab) - { - ttab->setState(state); - } -} - -bool KMultiTabBar::isTabRaised(int id) const -{ - KMultiTabBarTab *ttab=tab(id); - if (ttab) - { - return ttab->isChecked(); - } - - return false; -} - - -void KMultiTabBar::showActiveTabTexts(bool show) -{ - m_internal->showActiveTabTexts(show); -} - -void KMultiTabBar::setStyle(KMultiTabBarStyle style) -{ - m_internal->setStyle(style); -} - -KMultiTabBar::KMultiTabBarStyle KMultiTabBar::tabStyle() const -{ - return m_internal->m_style; -} - -void KMultiTabBar::setPosition(KMultiTabBarPosition pos) -{ - m_position=pos; - m_internal->setPosition(pos); - for (int i=0;isetPosition(pos); -} - -KMultiTabBar::KMultiTabBarPosition KMultiTabBar::position() const -{ - return m_position; -} -void KMultiTabBar::fontChange(const QFont& /* oldFont */) -{ - for (int i=0;icount();i++) - tabs()->at(i)->resize(); - update(); -} - -QList* KMultiTabBar::tabs() {return m_internal->tabs();} -QList* KMultiTabBar::buttons() {return &m_buttons;} - - -#include "moc_kmultitabbar.cxx" - - -