Logo ROOT   6.12/07
Reference Guide
TToggleGroup.cxx
Go to the documentation of this file.
1 // @(#)root/meta:$Id$
2 // Author: Piotr Golonka 31/07/97
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /** \class TToggleGroup
13 
14 This class defines check-box facility for TToggle objects
15 It is used in context menu "selectors" for picking up a value.
16 */
17 
18 
19 #include "TMethod.h"
20 #include "TToggleGroup.h"
21 
23 
24 ////////////////////////////////////////////////////////////////////////////////
25 /// Constructor.
26 
28 {
29  fToggles = new TOrdCollection();
30 }
31 
32 ////////////////////////////////////////////////////////////////////////////////
33 /// Copy constructor
34 
36 {
38 }
39 
40 ////////////////////////////////////////////////////////////////////////////////
41 /// Assignment operator.
42 
44 {
45  if (this != &rhs) {
46  delete fToggles;
48  }
49  return *this;
50 }
51 
52 
53 ////////////////////////////////////////////////////////////////////////////////
54 /// Deletes togglegroup but does not disposes toggled objects!
55 
57 {
58  delete fToggles;
59 }
60 
61 ////////////////////////////////////////////////////////////////////////////////
62 /// Add a new toggle.
63 
65 {
66  if (t) {
67  fToggles->AddLast(t);
68  if (select)
69  Select(t);
70  return IndexOf(t);
71  } else
72  return (-1);
73 }
74 
75 ////////////////////////////////////////////////////////////////////////////////
76 /// Add a new toggle at a specific position.
77 
79 {
80  if (t) {
81  fToggles->AddAt(t,pos);
82  if (select)
83  Select(t);
84  return IndexOf(t);
85  } else
86  return (-1);
87 }
88 
89 ////////////////////////////////////////////////////////////////////////////////
90 /// Select a toggle.
91 
93 {
94  TToggle *sel = At(idx);
95  if (sel)
96  Select(sel);
97 }
98 
99 ////////////////////////////////////////////////////////////////////////////////
100 /// Selector a toggle.
101 
103 {
104  TIter next(fToggles);
105  TToggle *i = 0;
106 
107  // Untoggle toggled , and toggle this one if it's present on a list!
108 
109  while ((i = (TToggle*)next()))
110  if ( i->GetState() || (i==t) )
111  i->Toggle();
112 }
113 
114 ////////////////////////////////////////////////////////////////////////////////
115 /// Disposes of all objects and clears array
116 
118 {
119  fToggles->Delete();
120 }
void Delete(Option_t *option="")
Remove all objects from the collection AND delete all heap based objects.
This class defines toggling facility for both - object's method or variables.
Definition: TToggle.h:43
TOrdCollection * fToggles
Definition: TToggleGroup.h:33
void AddLast(TObject *obj)
Add object at the end of the collection.
virtual void Select(Int_t idx)
Select a toggle.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
This class defines check-box facility for TToggle objects It is used in context menu "selectors" for ...
Definition: TToggleGroup.h:30
virtual TObject * Clone(const char *newname="") const
Make a clone of an collection using the Streamer facility.
TToggleGroup()
Constructor.
virtual void Toggle()
Toggles the Values and State of this object and connected data!
Definition: TToggle.cxx:111
TToggleGroup & operator=(const TToggleGroup &)
Assignment operator.
virtual TToggle * At(Int_t idx)
Definition: TToggleGroup.h:41
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual Bool_t GetState()
Returns the state of Toggle according to its current value and fOnValue, returns true if they match...
Definition: TToggle.cxx:68
virtual Int_t Add(TToggle *t, Bool_t select=1)
Add a new toggle.
virtual Int_t InsertAt(TToggle *t, Int_t pos, Bool_t select=1)
Add a new toggle at a specific position.
#define ClassImp(name)
Definition: Rtypes.h:359
virtual ~TToggleGroup()
Deletes togglegroup but does not disposes toggled objects!
virtual void DeleteAll()
Disposes of all objects and clears array.
virtual Int_t IndexOf(TToggle *t)
Definition: TToggleGroup.h:50
void AddAt(TObject *obj, Int_t idx)
Insert object at position idx in the collection.
Ordered collection.