GCpp general purpose C++ library  version 1.0
GItem.hh
Go to the documentation of this file.
1 //======================================================================
2 /*! \file GItem.hh
3  *
4  * Include file for classes GItem and GSubItem.
5  */
6 //======================================================================
7 
8 #ifndef G_ITEM_HH
9 #define G_ITEM_HH
10 
11 #include "GNamed.hh"
12 
13 //======================================================================
14 /*! \class GItem
15  *
16  * This class defines base elements for collections of pointer on objects
17  * of any type.
18  *
19  * This class is used to generate objects lists for graphical interfaces.
20  *
21  * A name is associated to each element (pointer), and an identification
22  * number.
23  */
24 class GItem : public GNamed
25 {
26  //------------------------------------------------------------
27  /*! \object_doc */
29  //------------------------------------------------------------
30 
31  protected:
32  bool selected; ///< Indicates if the element is selected
33  int id; ///< Identification number (for ROOT widgets)
34 //#ifndef __MAKECINT__
35  void * user_data; ///< Pointer on user data
36 //#endif
37  string data_info; ///< More detailed information (if required)
38 
39  //------------------------------------------------------------
40  // Constructors / affectation / destructor
41  public:
42 
43  GItem ( const string &s, void *ptr = NULL, const int n = 0 );
44  GItem ( const GItem &original );
45 
46  virtual ~GItem ( );
47 
48  GItem & operator = ( const GItem &original );
49 
50  //------------------------------------------------------------
51  // Comparison operators
52  bool operator == ( const GItem &item );
53 
54  //------------------------------------------------------------
55  int GetId ( ) const;
56  void SetId ( const int n );
57  void * GetUserData ( ) const;
58  void SetUserData ( void * ptr );
59 
60  virtual string GetInfo ( ) const; // inline
61  virtual void SetInfo ( const string & info ); // inline
62 
63  //------------------------------------------------------------
64  void Select ( const bool b = true );
65  bool IsSelected ( ) const;
66 
67 };
68 
69 
70 //======================================================================
71 /*! \class GSubItem
72  *
73  * This class is derived from GItem, for elements of sub-lists build
74  * from a main list.
75  *
76  * The element in the main list is refered to with the \b parent pointer.
77  *
78  * This class is used for example by GItemSelectionBox widget.
79  */
80 class GSubItem : public GItem
81 {
82  //------------------------------------------------------------
83  /*! \object_doc */
85  //------------------------------------------------------------
86 
87  protected:
88  GItem * parent; ///< Pointer to the element in main list
89 
90  //------------------------------------------------------------
91  // Constructors / affectation / destructor
92  public:
93 
94  GSubItem ( const string &s, void *ptr = NULL, const int n = 0, GItem *p = NULL );
95  GSubItem ( const GSubItem &original );
96  GSubItem ( GItem *p, const bool udat = true );
97 
98  virtual ~GSubItem ( );
99 
100  GSubItem & operator = ( const GSubItem &original );
101 
102  //------------------------------------------------------------
103  // Comparison operators
104  bool operator == ( const GSubItem &item );
105 
106  //------------------------------------------------------------
107  GItem * GetParentItem ( ) const;
108  void SetParentItem ( GItem * par );
109 
110 };
111 
112 //----------------------------------------------------------------------
113 // Inline functions
114 #include "icc/GItem.icc"
115 
116 //======================================================================
117 #endif
virtual ~GItem()
Definition: GItem.icc:13
Definition: GItem.hh:80
Definition: GNamed.hh:21
void SetParentItem(GItem *par)
Definition: GItem.icc:106
string data_info
More detailed information (if required)
Definition: GItem.hh:37
int GetId() const
Definition: GItem.icc:19
GItem & operator=(const GItem &original)
Definition: GItem.cpp:43
bool IsSelected() const
Definition: GItem.icc:58
bool selected
Indicates if the element is selected.
Definition: GItem.hh:28
#define GObject(T)
Definition: GClassDefine.hh:65
bool operator==(const GSubItem &item)
Definition: GItem.icc:117
bool operator==(const GItem &item)
Definition: GItem.icc:65
GItem * parent
Pointer to the element in main list.
Definition: GItem.hh:84
GItem(const string &s, void *ptr=NULL, const int n=0)
Definition: GItem.cpp:19
GItem * GetParentItem() const
Definition: GItem.icc:110
int id
Identification number (for ROOT widgets)
Definition: GItem.hh:33
virtual ~GSubItem()
Definition: GItem.icc:100
void SetUserData(void *ptr)
Definition: GItem.icc:35
void * user_data
Pointer on user data.
Definition: GItem.hh:35
virtual string GetInfo() const
Definition: GItem.icc:40
Definition: GItem.hh:24
GSubItem(const string &s, void *ptr=NULL, const int n=0, GItem *p=NULL)
Definition: GItem.icc:79
void Select(const bool b=true)
Definition: GItem.icc:54
void * GetUserData() const
Definition: GItem.icc:23
GSubItem & operator=(const GSubItem &original)
Definition: GItem.cpp:62
void SetId(const int n)
Definition: GItem.icc:29
virtual void SetInfo(const string &info)
Definition: GItem.icc:46