// @(#)root/gui:$Id$
// Author: Fons Rademakers   10/01/98

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/
/**************************************************************************

    This source is based on Xclass95, a Win95-looking GUI toolkit.
    Copyright (C) 1996, 1997 David Barth, Ricky Ralston, Hector Peraza.

    Xclass95 is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

**************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGScrollBar and TGScrollBarElement                                   //
//                                                                      //
// The classes in this file implement scrollbars. Scrollbars can be     //
// either placed horizontal or vertical. A scrollbar contains three     //
// TGScrollBarElements: The "head", "tail" and "slider". The head and   //
// tail are fixed at either end and have the typical arrows in them.    //
//                                                                      //
// The TGHScrollBar will generate the following event messages:         //
// kC_HSCROLL, kSB_SLIDERPOS, position, 0                               //
// kC_HSCROLL, kSB_SLIDERTRACK, position, 0                             //
//                                                                      //
// The TGVScrollBar will generate the following event messages:         //
// kC_VSCROLL, kSB_SLIDERPOS, position, 0                               //
// kC_VSCROLL, kSB_SLIDERTRACK, position, 0                             //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "TGScrollBar.h"
#include "TGResourcePool.h"
#include "TGPicture.h"
#include "TImage.h"
#include "TSystem.h"
#include "TTimer.h"
#include "TEnv.h"
#include "Riostream.h"


Pixmap_t TGScrollBar::fgBckgndPixmap = 0;
Int_t    TGScrollBar::fgScrollBarWidth = kDefaultScrollBarWidth;

ClassImp(TGScrollBarElement)
ClassImp(TGScrollBar)
ClassImp(TGHScrollBar)
ClassImp(TGVScrollBar)


//______________________________________________________________________________
class TSBRepeatTimer : public TTimer {
private:
   TGScrollBar   *fScrollBar;   // scroll bar
   Int_t          fSmallInc;    // step
public:
   TSBRepeatTimer(TGScrollBar *s, Long_t ms, Int_t inc) : TTimer(ms, kTRUE)
      { fScrollBar = s;  fSmallInc = inc; }

   Bool_t Notify();
   Int_t  GetSmallInc() const { return fSmallInc; }
};

//______________________________________________________________________________
Bool_t TSBRepeatTimer::Notify()
{
   // Notify when timer times out and reset the timer.

   fScrollBar->HandleTimer(this);
   Reset();
   return kFALSE;
}

//______________________________________________________________________________
TGScrollBarElement::TGScrollBarElement(const TGWindow *p, const TGPicture *pic,
                                       UInt_t w, UInt_t h, UInt_t options, Pixel_t back) :
                                       TGFrame(p, w, h, options | kOwnBackground, back)
{
   // Constructor.

   fPic = fPicN = pic;
   fState = kButtonUp;
   fPicD = 0;
   fStyle = 0;
   if (p && p->InheritsFrom("TGScrollBar"))
      fStyle = gClient->GetStyle();

   fBgndColor = fBackground;
   fHighColor = gClient->GetResourcePool()->GetHighLightColor();
   AddInput(kEnterWindowMask | kLeaveWindowMask);
}

//______________________________________________________________________________
TGScrollBarElement::~TGScrollBarElement()
{
   // destructor

   if (fPicD) {
      fClient->FreePicture(fPicD);
   }
}

//______________________________________________________________________________
void TGScrollBarElement::SetState(Int_t state)
{
   // Change state of scrollbar element (either up or down).

   if (state != fState) {
      switch (state) {
         case kButtonDown:
            fOptions &= ~kRaisedFrame;
            fOptions |= kSunkenFrame;
            break;
         case kButtonUp:
         case kButtonDisabled:
            fOptions &= ~kSunkenFrame;
            fOptions |= kRaisedFrame;
            break;
      }
      fState = state;
      fClient->NeedRedraw(this);
   }
}

//______________________________________________________________________________
void TGScrollBarElement::SetEnabled(Bool_t on)
{
   // Enable/Disable scroll bar button chaging the state.

   if (on) {
      if (fState == kButtonUp) {
         return;
      }
      SetState(kButtonUp);
      fPic = fPicN;
   } else {
      if (fState == kButtonDisabled) {
         return;
      }
      SetState(kButtonDisabled);

      if (!fPicD) {
         TImage *img = TImage::Create();
         if (!img) return;
         TImage *img2 = TImage::Create();
         if (!img2) {
            if (img) delete img;
            return;
         }
         TString back = gEnv->GetValue("Gui.BackgroundColor", "#c0c0c0");
         img2->FillRectangle(back.Data(), 0, 0, fPic->GetWidth(), fPic->GetHeight());
         img->SetImage(fPicN->GetPicture(), fPicN->GetMask());
         Pixmap_t mask = img->GetMask();
         img2->Merge(img, "overlay");

         TString name = "disbl_";
         name += fPic->GetName();
         fPicD = fClient->GetPicturePool()->GetPicture(name.Data(), img2->GetPixmap(),
                                                       mask);
         delete img;
         delete img2;
      }
      fPic = fPicD;
   }
   fClient->NeedRedraw(this);
}

//______________________________________________________________________________
void TGScrollBarElement::DrawBorder()
{
   // Draw border around scollbar element.

   switch (fOptions & (kSunkenFrame | kRaisedFrame)) {
      case kSunkenFrame: // pressed
         gVirtualX->DrawLine(fId, GetBlackGC()(), 0, 0, fWidth-2, 0);
         gVirtualX->DrawLine(fId, GetBlackGC()(), 0, 0, 0, fHeight-2);
         gVirtualX->DrawLine(fId, GetShadowGC()(),  1, 1, fWidth-3, 1);
         gVirtualX->DrawLine(fId, GetShadowGC()(),  1, 1, 1, fHeight-3);

         gVirtualX->DrawLine(fId, GetWhiteGC()(),  0, fHeight-1, fWidth-1, fHeight-1);
         gVirtualX->DrawLine(fId, GetWhiteGC()(),  fWidth-1, fHeight-1, fWidth-1, 1);
         gVirtualX->DrawLine(fId, GetBckgndGC()(),  1, fHeight-2, fWidth-2, fHeight-2);
         gVirtualX->DrawLine(fId, GetBckgndGC()(),  fWidth-2, fHeight-2, fWidth-2, 2);

         if (fPic) {
            int x = (fWidth - fPic->GetWidth()) >> 1;
            int y = (fHeight - fPic->GetHeight()) >> 1;
            fPic->Draw(fId, GetBckgndGC()(), x+1, y+1); // 3, 3
         }
         break;

      case kRaisedFrame: // normal
      case kButtonDisabled:
         if (fStyle > 0) {
            // new modern (flat) version
            if (fBackground == fHighColor) {
               gVirtualX->DrawRectangle(fId, GetShadowGC()(), 0, 0, fWidth-1, fHeight-1);
            }
            else {
               if (fPic == 0)
                  gVirtualX->DrawRectangle(fId, GetShadowGC()(), 0, 0, fWidth-1, fHeight-1);
               else
                  gVirtualX->DrawRectangle(fId, GetBckgndGC()(), 0, 0, fWidth-1, fHeight-1);
            }
            if (fParent && fParent->InheritsFrom("TGHScrollBar")) {
               if (fWidth > 20) {
                  gVirtualX->DrawLine(fId, GetShadowGC()(), (fWidth/2)-3, 4, (fWidth/2)-3, fHeight-5);
                  gVirtualX->DrawLine(fId, GetShadowGC()(), (fWidth/2),   4, (fWidth/2),   fHeight-5);
                  gVirtualX->DrawLine(fId, GetShadowGC()(), (fWidth/2)+3, 4, (fWidth/2)+3, fHeight-5);
               }
            }
            else if (fParent && fParent->InheritsFrom("TGVScrollBar")) {
               if (fHeight > 20) {
                  gVirtualX->DrawLine(fId, GetShadowGC()(), 4, (fHeight/2)-3, fWidth-5, (fHeight/2)-3);
                  gVirtualX->DrawLine(fId, GetShadowGC()(), 4, (fHeight/2)  , fWidth-5, (fHeight/2));
                  gVirtualX->DrawLine(fId, GetShadowGC()(), 4, (fHeight/2)+3, fWidth-5, (fHeight/2)+3);
               }
            }
            else { // not used in a scroll bar (e.g. in a combo box)
               gVirtualX->DrawRectangle(fId, GetShadowGC()(), 0, 0, fWidth-1, fHeight-1);
            }
         }
         else {
            gVirtualX->DrawLine(fId, GetBckgndGC()(), 0, 0, fWidth-2, 0);
            gVirtualX->DrawLine(fId, GetBckgndGC()(), 0, 0, 0, fHeight-2);
            gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 1, fWidth-3, 1);
            gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 1, 1, fHeight-3);

            gVirtualX->DrawLine(fId, GetShadowGC()(),  1, fHeight-2, fWidth-2, fHeight-2);
            gVirtualX->DrawLine(fId, GetShadowGC()(),  fWidth-2, fHeight-2, fWidth-2, 1);
            gVirtualX->DrawLine(fId, GetBlackGC()(), 0, fHeight-1, fWidth-1, fHeight-1);
            gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth-1, fHeight-1, fWidth-1, 0);
         }
         if (fPic) {
            int x = (fWidth - fPic->GetWidth()) >> 1;
            int y = (fHeight - fPic->GetHeight()) >> 1;
            fPic->Draw(fId, GetBckgndGC()(), x, y); // 2, 2
         }
         break;

      default:
         break;
   }
}

//______________________________________________________________________________
Bool_t TGScrollBarElement::HandleCrossing(Event_t *event)
{
   // Handle mouse crossing event.

   if (fStyle > 0) {
      TGScrollBarElement *el = 0;
      TGScrollBar *bar = 0;
      if ((event->fType == kEnterNotify) && (fState != kButtonDisabled)) {
         fBgndColor = fHighColor;
      } else {
         fBgndColor = fBackground;
      }
      if (event->fType == kLeaveNotify) {
         fBgndColor = fBackground;
      }
      gVirtualX->SetWindowBackground(fId, fBgndColor);
      TGFrame::DoRedraw();
      DrawBorder();
      if (fParent && fParent->InheritsFrom("TGScrollBar")) {
         bar = (TGScrollBar *)fParent;
         if ((el = bar->GetHead()) != this) {
            el->ChangeBackground(fBgndColor);
            el->DrawBorder();
         }
         if ((el = bar->GetTail()) != this) {
            el->ChangeBackground(fBgndColor);
            el->DrawBorder();
         }
         if ((el = bar->GetSlider()) != this) {
            el->ChangeBackground(fBgndColor);
            el->DrawBorder();
         }
      }
   }
   return kTRUE;
}

//______________________________________________________________________________
TGScrollBar::TGScrollBar(const TGWindow *p, UInt_t w, UInt_t h,
                         UInt_t options, Pixel_t back) :
   TGFrame(p, w, h, options | kOwnBackground, back),
   fX0(0), fY0(0), fXp(0), fYp(0), fDragging(kFALSE), fGrabPointer(kTRUE),
   fRange(0), fPsize(0), fPos(0), fSliderSize(0), fSliderRange(0),
   fSmallInc(1), fHead(0), fTail(0), fSlider(0), fHeadPic(0),
   fTailPic(0), fRepeat(0), fSubw()
{
   // Constructor.

   fAccelerated = kFALSE;

   fBgndColor = fBackground;
   fHighColor = gClient->GetResourcePool()->GetHighLightColor();

   fMsgWindow = p;
   if (gClient->GetStyle() == 0)
      SetBackgroundPixmap(GetBckgndPixmap());
   SetWindowName();
   AddInput(kEnterWindowMask | kLeaveWindowMask);
}

//______________________________________________________________________________
TGScrollBar::~TGScrollBar()
{
   // Delete a scrollbar (either horizontal or vertical).

   delete fHead;
   delete fTail;
   delete fSlider;
   if (fHeadPic) fClient->FreePicture(fHeadPic);
   if (fTailPic) fClient->FreePicture(fTailPic);
   if (fRepeat) { delete fRepeat; fRepeat = 0; }
}

//______________________________________________________________________________
Bool_t TGScrollBar::HandleCrossing(Event_t *event)
{
   // Handle mouse crossing event.

   if (gClient->GetStyle() > 0) {
      if (event->fType == kEnterNotify) {
         fBgndColor = fHighColor;
      } else {
         fBgndColor = fBackground;
      }
      if (event->fType == kLeaveNotify) {
         fBgndColor = fBackground;
      }
      fHead->ChangeBackground(fBgndColor);
      fTail->ChangeBackground(fBgndColor);
      fSlider->ChangeBackground(fBgndColor);
      fHead->DrawBorder();
      fTail->DrawBorder();
      fSlider->DrawBorder();
   }
   return kTRUE;
}

//______________________________________________________________________________
Bool_t TGScrollBar::HandleTimer(TTimer *t)
{
   // Handle repeat timer for horizontal or vertical scrollbar. Every time
   // timer times out we move slider.

   // shorten time out time to 50 milli seconds
   t->SetTime(50);

   Window_t  dum1, dum2;
   Event_t   ev;

   ev.fCode    = kButton1;
   ev.fType    = kButtonPress;
   ev.fUser[0] = fSubw;

   if (IsAccelerated()) {
      ++fSmallInc;
      if (fSmallInc > 100) fSmallInc = 100;
   }

   gVirtualX->QueryPointer(fId, dum1, dum2, ev.fXRoot, ev.fYRoot, ev.fX, ev.fY,
                      ev.fState);

   HandleButton(&ev);

   return kTRUE;
}

//______________________________________________________________________________
Pixmap_t TGScrollBar::GetBckgndPixmap()
{
   // Static method returning scrollbar background pixmap.

   static Bool_t init = kFALSE;
   if (!init) {
      fgBckgndPixmap = gClient->GetResourcePool()->GetCheckeredPixmap();
      init = kTRUE;
   }
   return fgBckgndPixmap;
}

//______________________________________________________________________________
Int_t TGScrollBar::GetScrollBarWidth()
{
   // Static method returning the scrollbar width.

   return fgScrollBarWidth;
}

//______________________________________________________________________________
void TGScrollBar::ChangeBackground(Pixel_t back)
{
   // Change background color

   TGFrame::ChangeBackground(back);
   fHead->ChangeBackground(back);
   fTail->ChangeBackground(back);
   fSlider->ChangeBackground(back);
}

//______________________________________________________________________________
TGHScrollBar::TGHScrollBar(const TGWindow *p, UInt_t w, UInt_t h,
                           UInt_t options, ULong_t back) :
    TGScrollBar(p, w, h, options, back)
{
   // Create a horizontal scrollbar widget.

   fHeadPic = fClient->GetPicture("arrow_left.xpm");
   fTailPic = fClient->GetPicture("arrow_right.xpm");

   if (!fHeadPic || !fTailPic) {
      Error("TGHScrollBar", "arrow_*.xpm not found");
      return;
   }
   fHead   = new TGScrollBarElement(this, fHeadPic, fgScrollBarWidth, fgScrollBarWidth,
                                    kRaisedFrame);
   fTail   = new TGScrollBarElement(this, fTailPic, fgScrollBarWidth, fgScrollBarWidth,
                                    kRaisedFrame);
   fSlider = new TGScrollBarElement(this, 0, fgScrollBarWidth, 50,
                                    kRaisedFrame);

   gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier, kButtonPressMask |
                         kButtonReleaseMask | kPointerMotionMask, kNone, kNone);

   fDragging = kFALSE;
   fX0 = fY0 = (fgScrollBarWidth = TMath::Max(fgScrollBarWidth, 5));
   fPos = 0;

   fRange = TMath::Max((Int_t) w - (fgScrollBarWidth << 1), 1);
   fPsize = fRange >> 1;

   fSliderSize  = 50;
   fSliderRange = 1;

   fHead->SetEditDisabled(kEditDisable | kEditDisableGrab);
   fTail->SetEditDisabled(kEditDisable | kEditDisableGrab);
   fSlider->SetEditDisabled(kEditDisable | kEditDisableGrab);
   fEditDisabled = kEditDisableLayout | kEditDisableHeight | kEditDisableBtnEnable;
}

//______________________________________________________________________________
void TGHScrollBar::Layout()
{
   // Layout and move horizontal scrollbar components.

   // Should also recalculate the slider size and range, etc.
   fHead->Move(0, 0);
   fHead->Resize(fgScrollBarWidth, fgScrollBarWidth);
   fTail->Move(fWidth-fgScrollBarWidth, 0);
   fTail->Resize(fgScrollBarWidth, fgScrollBarWidth);

   if (fSlider->GetX() != fX0) {
      fSlider->Move(fX0, 0);
      fSlider->Resize(50, fgScrollBarWidth);
      fClient->NeedRedraw(fSlider);
   }
}

//______________________________________________________________________________
Bool_t TGHScrollBar::HandleButton(Event_t *event)
{
   // Handle a mouse button event in a horizontal scrolbar.

   Int_t newpos;

   if (event->fCode == kButton4) {
      if (!fHead->IsEnabled()) {
         return kFALSE;
      }
      //scroll left
      newpos = fPos - fPsize;
      if (newpos<0) newpos = 0;
      SetPosition(newpos);
      return kTRUE;
   }
   if (event->fCode == kButton5) {
      if (!fTail->IsEnabled()) {
         return kFALSE;
      }
      // scroll right
      newpos = fPos + fPsize;
      SetPosition(newpos);
      return kTRUE;
   }

   if (event->fType == kButtonPress) {
      if (event->fCode == kButton3) {
         fX0 = event->fX - fSliderSize/2;
         fX0 = TMath::Max(fX0, fgScrollBarWidth);
         fX0 = TMath::Min(fX0, fgScrollBarWidth + fSliderRange);
         ULong_t pos = (ULong_t)(fX0 - fgScrollBarWidth) * (ULong_t)(fRange-fPsize) / (ULong_t)fSliderRange;
         fPos = (Int_t)pos;

         fPos = TMath::Max(fPos, 0);
         fPos = TMath::Min(fPos, fRange-fPsize);
         fSlider->Move(fX0, 0);

         SendMessage(fMsgWindow, MK_MSG(kC_HSCROLL, kSB_SLIDERTRACK), fPos, 0);
         PositionChanged(fPos);
         return kTRUE;
      }

      // fUser[0] contains the subwindow (child) in which the event occured
      // (see GX11Gui.cxx)
      Window_t subw = (Window_t)event->fUser[0];

      if (subw == fSlider->GetId()) {
         fXp = event->fX - fX0;
         fYp = event->fY - fY0;
         fDragging = kTRUE;

      } else {

         if (!fRepeat)
            fRepeat = new TSBRepeatTimer(this, 400, fSmallInc); // 500
         fRepeat->Reset();
         gSystem->AddTimer(fRepeat);
         fSubw = subw;

         if (subw == fHead->GetId()) {
            //if (!fHead->IsEnabled()) {
             //  return kFALSE;
            //}
            fHead->SetState(kButtonDown);
            fPos -= fSmallInc;
         } else if (subw == fTail->GetId()) {
            //if (!fTail->IsEnabled()) {
           //    return kFALSE;
           // }
            fTail->SetState(kButtonDown);
            fPos += fSmallInc;
         } else if (event->fX > fgScrollBarWidth && event->fX < fX0)
            fPos -= fPsize;
         else if (event->fX > fX0+fSliderSize && event->fX < (Int_t)fWidth-fgScrollBarWidth)
            fPos += fPsize;

         fPos = TMath::Max(fPos, 0);
         fPos = TMath::Min(fPos, fRange-fPsize);

         fX0 = fgScrollBarWidth + fPos * fSliderRange / TMath::Max(fRange-fPsize, 1);

         fX0 = TMath::Max(fX0, fgScrollBarWidth);
         fX0 = TMath::Min(fX0, fgScrollBarWidth + fSliderRange);

         fSlider->Move(fX0, 0);

         SendMessage(fMsgWindow, MK_MSG(kC_HSCROLL, kSB_SLIDERTRACK), fPos, 0);
         PositionChanged(fPos);
      }

      // last argument kFALSE forces all specified events to this window
      if (fGrabPointer && !fClient->IsEditable())
         gVirtualX->GrabPointer(fId, kButtonPressMask | kButtonReleaseMask |
                                kPointerMotionMask, kNone, kNone,
                                kTRUE, kFALSE);
   } else {
      fHead->SetState(kButtonUp);
      fTail->SetState(kButtonUp);

      if (fRepeat) {
         fRepeat->Remove();
         fRepeat->SetTime(400);  // might have been shortened in HandleTimer()
         fSmallInc = ((TSBRepeatTimer*)fRepeat)->GetSmallInc();
      }

      fDragging = kFALSE;

      fPos = TMath::Max(fPos, 0);
      fPos = TMath::Min(fPos, fRange-fPsize);

      SendMessage(fMsgWindow, MK_MSG(kC_HSCROLL, kSB_SLIDERPOS), fPos, 0);
      PositionChanged(fPos);

      if (fGrabPointer)
         gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);  // ungrab pointer
   }
   return kTRUE;
}

//______________________________________________________________________________
Bool_t TGHScrollBar::HandleMotion(Event_t *event)
{
   // Handle mouse motion event in a horizontal scrollbar.

   if (fDragging) {
      fX0 = event->fX - fXp;
      fY0 = event->fY - fYp;

      fX0 = TMath::Max(fX0, fgScrollBarWidth);
      fX0 = TMath::Min(fX0, fgScrollBarWidth + fSliderRange);
      fSlider->Move(fX0, 0);
      ULong_t pos = (ULong_t)(fX0 - fgScrollBarWidth) * (ULong_t)(fRange-fPsize) / (ULong_t)fSliderRange;
      fPos = (Int_t)pos;

      fPos = TMath::Max(fPos, 0);
      fPos = TMath::Min(fPos, fRange-fPsize);

      SendMessage(fMsgWindow, MK_MSG(kC_HSCROLL, kSB_SLIDERTRACK), fPos, 0);
      PositionChanged(fPos);
   }
   return kTRUE;
}

//______________________________________________________________________________
void TGHScrollBar::SetRange(Int_t range, Int_t page_size)
{
   // Set range of horizontal scrollbar.

   fRange = TMath::Max(range, 1);
   fPsize = TMath::Max(page_size, 0);
   fPos = TMath::Max(fPos, 0);
   fPos = TMath::Min(fPos, fRange-fPsize);

   fSliderSize = TMath::Max(fPsize * (fWidth - (fgScrollBarWidth << 1)) /
                            fRange, (UInt_t) 6);
   fSliderSize = TMath::Min((UInt_t)fSliderSize, fWidth - (fgScrollBarWidth << 1));

   fSliderRange = TMath::Max(fWidth - (fgScrollBarWidth << 1) - fSliderSize,
                             (UInt_t) 1);

   fX0 = fgScrollBarWidth + fPos * fSliderRange / TMath::Max(fRange-fPsize, 1);
   fX0 = TMath::Max(fX0, fgScrollBarWidth);
   fX0 = TMath::Min(fX0, fgScrollBarWidth + fSliderRange);

   fSlider->Move(fX0, 0);
   fSlider->Resize(fSliderSize, fgScrollBarWidth);
   fClient->NeedRedraw(fSlider);

   //  fPos = (fX0 - fgScrollBarWidth) * (fRange-fPsize) / fSliderRange;

   SendMessage(fMsgWindow, MK_MSG(kC_HSCROLL, kSB_SLIDERPOS), fPos, 0);
   PositionChanged(fPos);
   RangeChanged(fRange);
   PageSizeChanged(fPsize);
}

//______________________________________________________________________________
void TGHScrollBar::SetPosition(Int_t pos)
{
   // Set logical slider position of horizontal scrollbar.

   fPos = TMath::Max(pos, 0);
   fPos = TMath::Min(pos, fRange-fPsize);

   fX0 = fgScrollBarWidth + fPos * fSliderRange / TMath::Max(fRange-fPsize, 1);
   fX0 = TMath::Max(fX0, fgScrollBarWidth);
   fX0 = TMath::Min(fX0, fgScrollBarWidth + fSliderRange);

   fSlider->Move(fX0, 0);
   fSlider->Resize(fSliderSize, fgScrollBarWidth);
   fClient->NeedRedraw(fSlider);

   SendMessage(fMsgWindow, MK_MSG(kC_HSCROLL, kSB_SLIDERPOS), fPos, 0);
   PositionChanged(fPos);
}


//______________________________________________________________________________
TGVScrollBar::TGVScrollBar(const TGWindow *p, UInt_t w, UInt_t h,
                           UInt_t options, ULong_t back) :
    TGScrollBar(p, w, h, options, back)
{
   // Create a vertical scrollbar.

   fHeadPic = fClient->GetPicture("arrow_up.xpm");
   fTailPic = fClient->GetPicture("arrow_down.xpm");

   if (!fHeadPic || !fTailPic) {
      Error("TGVScrollBar", "arrow_*.xpm not found");
      return;
   }
   fHead   = new TGScrollBarElement(this, fHeadPic, fgScrollBarWidth, fgScrollBarWidth,
                                    kRaisedFrame);
   fTail   = new TGScrollBarElement(this, fTailPic, fgScrollBarWidth, fgScrollBarWidth,
                                    kRaisedFrame);
   fSlider = new TGScrollBarElement(this, 0, fgScrollBarWidth, 50,
                                    kRaisedFrame);

   gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier, kButtonPressMask |
                         kButtonReleaseMask | kPointerMotionMask, kNone, kNone);

   fDragging = kFALSE;
   fX0 = fY0 = (fgScrollBarWidth = TMath::Max(fgScrollBarWidth, 5));
   fPos = 0;

   fRange = TMath::Max((Int_t) h - (fgScrollBarWidth << 1), 1);
   fPsize = fRange >> 1;

   fSliderSize  = 50;
   fSliderRange = 1;

   fHead->SetEditDisabled(kEditDisable | kEditDisableGrab);
   fTail->SetEditDisabled(kEditDisable | kEditDisableGrab);
   fSlider->SetEditDisabled(kEditDisable | kEditDisableGrab);
   fEditDisabled = kEditDisableLayout | kEditDisableWidth | kEditDisableBtnEnable;
}

//______________________________________________________________________________
void TGVScrollBar::Layout()
{
   // Layout and move vertical scrollbar components.

   // Should recalculate fSliderSize, fSliderRange, fX0, fY0, etc. too...
   fHead->Move(0, 0);
   fHead->Resize(fgScrollBarWidth, fgScrollBarWidth);
   fTail->Move(0, fHeight-fgScrollBarWidth);
   fTail->Resize(fgScrollBarWidth, fgScrollBarWidth);

   if (fSlider->GetY() != fY0) {
      fSlider->Move(0, fY0);
      fSlider->Resize(fgScrollBarWidth, 50);
      fClient->NeedRedraw(fSlider);
   }
}

//______________________________________________________________________________
Bool_t TGVScrollBar::HandleButton(Event_t *event)
{
   // Handle mouse button event in vertical scrollbar.

   Int_t newpos;

   if (event->fCode == kButton4) {
      if (!fHead->IsEnabled()) {
         return kFALSE;
      }
      //scroll up
      newpos = fPos - fPsize;
      if (newpos<0) newpos = 0;
      SetPosition(newpos);
      return kTRUE;
   }
   if (event->fCode == kButton5) {
      if (!fTail->IsEnabled()) {
         return kFALSE;
      }

      // scroll down
      newpos = fPos + fPsize;
      SetPosition(newpos);
      return kTRUE;
   }

   if (event->fType == kButtonPress) {
      if (event->fCode == kButton3) {
         fY0 = event->fY - fSliderSize/2;
         fY0 = TMath::Max(fY0, fgScrollBarWidth);
         fY0 = TMath::Min(fY0, fgScrollBarWidth + fSliderRange);
         ULong_t pos = (ULong_t)(fY0 - fgScrollBarWidth) * (ULong_t)(fRange-fPsize) / (ULong_t)fSliderRange;
         fPos = (Int_t)pos;

         fPos = TMath::Max(fPos, 0);
         fPos = TMath::Min(fPos, fRange-fPsize);
         fSlider->Move(0, fY0);

         SendMessage(fMsgWindow, MK_MSG(kC_VSCROLL, kSB_SLIDERTRACK), fPos, 0);
         PositionChanged(fPos);
         return kTRUE;
      }

      // fUser[0] contains the subwindow (child) in which the event occured
      // (see GX11Gui.cxx)
      Window_t subw = (Window_t)event->fUser[0];

      if (subw == fSlider->GetId()) {
         fXp = event->fX - fX0;
         fYp = event->fY - fY0;
         fDragging = kTRUE;

      } else {

         if (!fRepeat)
            fRepeat = new TSBRepeatTimer(this, 400, fSmallInc); // 500
         fRepeat->Reset();
         gSystem->AddTimer(fRepeat);
         fSubw = subw;

         if (subw == fHead->GetId()) {
            //if (!fHead->IsEnabled()) {
            //   return kFALSE;
           // }
            fHead->SetState(kButtonDown);
            fPos -= fSmallInc;
         } else if (subw == fTail->GetId()) {
            //if (!fTail->IsEnabled()) {
            //   return kFALSE;
            //}
            fTail->SetState(kButtonDown);
            fPos += fSmallInc;
         } else if (event->fY > fgScrollBarWidth && event->fY < fY0)
            fPos -= fPsize;
         else if (event->fY > fY0+fSliderSize && event->fY < (Int_t)fHeight-fgScrollBarWidth)
            fPos += fPsize;

         fPos = TMath::Max(fPos, 0);
         fPos = TMath::Min(fPos, fRange-fPsize);

         ULong_t y0 = (ULong_t)fgScrollBarWidth + (ULong_t)fPos * (ULong_t)fSliderRange / (ULong_t)TMath::Max(fRange-fPsize, 1);
         fY0 = (Int_t)y0;

         fY0 = TMath::Max(fY0, fgScrollBarWidth);
         fY0 = TMath::Min(fY0, fgScrollBarWidth + fSliderRange);

         fSlider->Move(0, fY0);

         SendMessage(fMsgWindow, MK_MSG(kC_VSCROLL, kSB_SLIDERTRACK), fPos, 0);
         PositionChanged(fPos);
      }

      // last argument kFALSE forces all specified events to this window
      if (fGrabPointer && !fClient->IsEditable())
         gVirtualX->GrabPointer(fId, kButtonPressMask | kButtonReleaseMask |
                                kPointerMotionMask, kNone, kNone,
                                kTRUE, kFALSE);
   } else {
      fHead->SetState(kButtonUp);
      fTail->SetState(kButtonUp);

      if (fRepeat) {
         fRepeat->Remove();
         fRepeat->SetTime(400);  // might have been shortened in HandleTimer()
         fSmallInc = ((TSBRepeatTimer*)fRepeat)->GetSmallInc();
      }

      fDragging = kFALSE;

      fPos = TMath::Max(fPos, 0);
      fPos = TMath::Min(fPos, fRange-fPsize);

      SendMessage(fMsgWindow, MK_MSG(kC_VSCROLL, kSB_SLIDERPOS), fPos, 0);
      PositionChanged(fPos);

      if (fGrabPointer) {
         gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);  // ungrab pointer
      }
   }
   return kTRUE;
}

//______________________________________________________________________________
Bool_t TGVScrollBar::HandleMotion(Event_t *event)
{
   // Handle mouse motion in a vertical scrollbar.

   if (fDragging) {
      fX0 = event->fX - fXp;
      fY0 = event->fY - fYp;

      fY0 = TMath::Max(fY0, fgScrollBarWidth);
      fY0 = TMath::Min(fY0, fgScrollBarWidth + fSliderRange);
      fSlider->Move(0, fY0);
      ULong_t pos = (ULong_t)(fY0 - fgScrollBarWidth) * (ULong_t)(fRange-fPsize) / fSliderRange;
      fPos = (Int_t)pos;

      fPos = TMath::Max(fPos, 0);
      fPos = TMath::Min(fPos, fRange-fPsize);

      SendMessage(fMsgWindow, MK_MSG(kC_VSCROLL, kSB_SLIDERTRACK), fPos, 0);
      PositionChanged(fPos);
   }
   return kTRUE;
}

//______________________________________________________________________________
void TGVScrollBar::SetRange(Int_t range, Int_t page_size)
{
   // Set range of vertical scrollbar.

   fRange = TMath::Max(range, 1);
   fPsize = TMath::Max(page_size, 0);
   fPos = TMath::Max(fPos, 0);
   fPos = TMath::Min(fPos, fRange-fPsize);

   fSliderSize = TMath::Max(fPsize * (fHeight - (fgScrollBarWidth << 1)) /
                            fRange, (UInt_t) 6);
   fSliderSize = TMath::Min((UInt_t)fSliderSize, fHeight - (fgScrollBarWidth << 1));

   fSliderRange = TMath::Max(fHeight - (fgScrollBarWidth << 1) - fSliderSize,
                             (UInt_t)1);

   ULong_t y0 = (ULong_t)fgScrollBarWidth + (ULong_t)fPos * (ULong_t)fSliderRange / (ULong_t)TMath::Max(fRange-fPsize, 1);
   fY0 = (Int_t)y0;
   fY0 = TMath::Max(fY0, fgScrollBarWidth);
   fY0 = TMath::Min(fY0, fgScrollBarWidth + fSliderRange);

   fSlider->Move(0, fY0);
   fSlider->Resize(fgScrollBarWidth, fSliderSize);
   fClient->NeedRedraw(fSlider);

   //  fPos = (fY0 - fgScrollBarWidth) * (fRange-fPsize) / fSliderRange;


   SendMessage(fMsgWindow, MK_MSG(kC_VSCROLL, kSB_SLIDERPOS), fPos, 0);
   PositionChanged(fPos);
   RangeChanged(fRange);
   PageSizeChanged(fPsize);
}

//______________________________________________________________________________
void TGVScrollBar::SetPosition(Int_t pos)
{
   // Set logical slider position of vertical scrollbar.

   fPos = TMath::Max(pos, 0);
   fPos = TMath::Min(pos, fRange-fPsize);

   ULong_t y0 = (ULong_t)fgScrollBarWidth + (ULong_t)fPos * (ULong_t)fSliderRange / (ULong_t)TMath::Max(fRange-fPsize, 1);
   fY0 = (Int_t)y0;
   fY0 = TMath::Max(fY0, fgScrollBarWidth);
   fY0 = TMath::Min(fY0, fgScrollBarWidth + fSliderRange);

   fSlider->Move(0, fY0);
   fSlider->Resize(fgScrollBarWidth, fSliderSize);
   fClient->NeedRedraw(fSlider);

   SendMessage(fMsgWindow, MK_MSG(kC_VSCROLL, kSB_SLIDERPOS), fPos, 0);
   PositionChanged(fPos);
}

//______________________________________________________________________________
void TGHScrollBar::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
{
    // Save an horizontal scrollbar as a C++ statement(s) on output stream out.

   if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);

   out <<"   TGHScrollBar *";
   out << GetName() << " = new TGHScrollBar(" << fParent->GetName()
       << "," << GetWidth() << "," << GetHeight();

   if (fBackground == GetDefaultFrameBackground()) {
      if (!GetOptions()) {
         out <<");" << std::endl;
      } else {
         out << "," << GetOptionString() <<");" << std::endl;
      }
   } else {
      out << "," << GetOptionString() << ",ucolor);" << std::endl;
   }
   if (option && strstr(option, "keep_names"))
      out << "   " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;

   out << "   " << GetName() <<"->SetRange(" << GetRange() << "," << GetPageSize() << ");" << std::endl;
   out << "   " << GetName() <<"->SetPosition(" << GetPosition() << ");" << std::endl;
}

//______________________________________________________________________________
void TGVScrollBar::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
{
    // Save an vertical scrollbar as a C++ statement(s) on output stream out.

   if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);

   out<<"   TGVScrollBar *";
   out << GetName() <<" = new TGVScrollBar("<< fParent->GetName()
       << "," << GetWidth() << "," << GetHeight();

   if (fBackground == GetDefaultFrameBackground()) {

      if (!GetOptions()) {
         out <<");" << std::endl;
      } else {
         out << "," << GetOptionString() <<");" << std::endl;
      }
   } else {
      out << "," << GetOptionString() << ",ucolor);" << std::endl;
   }
   if (option && strstr(option, "keep_names"))
      out << "   " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;

   out << "   " << GetName() <<"->SetRange(" << GetRange() << "," << GetPageSize() << ");" << std::endl;
   out << "   " << GetName() <<"->SetPosition(" << GetPosition() << ");" << std::endl;
}
 TGScrollBar.cxx:1
 TGScrollBar.cxx:2
 TGScrollBar.cxx:3
 TGScrollBar.cxx:4
 TGScrollBar.cxx:5
 TGScrollBar.cxx:6
 TGScrollBar.cxx:7
 TGScrollBar.cxx:8
 TGScrollBar.cxx:9
 TGScrollBar.cxx:10
 TGScrollBar.cxx:11
 TGScrollBar.cxx:12
 TGScrollBar.cxx:13
 TGScrollBar.cxx:14
 TGScrollBar.cxx:15
 TGScrollBar.cxx:16
 TGScrollBar.cxx:17
 TGScrollBar.cxx:18
 TGScrollBar.cxx:19
 TGScrollBar.cxx:20
 TGScrollBar.cxx:21
 TGScrollBar.cxx:22
 TGScrollBar.cxx:23
 TGScrollBar.cxx:24
 TGScrollBar.cxx:25
 TGScrollBar.cxx:26
 TGScrollBar.cxx:27
 TGScrollBar.cxx:28
 TGScrollBar.cxx:29
 TGScrollBar.cxx:30
 TGScrollBar.cxx:31
 TGScrollBar.cxx:32
 TGScrollBar.cxx:33
 TGScrollBar.cxx:34
 TGScrollBar.cxx:35
 TGScrollBar.cxx:36
 TGScrollBar.cxx:37
 TGScrollBar.cxx:38
 TGScrollBar.cxx:39
 TGScrollBar.cxx:40
 TGScrollBar.cxx:41
 TGScrollBar.cxx:42
 TGScrollBar.cxx:43
 TGScrollBar.cxx:44
 TGScrollBar.cxx:45
 TGScrollBar.cxx:46
 TGScrollBar.cxx:47
 TGScrollBar.cxx:48
 TGScrollBar.cxx:49
 TGScrollBar.cxx:50
 TGScrollBar.cxx:51
 TGScrollBar.cxx:52
 TGScrollBar.cxx:53
 TGScrollBar.cxx:54
 TGScrollBar.cxx:55
 TGScrollBar.cxx:56
 TGScrollBar.cxx:57
 TGScrollBar.cxx:58
 TGScrollBar.cxx:59
 TGScrollBar.cxx:60
 TGScrollBar.cxx:61
 TGScrollBar.cxx:62
 TGScrollBar.cxx:63
 TGScrollBar.cxx:64
 TGScrollBar.cxx:65
 TGScrollBar.cxx:66
 TGScrollBar.cxx:67
 TGScrollBar.cxx:68
 TGScrollBar.cxx:69
 TGScrollBar.cxx:70
 TGScrollBar.cxx:71
 TGScrollBar.cxx:72
 TGScrollBar.cxx:73
 TGScrollBar.cxx:74
 TGScrollBar.cxx:75
 TGScrollBar.cxx:76
 TGScrollBar.cxx:77
 TGScrollBar.cxx:78
 TGScrollBar.cxx:79
 TGScrollBar.cxx:80
 TGScrollBar.cxx:81
 TGScrollBar.cxx:82
 TGScrollBar.cxx:83
 TGScrollBar.cxx:84
 TGScrollBar.cxx:85
 TGScrollBar.cxx:86
 TGScrollBar.cxx:87
 TGScrollBar.cxx:88
 TGScrollBar.cxx:89
 TGScrollBar.cxx:90
 TGScrollBar.cxx:91
 TGScrollBar.cxx:92
 TGScrollBar.cxx:93
 TGScrollBar.cxx:94
 TGScrollBar.cxx:95
 TGScrollBar.cxx:96
 TGScrollBar.cxx:97
 TGScrollBar.cxx:98
 TGScrollBar.cxx:99
 TGScrollBar.cxx:100
 TGScrollBar.cxx:101
 TGScrollBar.cxx:102
 TGScrollBar.cxx:103
 TGScrollBar.cxx:104
 TGScrollBar.cxx:105
 TGScrollBar.cxx:106
 TGScrollBar.cxx:107
 TGScrollBar.cxx:108
 TGScrollBar.cxx:109
 TGScrollBar.cxx:110
 TGScrollBar.cxx:111
 TGScrollBar.cxx:112
 TGScrollBar.cxx:113
 TGScrollBar.cxx:114
 TGScrollBar.cxx:115
 TGScrollBar.cxx:116
 TGScrollBar.cxx:117
 TGScrollBar.cxx:118
 TGScrollBar.cxx:119
 TGScrollBar.cxx:120
 TGScrollBar.cxx:121
 TGScrollBar.cxx:122
 TGScrollBar.cxx:123
 TGScrollBar.cxx:124
 TGScrollBar.cxx:125
 TGScrollBar.cxx:126
 TGScrollBar.cxx:127
 TGScrollBar.cxx:128
 TGScrollBar.cxx:129
 TGScrollBar.cxx:130
 TGScrollBar.cxx:131
 TGScrollBar.cxx:132
 TGScrollBar.cxx:133
 TGScrollBar.cxx:134
 TGScrollBar.cxx:135
 TGScrollBar.cxx:136
 TGScrollBar.cxx:137
 TGScrollBar.cxx:138
 TGScrollBar.cxx:139
 TGScrollBar.cxx:140
 TGScrollBar.cxx:141
 TGScrollBar.cxx:142
 TGScrollBar.cxx:143
 TGScrollBar.cxx:144
 TGScrollBar.cxx:145
 TGScrollBar.cxx:146
 TGScrollBar.cxx:147
 TGScrollBar.cxx:148
 TGScrollBar.cxx:149
 TGScrollBar.cxx:150
 TGScrollBar.cxx:151
 TGScrollBar.cxx:152
 TGScrollBar.cxx:153
 TGScrollBar.cxx:154
 TGScrollBar.cxx:155
 TGScrollBar.cxx:156
 TGScrollBar.cxx:157
 TGScrollBar.cxx:158
 TGScrollBar.cxx:159
 TGScrollBar.cxx:160
 TGScrollBar.cxx:161
 TGScrollBar.cxx:162
 TGScrollBar.cxx:163
 TGScrollBar.cxx:164
 TGScrollBar.cxx:165
 TGScrollBar.cxx:166
 TGScrollBar.cxx:167
 TGScrollBar.cxx:168
 TGScrollBar.cxx:169
 TGScrollBar.cxx:170
 TGScrollBar.cxx:171
 TGScrollBar.cxx:172
 TGScrollBar.cxx:173
 TGScrollBar.cxx:174
 TGScrollBar.cxx:175
 TGScrollBar.cxx:176
 TGScrollBar.cxx:177
 TGScrollBar.cxx:178
 TGScrollBar.cxx:179
 TGScrollBar.cxx:180
 TGScrollBar.cxx:181
 TGScrollBar.cxx:182
 TGScrollBar.cxx:183
 TGScrollBar.cxx:184
 TGScrollBar.cxx:185
 TGScrollBar.cxx:186
 TGScrollBar.cxx:187
 TGScrollBar.cxx:188
 TGScrollBar.cxx:189
 TGScrollBar.cxx:190
 TGScrollBar.cxx:191
 TGScrollBar.cxx:192
 TGScrollBar.cxx:193
 TGScrollBar.cxx:194
 TGScrollBar.cxx:195
 TGScrollBar.cxx:196
 TGScrollBar.cxx:197
 TGScrollBar.cxx:198
 TGScrollBar.cxx:199
 TGScrollBar.cxx:200
 TGScrollBar.cxx:201
 TGScrollBar.cxx:202
 TGScrollBar.cxx:203
 TGScrollBar.cxx:204
 TGScrollBar.cxx:205
 TGScrollBar.cxx:206
 TGScrollBar.cxx:207
 TGScrollBar.cxx:208
 TGScrollBar.cxx:209
 TGScrollBar.cxx:210
 TGScrollBar.cxx:211
 TGScrollBar.cxx:212
 TGScrollBar.cxx:213
 TGScrollBar.cxx:214
 TGScrollBar.cxx:215
 TGScrollBar.cxx:216
 TGScrollBar.cxx:217
 TGScrollBar.cxx:218
 TGScrollBar.cxx:219
 TGScrollBar.cxx:220
 TGScrollBar.cxx:221
 TGScrollBar.cxx:222
 TGScrollBar.cxx:223
 TGScrollBar.cxx:224
 TGScrollBar.cxx:225
 TGScrollBar.cxx:226
 TGScrollBar.cxx:227
 TGScrollBar.cxx:228
 TGScrollBar.cxx:229
 TGScrollBar.cxx:230
 TGScrollBar.cxx:231
 TGScrollBar.cxx:232
 TGScrollBar.cxx:233
 TGScrollBar.cxx:234
 TGScrollBar.cxx:235
 TGScrollBar.cxx:236
 TGScrollBar.cxx:237
 TGScrollBar.cxx:238
 TGScrollBar.cxx:239
 TGScrollBar.cxx:240
 TGScrollBar.cxx:241
 TGScrollBar.cxx:242
 TGScrollBar.cxx:243
 TGScrollBar.cxx:244
 TGScrollBar.cxx:245
 TGScrollBar.cxx:246
 TGScrollBar.cxx:247
 TGScrollBar.cxx:248
 TGScrollBar.cxx:249
 TGScrollBar.cxx:250
 TGScrollBar.cxx:251
 TGScrollBar.cxx:252
 TGScrollBar.cxx:253
 TGScrollBar.cxx:254
 TGScrollBar.cxx:255
 TGScrollBar.cxx:256
 TGScrollBar.cxx:257
 TGScrollBar.cxx:258
 TGScrollBar.cxx:259
 TGScrollBar.cxx:260
 TGScrollBar.cxx:261
 TGScrollBar.cxx:262
 TGScrollBar.cxx:263
 TGScrollBar.cxx:264
 TGScrollBar.cxx:265
 TGScrollBar.cxx:266
 TGScrollBar.cxx:267
 TGScrollBar.cxx:268
 TGScrollBar.cxx:269
 TGScrollBar.cxx:270
 TGScrollBar.cxx:271
 TGScrollBar.cxx:272
 TGScrollBar.cxx:273
 TGScrollBar.cxx:274
 TGScrollBar.cxx:275
 TGScrollBar.cxx:276
 TGScrollBar.cxx:277
 TGScrollBar.cxx:278
 TGScrollBar.cxx:279
 TGScrollBar.cxx:280
 TGScrollBar.cxx:281
 TGScrollBar.cxx:282
 TGScrollBar.cxx:283
 TGScrollBar.cxx:284
 TGScrollBar.cxx:285
 TGScrollBar.cxx:286
 TGScrollBar.cxx:287
 TGScrollBar.cxx:288
 TGScrollBar.cxx:289
 TGScrollBar.cxx:290
 TGScrollBar.cxx:291
 TGScrollBar.cxx:292
 TGScrollBar.cxx:293
 TGScrollBar.cxx:294
 TGScrollBar.cxx:295
 TGScrollBar.cxx:296
 TGScrollBar.cxx:297
 TGScrollBar.cxx:298
 TGScrollBar.cxx:299
 TGScrollBar.cxx:300
 TGScrollBar.cxx:301
 TGScrollBar.cxx:302
 TGScrollBar.cxx:303
 TGScrollBar.cxx:304
 TGScrollBar.cxx:305
 TGScrollBar.cxx:306
 TGScrollBar.cxx:307
 TGScrollBar.cxx:308
 TGScrollBar.cxx:309
 TGScrollBar.cxx:310
 TGScrollBar.cxx:311
 TGScrollBar.cxx:312
 TGScrollBar.cxx:313
 TGScrollBar.cxx:314
 TGScrollBar.cxx:315
 TGScrollBar.cxx:316
 TGScrollBar.cxx:317
 TGScrollBar.cxx:318
 TGScrollBar.cxx:319
 TGScrollBar.cxx:320
 TGScrollBar.cxx:321
 TGScrollBar.cxx:322
 TGScrollBar.cxx:323
 TGScrollBar.cxx:324
 TGScrollBar.cxx:325
 TGScrollBar.cxx:326
 TGScrollBar.cxx:327
 TGScrollBar.cxx:328
 TGScrollBar.cxx:329
 TGScrollBar.cxx:330
 TGScrollBar.cxx:331
 TGScrollBar.cxx:332
 TGScrollBar.cxx:333
 TGScrollBar.cxx:334
 TGScrollBar.cxx:335
 TGScrollBar.cxx:336
 TGScrollBar.cxx:337
 TGScrollBar.cxx:338
 TGScrollBar.cxx:339
 TGScrollBar.cxx:340
 TGScrollBar.cxx:341
 TGScrollBar.cxx:342
 TGScrollBar.cxx:343
 TGScrollBar.cxx:344
 TGScrollBar.cxx:345
 TGScrollBar.cxx:346
 TGScrollBar.cxx:347
 TGScrollBar.cxx:348
 TGScrollBar.cxx:349
 TGScrollBar.cxx:350
 TGScrollBar.cxx:351
 TGScrollBar.cxx:352
 TGScrollBar.cxx:353
 TGScrollBar.cxx:354
 TGScrollBar.cxx:355
 TGScrollBar.cxx:356
 TGScrollBar.cxx:357
 TGScrollBar.cxx:358
 TGScrollBar.cxx:359
 TGScrollBar.cxx:360
 TGScrollBar.cxx:361
 TGScrollBar.cxx:362
 TGScrollBar.cxx:363
 TGScrollBar.cxx:364
 TGScrollBar.cxx:365
 TGScrollBar.cxx:366
 TGScrollBar.cxx:367
 TGScrollBar.cxx:368
 TGScrollBar.cxx:369
 TGScrollBar.cxx:370
 TGScrollBar.cxx:371
 TGScrollBar.cxx:372
 TGScrollBar.cxx:373
 TGScrollBar.cxx:374
 TGScrollBar.cxx:375
 TGScrollBar.cxx:376
 TGScrollBar.cxx:377
 TGScrollBar.cxx:378
 TGScrollBar.cxx:379
 TGScrollBar.cxx:380
 TGScrollBar.cxx:381
 TGScrollBar.cxx:382
 TGScrollBar.cxx:383
 TGScrollBar.cxx:384
 TGScrollBar.cxx:385
 TGScrollBar.cxx:386
 TGScrollBar.cxx:387
 TGScrollBar.cxx:388
 TGScrollBar.cxx:389
 TGScrollBar.cxx:390
 TGScrollBar.cxx:391
 TGScrollBar.cxx:392
 TGScrollBar.cxx:393
 TGScrollBar.cxx:394
 TGScrollBar.cxx:395
 TGScrollBar.cxx:396
 TGScrollBar.cxx:397
 TGScrollBar.cxx:398
 TGScrollBar.cxx:399
 TGScrollBar.cxx:400
 TGScrollBar.cxx:401
 TGScrollBar.cxx:402
 TGScrollBar.cxx:403
 TGScrollBar.cxx:404
 TGScrollBar.cxx:405
 TGScrollBar.cxx:406
 TGScrollBar.cxx:407
 TGScrollBar.cxx:408
 TGScrollBar.cxx:409
 TGScrollBar.cxx:410
 TGScrollBar.cxx:411
 TGScrollBar.cxx:412
 TGScrollBar.cxx:413
 TGScrollBar.cxx:414
 TGScrollBar.cxx:415
 TGScrollBar.cxx:416
 TGScrollBar.cxx:417
 TGScrollBar.cxx:418
 TGScrollBar.cxx:419
 TGScrollBar.cxx:420
 TGScrollBar.cxx:421
 TGScrollBar.cxx:422
 TGScrollBar.cxx:423
 TGScrollBar.cxx:424
 TGScrollBar.cxx:425
 TGScrollBar.cxx:426
 TGScrollBar.cxx:427
 TGScrollBar.cxx:428
 TGScrollBar.cxx:429
 TGScrollBar.cxx:430
 TGScrollBar.cxx:431
 TGScrollBar.cxx:432
 TGScrollBar.cxx:433
 TGScrollBar.cxx:434
 TGScrollBar.cxx:435
 TGScrollBar.cxx:436
 TGScrollBar.cxx:437
 TGScrollBar.cxx:438
 TGScrollBar.cxx:439
 TGScrollBar.cxx:440
 TGScrollBar.cxx:441
 TGScrollBar.cxx:442
 TGScrollBar.cxx:443
 TGScrollBar.cxx:444
 TGScrollBar.cxx:445
 TGScrollBar.cxx:446
 TGScrollBar.cxx:447
 TGScrollBar.cxx:448
 TGScrollBar.cxx:449
 TGScrollBar.cxx:450
 TGScrollBar.cxx:451
 TGScrollBar.cxx:452
 TGScrollBar.cxx:453
 TGScrollBar.cxx:454
 TGScrollBar.cxx:455
 TGScrollBar.cxx:456
 TGScrollBar.cxx:457
 TGScrollBar.cxx:458
 TGScrollBar.cxx:459
 TGScrollBar.cxx:460
 TGScrollBar.cxx:461
 TGScrollBar.cxx:462
 TGScrollBar.cxx:463
 TGScrollBar.cxx:464
 TGScrollBar.cxx:465
 TGScrollBar.cxx:466
 TGScrollBar.cxx:467
 TGScrollBar.cxx:468
 TGScrollBar.cxx:469
 TGScrollBar.cxx:470
 TGScrollBar.cxx:471
 TGScrollBar.cxx:472
 TGScrollBar.cxx:473
 TGScrollBar.cxx:474
 TGScrollBar.cxx:475
 TGScrollBar.cxx:476
 TGScrollBar.cxx:477
 TGScrollBar.cxx:478
 TGScrollBar.cxx:479
 TGScrollBar.cxx:480
 TGScrollBar.cxx:481
 TGScrollBar.cxx:482
 TGScrollBar.cxx:483
 TGScrollBar.cxx:484
 TGScrollBar.cxx:485
 TGScrollBar.cxx:486
 TGScrollBar.cxx:487
 TGScrollBar.cxx:488
 TGScrollBar.cxx:489
 TGScrollBar.cxx:490
 TGScrollBar.cxx:491
 TGScrollBar.cxx:492
 TGScrollBar.cxx:493
 TGScrollBar.cxx:494
 TGScrollBar.cxx:495
 TGScrollBar.cxx:496
 TGScrollBar.cxx:497
 TGScrollBar.cxx:498
 TGScrollBar.cxx:499
 TGScrollBar.cxx:500
 TGScrollBar.cxx:501
 TGScrollBar.cxx:502
 TGScrollBar.cxx:503
 TGScrollBar.cxx:504
 TGScrollBar.cxx:505
 TGScrollBar.cxx:506
 TGScrollBar.cxx:507
 TGScrollBar.cxx:508
 TGScrollBar.cxx:509
 TGScrollBar.cxx:510
 TGScrollBar.cxx:511
 TGScrollBar.cxx:512
 TGScrollBar.cxx:513
 TGScrollBar.cxx:514
 TGScrollBar.cxx:515
 TGScrollBar.cxx:516
 TGScrollBar.cxx:517
 TGScrollBar.cxx:518
 TGScrollBar.cxx:519
 TGScrollBar.cxx:520
 TGScrollBar.cxx:521
 TGScrollBar.cxx:522
 TGScrollBar.cxx:523
 TGScrollBar.cxx:524
 TGScrollBar.cxx:525
 TGScrollBar.cxx:526
 TGScrollBar.cxx:527
 TGScrollBar.cxx:528
 TGScrollBar.cxx:529
 TGScrollBar.cxx:530
 TGScrollBar.cxx:531
 TGScrollBar.cxx:532
 TGScrollBar.cxx:533
 TGScrollBar.cxx:534
 TGScrollBar.cxx:535
 TGScrollBar.cxx:536
 TGScrollBar.cxx:537
 TGScrollBar.cxx:538
 TGScrollBar.cxx:539
 TGScrollBar.cxx:540
 TGScrollBar.cxx:541
 TGScrollBar.cxx:542
 TGScrollBar.cxx:543
 TGScrollBar.cxx:544
 TGScrollBar.cxx:545
 TGScrollBar.cxx:546
 TGScrollBar.cxx:547
 TGScrollBar.cxx:548
 TGScrollBar.cxx:549
 TGScrollBar.cxx:550
 TGScrollBar.cxx:551
 TGScrollBar.cxx:552
 TGScrollBar.cxx:553
 TGScrollBar.cxx:554
 TGScrollBar.cxx:555
 TGScrollBar.cxx:556
 TGScrollBar.cxx:557
 TGScrollBar.cxx:558
 TGScrollBar.cxx:559
 TGScrollBar.cxx:560
 TGScrollBar.cxx:561
 TGScrollBar.cxx:562
 TGScrollBar.cxx:563
 TGScrollBar.cxx:564
 TGScrollBar.cxx:565
 TGScrollBar.cxx:566
 TGScrollBar.cxx:567
 TGScrollBar.cxx:568
 TGScrollBar.cxx:569
 TGScrollBar.cxx:570
 TGScrollBar.cxx:571
 TGScrollBar.cxx:572
 TGScrollBar.cxx:573
 TGScrollBar.cxx:574
 TGScrollBar.cxx:575
 TGScrollBar.cxx:576
 TGScrollBar.cxx:577
 TGScrollBar.cxx:578
 TGScrollBar.cxx:579
 TGScrollBar.cxx:580
 TGScrollBar.cxx:581
 TGScrollBar.cxx:582
 TGScrollBar.cxx:583
 TGScrollBar.cxx:584
 TGScrollBar.cxx:585
 TGScrollBar.cxx:586
 TGScrollBar.cxx:587
 TGScrollBar.cxx:588
 TGScrollBar.cxx:589
 TGScrollBar.cxx:590
 TGScrollBar.cxx:591
 TGScrollBar.cxx:592
 TGScrollBar.cxx:593
 TGScrollBar.cxx:594
 TGScrollBar.cxx:595
 TGScrollBar.cxx:596
 TGScrollBar.cxx:597
 TGScrollBar.cxx:598
 TGScrollBar.cxx:599
 TGScrollBar.cxx:600
 TGScrollBar.cxx:601
 TGScrollBar.cxx:602
 TGScrollBar.cxx:603
 TGScrollBar.cxx:604
 TGScrollBar.cxx:605
 TGScrollBar.cxx:606
 TGScrollBar.cxx:607
 TGScrollBar.cxx:608
 TGScrollBar.cxx:609
 TGScrollBar.cxx:610
 TGScrollBar.cxx:611
 TGScrollBar.cxx:612
 TGScrollBar.cxx:613
 TGScrollBar.cxx:614
 TGScrollBar.cxx:615
 TGScrollBar.cxx:616
 TGScrollBar.cxx:617
 TGScrollBar.cxx:618
 TGScrollBar.cxx:619
 TGScrollBar.cxx:620
 TGScrollBar.cxx:621
 TGScrollBar.cxx:622
 TGScrollBar.cxx:623
 TGScrollBar.cxx:624
 TGScrollBar.cxx:625
 TGScrollBar.cxx:626
 TGScrollBar.cxx:627
 TGScrollBar.cxx:628
 TGScrollBar.cxx:629
 TGScrollBar.cxx:630
 TGScrollBar.cxx:631
 TGScrollBar.cxx:632
 TGScrollBar.cxx:633
 TGScrollBar.cxx:634
 TGScrollBar.cxx:635
 TGScrollBar.cxx:636
 TGScrollBar.cxx:637
 TGScrollBar.cxx:638
 TGScrollBar.cxx:639
 TGScrollBar.cxx:640
 TGScrollBar.cxx:641
 TGScrollBar.cxx:642
 TGScrollBar.cxx:643
 TGScrollBar.cxx:644
 TGScrollBar.cxx:645
 TGScrollBar.cxx:646
 TGScrollBar.cxx:647
 TGScrollBar.cxx:648
 TGScrollBar.cxx:649
 TGScrollBar.cxx:650
 TGScrollBar.cxx:651
 TGScrollBar.cxx:652
 TGScrollBar.cxx:653
 TGScrollBar.cxx:654
 TGScrollBar.cxx:655
 TGScrollBar.cxx:656
 TGScrollBar.cxx:657
 TGScrollBar.cxx:658
 TGScrollBar.cxx:659
 TGScrollBar.cxx:660
 TGScrollBar.cxx:661
 TGScrollBar.cxx:662
 TGScrollBar.cxx:663
 TGScrollBar.cxx:664
 TGScrollBar.cxx:665
 TGScrollBar.cxx:666
 TGScrollBar.cxx:667
 TGScrollBar.cxx:668
 TGScrollBar.cxx:669
 TGScrollBar.cxx:670
 TGScrollBar.cxx:671
 TGScrollBar.cxx:672
 TGScrollBar.cxx:673
 TGScrollBar.cxx:674
 TGScrollBar.cxx:675
 TGScrollBar.cxx:676
 TGScrollBar.cxx:677
 TGScrollBar.cxx:678
 TGScrollBar.cxx:679
 TGScrollBar.cxx:680
 TGScrollBar.cxx:681
 TGScrollBar.cxx:682
 TGScrollBar.cxx:683
 TGScrollBar.cxx:684
 TGScrollBar.cxx:685
 TGScrollBar.cxx:686
 TGScrollBar.cxx:687
 TGScrollBar.cxx:688
 TGScrollBar.cxx:689
 TGScrollBar.cxx:690
 TGScrollBar.cxx:691
 TGScrollBar.cxx:692
 TGScrollBar.cxx:693
 TGScrollBar.cxx:694
 TGScrollBar.cxx:695
 TGScrollBar.cxx:696
 TGScrollBar.cxx:697
 TGScrollBar.cxx:698
 TGScrollBar.cxx:699
 TGScrollBar.cxx:700
 TGScrollBar.cxx:701
 TGScrollBar.cxx:702
 TGScrollBar.cxx:703
 TGScrollBar.cxx:704
 TGScrollBar.cxx:705
 TGScrollBar.cxx:706
 TGScrollBar.cxx:707
 TGScrollBar.cxx:708
 TGScrollBar.cxx:709
 TGScrollBar.cxx:710
 TGScrollBar.cxx:711
 TGScrollBar.cxx:712
 TGScrollBar.cxx:713
 TGScrollBar.cxx:714
 TGScrollBar.cxx:715
 TGScrollBar.cxx:716
 TGScrollBar.cxx:717
 TGScrollBar.cxx:718
 TGScrollBar.cxx:719
 TGScrollBar.cxx:720
 TGScrollBar.cxx:721
 TGScrollBar.cxx:722
 TGScrollBar.cxx:723
 TGScrollBar.cxx:724
 TGScrollBar.cxx:725
 TGScrollBar.cxx:726
 TGScrollBar.cxx:727
 TGScrollBar.cxx:728
 TGScrollBar.cxx:729
 TGScrollBar.cxx:730
 TGScrollBar.cxx:731
 TGScrollBar.cxx:732
 TGScrollBar.cxx:733
 TGScrollBar.cxx:734
 TGScrollBar.cxx:735
 TGScrollBar.cxx:736
 TGScrollBar.cxx:737
 TGScrollBar.cxx:738
 TGScrollBar.cxx:739
 TGScrollBar.cxx:740
 TGScrollBar.cxx:741
 TGScrollBar.cxx:742
 TGScrollBar.cxx:743
 TGScrollBar.cxx:744
 TGScrollBar.cxx:745
 TGScrollBar.cxx:746
 TGScrollBar.cxx:747
 TGScrollBar.cxx:748
 TGScrollBar.cxx:749
 TGScrollBar.cxx:750
 TGScrollBar.cxx:751
 TGScrollBar.cxx:752
 TGScrollBar.cxx:753
 TGScrollBar.cxx:754
 TGScrollBar.cxx:755
 TGScrollBar.cxx:756
 TGScrollBar.cxx:757
 TGScrollBar.cxx:758
 TGScrollBar.cxx:759
 TGScrollBar.cxx:760
 TGScrollBar.cxx:761
 TGScrollBar.cxx:762
 TGScrollBar.cxx:763
 TGScrollBar.cxx:764
 TGScrollBar.cxx:765
 TGScrollBar.cxx:766
 TGScrollBar.cxx:767
 TGScrollBar.cxx:768
 TGScrollBar.cxx:769
 TGScrollBar.cxx:770
 TGScrollBar.cxx:771
 TGScrollBar.cxx:772
 TGScrollBar.cxx:773
 TGScrollBar.cxx:774
 TGScrollBar.cxx:775
 TGScrollBar.cxx:776
 TGScrollBar.cxx:777
 TGScrollBar.cxx:778
 TGScrollBar.cxx:779
 TGScrollBar.cxx:780
 TGScrollBar.cxx:781
 TGScrollBar.cxx:782
 TGScrollBar.cxx:783
 TGScrollBar.cxx:784
 TGScrollBar.cxx:785
 TGScrollBar.cxx:786
 TGScrollBar.cxx:787
 TGScrollBar.cxx:788
 TGScrollBar.cxx:789
 TGScrollBar.cxx:790
 TGScrollBar.cxx:791
 TGScrollBar.cxx:792
 TGScrollBar.cxx:793
 TGScrollBar.cxx:794
 TGScrollBar.cxx:795
 TGScrollBar.cxx:796
 TGScrollBar.cxx:797
 TGScrollBar.cxx:798
 TGScrollBar.cxx:799
 TGScrollBar.cxx:800
 TGScrollBar.cxx:801
 TGScrollBar.cxx:802
 TGScrollBar.cxx:803
 TGScrollBar.cxx:804
 TGScrollBar.cxx:805
 TGScrollBar.cxx:806
 TGScrollBar.cxx:807
 TGScrollBar.cxx:808
 TGScrollBar.cxx:809
 TGScrollBar.cxx:810
 TGScrollBar.cxx:811
 TGScrollBar.cxx:812
 TGScrollBar.cxx:813
 TGScrollBar.cxx:814
 TGScrollBar.cxx:815
 TGScrollBar.cxx:816
 TGScrollBar.cxx:817
 TGScrollBar.cxx:818
 TGScrollBar.cxx:819
 TGScrollBar.cxx:820
 TGScrollBar.cxx:821
 TGScrollBar.cxx:822
 TGScrollBar.cxx:823
 TGScrollBar.cxx:824
 TGScrollBar.cxx:825
 TGScrollBar.cxx:826
 TGScrollBar.cxx:827
 TGScrollBar.cxx:828
 TGScrollBar.cxx:829
 TGScrollBar.cxx:830
 TGScrollBar.cxx:831
 TGScrollBar.cxx:832
 TGScrollBar.cxx:833
 TGScrollBar.cxx:834
 TGScrollBar.cxx:835
 TGScrollBar.cxx:836
 TGScrollBar.cxx:837
 TGScrollBar.cxx:838
 TGScrollBar.cxx:839
 TGScrollBar.cxx:840
 TGScrollBar.cxx:841
 TGScrollBar.cxx:842
 TGScrollBar.cxx:843
 TGScrollBar.cxx:844
 TGScrollBar.cxx:845
 TGScrollBar.cxx:846
 TGScrollBar.cxx:847
 TGScrollBar.cxx:848
 TGScrollBar.cxx:849
 TGScrollBar.cxx:850
 TGScrollBar.cxx:851
 TGScrollBar.cxx:852
 TGScrollBar.cxx:853
 TGScrollBar.cxx:854
 TGScrollBar.cxx:855
 TGScrollBar.cxx:856
 TGScrollBar.cxx:857
 TGScrollBar.cxx:858
 TGScrollBar.cxx:859
 TGScrollBar.cxx:860
 TGScrollBar.cxx:861
 TGScrollBar.cxx:862
 TGScrollBar.cxx:863
 TGScrollBar.cxx:864
 TGScrollBar.cxx:865
 TGScrollBar.cxx:866
 TGScrollBar.cxx:867
 TGScrollBar.cxx:868
 TGScrollBar.cxx:869
 TGScrollBar.cxx:870
 TGScrollBar.cxx:871
 TGScrollBar.cxx:872
 TGScrollBar.cxx:873
 TGScrollBar.cxx:874
 TGScrollBar.cxx:875
 TGScrollBar.cxx:876
 TGScrollBar.cxx:877
 TGScrollBar.cxx:878
 TGScrollBar.cxx:879
 TGScrollBar.cxx:880
 TGScrollBar.cxx:881
 TGScrollBar.cxx:882
 TGScrollBar.cxx:883
 TGScrollBar.cxx:884
 TGScrollBar.cxx:885
 TGScrollBar.cxx:886
 TGScrollBar.cxx:887
 TGScrollBar.cxx:888
 TGScrollBar.cxx:889
 TGScrollBar.cxx:890
 TGScrollBar.cxx:891
 TGScrollBar.cxx:892
 TGScrollBar.cxx:893
 TGScrollBar.cxx:894
 TGScrollBar.cxx:895
 TGScrollBar.cxx:896
 TGScrollBar.cxx:897
 TGScrollBar.cxx:898
 TGScrollBar.cxx:899
 TGScrollBar.cxx:900
 TGScrollBar.cxx:901
 TGScrollBar.cxx:902
 TGScrollBar.cxx:903
 TGScrollBar.cxx:904
 TGScrollBar.cxx:905
 TGScrollBar.cxx:906
 TGScrollBar.cxx:907
 TGScrollBar.cxx:908
 TGScrollBar.cxx:909
 TGScrollBar.cxx:910
 TGScrollBar.cxx:911
 TGScrollBar.cxx:912
 TGScrollBar.cxx:913
 TGScrollBar.cxx:914
 TGScrollBar.cxx:915
 TGScrollBar.cxx:916
 TGScrollBar.cxx:917
 TGScrollBar.cxx:918
 TGScrollBar.cxx:919
 TGScrollBar.cxx:920
 TGScrollBar.cxx:921
 TGScrollBar.cxx:922
 TGScrollBar.cxx:923
 TGScrollBar.cxx:924
 TGScrollBar.cxx:925
 TGScrollBar.cxx:926
 TGScrollBar.cxx:927
 TGScrollBar.cxx:928
 TGScrollBar.cxx:929
 TGScrollBar.cxx:930
 TGScrollBar.cxx:931
 TGScrollBar.cxx:932
 TGScrollBar.cxx:933
 TGScrollBar.cxx:934
 TGScrollBar.cxx:935
 TGScrollBar.cxx:936
 TGScrollBar.cxx:937
 TGScrollBar.cxx:938
 TGScrollBar.cxx:939
 TGScrollBar.cxx:940
 TGScrollBar.cxx:941
 TGScrollBar.cxx:942
 TGScrollBar.cxx:943
 TGScrollBar.cxx:944
 TGScrollBar.cxx:945
 TGScrollBar.cxx:946
 TGScrollBar.cxx:947
 TGScrollBar.cxx:948
 TGScrollBar.cxx:949
 TGScrollBar.cxx:950
 TGScrollBar.cxx:951
 TGScrollBar.cxx:952
 TGScrollBar.cxx:953
 TGScrollBar.cxx:954
 TGScrollBar.cxx:955
 TGScrollBar.cxx:956
 TGScrollBar.cxx:957
 TGScrollBar.cxx:958
 TGScrollBar.cxx:959
 TGScrollBar.cxx:960
 TGScrollBar.cxx:961
 TGScrollBar.cxx:962
 TGScrollBar.cxx:963
 TGScrollBar.cxx:964
 TGScrollBar.cxx:965
 TGScrollBar.cxx:966
 TGScrollBar.cxx:967
 TGScrollBar.cxx:968
 TGScrollBar.cxx:969
 TGScrollBar.cxx:970
 TGScrollBar.cxx:971
 TGScrollBar.cxx:972
 TGScrollBar.cxx:973
 TGScrollBar.cxx:974
 TGScrollBar.cxx:975
 TGScrollBar.cxx:976
 TGScrollBar.cxx:977
 TGScrollBar.cxx:978
 TGScrollBar.cxx:979
 TGScrollBar.cxx:980
 TGScrollBar.cxx:981
 TGScrollBar.cxx:982
 TGScrollBar.cxx:983
 TGScrollBar.cxx:984
 TGScrollBar.cxx:985
 TGScrollBar.cxx:986
 TGScrollBar.cxx:987