]> SALOME platform Git repositories - modules/gui.git/blob - src/ObjBrowser/OB_ListItem.h
Salome HOME
071ec308a68883b82258df78c1a2d24353ea0146
[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
79   virtual int      rtti() const;
80
81   static int       RTTI();
82 };
83
84 /* 
85    CheckListItem class
86 */
87
88 class OB_EXPORT OB_CheckListItem : public ListItemF<QCheckListItem>, public QCheckListItem
89 {
90 public:
91   OB_CheckListItem( SUIT_DataObject*, QListView*, Type = CheckBox );
92   OB_CheckListItem( SUIT_DataObject*, QListViewItem*, Type = CheckBox );
93   OB_CheckListItem( SUIT_DataObject*, QListView*, QListViewItem*, Type = CheckBox );
94   OB_CheckListItem( SUIT_DataObject*, QListViewItem*, QListViewItem*, Type = CheckBox );
95
96   virtual ~OB_CheckListItem();
97
98   virtual void            setSelected( bool s );
99   virtual void            paintFocus( QPainter* p, const QColorGroup& cg, const QRect& r );
100   virtual void            paintCell( QPainter* p, const QColorGroup& cg, int c, int w, int align );
101
102
103   virtual int      rtti() const;
104
105   static int       RTTI();
106
107 protected:
108   void             stateChange( bool );
109
110 //private:
111 //  void             update();
112 };
113
114 #endif