#include "TMMenuBar.h"
#include "SPDMood.h"

ClassImp(TMMenuBar)

//___________________________________________________________________________________
TMMenuBar::TMMenuBar(const TGWindow* p, TGWindow* handler) : TGMenuBar(p) {

  fL0 = new TGLayoutHints(kLHintsTop | kLHintsLeft);
  fL1 = new TGLayoutHints(kLHintsTop | kLHintsRight);
  activeView = -1;

  fFileMenu = new TGPopupMenu(fClient->GetRoot());
  fFileMenu->AddEntry("Show Config", FILE_DUMPCONF);
  fFileMenu->AddEntry("Load Config", FILE_LOADCONF);
  fFileMenu->AddEntry("Set Default Config", FILE_DEFAULTCONF);
  fFileMenu->AddEntry("Save Config", FILE_SAVECONF);
  fFileMenu->AddEntry("Save Config As", FILE_SAVECONFAS);
  fFileMenu->AddEntry("Exit", FILE_EXIT);
  fFileMenu->Associate(handler);

  fConfMenu = new TGPopupMenu(fClient->GetRoot());
  fConfMenu->AddEntry("Change Source/Run", CONF_CHANGESOURCE);
  fConfMenu->AddEntry("Set Trigger Mask", CONF_TRIGMASKALL);
  fConfMenu->AddEntry("Equipment Activation", CONF_EQACTIVATE);
  fConfMenu->AddEntry("Suppress Error Messages", CONF_SUPPRERROR);
  fConfMenu->AddEntry("Update Time", CONF_UPDATETIME);
  fConfMenu->AddEntry("Adv EvCount Dump Options", CONF_ADVEVCNTDUMPALL);
  fConfMenu->Associate(handler);

  fOpMenu = new TGPopupMenu(fClient->GetRoot());
  fOpMenu->AddEntry("Dead and Noisy Pixels", OP_DEADNOISY);
  //!!!  fOpMenu->AddEntry("Connect to Grid", OP_GRIDCONNECT);
  fOpMenu->Associate(handler);

  fMaskMenu = new TGPopupMenu(fClient->GetRoot());
  fMaskMenu->AddEntry("Mask Pixels", MASK_MASK);
  fMaskMenu->AddEntry("Un-Mask Pixels", MASK_UNMASK);
  fMaskMenu->AddEntry("Load Mask", MASK_LOADDIR);
  fMaskMenu->AddEntry("Save Mask", MASK_SAVEDIR);
  fMaskMenu->AddEntry("Clear Mask", MASK_CLEAR);
  fMaskMenu->AddEntry("Print Masked Pixels", MASK_PRINTLIST);
  fMaskMenu->Associate(handler);


  this->AddPopup("&File", fFileMenu, fL0);
  this->AddPopup("&Settings", fConfMenu, fL0);
  this->AddPopup("&Operations", fOpMenu, fL0);
  this->AddPopup("&Pixel Masking", fMaskMenu, fL0);
}

//___________________________________________________________________________________
TMMenuBar::~TMMenuBar() {
  delete fFileMenu;
  delete fConfMenu;
  delete fOpMenu;
  delete fMaskMenu;
  delete fL0;
  delete fL1;
}
