ROOT logo
#include "TPieSliceEditor.h"
#include "TPieSlice.h"
#include "TGTextEntry.h"
#include "TGNumberEntry.h"
#include "TGLabel.h"

ClassImp(TPieSliceEditor)


enum EPieSliceID{
   kPieSlice_Title = 0, kPieSlice_Value, kPieSlice_Offset
};


//______________________________________________________________________________
TPieSliceEditor::TPieSliceEditor(const TGWindow *p, 
                  Int_t width, Int_t height,
                  UInt_t options, Pixel_t back)
                  : TGedFrame(p, width, height, options | kVerticalFrame, back)
{
   // TPieSliceEditor constructor.
   
   fPieSlice = 0;
   
   // start initializing the window components
   MakeTitle("Title");

   fTitle = new TGTextEntry(this, new TGTextBuffer(50), kPieSlice_Title);
   fTitle->Resize(135, fTitle->GetDefaultHeight());
   fTitle->SetToolTipText("Enter the pie-slice label");
   // better take kLHintsLeft and Right - Right is not working at the moment
   AddFrame(fTitle, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));

   TGCompositeFrame *f1 = new TGCompositeFrame(this, 120, 20, kHorizontalFrame);
   TGLabel *lbl1 = new TGLabel(f1,"Value");
   fValue = new TGNumberEntry(f1, 2, 2, kPieSlice_Value, TGNumberEntry::kNESReal, TGNumberEntry::kNEANonNegative);
   //fValue->SetToolTipText("Set the slice absolute value")
   fValue->Resize(50, 20);
   f1->AddFrame(lbl1, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
   f1->AddFrame(fValue, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
   AddFrame(f1, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));

   TGCompositeFrame *f2 = new TGCompositeFrame(this, 120, 20, kHorizontalFrame);
   TGLabel *lbl2 = new TGLabel(f2,"Rad Offset");
   fOffset = new TGNumberEntry(f2, 4, 2, kPieSlice_Offset, TGNumberEntry::kNESRealTwo, TGNumberEntry::kNEANonNegative);
   //fOffset->SetToolTipText("Set the slice radial offset")
   fOffset->Resize(50, 20);
   f2->AddFrame(lbl2, new TGLayoutHints(kLHintsLeft,1, 1, 1, 1));
   f2->AddFrame(fOffset, new TGLayoutHints(kLHintsLeft, 7, 1, 1, 1));
   AddFrame(f2, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
}


//______________________________________________________________________________
TPieSliceEditor::~TPieSliceEditor()
{
   // TPieSliceEditor destructor.
}


//______________________________________________________________________________
void TPieSliceEditor::SetModel(TObject *obj)
{
   // Set model.

   fPieSlice = (TPieSlice*) (obj);
   
   fAvoidSignal = kTRUE;
   fTitle->SetText(fPieSlice->GetTitle());
   fValue->SetNumber(fPieSlice->GetValue());
   fOffset->SetNumber(fPieSlice->GetRadiusOffset());
   
   if (fInit) ConnectSignals2Slots();
   fAvoidSignal = kFALSE;
}


//_____________________________________________________________________________
void TPieSliceEditor::ConnectSignals2Slots()
{
   // Connect signals to slots.

   fTitle->Connect("TextChanged(const char *)","TPieSliceEditor",this,"DoTitle(const char *)");
   fValue->Connect("ValueSet(Long_t)", "TPieSliceEditor", this, "DoValue()");
   fOffset->Connect("ValueSet(Long_t)", "TPieSliceEditor", this, "DoOffset()");
   
   fInit = kFALSE;  // connect the slots to the signals only once
}


//______________________________________________________________________________
void TPieSliceEditor::DoTitle(const char *text)
{
   // Slot for setting the graph title.

   if (fAvoidSignal) return;
   fPieSlice->SetTitle(text);
   Update();
}


//______________________________________________________________________________
void TPieSliceEditor::DoValue()
{
   // Slot for setting the graph title.

   if (fAvoidSignal) return;
   
   fPieSlice->SetValue(fValue->GetNumber());
   Update();
}


//______________________________________________________________________________
void TPieSliceEditor::DoOffset()
{
   // Slot for setting the graph title.

   if (fAvoidSignal) return;
   
   fPieSlice->SetRadiusOffset(fOffset->GetNumber());
   Update();
}

 TPieSliceEditor.cxx:1
 TPieSliceEditor.cxx:2
 TPieSliceEditor.cxx:3
 TPieSliceEditor.cxx:4
 TPieSliceEditor.cxx:5
 TPieSliceEditor.cxx:6
 TPieSliceEditor.cxx:7
 TPieSliceEditor.cxx:8
 TPieSliceEditor.cxx:9
 TPieSliceEditor.cxx:10
 TPieSliceEditor.cxx:11
 TPieSliceEditor.cxx:12
 TPieSliceEditor.cxx:13
 TPieSliceEditor.cxx:14
 TPieSliceEditor.cxx:15
 TPieSliceEditor.cxx:16
 TPieSliceEditor.cxx:17
 TPieSliceEditor.cxx:18
 TPieSliceEditor.cxx:19
 TPieSliceEditor.cxx:20
 TPieSliceEditor.cxx:21
 TPieSliceEditor.cxx:22
 TPieSliceEditor.cxx:23
 TPieSliceEditor.cxx:24
 TPieSliceEditor.cxx:25
 TPieSliceEditor.cxx:26
 TPieSliceEditor.cxx:27
 TPieSliceEditor.cxx:28
 TPieSliceEditor.cxx:29
 TPieSliceEditor.cxx:30
 TPieSliceEditor.cxx:31
 TPieSliceEditor.cxx:32
 TPieSliceEditor.cxx:33
 TPieSliceEditor.cxx:34
 TPieSliceEditor.cxx:35
 TPieSliceEditor.cxx:36
 TPieSliceEditor.cxx:37
 TPieSliceEditor.cxx:38
 TPieSliceEditor.cxx:39
 TPieSliceEditor.cxx:40
 TPieSliceEditor.cxx:41
 TPieSliceEditor.cxx:42
 TPieSliceEditor.cxx:43
 TPieSliceEditor.cxx:44
 TPieSliceEditor.cxx:45
 TPieSliceEditor.cxx:46
 TPieSliceEditor.cxx:47
 TPieSliceEditor.cxx:48
 TPieSliceEditor.cxx:49
 TPieSliceEditor.cxx:50
 TPieSliceEditor.cxx:51
 TPieSliceEditor.cxx:52
 TPieSliceEditor.cxx:53
 TPieSliceEditor.cxx:54
 TPieSliceEditor.cxx:55
 TPieSliceEditor.cxx:56
 TPieSliceEditor.cxx:57
 TPieSliceEditor.cxx:58
 TPieSliceEditor.cxx:59
 TPieSliceEditor.cxx:60
 TPieSliceEditor.cxx:61
 TPieSliceEditor.cxx:62
 TPieSliceEditor.cxx:63
 TPieSliceEditor.cxx:64
 TPieSliceEditor.cxx:65
 TPieSliceEditor.cxx:66
 TPieSliceEditor.cxx:67
 TPieSliceEditor.cxx:68
 TPieSliceEditor.cxx:69
 TPieSliceEditor.cxx:70
 TPieSliceEditor.cxx:71
 TPieSliceEditor.cxx:72
 TPieSliceEditor.cxx:73
 TPieSliceEditor.cxx:74
 TPieSliceEditor.cxx:75
 TPieSliceEditor.cxx:76
 TPieSliceEditor.cxx:77
 TPieSliceEditor.cxx:78
 TPieSliceEditor.cxx:79
 TPieSliceEditor.cxx:80
 TPieSliceEditor.cxx:81
 TPieSliceEditor.cxx:82
 TPieSliceEditor.cxx:83
 TPieSliceEditor.cxx:84
 TPieSliceEditor.cxx:85
 TPieSliceEditor.cxx:86
 TPieSliceEditor.cxx:87
 TPieSliceEditor.cxx:88
 TPieSliceEditor.cxx:89
 TPieSliceEditor.cxx:90
 TPieSliceEditor.cxx:91
 TPieSliceEditor.cxx:92
 TPieSliceEditor.cxx:93
 TPieSliceEditor.cxx:94
 TPieSliceEditor.cxx:95
 TPieSliceEditor.cxx:96
 TPieSliceEditor.cxx:97
 TPieSliceEditor.cxx:98
 TPieSliceEditor.cxx:99
 TPieSliceEditor.cxx:100
 TPieSliceEditor.cxx:101
 TPieSliceEditor.cxx:102
 TPieSliceEditor.cxx:103
 TPieSliceEditor.cxx:104
 TPieSliceEditor.cxx:105
 TPieSliceEditor.cxx:106
 TPieSliceEditor.cxx:107
 TPieSliceEditor.cxx:108
 TPieSliceEditor.cxx:109
 TPieSliceEditor.cxx:110
 TPieSliceEditor.cxx:111
 TPieSliceEditor.cxx:112
 TPieSliceEditor.cxx:113
 TPieSliceEditor.cxx:114
 TPieSliceEditor.cxx:115
 TPieSliceEditor.cxx:116
 TPieSliceEditor.cxx:117
 TPieSliceEditor.cxx:118
 TPieSliceEditor.cxx:119
 TPieSliceEditor.cxx:120
 TPieSliceEditor.cxx:121
 TPieSliceEditor.cxx:122
 TPieSliceEditor.cxx:123
 TPieSliceEditor.cxx:124