//*CMZ :  2.00/00 01/03/98  19.58.36  by  Fons Rademakers
//*-- Author :    Fons Rademakers   17/01/98

//*KEEP,CopyRight,T=C.
/*************************************************************************
 * Copyright(c) 1995-1999, The ROOT System, All rights reserved.         *
 * Authors: Rene Brun, Fons Rademakers.                                  *
 * For list of contributors see $ROOTSYS/AA_CREDITS.                     *
 *                                                                       *
 * Permission to use, copy, modify and distribute this software and its  *
 * documentation for non-commercial purposes is hereby granted without   *
 * fee, provided that the above copyright notice appears in all copies   *
 * and that both the copyright notice and this permission notice appear  *
 * in the supporting documentation. The authors make no claims about the *
 * suitability of this software for any purpose. It is provided "as is"  *
 * without express or implied warranty.                                  *
 *************************************************************************/
//*KEEP,CopyLeft.
/**************************************************************************

    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.

**************************************************************************/
//*KEND.

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGListView, TGLVContainer and TGLVEntry                              //
//                                                                      //
// A list view is a widget that can contain a number of items           //
// arranged in a grid or list. The items can be represented either      //
// by a string or by an icon.                                           //
//                                                                      //
// The TGListView is user callable. The other classes are service       //
// classes of the list view.                                            //
//                                                                      //
// A list view can generate the following events:                       //
// kC_CONTAINER, kCT_SELCHANGED, total items, selected items.           //
// kC_CONTAINER, kCT_ITEMCLICK, which button, location (y<<16|x).       //
// kC_CONTAINER, kCT_ITEMDBLCLICK, which button, location (y<<16|x).    //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

//*KEEP,TGListView.
#include "TGListView.h"
//*KEEP,TGPicture.
#include "TGPicture.h"
//*KEEP,TGButton.
#include "TGButton.h"
//*KEEP,TGScrollBar.
#include "TGScrollBar.h"
//*KEEP,TList.
#include "TList.h"
//*KEEP,TMath.
#include "TMath.h"
//*KEND.


ClassImp(TGLVEntry)
ClassImp(TGLVContainer)
ClassImp(TGListView)



//______________________________________________________________________________
 TGLVEntry::TGLVEntry(const TGWindow *p, const TGPicture *bigpic,
                     const TGPicture *smallpic, TGString *name,
                     TGString **subnames, EListViewMode viewMode,
                     UInt_t options, ULong_t back) :
   TGFrame(p, 10, 10, options, back)
{
   // Create a list view item.

   int i;

   fSelPic = 0;

   fCurrent  =
   fBigPic   = bigpic;
   fSmallPic = smallpic;

   fName = name;
   fSubnames = subnames;
   fUserData = 0;

   fCpos  =
   fJmode = 0;

   fActive = kFALSE;

   fNormGC     = fgDefaultGC;
   fFontStruct = fgDefaultFontStruct;

   int max_ascent, max_descent;
   fTWidth = gGXW->TextWidth(fFontStruct, fName->GetString(), fName->GetLength());
   gGXW->GetFontProperties(fFontStruct, max_ascent, max_descent);
   fTHeight = max_ascent + max_descent;

   if (fSubnames) {
      for (i = 0; fSubnames[i] != 0; ++i)
         ;
      fCtw = new int[i];
      for (i = 0; fSubnames[i] != 0; ++i)
         fCtw[i] = gGXW->TextWidth(fFontStruct, fSubnames[i]->GetString(),
                                   fSubnames[i]->GetLength());
   } else {
      fCtw = 0;
   }

   fViewMode = (EListViewMode)-1;
   SetViewMode(viewMode);
}

//______________________________________________________________________________
 TGLVEntry::~TGLVEntry()
{
   // Delete a list view item.

   int i;

   if (fName) delete fName;
   if (fSelPic) delete fSelPic;
   if (fSubnames) {
      for (i = 0; fSubnames[i] != 0; ++i) delete fSubnames[i];
      delete [] fSubnames;
      delete [] fCtw;
   }
}

//______________________________________________________________________________
 void TGLVEntry::Activate(Bool_t a)
{
   // Make list view item active.

   if (fActive == a) return;
   fActive = a;

   if (fActive) {
      fSelPic = new TGSelectedPicture(fClient, fCurrent);
   } else {
      if (fSelPic) delete fSelPic;
      fSelPic = 0;
   }
   DoRedraw();
}

//______________________________________________________________________________
 void TGLVEntry::SetViewMode(EListViewMode viewMode)
{
   // Set the view mode for this list item.

   if (viewMode != fViewMode) {
      fViewMode = viewMode;
      if (viewMode == kLVLargeIcons)
         fCurrent = fBigPic;
      else
         fCurrent = fSmallPic;
      if (fActive) {
         if (fSelPic) delete fSelPic;
         fSelPic = new TGSelectedPicture(fClient, fCurrent);
      }
      gGXW->ClearWindow(fId);
      Resize(GetDefaultSize());
      fClient->NeedRedraw(this);
   }
}

//______________________________________________________________________________
 void TGLVEntry::DoRedraw()
{
   // Redraw list view item.

   int ix, iy, lx, ly;

   if (fViewMode == kLVLargeIcons) {
      ix = (fWidth - fCurrent->GetWidth()) >> 1;
      iy = 0;
      lx = (fWidth - fTWidth) >> 1;
      ly = fHeight - (fTHeight+1) - 2;
   } else {
      ix = 0;
      iy = (fHeight - fCurrent->GetHeight()) >> 1;
      lx = fCurrent->GetWidth() + 2;
      ly = (fHeight - (fTHeight+1)) >> 1;
   }

   if (fActive) {
      if (fSelPic) fSelPic->Draw(fId, fNormGC, ix, iy);
      gGXW->SetForeground(fNormGC, fgDefaultSelectedBackground);
      gGXW->FillRectangle(fId, fNormGC, lx, ly, fTWidth, fTHeight+1);
      gGXW->SetForeground(fNormGC, fgSelPixel);
   } else {
      fCurrent->Draw(fId, fNormGC, ix, iy);
      gGXW->SetForeground(fNormGC, fgWhitePixel);
      gGXW->FillRectangle(fId, fNormGC, lx, ly, fTWidth, fTHeight+1);
      gGXW->SetForeground(fNormGC, fgBlackPixel);
   }

   int max_ascent, max_descent;
   gGXW->GetFontProperties(fFontStruct, max_ascent, max_descent);
   fName->Draw(fId, fNormGC, lx, ly + max_ascent);

   gGXW->SetForeground(fNormGC, fgBlackPixel);

   if (fViewMode == kLVDetails) {
      if (fSubnames && fCpos && fJmode && fCtw) {
         int i;

         for (i = 0; fSubnames[i] != 0; ++i) {
            if (fJmode[i] == kTextRight)
               lx = fCpos[i+1] - fCtw[i] - 2;
            else if (fJmode[i] == kTextCenterX)
               lx = (fCpos[i] + fCpos[i+1] - fCtw[i]) >> 1;
            else // default to TEXT_LEFT
               lx = fCpos[i] + 2;
            fSubnames[i]->Draw(fId, fNormGC, lx, ly + max_ascent);
         }
      }
   }
}

//______________________________________________________________________________
 TGDimension TGLVEntry::GetDefaultSize() const
{
   // Get default size of list item.

   TGDimension size;
   TGDimension isize(fCurrent->GetWidth(), fCurrent->GetHeight());
   TGDimension lsize(fTWidth, fTHeight+1);

   switch (fViewMode) {
      default:
      case kLVLargeIcons:
         size.fWidth = TMath::Max(isize.fWidth, lsize.fWidth);
         size.fHeight = isize.fHeight + lsize.fHeight + 6;
         break;

      case kLVSmallIcons:
      case kLVList:
      case kLVDetails:
         size.fWidth = isize.fWidth + lsize.fWidth + 4;
         size.fHeight = TMath::Max(isize.fHeight, lsize.fHeight);
         break;
   }
   return size;
}



