TPieSliceEditor.cxx

Go to the documentation of this file.
00001 #include "TPieSliceEditor.h"
00002 #include "TPieSlice.h"
00003 #include "TGTextEntry.h"
00004 #include "TGNumberEntry.h"
00005 #include "TGLabel.h"
00006 
00007 ClassImp(TPieSliceEditor)
00008 
00009 
00010 enum EPieSliceID{
00011    kPieSlice_Title = 0, kPieSlice_Value, kPieSlice_Offset
00012 };
00013 
00014 
00015 //______________________________________________________________________________
00016 TPieSliceEditor::TPieSliceEditor(const TGWindow *p, 
00017                   Int_t width, Int_t height,
00018                   UInt_t options, Pixel_t back)
00019                   : TGedFrame(p, width, height, options | kVerticalFrame, back)
00020 {
00021    // TPieSliceEditor constructor.
00022    
00023    fPieSlice = 0;
00024    
00025    // start initializing the window components
00026    MakeTitle("Title");
00027 
00028    fTitle = new TGTextEntry(this, new TGTextBuffer(50), kPieSlice_Title);
00029    fTitle->Resize(135, fTitle->GetDefaultHeight());
00030    fTitle->SetToolTipText("Enter the pie-slice label");
00031    // better take kLHintsLeft and Right - Right is not working at the moment
00032    AddFrame(fTitle, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
00033 
00034    TGCompositeFrame *f1 = new TGCompositeFrame(this, 120, 20, kHorizontalFrame);
00035    TGLabel *lbl1 = new TGLabel(f1,"Value");
00036    fValue = new TGNumberEntry(f1, 2, 2, kPieSlice_Value, TGNumberEntry::kNESReal, TGNumberEntry::kNEANonNegative);
00037    //fValue->SetToolTipText("Set the slice absolute value")
00038    fValue->Resize(50, 20);
00039    f1->AddFrame(lbl1, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
00040    f1->AddFrame(fValue, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
00041    AddFrame(f1, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
00042 
00043    TGCompositeFrame *f2 = new TGCompositeFrame(this, 120, 20, kHorizontalFrame);
00044    TGLabel *lbl2 = new TGLabel(f2,"Rad Offset");
00045    fOffset = new TGNumberEntry(f2, 4, 2, kPieSlice_Offset, TGNumberEntry::kNESRealTwo, TGNumberEntry::kNEANonNegative);
00046    //fOffset->SetToolTipText("Set the slice radial offset")
00047    fOffset->Resize(50, 20);
00048    f2->AddFrame(lbl2, new TGLayoutHints(kLHintsLeft,1, 1, 1, 1));
00049    f2->AddFrame(fOffset, new TGLayoutHints(kLHintsLeft, 7, 1, 1, 1));
00050    AddFrame(f2, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
00051 }
00052 
00053 
00054 //______________________________________________________________________________
00055 TPieSliceEditor::~TPieSliceEditor()
00056 {
00057    // TPieSliceEditor destructor.
00058 }
00059 
00060 
00061 //______________________________________________________________________________
00062 void TPieSliceEditor::SetModel(TObject *obj)
00063 {
00064    // Set model.
00065 
00066    fPieSlice = (TPieSlice*) (obj);
00067    
00068    fAvoidSignal = kTRUE;
00069    fTitle->SetText(fPieSlice->GetTitle());
00070    fValue->SetNumber(fPieSlice->GetValue());
00071    fOffset->SetNumber(fPieSlice->GetRadiusOffset());
00072    
00073    if (fInit) ConnectSignals2Slots();
00074    fAvoidSignal = kFALSE;
00075 }
00076 
00077 
00078 //_____________________________________________________________________________
00079 void TPieSliceEditor::ConnectSignals2Slots()
00080 {
00081    // Connect signals to slots.
00082 
00083    fTitle->Connect("TextChanged(const char *)","TPieSliceEditor",this,"DoTitle(const char *)");
00084    fValue->Connect("ValueSet(Long_t)", "TPieSliceEditor", this, "DoValue()");
00085    fOffset->Connect("ValueSet(Long_t)", "TPieSliceEditor", this, "DoOffset()");
00086    
00087    fInit = kFALSE;  // connect the slots to the signals only once
00088 }
00089 
00090 
00091 //______________________________________________________________________________
00092 void TPieSliceEditor::DoTitle(const char *text)
00093 {
00094    // Slot for setting the graph title.
00095 
00096    if (fAvoidSignal) return;
00097    fPieSlice->SetTitle(text);
00098    Update();
00099 }
00100 
00101 
00102 //______________________________________________________________________________
00103 void TPieSliceEditor::DoValue()
00104 {
00105    // Slot for setting the graph title.
00106 
00107    if (fAvoidSignal) return;
00108    
00109    fPieSlice->SetValue(fValue->GetNumber());
00110    Update();
00111 }
00112 
00113 
00114 //______________________________________________________________________________
00115 void TPieSliceEditor::DoOffset()
00116 {
00117    // Slot for setting the graph title.
00118 
00119    if (fAvoidSignal) return;
00120    
00121    fPieSlice->SetRadiusOffset(fOffset->GetNumber());
00122    Update();
00123 }
00124 

Generated on Tue Jul 5 14:19:48 2011 for ROOT_528-00b_version by  doxygen 1.5.1