Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TArrowEditor.cxx
Go to the documentation of this file.
1// @(#)root/ged:$Id$
2// Author: Ilka Antcheva 20/10/04
3
4/*************************************************************************
5 * Copyright (C) 1995-2004, 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#include "TArrowEditor.h"
13#include "TGComboBox.h"
14#include "TGLabel.h"
15#include "TGNumberEntry.h"
16#include "TArrow.h"
17
18
24
25/** \class TArrowEditor
26 \ingroup ged
27
28Implements user interface for editing of arrow attributes:
29shape, size, angle.
30*/
31
32////////////////////////////////////////////////////////////////////////////////
33/// Constructor of arrow GUI.
34
36 Int_t height, UInt_t options, Pixel_t back)
37 : TGedFrame(p, width, height, options | kVerticalFrame, back)
38{
39 fArrow = 0;
40
41 MakeTitle("Arrow");
42
43 TGCompositeFrame *f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
44 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
45
46 TGCompositeFrame *f2a = new TGCompositeFrame(f2, 80, 20);
47 f2->AddFrame(f2a, new TGLayoutHints(kLHintsTop, 10, 0, 0, 0));
48
49 TGLabel *fShapeLabel = new TGLabel(f2a, "Shape:");
50 f2a->AddFrame(fShapeLabel, new TGLayoutHints(kLHintsNormal, 0, 0, 1, 5));
51
52 TGLabel *fAngleLabel = new TGLabel(f2a, "Angle:");
53 f2a->AddFrame(fAngleLabel, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 5));
54
55 TGLabel *fSizeLabel = new TGLabel(f2a, "Size: ");
56 f2a->AddFrame(fSizeLabel, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 1));
57
58 TGCompositeFrame *f2b = new TGCompositeFrame(f2, 80, 20, kFixedWidth);
59 f2->AddFrame(f2b, new TGLayoutHints(kLHintsTop, 10, 0, 0, 0));
60
62 fOptionCombo->Resize(80, 20);
63 f2b->AddFrame(fOptionCombo, new TGLayoutHints(kLHintsExpandX, 1, 1, 1, 1));
64 fOptionCombo->Associate(this);
65
66 fAngleEntry = new TGNumberEntry(f2b, 30, 8, kARROW_ANG,
70 fAngleEntry->GetNumberEntry()->SetToolTipText("Set the arrow opening angle in degrees.");
71 f2b->AddFrame(fAngleEntry, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
72
73 fSizeEntry = new TGNumberEntry(f2b, 0.03, 8, kARROW_SIZ,
77 fSizeEntry->GetNumberEntry()->SetToolTipText("Set the size of arrow.");
78 f2b->AddFrame(fSizeEntry, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
79
80}
81
82////////////////////////////////////////////////////////////////////////////////
83/// Destructor of arrow editor.
84
86{
88 TIter next(GetList());
89
90 while ((el = (TGFrameElement *)next())) {
91 if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame"))
92 ((TGCompositeFrame *)el->fFrame)->Cleanup();
93 }
94 Cleanup();
95}
96
97////////////////////////////////////////////////////////////////////////////////
98/// Connect signals to slots.
99
101{
102 fOptionCombo->Connect("Selected(Int_t)", "TArrowEditor", this, "DoOption(Int_t)");
103 fAngleEntry->Connect("ValueSet(Long_t)", "TArrowEditor", this, "DoAngle()");
104 (fAngleEntry->GetNumberEntry())->Connect("ReturnPressed()", "TArrowEditor", this, "DoAngle()");
105 fSizeEntry->Connect("ValueSet(Long_t)", "TArrowEditor", this, "DoSize()");
106 (fSizeEntry->GetNumberEntry())->Connect("ReturnPressed()", "TArrowEditor", this, "DoSize()");
107
108 fInit = kFALSE;
109}
110
111////////////////////////////////////////////////////////////////////////////////
112/// Pick up the used arrow attributes.
113
115{
116 fArrow = (TArrow *)obj;
118
119 Int_t id = GetShapeEntry(fArrow->GetDrawOption());
120 if (id != fOptionCombo->GetSelected())
121 fOptionCombo->Select(id);
122
123 Float_t sz = fArrow->GetArrowSize();
124 fSizeEntry->SetNumber(sz);
125
126 Int_t deg = (Int_t)fArrow->GetAngle();
127 fAngleEntry->SetNumber(deg);
128
131}
132
133////////////////////////////////////////////////////////////////////////////////
134/// Slot connected to the arrow opening angle setting.
135
137{
138 if (fAvoidSignal) return;
139 fArrow->SetAngle((Float_t)fAngleEntry->GetNumber());
140 fArrow->Paint(fArrow->GetDrawOption());
141 Update();
142}
143
144////////////////////////////////////////////////////////////////////////////////
145/// Slot connected to the arrow shape setting.
146
148{
149 if (fAvoidSignal) return;
150 const char* opt=0;
151 switch (id) {
152 case 1:
153 opt = "|>";
154 break;
155 case 2:
156 opt = "<|";
157 break;
158 case 3:
159 opt = ">";
160 break;
161 case 4:
162 opt = "<";
163 break;
164 case 5:
165 opt = "->-";
166 break;
167 case 6:
168 opt = "-<-";
169 break;
170 case 7:
171 opt = "-|>-";
172 break;
173 case 8:
174 opt = "-<|-";
175 break;
176 case 9:
177 opt = "<>";
178 break;
179 case 10:
180 opt = "<|>";
181 break;
182 }
183 fArrow->SetDrawOption(opt);
184 fArrow->Paint(fArrow->GetDrawOption());
185 Update();
186}
187
188
189////////////////////////////////////////////////////////////////////////////////
190/// Slot connected to the arrow size.
191
193{
194 if (fAvoidSignal) return;
195 fArrow->SetArrowSize(fSizeEntry->GetNumber());
196 fArrow->Paint(fArrow->GetDrawOption());
197 Update();
198}
199
200////////////////////////////////////////////////////////////////////////////////
201/// Arrow shape combobox.
202
204{
205 TGComboBox *cb = new TGComboBox(parent, id);
206
207 cb->AddEntry(" -------|>",1);
208 cb->AddEntry(" <|-------",2);
209 cb->AddEntry(" -------->",3);
210 cb->AddEntry(" <--------",4);
211 cb->AddEntry(" ---->----",5);
212 cb->AddEntry(" ----<----",6);
213 cb->AddEntry(" ----|>---",7);
214 cb->AddEntry(" ---<|----",8);
215 cb->AddEntry(" <------>", 9);
216 cb->AddEntry(" <|-----|>",10);
217 (cb->GetListBox())->Resize((cb->GetListBox())->GetWidth(), 136);
218 cb->Select(1);
219 return cb;
220}
221
222////////////////////////////////////////////////////////////////////////////////
223/// Return shape entry according to the arrow draw option.
224
226{
227 TString opt = option;
228 opt.ToLower();
229 Int_t id = 0;
230
231 if (opt == "|>") id = 1;
232 if (opt == "<|") id = 2;
233 if (opt == ">") id = 3;
234 if (opt == "<") id = 4;
235 if (opt == "->-") id = 5;
236 if (opt == "-<-") id = 6;
237 if (opt == "-|>-") id = 7;
238 if (opt == "-<|-") id = 8;
239 if (opt == "<>") id = 9;
240 if (opt == "<|>") id = 10;
241 return id;
242}
@ kVerticalFrame
Definition GuiTypes.h:382
@ kFixedWidth
Definition GuiTypes.h:388
@ kHorizontalFrame
Definition GuiTypes.h:383
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
float Float_t
Float 4 bytes (float).
Definition RtypesCore.h:71
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
EArrowWid
@ kARROW_SIZ
@ kARROW_ANG
@ kARROW_OPT
@ kLHintsNormal
Definition TGLayout.h:32
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
XFontStruct * id
Definition TGX11.cxx:147
virtual void ConnectSignals2Slots()
Connect signals to slots.
TArrow * fArrow
arrow object
Int_t GetShapeEntry(Option_t *opt)
Return shape entry according to the arrow draw option.
virtual void DoOption(Int_t id)
Slot connected to the arrow shape setting.
TGNumberEntry * fSizeEntry
size entry
TArrowEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor of arrow GUI.
virtual void DoSize()
Slot connected to the arrow size.
TGNumberEntry * fAngleEntry
opening angle entry
TGComboBox * BuildOptionComboBox(TGFrame *parent, Int_t id)
Arrow shape combobox.
TGComboBox * fOptionCombo
arrow shapes combo box
void SetModel(TObject *obj) override
Pick up the used arrow attributes.
~TArrowEditor() override
Destructor of arrow editor.
virtual void DoAngle()
Slot connected to the arrow opening angle setting.
A combobox (also known as a drop down listbox) allows the selection of one item out of a list of item...
Definition TGComboBox.h:47
virtual void AddEntry(TGString *s, Int_t id)
Definition TGComboBox.h:86
virtual TGListBox * GetListBox() const
Definition TGComboBox.h:110
virtual void Select(Int_t id, Bool_t emit=kTRUE)
Make the selected item visible in the combo box window and emit signals according to the second param...
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
virtual TList * GetList() const
Definition TGFrame.h:312
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:959
TGCompositeFrame(const TGCompositeFrame &)=delete
TGFrame * fFrame
Definition TGLayout.h:112
TGFrame(const TGFrame &)=delete
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
TGNumberEntry is a number entry input widget with up/down buttons.
@ kNEANonNegative
Non-negative number.
@ kNESInteger
Style of number entry field.
@ kNESRealTwo
Fixed fraction real, two digit.
@ kNELLimitMinMax
Both lower and upper limits.
ROOT GUI Window base class.
Definition TGWindow.h:23
TGedFrame(const TGedFrame &)=delete
Bool_t fInit
init flag for setting signals/slots
Definition TGedFrame.h:47
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition TGedFrame.cxx:94
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition TGedFrame.cxx:71
Bool_t fAvoidSignal
flag for executing slots
Definition TGedFrame.h:50
Mother of all ROOT objects.
Definition TObject.h:42
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:227
Basic string class.
Definition TString.h:138
void ToLower()
Change string to lower-case.
Definition TString.cxx:1189