Salome HOME
Join modifications from branch BR_3_1_0deb
[modules/gui.git] / src / ObjBrowser / OB_ListItem.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/
18 //
19
20 #ifndef OB_LISTITEM_H
21 #define OB_LISTITEM_H
22
23 #include "OB.h"
24
25 #include <qlistview.h>
26
27 class SUIT_DataObject;
28
29 /* 
30   base template class for ListViewItems and CheckListItems
31 */
32
33 template<class T> class ListItemF
34 {
35 public:
36         ListItemF(T&, SUIT_DataObject* );
37   /*ListItem( SUIT_DataObject*, QListView* );
38   ListItem( SUIT_DataObject*, QListViewItem* );
39   ListItem( SUIT_DataObject*, QListView*, QListViewItem* );
40   ListItem( SUIT_DataObject*, QListViewItem*, QListViewItem* );
41
42   ListItem( SUIT_DataObject*, QListView*, int );
43   ListItem( SUIT_DataObject*, QListViewItem*, int );
44   ListItem( SUIT_DataObject*, QListView*, QListViewItem*, int );
45   ListItem( SUIT_DataObject*, QListViewItem*, QListViewItem*, int );*/
46
47   void            setSel( bool s );
48   inline SUIT_DataObject* dataObject() const { return myObject; }
49   void            paintFoc( QPainter* p, QColorGroup& cg, const QRect& r );
50   void            paintC( QPainter* p, QColorGroup& cg, int c, int w, int align );
51
52 protected:
53   void                     update();
54
55 protected:
56   SUIT_DataObject* myObject;
57   T& myT;
58 };
59
60 /* 
61    ListViewItem class
62 */
63
64 class OB_EXPORT OB_ListItem : public ListItemF<QListViewItem>, public QListViewItem
65 {
66 public:
67         OB_ListItem( SUIT_DataObject*, QListView* );
68         OB_ListItem( SUIT_DataObject*, QListViewItem* );
69         OB_ListItem( SUIT_DataObject*, QListView*, QListViewItem* );
70         OB_ListItem( SUIT_DataObject*, QListViewItem*, QListViewItem* );
71
72         virtual ~OB_ListItem();
73
74   virtual void            setSelected( bool s );
75   virtual void            paintFocus( QPainter* p, const QColorGroup& cg, const QRect& r );
76   virtual void            paintCell( QPainter* p, const QColorGroup& cg, int c, int w, int align );
77
78   virtual void setText ( int column, const QString & text );
79
80   virtual int      rtti() const;
81
82   static int       RTTI();
83 };
84
85 /* 
86    CheckListItem class
87 */
88
89 class OB_EXPORT OB_CheckListItem : public ListItemF<QCheckListItem>, public QCheckListItem
90 {
91 public:
92   OB_CheckListItem( SUIT_DataObject*, QListView*, Type = CheckBox );
93   OB_CheckListItem( SUIT_DataObject*, QListViewItem*, Type = CheckBox );
94   OB_CheckListItem( SUIT_DataObject*, QListView*, QListViewItem*, Type = CheckBox );
95   OB_CheckListItem( SUIT_DataObject*, QListViewItem*, QListViewItem*, Type = CheckBox );
96
97   virtual ~OB_CheckListItem();
98
99   virtual void            setSelected( bool s );
100   virtual void            paintFocus( QPainter* p, const QColorGroup& cg, const QRect& r );
101   virtual void            paintCell( QPainter* p, const QColorGroup& cg, int c, int w, int align );
102
103
104   virtual int      rtti() const;
105
106   static int       RTTI();
107
108 protected:
109   void             stateChange( bool );
110
111 //private:
112 //  void             update();
113 };
114
115 #endif