#include "TMDisplayingFastorMissingAll.h"
#include "TMHistogrammingFastorMissingAll.h"
#include "TMMainFrame.h"
#include "TMControlSPD.h"
#include "SPDMood.h"
#include <TSystem.h>
#include <TCanvas.h>
#include <TGStatusBar.h>

ClassImp(TMDisplayingFastorMissingAll)

//_____________________________________________________________________
TMDisplayingFastorMissingAll::TMDisplayingFastorMissingAll(const Char_t *frameName, const TGWindow *p, UInt_t width, UInt_t height, TMHistogramming *hist, UInt_t id, UInt_t plotNr, UInt_t cloneId) :
  TMDisplaying(frameName,p,width,height,hist,id,plotNr,cloneId,kTRUE)
{
  gClient->GetColorByName("green", green);
  gClient->GetColorByName("gray", gray);

  CreateTopFrame();
  CreateStatusFrame();
  CreateBottomFrame();

  MapSubwindows();
  Resize();
  MapWindow();

  TCanvas *canv = fTheCanvas->GetCanvas();
  fHist->Draw(canv);
  Update();
}
//_____________________________________________________________________
TMDisplayingFastorMissingAll::~TMDisplayingFastorMissingAll() {}
//_____________________________________________________________________
void TMDisplayingFastorMissingAll::CreateStatusFrame() {
  fTotalStatus = new TGStatusBar(this, fWidth, 27, kHorizontalFrame | kFixedSize);
  fTotalStatus->Draw3DCorner(kFALSE);
  AddFrame(fTotalStatus, new TGLayoutHints(kLHintsExpandX, 0,0,0,0));
}
//_____________________________________________________________________
void TMDisplayingFastorMissingAll::Update() {
  ULong_t expected = ((TMHistogrammingFastorMissingAll*)fHist)->GetTotalExpected();
  ULong_t actual   = ((TMHistogrammingFastorMissingAll*)fHist)->GetTotalActual();
  

  TString totalmsg = "";
  if (expected>0) {
    totalmsg = Form("In Total, Missing signals / Expected signals: %ld / %ld = %f", 
		    expected-actual, expected, (Float_t)(expected-actual)/expected);
  }
  fTotalStatus->SetText(totalmsg.Data(),0);
  TMDisplaying::Update();
}
