Ignore:
Timestamp:
06/16/03 13:45:01 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc

    r2173 r2178  
    181181    filemenu->AddEntry("Save As status.&root", kFileSaveAsRoot);
    182182    filemenu->AddSeparator();
     183    filemenu->AddEntry("Re&set",               kFileReset);
     184    filemenu->AddSeparator();
    183185    filemenu->AddEntry("Print with &lpr",      kFilePrint);
    184186    //filemenu->AddEntry("Set printer &name",    kFilePrinterName);
     
    196198    tabmenu->AddEntry("Save As tab-i.&C",    kTabSaveAsC);
    197199    tabmenu->AddEntry("Save As tab-i.&root", kTabSaveAsRoot);
     200    tabmenu->AddSeparator();
     201    tabmenu->AddEntry("Re&move",             kTabRemove);
    198202    tabmenu->AddSeparator();
    199203    tabmenu->AddEntry("Print with &lpr",     kFilePrint);
     
    560564// to the corresponding TCanvas. If it isn't found NULL is returned.
    561565//
    562 TCanvas *MStatusDisplay::GetCanvas(TGCompositeFrame *cf) const
     566TRootEmbeddedCanvas *MStatusDisplay::GetEmbeddedCanvas(TGCompositeFrame *cf) const
    563567{
    564568    TIter Next(cf->GetList());
     
    567571    while ((f=(TGFrameElement*)Next()))
    568572        if (f->fFrame->InheritsFrom(TRootEmbeddedCanvas::Class()))
    569             return ((TRootEmbeddedCanvas*)f->fFrame)->GetCanvas();
     573            return (TRootEmbeddedCanvas*)f->fFrame;
    570574
    571575    return NULL;
     576}
     577
     578// --------------------------------------------------------------------------
     579//
     580// Takes a TGCompositeFrame as argument. Searches for the first
     581// TRootEmbeddedCanvas which is contained by it and returns a pointer
     582// to the corresponding TCanvas. If it isn't found NULL is returned.
     583//
     584TCanvas *MStatusDisplay::GetCanvas(TGCompositeFrame *cf) const
     585{
     586    TRootEmbeddedCanvas *ec = GetEmbeddedCanvas(cf);
     587    return ec ? ec->GetCanvas() : NULL;
    572588}
    573589
     
    654670    c.SetBorderMode(0);
    655671
    656     // If kNoContaxtMenu set set kNoCOntextMenu of the canvas
     672    // If kNoContextMenu set set kNoContextMenu of the canvas
    657673    if (TestBit(kNoContextMenu))
    658674        c.SetBit(kNoContextMenu);
     
    738754
    739755    return pages;
     756}
     757
     758// --------------------------------------------------------------------------
     759//
     760// Remove tab no i if this tab contains a TRootEmbeddedCanvas
     761//
     762void MStatusDisplay::RemoveTab(int i)
     763{
     764    TGCompositeFrame *f = fTab->GetTabContainer(i);
     765    if (!f)
     766        return;
     767
     768    TRootEmbeddedCanvas *ec = GetEmbeddedCanvas(f);
     769    if (!ec)
     770        return;
     771
     772    TCanvas *c = ec->GetCanvas();
     773    if (!c)
     774        return;
     775
     776    const TString name(c->GetName());
     777
     778    f->RemoveFrame(ec);
     779    delete fList->Remove(ec);
     780
     781    fTab->RemoveTab(i);
     782
     783    // layout and map new tab
     784#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,00)
     785    MapSubwindows();
     786    Layout();
     787#else
     788    Layout();
     789    MapSubwindows();
     790#endif
     791
     792    // display new tab in the main frame
     793    gClient->ProcessEventsFor(fTab);
     794
     795    *fLog << inf << "Removed Tab #" << i << " '" << name << "'" << endl;
     796}
     797
     798// --------------------------------------------------------------------------
     799//
     800// Use this to check whether the MStatusDisplay still contains the
     801// TCanvas c. It could be removed meanwhile by menu usage.
     802//
     803Bool_t MStatusDisplay::HasCanvas(const TCanvas *c) const
     804{
     805    for (int i=1; i<fTab->GetNumberOfTabs(); i++)
     806        if (c==GetCanvas(i))
     807            return kTRUE;
     808    return kFALSE;
    740809}
    741810
     
    773842        return kTRUE;
    774843
     844    case kFileReset:
     845        for (int i=fTab->GetNumberOfTabs()-1; i>0; i--)
     846            RemoveTab(i);
     847        return kTRUE;
    775848        /*
    776849    case kFileSave:
     
    828901    case kTabPrevious:
    829902        fTab->SetTab(fTab->GetCurrent()-1);
     903        return kTRUE;
     904
     905    case kTabRemove:
     906        RemoveTab(fTab->GetCurrent());
    830907        return kTRUE;
    831908
Note: See TracChangeset for help on using the changeset viewer.