Logo ROOT   6.18/05
Reference Guide
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
19
24};
25
26////////////////////////////////////////////////////////////////////////////////
27
28/*
29<center><h2>Implements user interface for editing of arrow attributes:
30shape, size, angle.</h2></center>
31The picture below shows this interface.
32*/
33
34////////////////////////////////////////////////////////////////////////////////
35/// Constructor of arrow GUI.
36
38 Int_t height, UInt_t options, Pixel_t back)
39 : TGedFrame(p, width, height, options | kVerticalFrame, back)
40{
41 fArrow = 0;
42
43 MakeTitle("Arrow");
44
45 TGCompositeFrame *f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
46 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
47
48 TGCompositeFrame *f2a = new TGCompositeFrame(f2, 80, 20);
49 f2->AddFrame(f2a, new TGLayoutHints(kLHintsTop, 10, 0, 0, 0));
50
51 TGLabel *fShapeLabel = new TGLabel(f2a, "Shape:");
52 f2a->AddFrame(fShapeLabel, new TGLayoutHints(kLHintsNormal, 0, 0, 1, 5));
53
54 TGLabel *fAngleLabel = new TGLabel(f2a, "Angle:");
55 f2a->AddFrame(fAngleLabel, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 5));
56
57 TGLabel *fSizeLabel = new TGLabel(f2a, "Size: ");
58 f2a->AddFrame(fSizeLabel, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 1));
59
60 TGCompositeFrame *f2b = new TGCompositeFrame(f2, 80, 20, kFixedWidth);
61 f2->AddFrame(f2b, new TGLayoutHints(kLHintsTop, 10, 0, 0, 0));
62
64 fOptionCombo->Resize(80, 20);
65 f2b->AddFrame(fOptionCombo, new TGLayoutHints(kLHintsExpandX, 1, 1, 1, 1));
67
68 fAngleEntry = new TGNumberEntry(f2b, 30, 8, kARROW_ANG,
72 fAngleEntry->GetNumberEntry()->SetToolTipText("Set the arrow opening angle in degrees.");
73 f2b->AddFrame(fAngleEntry, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
74
75 fSizeEntry = new TGNumberEntry(f2b, 0.03, 8, kARROW_SIZ,
79 fSizeEntry->GetNumberEntry()->SetToolTipText("Set the size of arrow.");
80 f2b->AddFrame(fSizeEntry, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
81
82}
83
84////////////////////////////////////////////////////////////////////////////////
85/// Destructor of arrow editor.
86
88{
90 TIter next(GetList());
91
92 while ((el = (TGFrameElement *)next())) {
93 if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame"))
94 ((TGCompositeFrame *)el->fFrame)->Cleanup();
95 }
96 Cleanup();
97}
98
99////////////////////////////////////////////////////////////////////////////////
100/// Connect signals to slots.
101
103{
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()");
109
110 fInit = kFALSE;
111}
112
113////////////////////////////////////////////////////////////////////////////////
114/// Pick up the used arrow attributes.
115
117{
118 fArrow = (TArrow *)obj;
120
122 if (id != fOptionCombo->GetSelected())
123 fOptionCombo->Select(id);
124
127
130
133}
134
135////////////////////////////////////////////////////////////////////////////////
136/// Slot connected to the arrow opening angle setting.
137
139{
140 if (fAvoidSignal) return;
143 Update();
144}
145
146////////////////////////////////////////////////////////////////////////////////
147/// Slot connected to the arrow shape setting.
148
150{
151 if (fAvoidSignal) return;
152 const char* opt=0;
153 switch (id) {
154 case 1:
155 opt = "|>";
156 break;
157 case 2:
158 opt = "<|";
159 break;
160 case 3:
161 opt = ">";
162 break;
163 case 4:
164 opt = "<";
165 break;
166 case 5:
167 opt = "->-";
168 break;
169 case 6:
170 opt = "-<-";
171 break;
172 case 7:
173 opt = "-|>-";
174 break;
175 case 8:
176 opt = "-<|-";
177 break;
178 case 9:
179 opt = "<>";
180 break;
181 case 10:
182 opt = "<|>";
183 break;
184 }
185 fArrow->SetDrawOption(opt);
187 Update();
188}
189
190
191////////////////////////////////////////////////////////////////////////////////
192/// Slot connected to the arrow size.
193
195{
196 if (fAvoidSignal) return;
199 Update();
200}
201
202////////////////////////////////////////////////////////////////////////////////
203/// Arrow shape combobox.
204
206{
207 TGComboBox *cb = new TGComboBox(parent, id);
208
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);
220 cb->Select(1);
221 return cb;
222}
223
224////////////////////////////////////////////////////////////////////////////////
225/// Return shape entry according to the arrow draw option.
226
228{
229 TString opt = option;
230 opt.ToLower();
231 Int_t id = 0;
232
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;
243 return id;
244}
ULong_t Pixel_t
Definition: GuiTypes.h:39
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:365
EArrowWid
@ kARROW_SIZ
@ kARROW_ANG
@ kARROW_OPT
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
@ kVerticalFrame
Definition: TGFrame.h:59
@ kFixedWidth
Definition: TGFrame.h:65
@ kHorizontalFrame
Definition: TGFrame.h:60
@ kLHintsNormal
Definition: TGLayout.h:39
@ kLHintsTop
Definition: TGLayout.h:34
@ kLHintsExpandX
Definition: TGLayout.h:37
XFontStruct * id
Definition: TGX11.cxx:108
virtual void ConnectSignals2Slots()
Connect signals to slots.
TArrow * fArrow
Definition: TArrowEditor.h:34
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
Definition: TArrowEditor.h:37
virtual ~TArrowEditor()
Destructor of arrow editor.
virtual void DoSize()
Slot connected to the arrow size.
TArrowEditor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor of arrow GUI.
TGNumberEntry * fAngleEntry
Definition: TArrowEditor.h:36
TGComboBox * BuildOptionComboBox(TGFrame *parent, Int_t id)
Arrow shape combobox.
virtual void SetModel(TObject *obj)
Pick up the used arrow attributes.
TGComboBox * fOptionCombo
Definition: TArrowEditor.h:35
virtual void DoAngle()
Slot connected to the arrow opening angle setting.
Draw all kinds of Arrows.
Definition: TArrow.h:29
Float_t GetAngle() const
Definition: TArrow.h:51
virtual void SetArrowSize(Float_t arrowsize=0.05)
Definition: TArrow.h:59
virtual void Paint(Option_t *option="")
Paint this arrow with its current attributes.
Definition: TArrow.cxx:159
Float_t GetArrowSize() const
Definition: TArrow.h:52
virtual void SetAngle(Float_t angle=60)
Definition: TArrow.h:58
virtual Int_t GetSelected() const
Definition: TGComboBox.h:134
virtual void AddEntry(TGString *s, Int_t id)
Definition: TGComboBox.h:106
virtual TGListBox * GetListBox() const
Definition: TGComboBox.h:130
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...
Definition: TGComboBox.cxx:443
virtual TList * GetList() const
Definition: TGFrame.h:369
TGCompositeFrame(const TGCompositeFrame &)
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:949
TGFrame * fFrame
Definition: TGLayout.h:119
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
virtual void SetNumber(Double_t val)
TGNumberEntryField * GetNumberEntry() const
virtual Double_t GetNumber() const
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:84
Bool_t fInit
Definition: TGedFrame.h:53
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition: TGedFrame.cxx:73
Bool_t fAvoidSignal
Definition: TGedFrame.h:56
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:128
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
Definition: TObject.cxx:341
virtual void SetDrawOption(Option_t *option="")
Set drawing option for object.
Definition: TObject.cxx:677
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition: TQObject.cxx:867
Basic string class.
Definition: TString.h:131
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1125
static constexpr double deg