library: libGui #include "TGListTree.h"

# TGListTree

class description - source file - inheritance tree (.pdf)

## class TGListTree : public TGContainer

| Inheritance Chart:

`TObject`

<-

`TGObject`

<-

`TGWindow`

`TQObject`

<-

`TGFrame`

<-

`TGCompositeFrame`

<-

`TGContainer`

<-

`TGListTree`

        protected:

                 virtual void Clicked(TGFrame*, Int_t)
                 virtual void Clicked(TGFrame*, Int_t, Int_t, Int_t)
                 virtual void CurrentChanged(Int_t, Int_t)
                 virtual void CurrentChanged(TGFrame*)
                 virtual void DoRedraw()
                 virtual void DoubleClicked(TGFrame*, Int_t)
                 virtual void DoubleClicked(TGFrame*, Int_t, Int_t, Int_t)
                         void Draw(Int_t yevent, Int_t hevent)
                 virtual void Draw(Option_t* = "")
                        Int_t DrawChildren(TGListTreeItem* item, Int_t x, Int_t y, Int_t xroot)
                         void DrawItem(TGListTreeItem* item, Int_t x, Int_t y, Int_t* xroot, UInt_t* retwidth, UInt_t* retheight)
                         void DrawItemName(TGListTreeItem* item)
                         void DrawNode(TGListTreeItem* item, Int_t x, Int_t y)
              TGListTreeItem* FindItem(Int_t findy)
                virtual void* FindItem(const TString& name, Bool_t direction = kTRUE, Bool_t caseSensitive = kTRUE, Bool_t beginWith = kFALSE)
          static FontStruct_t GetDefaultFontStruct()
           static const TGGC& GetDrawGC() const
               static Pixel_t GetGrayPixel()
           static const TGGC& GetHighlightGC() const
           static const TGGC& GetLineGC() const
                         void InsertChild(TGListTreeItem* parent, TGListTreeItem* item)
                         void InsertChildren(TGListTreeItem* parent, TGListTreeItem* item)
                 virtual void KeyPressed(TGFrame*, UInt_t, UInt_t)
                 virtual void Layout()
                 virtual void OnMouseOver(TGFrame*)
                         void PDeleteChildren(TGListTreeItem* item)
                         void RemoveReference(TGListTreeItem* item)
                 virtual void ReturnPressed(TGFrame*)
                        Int_t SearchChildren(TGListTreeItem* item, Int_t y, Int_t findy, TGListTreeItem** finditem)

        public:

                              TGListTree(TGWindow* p = 0, UInt_t w = 1, UInt_t h = 1, UInt_t options = 0, Pixel_t back = GetWhitePixel())
                              TGListTree(TGCanvas* p, UInt_t options, Pixel_t back = GetWhitePixel())
                              TGListTree(const TGListTree&)
                      virtual ~TGListTree()
              TGListTreeItem* AddItem(TGListTreeItem* parent, const char* string, const TGPicture* open = 0, const TGPicture* closed = 0)
              TGListTreeItem* AddItem(TGListTreeItem* parent, const char* string, void* userData, const TGPicture* open = 0, const TGPicture* closed = 0)
                         void AdjustPosition(TGListTreeItem* item)
                 virtual void AdjustPosition()
               static TClass* Class()
                         void ClearHighlighted()
                 virtual void Clicked(TGListTreeItem* entry, Int_t btn)
                 virtual void Clicked(TGListTreeItem* entry, Int_t btn, Int_t x, Int_t y)
                         void CloseItem(TGListTreeItem* item)
                        Int_t DeleteChildren(TGListTreeItem* item)
                        Int_t DeleteItem(TGListTreeItem* item)
                 virtual void DoubleClicked(TGListTreeItem* entry, Int_t btn)
                 virtual void DoubleClicked(TGListTreeItem* entry, Int_t btn, Int_t x, Int_t y)
                 virtual void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
                 virtual void End(Bool_t select = kFALSE)
              TGListTreeItem* FindChildByData(TGListTreeItem* item, void* userData)
              TGListTreeItem* FindChildByName(TGListTreeItem* item, const char* name)
              TGListTreeItem* FindItemByPathname(const char* path)
              TGListTreeItem* FindSiblingByData(TGListTreeItem* item, void* userData)
              TGListTreeItem* FindSiblingByName(TGListTreeItem* item, const char* name)
          virtual TGDimension GetDefaultSize() const
              TGListTreeItem* GetFirstItem() const
                         void GetPathnameFromItem(TGListTreeItem* item, char* path, Int_t depth = 0)
              TGListTreeItem* GetSelected() const
               virtual Bool_t HandleButton(Event_t* event)
               virtual Bool_t HandleCrossing(Event_t* event)
               virtual Bool_t HandleDoubleClick(Event_t* event)
               virtual Bool_t HandleExpose(Event_t* event)
               virtual Bool_t HandleKey(Event_t* event)
               virtual Bool_t HandleMotion(Event_t* event)
                         void HighlightChildren(TGListTreeItem* item, Bool_t state, Bool_t draw)
                         void HighlightItem(TGListTreeItem* item)
                         void HighlightItem(TGListTreeItem* item, Bool_t state, Bool_t draw)
                 virtual void Home(Bool_t select = kFALSE)
              virtual TClass* IsA() const
                 virtual void KeyPressed(TGListTreeItem* entry, UInt_t keysym, UInt_t mask)
                 virtual void LineDown(Bool_t select = kFALSE)
                 virtual void LineUp(Bool_t select = kFALSE)
                 virtual void OnMouseOver(TGListTreeItem* entry)
                         void OpenItem(TGListTreeItem* item)
                 virtual void PageDown(Bool_t select = kFALSE)
                 virtual void PageUp(Bool_t select = kFALSE)
                        Int_t RecursiveDeleteItem(TGListTreeItem* item, void* userData)
                         void RenameItem(TGListTreeItem* item, const char* string)
                        Int_t Reparent(TGListTreeItem* item, TGListTreeItem* newparent)
                        Int_t ReparentChildren(TGListTreeItem* item, TGListTreeItem* newparent)
                 virtual void ReturnPressed(TGListTreeItem* entry)
                 virtual void SavePrimitive(ofstream& out, Option_t* option)
                 virtual void Search()
                         void SetAutoTips(Bool_t on = kTRUE)
                 virtual void SetCanvas(TGCanvas* canvas)
                         void SetToolTipItem(TGListTreeItem* item, const char* string)
                         void SetToolTipText(const char* text, Int_t x, Int_t y, Long_t delayms)
                 virtual void ShowMembers(TMemberInspector& insp, char* parent)
                        Int_t Sort(TGListTreeItem* item)
                        Int_t SortChildren(TGListTreeItem* item)
                        Int_t SortSiblings(TGListTreeItem* item)
                 virtual void Streamer(TBuffer& b)
                         void StreamerNVirtual(TBuffer& b)
                         void UnselectAll(Bool_t draw)

