kdeui Library API Documentation

kjanuswidget.h

00001 /*  This file is part of the KDE Libraries
00002  *  Copyright (C) 1999-2000 Espen Sand (espen@kde.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 as published by the Free Software Foundation; either
00007  *  version 2 of the License, or (at your option) any later version.
00008  *
00009  *  This library is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *  Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this library; see the file COPYING.LIB.  If not, write to
00016  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017  *  Boston, MA 02111-1307, USA.
00018  */
00019 
00020 #ifndef _KJANUS_WIDGET_H_
00021 #define _KJANUS_WIDGET_H_
00022 
00023 #include <qptrlist.h>
00024 #include <qpixmap.h>
00025 #include <qsplitter.h>
00026 
00027 #include <klistbox.h>
00028 #include <qstringlist.h>
00029 #include <qmap.h>
00030 
00031 class KListView;
00032 
00033 class QGrid;
00034 class QHBox;
00035 class QLabel;
00036 class QTabWidget;
00037 class QVBox;
00038 class QWidgetStack;
00039 class KSeparator;
00040 class QListViewItem;
00041 class KGuiItem;
00042 
00066 class KJanusWidget : public QWidget
00067 {
00068   Q_OBJECT
00069 
00070   private:
00071     class IconListBox : public KListBox
00072     {
00073       public:
00074         IconListBox( QWidget *parent=0, const char *name=0, WFlags f=0 );
00075     void updateMinimumHeight();
00076     void updateWidth();
00077     void invalidateHeight();
00078     void invalidateWidth();
00079     void setShowAll( bool showAll );
00080 
00081       private:
00082     bool mShowAll;
00083     bool mHeightValid;
00084     bool mWidthValid;
00085     };
00086 
00087   public:
00088     enum Face
00089     {
00096       TreeList = 0,
00103       Tabbed,
00109       Plain,
00117       Swallow,
00125       IconList
00126     };
00127 
00128   public:
00129 
00138     KJanusWidget( QWidget *parent=0, const char *name=0, int face=Plain );
00139 
00143     ~KJanusWidget();
00144 
00150     virtual bool showPage( int index );
00151 
00158     virtual int  activePageIndex() const;
00159 
00166     virtual bool isValid() const;
00167 
00173     virtual int face() const;
00174 
00181     virtual QSize minimumSizeHint() const;
00182 
00189     virtual QSize sizeHint() const;
00190 
00196     virtual QFrame *plainPage();
00197 
00217     virtual QFrame *addPage(const QString &item,const QString &header=QString::null,
00218             const QPixmap &pixmap=QPixmap() );
00219 
00234      virtual QFrame *addPage(const QStringList &items, const QString &header=QString::null,
00235             const QPixmap &pixmap=QPixmap() );
00236 
00256     virtual QVBox *addVBoxPage( const QString &item,
00257             const QString &header=QString::null,
00258             const QPixmap &pixmap=QPixmap() );
00259 
00272     virtual QVBox *addVBoxPage( const QStringList &items,
00273             const QString &header=QString::null,
00274             const QPixmap &pixmap=QPixmap() );
00275 
00296     virtual QHBox *addHBoxPage( const QString &itemName,
00297             const QString &header=QString::null,
00298             const QPixmap &pixmap=QPixmap() );
00299 
00312     virtual QHBox *addHBoxPage( const QStringList &items,
00313             const QString &header=QString::null,
00314             const QPixmap &pixmap=QPixmap() );
00315 
00339     virtual QGrid *addGridPage( int n, Orientation dir,
00340             const QString &itemName,
00341             const QString &header=QString::null,
00342             const QPixmap &pixmap=QPixmap() );
00343 
00356     virtual QGrid *addGridPage( int n, Orientation dir,
00357             const QStringList &items,
00358             const QString &header=QString::null,
00359             const QPixmap &pixmap=QPixmap() );
00360 
00370     void removePage( QWidget *page );
00371 
00372 
00389     virtual int pageIndex( QWidget *widget ) const;
00390 
00400     virtual bool setSwallowedWidget( QWidget *widget );
00401 
00412     virtual void setTreeListAutoResize( bool state );
00413 
00426     virtual void setShowIconsInTreeList(bool state);
00427 
00436     virtual void setRootIsDecorated( bool state );
00437 
00451     /*virtual*/ void unfoldTreeList( bool persist = false ); //### KDE4 BIC add virtual
00452 
00461     /*virtual*/ void addWidgetBelowList( QWidget * widget ); // ### KDE4
00462 
00473     /*virtual*/ void addButtonBelowList( const QString & text, QObject * recv,
00474                     const char * slot ); //### KDE4
00475 
00487     /*virtual*/ void addButtonBelowList( const KGuiItem & guiitem, QObject *
00488                     recv, const char * slot ); //### KDE4
00489 
00502     virtual void setIconListAllVisible( bool state );
00503 
00509     virtual void setFolderIcon(const QStringList &path, const QPixmap &pixmap);
00516     /*virtual*/ QString pageTitle(int index) const;
00524     /*virtual*/ QWidget *pageWidget(int index) const;
00525 
00526   signals:
00527     void aboutToShowPage(QWidget *page);
00528 
00529   public slots:
00533     virtual void setFocus();
00534 
00535   protected:
00540     virtual void showEvent( QShowEvent * );
00541 
00550     virtual bool eventFilter( QObject *o, QEvent *e );
00551 
00552   private slots:
00553     bool slotShowPage();
00554     void slotFontChanged();
00555     void slotItemClicked(QListViewItem *it);
00556     void pageGone(QObject *obj); // signal from the added page's "destroyed" signal
00557     void slotReopen(QListViewItem *item);
00558 
00559   protected:
00560     bool showPage( QWidget *w );
00561     void addPageWidget( QFrame *page, const QStringList &items,
00562             const QString &header, const QPixmap &pixmap );
00563     void InsertTreeListItem(const QStringList &items, const QPixmap &pixmap, QFrame *page);
00564     QWidget *FindParent();
00565 
00566   private:
00567     bool mValid;
00568 
00569     // Obsolete members. Remove in KDE 4.
00570     QPtrList<QWidget> *mPageList;
00571     QStringList *mTitleList;
00572 
00573     int          mFace;
00574     KListView    *mTreeList;
00575     IconListBox  *mIconList;
00576     QWidgetStack *mPageStack;
00577     QLabel       *mTitleLabel;
00578     QTabWidget   *mTabControl;
00579     QFrame       *mPlainPage;
00580     QWidget      *mSwallowPage;
00581     QWidget      *mActivePageWidget;
00582     KSeparator   *mTitleSep;
00583     QSplitter::ResizeMode mTreeListResizeMode;
00584     bool         mShowIconsInTreeList;
00585     QMap<QListViewItem *, QWidget *> mTreeListToPageStack;
00586     QMap<QListBoxItem *, QWidget *> mIconListToPageStack;
00587     QMap<QString, QPixmap> mFolderIconMap;
00588     QMap<QString, QStringList> mChildrenNames;
00589     QMap<QString, QWidget *> mChildPages;
00590 
00591   public:
00592     class IconListItem;
00593   protected:
00594     virtual void virtual_hook( int id, void* data );
00595   private:
00596     class KJanusWidgetPrivate;
00597     KJanusWidgetPrivate *d;
00598 };
00599 
00600 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.2.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Feb 4 12:34:17 2004 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2003