Logo ROOT  
Reference Guide
TTextEditor.cxx
Go to the documentation of this file.
1 /*************************************************************************
2  * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
3  * All rights reserved. *
4  * *
5  * For the licensing terms see $ROOTSYS/LICENSE. *
6  * For the list of contributors see $ROOTSYS/README/CREDITS. *
7  *************************************************************************/
8 
9 #include "TTextEditor.h"
10 #include "TText.h"
11 #include "TGTextEntry.h"
12 #include "TGNumberEntry.h"
13 #include "TGLabel.h"
14 
16 
17 
18 enum ELatexID{
20 };
21 
22 
23 ////////////////////////////////////////////////////////////////////////////////
24 /// TTextEditor constructor.
25 
27  Int_t width, Int_t height,
28  UInt_t options, Pixel_t back)
29  : TGedFrame(p, width, height, options | kVerticalFrame, back)
30 {
31  fText = 0;
32 
33  // start initializing the window components
34  MakeTitle("Text String");
35 
36  fText = new TGTextEntry(this, new TGTextBuffer(50), kText_Text);
38  fText->SetToolTipText("Enter the text string");
39  AddFrame(fText, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
40 
42  TGLabel *lbl1 = new TGLabel(f1,"X Position");
45  fXpos->Resize(50, 20);
46  f1->AddFrame(lbl1, new TGLayoutHints(kLHintsLeft,1, 1, 1, 1));
47  f1->AddFrame(fXpos, new TGLayoutHints(kLHintsLeft, 7, 1, 1, 1));
48  AddFrame(f1, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
49 
50  TGCompositeFrame *f2 = new TGCompositeFrame(this, 120, 20, kHorizontalFrame);
51  TGLabel *lbl2 = new TGLabel(f2,"Y Position");
54  fYpos->Resize(50, 20);
55  f2->AddFrame(lbl2, new TGLayoutHints(kLHintsLeft,1, 1, 1, 1));
56  f2->AddFrame(fYpos, new TGLayoutHints(kLHintsLeft, 7, 1, 1, 1));
57  AddFrame(f2, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
58 
59  TGCompositeFrame *f3 = new TGCompositeFrame(this, 120, 20, kHorizontalFrame);
60  TGLabel *lbl3 = new TGLabel(f3,"Text Angle");
63  fAngle->Resize(50, 20);
64  f3->AddFrame(lbl3, new TGLayoutHints(kLHintsLeft,1, 1, 1, 1));
65  f3->AddFrame(fAngle, new TGLayoutHints(kLHintsLeft, 7, 1, 1, 1));
66  AddFrame(f3, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
67 
68  TGCompositeFrame *f4 = new TGCompositeFrame(this, 120, 20, kHorizontalFrame);
69  TGLabel *lbl4 = new TGLabel(f4,"Text Size");
72  fSize->Resize(50, 20);
73  f4->AddFrame(lbl4, new TGLayoutHints(kLHintsLeft,1, 1, 1, 1));
74  f4->AddFrame(fSize, new TGLayoutHints(kLHintsLeft, 7, 1, 1, 1));
75  AddFrame(f4, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
76 }
77 
78 
79 ////////////////////////////////////////////////////////////////////////////////
80 /// TTextEditor destructor.
81 
83 {
84 }
85 
86 
87 ////////////////////////////////////////////////////////////////////////////////
88 /// Set model.
89 
91 {
92  fEditedText = (TText*) (obj);
93 
100 
103 }
104 
105 
106 ////////////////////////////////////////////////////////////////////////////////
107 /// Connect signals to slots.
108 
110 {
111  fText->Connect("TextChanged(const char *)","TTextEditor",this,"DoText(const char *)");
112  fXpos->Connect("ValueSet(Long_t)", "TTextEditor", this, "DoXpos()");
113  fYpos->Connect("ValueSet(Long_t)", "TTextEditor", this, "DoYpos()");
114  fAngle->Connect("ValueSet(Long_t)", "TTextEditor", this, "DoAngle()");
115  fSize->Connect("ValueSet(Long_t)", "TTextEditor", this, "DoSize()");
116 
117  fInit = kFALSE; // connect the slots to the signals only once
118 }
119 
120 ////////////////////////////////////////////////////////////////////////////////
121 /// Slot for setting the text Angle.
122 
124 {
125  if (fAvoidSignal) return;
127  Update();
128 }
129 
130 
131 ////////////////////////////////////////////////////////////////////////////////
132 /// Slot for setting the text Size.
133 
135 {
136  if (fAvoidSignal) return;
138  Update();
139 }
140 
141 
142 ////////////////////////////////////////////////////////////////////////////////
143 /// Slot for setting the text string.
144 
145 void TTextEditor::DoText(const char *text)
146 {
147  if (fAvoidSignal) return;
149  Update();
150 }
151 
152 
153 ////////////////////////////////////////////////////////////////////////////////
154 /// Slot for setting the text X position.
155 
157 {
158  if (fAvoidSignal) return;
160  Update();
161 }
162 
163 
164 ////////////////////////////////////////////////////////////////////////////////
165 /// Slot for setting the text Y position.
166 
168 {
169  if (fAvoidSignal) return;
171  Update();
172 }
kText_Text
@ kText_Text
Definition: TTextEditor.cxx:19
TGWindow
Definition: TGWindow.h:31
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TGTextEntry::SetText
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Sets text entry to text, clears the selection and moves the cursor to the end of the line.
Definition: TGTextEntry.cxx:623
TTextEditor::fSize
TGNumberEntry * fSize
Definition: TTextEditor.h:37
TTextEditor::fText
TGTextEntry * fText
Definition: TTextEditor.h:35
Pixel_t
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TNamed::GetTitle
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
kVerticalFrame
@ kVerticalFrame
Definition: GuiTypes.h:381
TGNumberFormat::kNEAAnyNumber
@ kNEAAnyNumber
Definition: TGNumberEntry.h:50
TText::SetX
virtual void SetX(Double_t x)
Definition: TText.h:76
kLHintsLeft
@ kLHintsLeft
Definition: TGLayout.h:31
TTextEditor::fEditedText
TText * fEditedText
Definition: TTextEditor.h:32
TGTextEntry::SetToolTipText
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
Definition: TGTextEntry.cxx:1663
TGLabel
Definition: TGLabel.h:32
TGFrame::GetDefaultHeight
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:215
kText_Size
@ kText_Size
Definition: TTextEditor.cxx:19
width
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
TGNumberFormat::kNEANonNegative
@ kNEANonNegative
Definition: TGNumberEntry.h:51
TTextEditor::ConnectSignals2Slots
void ConnectSignals2Slots()
Connect signals to slots.
Definition: TTextEditor.cxx:109
TAttText::SetTextSize
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition: TAttText.h:46
TTextEditor::DoText
void DoText(const char *)
Slot for setting the text string.
Definition: TTextEditor.cxx:145
TGNumberFormat::kNESRealTwo
@ kNESRealTwo
Definition: TGNumberEntry.h:36
TAttText::GetTextSize
virtual Float_t GetTextSize() const
Return the text size.
Definition: TAttText.h:36
TGedFrame::Update
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition: TGedFrame.cxx:73
ELatexID
ELatexID
Definition: TTextEditor.cxx:18
TTextEditor::DoAngle
void DoAngle()
Slot for setting the text Angle.
Definition: TTextEditor.cxx:123
text
TText * text
Definition: entrylist_figure1.C:10
TTextEditor.h
TGTextBuffer
Definition: TGTextBuffer.h:30
kText_Angle
@ kText_Angle
Definition: TTextEditor.cxx:19
TGedFrame::fAvoidSignal
Bool_t fAvoidSignal
Definition: TGedFrame.h:57
TAttText::GetTextAngle
virtual Float_t GetTextAngle() const
Return the text angle.
Definition: TAttText.h:33
kText_Xpos
@ kText_Xpos
Definition: TTextEditor.cxx:19
TText::GetX
Double_t GetX() const
Definition: TText.h:53
TTextEditor::fXpos
TGNumberEntry * fXpos
Definition: TTextEditor.h:38
TGNumberEntry::SetNumber
virtual void SetNumber(Double_t val)
Definition: TGNumberEntry.h:186
TText::GetY
Double_t GetY() const
Definition: TText.h:61
TTextEditor::SetModel
void SetModel(TObject *)
Set model.
Definition: TTextEditor.cxx:90
TGFrame::Resize
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:590
TGTextEntry
Definition: TGTextEntry.h:39
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TGLayoutHints
Definition: TGLayout.h:57
TGedFrame::MakeTitle
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
TTextEditor
Definition: TTextEditor.h:29
TTextEditor::DoXpos
void DoXpos()
Slot for setting the text X position.
Definition: TTextEditor.cxx:156
TNamed::SetTitle
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
TTextEditor::DoYpos
void DoYpos()
Slot for setting the text Y position.
Definition: TTextEditor.cxx:167
unsigned int
kHorizontalFrame
@ kHorizontalFrame
Definition: GuiTypes.h:382
TGedFrame
Definition: TGedFrame.h:34
TGLabel.h
TText
Base class for several text objects.
Definition: TText.h:22
f1
TF1 * f1
Definition: legend1.C:11
TQObject::Connect
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:866
TTextEditor::TTextEditor
TTextEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
TTextEditor constructor.
Definition: TTextEditor.cxx:26
kText_Ypos
@ kText_Ypos
Definition: TTextEditor.cxx:19
TTextEditor::fAngle
TGNumberEntry * fAngle
Definition: TTextEditor.h:36
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TGTextEntry.h
TTextEditor::~TTextEditor
~TTextEditor()
TTextEditor destructor.
Definition: TTextEditor.cxx:82
TGNumberEntry.h
TGNumberEntry::GetNumber
virtual Double_t GetNumber() const
Definition: TGNumberEntry.h:206
TGCompositeFrame::TGCompositeFrame
TGCompositeFrame(const TGCompositeFrame &)=delete
TGNumberEntry
Definition: TGNumberEntry.h:157
TGedFrame::fInit
Bool_t fInit
Definition: TGedFrame.h:54
TGCompositeFrame
Definition: TGFrame.h:323
TAttText::SetTextAngle
virtual void SetTextAngle(Float_t tangle=0)
Set the text angle.
Definition: TAttText.h:42
TGCompositeFrame::AddFrame
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1102
TText.h
TText::SetY
virtual void SetY(Double_t y)
Definition: TText.h:77
TTextEditor::DoSize
void DoSize()
Slot for setting the text Size.
Definition: TTextEditor.cxx:134
TTextEditor::fYpos
TGNumberEntry * fYpos
Definition: TTextEditor.h:39
TGNumberFormat::kNESInteger
@ kNESInteger
Definition: TGNumberEntry.h:34
int