#include "TGedFrame.h"
#include "TGedEditor.h"
#include "TG3DLine.h"
#include "TClass.h"
#include "TCanvas.h"
#include "TGLabel.h"
#include "TGToolTip.h"
#include "TGCanvas.h"
#include "TGScrollBar.h"
#include "snprintf.h"
ClassImp(TGedFrame)
TGedFrame::TGedFrame(const TGWindow *p, Int_t width,
Int_t height, UInt_t options, Pixel_t back)
: TGCompositeFrame(p, width, height, options, back),
fInit(kTRUE),
fGedEditor(0),
fModelClass(0),
fLayoutHints(0),
fAvoidSignal(kFALSE),
fExtraTabs(0),
fPriority(50)
{
fName = "";
fGedEditor = TGedEditor::GetFrameCreator();
SetCleanup(kDeepCleanup);
}
TGedFrame::~TGedFrame()
{
if (fExtraTabs) {
TGedSubFrame* sf;
TIter next(fExtraTabs);
while ((sf = (TGedSubFrame*) next()) != 0) {
delete sf->fFrame;
fExtraTabs->Remove(sf);
delete sf;
}
delete fExtraTabs;
}
delete fLayoutHints;
}
void TGedFrame::Update()
{
fGedEditor->Update(this);
}
Option_t *TGedFrame::GetDrawOption() const
{
if (!fGedEditor->GetPad()) return "";
TListIter next(fGedEditor->GetPad()->GetListOfPrimitives());
TObject *obj;
while ((obj = next())) {
if (obj == fGedEditor->GetModel()) return next.GetOption();
}
return "";
}
TGLayoutHints* TGedFrame::GetLayoutHints()
{
if (fLayoutHints == 0){
fLayoutHints = new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 2, 2);
fLayoutHints->AddReference();
}
return fLayoutHints;
}
void TGedFrame::MakeTitle(const char *title)
{
TGCompositeFrame *f1 = new TGCompositeFrame(this, 145, 10, kHorizontalFrame |
kFitWidth |
kFixedWidth |
kOwnBackground);
f1->AddFrame(new TGLabel(f1, title),
new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
f1->AddFrame(new TGHorizontal3DLine(f1),
new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
}
void TGedFrame::AddExtraTab(TGedSubFrame* sf)
{
if (fExtraTabs == 0) fExtraTabs = new TList();
fExtraTabs->Add(sf);
sf->fFrame->SetCleanup(kDeepCleanup);
}
TGVerticalFrame* TGedFrame::CreateEditorTabSubFrame(const Text_t* name)
{
TGCompositeFrame* tabcont = fGedEditor->GetEditorTab(name);
TGVerticalFrame* newframe = new TGVerticalFrame(tabcont);
AddExtraTab(new TGedFrame::TGedSubFrame(TString(name), newframe));
return newframe;
}
void TGedFrame::Refresh(TObject* model)
{
SetModel(model);
}
void TGedFrame::SetDrawOption(Option_t *option)
{
if (!fGedEditor->GetPad() || !option) return;
TListIter next(fGedEditor->GetPad()->GetListOfPrimitives());
delete fGedEditor->GetPad()->FindObject("Tframe");
TObject *obj;
while ((obj = next())) {
if (obj == fGedEditor->GetModel()) {
next.SetOption(option);
fGedEditor->GetPad()->Modified();
fGedEditor->GetPad()->Update();
return;
}
}
}
void TGedFrame::ActivateBaseClassEditors(TClass* cl)
{
if (cl->GetListOfBases()->IsEmpty() == kFALSE) {
fGedEditor->ActivateEditors(cl->GetListOfBases(), kTRUE);
}
}
TGedNameFrame::TGedNameFrame(const TGWindow *p, Int_t width,
Int_t height, UInt_t options, Pixel_t back)
: TGedFrame(p, width, height, options | kVerticalFrame, back)
{
fPriority = 0;
f1 = new TGCompositeFrame(this, 145, 10, kHorizontalFrame |
kFixedWidth |
kOwnBackground);
f1->AddFrame(new TGLabel(f1,"Name"),
new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
f1->AddFrame(new TGHorizontal3DLine(f1),
new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
AddFrame(f1, new TGLayoutHints(kLHintsTop));
f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame | kFixedWidth);
fLabel = new TGLabel(f2, "");
f2->AddFrame(fLabel, new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
Pixel_t color;
gClient->GetColorByName("#ff0000", color);
fLabel->SetTextColor(color, kFALSE);
fTip = new TGToolTip(fClient->GetDefaultRoot(), this, "TGedNameFrame", 500);
AddInput(kEnterWindowMask | kLeaveWindowMask | kKeyPressMask | kButtonPressMask);
}
TGedNameFrame::~TGedNameFrame()
{
fLayoutHints = 0;
delete fTip;
}
Bool_t TGedNameFrame::HandleCrossing(Event_t *event)
{
if (event->fType == kEnterNotify)
fTip->Reset();
else
fTip->Hide();
return kFALSE;
}
Bool_t TGedNameFrame::HandleButton(Event_t * )
{
if (fTip) fTip->Hide();
return kFALSE;
}
void TGedNameFrame::SetModel(TObject* obj)
{
TString string;
if (obj == 0) {
fLabel->SetText(new TGString("Object not selected"));
return;
}
string.Append(obj->GetName());
string.Append("::");
string.Append(obj->ClassName());
fLabel->SetText(new TGString(string));
string = Form("Name: %s\nTitle: %s\nClass: %s",
obj->GetName(), obj->GetTitle(), obj->ClassName());
fTip->SetText(string);
{
TGCanvas *canvas = fGedEditor->GetTGCanvas();
TGVScrollBar *vsb = canvas->GetVScrollbar();
Int_t hscrollw = (vsb && vsb->IsMapped()) ? vsb->GetWidth() : 0;
Int_t labwidth = TMath::Min(fLabel->GetDefaultSize().fWidth,
canvas->GetWidth() - 10 - hscrollw);
f2->SetWidth(TMath::Max(labwidth, 80));
}
}
Last change: Wed Jun 25 08:43:56 2008
Last generated: 2008-06-25 08:43
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.