Logo ROOT  
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 "TToggleGroup.h"
20 
22 
23 ////////////////////////////////////////////////////////////////////////////////
24 /// Constructor.
25 
27 {
28  fToggles = new TOrdCollection();
29 }
30 
31 ////////////////////////////////////////////////////////////////////////////////
32 /// Copy constructor
33 
34 TToggleGroup::TToggleGroup(const TToggleGroup& rhs) : TNamed(rhs),fToggles(0)
35 {
37 }
38 
39 ////////////////////////////////////////////////////////////////////////////////
40 /// Assignment operator.
41 
43 {
44  if (this != &rhs) {
45  delete fToggles;
47  }
48  return *this;
49 }
50 
51 
52 ////////////////////////////////////////////////////////////////////////////////
53 /// Deletes togglegroup but does not disposes toggled objects!
54 
56 {
57  delete fToggles;
58 }
59 
60 ////////////////////////////////////////////////////////////////////////////////
61 /// Add a new toggle.
62 
64 {
65  if (t) {
66  fToggles->AddLast(t);
67  if (select)
68  Select(t);
69  return IndexOf(t);
70  } else
71  return (-1);
72 }
73 
74 ////////////////////////////////////////////////////////////////////////////////
75 /// Add a new toggle at a specific position.
76 
78 {
79  if (t) {
80  fToggles->AddAt(t,pos);
81  if (select)
82  Select(t);
83  return IndexOf(t);
84  } else
85  return (-1);
86 }
87 
88 ////////////////////////////////////////////////////////////////////////////////
89 /// Select a toggle.
90 
92 {
93  TToggle *sel = At(idx);
94  if (sel)
95  Select(sel);
96 }
97 
98 ////////////////////////////////////////////////////////////////////////////////
99 /// Selector a toggle.
100 
102 {
103  TIter next(fToggles);
104  TToggle *i = 0;
105 
106  // Untoggle toggled , and toggle this one if it's present on a list!
107 
108  while ((i = (TToggle*)next()))
109  if ( i->GetState() || (i==t) )
110  i->Toggle();
111 }
112 
113 ////////////////////////////////////////////////////////////////////////////////
114 /// Disposes of all objects and clears array
115 
117 {
118  fToggles->Delete();
119 }
TToggleGroup::fToggles
TOrdCollection * fToggles
Definition: TToggleGroup.h:33
TToggle::GetState
virtual Bool_t GetState()
Returns the state of Toggle according to its current value and fOnValue, returns true if they match.
Definition: TToggle.cxx:69
TOrdCollection::Delete
void Delete(Option_t *option="")
Remove all objects from the collection AND delete all heap based objects.
Definition: TOrdCollection.cxx:199
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TToggleGroup::IndexOf
virtual Int_t IndexOf(TToggle *t)
Definition: TToggleGroup.h:50
TOrdCollection
Ordered collection.
Definition: TOrdCollection.h:32
TCollection::Clone
virtual TObject * Clone(const char *newname="") const
Make a clone of an collection using the Streamer facility.
Definition: TCollection.cxx:263
TToggleGroup.h
TToggleGroup::Select
virtual void Select(Int_t idx)
Select a toggle.
Definition: TToggleGroup.cxx:91
bool
TOrdCollection::AddAt
void AddAt(TObject *obj, Int_t idx)
Insert object at position idx in the collection.
Definition: TOrdCollection.cxx:59
TToggle
This class defines toggling facility for both - object's method or variables.
Definition: TToggle.h:47
TToggleGroup::~TToggleGroup
virtual ~TToggleGroup()
Deletes togglegroup but does not disposes toggled objects!
Definition: TToggleGroup.cxx:55
TToggleGroup::Add
virtual Int_t Add(TToggle *t, Bool_t select=1)
Add a new toggle.
Definition: TToggleGroup.cxx:63
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
TToggleGroup
This class defines check-box facility for TToggle objects It is used in context menu "selectors" for ...
Definition: TToggleGroup.h:30
TToggle::Toggle
virtual void Toggle()
Toggles the Values and State of this object and connected data!
Definition: TToggle.cxx:112
TToggleGroup::DeleteAll
virtual void DeleteAll()
Disposes of all objects and clears array.
Definition: TToggleGroup.cxx:116
TToggleGroup::operator=
TToggleGroup & operator=(const TToggleGroup &)
Assignment operator.
Definition: TToggleGroup.cxx:42
TToggleGroup::InsertAt
virtual Int_t InsertAt(TToggle *t, Int_t pos, Bool_t select=1)
Add a new toggle at a specific position.
Definition: TToggleGroup.cxx:77
TToggleGroup::TToggleGroup
TToggleGroup()
Constructor.
Definition: TToggleGroup.cxx:26
TToggleGroup::At
virtual TToggle * At(Int_t idx)
Definition: TToggleGroup.h:41
TIter
Definition: TCollection.h:233
int
TOrdCollection::AddLast
void AddLast(TObject *obj)
Add object at the end of the collection.
Definition: TOrdCollection.cxx:100