Logo ROOT   6.14/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 
20 enum EArrowWid {
24 };
25 
26 ////////////////////////////////////////////////////////////////////////////////
27 
28 /*
29 <center><h2>Implements user interface for editing of arrow attributes:
30 shape, size, angle.</h2></center>
31 The 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));
66  fOptionCombo->Associate(this);
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 {
89  TGFrameElement *el;
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 
125  Float_t sz = fArrow->GetArrowSize();
126  fSizeEntry->SetNumber(sz);
127 
128  Int_t deg = (Int_t)fArrow->GetAngle();
129  fAngleEntry->SetNumber(deg);
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 }
TGNumberEntry * fAngleEntry
Definition: TArrowEditor.h:36
virtual void Paint(Option_t *option="")
Paint this arrow with its current attributes.
Definition: TArrow.cxx:159
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
Int_t GetShapeEntry(Option_t *opt)
Return shape entry according to the arrow draw option.
Float_t GetArrowSize() const
Definition: TArrow.h:52
TGComboBox * fOptionCombo
Definition: TArrowEditor.h:35
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
image html pict1_TGaxis_012 png width
Define new text attributes for the label number "labNum".
Definition: TGaxis.cxx:2551
virtual void DoOption(Int_t id)
Slot connected to the arrow shape setting.
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
virtual void SetModel(TObject *obj)
Pick up the used arrow attributes.
virtual void SetNumber(Double_t val)
Basic string class.
Definition: TString.h:131
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1100
int Int_t
Definition: RtypesCore.h:41
UInt_t GetWidth() const
Definition: TGFrame.h:271
TArrow * fArrow
Definition: TArrowEditor.h:34
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:128
Bool_t fAvoidSignal
Definition: TGedFrame.h:56
ULong_t Pixel_t
Definition: GuiTypes.h:39
virtual ~TArrowEditor()
Destructor of arrow editor.
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition: TGedFrame.cxx:73
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
TGCompositeFrame(const TGCompositeFrame &)
virtual void SetArrowSize(Float_t arrowsize=0.05)
Definition: TArrow.h:59
virtual TList * GetList() const
Definition: TGFrame.h:369
XFontStruct * id
Definition: TGX11.cxx:108
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.
TGComboBox * BuildOptionComboBox(TGFrame *parent, Int_t id)
Arrow shape combobox.
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
Definition: TObject.cxx:341
virtual TGListBox * GetListBox() const
Definition: TGComboBox.h:130
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
virtual void DoAngle()
Slot connected to the arrow opening angle setting.
static constexpr double deg
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:84
unsigned int UInt_t
Definition: RtypesCore.h:42
TGFrame * fFrame
Definition: TGLayout.h:119
const Bool_t kFALSE
Definition: RtypesCore.h:88
virtual void ConnectSignals2Slots()
Connect signals to slots.
#define ClassImp(name)
Definition: Rtypes.h:359
virtual void AddEntry(TGString *s, Int_t id)
Definition: TGComboBox.h:106
virtual Double_t GetNumber() const
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void DoSize()
Slot connected to the arrow size.
Bool_t fInit
Definition: TGedFrame.h:53
virtual Int_t GetSelected() const
Definition: TGComboBox.h:134
TGNumberEntryField * GetNumberEntry() const
Float_t GetAngle() const
Definition: TArrow.h:51
Draw all kinds of Arrows.
Definition: TArrow.h:29
virtual void SetDrawOption(Option_t *option="")
Set drawing option for object.
Definition: TObject.cxx:677
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:949
const Bool_t kTRUE
Definition: RtypesCore.h:87
EArrowWid
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
TGNumberEntry * fSizeEntry
Definition: TArrowEditor.h:37
virtual void SetAngle(Float_t angle=60)
Definition: TArrow.h:58