00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "TEveTextEditor.h"
00013 #include "TEveText.h"
00014 #include "TEveGValuators.h"
00015
00016 #include "TGLFontManager.h"
00017
00018 #include "TColor.h"
00019 #include "TGLabel.h"
00020 #include "TGColorSelect.h"
00021 #include "TGComboBox.h"
00022 #include "TGTextBuffer.h"
00023 #include "TGTextEntry.h"
00024 #include "TObjArray.h"
00025 #include "TObjString.h"
00026 #include "TG3DLine.h"
00027
00028
00029
00030
00031
00032
00033 ClassImp(TEveTextEditor);
00034
00035
00036 TEveTextEditor::TEveTextEditor(const TGWindow *p, Int_t width, Int_t height,
00037 UInt_t options, Pixel_t back) :
00038 TGedFrame(p, width, height, options | kVerticalFrame, back),
00039 fM(0),
00040
00041 fSize(0),
00042 fFile(0),
00043 fMode(0),
00044 fExtrude(0),
00045
00046 fLighting(0),
00047 fAutoLighting(0)
00048 {
00049
00050
00051 MakeTitle("TEveText");
00052
00053
00054 fText = new TGTextEntry(this);
00055 fText->Resize(135, fText->GetDefaultHeight());
00056 AddFrame(fText, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
00057 fText->Connect("TextChanged(const char *)", "TEveTextEditor", this, "DoText(const char *)");
00058
00059
00060 fSize = MakeLabeledCombo("Size:");
00061 Int_t* fsp = &TGLFontManager::GetFontSizeArray()->front();
00062 Int_t nums = TGLFontManager::GetFontSizeArray()->size();
00063 for(Int_t i= 0; i< nums; i++)
00064 {
00065 fSize->AddEntry(Form("%-2d", fsp[i]), fsp[i]);
00066 }
00067 fSize->Connect("Selected(Int_t)", "TEveTextEditor", this, "DoFontSize()");
00068
00069
00070 fFile = MakeLabeledCombo("File:");
00071 TObjArray* farr = TGLFontManager::GetFontFileArray();
00072 TIter next(farr);
00073 TObjString* os;
00074 Int_t cnt = 0;
00075 while ((os = (TObjString*) next()) != 0)
00076 {
00077 fFile->AddEntry(Form("%s", os->GetString().Data()), cnt);
00078 cnt++;
00079 }
00080 fFile->Connect("Selected(Int_t)", "TEveTextEditor", this, "DoFontFile()");
00081
00082
00083 fMode = MakeLabeledCombo("Mode:");
00084 fMode->AddEntry("Bitmap", TGLFont::kBitmap);
00085 fMode->AddEntry("Pixmap", TGLFont::kPixmap);
00086 fMode->AddEntry("Texture", TGLFont::kTexture);
00087 fMode->AddEntry("Outline", TGLFont::kOutline);
00088 fMode->AddEntry("Polygon", TGLFont::kPolygon);
00089 fMode->AddEntry("Extrude", TGLFont::kExtrude);
00090 fMode->Connect("Selected(Int_t)", "TEveTextEditor", this, "DoFontMode()");
00091
00092 fExtrude = new TEveGValuator(this, "Depth:", 90, 0);
00093 fExtrude->SetLabelWidth(45);
00094 fExtrude->SetNELength(5);
00095
00096 fExtrude->Build();
00097 fExtrude->SetLimits(0.01, 10, 100, TGNumberFormat::kNESRealTwo);
00098 fExtrude->SetToolTip("Extrusion depth.");
00099 fExtrude->Connect("ValueSet(Double_t)", "TEveTextEditor", this, "DoExtrude()");
00100 AddFrame(fExtrude, new TGLayoutHints(kLHintsTop, 4, 1, 1, 1));
00101
00102
00103 TGCompositeFrame *f1 = new TGCompositeFrame(this, 145, 10, kHorizontalFrame | kFitWidth | kFixedWidth );
00104 f1->AddFrame(new TGLabel(f1, "GLConfig"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00105 f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
00106 AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 8, 0));
00107
00108 TGCompositeFrame *alf = new TGCompositeFrame(this, 145, 10, kHorizontalFrame );
00109 fAutoLighting = new TGCheckButton(alf, "AutoLighting");
00110 alf->AddFrame(fAutoLighting, new TGLayoutHints(kLHintsLeft, 1,2,0,0));
00111 fAutoLighting->Connect("Toggled(Bool_t)", "TEveTextEditor", this, "DoAutoLighting()");
00112 fLighting = new TGCheckButton(alf, "Lighting");
00113 alf->AddFrame(fLighting, new TGLayoutHints(kLHintsLeft, 1,2,0,0));
00114 fLighting->Connect("Toggled(Bool_t)", "TEveTextEditor", this, "DoLighting()");
00115 AddFrame(alf, new TGLayoutHints(kLHintsTop, 0, 0, 0, 0));
00116 }
00117
00118
00119 TGComboBox* TEveTextEditor::MakeLabeledCombo(const char* name)
00120 {
00121
00122
00123 UInt_t labelW = 45;
00124 UInt_t labelH = 20;
00125 TGHorizontalFrame* hf = new TGHorizontalFrame(this);
00126
00127 TGCompositeFrame *labfr = new TGHorizontalFrame(hf, labelW, labelH, kFixedSize);
00128 TGLabel* label = new TGLabel(labfr, name);
00129 labfr->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsBottom));
00130 hf->AddFrame(labfr, new TGLayoutHints(kLHintsLeft));
00131
00132 TGLayoutHints* clh = new TGLayoutHints(kLHintsLeft, 0,0,0,0);
00133 TGComboBox* combo = new TGComboBox(hf);
00134 combo->Resize(90, 20);
00135 hf->AddFrame(combo, clh);
00136
00137 AddFrame(hf, new TGLayoutHints(kLHintsTop, 4, 1, 1, 1));
00138 return combo;
00139 }
00140
00141
00142 void TEveTextEditor::SetModel(TObject* obj)
00143 {
00144
00145
00146 fM = dynamic_cast<TEveText*>(obj);
00147 if (strcmp(fM->GetText(), fText->GetText()))
00148 fText->SetText(fM->GetText());
00149
00150 fSize->Select(fM->GetFontSize(), kFALSE);
00151 fFile->Select(fM->GetFontFile(), kFALSE);
00152
00153
00154 fMode->Select(fM->GetFontMode(), kFALSE);
00155
00156
00157 fAutoLighting->SetState(fM->GetAutoLighting() ? kButtonDown : kButtonUp);
00158 if (fM->GetAutoLighting()) {
00159 fLighting->SetDisabledAndSelected(fM->GetLighting() ? kButtonDown : kButtonUp);
00160 } else {
00161 fLighting->SetEnabled();
00162 fLighting->SetState(fM->GetLighting() ? kButtonDown : kButtonUp);
00163 }
00164
00165
00166 if (fM->GetFontMode() == TGLFont::kExtrude)
00167 {
00168 ShowFrame(fExtrude);
00169 fExtrude->SetValue(fM->GetExtrude());
00170 }
00171 else
00172 {
00173 HideFrame(fExtrude);
00174 }
00175 }
00176
00177
00178 void TEveTextEditor::DoText(const char* )
00179 {
00180
00181
00182 fM->SetText(fText->GetText());
00183 Update();
00184 }
00185
00186
00187 void TEveTextEditor::DoFontSize()
00188 {
00189
00190
00191 fM->SetFontSize(fSize->GetSelected(), kFALSE);
00192 Update();
00193 }
00194
00195
00196 void TEveTextEditor::DoFontFile()
00197 {
00198
00199
00200 fM->SetFontFile(fFile->GetSelected());
00201 Update();
00202 }
00203
00204 void TEveTextEditor::DoFontMode()
00205 {
00206
00207
00208 fM->SetFontMode(fMode->GetSelected());
00209 Update();
00210 }
00211
00212
00213 void TEveTextEditor::DoExtrude()
00214 {
00215
00216
00217 fM->SetExtrude(fExtrude->GetValue());
00218 Update();
00219 }
00220
00221
00222 void TEveTextEditor::DoAutoLighting()
00223 {
00224
00225
00226 fM->SetAutoLighting(fAutoLighting->IsOn());
00227 Update();
00228 }
00229
00230
00231 void TEveTextEditor::DoLighting()
00232 {
00233
00234
00235 fM->SetLighting(fLighting->IsOn());
00236 Update();
00237 }