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 
00067 class KDEUI_EXPORT KJanusWidget : public QWidget
00068 {
00069   Q_OBJECT
00070 
00071   private:
00072     class IconListBox : public KListBox
00073     {
00074       friend class KJanusWidget;
00075 
00076       public:
00077         IconListBox( QWidget *parent=0, const char *name=0, WFlags f=0 );
00078     void updateMinimumHeight();
00079     void updateWidth();
00080     void invalidateHeight();
00081     void invalidateWidth();
00082     void setShowAll( bool showAll );
00083 
00084       protected:
00085         void slotOnItem( QListBoxItem *item );
00086     virtual void leaveEvent( QEvent * );
00087     
00088       private:
00089     bool mShowAll;
00090     bool mHeightValid;
00091     bool mWidthValid;
00092     QListBoxItem *mOldItem; 
00093     };
00094 
00095   public:
00096     enum Face
00097     {
00104       TreeList = 0,
00111       Tabbed,
00117       Plain,
00125       Swallow,
00133       IconList
00134     };
00135 
00136   public:
00137 
00146     KJanusWidget( QWidget *parent=0, const char *name=0, int face=Plain );
00147 
00151     ~KJanusWidget();
00152 
00158     virtual bool showPage( int index );
00159 
00166     virtual int  activePageIndex() const;
00167 
00174     virtual bool isValid() const;
00175 
00181     virtual int face() const;
00182 
00189     virtual QSize minimumSizeHint() const;
00190 
00197     virtual QSize sizeHint() const;
00198 
00204     virtual QFrame *plainPage();
00205 
00225     virtual QFrame *addPage(const QString &item,const QString &header=QString::null,
00226             const QPixmap &pixmap=QPixmap() );
00227 
00242      virtual QFrame *addPage(const QStringList &items, const QString &header=QString::null,
00243             const QPixmap &pixmap=QPixmap() );
00244 
00264     virtual QVBox *addVBoxPage( const QString &item,
00265             const QString &header=QString::null,
00266             const QPixmap &pixmap=QPixmap() );
00267 
00280     virtual QVBox *addVBoxPage( const QStringList &items,
00281             const QString &header=QString::null,
00282             const QPixmap &pixmap=QPixmap() );
00283 
00304     virtual QHBox *addHBoxPage( const QString &itemName,
00305             const QString &header=QString::null,
00306             const QPixmap &pixmap=QPixmap() );
00307 
00320     virtual QHBox *addHBoxPage( const QStringList &items,
00321             const QString &header=QString::null,
00322             const QPixmap &pixmap=QPixmap() );
00323 
00347     virtual QGrid *addGridPage( int n, Orientation dir,
00348             const QString &itemName,
00349             const QString &header=QString::null,
00350             const QPixmap &pixmap=QPixmap() );
00351 
00364     virtual QGrid *addGridPage( int n, Orientation dir,
00365             const QStringList &items,
00366             const QString &header=QString::null,
00367             const QPixmap &pixmap=QPixmap() );
00368 
00378     void removePage( QWidget *page );
00379 
00380 
00397     virtual int pageIndex( QWidget *widget ) const;
00398 
00408     virtual bool setSwallowedWidget( QWidget *widget );
00409 
00420     virtual void setTreeListAutoResize( bool state );
00421 
00434     virtual void setShowIconsInTreeList(bool state);
00435 
00444     virtual void setRootIsDecorated( bool state );
00445 
00459     /*virtual*/ void unfoldTreeList( bool persist = false ); //### KDE4 BIC add virtual
00460 
00469     /*virtual*/ void addWidgetBelowList( QWidget * widget ); // ### KDE4
00470 
00481     /*virtual*/ void addButtonBelowList( const QString & text, QObject * recv,
00482                     const char * slot ); //### KDE4
00483 
00495     /*virtual*/ void addButtonBelowList( const KGuiItem & guiitem, QObject *
00496                     recv, const char * slot ); //### KDE4
00497 
00510     virtual void setIconListAllVisible( bool state );
00511 
00517     virtual void setFolderIcon(const QStringList &path, const QPixmap &pixmap);
00524     /*virtual*/ QString pageTitle(int index) const;
00532     /*virtual*/ QWidget *pageWidget(int index) const;
00533 
00534   signals:
00540     void aboutToShowPage(QWidget *page);
00541 
00542   public slots:
00546     virtual void setFocus();
00547 
00548   protected:
00553     virtual void showEvent( QShowEvent * );
00554 
00563     virtual bool eventFilter( QObject *o, QEvent *e );
00564 
00565   private slots:
00566     bool slotShowPage();
00567     void slotFontChanged();
00568 
00569     void slotOnItem(QListBoxItem *item);
00570     void slotItemClicked(QListViewItem *it);
00571     void pageGone(QObject *obj); // signal from the added page's "destroyed" signal
00572     void slotReopen(QListViewItem *item);
00573 
00574   protected:
00575     bool showPage( QWidget *w );
00576     void addPageWidget( QFrame *page, const QStringList &items,
00577             const QString &header, const QPixmap &pixmap );
00578     void InsertTreeListItem(const QStringList &items, const QPixmap &pixmap, QFrame *page);
00579     QWidget *FindParent();
00580 
00581   private:
00582     bool mValid;
00583 
00584     // Obsolete members. Remove in KDE 4.
00585     QPtrList<QWidget> *mPageList;
00586     QStringList *mTitleList;
00587 
00588     int          mFace;
00589     KListView    *mTreeList;
00590     IconListBox  *mIconList;
00591     QWidgetStack *mPageStack;
00592     QLabel       *mTitleLabel;
00593     QTabWidget   *mTabControl;
00594     QFrame       *mPlainPage;
00595     QWidget      *mSwallowPage;
00596     QWidget      *mActivePageWidget;
00597     KSeparator   *mTitleSep;
00598     QSplitter::ResizeMode mTreeListResizeMode;
00599     bool         mShowIconsInTreeList;
00600     QMap<QListViewItem *, QWidget *> mTreeListToPageStack;
00601     QMap<QListBoxItem *, QWidget *> mIconListToPageStack;
00602     QMap<QString, QPixmap> mFolderIconMap;
00603     QMap<QString, QStringList> mChildrenNames;
00604     QMap<QString, QWidget *> mChildPages;
00605 
00606   public:
00607     class IconListItem;
00608   protected:
00609     virtual void virtual_hook( int id, void* data );
00610   private:
00611     class KJanusWidgetPrivate;
00612     KJanusWidgetPrivate *d;
00613 };
00614 
00615 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.4.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Oct 9 07:56:04 2005 by doxygen 1.4.4 written by Dimitri van Heesch, © 1997-2003