Logo ROOT  
Reference Guide
TEveTextEditor.cxx
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Authors: Alja & Matevz Tadel 2008
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, 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 "TEveTextEditor.h"
13#include "TEveText.h"
14#include "TEveGValuators.h"
15
16#include "TGLFontManager.h"
17
18#include "TColor.h"
19#include "TGLabel.h"
20#include "TGColorSelect.h"
21#include "TGComboBox.h"
22#include "TGTextBuffer.h"
23#include "TGTextEntry.h"
24#include "TObjArray.h"
25#include "TObjString.h"
26#include "TG3DLine.h"
27
28
29/** \class TEveTextEditor
30\ingroup TEve
31GUI editor for TEveText.
32*/
33
35
36////////////////////////////////////////////////////////////////////////////////
37/// Constructor.
38
40 UInt_t options, Pixel_t back) :
41 TGedFrame(p, width, height, options | kVerticalFrame, back),
42 fM(0),
43
44 fSize(0),
45 fFile(0),
46 fMode(0),
47 fExtrude(0),
48
49 fLighting(0),
50 fAutoLighting(0)
51{
52 MakeTitle("TEveText");
53
54 // Text entry
55 fText = new TGTextEntry(this);
57 AddFrame(fText, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
58 fText->Connect("TextChanged(const char *)", "TEveTextEditor", this, "DoText(const char *)");
59
60 // Face Size combo
61 fSize = MakeLabeledCombo("Size:");
62 Int_t* fsp = &TGLFontManager::GetFontSizeArray()->front();
64 for(Int_t i= 0; i< nums; i++)
65 {
66 fSize->AddEntry(Form("%-2d", fsp[i]), fsp[i]);
67 }
68 fSize->Connect("Selected(Int_t)", "TEveTextEditor", this, "DoFontSize()");
69
70 // Font File combo
71 fFile = MakeLabeledCombo("File:");
73 TIter next(farr);
74 TObjString* os;
75 Int_t cnt = 0;
76 while ((os = (TObjString*) next()) != 0)
77 {
78 fFile->AddEntry(Form("%s", os->GetString().Data()), cnt);
79 cnt++;
80 }
81 fFile->Connect("Selected(Int_t)", "TEveTextEditor", this, "DoFontFile()");
82
83 // Mode combo
84 fMode = MakeLabeledCombo("Mode:");
87 fMode->AddEntry("Texture", TGLFont::kTexture);
88 fMode->AddEntry("Outline", TGLFont::kOutline);
89 fMode->AddEntry("Polygon", TGLFont::kPolygon);
90 fMode->AddEntry("Extrude", TGLFont::kExtrude);
91 fMode->Connect("Selected(Int_t)", "TEveTextEditor", this, "DoFontMode()");
92
93 fExtrude = new TEveGValuator(this, "Depth:", 90, 0);
96 // fExtrude->SetShowSlider(kFALSE);
97 fExtrude->Build();
99 fExtrude->SetToolTip("Extrusion depth.");
100 fExtrude->Connect("ValueSet(Double_t)", "TEveTextEditor", this, "DoExtrude()");
101 AddFrame(fExtrude, new TGLayoutHints(kLHintsTop, 4, 1, 1, 1));
102
103 // GLConfig
105 f1->AddFrame(new TGLabel(f1, "GLConfig"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
106 f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
107 AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 8, 0));
108
109 TGCompositeFrame *alf = new TGCompositeFrame(this, 145, 10, kHorizontalFrame );
110 fAutoLighting = new TGCheckButton(alf, "AutoLighting");
111 alf->AddFrame(fAutoLighting, new TGLayoutHints(kLHintsLeft, 1,2,0,0));
112 fAutoLighting->Connect("Toggled(Bool_t)", "TEveTextEditor", this, "DoAutoLighting()");
113 fLighting = new TGCheckButton(alf, "Lighting");
114 alf->AddFrame(fLighting, new TGLayoutHints(kLHintsLeft, 1,2,0,0));
115 fLighting->Connect("Toggled(Bool_t)", "TEveTextEditor", this, "DoLighting()");
116 AddFrame(alf, new TGLayoutHints(kLHintsTop, 0, 0, 0, 0));
117}
118
119////////////////////////////////////////////////////////////////////////////////
120/// Helper function. Creates TGComboBox with fixed size TGLabel.
121
123{
124 UInt_t labelW = 45;
125 UInt_t labelH = 20;
126 TGHorizontalFrame* hf = new TGHorizontalFrame(this);
127 // label
128 TGCompositeFrame *labfr = new TGHorizontalFrame(hf, labelW, labelH, kFixedSize);
129 TGLabel* label = new TGLabel(labfr, name);
130 labfr->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsBottom));
131 hf->AddFrame(labfr, new TGLayoutHints(kLHintsLeft));
132 // combo
133 TGLayoutHints* clh = new TGLayoutHints(kLHintsLeft, 0,0,0,0);
134 TGComboBox* combo = new TGComboBox(hf);
135 combo->Resize(90, 20);
136 hf->AddFrame(combo, clh);
137
138 AddFrame(hf, new TGLayoutHints(kLHintsTop, 4, 1, 1, 1));
139 return combo;
140}
141
142////////////////////////////////////////////////////////////////////////////////
143/// Set model object.
144
146{
147 fM = dynamic_cast<TEveText*>(obj);
148 if (strcmp(fM->GetText(), fText->GetText()))
149 fText->SetText(fM->GetText());
150
153
154 // mode
156
157 // lightning
159 if (fM->GetAutoLighting()) {
161 } else {
164 }
165
166 // extrude
168 {
171 }
172 else
173 {
175 }
176}
177
178////////////////////////////////////////////////////////////////////////////////
179/// Slot for setting text.
180
181void TEveTextEditor::DoText(const char* /*txt*/)
182{
183 fM->SetText(fText->GetText());
184 Update();
185}
186
187////////////////////////////////////////////////////////////////////////////////
188/// Slot for setting FTGL attributes.
189
191{
193 Update();
194}
195
196////////////////////////////////////////////////////////////////////////////////
197/// Slot for setting FTGL attributes.
198
200{
202 Update();
203}
204////////////////////////////////////////////////////////////////////////////////
205/// Slot for setting FTGL attributes.
206
208{
210 Update();
211}
212
213////////////////////////////////////////////////////////////////////////////////
214/// Slot for setting an extrude depth.
215
217{
219 Update();
220}
221
222////////////////////////////////////////////////////////////////////////////////
223/// Slot for enabling/disabling defaults.
224
226{
228 Update();
229}
230
231////////////////////////////////////////////////////////////////////////////////
232/// Slot for enabling/disabling GL lighting.
233
235{
237 Update();
238}
size_t fSize
@ kVerticalFrame
Definition: GuiTypes.h:381
@ kFixedWidth
Definition: GuiTypes.h:387
@ kFitWidth
Definition: GuiTypes.h:386
@ kHorizontalFrame
Definition: GuiTypes.h:382
@ kFixedSize
Definition: GuiTypes.h:390
ULong_t Pixel_t
Definition: GuiTypes.h:39
const Bool_t kFALSE
Definition: RtypesCore.h:90
#define ClassImp(name)
Definition: Rtypes.h:361
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
@ kButtonDown
Definition: TGButton.h:54
@ kButtonUp
Definition: TGButton.h:53
@ kLHintsLeft
Definition: TGLayout.h:31
@ kLHintsBottom
Definition: TGLayout.h:36
@ kLHintsTop
Definition: TGLayout.h:34
@ kLHintsExpandX
Definition: TGLayout.h:37
char name[80]
Definition: TGX11.cxx:109
char * Form(const char *fmt,...)
void SetLabelWidth(Int_t w)
void SetNELength(Int_t l)
Composite GUI element for single value selection (supports label, number-entry and slider).
void SetToolTip(const char *tip)
Set the tooltip of the number-entry.
void SetLimits(Int_t min, Int_t max)
Set limits of the represented value for integer values.
virtual void Build(Bool_t connect=kTRUE)
Create sub-components (label, number entry, slider).
Float_t GetValue() const
virtual void SetValue(Float_t v, Bool_t emit=kFALSE)
Set value, optionally emit signal.
GUI editor for TEveText.
void DoFontMode()
Slot for setting FTGL attributes.
virtual void SetModel(TObject *obj)
Set model object.
TGCheckButton * fLighting
TGComboBox * fSize
void DoText(const char *)
Slot for setting text.
void DoFontFile()
Slot for setting FTGL attributes.
TEveText * fM
TGCheckButton * fAutoLighting
void DoLighting()
Slot for enabling/disabling GL lighting.
TGComboBox * fFile
TEveGValuator * fExtrude
TGTextEntry * fText
void DoAutoLighting()
Slot for enabling/disabling defaults.
void DoFontSize()
Slot for setting FTGL attributes.
void DoExtrude()
Slot for setting an extrude depth.
TEveTextEditor(const TEveTextEditor &)
TGComboBox * MakeLabeledCombo(const char *name)
Helper function. Creates TGComboBox with fixed size TGLabel.
TGComboBox * fMode
TEveElement class used for displaying FreeType GL fonts.
Definition: TEveText.h:25
Float_t GetExtrude() const
Definition: TEveText.h:66
const char * GetText() const
Definition: TEveText.h:57
void SetAutoLighting(Bool_t isOn)
Definition: TEveText.h:64
void SetFontFile(Int_t file)
Definition: TEveText.h:53
Bool_t GetAutoLighting() const
Definition: TEveText.h:63
void SetFontMode(Int_t mode)
Set FTFont class ID.
Definition: TEveText.cxx:93
void SetFontSize(Int_t size, Bool_t validate=kTRUE)
Set valid font size.
Definition: TEveText.cxx:60
Bool_t GetLighting() const
Definition: TEveText.h:60
void SetLighting(Bool_t isOn)
Definition: TEveText.h:61
Int_t GetFontSize() const
Definition: TEveText.h:49
Int_t GetFontFile() const
Definition: TEveText.h:50
void SetText(const char *t)
Definition: TEveText.h:58
void SetExtrude(Float_t x)
Definition: TEveText.h:67
Int_t GetFontMode() const
Definition: TEveText.h:51
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGButton.cxx:411
virtual Bool_t IsOn() const
Definition: TGButton.h:311
virtual void SetDisabledAndSelected(Bool_t)
Set the state of a check button to disabled and either on or off.
Definition: TGButton.cxx:1262
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set check button state.
Definition: TGButton.cxx:1202
virtual Int_t GetSelected() const
Definition: TGComboBox.h:134
virtual void AddEntry(TGString *s, Int_t id)
Definition: TGComboBox.h:106
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:451
TGCompositeFrame(const TGCompositeFrame &)
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1101
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition: TGFrame.cxx:1188
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition: TGFrame.cxx:1174
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:216
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:589
static FontSizeVec_t * GetFontSizeArray()
Get valid font size vector.
static TObjArray * GetFontFileArray()
Get id to file name map.
const char * GetText() const
Definition: TGTextEntry.h:134
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.
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition: TGedFrame.cxx:73
An array of TObjects.
Definition: TObjArray.h:37
Collectable string class.
Definition: TObjString.h:28
const TString & GetString() const
Definition: TObjString.h:46
Mother of all ROOT objects.
Definition: TObject.h:37
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
const char * Data() const
Definition: TString.h:364
TF1 * f1
Definition: legend1.C:11
const char * cnt
Definition: TXMLSetup.cxx:74