/* * ScanMainFrame.cpp * * Created on: Feb 8, 2016 * Author: Hovanes Egiyan */ #include "ScanMainFrame.hh" #include "FileNameFinder.hh" ClassImp(ScanMainFrame) using namespace std; ScanMainFrame::ScanMainFrame( FileNameFinder* fileFinder ) : LogableMainFrame(gClient->GetRoot(), 1500, 500 ), smfFileFinder(fileFinder) { SetBackgroundColor(0x002400); // cout << "Will make the menu bad for " << fileName << endl; this->MakeMenuBar(); // // Sets window name and shows the main frame SetWindowName( "Scan Analysis Top Window" ); SetName("Scan Analysis Top Window"); this->SetWMSize( 400, 150 ); cout << "Mapping subwindows" << endl; this->MapSubwindows(); this->Resize(this->GetDefaultSize()); this->MapWindow(); if( smfFileFinder->getFileName() != "" ) { smfScan = new ScanCombo( smfFileFinder->getFullFileName() ); } return; } ScanMainFrame::~ScanMainFrame() { if( smfScan != 0 ) { try { delete smfScan; } catch(...) { cout << "Failed to delete scan" << endl; } } this->Cleanup(); gApplication->Terminate(0); return; } void ScanMainFrame::MakeMenuBar() { TGHorizontalFrame* menuFrame = new TGHorizontalFrame(this, fWidth, 20 ); // a popup menu TGPopupMenu* fMenuFile = new TGPopupMenu(gClient->GetRoot()); // adding menu entries fMenuFile->AddEntry("&Reopen last",kM_FILE_REOPEN); fMenuFile->AddEntry("&Open...",kM_FILE_OPEN); fMenuFile->AddSeparator(); fMenuFile->AddEntry("E&xit",kM_FILE_EXIT); // Connect action for clicking an option fMenuFile->Connect("Activated(Int_t)","ScanMainFrame",this,"HandleMenu(Int_t)"); // Connect actions for popping up a submenu fMenuFile->Connect("PoppedUp()","ScanMainFrame",this,"HandlePopup()"); // Conenct action for highlighting fMenuFile->Connect("Highlighted(Int_t)","ScanMainFrame",this,"HandleHighlight(Int_t)"); // Create the menu bar itself TGLayoutHints* fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0); // TGLayoutHints* fMenuBarHelpLayout = new TGLayoutHints(kLHintsTop | kLHintsRight); // menu bar lmfMenuBar = new TGMenuBar(menuFrame,100,20,kHorizontalFrame); // adding popup menus lmfMenuBar->AddPopup("&File",fMenuFile,fMenuBarItemLayout); menuFrame->AddFrame(lmfMenuBar, new TGLayoutHints(kLHintsExpandX | kLHintsTop, 5, 5, 5, 5)); this->AddFrame(menuFrame, new TGLayoutHints(kLHintsExpandX | kLHintsTop, 5, 5, 5, 5)); return; } // Override the CloseWindow method to terminate the program when the OverviewMainFrame object is closed. void ScanMainFrame::CloseWindow() { LogableMainFrame::CloseWindow(); cout << "Closing the main application window and exiting the program" << endl; gApplication->Terminate(0); return; } void ScanMainFrame::HandleMenu(Int_t choice) { cout << "Choice " << choice << " has been made " << endl; switch (choice) { case kM_FILE_REOPEN: // Reopen the file that was opened last time // if (smfScan != 0) { // try { // delete smfScan; // } catch (...) { // cout << "Could not delete Scan object" << endl; // } // } if (smfFileFinder->getFileName() != "") { smfScan = new ScanCombo(smfFileFinder->getFullFileName()); } break; case kM_FILE_OPEN: // Select a new file and open it smfFileFinder->getFileNameFromGUI( this ); cout << "Got the file attributes " << endl; if (smfFileFinder->getFileName() != "") { smfScan = new ScanCombo(smfFileFinder->getFullFileName()); } break; default: break; } // Call the same method of the base class LogableMainFrame::HandleMenu( choice ); return; } void ScanMainFrame::HandlePopup() { cout << "Popped up " << endl; return; } void ScanMainFrame::HandleHighlight( Int_t choice ) { cout << "Highlighted " << choice << endl; return; }