Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
15
16
17/** \class TTextEditor
18\ingroup ged
19
20Editor for changing TText's and TLatex's attributes.
21
22*/
23
24
28
29
30////////////////////////////////////////////////////////////////////////////////
31/// TTextEditor constructor.
32
35 UInt_t options, Pixel_t back)
36 : TGedFrame(p, width, height, options | kVerticalFrame, back)
37{
38 fText = 0;
39
40 // start initializing the window components
41 MakeTitle("Text String");
42
43 fText = new TGTextEntry(this, new TGTextBuffer(50), kText_Text);
45 fText->SetToolTipText("Enter the text string");
46 AddFrame(fText, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
47
49 TGLabel *lbl1 = new TGLabel(f1,"X Position");
52 fXpos->Resize(50, 20);
53 f1->AddFrame(lbl1, new TGLayoutHints(kLHintsLeft,1, 1, 1, 1));
54 f1->AddFrame(fXpos, new TGLayoutHints(kLHintsLeft, 7, 1, 1, 1));
55 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
56
57 TGCompositeFrame *f2 = new TGCompositeFrame(this, 120, 20, kHorizontalFrame);
58 TGLabel *lbl2 = new TGLabel(f2,"Y Position");
61 fYpos->Resize(50, 20);
62 f2->AddFrame(lbl2, new TGLayoutHints(kLHintsLeft,1, 1, 1, 1));
63 f2->AddFrame(fYpos, new TGLayoutHints(kLHintsLeft, 7, 1, 1, 1));
64 AddFrame(f2, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
65
66 TGCompositeFrame *f3 = new TGCompositeFrame(this, 120, 20, kHorizontalFrame);
67 TGLabel *lbl3 = new TGLabel(f3,"Text Angle");
70 fAngle->Resize(50, 20);
71 f3->AddFrame(lbl3, new TGLayoutHints(kLHintsLeft,1, 1, 1, 1));
72 f3->AddFrame(fAngle, new TGLayoutHints(kLHintsLeft, 7, 1, 1, 1));
73 AddFrame(f3, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
74
75 TGCompositeFrame *f4 = new TGCompositeFrame(this, 120, 20, kHorizontalFrame);
76 TGLabel *lbl4 = new TGLabel(f4,"Text Size");
79 fSize->Resize(50, 20);
80 f4->AddFrame(lbl4, new TGLayoutHints(kLHintsLeft,1, 1, 1, 1));
81 f4->AddFrame(fSize, new TGLayoutHints(kLHintsLeft, 7, 1, 1, 1));
82 AddFrame(f4, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
83}
84
85
86////////////////////////////////////////////////////////////////////////////////
87/// TTextEditor destructor.
88
92
93
94////////////////////////////////////////////////////////////////////////////////
95/// Set model.
96
111
112
113////////////////////////////////////////////////////////////////////////////////
114/// Connect signals to slots.
115
117{
118 fText->Connect("TextChanged(const char *)","TTextEditor",this,"DoText(const char *)");
119 fXpos->Connect("ValueSet(Long_t)", "TTextEditor", this, "DoXpos()");
120 fYpos->Connect("ValueSet(Long_t)", "TTextEditor", this, "DoYpos()");
121 fAngle->Connect("ValueSet(Long_t)", "TTextEditor", this, "DoAngle()");
122 fSize->Connect("ValueSet(Long_t)", "TTextEditor", this, "DoSize()");
123
124 fInit = kFALSE; // connect the slots to the signals only once
125}
126
127////////////////////////////////////////////////////////////////////////////////
128/// Slot for setting the text Angle.
129
131{
132 if (fAvoidSignal) return;
134 Update();
135}
136
137
138////////////////////////////////////////////////////////////////////////////////
139/// Slot for setting the text Size.
140
142{
143 if (fAvoidSignal) return;
145 Update();
146}
147
148
149////////////////////////////////////////////////////////////////////////////////
150/// Slot for setting the text string.
151
152void TTextEditor::DoText(const char *text)
153{
154 if (fAvoidSignal) return;
156 Update();
157}
158
159
160////////////////////////////////////////////////////////////////////////////////
161/// Slot for setting the text X position.
162
164{
165 if (fAvoidSignal) return;
167 Update();
168}
169
170
171////////////////////////////////////////////////////////////////////////////////
172/// Slot for setting the text Y position.
173
175{
176 if (fAvoidSignal) return;
178 Update();
179}
@ kVerticalFrame
Definition GuiTypes.h:381
@ kHorizontalFrame
Definition GuiTypes.h:382
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
@ kLHintsLeft
Definition TGLayout.h:24
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Option_t Option_t TPoint TPoint const char text
ELatexID
@ kText_Xpos
@ kText_Angle
@ kText_Text
@ kText_Size
@ kText_Ypos
virtual Float_t GetTextSize() const
Return the text size.
Definition TAttText.h:38
virtual void SetTextAngle(Float_t tangle=0)
Set the text angle.
Definition TAttText.h:45
virtual Float_t GetTextAngle() const
Return the text angle.
Definition TAttText.h:35
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition TAttText.h:49
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
TGCompositeFrame(const TGCompositeFrame &)=delete
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:193
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.
virtual Double_t GetNumber() const
virtual void SetNumber(Double_t val, Bool_t emit=kTRUE)
@ kNEANonNegative
Non-negative number.
@ kNEAAnyNumber
Attributes of number entry field.
@ kNESInteger
Style of number entry field.
@ kNESRealTwo
Fixed fraction real, two digit.
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
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.
ROOT GUI Window base class.
Definition TGWindow.h:23
Base frame for implementing GUI - a service class.
Definition TGedFrame.h:27
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
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:173
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
Mother of all ROOT objects.
Definition TObject.h:41
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:865
void SetModel(TObject *) override
Set model.
void DoSize()
Slot for setting the text Size.
~TTextEditor() override
TTextEditor destructor.
void DoText(const char *)
Slot for setting the text string.
TGNumberEntry * fYpos
Text's Y position.
Definition TTextEditor.h:31
TGNumberEntry * fXpos
Text's X position.
Definition TTextEditor.h:30
TGNumberEntry * fAngle
Text's angle.
Definition TTextEditor.h:28
void DoAngle()
Slot for setting the text Angle.
void ConnectSignals2Slots()
Connect signals to slots.
void DoYpos()
Slot for setting the text Y position.
TTextEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
TTextEditor constructor.
TGNumberEntry * fSize
Text's angle.
Definition TTextEditor.h:29
void DoXpos()
Slot for setting the text X position.
TGTextEntry * fText
Text.
Definition TTextEditor.h:27
TText * fEditedText
Definition TTextEditor.h:24
Base class for several text objects.
Definition TText.h:22
Double_t GetX() const
Definition TText.h:53
virtual void SetY(Double_t y)
Definition TText.h:77
virtual void SetX(Double_t x)
Definition TText.h:76
Double_t GetY() const
Definition TText.h:61
TF1 * f1
Definition legend1.C:11