Index: trunk/MagicSoft/Mars/mdatacheck/MGDisplayAdc.cc
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MGDisplayAdc.cc	(revision 749)
+++ trunk/MagicSoft/Mars/mdatacheck/MGDisplayAdc.cc	(revision 958)
@@ -26,148 +26,235 @@
 #include "MGDisplayAdc.h"
 
+#include <iostream.h>            // cout for debugging
+
 #include <TGButton.h>            // TGTextButton
 #include <TCanvas.h>             // TCanvas.h
 #include <TGMsgBox.h>            // TGMsgBox
+#include <TGListBox.h>           // TGListBox
+#include <TGSlider.h>            // TGVSlider
+#include <TGButtonGroup.h>       // TGVButtonGroup
 #include <TRootEmbeddedCanvas.h> // TRootEmbeddedCanvas
 
-enum ComIdentDisplayAdc {
-	M_BUTTON_SAVE,
-		M_BUTTON_PRINT,
-		M_BUTTON_PRINTALL,
-		M_BUTTON_CLOSE , 
-		
-		M_BUTTON_PREV, 
-		M_BUTTON_NEXT,
-
-		M_LIST_HISTO,
-		M_RADIO_HIGH,
-		M_RADIO_LOW,
-		M_RADIO_LH,
-		M_BUTTON_RESET,
-		M_VSId1
-} ; 
-
-MGDisplayAdc::MGDisplayAdc ( MHFadcCam *histos,
-			    const TGWindow *p, const TGWindow *main, 
-			    UInt_t w, UInt_t h, 
-			    UInt_t options) 
-	: TGTransientFrame(p, main, w, h, options ) 
-{
-    //
-    //   default constructor
-    //
-
-    //
-    // NEVER try to delete them in the destructor!
-    //
-    fHists = histos ;
-
-    //
-    //   the top frame for the list and some buttons and the Canvas
-    //
-    fFrameTop = new TGHorizontalFrame (this, 60,20,  kFitWidth ) ;
-
-    //
-    //    left part of top frame
-    //
-    fFT1 =  new TGVerticalFrame (fFrameTop, 80,300,  kFitWidth ) ;
-
-    fHistoList = new TGListBox ( fFT1, M_LIST_HISTO ) ;
-    fHistoList->Associate( this ) ;
-    fFT1->AddFrame ( fHistoList, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 10, 10 ) )  ;
-	
-    fHistoList->Resize(80, 405 ) ;
-
-    fFrameTop->AddFrame (fFT1, new TGLayoutHints ( kLHintsTop , 10, 10, 10, 10 ) ) ;
+#include "MHFadcCam.h"
+
+enum ComIdentDisplayAdc
+{
+    M_BUTTON_SAVE,
+    M_BUTTON_PRINT,
+    M_BUTTON_PRINTALL,
+    M_BUTTON_CLOSE,
+
+    M_BUTTON_PREV,
+    M_BUTTON_NEXT,
+
+    M_LIST_HISTO,
+    M_RADIO_HI,
+    M_RADIO_LO,
+    M_RADIO_LH,
+    M_BUTTON_RESET,
+    M_VSId1
+};
+
+void MGDisplayAdc::AddFrameTop(TGHorizontalFrame *frame)
+{
+    //
+    // left part of top frame
+    //
+    TGVerticalFrame *left = new TGVerticalFrame(frame, 80, 300, kFitWidth);
+    fList->Add(left);
+
+    fHistoList = new TGListBox (left, M_LIST_HISTO);
+    fHistoList->Associate(this);
+    fHistoList->Resize(80, 405);
+
+    fList->Add(fHistoList);
+
+    TGLayoutHints *laylist = new TGLayoutHints(kLHintsNormal, 10, 10, 10, 10);
+    fList->Add(laylist);
+
+    left->AddFrame(fHistoList, laylist);
 
     //
     //    middle part of top frame
     //
-    fFT2 =  new TGVerticalFrame (fFrameTop, 80,20,  kFitWidth ) ;
-
-    fButtonPrev = new TGTextButton ( fFT2, "Prev Histo", M_BUTTON_PREV ) ;
-    fButtonPrev->Associate (this) ;
-    fFT2->AddFrame ( fButtonPrev, new TGLayoutHints (kLHintsLeft | kLHintsTop,10, 10, 0, 10 ) )  ;
-
-
-    fVslider1 = new TGVSlider (fFT2, 250, kSlider1 | kScaleBoth, M_VSId1);
-
-    fVslider1->Associate(this);
-    fVslider1->SetRange(0, 576);
-    fFT2->AddFrame(fVslider1);
-
-    fButtonNext = new TGTextButton ( fFT2, "Next Histo", M_BUTTON_NEXT ) ;
-    fButtonNext->Associate (this) ;
-    fFT2->AddFrame ( fButtonNext, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 10, 5 ) )  ;
-
-    fFrameTop->AddFrame (fFT2, new TGLayoutHints ( kLHintsTop , 10, 10, 10, 10 ) ) ;
-
-    //
-    // Radio buttons, used to select the high, low anh high/low display
-    //
-    fRadio[0] = new  TGRadioButton(fFT2, "&High Gain", M_RADIO_HIGH);
-    fFT2->AddFrame ( fRadio[0], new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 10, 5 ) )  ;
-    fRadio[0]->Associate(this);
-    fRadio[0]->SetState(kButtonDown);
-    fHistoLock = kFALSE;
-    fHistoType=1;
-
-    fRadio[1] = new  TGRadioButton(fFT2, "&Low Gain", M_RADIO_LOW);
-    fFT2->AddFrame ( fRadio[1], new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 10, 5 ) )  ;
-    fRadio[1]->Associate(this);
-
-    fRadio[2] = new  TGRadioButton(fFT2, "H&igh/Low Gain", M_RADIO_LH);
-    fFT2->AddFrame ( fRadio[2], new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 10, 5 ) )  ;
-    fRadio[2]->Associate(this);
+    TGVerticalFrame *mid = new TGVerticalFrame(frame, 80, 20, kFitWidth);
+    fList->Add(mid);
+
+    // ---
+
+    TGTextButton *prev = new TGTextButton(mid, "Prev Histo", M_BUTTON_PREV);
+    TGTextButton *next = new TGTextButton(mid, "Next Histo", M_BUTTON_NEXT);
+    prev->Associate(this);
+    next->Associate(this);
+
+    fList->Add(prev);
+    fList->Add(next);
+
+    // ---
+
+    fSlider = new TGVSlider(mid, 250, kSlider1|kScaleBoth, M_VSId1);
+    fSlider->Associate(this);
+    fSlider->SetRange(1, 577);
+
+    fList->Add(fSlider);
+
+    // ---
+
+    TGVButtonGroup *group = new TGVButtonGroup(mid);
+    fList->Add(group);
+
+    TGRadioButton *radio1 = new TGRadioButton(group, "&High Gain",     M_RADIO_HI);
+    TGRadioButton *radio2 = new TGRadioButton(group, "&Low Gain",      M_RADIO_LO);
+    TGRadioButton *radio3 = new TGRadioButton(group, "H&igh/Low Gain", M_RADIO_LH);
+
+    /* FIXME:
+
+    ~TGRadioButton calls TGRadioButton::TGFrame::GetMainFrame
+    which calles fParent->GetFrame()
+
+    fList->Add(radio1);
+    fList->Add(radio2);
+    fList->Add(radio3);
+    */
+
+    radio1->SetState(kButtonDown);
+
+    radio1->Associate(this);
+    radio2->Associate(this);
+    radio3->Associate(this);
+
+    // ---
+
+    TGLayoutHints *laybut1 = new TGLayoutHints(kLHintsNormal, 10, 10,  0, 10);
+    TGLayoutHints *laybut2 = new TGLayoutHints(kLHintsNormal, 10, 10, 10,  5);
+
+    fList->Add(laybut1);
+    fList->Add(laybut2);
+
+    mid->AddFrame(prev,   laybut1);
+    mid->AddFrame(fSlider);
+    mid->AddFrame(next,   laybut2);
+    mid->AddFrame(group,  laybut2);
 
     //
     //    right part of top frame
     //
