Ignore:
Timestamp:
01/14/04 18:06:11 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r2788 r2805  
    190190    filemenu->AddEntry("Save As status.&root", kFileSaveAsRoot);
    191191    filemenu->AddSeparator();
     192    filemenu->AddEntry("&Open...",             kFileOpen);
    192193    filemenu->AddEntry("Save &As...",          kFileSaveAs);
    193194    filemenu->AddSeparator();
     
    10881089        return kTRUE;
    10891090
     1091    case kFileOpen:
     1092        Open();
     1093        return kTRUE;
     1094
    10901095    case kFileSaveAs:
    10911096        SaveAs();
     
    17251730{
    17261731    const TString newstr("%%DocumentPaperSizes: a4\n%%Orientation: Landscape\n");
    1727     const Int_t   l = newstr.Length();
     1732
     1733    ifstream fin(name);
     1734    ofstream fout(name+".$$$");
     1735
     1736    char c;
     1737
     1738    TString str;
     1739    fin >> str >> c;                // Read "%!PS-Adobe-2.0\n"
     1740    fout << str << endl << newstr;
     1741
     1742    // Doing it in blocks seems not to gain much for small (MB) files
     1743    while (fin)
     1744    {
     1745        fin.read(&c, 1);
     1746        fout.write(&c, 1);
     1747    }
     1748
     1749    gSystem->Unlink(name);
     1750    gSystem->Rename(name+".$$$", name);
     1751/*
     1752    //
     1753    // Old style algorithm. Shifts blocks inside a single file --- SLOW!
     1754    //
     1755    const Int_t l = newstr.Length();
    17281756
    17291757    Long_t t[4]; // { id, size, flags, modtime }
     
    17681796    delete c[1];
    17691797    delete c[0];
     1798*/
    17701799}
    17711800
     
    21552184    {
    21562185        "PostScript",   "*.ps",
    2157         // "Encapsulated PostScript", "*.eps",
    21582186        "Gif files",    "*.gif",
    21592187        "Macro files",  "*.C",
     
    21862214    Warning("MStatusDisplay::SaveAs", "Unknown Extension: %s", fi.fFilename);
    21872215    return 0;
     2216}
     2217
     2218// --------------------------------------------------------------------------
     2219//
     2220//  Open contents of a MStatusDisplay with key name from file fname.
     2221//
     2222Int_t MStatusDisplay::Open(TString fname, const char *name)
     2223{
     2224    TFile file(fname, "READ");
     2225    if (file.IsZombie())
     2226    {
     2227        gLog << warn << "WARNING - Cannot open file " << fname << endl;
     2228        return 0;
     2229    }
     2230
     2231    return Read(name);
     2232}
     2233
     2234// --------------------------------------------------------------------------
     2235//
     2236//  Opens an open dialog
     2237//
     2238Int_t MStatusDisplay::Open()
     2239{
     2240    static const char *gOpenTypes[] =
     2241    {
     2242        "ROOT files", "*.root",
     2243        "All files",  "*",
     2244        NULL,           NULL
     2245    };
     2246
     2247    static TString dir(".");
     2248
     2249    TGFileInfo fi; // fFileName and fIniDir deleted in ~TGFileInfo
     2250
     2251    fi.fFileTypes = (const char**)gOpenTypes;
     2252    fi.fIniDir    = StrDup(dir);
     2253
     2254    new TGFileDialog(fClient->GetRoot(), this, kFDSave, &fi);
     2255
     2256    if (!fi.fFilename)
     2257        return 0;
     2258
     2259    dir = fi.fIniDir;
     2260
     2261    return Open(fi.fFilename);
    21882262}
    21892263
Note: See TracChangeset for help on using the changeset viewer.