30 ClassImp(TEveGedEditor);
32 Int_t TEveGedEditor::fgMaxExtraEditors = 10;
33 TList *TEveGedEditor::fgExtraEditors =
new TList;
35 TContextMenu *TEveGedEditor::fgContextMenu = 0;
40 TEveGedEditor::TEveGedEditor(TCanvas* canvas, UInt_t width, UInt_t height) :
41 TGedEditor(canvas, width, height),
47 fTabContainer->RemoveAll();
48 TGedFrame* nf = CreateNameFrame(fTabContainer,
"Style");
49 nf->SetGedEditor(
this);
51 fTabContainer->AddFrame(nf,
new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 2, 2));
54 TClass* amClass = TClass::GetClass(
"TAttMarker");
55 TClass* edClass = TClass::GetClass(
"TAttMarkerEditor");
56 TGWindow *exroot = (TGWindow*) fClient->GetRoot();
57 fClient->SetRoot(fTabContainer);
58 SetFrameCreator(
this);
59 TGedFrame *frame =
reinterpret_cast<TGedFrame*
>(edClass->New());
60 frame->SetModelClass(amClass);
62 Int_t off = edClass->GetDataMemberOffset(
"fPriority");
64 Warning(
"TEveGedEditor::TEveGedEditor",
"Can't fix priority for TAttMarkerEditor.\n");
66 * (Int_t*) (((
char*)frame) + off) = 1;
69 fClient->SetRoot(exroot);
70 fFrameMap.Add(amClass, frame);
76 TEveGedEditor::~TEveGedEditor()
79 Info(
"TEveGedEditor::~TEveGedEditor",
"%p going down.",
this);
86 void TEveGedEditor::CloseWindow()
89 Info(
"TEveGedEditor::CloseWindow",
"%p closing.",
this);
91 fgExtraEditors->Remove(
this);
96 if (gDNDManager->GetMainFrame() ==
this)
97 gDNDManager->SetMainFrame(0);
105 TGedFrame* TEveGedEditor::CreateNameFrame(
const TGWindow* parent,
const char* )
107 return new TEveGedNameFrame(parent);
113 TEveElement* TEveGedEditor::GetEveElement()
const
115 return (fModel == fObject) ? fElement : 0;
121 void TEveGedEditor::DisplayElement(TEveElement* re)
123 static const TEveException eh(
"TEveGedEditor::DisplayElement ");
126 fObject = fElement ? fElement->GetEditorObject(eh) : 0;
127 TGedEditor::SetModel(fPad, fObject, kButton1Down, kTRUE);
133 void TEveGedEditor::DisplayObject(TObject* obj)
135 fElement =
dynamic_cast<TEveElement*
>(obj);
137 TGedEditor::SetModel(fPad, obj, kButton1Down, kTRUE);
143 void TEveGedEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t event, Bool_t force)
145 fElement =
dynamic_cast<TEveElement*
>(obj);
147 TGedEditor::SetModel(pad, obj, event, force);
154 void TEveGedEditor::Update(TGedFrame* )
158 fElement->ElementChanged();
159 fElement->PropagateVizParamsToProjecteds();
168 void TEveGedEditor::SpawnNewEditor(TObject* obj)
170 if (fgExtraEditors->GetSize() >= fgMaxExtraEditors)
172 new TGMsgBox(gClient->GetDefaultRoot(), gEve->GetMainWindow(),
174 "Maximum number of extra editors reached.",
180 TEveGedEditor *ed =
new TEveGedEditor();
181 ed->DisplayObject(obj);
182 ed->SetWindowName(Form(
"GED %s", obj->GetName()));
184 fgExtraEditors->Add(ed);
191 void TEveGedEditor::ElementChanged(TEveElement* el)
193 TObject *eobj = el->GetEditorObject(
"TEveGedEditor::ElementChanged ");
194 TObjLink *lnk = fgExtraEditors->FirstLink();
197 TEveGedEditor *ed = (TEveGedEditor*) lnk->GetObject();
198 if (ed->GetModel() == eobj)
199 ed->DisplayElement(el);
207 void TEveGedEditor::ElementDeleted(TEveElement* el)
209 TObject *eobj = el->GetEditorObject(
"TEveGedEditor::ElementChanged ");
210 TObjLink *lnk = fgExtraEditors->FirstLink();
213 TEveGedEditor *ed = (TEveGedEditor*) lnk->GetObject();
214 if (ed->GetModel() == eobj)
216 TObjLink *next = lnk->Next();
218 fgExtraEditors->Remove(lnk);
231 void TEveGedEditor::DestroyEditors()
233 while ( ! fgExtraEditors->IsEmpty())
235 TEveGedEditor *ed = (TEveGedEditor*) fgExtraEditors->First();
237 fgExtraEditors->RemoveFirst();
244 TContextMenu* TEveGedEditor::GetContextMenu()
246 if (fgContextMenu == 0)
247 fgContextMenu =
new TContextMenu(
"",
"");
248 return fgContextMenu;
258 ClassImp(TEveGedNameFrame);
263 TEveGedNameFrame::TEveGedNameFrame(
const TGWindow *p, Int_t width, Int_t height,
265 TGedFrame(p, width, height, options),
268 fNCButton =
new TEveGedNameTextButton(
this);
269 fNCButton->SetTextColor(0x0020a0);
270 AddFrame(fNCButton,
new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
271 fNCButton->Connect(
"Clicked()",
"TEveGedNameFrame",
this,
"SpawnEditorClone()");
277 TEveGedNameFrame::~TEveGedNameFrame()
284 void TEveGedNameFrame::SetModel(TObject* obj)
288 fNCButton->SetText(Form(
"%s [%s]", obj->GetName(), obj->ClassName()));
289 fNCButton->SetToolTipText(obj->GetTitle());
290 fNCButton->SetEnabled(kTRUE);
294 fNCButton->SetText(
"No object selected.");
295 fNCButton->SetToolTipText(0);
296 fNCButton->SetEnabled(kFALSE);
303 void TEveGedNameFrame::SpawnEditorClone()
305 TEveGedEditor::SpawnNewEditor(fGedEditor->GetModel());
314 ClassImp(TEveGedNameTextButton);
319 TEveGedNameTextButton::TEveGedNameTextButton(TEveGedNameFrame* p) :
323 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
324 kButtonPressMask | kButtonReleaseMask,
331 TEveGedNameTextButton::~TEveGedNameTextButton()
338 Bool_t TEveGedNameTextButton::HandleButton(Event_t* event)
340 static const TEveException eh(
"TEveGedNameTextButton::HandleButton ");
342 if (fTip) fTip->Hide();
343 if (fState == kButtonDisabled)
return kTRUE;
345 if (event->fCode == kButton3 && event->fType == kButtonPress)
347 TEveGedEditor *eged = (TEveGedEditor*) fFrame->GetGedEditor();
348 TEveElement *el = eged->GetEveElement();
350 TEveGedEditor::GetContextMenu()->Popup(event->fXRoot, event->fYRoot,
354 else if (event->fCode == kButton1)
356 return TGTextButton::HandleButton(event);