Logo ROOT  
Reference Guide
TTextEditor.cxx
Go to the documentation of this file.
1 #include "TTextEditor.h"
2 #include "TText.h"
3 #include "TGTextEntry.h"
4 #include "TGNumberEntry.h"
5 #include "TGLabel.h"
6 
8 
9 
10 enum ELatexID{
12 };
13 
14 
15 ////////////////////////////////////////////////////////////////////////////////
16 /// TTextEditor constructor.
17 
19  Int_t width, Int_t height,
20  UInt_t options, Pixel_t back)
21  : TGedFrame(p, width, height, options | kVerticalFrame, back)
22 {
23  fText = 0;
24 
25  // start initializing the window components
26  MakeTitle("Text String");
27 
28  fText = new TGTextEntry(this, new TGTextBuffer(50), kText_Text);
30  fText->SetToolTipText("Enter the text string");
31  AddFrame(fText, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
32 
34  TGLabel *lbl1 = new TGLabel(f1,"X Position");
37  fXpos->Resize(50, 20);
38  f1->AddFrame(lbl1, new TGLayoutHints(kLHintsLeft,1, 1, 1, 1));
39  f1->AddFrame(fXpos, new TGLayoutHints(kLHintsLeft, 7, 1, 1, 1));
40  AddFrame(f1, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
41 
42  TGCompositeFrame *f2 = new TGCompositeFrame(this, 120, 20, kHorizontalFrame);
43  TGLabel *lbl2 = new TGLabel(f2,"Y Position");
46  fYpos->Resize(50, 20);
47  f2->AddFrame(lbl2, new TGLayoutHints(kLHintsLeft,1, 1, 1, 1));
48  f2->AddFrame(fYpos, new TGLayoutHints(kLHintsLeft, 7, 1, 1, 1));
49  AddFrame(f2, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
50 
51  TGCompositeFrame *f3 = new TGCompositeFrame(this, 120, 20, kHorizontalFrame);
52  TGLabel *lbl3 = new TGLabel(f3,"Text Angle");
55  fAngle->Resize(50, 20);
56  f3->AddFrame(lbl3, new TGLayoutHints(kLHintsLeft,1, 1, 1, 1));
57  f3->AddFrame(fAngle, new TGLayoutHints(kLHintsLeft, 7, 1, 1, 1));
58  AddFrame(f3, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
59 
60  TGCompositeFrame *f4 = new TGCompositeFrame(this, 120, 20, kHorizontalFrame);
61  TGLabel *lbl4 = new TGLabel(f4,"Text Size");
64  fSize->Resize(50, 20);
65  f4->AddFrame(lbl4, new TGLayoutHints(kLHintsLeft,1, 1, 1, 1));
66  f4->AddFrame(fSize, new TGLayoutHints(kLHintsLeft, 7, 1, 1, 1));
67  AddFrame(f4, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
68 }
69 
70 
71 ////////////////////////////////////////////////////////////////////////////////
72 /// TTextEditor destructor.
73 
75 {
76 }
77 
78 
79 ////////////////////////////////////////////////////////////////////////////////
80 /// Set model.
81 
83 {
84  fEditedText = (TText*) (obj);
85 
90  fAngle->SetNumber(fEditedText->GetTextAngle());
91  fSize->SetNumber(fEditedText->GetTextSize());
92 
95 }
96 
97 
98 ////////////////////////////////////////////////////////////////////////////////
99 /// Connect signals to slots.
100 
102 {
103  fText->Connect("TextChanged(const char *)","TTextEditor",this,"DoText(const char *)");
104  fXpos->Connect("ValueSet(Long_t)", "TTextEditor", this, "DoXpos()");
105  fYpos->Connect("ValueSet(Long_t)", "TTextEditor", this, "DoYpos()");
106  fAngle->Connect("ValueSet(Long_t)", "TTextEditor", this, "DoAngle()");
107  fSize->Connect("ValueSet(Long_t)", "TTextEditor", this, "DoSize()");
108 
109  fInit = kFALSE; // connect the slots to the signals only once
110 }
111 
112 ////////////////////////////////////////////////////////////////////////////////
113 /// Slot for setting the text Angle.
114 
116 {
117  if (fAvoidSignal) return;
118  fEditedText->SetTextAngle(fAngle->GetNumber());
119  Update();
120 }
121 
122 
123 ////////////////////////////////////////////////////////////////////////////////
124 /// Slot for setting the text Size.
125 
127 {
128  if (fAvoidSignal) return;
129  fEditedText->SetTextSize(fSize->GetNumber());
130  Update();
131 }
132 
133 
134 ////////////////////////////////////////////////////////////////////////////////
135 /// Slot for setting the text string.
136 
137 void TTextEditor::DoText(const char *text)
138 {
139  if (fAvoidSignal) return;
141  Update();
142 }
143 
144 
145 ////////////////////////////////////////////////////////////////////////////////
146 /// Slot for setting the text X position.
147 
149 {
150  if (fAvoidSignal) return;
152  Update();
153 }
154 
155 
156 ////////////////////////////////////////////////////////////////////////////////
157 /// Slot for setting the text Y position.
158 
160 {
161  if (fAvoidSignal) return;
163  Update();
164 }
kText_Text
@ kText_Text
Definition: TTextEditor.cxx:11
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:36
TGCompositeFrame::TGCompositeFrame
TGCompositeFrame(const TGCompositeFrame &)
TTextEditor::fText
TGTextEntry * fText
Definition: TTextEditor.h:34
Pixel_t
ULong_t Pixel_t
Definition: GuiTypes.h:39
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TNamed::GetTitle
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:54
kVerticalFrame
@ kVerticalFrame
Definition: GuiTypes.h:381
TGNumberFormat::kNEAAnyNumber
@ kNEAAnyNumber
Definition: TGNumberEntry.h:56
TText::SetX
virtual void SetX(Double_t x)
Definition: TText.h:76
kLHintsLeft
@ kLHintsLeft
Definition: TGLayout.h:37
TTextEditor::fEditedText
TText * fEditedText
Definition: TTextEditor.h:31
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:216
kText_Size
@ kText_Size
Definition: TTextEditor.cxx:11
width
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
TGNumberFormat::kNEANonNegative
@ kNEANonNegative
Definition: TGNumberEntry.h:57
TTextEditor::ConnectSignals2Slots
void ConnectSignals2Slots()
Connect signals to slots.
Definition: TTextEditor.cxx:101
TTextEditor::DoText
void DoText(const char *)
Slot for setting the text string.
Definition: TTextEditor.cxx:137
TGNumberFormat::kNESRealTwo
@ kNESRealTwo
Definition: TGNumberEntry.h:48
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:10
TTextEditor::DoAngle
void DoAngle()
Slot for setting the text Angle.
Definition: TTextEditor.cxx:115
text
TText * text
Definition: entrylist_figure1.C:10
TTextEditor.h
TGTextBuffer
Definition: TGTextBuffer.h:30
kText_Angle
@ kText_Angle
Definition: TTextEditor.cxx:11
TGedFrame::fAvoidSignal
Bool_t fAvoidSignal
Definition: TGedFrame.h:56
kText_Xpos
@ kText_Xpos
Definition: TTextEditor.cxx:11
TText::GetX
Double_t GetX() const
Definition: TText.h:53
TTextEditor::fXpos
TGNumberEntry * fXpos
Definition: TTextEditor.h:37
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:82
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:28
TTextEditor::DoXpos
void DoXpos()
Slot for setting the text X position.
Definition: TTextEditor.cxx:148
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:159
unsigned int
kHorizontalFrame
@ kHorizontalFrame
Definition: GuiTypes.h:382
TGedFrame
Definition: TGedFrame.h:33
TGLabel.h
TText
Definition: TText.h:22
f1
TF1 * f1
Definition: legend1.C:11
TTextEditor::TTextEditor
TTextEditor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
TTextEditor constructor.
Definition: TTextEditor.cxx:18
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:864
kText_Ypos
@ kText_Ypos
Definition: TTextEditor.cxx:11
TTextEditor::fAngle
TGNumberEntry * fAngle
Definition: TTextEditor.h:35
TObject
Definition: TObject.h:37
TGTextEntry.h
TTextEditor::~TTextEditor
~TTextEditor()
TTextEditor destructor.
Definition: TTextEditor.cxx:74
TGNumberEntry.h
TGNumberEntry::GetNumber
virtual Double_t GetNumber() const
Definition: TGNumberEntry.h:206
TGNumberEntry
Definition: TGNumberEntry.h:156
TGedFrame::fInit
Bool_t fInit
Definition: TGedFrame.h:53
TGCompositeFrame
Definition: TGFrame.h:324
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:126
TTextEditor::fYpos
TGNumberEntry * fYpos
Definition: TTextEditor.h:38
TGNumberFormat::kNESInteger
@ kNESInteger
Definition: TGNumberEntry.h:46
int