Changeset 2805 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 01/14/04 18:06:11 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc
r2788 r2805 190 190 filemenu->AddEntry("Save As status.&root", kFileSaveAsRoot); 191 191 filemenu->AddSeparator(); 192 filemenu->AddEntry("&Open...", kFileOpen); 192 193 filemenu->AddEntry("Save &As...", kFileSaveAs); 193 194 filemenu->AddSeparator(); … … 1088 1089 return kTRUE; 1089 1090 1091 case kFileOpen: 1092 Open(); 1093 return kTRUE; 1094 1090 1095 case kFileSaveAs: 1091 1096 SaveAs(); … … 1725 1730 { 1726 1731 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(); 1728 1756 1729 1757 Long_t t[4]; // { id, size, flags, modtime } … … 1768 1796 delete c[1]; 1769 1797 delete c[0]; 1798 */ 1770 1799 } 1771 1800 … … 2155 2184 { 2156 2185 "PostScript", "*.ps", 2157 // "Encapsulated PostScript", "*.eps",2158 2186 "Gif files", "*.gif", 2159 2187 "Macro files", "*.C", … … 2186 2214 Warning("MStatusDisplay::SaveAs", "Unknown Extension: %s", fi.fFilename); 2187 2215 return 0; 2216 } 2217 2218 // -------------------------------------------------------------------------- 2219 // 2220 // Open contents of a MStatusDisplay with key name from file fname. 2221 // 2222 Int_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 // 2238 Int_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); 2188 2262 } 2189 2263 -
trunk/MagicSoft/Mars/mbase/MStatusDisplay.h
r2787 r2805 39 39 typedef enum { 40 40 // kFile 41 kFileBrowser, kFileCanvas, kFile Save, kFileSaveAs, kFileSaveAsPS,41 kFileBrowser, kFileCanvas, kFileOpen, kFileSave, kFileSaveAs, kFileSaveAsPS, 42 42 kFileSaveAsRoot, kFileSaveAsGIF, kFileSaveAsC, kFilePrint, 43 43 kFilePrinterName, kFileClose, kFileExit, kFileReset, … … 183 183 184 184 Int_t SaveAs(Int_t num=-1); 185 Int_t Open(TString fname, const char *name="MStatusDisplay"); 186 Int_t Open(); 185 187 186 188 Status_t CheckStatus() const { return fStatus; }
Note:
See TracChangeset
for help on using the changeset viewer.