#ifndef TMDisplaying_H
#define TMDisplaying_H

#include "TMHistogramming.h"
#include "TRootEmbeddedCanvasHenrik.h"
#include <TGFrame.h>
#include <TGButton.h>
#include <TGStatusBar.h>
#include <TGLabel.h>
#include <TGTextEntry.h>

class TMDisplaying : public TGMainFrame {
 public:
  TMDisplaying(const Char_t *frameName, const TGWindow *p, UInt_t width, UInt_t height, TMHistogramming *hist, UInt_t id, UInt_t plotNr, UInt_t cloneId, Bool_t overRide);
  TMDisplaying(const Char_t *frameName, const TGWindow *p, UInt_t width, UInt_t height, TMHistogramming *hist, UInt_t id, UInt_t plotNr, UInt_t cloneId);
  virtual ~TMDisplaying();
  
  virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
  virtual void   ProcessTrigMask();
  virtual void   ProcessScreenShot();
  virtual void   ProcessScreenShot2(const Char_t *localFile);
  virtual void   ProcessScreenShot2default(const Char_t *localDir, const Char_t *extension="gif");
  virtual void   ProcessReset();
  virtual void   ProcessUpdate();
  virtual void   ProcessKill();
  virtual void   ProcessClone();
  virtual void   ToggleButton(Int_t id);
  virtual void   ToggleAutoUpdateButton(Bool_t down);
  virtual void   ToggleAutoResetButton(Bool_t down);
  virtual void   TogglePauseButton(Bool_t down);

#ifdef MOVIE_VER
  virtual void   ToggleMovieButton(Bool_t down);
#endif

  virtual void   ProcessStartRun();
  virtual void   ProcessEndRun();

  virtual void   Update();
  virtual void   UpdateAuto();
  virtual void   UpdateAutoAll();

  virtual Bool_t IsAutoUpdate() {return fAutoUpdate;}

  virtual void   CloseWindow();

  virtual void   CreateTopFrame();
  virtual void   CreateBottomFrame();
  virtual void   UpdateWindowName();
  virtual void   SetPlotNr(UInt_t plotnr);

  virtual const Char_t* GetTextEventMod() {return fTextEventMod->GetText();}
  virtual const Char_t* GetTextEventModEq() {return fTextEventModEq->GetText();}
  virtual void          SetTextEventMod(const Char_t *text) {fTextEventMod->SetText(text);}
  virtual void          SetTextEventModEq(const Char_t *text) {fTextEventModEq->SetText(text);}

#ifdef MOVIE_VER
  virtual void   ProcessMovieStart();
  virtual void   ProcessMovieEnd();
  virtual void   MakeMovieShot();
#endif

 protected:
  TString fFrameName;
  UInt_t  fWidth;
  UInt_t  fHeight;
  TMHistogramming *fHist;
  UInt_t  fID;
  UInt_t  fPlotNr;
  UInt_t  fCloneId;
  Bool_t  fAutoUpdate;
  Bool_t  fPleaseWait;

#ifdef MOVIE_VER
  Bool_t  fMovie;
  UInt_t  fNrImg;
  TString fImgDir;
#endif

  TRootEmbeddedCanvasHenrik   *fTheCanvas;
  TGCompositeFrame      *fBottomButtons, *fBottomStatus;
  TGStatusBar           *fStatusBar;
  TGTextButton          *fBottomPause, *fBottomAutoUpdate, *fBottomAutoReset; 
  TGTextButton          *fBottomUpdate, *fBottomReset, *fBottomClone, *fBottomKill, *fBottomTrigMask, *fBottomScreenShot;
  TGTextEntry           *fTextEventMod, *fTextEventModEq;
  TGLabel               *fTextEventLabel1, *fTextEventLabel2, *fTextEventLabel3;

#ifdef MOVIE_VER
  TGTextButton          *fBottomMovie;
#endif

  Pixel_t               green, gray;

  enum bottomIDS {
    BOTTOM_MOVIE, BOTTOM_PAUSE, BOTTOM_AUTOUPDATE, BOTTOM_AUTORESET, 
    BOTTOM_UPDATE, BOTTOM_RESET, BOTTOM_CLONE, BOTTOM_KILL, BOTTOM_SCREENSHOT, SCREENSHOT2,
    BOTTOM_TRIGMASK, TRIGMASK2, 
    TEXT_EVENTMOD, TEXT_EVENTMODEQ
  };

  ClassDef(TMDisplaying, 0)
};

#endif
