kitchensync

kwidgetlist.h
1/*
2 This file is part of KitchenSync.
3
4 Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22#ifndef KWIDGETLIST_H
23#define KWIDGETLIST_H
24
25#include <tqscrollview.h>
26
27class KWidgetListItem;
28
29class KWidgetList : public TQScrollView
30{
31 Q_OBJECT
32
33
34 public:
35 KWidgetList( TQWidget *parent = 0, const char *name = 0 );
36 ~KWidgetList();
37
38 uint count() const;
39
40 void appendItem( KWidgetListItem *item );
41 void removeItem( int index );
42 void takeItem( KWidgetListItem *item );
43
44 void setSelected( KWidgetListItem *item );
45 void setSelected( int index );
46
47 bool isSelected( KWidgetListItem *item ) const;
48 bool isSelected( int index ) const;
49
50 KWidgetListItem *selectedItem() const;
51 KWidgetListItem *item( int index ) const;
52
53 int index( KWidgetListItem *item ) const;
54
55 virtual bool eventFilter( TQObject *object, TQEvent *event );
56
57 public slots:
58 void clear();
59 virtual void setFocus();
60
61 signals:
62 void selectionChanged( KWidgetListItem *item );
63 void doubleClicked( KWidgetListItem *item );
64
65 private:
66 class Private;
67 Private *d;
68};
69
70class KWidgetListItem : public TQWidget
71{
72 public:
73 KWidgetListItem( KWidgetList *parent, const char *name = 0 );
74 ~KWidgetListItem();
75
76 void setSelected( bool selected );
77
78 protected:
79 void setForegroundColor( const TQColor& );
80 void setBackgroundColor( const TQColor& );
81 void setSelectionForegroundColor( const TQColor& );
82 void setSelectionBackgroundColor( const TQColor& );
83
84 private:
85 TQColor mForegroundColor;
86 TQColor mBackgroundColor;
87 TQColor mSelectionForegroundColor;
88 TQColor mSelectionBackgroundColor;
89};
90
91#endif