### Data Members

        protected:

               TGListTreeItem* fFirst         pointer to first item in list
               TGListTreeItem* fSelected      pointer to selected item in list
                         Int_t fHspacing      horizontal spacing between items
                         Int_t fVspacing      vertical spacing between items
                         Int_t fIndent        number of pixels indentation
                         Int_t fMargin        number of pixels margin from left side
                         Int_t fLastY         last used y position
                       Pixel_t fGrayPixel     gray draw color
                    GContext_t fDrawGC        icon drawing context
                    GContext_t fLineGC        dashed line drawing context
                    GContext_t fHighlightGC   highlighted icon drawing context
                  FontStruct_t fFont          font used to draw item text
                        UInt_t fDefw          default list width
                        UInt_t fDefh          default list height
                         Int_t fExposeTop     top y postion of visible region
                         Int_t fExposeBottom  bottom y position of visible region
                    TGToolTip* fTip           tooltip shown when moving over list items
               TGListTreeItem* fTipItem       item for which tooltip is set
                        Bool_t fAutoTips      assume item->fUserData is TObject and use GetTitle() for tip text
                static Pixel_t fgGrayPixel
          static const TGFont* fgDefaultFont
                  static TGGC* fgDrawGC
                  static TGGC* fgLineGC
                  static TGGC* fgHighlightGC

## Class Description

     TGListTree and TGListTreeItem

     A list tree is a widget that can contain a number of items
     arranged in a tree structure. The items are represented by small
     folder icons that can be either open or closed.

     The TGListTree is user callable. The TGListTreeItem is a service
     class of the list tree.

     A list tree can generate the following events:
     kC_LISTTREE, kCT_ITEMCLICK, which button, location (y<<16|x).
     kC_LISTTREE, kCT_ITEMDBLCLICK, which button, location (y<<16|x).

TGListTree(TGWindow *p, UInt_t w, UInt_t h, UInt_t options, ULong_t back) : TGContainer(p, w, h, options, back)

     Create a list tree widget.

TGListTree(TGCanvas *p,UInt_t options,ULong_t back) : TGContainer(p, options, back)

     Create a list tree widget.

~TGListTree()

     Delete list tree widget.

void HighlightItem(TGListTreeItem *item, Bool_t state, Bool_t draw)

     Highlight tree item.

