kwidgetlist.h
00001 /* 00002 This file is part of KitchenSync. 00003 00004 Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef KWIDGETLIST_H 00023 #define KWIDGETLIST_H 00024 00025 #include <tqscrollview.h> 00026 00027 class KWidgetListItem; 00028 00029 class KWidgetList : public TQScrollView 00030 { 00031 Q_OBJECT 00032 00033 00034 public: 00035 KWidgetList( TQWidget *parent = 0, const char *name = 0 ); 00036 ~KWidgetList(); 00037 00038 uint count() const; 00039 00040 void appendItem( KWidgetListItem *item ); 00041 void removeItem( int index ); 00042 void takeItem( KWidgetListItem *item ); 00043 00044 void setSelected( KWidgetListItem *item ); 00045 void setSelected( int index ); 00046 00047 bool isSelected( KWidgetListItem *item ) const; 00048 bool isSelected( int index ) const; 00049 00050 KWidgetListItem *selectedItem() const; 00051 KWidgetListItem *item( int index ) const; 00052 00053 int index( KWidgetListItem *item ) const; 00054 00055 virtual bool eventFilter( TQObject *object, TQEvent *event ); 00056 00057 public slots: 00058 void clear(); 00059 virtual void setFocus(); 00060 00061 signals: 00062 void selectionChanged( KWidgetListItem *item ); 00063 void doubleClicked( KWidgetListItem *item ); 00064 00065 private: 00066 class Private; 00067 Private *d; 00068 }; 00069 00070 class KWidgetListItem : public TQWidget 00071 { 00072 public: 00073 KWidgetListItem( KWidgetList *parent, const char *name = 0 ); 00074 ~KWidgetListItem(); 00075 00076 void setSelected( bool selected ); 00077 00078 protected: 00079 void setForegroundColor( const TQColor& ); 00080 void setBackgroundColor( const TQColor& ); 00081 void setSelectionForegroundColor( const TQColor& ); 00082 void setSelectionBackgroundColor( const TQColor& ); 00083 00084 private: 00085 TQColor mForegroundColor; 00086 TQColor mBackgroundColor; 00087 TQColor mSelectionForegroundColor; 00088 TQColor mSelectionBackgroundColor; 00089 }; 00090 00091 #endif