-    fFT3 =  new TGVerticalFrame (fFrameTop, 60, 60,  kFitWidth ) ;
-
-    fECanv = new TRootEmbeddedCanvas("fECanv", fFT3, 400, 400 ) ;
-
-    fFT3->AddFrame( fECanv, new TGLayoutHints ( kLHintsCenterX | kLHintsCenterY | kLHintsExpandX | kLHintsExpandY , 10, 10, 10, 10 ) ) ;
-
-    //
-    //the button for reseting the histogram
-    //
-    fButtonReset = new TGTextButton ( fFT3, "Reset histo", M_BUTTON_RESET ) ;
-    fButtonReset->Associate (this) ;
-    fFT3->AddFrame ( fButtonReset, new TGLayoutHints (kLHintsCenterX | kLHintsTop,10, 10, 0, 10 ) )  ;
-	
-    fCanv = fECanv->GetCanvas() ;
-
-    fFrameTop->AddFrame (fFT3, new TGLayoutHints ( kLHintsCenterX | kLHintsCenterY | kLHintsExpandX | kLHintsExpandY , 10, 10, 10, 10 ) ) ;
-
-    AddFrame ( fFrameTop, new TGLayoutHints ( kLHintsTop | kLHintsExpandX , 10, 10, 10, 10 ) ) ;
-
+    TGVerticalFrame *right = new TGVerticalFrame(frame, 60, 60, kFitWidth);
+    fList->Add(right);
+
+    TRootEmbeddedCanvas *canvas = new TRootEmbeddedCanvas("fECanv", right, 800, 400);
+    fList->Add(canvas);
+
+    TGLayoutHints *laycanv = new TGLayoutHints(kLHintsCenterX|kLHintsCenterY|kLHintsExpandX|kLHintsExpandY, 10, 10, 10, 10);
+    fList->Add(laycanv);
+
+    right->AddFrame(canvas, laycanv);
+
+
+    TGTextButton *reset = new TGTextButton(right, "Reset histo", M_BUTTON_RESET);
+    reset->Associate(this);
+    fList->Add(reset);
+
+    TGLayoutHints *layreset = new TGLayoutHints(kLHintsCenterX|kLHintsTop,10, 10, 0, 10);
+    fList->Add(layreset);
+
+    right->AddFrame(reset, layreset);
+
+    // ---
+
+    fCanvas = canvas->GetCanvas();
+
+    //
+    // layout the three subframes
+    //
+    TGLayoutHints *layframe1 = new TGLayoutHints(kLHintsTop, 10, 10, 10, 10);
+    TGLayoutHints *layframe2 = new TGLayoutHints(kLHintsCenterX|kLHintsCenterY|kLHintsExpandX|kLHintsExpandY, 10, 10, 10, 10);
+    fList->Add(layframe1);
+    fList->Add(layframe2);
+
+    frame->AddFrame(left,  layframe1);
+    frame->AddFrame(mid,   layframe1);
+    frame->AddFrame(right, layframe2);
+}
+
+void MGDisplayAdc::AddFrameLow(TGHorizontalFrame *frame)
+{
     //
     //   the low frame for the control buttons
     //
-    fFrameLow = new TGHorizontalFrame (this, 60,20, kFixedWidth ) ;
-
-    fButtonSave = new TGTextButton ( fFrameLow, "Save", M_BUTTON_SAVE ) ;
-    fButtonSave->Associate (this) ;
-    fFrameLow->AddFrame ( fButtonSave, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 5, 5 ) )  ;
-
-    fButtonPrint = new TGTextButton ( fFrameLow, "Print", M_BUTTON_PRINT ) ;
-    fButtonPrint->Associate (this) ;
-    fFrameLow->AddFrame ( fButtonPrint, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 5, 5 ) )  ;
-
-    fButtonPrintAll = new TGTextButton ( fFrameLow, "PrintAll", M_BUTTON_PRINTALL ) ;
-    fButtonPrintAll->Associate (this) ;
-    fFrameLow->AddFrame ( fButtonPrintAll, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 5, 5 ) )  ;
-  
-    fButtonClose = new TGTextButton ( fFrameLow, "Close", M_BUTTON_CLOSE ) ;
-    fButtonClose->Associate (this) ;
-    fFrameLow->AddFrame ( fButtonClose, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 5, 5 ) )  ;
-    AddFrame ( fFrameLow, new TGLayoutHints ( kLHintsBottom | kLHintsExpandX , 10, 10, 10, 10 ) ) ;
-	
-    //
-    //
-    //
-    BuildHistoList() ;
-
+    TGTextButton *but1 = new TGTextButton(frame, "Save",     M_BUTTON_SAVE);
+    TGTextButton *but2 = new TGTextButton(frame, "Print",    M_BUTTON_PRINT);
+    TGTextButton *but3 = new TGTextButton(frame, "PrintAll", M_BUTTON_PRINTALL);
+    TGTextButton *but4 = new TGTextButton(frame, "Close",    M_BUTTON_CLOSE);
+
+    but1->Associate(this);
+    but2->Associate(this);
+    but3->Associate(this);
+    but4->Associate(this);
+
+    fList->Add(but1);
+    fList->Add(but2);
+    fList->Add(but3);
+    fList->Add(but4);
+
+    TGLayoutHints *laybut = new TGLayoutHints(kLHintsNormal, 10, 10, 5, 5);
+    fList->Add(laybut);
+
+    frame->AddFrame(but1, laybut);
+    frame->AddFrame(but2, laybut);
+    frame->AddFrame(but3, laybut);
+    frame->AddFrame(but4, laybut);
+}
+
+MGDisplayAdc::MGDisplayAdc(MHFadcCam *histos,
+                           const TGWindow *p, const TGWindow *main,
+                           UInt_t w, UInt_t h,
+                           UInt_t options)
+: TGTransientFrame(p, main, w, h, options), fHists(histos), fHistoType(M_RADIO_HI)
+{
+    fList = new TList;
+    fList->SetOwner();
+
+    //
+    // Create the to frames
+    //
+    TGHorizontalFrame *frametop = new TGHorizontalFrame(this, 60, 20, kFitWidth);
+    TGHorizontalFrame *framelow = new TGHorizontalFrame(this, 60, 20, kFixedWidth);
+
+    //
+    // Add frames to 'autodel'
+    //
+    fList->Add(frametop);
+    fList->Add(framelow);
+
+    //
+    // Add the gui elements to the two frames
+    //
+    AddFrameTop(frametop);
+    AddFrameLow(framelow);
+
+    //
+    // layout the two frames in this frame
+    //
+    TGLayoutHints *laytop = new TGLayoutHints(kLHintsTop|kLHintsExpandX,    10, 10, 10, 10);
+    TGLayoutHints *laylow = new TGLayoutHints(kLHintsBottom|kLHintsExpandX, 10, 10, 10, 10);
+
+    AddFrame(frametop, laytop);
+    AddFrame(framelow, laylow);
+
+    //
+    // Setup interieur
+    //
+    BuildHistoList();
+
+    //
+    // Here the initial display is set to hitogram 0
+    //
+    fHistoList->Select(1);
+    UpdateHist();
+
+    //
+    // Setup frame
+    //
     MapSubwindows();
 
@@ -176,14 +263,4 @@
     SetWindowName("ADC Spectra");
     SetIconName("ADC Spectra");
-
-    //
-    // Here the initial display is set to hitogram 0
-    //
-    fHistoList->Select(1, kTRUE);
-    DrawSelectedHi() ;
-    SetSelectedTopEntry();
-    fCanv->Modified() ;
-    fCanv->Update() ;
-    SetSelectedPos();
 
     MapWindow();
@@ -191,51 +268,27 @@
 }  
 
