lib

kotoolboxpalette.cc

00001 /*
00002  *  Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
00003  *
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2, as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00016 
00017  */
00018 
00019 
00020 #include <qdockwindow.h>
00021 #include <qtoolbox.h>
00022 
00023 #include <kopalette.h>
00024 #include <kopalettemanager.h>
00025 #include <kotoolboxpalette.h>
00026 
00027 KoToolBoxPalette::KoToolBoxPalette(QWidget * parent, const char * name)
00028     : KoPalette(parent, name)
00029 {
00030     m_page = new QToolBox(this);
00031     m_page->unsetFont();
00032     setMainWidget(m_page);
00033     m_style = PALETTE_TOOLBOX;
00034 }
00035 
00036 KoToolBoxPalette::~KoToolBoxPalette()
00037 {
00038 }
00039 
00040 
00041 void KoToolBoxPalette::resetFont()
00042 {
00043     KoPalette::resetFont();
00044     m_page->unsetFont();
00045 }
00046 
00047 
00048 void KoToolBoxPalette::plug(QWidget *w, const QString & label, int position)
00049 {
00050     w->unsetFont();
00051     m_page->insertItem( position, w,  label );
00052 }
00053 
00054 
00055 void KoToolBoxPalette::unplug(const QWidget *w)
00056 {
00057     m_page->removeItem( const_cast<QWidget*>(w) );
00058 }
00059 
00060 void KoToolBoxPalette::showPage(QWidget *w)
00061 {
00062     m_page->setCurrentItem( w );
00063 }
00064 
00065 
00066 int KoToolBoxPalette::indexOf(QWidget *w)
00067 {
00068     if (m_hiddenPages.find(w) != m_hiddenPages.end()) {
00069         return m_page->indexOf(w);
00070     }
00071     else {
00072         return m_page->indexOf(w);
00073     }
00074 }
00075 
00076 
00077 void KoToolBoxPalette::makeVisible(bool v)
00078 {
00079     if (v && m_page->count() > 0) {
00080         show();
00081     }
00082     else {
00083         hide();
00084     }
00085 }
00086 
00087 bool KoToolBoxPalette::isHidden(QWidget * w)
00088 {
00089     return (m_hiddenPages.find(w) != m_hiddenPages.end());
00090 }
00091 
00092 void KoToolBoxPalette::togglePageHidden(QWidget *w)
00093 {
00094     if (m_hiddenPages.find(w) != m_hiddenPages.end()) {
00095         int i = *m_hiddenPages.find(w);
00096         m_page->insertItem(i, w, w->caption());
00097         show();
00098     }
00099     else {
00100         int i = m_page->indexOf(w);
00101         m_page->removeItem(w);
00102         m_hiddenPages[w] = i;
00103         if (m_page->count() == 0) {
00104             hide();
00105         }
00106     }
00107 
00108 }
00109 
00110 void KoToolBoxPalette::hidePage( QWidget * w)
00111 {
00112     if (m_hiddenPages.find(w) != m_hiddenPages.end()) return;
00113     int i = m_page->indexOf(w);
00114     m_page->removeItem(w);
00115     m_hiddenPages[w] = i;
00116     if (m_page->count() == 0) {
00117         hide();
00118     }
00119 }
00120 
00121 #include "kotoolboxpalette.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys