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., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef _KJANUS_WIDGET_H_ 00021 #define _KJANUS_WIDGET_H_ 00022 00023 #include <tqptrlist.h> 00024 #include <tqpixmap.h> 00025 #include <tqsplitter.h> 00026 00027 #include <tdelistbox.h> 00028 #include <tqstringlist.h> 00029 #include <tqmap.h> 00030 00031 class TDEListView; 00032 00033 class TQGrid; 00034 class TQHBox; 00035 class TQLabel; 00036 class TQTabWidget; 00037 class TQVBox; 00038 class TQWidgetStack; 00039 class KSeparator; 00040 class TQListViewItem; 00041 class KGuiItem; 00042 00067 class TDEUI_EXPORT KJanusWidget : public TQWidget 00068 { 00069 Q_OBJECT 00070 00071 private: 00072 class IconListBox : public TDEListBox 00073 { 00074 friend class KJanusWidget; 00075 00076 public: 00077 IconListBox( TQWidget *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( TQListBoxItem *item ); 00086 virtual void leaveEvent( TQEvent * ); 00087 00088 private: 00089 bool mShowAll; 00090 bool mHeightValid; 00091 bool mWidthValid; 00092 TQListBoxItem *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( TQWidget *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 TQSize minimumSizeHint() const; 00190 00197 virtual TQSize sizeHint() const; 00198 00204 virtual TQFrame *plainPage(); 00205 00225 virtual TQFrame *addPage(const TQString &item,const TQString &header=TQString::null, 00226 const TQPixmap &pixmap=TQPixmap() ); 00227 00242 virtual TQFrame *addPage(const TQStringList &items, const TQString &header=TQString::null, 00243 const TQPixmap &pixmap=TQPixmap() ); 00244 00264 virtual TQVBox *addVBoxPage( const TQString &item, 00265 const TQString &header=TQString::null, 00266 const TQPixmap &pixmap=TQPixmap() ); 00267 00280 virtual TQVBox *addVBoxPage( const TQStringList &items, 00281 const TQString &header=TQString::null, 00282 const TQPixmap &pixmap=TQPixmap() ); 00283 00304 virtual TQHBox *addHBoxPage( const TQString &itemName, 00305 const TQString &header=TQString::null, 00306 const TQPixmap &pixmap=TQPixmap() ); 00307 00320 virtual TQHBox *addHBoxPage( const TQStringList &items, 00321 const TQString &header=TQString::null, 00322 const TQPixmap &pixmap=TQPixmap() ); 00323 00347 virtual TQGrid *addGridPage( int n, Orientation dir, 00348 const TQString &itemName, 00349 const TQString &header=TQString::null, 00350 const TQPixmap &pixmap=TQPixmap() ); 00351 00364 virtual TQGrid *addGridPage( int n, Orientation dir, 00365 const TQStringList &items, 00366 const TQString &header=TQString::null, 00367 const TQPixmap &pixmap=TQPixmap() ); 00368 00378 void removePage( TQWidget *page ); 00379 00380 00397 virtual int pageIndex( TQWidget *widget ) const; 00398 00408 virtual bool setSwallowedWidget( TQWidget *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( TQWidget * widget ); // ### KDE4 00470 00481 /*virtual*/ void addButtonBelowList( const TQString & text, TQObject * recv, 00482 const char * slot ); //### KDE4 00483 00495 /*virtual*/ void addButtonBelowList( const KGuiItem & guiitem, TQObject * 00496 recv, const char * slot ); //### KDE4 00497 00510 virtual void setIconListAllVisible( bool state ); 00511 00517 virtual void setFolderIcon(const TQStringList &path, const TQPixmap &pixmap); 00524 /*virtual*/ TQString pageTitle(int index) const; 00532 /*virtual*/ TQWidget *pageWidget(int index) const; 00533 00534 signals: 00540 void aboutToShowPage(TQWidget *page); 00541 00542 public slots: 00546 virtual void setFocus(); 00547 00548 protected: 00553 virtual void showEvent( TQShowEvent * ); 00554 00563 virtual bool eventFilter( TQObject *o, TQEvent *e ); 00564 00565 private slots: 00566 bool slotShowPage(); 00567 void slotFontChanged(); 00568 00569 void slotOnItem(TQListBoxItem *item); 00570 void slotItemClicked(TQListViewItem *it); 00571 void pageGone(TQObject *obj); // signal from the added page's "destroyed" signal 00572 void slotReopen(TQListViewItem *item); 00573 00574 protected: 00575 bool showPage( TQWidget *w ); 00576 void addPageWidget( TQFrame *page, const TQStringList &items, 00577 const TQString &header, const TQPixmap &pixmap ); 00578 void InsertTreeListItem(const TQStringList &items, const TQPixmap &pixmap, TQFrame *page); 00579 TQWidget *FindParent(); 00580 00581 private: 00582 bool mValid; 00583 00584 // Obsolete members. Remove in KDE 4. 00585 TQPtrList<TQWidget> *mPageList; 00586 TQStringList *mTitleList; 00587 00588 int mFace; 00589 TDEListView *mTreeList; 00590 IconListBox *mIconList; 00591 TQWidgetStack *mPageStack; 00592 TQLabel *mTitleLabel; 00593 TQTabWidget *mTabControl; 00594 TQFrame *mPlainPage; 00595 TQWidget *mSwallowPage; 00596 TQWidget *mActivePageWidget; 00597 KSeparator *mTitleSep; 00598 TQSplitter::ResizeMode mTreeListResizeMode; 00599 bool mShowIconsInTreeList; 00600 TQMap<TQListViewItem *, TQWidget *> mTreeListToPageStack; 00601 TQMap<TQListBoxItem *, TQWidget *> mIconListToPageStack; 00602 TQMap<TQString, TQPixmap> mFolderIconMap; 00603 TQMap<TQString, TQStringList> mChildrenNames; 00604 TQMap<TQString, TQWidget *> 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