void HighlightChildren(TGListTreeItem *item, Bool_t state, Bool_t draw)

     Higlight item children.

void UnselectAll(Bool_t draw)

     Unselect all items.

Bool_t HandleButton(Event_t *event)

     Handle button events in the list tree.

Bool_t HandleDoubleClick(Event_t *event)

     Handle double click event in the list tree (only for kButton1).

Bool_t HandleExpose(Event_t * /*event*/)

     Handle expose event in the list tree.

Bool_t HandleCrossing(Event_t *event)

     Handle mouse crossing event.

Bool_t HandleMotion(Event_t *event)

     Handle mouse motion event. Only used to set tool tip.

Bool_t HandleKey(Event_t *event)

     The key press event handler converts a key press to some line editor
     action.

void OnMouseOver(TGListTreeItem *entry)

     Signal emitted when pointer is over entry.

void KeyPressed(TGListTreeItem *entry, UInt_t keysym, UInt_t mask)

     Signal emitted when keyboard key pressed

     item - selected item
     keysym - defined in "KeySymbols.h"
     mask - modifier key mask, defined in "GuiTypes.h"

     const Mask_t kKeyShiftMask   = BIT(0);
     const Mask_t kKeyLockMask    = BIT(1);
     const Mask_t kKeyControlMask = BIT(2);
     const Mask_t kKeyMod1Mask    = BIT(3);   // typically the Alt key
     const Mask_t kButton1Mask    = BIT(8);
     const Mask_t kButton2Mask    = BIT(9);
     const Mask_t kButton3Mask    = BIT(10);
     const Mask_t kButton4Mask    = BIT(11);
     const Mask_t kButton5Mask    = BIT(12);
     const Mask_t kAnyModifier    = BIT(15);

void ReturnPressed(TGListTreeItem *entry)

     Emit ReturnPressed() signal.

void Clicked(TGListTreeItem *entry, Int_t btn)

     Emit Clicked() signal.

void Clicked(TGListTreeItem *entry, Int_t btn, Int_t x, Int_t y)

     Emit Clicked() signal.

void DoubleClicked(TGListTreeItem *entry, Int_t btn)

     Emit DoubleClicked() signal.

void DoubleClicked(TGListTreeItem *entry, Int_t btn, Int_t x, Int_t y)

     Emit DoubleClicked() signal.

void Home(Bool_t /*select*/)

     Move content to the top.

void End(Bool_t /*select*/)

     Move content to the bottom.

void PageUp(Bool_t /*select*/)

     Move content one page up.

void PageDown(Bool_t /*select*/)

     Move content one page down.

void LineUp(Bool_t /*select*/)

     Move content one item-size up.

void LineDown(Bool_t /*select*/)

     Move content one item-size down.

void AdjustPosition(TGListTreeItem *item)

     Move content to position of item. If item is 0, move to position
     of currently selected item.

void Search()

     Invokes search dialog. Looks for item with the entered name.

void DrawRegion(Int_t /*x*/, Int_t /*y*/, UInt_t /*w*/, UInt_t /*h*/)

     Redraw list tree.

void DoRedraw()

     Redraw list tree.

void Draw(Int_t yevent, Int_t hevent)

     Draw list tree widget.

Int_t DrawChildren(TGListTreeItem *item, Int_t x, Int_t y, Int_t xroot)

     Draw children of item in list tree.

void DrawItem(TGListTreeItem *item, Int_t x, Int_t y, Int_t *xroot, UInt_t *retwidth, UInt_t *retheight)

     Draw list tree item.

void DrawItemName(TGListTreeItem *item)

     Draw name of list tree item.

void DrawNode(TGListTreeItem *item, Int_t x, Int_t y)

     Draw node (little + in box).

void SetToolTipText(const char *text, Int_t x, Int_t y, Long_t delayms)

     Set tool tip text associated with this item. The delay is in
     milliseconds (minimum 250). To remove tool tip call method with
     delayms = 0. To change delayms you first have to call this method
     with delayms=0.

void RemoveReference(TGListTreeItem *item)

     This function removes the specified item from the linked list.
     It does not do anything with the data contained in the item, though.

void PDeleteChildren(TGListTreeItem *item)

     Delete children of item from list.

void InsertChild(TGListTreeItem *parent, TGListTreeItem *item)

     Insert child in list.

void InsertChildren(TGListTreeItem *parent, TGListTreeItem *item)

     Insert a list of ALREADY LINKED children into another list

Int_t SearchChildren(TGListTreeItem *item, Int_t y, Int_t findy, TGListTreeItem **finditem)

     Search child item.

TGListTreeItem* FindItem(Int_t findy)

     Find item at postion findy.

