Logo ROOT   6.12/07
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
31 GUI 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();
63  Int_t nums = TGLFontManager::GetFontSizeArray()->size();
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:");
85  fMode->AddEntry("Bitmap", TGLFont::kBitmap);
86  fMode->AddEntry("Pixmap", TGLFont::kPixmap);
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
167  if (fM->GetFontMode() == TGLFont::kExtrude)
168  {
171  }
172  else
173  {
175  }
176 }
177 
178 ////////////////////////////////////////////////////////////////////////////////
179 /// Slot for setting text.
180 
181 void 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 }
Int_t GetFontFile() const
Definition: TEveText.h:50
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition: TGFrame.cxx:1172
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
TEveText * fM
An array of TObjects.
Definition: TObjArray.h:37
void SetAutoLighting(Bool_t isOn)
Definition: TEveText.h:64
void DoExtrude()
Slot for setting an extrude depth.
Collectable string class.
Definition: TObjString.h:28
virtual void SetValue(Float_t v, Bool_t emit=kFALSE)
Set value, optionally emit signal.
Float_t GetExtrude() const
Definition: TEveText.h:66
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition: TGFrame.cxx:1186
int Int_t
Definition: RtypesCore.h:41
void DoText(const char *)
Slot for setting text.
void SetToolTip(const char *tip)
Set the tooltip of the number-entry.
TGComboBox * MakeLabeledCombo(const char *name)
Helper function. Creates TGComboBox with fixed size TGLabel.
virtual void SetModel(TObject *obj)
Set model object.
void DoLighting()
Slot for enabling/disabling GL lighting.
Composite GUI element for single value selection (supports label, number-entry and slider)...
void SetText(const char *t)
Definition: TEveText.h:58
ULong_t Pixel_t
Definition: GuiTypes.h:39
void DoAutoLighting()
Slot for enabling/disabling defaults.
const char * GetText() const
Definition: TEveText.h:57
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition: TGedFrame.cxx:73
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:443
TGCompositeFrame(const TGCompositeFrame &)
void DoFontMode()
Slot for setting FTGL attributes.
TEveGValuator * fExtrude
virtual Bool_t IsOn() const
Definition: TGButton.h:311
GUI editor for TEveText.
virtual void SetDisabledAndSelected(Bool_t)
Set the state of a check button to disabled and either on or off.
Definition: TGButton.cxx:1260
Int_t GetFontMode() const
Definition: TEveText.h:51
TGCheckButton * fLighting
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:867
const TString & GetString() const
Definition: TObjString.h:47
TEveTextEditor(const TEveTextEditor &)
void SetNELength(Int_t l)
unsigned int UInt_t
Definition: RtypesCore.h:42
char * Form(const char *fmt,...)
const Bool_t kFALSE
Definition: RtypesCore.h:88
const char * GetText() const
Definition: TGTextEntry.h:134
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:238
Bool_t GetLighting() const
Definition: TEveText.h:60
virtual void Build(Bool_t connect=kTRUE)
Create sub-components (label, number entry, slider).
#define ClassImp(name)
Definition: Rtypes.h:359
virtual void AddEntry(TGString *s, Int_t id)
Definition: TGComboBox.h:106
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGButton.cxx:409
void SetExtrude(Float_t x)
Definition: TEveText.h:67
void SetFontSize(Int_t size, Bool_t validate=kTRUE)
Set valid font size.
Definition: TEveText.cxx:60
TGComboBox * fMode
TEveElement class used for displaying FreeType GL fonts.
Definition: TEveText.h:21
void SetFontMode(Int_t mode)
Set FTFont class ID.
Definition: TEveText.cxx:93
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
Mother of all ROOT objects.
Definition: TObject.h:37
void SetFontFile(Int_t file)
Definition: TEveText.h:53
TGComboBox * fSize
virtual Int_t GetSelected() const
Definition: TGComboBox.h:134
void DoFontFile()
Slot for setting FTGL attributes.
void SetLabelWidth(Int_t w)
TF1 * f1
Definition: legend1.C:11
void DoFontSize()
Slot for setting FTGL attributes.
static FontSizeVec_t * GetFontSizeArray()
Get valid font size vector.
static TObjArray * GetFontFileArray()
Get id to file name map.
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set check button state.
Definition: TGButton.cxx:1200
void SetLimits(Int_t min, Int_t max)
Set limits of the represented value for integer values.
void SetLighting(Bool_t isOn)
Definition: TEveText.h:61
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...
TGComboBox * fFile
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
TGCheckButton * fAutoLighting
char name[80]
Definition: TGX11.cxx:109
Float_t GetValue() const
TGTextEntry * fText
const char * cnt
Definition: TXMLSetup.cxx:74
Bool_t GetAutoLighting() const
Definition: TEveText.h:63
Int_t GetFontSize() const
Definition: TEveText.h:49
const char * Data() const
Definition: TString.h:345