GUI/TFndBaseMonGUI.h

00001 // @(#)fROOT/GUI:$Name:  $:$Id: TFndBaseMonGUI.h,v 1.16 2007/08/29 15:39:25 Diego_Faso Exp $
00002 // Author: Diego Faso <mailto:faso@to.infn.it>, 2006/11/22
00003 
00004 #ifndef FROOT_TFndBaseMonGUI
00005 #define FROOT_TFndBaseMonGUI
00006 
00007 // --- ROOT GUI includes
00008 #ifndef ROOT_TGNumberEntry
00009 #include "TGNumberEntry.h"
00010 #endif
00011 #ifndef ROOT_TGComboBox
00012 #include "TGComboBox.h"
00013 #endif
00014 #ifndef ROOT_TGFrame
00015 #include "TGFrame.h"
00016 #endif
00017 #ifndef ROOT_TGCanvas
00018 #include "TGCanvas.h"
00019 #endif
00020 #ifndef ROOT_TGButton
00021 #include "TGButton.h"
00022 #endif
00023 #ifndef ROOT_TGTextEdit
00024 #include "TGTextEdit.h"
00025 #endif
00026 #ifndef ROOT_TGLabel
00027 #include "TGLabel.h"
00028 #endif
00029 #ifndef ROOT_TRootCanvas
00030 #include "TRootCanvas.h"
00031 #endif
00032 #ifndef ROOT_TGStatusBar
00033 #include "TGStatusBar.h"
00034 #endif
00035 #ifndef ROOT_TRootEmbeddedCanvas
00036 #include "TRootEmbeddedCanvas.h"
00037 #endif
00038 #ifndef ROOT_TCanvas
00039 #include "TCanvas.h"
00040 #endif
00041 // ---
00042 
00043 #include "TFrame.h"
00044 
00045 #include "Riostream.h"
00046 
00047 // --- FROOT includes
00048 #include "FROOT.h"
00049 #include "Gui.h"
00050 
00052 //                  TFndBaseMonGUI                 //
00053 //                                                 //
00054 // This is a general (virtual) implementation for  //
00055 //  monitor GUI applications.                      //
00056 // User must define a daughter class and add       //
00057 //  every needed method.                           //
00058 // In particular a "AdjustGui()" method could be   //
00059 //  used to change labels, positions.              //
00060 //                                                 //
00061 // "ResetDaughter()" must be defined in daughters  //
00062 //                                                 //
00063 // Standard daughter class implementation:         //
00064 //   (TFndMonGUI: public TFndBaseMonGUI)           //
00065 //                                                 //
00066 //   TFndMonGUI *MonGui = new TFndMonGUI();        //
00067 //   MonGui->BuildGUI();                           //
00068 //   MonGui->AdjustGUI();                          //
00069 //   MonGui->MakeConnections();                    //
00070 //   MonGui->MapGUI();                             //
00071 //                                                 //
00073 
00074 using namespace FROOT;
00075 
00076 class TFndBaseMonGUI: public TObject{
00077 
00078 protected:
00079 
00080   Int_t fDebugLev; // debug level: 0,1,2,3
00081 
00082   // --- FONTS
00083   TString fFontType;
00084   UInt_t fFontSize;
00085   TString fFontISO;
00086   TString fFontString;
00087 
00088   TGFont *fFont_Title;
00089   TGGC   *fFontGC_Title;
00090 
00091   TGFont *fFont_GrpTitle;
00092   TGGC   *fFontGC_GrpTitle;
00093 
00094   TGFont *fFont_LabNorm; // label normal font
00095   TGGC   *fFontGC_LabNorm;
00096   TGFont *fFont_LabEnl; // label enlightened font
00097   TGGC   *fFontGC_LabEnl;
00098 
00099   TGFont *fFont_But; // buttons font
00100   TGGC   *fFontGC_But;
00101   // ---
00102 
00103   // --- GUI elements
00104   TGMainFrame *fMainFrame;   
00105 
00106   // Container Level: 0->Main -> 1 -> 2
00107   TGVerticalFrame *fVertFrm_CL1; // CL1 means: ContainerLevel: 1
00108   TGHorizontalFrame *fHorFrm_CL2; // CL1 means: ContainerLevel: 2
00109   
00110   TRootEmbeddedCanvas *fShowEmbeddedCanvas;
00111   /*   TGLRenderArea *fGLInfoRegArea; */
00112   /*   TGLWindow *fGLInfoRegWindow; */
00113   TCanvas *fShowCanvas;
00114 
00115   // group frame for STEERING commands
00116   TGGroupFrame *fGrpFrm_SteerCmd;
00117 
00118   TGLabel *fSteer_Combo_Lbl;
00119   TGComboBox *fSteer_Combo; 
00120 
00121   TGLabel *fSteer_Num1_Lbl;
00122   TGNumberEntry *fSteer_Num1;
00123 
00124   TGLabel *fSteer_Num2_Lbl;
00125   TGNumberEntry *fSteer_Num2;
00126 
00127   TGTextButton *fSteer_But1;
00128   TGTextButton *fSteer_But2;
00129 
00130   // group frame for SELECTION commands
00131   TGGroupFrame *fGrpFrm_SelectCmd;
00132 
00133   TGLabel *fSel_Combo1_Lbl;
00134   TGComboBox *fSel_Combo1;
00135 
00136   TGLabel *fSel_Combo2_Lbl;
00137   TGComboBox *fSel_Combo2;
00138 
00139   // group frame for messages
00140   TGGroupFrame *fGrpFrm_Msg;
00141   TGTextEdit *fMsg_TxtEdit;
00142 
00143   TGStatusBar *fStatBar1; // main status bar
00144   
00145   ofstream *fCurLogFile; 
00146   ofstream *fCurTmpFile; 
00147   TString fCurTmpFileName; // temporary file name  
00148 
00149  private:
00150   virtual void LoadFonts(); // standard fonts used for GUI elements
00151   
00152  public:
00153   TFndBaseMonGUI();
00154   ~TFndBaseMonGUI();
00155   void SetDebugLevel(Int_t deb_lev) { fDebugLev = deb_lev; }
00156 
00157   void BuildBaseGUI();
00158   
00159   virtual void BuildGUI()
00160     { // can be re-defined in daughters
00161       BuildBaseGUI(); // must be called in virtual implementation
00162     }
00163   
00164   virtual void CustomizeGUI();
00165   
00166   virtual void MapGUI();  // can be re-defined in daughters
00167   virtual void CloseGUI();  // can be re-defined in daughters
00168   
00169   virtual Bool_t MakeConnections(Bool_t Connect = kTRUE);  // can be re-defined in daughters
00170   
00171   void SetFontType(TString ftype);
00172   void SetFontSize(Float_t fsize);
00173   
00174   virtual void UpdateDisplayPad();
00175   virtual void ResetDisplayPad(Int_t ncols=0,Int_t nraws=0);
00176   
00177   virtual void FillCombo_Steer();
00178   virtual void FillCombo_Sel1();
00179   virtual void FillCombo_Sel2();
00180   
00181   virtual void Exe_SteerCombo(Int_t id);
00182   virtual void Exe_SelCombo1(Int_t id);
00183   virtual void Exe_SelCombo2(Int_t id);
00184   
00185   virtual void WriteStatusMessage(const TString &msg,Int_t partidx=0);
00186   
00187   // --- facilities and adds-on
00188   virtual void SetBackgroundColor(const Int_t &col);
00189   
00190   // --- log-file support (used by the info frame)
00191   virtual void OpenLogFile(const TString &fdir, const TString &fnam,const Bool_t &is_temp,const Bool_t &reset_old);
00192   virtual void CloseLogFile(const Bool_t &is_temp);
00193   virtual void WriteLogFile(const TString &line,const Bool_t &is_temp);
00194  
00195   virtual void SetTmpFilename(const TString &nam) { fCurTmpFileName = nam; };
00196 
00197   virtual void ResetTextMessage()
00198     {
00199       AddTextMessage("",kTRUE); 
00200     }
00201   virtual void AddTextMessage(const TString &msg,Bool_t reset=kFALSE,Bool_t refresh=kTRUE); // add text to the msg frame
00202   virtual Int_t WriteTextEdit(const TString &txt_filename);
00203   
00204   virtual void HandleMouseActions(Int_t event, Int_t x, Int_t y, TObject *selected);
00205   
00206   virtual void HandleMouseActionsDaughter(Int_t event, Int_t x, Int_t y, TObject *selected) = 0;
00207   virtual void ResetDaughter() = 0;
00208 
00209   ClassDef(TFndBaseMonGUI,0) // base (virtual) class for monitoring GUI applications
00210 };
00211 
00212 
00216 //                                           //
00217 //        TRANSIENT PROGRESS CLASS           //
00218 //                                           //
00222 #include "TGProgressBar.h"
00223 
00224 using namespace Gui;
00225 class TFndGTransientProgress : public TGMainFrame{
00226   
00227  protected:
00228   TGVerticalFrame *fFrmVert;
00229   TGStatusBar *fStatBar;
00230   TGHProgressBar *fPrgBar;
00231   TGLabel *fLblTitle;
00232   TGTextButton *fTxtButCancel;
00233   
00234   Bool_t fIsCancelled;
00235   void BuildGUI();
00236   void MakeConnections();
00237   void DisplayGUI();
00238   
00239  public:
00240   TFndGTransientProgress();
00241   ~TFndGTransientProgress();
00242   
00243   void UpdateGUI();
00244   
00245   void DoCancel();
00246   
00247   void SetTitle(const TString &tit);
00248   void ReSetStatusMessage(TString msg="");
00249   void SetProgressBar(const Float_t &pos_perc);  // set position [%]
00250   void SetProgressBar(const Float_t &current,const Float_t &total);
00251   
00252   Bool_t IsCancelled() { return fIsCancelled; }
00253 
00254   //  friend class TFndBaseMonGUI;
00255   
00256   ClassDef(TFndGTransientProgress,1)
00257     };
00258     
00259 #endif //FROOT_TFndBaseMonGUI
00260     

Generated on Tue Oct 16 15:40:46 2007 by  doxygen 1.5.2