Changeset 1050 for trunk/MagicSoft/Mars
- Timestamp:
- 11/07/01 14:13:50 (23 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc
r1003 r1050 32 32 // This can be the name of the class or a given name, which identifies // 33 33 // the container in a parameter container list (MParList). // 34 // The container is writte to the ascii file if its ReadyToSave flag is 34 // The container is writte to the ascii file if its ReadyToSave flag is // 35 35 // set (MParContainer) // 36 36 // // … … 54 54 // of the class (eg. MHillas) but it can also be a different name which 55 55 // identifies the container in the parameter list. 56 // Because you cannot write more than one container there is no Add-function 57 // like in MWriteRootFile. 58 // 59 // For Example: MWriteAsciiFile("file.txt", "MHillas"); 56 60 // 57 61 MWriteAsciiFile::MWriteAsciiFile(const char *filename, const char *contname, … … 72 76 // Specify a the name of the ascii output file 'filename' and a pointer to 73 77 // the container you want to write. 78 // Because you cannot write more than one container there is no Add-function 79 // like in MWriteRootFile. 80 // 81 // For Example: MHillas hillas; 82 // MWriteAsciiFile("file.txt", &hillas); 83 // 74 84 // 75 85 MWriteAsciiFile::MWriteAsciiFile(const char *filename, MParContainer *cont, -
trunk/MagicSoft/Mars/mmain/MBrowser.cc
r1030 r1050 33 33 #include <TGMsgBox.h> // TGMsgBox 34 34 #include <TGListBox.h> // TGListBox 35 #include <TGComboBox.h> // TGComboBox 35 #include <TGTextEntry.h> // TGTextEntry 36 #include <TGFSComboBox.h> // TGFSComboBox, TGFSLboxEntry 36 37 #include <TGProgressBar.h> // TGHProgressBar 37 38 #include <TGFSContainer.h> // TGFileContainer … … 47 48 48 49 enum { 49 M_FILE_CLOSE = 0x1000, 50 M_PBUTTON_CDIR_UP = 0x1001, 51 M_PBUTTON_LIST_MODE = 0x1002, 52 M_PBUTTON_DETAIL_MODE = 0x1003, 53 M_DIRBOX = 0x1004 50 kFileClose, 51 kButDirUp, 52 kButListMode, 53 kButDetailMode, 54 kCBDirectory, 55 kTEFileName 54 56 }; 55 57 … … 60 62 // 61 63 TGPopupMenu *filemenu = new TGPopupMenu(gClient->GetRoot()); 62 filemenu->AddEntry("Close", M_FILE_CLOSE); 63 //filemenu->Associate(this); 64 filemenu->AddEntry("Close", kFileClose); 64 65 fList->Add(filemenu); 65 66 … … 110 111 // Create Dir-Listbox and buttons in first frame 111 112 // 112 fDir = new TG ComboBox(frame, M_DIRBOX);113 fDir = new TGFSComboBox(frame, kCBDirectory); 113 114 fDir->Resize(350, 20); 114 115 … … 123 124 // Create the corresponding picture buttons 124 125 // 125 fCdup = new TGPictureButton(frame, fPic1, M_PBUTTON_CDIR_UP);126 fListMode = new TGPictureButton(frame, fPic2, M_PBUTTON_LIST_MODE);127 fDetail = new TGPictureButton(frame, fPic3, M_PBUTTON_DETAIL_MODE);126 fCdup = new TGPictureButton(frame, fPic1, kButDirUp); 127 fListMode = new TGPictureButton(frame, fPic2, kButListMode); 128 fDetail = new TGPictureButton(frame, fPic3, kButDetailMode); 128 129 129 130 // … … 163 164 // padding: 5, 5, 5, 5 164 165 // 165 TGLayoutHints *layout = new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5); 166 TGLayoutHints *laydir = new TGLayoutHints(kLHintsExpandX|kLHintsLeft|kLHintsCenterY); //, 5, 5, 5, 5); 167 fList->Add(laydir); 168 169 TGLayoutHints *layout = new TGLayoutHints(kLHintsRight|kLHintsCenterY, 10); //, 5, 5, 5); 166 170 fList->Add(layout); 167 171 168 frame->AddFrame(fDir, layout); 169 frame->AddFrame(fCdup, layout); 172 frame->AddFrame(fDir, laydir); 170 173 frame->AddFrame(fListMode, layout); 171 174 frame->AddFrame(fDetail, layout); 175 frame->AddFrame(fCdup, layout); 172 176 } 173 177 … … 193 197 fFileCont->Sort(kSortByName); 194 198 195 TGLayoutHints *layview = new TGLayoutHints(kLHintsTop|kLHintsExpandX|kLHintsExpandY , 5, 5, 5, 5);199 TGLayoutHints *layview = new TGLayoutHints(kLHintsTop|kLHintsExpandX|kLHintsExpandY); //, 5, 5, 5, 5); 196 200 fList->Add(layview); 197 201 … … 206 210 // Create three frames for the first tab 207 211 // 208 TGCompositeFrame *tab1 = new TGCompositeFrame(frame, 100, 100, kHorizontalFrame); 209 TGCompositeFrame *tab1a = new TGCompositeFrame(frame, 100, 100, kHorizontalFrame); 210 TGCompositeFrame *tab1b = new TGCompositeFrame(frame, 100, 100, kVerticalFrame); 211 212 TGLayoutHints *laytab1b = new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 5, 5, 5, 5); 213 TGLayoutHints *laytab1 = new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5); 214 215 fList->Add(laytab1b); 212 TGHorizontalFrame *tab1a = new TGHorizontalFrame(frame, 100, 100); 213 TGHorizontalFrame *tab1b = new TGHorizontalFrame(frame, 100, 100); 214 TGVerticalFrame *tab2 = new TGVerticalFrame (frame, 100, 100); 215 216 TGLayoutHints *laytab1 = new TGLayoutHints(kLHintsNormal|kLHintsExpandX, 10, 10, 10); 217 TGLayoutHints *laytab2 = new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 10, 10, 10, 10); 218 TGLayoutHints *layentry = new TGLayoutHints(kLHintsNormal|kLHintsExpandX); //, 5, 5, 5); 219 220 frame->AddFrame(tab1a, laytab1); 221 frame->AddFrame(tab1b, laytab1); 222 frame->AddFrame(tab2, laytab2); 223 224 fEntry = new TGTextEntry(tab1a, "", kTEFileName); 225 fEntry->Resize(350, 20); 226 fEntry->Associate(this); 227 tab1a->AddFrame(fEntry, layentry); 228 229 CreateDirListMenu(tab1b); 230 CreateDirListBox(tab2); 231 216 232 fList->Add(laytab1); 217 218 frame->AddFrame(tab1a); 219 frame->AddFrame(tab1b, laytab1b); 220 frame->AddFrame(tab1, laytab1); 221 222 fList->Add(tab1); 233 fList->Add(laytab2); 223 234 fList->Add(tab1a); 224 235 fList->Add(tab1b); 225 226 CreateDirListMenu(tab1a);227 CreateDirListBox(tab1b);236 fList->Add(tab2); 237 fList->Add(layentry); 238 fList->Add(fEntry); 228 239 } 229 240 … … 394 405 fFileCont->ChangeDirectory(txt?txt:gSystem->WorkingDirectory()); 395 406 396 const char *dir = fFileCont->GetDirectory(); 397 // const UInt_t num = fDir->GetSelected()+1; 398 399 // 400 // FIXME: This is a big workaround! 401 // 402 fDir->InsertEntry(dir, -1/*num*/, -1); 403 fDir->Select(-1/*num*/); 407 const char *dir = fFileCont->GetDirectory(); 408 fDir->Update(dir); 409 } 410 411 void MBrowser::SetFileName(const char *name) 412 { 413 // 414 // determine the file type by extensions 415 // 416 const char *ext=strrchr(name, '.'); 417 418 Bool_t failed = kFALSE; 419 420 if (!ext) 421 failed = kTRUE; 422 else 423 if (strcasecmp(ext, ".root")) 424 failed = kTRUE; 425 426 char *fname=NULL; 427 if (!failed) 428 { 429 const char *dir = fFileCont->GetDirectory(); 430 431 fname = Form("%s/%s", dir, name); 432 433 failed = gSystem->AccessPathName(fname, kFileExists); 434 } 435 436 if (!failed) 437 strcpy(fInputFile, fname); 438 else 439 fname = Form(fInputFile); 440 441 char *slash = strrchr(fname, '/'); 442 443 fEntry->SetText(slash ? slash+1 : ""); 444 445 if (!slash) 446 return; 447 448 *slash = '\0'; 449 ChangeDir(fname); 404 450 } 405 451 … … 410 456 switch (GET_MSG(msg)) 411 457 { 458 case kC_TEXTENTRY: 459 if (GET_SUBMSG(msg)!=kTE_ENTER) 460 return kTRUE; 461 462 SetFileName(fEntry->GetText()); 463 return kTRUE; 464 412 465 case kC_COMMAND: 413 466 switch (GET_SUBMSG(msg)) … … 417 470 switch (parm1) 418 471 { 419 case M_PBUTTON_CDIR_UP:472 case kButDirUp : 420 473 // 421 474 // goto the parent directory … … 424 477 return kTRUE; 425 478 426 case M_PBUTTON_LIST_MODE:479 case kButListMode: 427 480 fFileView->SetViewMode(kLVList); 428 481 fDetail->SetState(kButtonUp) ; 429 482 return kTRUE; 430 483 431 case M_PBUTTON_DETAIL_MODE:484 case kButDetailMode: 432 485 fFileView->SetViewMode(kLVDetails); 433 486 fListMode->SetState(kButtonUp); … … 441 494 // But to do this we need the number of entries in the list. 442 495 // 443 if (parm1 == M_DIRBOX) 444 ChangeDir(((TGTextLBEntry*)fDir->GetSelectedEntry())->GetText()->GetString()); 496 if (parm1 != kCBDirectory) 497 return kTRUE; 498 499 ChangeDir(((TGTreeLBEntry*)fDir->GetSelectedEntry())->GetPath()->GetString()); 445 500 return kTRUE; 446 501 447 502 case kCM_MENU: 448 if (parm1== M_FILE_CLOSE)503 if (parm1==kFileClose) 449 504 CloseWindow(); 450 505 return kTRUE; … … 465 520 // 466 521 467 if (parm1 != kButton1) 468 return kTRUE; 469 470 if (fFileCont->NumSelected() != 1 ) 522 if (parm1 != kButton1 || fFileCont->NumSelected() != 1) 471 523 return kTRUE; 472 524 … … 489 541 } 490 542 491 // 492 // file is no directory, is a file 493 // determine the file type by extensions 494 // 495 const char *extension=strrchr(str, '.'); 496 497 if (!extension) 498 return kTRUE; 499 500 const char *dir = fFileCont->GetDirectory(); 501 502 if (!strcasecmp(extension, ".ps")) // postscript file 503 { 504 char *cmd = new char[strlen(dir)+strlen(str)+40]; 505 sprintf(cmd, "gv %s/%s &", dir, str); 506 gSystem->Exec(cmd); 507 delete cmd; 508 return kTRUE; 509 } 510 511 if (!strcasecmp(extension, ".root")) 512 { 513 sprintf(fInputFile, "%s/%s", dir, str); 514 return kTRUE; 515 } 543 SetFileName(str); 516 544 return kTRUE; 517 545 } -
trunk/MagicSoft/Mars/mmain/MBrowser.h
r1030 r1050 13 13 class TGTab; 14 14 class TGListView; 15 class TGComboBox; 15 class TGTextEntry; 16 class TGFSComboBox; 16 17 class TGProgressBar; 17 18 class TGPictureButton; … … 23 24 TGTab *fTabs; 24 25 25 TGComboBox *fDir; 26 TGFSComboBox *fDir; 27 TGTextEntry *fEntry; 26 28 27 29 TGPictureButton *fCdup; … … 42 44 void CreateDirListMenu(TGCompositeFrame *frame); 43 45 void CreateDirListBox(TGCompositeFrame *frame); 46 47 void SetFileName(const char *name); 44 48 45 49 protected: -
trunk/MagicSoft/Mars/mmain/MMars.cc
r993 r1050 30 30 #include <TGTab.h> // TGTab 31 31 #include <TGMenu.h> // TGPopupMenu 32 #include <TSystem.h> // gSystem->Exec 32 33 #include <TGMsgBox.h> // TGMsgBox 33 34 #include <TGButton.h> // TGPictureButton 34 35 #include <TG3DLine.h> // TGHorizontal3DLine 35 // use TGSplitter.h for root<3.00 36 36 37 #include "MEvtDisp.h" 37 38 #include "MAnalysis.h" … … 289 290 290 291 case M_PICTURE_MAGIC: 291 DisplWarning("Please open a Netscape to the MAGIC homepage\n" 292 "http://hegra1.mppmu.mpg.de/MAGICWeb/"); 292 gSystem->Exec("netscape http://hegra1.mppmu.mpg.de/MAGICWeb/ &"); 293 293 return kTRUE; 294 294 295 295 case M_PICTURE_MARS: 296 DisplWarning("Please open a Netscape to the MARS homepage\n" 297 "http://magic.uni-sw.gwdg.de/mars/"); 296 gSystem->Exec("netscape http://magic.uni-sw.gwdg.de/mars/ &"); 298 297 return kTRUE; 299 298 }
Note:
See TracChangeset
for help on using the changeset viewer.