18 ClassImp(TArrowEditor);
37 TArrowEditor::TArrowEditor(
const TGWindow *p, Int_t width,
38 Int_t height, UInt_t options, Pixel_t back)
39 : TGedFrame(p, width, height, options | kVerticalFrame, back)
45 TGCompositeFrame *f2 =
new TGCompositeFrame(
this, 80, 20, kHorizontalFrame);
46 AddFrame(f2,
new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
48 TGCompositeFrame *f2a =
new TGCompositeFrame(f2, 80, 20);
49 f2->AddFrame(f2a,
new TGLayoutHints(kLHintsTop, 10, 0, 0, 0));
51 TGLabel *fShapeLabel =
new TGLabel(f2a,
"Shape:");
52 f2a->AddFrame(fShapeLabel,
new TGLayoutHints(kLHintsNormal, 0, 0, 1, 5));
54 TGLabel *fAngleLabel =
new TGLabel(f2a,
"Angle:");
55 f2a->AddFrame(fAngleLabel,
new TGLayoutHints(kLHintsNormal, 0, 0, 5, 5));
57 TGLabel *fSizeLabel =
new TGLabel(f2a,
"Size: ");
58 f2a->AddFrame(fSizeLabel,
new TGLayoutHints(kLHintsNormal, 0, 0, 5, 1));
60 TGCompositeFrame *f2b =
new TGCompositeFrame(f2, 80, 20, kFixedWidth);
61 f2->AddFrame(f2b,
new TGLayoutHints(kLHintsTop, 10, 0, 0, 0));
63 fOptionCombo = BuildOptionComboBox(f2b, kARROW_OPT);
64 fOptionCombo->Resize(80, 20);
65 f2b->AddFrame(fOptionCombo,
new TGLayoutHints(kLHintsExpandX, 1, 1, 1, 1));
66 fOptionCombo->Associate(
this);
68 fAngleEntry =
new TGNumberEntry(f2b, 30, 8, kARROW_ANG,
69 TGNumberFormat::kNESInteger,
70 TGNumberFormat::kNEANonNegative,
71 TGNumberFormat::kNELLimitMinMax,0, 180);
72 fAngleEntry->GetNumberEntry()->SetToolTipText(
"Set the arrow opening angle in degrees.");
73 f2b->AddFrame(fAngleEntry,
new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
75 fSizeEntry =
new TGNumberEntry(f2b, 0.03, 8, kARROW_SIZ,
76 TGNumberFormat::kNESRealTwo,
77 TGNumberFormat::kNEANonNegative,
78 TGNumberFormat::kNELLimitMinMax, 0.01, 0.30);
79 fSizeEntry->GetNumberEntry()->SetToolTipText(
"Set the size of arrow.");
80 f2b->AddFrame(fSizeEntry,
new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
87 TArrowEditor::~TArrowEditor()
90 TIter next(GetList());
92 while ((el = (TGFrameElement *)next())) {
93 if (!strcmp(el->fFrame->ClassName(),
"TGCompositeFrame"))
94 ((TGCompositeFrame *)el->fFrame)->Cleanup();
102 void TArrowEditor::ConnectSignals2Slots()
104 fOptionCombo->Connect(
"Selected(Int_t)",
"TArrowEditor",
this,
"DoOption(Int_t)");
105 fAngleEntry->Connect(
"ValueSet(Long_t)",
"TArrowEditor",
this,
"DoAngle()");
106 (fAngleEntry->GetNumberEntry())->Connect(
"ReturnPressed()",
"TArrowEditor",
this,
"DoAngle()");
107 fSizeEntry->Connect(
"ValueSet(Long_t)",
"TArrowEditor",
this,
"DoSize()");
108 (fSizeEntry->GetNumberEntry())->Connect(
"ReturnPressed()",
"TArrowEditor",
this,
"DoSize()");
116 void TArrowEditor::SetModel(TObject* obj)
118 fArrow = (TArrow *)obj;
119 fAvoidSignal = kTRUE;
121 Int_t
id = GetShapeEntry(fArrow->GetDrawOption());
122 if (
id != fOptionCombo->GetSelected())
123 fOptionCombo->Select(
id);
125 Float_t sz = fArrow->GetArrowSize();
126 fSizeEntry->SetNumber(sz);
128 Int_t deg = (Int_t)fArrow->GetAngle();
129 fAngleEntry->SetNumber(deg);
131 if (fInit) ConnectSignals2Slots();
132 fAvoidSignal = kFALSE;
138 void TArrowEditor::DoAngle()
140 if (fAvoidSignal)
return;
141 fArrow->SetAngle((Float_t)fAngleEntry->GetNumber());
142 fArrow->Paint(fArrow->GetDrawOption());
149 void TArrowEditor::DoOption(Int_t
id)
151 if (fAvoidSignal)
return;
185 fArrow->SetDrawOption(opt);
186 fArrow->Paint(fArrow->GetDrawOption());
194 void TArrowEditor::DoSize()
196 if (fAvoidSignal)
return;
197 fArrow->SetArrowSize(fSizeEntry->GetNumber());
198 fArrow->Paint(fArrow->GetDrawOption());
205 TGComboBox* TArrowEditor::BuildOptionComboBox(TGFrame* parent, Int_t
id)
207 TGComboBox *cb =
new TGComboBox(parent,
id);
209 cb->AddEntry(
" -------|>",1);
210 cb->AddEntry(
" <|-------",2);
211 cb->AddEntry(
" -------->",3);
212 cb->AddEntry(
" <--------",4);
213 cb->AddEntry(
" ---->----",5);
214 cb->AddEntry(
" ----<----",6);
215 cb->AddEntry(
" ----|>---",7);
216 cb->AddEntry(
" ---<|----",8);
217 cb->AddEntry(
" <------>", 9);
218 cb->AddEntry(
" <|-----|>",10);
219 (cb->GetListBox())->Resize((cb->GetListBox())->GetWidth(), 136);
227 Int_t TArrowEditor::GetShapeEntry(Option_t *option)
229 TString opt = option;
233 if (opt ==
"|>")
id = 1;
234 if (opt ==
"<|")
id = 2;
235 if (opt ==
">")
id = 3;
236 if (opt ==
"<")
id = 4;
237 if (opt ==
"->-")
id = 5;
238 if (opt ==
"-<-")
id = 6;
239 if (opt ==
"-|>-")
id = 7;
240 if (opt ==
"-<|-")
id = 8;
241 if (opt ==
"<>")
id = 9;
242 if (opt ==
"<|>")
id = 10;