/*
<img src="gif/TAttLineEditor.gif">
*/
//End_Html
#include "TAttLineEditor.h"
#include "TGColorSelect.h"
#include "TGComboBox.h"
#include "TColor.h"
#include "TGraph.h"
ClassImp(TAttLineEditor)
enum ELineWid {
   kCOLOR,
   kLINE_WIDTH,
   kLINE_STYLE
};
TAttLineEditor::TAttLineEditor(const TGWindow *p, Int_t width,
                               Int_t height, UInt_t options, Pixel_t back)
   : TGedFrame(p, width, height, options | kVerticalFrame, back)
{
   
   fPriority = 1;
   fAttLine = 0;
   MakeTitle("Line");
   TGCompositeFrame *f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
   AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
   fColorSelect = new TGColorSelect(f2, 0, kCOLOR);
   f2->AddFrame(fColorSelect, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
   fColorSelect->Associate(this);
   fStyleCombo = new TGLineStyleComboBox(this, kLINE_STYLE);
   fStyleCombo->Resize(137, 20);
   AddFrame(fStyleCombo, new TGLayoutHints(kLHintsLeft, 3, 1, 1, 1));
   fStyleCombo->Associate(this);
   fWidthCombo = new TGLineWidthComboBox(f2, kLINE_WIDTH);
   fWidthCombo->Resize(91, 20);
   f2->AddFrame(fWidthCombo, new TGLayoutHints(kLHintsLeft, 3, 1, 1, 1));
   fWidthCombo->Associate(this);
}
TAttLineEditor::~TAttLineEditor()
{
   
}
void TAttLineEditor::ConnectSignals2Slots()
{
   
   fColorSelect->Connect("ColorSelected(Pixel_t)", "TAttLineEditor", this, "DoLineColor(Pixel_t)");
   fStyleCombo->Connect("Selected(Int_t)", "TAttLineEditor", this, "DoLineStyle(Int_t)"); 
   fWidthCombo->Connect("Selected(Int_t)", "TAttLineEditor", this, "DoLineWidth(Int_t)"); 
   fInit = kFALSE;
}
void TAttLineEditor::SetModel(TObject* obj)
{
   
   fAttLine = dynamic_cast<TAttLine*>(obj);
   fAvoidSignal = kTRUE;
   fStyleCombo->Select(fAttLine->GetLineStyle());
   if (obj->InheritsFrom(TGraph::Class())) {
      fWidthCombo->Select(TMath::Abs(fAttLine->GetLineWidth()%100));
   } else {
      fWidthCombo->Select(fAttLine->GetLineWidth());
   }
   Color_t c = fAttLine->GetLineColor();
   Pixel_t p = TColor::Number2Pixel(c);
   fColorSelect->SetColor(p);
   if (fInit) ConnectSignals2Slots();
   fAvoidSignal = kFALSE;
}
void TAttLineEditor::DoLineColor(Pixel_t color)
{
   
   if (fAvoidSignal) return;
   fAttLine->SetLineColor(TColor::GetColor(color));
   Update();
}
void TAttLineEditor::DoLineStyle(Int_t style)
{
   
   if (fAvoidSignal) return;
   fAttLine->SetLineStyle(style);
   Update();
}
void TAttLineEditor::DoLineWidth(Int_t width)
{
   
   if (fAvoidSignal) return;
   if (dynamic_cast<TGraph*>(fAttLine)) {
      Int_t graphLineWidth = 100*Int_t(fAttLine->GetLineWidth()/100);
      if (graphLineWidth >= 0) {
         fAttLine->SetLineWidth(graphLineWidth+width);
      } else {
         fAttLine->SetLineWidth(-(TMath::Abs(graphLineWidth)+width));
      }
   } else {
      fAttLine->SetLineWidth(width);
   }
   Update();
}
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.