-MGDisplayAdc::~MGDisplayAdc ()
+MGDisplayAdc::~MGDisplayAdc()
 { 
-    delete fButtonSave ;
-    delete fButtonPrint ; 
-    delete fButtonPrintAll ; 
-    delete fButtonClose ; 
-    
-    delete fButtonPrev; 
-    delete fButtonNext ; 
-    delete fButtonReset ;
-    
-    delete fVslider1; 
-    delete fECanv ;
-    
-    delete fHistoList ;
-    delete fRadio[2];
-    delete fRadio[1];
-    delete fRadio[0]; 
-    delete fFT1 ; 
-    delete fFT2 ; 
-    delete fFT3 ; 
-    delete fFrameLow ; 
-    delete fFrameTop ; 
+    delete fList;
 }  
+
+// ======================================================================
+
+void MGDisplayAdc::CloseWindow()
+{
+    // Got close message for this MainFrame. Calls parent CloseWindow()
+    // (which destroys the window) and terminate the application.
+    // The close message is generated by the window manager when its close
+    // window menu item is selected.
+    //
+    delete this;
+}
+
+
 
 // ======================================================================
 // ======================================================================
 
-void MGDisplayAdc::CloseWindow()
-{
-  // Got close message for this MainFrame. Calls parent CloseWindow()
-  // (which destroys the window) and terminate the application.
-  // The close message is generated by the window manager when its close
-  // window menu item is selected.
-  // 
-  delete this ; 
-  //  TGTransientFrame::CloseWindow();
-  //  TGMainFrame::CloseWindow();
-  //   gROOT->GetApplication()->Terminate(0)  ; 
-}
-
-
-
-// ======================================================================
-// ======================================================================
-
-Bool_t MGDisplayAdc::BuildHistoList(Int_t type ) 
+Bool_t MGDisplayAdc::BuildHistoList()
 {
     //
@@ -248,17 +301,55 @@
     //   to plot the low gain
     //
-
     const Int_t nhi = fHists->GetEntries();
-    for ( Int_t i=0 ; i < nhi; i++ ) {
-        fHistoList->AddEntry(fHists->GetHistHi(i)->GetName(), i+1) ;
-    }
-
-    fHistoList->MapSubwindows() ;
-    fHistoList->Layout() ;
-    return kTRUE ;
+    for (Int_t i=0 ; i<nhi; i++)
+        fHistoList->AddEntry(fHists->GetHistHi(i)->GetName(), i+1);
+
+    fHistoList->MapSubwindows();
+    fHistoList->Layout();
+
+    return kTRUE;
 } 
 
 // ======================================================================
 // ======================================================================