TGListTreeItem* AddItem(TGListTreeItem *parent, const char *string, const TGPicture *open, const TGPicture *closed)

     Add item to list tree. Returns new item.

TGListTreeItem* AddItem(TGListTreeItem *parent, const char *string, void *userData, const TGPicture *open, const TGPicture *closed)

     Add item to list tree. If item with same userData already exists
     don't add it. Returns new item.

void RenameItem(TGListTreeItem *item, const char *string)

     Rename item in list tree.

Int_t DeleteItem(TGListTreeItem *item)

     Delete item from list tree.

void OpenItem(TGListTreeItem *item)

     Open item in list tree (i.e. show child items).

void CloseItem(TGListTreeItem *item)

     Close item in list tree (i.e. hide child items).

Int_t RecursiveDeleteItem(TGListTreeItem *item, void *ptr)

     Delete item with fUserData == ptr. Search tree downwards starting
     at item.

void SetToolTipItem(TGListTreeItem *item, const char *string)

     Set tooltip text for this item. By default an item for which the
     userData is a pointer to an TObject the TObject::GetTitle() will
     be used to get the tip text.

Int_t DeleteChildren(TGListTreeItem *item)

     Delete children of item from list.

Int_t Reparent(TGListTreeItem *item, TGListTreeItem *newparent)

     Make newparent the new parent of item.

Int_t ReparentChildren(TGListTreeItem *item, TGListTreeItem *newparent)

     Make newparent the new parent of the children of item.

Int_t Sort(TGListTreeItem *item)

     Sort items starting with item.

Int_t SortSiblings(TGListTreeItem *item)

     Sort siblings of item.

Int_t SortChildren(TGListTreeItem *item)

     Sort children of item.

TGListTreeItem* FindSiblingByName(TGListTreeItem *item, const char *name)

     Find sibling of item by name.

TGListTreeItem* FindSiblingByData(TGListTreeItem *item, void *userData)

     Find sibling of item by userData.

TGListTreeItem* FindChildByName(TGListTreeItem *item, const char *name)

     Find child of item by name.

TGListTreeItem* FindChildByData(TGListTreeItem *item, void *userData)

     Find child of item by userData.

TGListTreeItem* FindItemByPathname(const char *path)

     Find item by pathname. Pathname is in the form of /xx/yy/zz. If zz
     in path /xx/yy is found it returns item, 0 otherwise.

void HighlightItem(TGListTreeItem *item)

     Highlight item.

void ClearHighlighted()

     Un highlight items.

void GetPathnameFromItem(TGListTreeItem *item, char *path, Int_t depth)

     Get pathname from item. Use depth to limit path name to last
     depth levels. By default depth is not limited.

Pixel_t GetGrayPixel()

FontStruct_t GetDefaultFontStruct()

const TGGC& GetDrawGC()

const TGGC& GetLineGC()

const TGGC& GetHighlightGC()

void SavePrimitive(ofstream &out, Option_t *option)

     Save a list tree widget as a C++ statement(s) on output stream out

### Inline Functions

                       void Draw(Option_t* = "")
                      void* FindItem(const TString& name, Bool_t direction = kTRUE, Bool_t caseSensitive = kTRUE, Bool_t beginWith = kFALSE)
                       void Layout()
                       void CurrentChanged(Int_t, Int_t)
                       void CurrentChanged(TGFrame*)
                       void SetCanvas(TGCanvas* canvas)
                TGDimension GetDefaultSize() const
                       void SetAutoTips(Bool_t on = kTRUE)
                       void AdjustPosition()
            TGListTreeItem* GetFirstItem() const
            TGListTreeItem* GetSelected() const
                       void OnMouseOver(TGListTreeItem* entry)
                       void KeyPressed(TGListTreeItem* entry, UInt_t keysym, UInt_t mask)
                       void ReturnPressed(TGListTreeItem* entry)
                       void Clicked(TGListTreeItem* entry, Int_t btn)
                       void Clicked(TGListTreeItem* entry, Int_t btn, Int_t x, Int_t y)
                       void DoubleClicked(TGListTreeItem* entry, Int_t btn)
                       void DoubleClicked(TGListTreeItem* entry, Int_t btn, Int_t x, Int_t y)
                    TClass* Class()
                    TClass* IsA() const
                       void ShowMembers(TMemberInspector& insp, char* parent)
                       void Streamer(TBuffer& b)
                       void StreamerNVirtual(TBuffer& b)
                 TGListTree TGListTree(const TGListTree&)

Author: Fons Rademakers 25/02/98
Last update: root/gui:$Name: $:$Id: TGListTree.cxx,v 1.38 2005/06/27 15:11:53 rdm Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *