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
16
17
18/** \class TTextEditor
19\ingroup ged
20
21Editor for changing TText's and TLatex's attributes.
22
23*/
24
25
28};
29
30
31////////////////////////////////////////////////////////////////////////////////
32/// TTextEditor constructor.
33
36 UInt_t options, Pixel_t back)
37 : TGedFrame(p, width, height, options | kVerticalFrame, back)
38{
39 fText = 0;
40
41 // start initializing the window components
42 MakeTitle("Text String");
43
44 fText = new TGTextEntry(this, new TGTextBuffer(50), kText_Text);
46 fText->SetToolTipText("Enter the text string");
47 AddFrame(fText, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
48
50 TGLabel *lbl1 = new TGLabel(f1,"X Position");
53 fXpos->Resize(50, 20);
54 f1->AddFrame(lbl1, new TGLayoutHints(kLHintsLeft,1, 1, 1, 1));
55 f1->AddFrame(fXpos, new TGLayoutHints(kLHintsLeft, 7, 1, 1, 1));
56 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
57
58 TGCompositeFrame *f2 = new TGCompositeFrame(this, 120, 20, kHorizontalFrame);
59 TGLabel *lbl2 = new TGLabel(f2,"Y Position");
62 fYpos->Resize(50, 20);
63 f2->AddFrame(lbl2, new TGLayoutHints(kLHintsLeft,1, 1, 1, 1));
64 f2->AddFrame(fYpos, new TGLayoutHints(kLHintsLeft, 7, 1, 1, 1));
65 AddFrame(f2, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
66
67 TGCompositeFrame *f3 = new TGCompositeFrame(this, 120, 20, kHorizontalFrame);
68 TGLabel *lbl3 = new TGLabel(f3,"Text Angle");
71 fAngle->Resize(50, 20);
72 f3->AddFrame(lbl3, new TGLayoutHints(kLHintsLeft,1, 1, 1, 1));
73 f3->AddFrame(fAngle, new TGLayoutHints(kLHintsLeft, 7, 1, 1, 1));
74 AddFrame(f3, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
75
76 TGCompositeFrame *f4 = new TGCompositeFrame(this, 120, 20, kHorizontalFrame);
77 TGLabel *lbl4 = new TGLabel(f4,"Text Size");
80 fSize->Resize(50, 20);
81 f4->AddFrame(lbl4, new TGLayoutHints(kLHintsLeft,1, 1, 1, 1));
82 f4->AddFrame(fSize, new TGLayoutHints(kLHintsLeft, 7, 1, 1, 1));
83 AddFrame(f4, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
84}
85
86
87////////////////////////////////////////////////////////////////////////////////
88/// TTextEditor destructor.
89
91{
92}
93
94
95////////////////////////////////////////////////////////////////////////////////
96/// Set model.
97
99{
100 fEditedText = (TText*) (obj);
101
108
111}
112
113
114////////////////////////////////////////////////////////////////////////////////
115/// Connect signals to slots.
116
118{
119 fText->Connect("TextChanged(const char *)","TTextEditor",this,"DoText(const char *)");
120 fXpos->Connect("ValueSet(Long_t)", "TTextEditor", this, "DoXpos()");
121 fYpos->Connect("ValueSet(Long_t)", "TTextEditor", this, "DoYpos()");
122 fAngle->Connect("ValueSet(Long_t)", "TTextEditor", this, "DoAngle()");
123 fSize->Connect("ValueSet(Long_t)", "TTextEditor", this, "DoSize()");
124
125 fInit = kFALSE; // connect the slots to the signals only once
126}
127
128////////////////////////////////////////////////////////////////////////////////
129/// Slot for setting the text Angle.
130
132{
133 if (fAvoidSignal) return;
135 Update();
136}
137
138
139////////////////////////////////////////////////////////////////////////////////
140/// Slot for setting the text Size.
141
143{
144 if (fAvoidSignal) return;
146 Update();
147}
148
149
150////////////////////////////////////////////////////////////////////////////////
151/// Slot for setting the text string.
152
153void TTextEditor::DoText(const char *text)
154{
155 if (fAvoidSignal) return;
157 Update();
158}
159
160
161////////////////////////////////////////////////////////////////////////////////
162/// Slot for setting the text X position.
163
165{
166 if (fAvoidSignal) return;
168 Update();
169}
170
171
172////////////////////////////////////////////////////////////////////////////////
173/// Slot for setting the text Y position.
174
176{
177 if (fAvoidSignal) return;
179 Update();
180}
@ 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:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
@ 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:36
virtual void SetTextAngle(Float_t tangle=0)
Set the text angle.
Definition TAttText.h:43
virtual Float_t GetTextAngle() const
Return the text angle.
Definition TAttText.h:33
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition TAttText.h:47
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:191
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:95
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition TGedFrame.cxx:72
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:164
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
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:869
Editor for changing TText's and TLatex's attributes.
Definition TTextEditor.h:21
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