+void MGDisplayAdc::UpdateHist()
+{
+    const Int_t selected = fHistoList->GetSelected();
+
+    fHistoList->Select(selected); // ???
+
+    fCanvas->Clear();
+
+    switch (fHistoType)
+    {
+    case M_RADIO_HI:
+    case M_RADIO_LO:
+        fCanvas->Divide(1, 1);
+
+        fCanvas->cd();
+        if (fHistoType==M_RADIO_HI)
+            fHists->DrawHi(selected-1);
+        else
+            fHists->DrawLo(selected-1);
+        break;
+
+    case M_RADIO_LH:
+        fCanvas->Divide(1, 2);
+
+        fCanvas->cd(1);
+        fHists->DrawHi(selected-1);
+
+        fCanvas->cd(2);
+        fHists->DrawLo(selected-1);
+        break;
+    }
+
+    fHistoList->SetTopEntry(selected);
+
+    fCanvas->Modified();
+    fCanvas->Update();
+
+    fSlider->SetPosition(selected);
+}
 
 Bool_t MGDisplayAdc::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
@@ -267,12 +358,4 @@
     // Process events generated by the buttons in the frame.
     //
-    Int_t   buttons = 4, retval = 0 ;
-    //Char_t  wort[100] ;
-    //Char_t  extens[5] ;
-    //Char_t  command[110] ;
-
-    //TGFileItem *item ;     // to process items in the file view container
-    //void *np = NULL ;      // null pointer
-
     switch (GET_MSG(msg))
     {
@@ -281,206 +364,70 @@
         {
         case kCM_BUTTON:
-
             switch (parm1)
             {
             case M_BUTTON_SAVE:
-                new TGMsgBox(fClient->GetRoot(), this,
-                             "WARNING!",
-                             "Not implemented yet.",
-                             kMBIconExclamation, buttons, &retval);
-                break ;
+                cout << "Sorry, not yet implemented!" << endl;
+                return kTRUE;
 
             case M_BUTTON_PRINT:
-                break;
+                cout << "Sorry, not yet implemented!" << endl;
+                return kTRUE;
 
             case M_BUTTON_RESET:
-                new TGMsgBox(fClient->GetRoot(), this,
-                             "WARNING!",
-                             "Not implemented yet.",
-                             kMBIconExclamation, buttons, &retval);
-                break;
+                cout << "Sorry, not yet implemented!" << endl;
+                return kTRUE;
 
             case M_BUTTON_CLOSE:
-                CloseWindow() ;
-                break ;
-
-                // The selection for "Next Histogram".
-                // There is also a link for the sicronisation with the slider
-                //
+                CloseWindow();
+                return kTRUE;
+
             case M_BUTTON_PREV:
             case M_BUTTON_NEXT:
-                if ((parm1==M_BUTTON_PREV && GetSelected()-1 > 0) ||
-                    (parm2==M_BUTTON_NEXT && GetSelected()-1 < 576))
                 {
-                    if (fHistoLock == kTRUE )
-                    {
-                        fCanvas->cd(1);
-                        SelectSelected();
-                        DrawSelectedHi() ;
-                        fCanvas->cd(2);
-                        DrawSelectedLo() ;
-                    }
-                    else
-                    {
-                        fCanv->cd();
-                        SelectSelected();
-                        DrawSelectedHi() ;
-
-                    }
-                    SetSelectedTopEntry();
-                    fCanv->Modified() ;
-                    fCanv->Update() ;
-                    SetSelectedPos();
-
+                    const Int_t selected = fHistoList->GetSelected();
+
+                    if ((parm1==M_BUTTON_PREV && selected==1) ||
+                        (parm1==M_BUTTON_NEXT && selected==577))
+                        return kTRUE;
+
+                    fHistoList->Select(parm1==M_BUTTON_PREV ? selected-1 : selected+1);
+                    UpdateHist();
                 }
-                if (fRadio[1]->GetState() != kButtonDown)
-                    break;
-
-                fRadio[0]->SetState(kButtonDown);
-                fRadio[1]->SetState(kButtonUp);
-                break;
-
-            default:
-                break ;
+                return kTRUE;
             }
-            break;
+            return kTRUE;
 
         case kCM_RADIOBUTTON:
-
             switch(parm1)
             {
-            case M_RADIO_HIGH:
-            case M_RADIO_LOW:
-                if (parm1 == M_RADIO_HIGH)
-                {
-                    fRadio[1]->SetState(kButtonUp);
-                    fRadio[2]->SetState(kButtonUp);
-                    fHistoType=1;
-                }
-                else
-                {
-                    fRadio[0]->SetState(kButtonUp);
-                    fRadio[2]->SetState(kButtonUp);
-                    fHistoType = 2;
-                }
-                fHistoLock = kFALSE;
-
-                fCanv->cd();
-                SelectSelected();
-                parm1 == M_RADIO_HIGH ? DrawSelectedHi() : DrawSelectedLo();
-
-                SetSelectedTopEntry();
-                fCanv->Modified() ;
-                fCanv->Update() ;
-                SetSelectedPos();
-                break;
-				
+            case M_RADIO_HI:
+            case M_RADIO_LO:
             case M_RADIO_LH:
-                fRadio[0]->SetState(kButtonUp);
-                fRadio[1]->SetState(kButtonUp);
-
-                if (fHistoLock == kFALSE)
-                {
-                    fCanvas = fECanv->GetCanvas();
-                    fCanvas->Divide(1,2, 0, 0 ,0);
-
-                    fCanv->Modified() ;
-                    fCanv->Update() ;
-                    fHistoLock = kTRUE;
-                    fHistoType = 3;
-                }
-
-                fCanvas->cd(1);
-
-                SelectSelected();
-                DrawSelectedHi() ;
-                SetSelectedTopEntry();
-
-                fCanvas->cd(2);
-                SelectSelected();
-                DrawSelectedLo() ;
-                SetSelectedTopEntry();
-
-                fCanv->Modified() ;
-                fCanv->Update();
-
-            default:
-                break;
+                fHistoType = parm1;
+                UpdateHist();
+                return kTRUE;
             }
-            break;
+            return kTRUE;
         }
 		
     case kCM_LISTBOX:
-        if (GET_SUBMSG(msg) != M_LIST_HISTO)
-            break;
-
-        if (fHistoLock == kTRUE )
-        {
-            fCanvas->cd(1);
-            DrawSelectedHi() ;
-            fCanvas->cd(2);
-            DrawSelectedLo() ;
-        }
-        else
-        {
-            fCanv->cd() ;
-            DrawSelectedHi() ;
-        }
-        fCanv->Modified() ;
-        fCanv->Update() ;
-        SetSelectedPos();
-        break ;
-
-/*
-    case kC_CONTAINER:
-        switch (GET_SUBMSG(msg))
-        {
-
-        case kCT_ITEMDBLCLICK:
-            break;
-
-        default:
-            break ;
-        }
-*/
+        if (GET_SUBMSG(msg) == M_LIST_HISTO)
+            UpdateHist();
+
+        return kTRUE;
 
     case kC_VSLIDER:
         if (GET_SUBMSG(msg)!=kSL_POS || parm1!=M_VSId1)
-            break;
+            return kTRUE;
 
         // Check for the slider movement and sicronise with TGListBox
-        if (parm2<0 || parm2>576)
-            break;
-
-        if (fHistoLock==kTRUE)
-        {
-            fCanvas->cd(1) ;
-            DrawHi(parm2) ;
-            fHistoList->Select(parm2+1, kTRUE);
-
-            fCanvas->cd(2) ;
-            DrawLo(parm2) ;
-        }
-        else
-        {
-            fCanv->cd() ;
-            DrawHi(parm2) ;
-        }
-
-        fHistoList->Select(parm2+1, kTRUE);
-        SetSelectedTopEntry();
-
-        fCanv->Modified() ;
-        fCanv->Update() ;
-
-        if (fRadio[1]->GetState() != kButtonDown)
-            break;
-
-        fRadio[0]->SetState(kButtonDown);
-        fRadio[1]->SetState(kButtonUp);
-
-        break;
-
+        if (parm2<1 || parm2>577)
+            return kTRUE;
+
+        fHistoList->Select(parm2);
+        UpdateHist();
+        return kTRUE;
     }
+
     return kTRUE;
 }
