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 
00089 class KJanusWidget : public QWidget
00090 {
00091   Q_OBJECT
00092 
00093   private:
00094     class IconListBox : public KListBox
00095     {
00096       public:
00097         IconListBox( QWidget *parent=0, const char *name=0, WFlags f=0 );
00098     void updateMinimumHeight();
00099     void updateWidth();
00100     void invalidateHeight();
00101     void invalidateWidth();
00102     void setShowAll( bool showAll );
00103 
00104       private:
00105     bool mShowAll;
00106     bool mHeightValid;
00107     bool mWidthValid;
00108     };
00109 
00110   public:
00111     enum Face
00112     {
00113       TreeList = 0,
00114       Tabbed,
00115       Plain,
00116       Swallow,
00117       IconList
00118     };
00119 
00120   public:
00121 
00130     KJanusWidget( QWidget *parent=0, const char *name=0, int face=Plain );
00131 
00135     ~KJanusWidget();
00136 
00142     virtual bool showPage( int index );
00143 
00150     virtual int  activePageIndex() const;
00151 
00158     virtual bool isValid() const;
00159 
00165     virtual int face() const;
00166 
00173     virtual QSize minimumSizeHint() const;
00174 
00181     virtual QSize sizeHint() const;
00182 
00188     virtual QFrame *plainPage();
00189 
00209     virtual QFrame *addPage(const QString &item,const QString &header=QString::null,
00210             const QPixmap &pixmap=QPixmap() );
00211 
00226      virtual QFrame *addPage(const QStringList &items, const QString &header=QString::null,
00227             const QPixmap &pixmap=QPixmap() );
00228 
00248     virtual QVBox *addVBoxPage( const QString &item,
00249             const QString &header=QString::null,
00250             const QPixmap &pixmap=QPixmap() );
00251 
00264     virtual QVBox *addVBoxPage( const QStringList &items,
00265             const QString &header=QString::null,
00266             const QPixmap &pixmap=QPixmap() );
00267 
00288     virtual QHBox *addHBoxPage( const QString &itemName,
00289             const QString &header=QString::null,
00290             const QPixmap &pixmap=QPixmap() );
00291 
00304     virtual QHBox *addHBoxPage( const QStringList &items,
00305             const QString &header=QString::null,
00306             const QPixmap &pixmap=QPixmap() );
00307 
00331     virtual QGrid *addGridPage( int n, Orientation dir,
00332             const QString &itemName,
00333             const QString &header=QString::null,
00334             const QPixmap &pixmap=QPixmap() );
00335 
00348     virtual QGrid *addGridPage( int n, Orientation dir,
00349             const QStringList &items,
00350             const QString &header=QString::null,
00351             const QPixmap &pixmap=QPixmap() );
00352 
00362     void removePage( QWidget *page );
00363 
00364 
00381     virtual int pageIndex( QWidget *widget ) const;
00382 
00392     virtual bool setSwallowedWidget( QWidget *widget );
00393 
00404     virtual void setTreeListAutoResize( bool state );
00405 
00418     virtual void setShowIconsInTreeList(bool state);
00419 
00428     virtual void setRootIsDecorated( bool state );
00429 
00442     virtual void setIconListAllVisible( bool state );
00443 
00449     virtual void setFolderIcon(const QStringList &path, const QPixmap &pixmap);
00450 
00451   signals:
00452     void aboutToShowPage(QWidget *page);
00453 
00454   public slots:
00458     virtual void setFocus();
00459 
00460   protected:
00465     virtual void showEvent( QShowEvent * );
00466 
00475     virtual bool eventFilter( QObject *o, QEvent *e );
00476 
00477   private slots:
00478     bool slotShowPage();
00479     void slotFontChanged();
00480     void slotItemClicked(QListViewItem *it);
00481     void pageGone(QObject *obj); // signal from the added page's "destroyed" signal
00482 
00483   protected:
00484     bool showPage( QWidget *w );
00485     void addPageWidget( QFrame *page, const QStringList &items,
00486             const QString &header, const QPixmap &pixmap );
00487     void InsertTreeListItem(const QStringList &items, const QPixmap &pixmap, QFrame *page);
00488     QWidget *FindParent();
00489 
00490   private:
00491     bool mValid;
00492 
00493     // Obsolete members. Remove in KDE 4.
00494     QPtrList<QWidget> *mPageList;
00495     QStringList *mTitleList;
00496 
00497     int          mFace;
00498     KListView    *mTreeList;
00499     IconListBox  *mIconList;
00500     QWidgetStack *mPageStack;
00501     QLabel       *mTitleLabel;
00502     QTabWidget   *mTabControl;
00503     QFrame       *mPlainPage;
00504     QWidget      *mSwallowPage;
00505     QWidget      *mActivePageWidget;
00506     KSeparator   *mTitleSep;
00507     QSplitter::ResizeMode mTreeListResizeMode;
00508     bool         mShowIconsInTreeList;
00509     QMap<QListViewItem *, QWidget *> mTreeListToPageStack;
00510     QMap<QListBoxItem *, QWidget *> mIconListToPageStack;
00511     QMap<QString, QPixmap> mFolderIconMap;
00512     QMap<QString, QStringList> mChildrenNames;
00513     QMap<QString, QWidget *> mChildPages;
00514 
00515   public:
00516     class IconListItem;
00517   protected:
00518     virtual void virtual_hook( int id, void* data );
00519   private:
00520     class KJanusWidgetPrivate;
00521     KJanusWidgetPrivate *d;
00522 };
00523 
00524 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 27 22:15:03 2005 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001