//______________________________________________________________________________
TGLVContainer::TGLVContainer(const TGWindow *p, UInt_t w, UInt_t h,
                             UInt_t options, ULong_t back) :
   TGCompositeFrame(p, w, h, options, back)
{
   // Create a list view container. This is the (large) frame that contains
   // all the list items. It will be show through a TGViewPort (which is
   // created by the TGCanvas derived TGListView).

   fMsgWindow  = p;
   fLastActive = 0;
   fDragging   = kFALSE;
   fTotal = fSelected = 0;

   fCpos = fJmode = 0;

   fViewMode = kLVLargeIcons;
   fItemLayout = new TGLayoutHints(kLHintsExpandY | kLHintsCenterX);

   SetLayoutManager(new TGTileLayout(this, 8));

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

//______________________________________________________________________________
TGLVContainer::~TGLVContainer()
{
   // Delete list view container.

   RemoveAll();
   delete fItemLayout;
}

//______________________________________________________________________________
void TGLVContainer::SetViewMode(EListViewMode viewMode)
{
   // Set list view mode for container.

   if (fViewMode != viewMode) {
      TGLayoutHints *oldLayout = fItemLayout;

      fViewMode = viewMode;
      if (viewMode == kLVLargeIcons)
         fItemLayout = new TGLayoutHints(kLHintsExpandY | kLHintsCenterX);
      else
         fItemLayout = new TGLayoutHints(kLHintsLeft | kLHintsCenterY);

      TGFrameElement *el;
      TIter next(fList);
      while ((el = (TGFrameElement *) next())) {
         el->fLayout = fItemLayout;
         ((TGLVEntry *) el->fFrame)->SetViewMode(viewMode);
      }
      delete oldLayout;

      switch (viewMode) {
         default:
         case kLVLargeIcons:
            SetLayoutManager(new TGTileLayout(this, 8));
            break;

         case kLVSmallIcons:
            SetLayoutManager(new TGTileLayout(this, 2));
            break;

         case kLVList:
            SetLayoutManager(new TGListLayout(this, 2));
            break;

         case kLVDetails:
            SetLayoutManager(new TGListDetailsLayout(this, 2));
            break;
      }
      //TGCanvas *canvas = (TGCanvas *) this->GetParent()->GetParent();
      //canvas->Layout();
   }
}

//______________________________________________________________________________
void TGLVContainer::SetColumns(Int_t *cpos, Int_t *jmode)
{
   // Set column information for list items.

   fCpos  = cpos;
   fJmode = jmode;

   TGFrameElement *el;
   TIter next(fList);
   while ((el = (TGFrameElement *) next()))
      ((TGLVEntry *) el->fFrame)->SetColumns(fCpos, fJmode);

   Layout();
}

//______________________________________________________________________________
TGDimension TGLVContainer::GetMaxItemSize() const
{
   // Get maximum item size of all list view items in the container.

   TGDimension csize, maxsize(0,0);

   TGFrameElement *el;
   TIter next(fList);
   while ((el = (TGFrameElement *) next())) {
      csize = el->fFrame->GetDefaultSize();
      maxsize.fWidth  = TMath::Max(maxsize.fWidth, csize.fWidth);
      maxsize.fHeight = TMath::Max(maxsize.fHeight, csize.fHeight);
   }
   if (fViewMode == kLVLargeIcons) {
      maxsize.fWidth  += 8;
      maxsize.fHeight += 8;
   } else {
      maxsize.fWidth  += 2;
      maxsize.fHeight += 2;
   }
   return maxsize;
}

//______________________________________________________________________________
Bool_t TGLVContainer::HandleButton(Event_t *event)
{
   // Handle mouse button event in container.

   int total, selected;

   if (event->fType == kButtonPress) {
      fXp = event->fX;
      fYp = event->fY;

      if (fLastActive) {
         fLastActive->Activate(kFALSE);
         fLastActive = 0;
      }
      total = selected = 0;

      TGFrameElement *el;
      TIter next(fList);
      while ((el = (TGFrameElement *) next())) {
         TGLVEntry *f = (TGLVEntry *) el->fFrame;
         ++total;
         if (f->GetId() == (Window_t)event->fUser[0]) {  // fUser[0] = subwindow
            f->Activate(kTRUE);
            ++selected;
            fLastActive = f;
         } else {
            f->Activate(kFALSE);
         }
      }

      if (fTotal != total || fSelected != selected) {
         fTotal = total;
         fSelected = selected;
         SendMessage(fMsgWindow, MK_MSG(kC_CONTAINER, kCT_SELCHANGED),
                     fTotal, fSelected);
      }

      if (selected == 0) {
         fDragging = kTRUE;
         fX0 = fXf = fXp;
         fY0 = fYf = fYp;
         gGXW->DrawRectangle(fId, fgLineGC, fX0, fY0, fXf-fX0, fYf-fY0);
      }
   }

   if (event->fType == kButtonRelease) {
      if (fDragging) {
         fDragging = kFALSE;
         gGXW->DrawRectangle(fId, fgLineGC, fX0, fY0, fXf-fX0, fYf-fY0);
      } else {
         SendMessage(fMsgWindow, MK_MSG(kC_CONTAINER, kCT_ITEMCLICK),
                     event->fCode, (event->fYRoot << 16) | event->fXRoot);
      }
   }
   return kTRUE;
}

//______________________________________________________________________________
Bool_t TGLVContainer::HandleDoubleClick(Event_t *event)
{
   // Handle double click mouse event.

   TGFrameElement *el;
   TIter next(fList);
   while ((el = (TGFrameElement *) next())) {
      TGLVEntry *f = (TGLVEntry *) el->fFrame;
      if (f->GetId() == (Window_t)event->fUser[0]) {   // fUser[0] = subwindow
         SendMessage(fMsgWindow, MK_MSG(kC_CONTAINER, kCT_ITEMDBLCLICK),
                     event->fCode, (event->fYRoot << 16) | event->fXRoot);
         break;
      }
   }
   return kTRUE;
}

//______________________________________________________________________________
Bool_t TGLVContainer::HandleMotion(Event_t *event)
{
   // Handle mouse motion events.

   int xf0, yf0, xff, yff, total, selected;

   if (fDragging) {
      gGXW->DrawRectangle(fId, fgLineGC, fX0, fY0, fXf-fX0, fYf-fY0);
      fX0 = TMath::Min(fXp, event->fX);
      fXf = TMath::Max(fXp, event->fX);
      fY0 = TMath::Min(fYp, event->fY);
      fYf = TMath::Max(fYp, event->fY);

      total = selected = 0;

      TGFrameElement *el;
      TIter next(fList);
      while ((el = (TGFrameElement *) next())) {
         TGLVEntry *f = (TGLVEntry *) el->fFrame;
         ++total;
         xf0 = f->GetX() + (f->GetWidth() >> 3);
         yf0 = f->GetY() + (f->GetHeight() >> 3);
         xff = xf0 + f->GetWidth() - (f->GetWidth() >> 2);
         yff = yf0 + f->GetHeight() - (f->GetHeight() >> 2);

         if (((xf0 > fX0 && xf0 < fXf) ||
              (xff > fX0 && xff < fXf)) &&
             ((yf0 > fY0 && yf0 < fYf) ||
              (yff > fY0 && yff < fYf))) {
            f->Activate(kTRUE);
            ++selected;
         } else {
            f->Activate(kFALSE);
         }
      }

      gGXW->DrawRectangle(fId, fgLineGC, fX0, fY0, fXf-fX0, fYf-fY0);

      if (fTotal != total || fSelected != selected) {
         fTotal = total;
         fSelected = selected;
         SendMessage(fMsgWindow, MK_MSG(kC_CONTAINER, kCT_SELCHANGED),
                     fTotal, fSelected);
      }
   }
   return kTRUE;
}

//______________________________________________________________________________
void TGLVContainer::UnSelectAll()
{
   // Unselect all items in the container.

   TGFrameElement *el;
   TIter next(fList);
   while ((el = (TGFrameElement *) next())) {
      TGLVEntry *f = (TGLVEntry *) el->fFrame;
      f->Activate(kFALSE);
   }

   fSelected = 0;
   SendMessage(fMsgWindow, MK_MSG(kC_CONTAINER, kCT_SELCHANGED),
               fTotal, fSelected);
}

//______________________________________________________________________________
void TGLVContainer::SelectAll()
{
   // Select all items in the container.

   TGFrameElement *el;
   TIter next(fList);
   while ((el = (TGFrameElement *) next())) {
      TGLVEntry *f = (TGLVEntry *) el->fFrame;
      f->Activate(kTRUE);
   }

   fSelected = fTotal;
   SendMessage(fMsgWindow, MK_MSG(kC_CONTAINER, kCT_SELCHANGED),
               fTotal, fSelected);
}

//______________________________________________________________________________
void TGLVContainer::InvertSelection()
{
   // Incert the selection, all selected items become unselected and
   // vice versa.

   int selected = 0;

   TGFrameElement *el;
   TIter next(fList);
   while ((el = (TGFrameElement *) next())) {
      TGLVEntry *f = (TGLVEntry *) el->fFrame;
      if (f->IsActive()) {
         f->Activate(kFALSE);
      } else {
         f->Activate(kTRUE);
         ++selected;
      }
   }

   fSelected = selected;
   SendMessage(fMsgWindow, MK_MSG(kC_CONTAINER, kCT_SELCHANGED),
               fTotal, fSelected);
}

//______________________________________________________________________________
void TGLVContainer::RemoveAll()
{
   // Remove all items from the container.

   TGFrameElement *el;
   TIter next(fList);
   while ((el = (TGFrameElement *) next())) {
      el->fFrame->DestroyWindow();
      delete el->fFrame;
   }
   fList->Delete();

   fSelected = fTotal = 0;
   fLastActive = 0;
   SendMessage(fMsgWindow, MK_MSG(kC_CONTAINER, kCT_SELCHANGED),
               fTotal, fSelected);
}

//______________________________________________________________________________
void TGLVContainer::RemoveItem(TGLVEntry *item)
{
   // Remove item from container.

   TGFrameElement *el;
   TIter next(fList);
   while ((el = (TGFrameElement *) next())) {
      if (item == el->fFrame) {
         if (item == fLastActive) fLastActive = 0;
         if (item->IsActive()) fSelected--;
         fTotal--;
         item->DestroyWindow();
         delete item;
         fList->Remove(el);
         break;
      }
   }
}

//______________________________________________________________________________
void TGLVContainer::RemoveItemWithData(void *userData)
{
   // Remove item with fUserData == userData from container.

   TGFrameElement *el;
   TIter next(fList);
   while ((el = (TGFrameElement *) next())) {
      TGLVEntry *f = (TGLVEntry *) el->fFrame;
      if (f->GetUserData() == userData) {
         RemoveItem(f);
         break;
      }
   }
}

//______________________________________________________________________________
const TGLVEntry *TGLVContainer::GetNextSelected(void **current)
{
   // Return next selected item.

   TGLVEntry *f;
   TObjLink *lnk = (TObjLink *) *current;

   lnk = (lnk == 0) ? fList->FirstLink() : lnk->Next();
   while (lnk) {
      f = (TGLVEntry *) ((TGFrameElement *) lnk->GetObject())->fFrame;
      if (f->IsActive()) {
         *current = (void *) lnk;
         return f;
      }
      lnk = lnk->Next();
   }
   return 0;
}



//______________________________________________________________________________
TGListView::TGListView(const TGWindow *p, UInt_t w, UInt_t h,
                       UInt_t options, ULong_t back) :
   TGCanvas(p, w, h, options, back)
{
   // Create a list view widget.

   int i;

   fViewMode = kLVLargeIcons;

   // for test only...
   fColHeader[0] = new TGTextButton(this, new TGHotString("Name"),
                                    1, fgDefaultGC, fgDefaultFontStruct);
   fColHeader[1] = new TGTextButton(this, new TGHotString("Attributes"),
                                    3, fgDefaultGC, fgDefaultFontStruct);
   fColHeader[2] = new TGTextButton(this, new TGHotString("Size"),
                                    2, fgDefaultGC, fgDefaultFontStruct);
   fColHeader[3] = new TGTextButton(this, new TGHotString("Owner"),
                                    3, fgDefaultGC, fgDefaultFontStruct);
   fColHeader[4] = new TGTextButton(this, new TGHotString("Group"),
                                    3, fgDefaultGC, fgDefaultFontStruct);
   fColHeader[5] = new TGTextButton(this, new TGHotString("Modified"),
                                    3, fgDefaultGC, fgDefaultFontStruct);
   fColHeader[6] = new TGTextButton(this, new TGHotString(""),
                                    4, fgDefaultGC, fgDefaultFontStruct);

   fColHeader[0]->SetTextJustify(kTextLeft | kTextCenterY);
   fColHeader[1]->SetTextJustify(kTextCenterX | kTextCenterY);
   fColHeader[2]->SetTextJustify(kTextRight | kTextCenterY);
   fColHeader[3]->SetTextJustify(kTextCenterX | kTextCenterY);
   fColHeader[4]->SetTextJustify(kTextCenterX | kTextCenterY);
   fColHeader[5]->SetTextJustify(kTextCenterX | kTextCenterY);
   fColHeader[6]->SetTextJustify(kTextCenterX | kTextCenterY);

   fColHeader[6]->SetState(kButtonDisabled);

   //for (i = 0; i < 7; ++i)
   //  TGCompositeFrame::AddFrame(fColHeader[i], 0);

   int xl = fBorderWidth + fColHeader[0]->GetDefaultWidth() + 20 + 10;

   for (i = 1; i < 7; ++i) {
      fColumns[i-1] = xl;
      xl += fColHeader[i]->GetDefaultWidth() + 20;
   }
   fColumns[6] = 0;

   fJmode[0] = kTextCenterX;
   fJmode[1] = kTextRight;
   fJmode[2] = kTextCenterX;
   fJmode[3] = kTextCenterX;
   fJmode[4] = kTextCenterX;
   fJmode[5] = kTextCenterX;
   fJmode[6] = kTextCenterX;
}

//______________________________________________________________________________
TGListView::~TGListView()
{
   // Delete a list view widget.

   delete fColHeader[0];
   delete fColHeader[1];
   delete fColHeader[2];
   delete fColHeader[3];
   delete fColHeader[4];
   delete fColHeader[5];
   delete fColHeader[6];
}

//______________________________________________________________________________
void TGListView::SetHeader(const char *s, Int_t mode, Int_t idx)
{
   // Set header button idx (0-6), mode is the x text alignmode
   // (ETextJustification).

   if (idx < 0 || idx > 6) {
      Error("SetHeader", "header index must be between 0 - 6");
      return;
   }
   delete fColHeader[idx];
   fColHeader[idx] = new TGTextButton(this, new TGHotString(s),
                                      -1, fgDefaultGC, fgDefaultFontStruct);
   fColHeader[idx]->SetTextJustify(mode | kTextCenterY);
}

//______________________________________________________________________________
void TGListView::SetViewMode(EListViewMode viewMode)
{
   // Set list view mode.

   TGLVContainer *container;

   if (fViewMode != viewMode) {
      fViewMode = viewMode;
      container = (TGLVContainer *) fVport->GetContainer();
      if (container) container->SetViewMode(viewMode);
      Layout();
   }
}

//______________________________________________________________________________
void TGListView::SetContainer(TGFrame *f)
{
   // Set list view container. Container must be at least of type
   // TGLVContainer.

   if (f->InheritsFrom(TGLVContainer::Class())) {
      TGCanvas::SetContainer(f);
      ((TGLVContainer *) f)->SetColumns(fColumns, fJmode);
   } else
      Error("SetContainer", "frame must inherit from TGLVContainer");
}

//______________________________________________________________________________
void TGListView::Layout()
{
   // Layout list view components (container and contents of container).

   Int_t  i, xl = fBorderWidth;
   UInt_t w, h = 0;

   TGLVContainer *container = (TGLVContainer *) fVport->GetContainer();
   if (!container) {
      Error("Layout", "no listview container set yet");
      return;
   }
   fMaxSize = container->GetMaxItemSize();

   if (fViewMode == kLVDetails) {

      // for test only...
      h = fColHeader[0]->GetDefaultHeight()-4;
      for (i = 0; i < 6; ++i) {
         w = fColHeader[i]->GetDefaultWidth()+20;
         if (i == 0) w = fMaxSize.fWidth + 10;
         fColHeader[i]->MoveResize(xl, fBorderWidth, w, h);
         fColHeader[i]->MapWindow();
         xl += w;
         fColumns[i] = xl-fBorderWidth-2;  // -2 is fSep in the layout routine
      }
      fColHeader[i]->MoveResize(xl, fBorderWidth, fVport->GetWidth()-xl+fBorderWidth, h);
      fColHeader[i]->MapWindow();
      fVScrollbar->RaiseWindow();

      container->SetColumns(fColumns, fJmode);

   } else {
      for (i = 0; i < 7; ++i)
        fColHeader[i]->UnmapWindow();
   }

   TGCanvas::Layout();
   if (fViewMode == kLVList) {
      if (fMaxSize.fWidth > 0)
         fHScrollbar->SetRange(container->GetWidth()/fMaxSize.fWidth,
                               fVport->GetWidth()/fMaxSize.fWidth);
   }
   if (fViewMode == kLVDetails) {
      fColHeader[i]->MoveResize(xl, fBorderWidth, fVport->GetWidth()-xl+fBorderWidth, h);
      fVport->MoveResize(fBorderWidth, fBorderWidth+h, fVport->GetWidth(), fVport->GetHeight()-h);
      fVScrollbar->SetRange(container->GetHeight(), fVport->GetHeight());
   }
}

//______________________________________________________________________________
Bool_t TGListView::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
{
   // Handle messages generated by the list view components.

   if ((fViewMode == kLVList) && (GET_MSG(msg) == kC_HSCROLL)) {
      switch (GET_SUBMSG(msg)) {
         case kSB_SLIDERTRACK:
         case kSB_SLIDERPOS:
           fVport->SetHPos((Int_t)-parm1 * fMaxSize.fWidth);
           break;
      }
   } else {
      return TGCanvas::ProcessMessage(msg, parm1, parm2);
   }
   return kTRUE;
}


ROOT page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.