Changeset 2052 for trunk/MagicSoft/Mars/mmain
- Timestamp:
- 05/02/03 08:56:31 (22 years ago)
- Location:
- trunk/MagicSoft/Mars/mmain
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc
r2022 r2052 31 31 // (see Read and Write) or printed as a postscript file (see SaveAsPS). 32 32 // 33 // To write gif files of C-Macros use SaveAsGif() or SaveAsC(). 34 // Direct printing to the default printer (via lpr) can be done by 35 // PrintToLpr(). 36 // 33 37 // It has also to half status lines which can be used to display the status 34 38 // or something going on. Together with the status lines it has a progress … … 101 105 // filemenu->AddEntry("S&ave [F2]", kFileSave); 102 106 // filemenu->AddEntry("Save &As... [Shift-F2]", kFileSaveAs); 103 filemenu->AddEntry("Save As status.&ps", kFileSaveAsPS);104 // filemenu->AddEntry("Save As status.&gif",kFileSaveAsGIF);105 // filemenu->AddEntry("Save As status.&C",kFileSaveAsC);107 filemenu->AddEntry("Save As status.&ps", kFileSaveAsPS); 108 filemenu->AddEntry("Save As status.&gif", kFileSaveAsGIF); 109 filemenu->AddEntry("Save As status.&C", kFileSaveAsC); 106 110 filemenu->AddEntry("Save As status.&root", kFileSaveAsRoot); 107 111 filemenu->AddSeparator(); 108 filemenu->AddEntry("Print with &lpr", kFilePrint);109 filemenu->AddEntry("Set printer &name", kFilePrinterName);112 filemenu->AddEntry("Print with &lpr", kFilePrint); 113 filemenu->AddEntry("Set printer &name", kFilePrinterName); 110 114 filemenu->AddSeparator(); 111 115 filemenu->AddEntry("E&xit", kFileExit); … … 118 122 // tabmenu->AddEntry("S&ave [F2]", kFileSave); 119 123 // tabmenu->AddEntry("Save &As... [Shift-F2]", kFileSaveAs); 120 tabmenu->AddEntry("Save As tab-i.&ps", kTabSaveAsPS);121 // tabmenu->AddEntry("Save As tab-i.&gif",kTabSaveAsGIF);122 // tabmenu->AddEntry("Save As tab-i.&C",kTabSaveAsC);124 tabmenu->AddEntry("Save As tab-i.&ps", kTabSaveAsPS); 125 tabmenu->AddEntry("Save As tab-i.&gif", kTabSaveAsGIF); 126 tabmenu->AddEntry("Save As tab-i.&C", kTabSaveAsC); 123 127 tabmenu->AddEntry("Save As tab-i.&root", kTabSaveAsRoot); 124 128 tabmenu->AddSeparator(); 125 tabmenu->AddEntry("Print with &lpr", kFilePrint);129 tabmenu->AddEntry("Print with &lpr", kFilePrint); 126 130 tabmenu->AddSeparator(); 127 tabmenu->AddEntry("Next [&+]", kTabNext);128 tabmenu->AddEntry("Previous [&-]", kTabPrevious);131 tabmenu->AddEntry("Next [&+]", kTabNext); 132 tabmenu->AddEntry("Previous [&-]", kTabPrevious); 129 133 tabmenu->Associate(this); 130 134 … … 135 139 loopmenu->AddEntry("&Stop", kLoopStop); 136 140 loopmenu->Associate(this); 141 142 // 143 // Loop Menu 144 // 145 MGPopupMenu *sizemenu = new MGPopupMenu(gClient->GetRoot()); 146 sizemenu->AddEntry("Fit to 640x&480", kSize640); 147 sizemenu->AddEntry("Fit to 800x&600", kSize800); 148 sizemenu->AddEntry("Fit to 960x7&20", kSize960); 149 sizemenu->AddEntry("Fit to 1024x&768", kSize1024); 150 sizemenu->AddEntry("Fit to 1280x&1024", kSize1280); 151 sizemenu->Associate(this); 137 152 138 153 // … … 143 158 menubar->AddPopup("&Tab", tabmenu, NULL); 144 159 menubar->AddPopup("&Loop", loopmenu, NULL); 160 menubar->AddPopup("&Size", sizemenu, NULL); 145 161 menubar->BindKeys(this); 146 162 AddFrame(menubar); … … 160 176 fList->Add(filemenu); 161 177 fList->Add(loopmenu); 178 fList->Add(sizemenu); 162 179 fList->Add(menubar); 163 180 fList->Add(tabmenu); … … 175 192 176 193 // Add MARS version 177 TString txt = "Official Release: V"; 178 TGLabel *l = new TGLabel(f, txt+MARSVER); 194 TGLabel *l = new TGLabel(f, Form("Official Release: V%s", MARSVER)); 179 195 fList->Add(l); 180 196 … … 184 200 185 201 // Add root version 186 txt = "Using ROOT v"; 187 l = new TGLabel(f, txt+ROOTVER); 202 l = new TGLabel(f, Form("Using ROOT v%s", ROOTVER)); 188 203 fList->Add(l); 189 204 … … 238 253 TGCompositeFrame *f = fTab->AddTab("-Logbook-"); 239 254 240 // Create TGListBox for logging contents241 fLogBox = new TGListBox(f, 1, 1);242 fLogBox->ChangeBackground(TGFrame::GetBlackPixel());255 // Create TGListBox(p, id=-1, opt, back) for logging contents 256 fLogBox = new TGListBox(f, -1, kSunkenFrame); 257 //fLogBox->Associate(this); 243 258 244 259 // Add List box to the tab 245 TGLayoutHints *lay = new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY );//, 5, 6, 5);260 TGLayoutHints *lay = new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY,2,2,2,2); 246 261 f->AddFrame(fLogBox, lay); 247 262 … … 373 388 void MStatusDisplay::SetStatusLine2(const MParContainer &cont) 374 389 { 375 TString txt = cont.GetDescriptor(); 376 txt += ": "; 377 txt += cont.GetTitle(); 378 379 SetStatusLine2(txt); 390 SetStatusLine2(Form("%s: %s", cont.GetDescriptor(), cont.GetTitle())); 380 391 } 381 392 … … 406 417 // set the smallest and biggest size of the Main frame 407 418 // and move it to its appearance position 408 SetWMSizeHints( 640, 548, 1280, 1024, 10, 10);419 SetWMSizeHints(570, 480, 1280, 980, 1, 1); 409 420 Move(rand()%100+50, rand()%100+50); 421 //Resize(740, 600); 422 Resize(570, 480); 410 423 411 424 // … … 603 616 // via SetPrinter 'lpr -Pname' is used. 604 617 // 605 Int_t MStatusDisplay::PrintToLpr(Int_t num) const618 Int_t MStatusDisplay::PrintToLpr(Int_t num) 606 619 { 607 620 TString name = "mars"; … … 613 626 614 627 const Int_t pages = SaveAsPS(num, name); 628 629 SetStatusLine1("Printing..."); 630 SetStatusLine2(""); 631 615 632 if (!pages) 616 633 { 617 634 *fLog << warn << "MStatusDisplay::PrintToLpr: Sorry, couldn't save file as temporary postscript!" << endl; 635 SetStatusLine2("Failed!"); 618 636 return 0; 619 637 } … … 630 648 gSystem->Exec(cmd); 631 649 gSystem->Unlink(name); 650 651 SetStatusLine2(Form("Done (%dpages)", pages)); 632 652 633 653 return pages; … … 658 678 */ 659 679 case kFileSaveAsPS: 660 //cout << "FileSaveAsPS..." << endl;661 680 SaveAsPS(); 662 681 return kTRUE; 663 /* 682 664 683 case kFileSaveAsGIF: 665 cout << "FileSaveAsGIF..." << endl;666 684 SaveAsGIF(); 667 685 return kTRUE; 668 686 669 687 case kFileSaveAsC: 670 cout << "FileSaveAsC..." << endl;671 688 SaveAsC(); 672 689 return kTRUE; 673 */ 690 674 691 case kFileSaveAsRoot: 675 692 SaveAsRoot(); … … 683 700 SaveAsPS(fTab->GetCurrent()); 684 701 return kTRUE; 685 /* 702 686 703 case kTabSaveAsGIF: 687 cout << "TabSaveAsGIF... " << fTab->GetCurrent() << endl;688 704 SaveAsGIF(fTab->GetCurrent()); 689 705 return kTRUE; 690 706 691 707 case kTabSaveAsC: 692 cout << "TabSaveAsC... " << fTab->GetCurrent() << endl;693 708 SaveAsC(fTab->GetCurrent()); 694 709 return kTRUE; 695 */ 710 696 711 case kTabSaveAsRoot: 697 712 SaveAsRoot(fTab->GetCurrent()); … … 710 725 return kTRUE; 711 726 727 case kSize640: 728 Resize(570, 480); 729 return kTRUE; 730 case kSize800: 731 Resize(740, 600); 732 return kTRUE; 733 case kSize960: 734 Resize(880, 700); 735 return kTRUE; 736 case kSize1024: 737 Resize(980, 768); 738 return kTRUE; 739 case kSize1280: 740 Resize(1280, 980); 741 return kTRUE; 742 712 743 default: 713 cout << "Command-Menu : Id=" << id << endl;744 cout << "Command-Menu #" << id << endl; 714 745 } 715 746 return kTRUE; … … 726 757 { 727 758 case kCM_MENU: 728 return ProcessMessageCommandMenu(mp1); 759 return ProcessMessageCommandMenu(mp1); // mp2=userdata 729 760 730 761 case kCM_MENUSELECT: 731 cout << "Menuselect #" << mp1 << endl; 762 cout << "Command-Menuselect #" << mp1 << " (UserData=" << (void*)mp2 << ")" << endl; 763 return kTRUE; 764 765 case kCM_BUTTON: 766 cout << "Command-Button." << endl; 767 return kTRUE; 768 769 case kCM_CHECKBUTTON: 770 cout << "Command-CheckButton." << endl; 771 return kTRUE; 772 773 case kCM_RADIOBUTTON: 774 cout << "Command-RadioButton." << endl; 775 return kTRUE; 776 777 case kCM_LISTBOX: 778 cout << "Command-Listbox #" << mp1 << " (LineId #" << mp2 << ")" << endl; 779 return kTRUE; 780 781 case kCM_COMBOBOX: 782 cout << "Command-ComboBox." << endl; 732 783 return kTRUE; 733 784 … … 764 815 Bool_t MStatusDisplay::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2) 765 816 { 817 // Can be found in WidgetMessageTypes.h 766 818 switch (GET_MSG(msg)) 767 819 { … … 1005 1057 TObject *obj; 1006 1058 1059 // See also TPad::UseCurrentStyle 1007 1060 TIter Next(p.GetListOfPrimitives()); 1008 1061 while ((obj=Next())) … … 1036 1089 } 1037 1090 1091 Bool_t MStatusDisplay::CheckTabForCanvas(int num) const 1092 { 1093 if (num>=fTab->GetNumberOfTabs()) 1094 { 1095 *fLog << warn << "Tab #" << num << " doesn't exist..." << endl; 1096 return kFALSE; 1097 } 1098 if (num==0) 1099 { 1100 *fLog << warn << "Tab #" << num << " doesn't contain an embedded canvas..." << endl; 1101 return kFALSE; 1102 } 1103 if (fTab->GetNumberOfTabs()<2 || !gPad) 1104 { 1105 *fLog << warn << "Sorry, you must have at least one existing canvas (gPad!=NULL)" << endl; 1106 return kFALSE; 1107 } 1108 return kTRUE; 1109 } 1110 1038 1111 // -------------------------------------------------------------------------- 1039 1112 // … … 1046 1119 // To write all tabs you can also use SaveAsPS(name) 1047 1120 // 1048 Int_t MStatusDisplay::SaveAsPS(Int_t num, TString name) const 1049 { 1050 if (num>=fTab->GetNumberOfTabs()) 1051 { 1052 *fLog << warn << "Tab #" << num << " doesn't exist..." << endl; 1053 return 0; 1054 } 1055 if (num==0) 1056 { 1057 *fLog << warn << "Tab #" << num << " doesn't contain an embedded canvas..." << endl; 1058 return 0; 1059 } 1060 if (fTab->GetNumberOfTabs()<2 || !gPad) 1061 { 1062 *fLog << warn << "Sorry, you must have at least one existing canvas (gPad!=NULL)" << endl; 1121 Int_t MStatusDisplay::SaveAsPS(Int_t num, TString name) 1122 { 1123 SetStatusLine1("Writing Postscript file..."); 1124 SetStatusLine2(""); 1125 1126 if (!CheckTabForCanvas(num)) 1127 { 1128 SetStatusLine2("Failed!"); 1063 1129 return 0; 1064 1130 } … … 1107 1173 continue; 1108 1174 } 1175 1176 SetStatusLine2(Form("Tab #%d", i)); 1109 1177 1110 1178 // … … 1186 1254 *fLog << inf << "done." << endl; 1187 1255 1256 SetStatusLine2(Form("Done (%dpages)", page-1)); 1257 1188 1258 return page-1; 1189 1259 } 1190 1260 1191 /* 1192 void MStatusDisplay::SaveAsGIF(Int_t num, TString name) const 1193 { 1261 Bool_t MStatusDisplay::SaveAsGIF(Int_t num, TString name) 1262 { 1263 SetStatusLine1("Writing GIF file..."); 1264 SetStatusLine2(""); 1265 1266 if (!CheckTabForCanvas(num)) 1267 { 1268 SetStatusLine2("Failed!"); 1269 return 0; 1270 } 1271 1194 1272 AddExtension(name, "gif", num); 1195 1273 1196 cout << "Open gif-File: " << name << endl; 1197 cout << " SORRY, not implemented." << endl; 1198 } 1199 1200 void MStatusDisplay::SaveAsC(Int_t num, TString name) const 1201 { 1274 if (num<0) 1275 *fLog << inf << "Writing gif-Files..." << endl; 1276 1277 TPad *padsav = (TPad*)gPad; 1278 1279 int page = 1; 1280 1281 // 1282 // Maintain tab numbers 1283 // 1284 const Int_t from = num<0 ? 1 : num; 1285 const Int_t to = num<0 ? fTab->GetNumberOfTabs() : num+1; 1286 1287 for (int i=from; i<to; i++) 1288 { 1289 TCanvas *c; 1290 if (!(c = GetCanvas(i))) 1291 { 1292 if (num<0) 1293 *fLog << inf << " - "; 1294 *fLog << "Tab #" << i << " doesn't contain an embedded Canvas... skipped." << endl; 1295 continue; 1296 } 1297 1298 SetStatusLine2(Form("Tab #%d", i)); 1299 1300 // 1301 // Clone canvas and change background color and schedule for 1302 // deletion 1303 // 1304 //TCanvas *n = (TCanvas*)c->Clone(); 1305 //CanvasSetFillColor(*n, kWhite); 1306 1307 // 1308 // Paint canvas into root file 1309 // 1310 TString writename = name; 1311 if (num<0) 1312 { 1313 TString numname = "-"; 1314 numname += i; 1315 writename.Insert(name.Last('.'), numname); 1316 } 1317 if (num<0) 1318 *fLog << inf << " - "; 1319 *fLog << inf << "Writing Tab #" << i << " to " << writename << ": " << c->GetName() << " (" << c << ") "; 1320 if (num>0) 1321 *fLog << "to " << name; 1322 *fLog << "..." << flush; 1323 1324 c->Draw(); 1325 c->SaveAs(writename); 1326 /* 1327 n->Draw(); 1328 n->SaveAs(writename); 1329 delete n; 1330 */ 1331 1332 if (num<0) 1333 *fLog << "done." << endl; 1334 } 1335 1336 padsav->cd(); 1337 1338 *fLog << inf << "done." << endl; 1339 1340 SetStatusLine2("Done."); 1341 1342 return page-1; 1343 } 1344 1345 Bool_t MStatusDisplay::SaveAsC(Int_t num, TString name) 1346 { 1347 SetStatusLine1("Writing C++ file..."); 1348 SetStatusLine2(""); 1349 1350 if (!CheckTabForCanvas(num)) 1351 { 1352 SetStatusLine2("Failed!"); 1353 return 0; 1354 } 1355 1202 1356 AddExtension(name, "C", num); 1203 1357 1204 cout << "Open C-File: " << name << endl; 1205 cout << " SORRY, not implemented." << endl; 1206 } 1207 */ 1358 if (num<0) 1359 *fLog << inf << "Writing C-Files..." << endl; 1360 1361 TPad *padsav = (TPad*)gPad; 1362 1363 int page = 1; 1364 1365 // 1366 // Maintain tab numbers 1367 // 1368 const Int_t from = num<0 ? 1 : num; 1369 const Int_t to = num<0 ? fTab->GetNumberOfTabs() : num+1; 1370 1371 for (int i=from; i<to; i++) 1372 { 1373 TCanvas *c; 1374 if (!(c = GetCanvas(i))) 1375 { 1376 if (num<0) 1377 *fLog << inf << " - "; 1378 *fLog << "Tab #" << i << " doesn't contain an embedded Canvas... skipped." << endl; 1379 continue; 1380 } 1381 1382 SetStatusLine2(Form("Tab #%d", i)); 1383 1384 // 1385 // Clone canvas and change background color and schedule for 1386 // deletion 1387 // 1388 TCanvas *n = (TCanvas*)c->Clone(); 1389 CanvasSetFillColor(*n, kWhite); 1390 1391 // 1392 // Paint canvas into root file 1393 // 1394 TString writename = name; 1395 if (num<0) 1396 { 1397 TString numname = "-"; 1398 numname += i; 1399 writename.Insert(name.Last('.'), numname); 1400 } 1401 if (num<0) 1402 *fLog << inf << " - "; 1403 *fLog << inf << "Writing Tab #" << i << " to " << writename << ": " << c->GetName() << " (" << n << ") "; 1404 if (num>0) 1405 *fLog << "to " << name; 1406 *fLog << "..." << flush; 1407 1408 n->SaveSource(writename, ""); 1409 delete n; 1410 1411 if (num<0) 1412 *fLog << "done." << endl; 1413 } 1414 1415 padsav->cd(); 1416 1417 *fLog << inf << "done." << endl; 1418 1419 SetStatusLine2("Done."); 1420 1421 return page-1; 1422 } 1208 1423 1209 1424 // -------------------------------------------------------------------------- … … 1219 1434 Int_t MStatusDisplay::SaveAsRoot(Int_t num, TString name) 1220 1435 { 1221 if (num>=fTab->GetNumberOfTabs()) 1222 { 1223 *fLog << warn << "Tab #" << num << " doesn't exist..." << endl; 1224 return 0; 1225 } 1226 if (num==0) 1227 { 1228 *fLog << warn << "Tab #" << num << " doesn't contain an embedded canvas..." << endl; 1229 return 0; 1230 } 1231 if (fTab->GetNumberOfTabs()<2 || !gPad) 1232 { 1233 *fLog << warn << "Sorry, you must have at least one existing canvas." << endl; 1436 SetStatusLine1("Writing root file..."); 1437 SetStatusLine2(""); 1438 1439 if (!CheckTabForCanvas(num)) 1440 { 1441 SetStatusLine2("Failed!"); 1234 1442 return 0; 1235 1443 } … … 1242 1450 gFile = fsave; 1243 1451 1452 SetStatusLine2("Done."); 1453 1244 1454 return keys; 1245 1455 } 1456 1457 Bool_t MStatusDisplay::HandleConfigureNotify(Event_t *evt) 1458 { 1459 //cout << "----- Start -----" << endl; 1460 1461 UInt_t w = evt->fWidth; 1462 UInt_t h = evt->fHeight; 1463 1464 //cout << "Old: " << GetWidth() << " " << GetHeight() << " " << GetBorderWidth() << endl; 1465 //cout << "New: " << w << " " << h << endl; 1466 1467 Bool_t wchanged = w!=GetWidth(); 1468 Bool_t hchanged = h!=GetHeight(); 1469 1470 if (!wchanged && !hchanged) 1471 { 1472 Layout(); 1473 return kTRUE; 1474 } 1475 1476 if (GetWidth()==1 && GetHeight()==1) 1477 return kTRUE; 1478 1479 // calculate the constant part of the window 1480 const UInt_t cw = GetWidth() -fTab->GetWidth(); 1481 const UInt_t ch = GetHeight()-fTab->GetHeight(); 1482 1483 // canculate new size of frame (canvas @ 1:sqrt(2)) 1484 if (hchanged) 1485 w = (UInt_t)((h-ch)*sqrt(2)+.5)+cw; 1486 else 1487 h = (UInt_t)((w-cw)/sqrt(2)+.5)+ch; 1488 1489 //cout << "Res: " << w << " " << h << " " << evt->fX << " " << evt->fY << endl; 1490 1491 // resize frame 1492 Resize(w, h); 1493 1494 return kTRUE; 1495 } 1496 1497 Bool_t MStatusDisplay::HandleEvent(Event_t *event) 1498 { 1499 /* 1500 if (event->fType!=9) 1501 { 1502 cout << "Event: " << event->fType << " "; 1503 cout << event->fX << " " << event->fY << endl; 1504 } 1505 */ 1506 /* 1507 switch (event->fType) { 1508 case kConfigureNotify: 1509 //while (gVirtualX->CheckEvent(fId, kConfigureNotify, *event)) 1510 // ; 1511 HandleConfigureNotify(event); 1512 return kTRUE; 1513 } 1514 */ 1515 // if (event->fType==kConfigureNotify && event->fX!=0 && event->fY!=0) 1516 // return kTRUE; 1517 1518 return TGMainFrame::HandleEvent(event); 1519 } -
trunk/MagicSoft/Mars/mmain/MStatusDisplay.h
r2015 r2052 51 51 kTabNext, 52 52 kTabPrevious, 53 kSize640, 54 kSize800, 55 kSize960, 56 kSize1024, 57 kSize1280, 53 58 kFileExit, 54 59 kPicMagic, … … 89 94 Bool_t ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2); 90 95 void CloseWindow(); 96 Bool_t HandleConfigureNotify(Event_t *); 97 Bool_t HandleEvent(Event_t *event); 91 98 92 99 Bool_t HandleTimer(TTimer *timer=NULL); … … 135 142 void SetNoContextMenu(Bool_t flag=kTRUE); 136 143 137 Int_t SaveAsPS(TString name="") const{ return SaveAsPS(-1, name); }138 //Bool_t SaveAsGIF(TString name="") const{ return SaveAsGIF(-1, name); }139 //Bool_t SaveAsC(TString name="") const{ return SaveAsC(-1, name); }140 Int_t SaveAsRoot(TString name="") { return SaveAsRoot(-1, name); }141 Int_t PrintToLpr() const{ return PrintToLpr(-1); }144 Int_t SaveAsPS(TString name="") { return SaveAsPS(-1, name); } 145 Bool_t SaveAsGIF(TString name="") { return SaveAsGIF(-1, name); } 146 Bool_t SaveAsC(TString name="") { return SaveAsC(-1, name); } 147 Int_t SaveAsRoot(TString name="") { return SaveAsRoot(-1, name); } 148 Int_t PrintToLpr() { return PrintToLpr(-1); } 142 149 143 Int_t SaveAsPS(Int_t num, TString name="") const;144 //Bool_t SaveAsGIF(Int_t num, TString name="") const;145 //Bool_t SaveAsC(Int_t num, TString name="") const;146 Int_t SaveAsRoot(Int_t num, TString name="");147 Int_t PrintToLpr(Int_t num) const;150 Int_t SaveAsPS(Int_t num, TString name=""); 151 Bool_t SaveAsGIF(Int_t num, TString name=""); 152 Bool_t SaveAsC(Int_t num, TString name=""); 153 Int_t SaveAsRoot(Int_t num, TString name=""); 154 Int_t PrintToLpr(Int_t num); 148 155 149 156 Status_t CheckStatus() const { return fStatus; } … … 153 160 void UnLock() { ResetBit(kIsLocked); } 154 161 162 Bool_t CheckTabForCanvas(int num) const; 163 155 164 ClassDef(MStatusDisplay, 0) // Window for a status display 156 165 };
Note:
See TracChangeset
for help on using the changeset viewer.