// @(#)root/treeviewer:$Id$
//Author : Andrei Gheata   16/08/00

/*************************************************************************
 * 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.             *
 *************************************************************************/

#ifndef ROOT_TTVLVContainer
#define ROOT_TTVLVContainer


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TTVLVEntry                                                           //
//                                                                      //
// This class represent entries that goes into the TreeViewer           //
// listview container. It subclasses TGLVEntry and adds 2               //
// data members: the item true name and the alias                       //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TGListView
#include "TGListView.h"
#endif


class TGLabel;
class TGTextEntry;
class TTreeViewer;
class TGToolTip;
class TTVLVEntry;
class TTVLVContainer;

class TGItemContext : public TObject {

protected:
   TTVLVEntry *fItem;       // pointer to associated item
public:
   TGItemContext();
   virtual     ~TGItemContext() { }
   void         Associate(TTVLVEntry *item) { fItem = item; }
   virtual void Delete(Option_t *) { }           // *MENU*
   void         Draw(Option_t *option="");       // *MENU*
   void         EditExpression();                // *MENU*
   void         Empty();                         // *MENU*
   void         RemoveItem();                    // *MENU*
   void         Scan();                          // *MENU*
   void         SetExpression(const char *name="", const char *alias="-empty-", Bool_t cut=kFALSE); // *MENU*

   ClassDef(TGItemContext, 0)  // Context menu for TTVLVEntry
};


class TTVLVEntry : public TGLVEntry {

protected:
   TTVLVContainer *fContainer;  // container to whom this item belongs
   TString         fTrueName;   // name for this entry
   TString         fAlias;      // alias for this entry
   TString         fConvName;   // name converted into true expressions
   TGToolTip      *fTip;        // tool tip associated with item
   Bool_t          fIsCut;      // flag for cut type items
   TGItemContext  *fContext;    // associated context menu

protected:
   Bool_t         FullConverted();

public:
   TTVLVEntry(const TGWindow *p,
              const TGPicture *bigpic, const TGPicture *smallpic,
              TGString *name, TGString **subnames, EListViewMode ViewMode);
   virtual ~TTVLVEntry();
   const char     *ConvertAliases();
   void            CopyItem(TTVLVEntry *dest);
   const char     *GetAlias() {return fAlias.Data();}
   TTVLVContainer *GetContainer() {return fContainer;}
   TGItemContext  *GetContext() {return fContext;}
   const char     *GetConvName() {return fConvName;}
   const char     *GetTrueName() {return fTrueName.Data();}
   TGToolTip      *GetTip() {return fTip;}
   virtual Bool_t  HandleCrossing(Event_t *event);
   Bool_t          HasAlias();
   Bool_t          IsCut() {return fIsCut;}
   void            PrependTilde();
   void            SetCutType(Bool_t type=kFALSE);
   void            SetItemName(const char* name);
   void            SetAlias(const char* alias) {fAlias = alias;}
   void            SetExpression(const char* name, const char* alias, Bool_t cutType=kFALSE);
   void            SetTrueName(const char* name) {fTrueName = name;}
   void            SetToolTipText(const char *text, Long_t delayms = 1000);
   void            SetSmallPic(const TGPicture *spic);
   void            Empty();

   ClassDef(TTVLVEntry,0)  // Item that goes into the tree list view widget
};


//////////////////////////////////////////////////////////////////////////
//                                                                      //
//   TTVLVContainer                                                     //
//                                                                      //
// This class represent the list view container for the                 //
// TreeView class. It is a TGLVContainer with item dragging             //
// capabilities for the TTVLVEntry objects inside                       //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

class TTVLVContainer : public TGLVContainer {

friend class TGClient;

private:
   Cursor_t     fCursor;             // current cursor
   Cursor_t     fDefaultCursor;      // default cursor
   TGListView  *fListView;           // associated list view
   TTreeViewer *fViewer;             // pointer to tree viewer
   TList       *fExpressionList;     // list of user defined expression widgets
public:
   TTVLVContainer(const TGWindow *p, UInt_t w, UInt_t h, UInt_t options=kSunkenFrame);
   virtual ~TTVLVContainer();
   virtual void AddThisItem(TTVLVEntry *item)
                  { AddFrame(item, fItemLayout); item->SetColumns(fCpos, fJmode); }
   const char    *Cut();
   void           EmptyAll();     // empty all items of expression type
   TTVLVEntry    *ExpressionItem(Int_t index);
   TList         *ExpressionList();
   const char    *Ex();
   const char    *Ey();
   const char    *Ez();
   TTreeViewer   *GetViewer() {return fViewer;}
   void           SetListView(TGListView *lv) {fListView = lv;}
   void           SetViewer(TTreeViewer *viewer) {fViewer = viewer;}
   void           RemoveNonStatic();
   const char    *ScanList();
   void           SelectItem(const char* name);
   virtual Bool_t HandleButton(Event_t *event);
   virtual Bool_t HandleMotion(Event_t *event);

   ClassDef(TTVLVContainer,0)  // A dragging-capable LVContainer
};


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGSelectBox                                                          //
//                                                                      //
// This class represent a specialized expression editor for             //
// TTVLVEntry 'true name' and 'alias' data members.                     //
// It is a singleton in order to be able to use it for several          //
// expressions.                                                         //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

class TGSelectBox : public TGTransientFrame {

private:
   TTreeViewer       *fViewer;        // pointer to tree viewer
   TGLabel           *fLabel;         // label
   TTVLVEntry        *fEntry;         // edited expression entry
   TGTextEntry       *fTe;            // text entry box
   TGLabel           *fLabelAlias;    // alias label
   TGTextEntry       *fTeAlias;       // alias text entry
   TString            fOldAlias;      // old alias for edited entry
   TGLayoutHints     *fLayout;        // layout hints for widgets inside
   TGLayoutHints     *fBLayout;       // layout for cancel button
   TGLayoutHints     *fBLayout1;      // layout for close button
   TGHorizontalFrame *fBf;            // buttons frame
   TGTextButton      *fDONE;          // close button
   TGTextButton      *fCANCEL;        // cancel button

protected:
   static TGSelectBox *fgInstance;// pointer to this select box

public:
   TGSelectBox(const TGWindow *p, const TGWindow *main, UInt_t w = 10, UInt_t h = 10);
   virtual ~TGSelectBox();
   virtual void   CloseWindow();
   TTVLVEntry    *EditedEntry() {return fEntry;}
   void           GrabPointer();
   void           SetLabel(const char* title);
   void           SetEntry(TTVLVEntry *entry);
   void           SaveText();
   void           InsertText(const char* text);
   virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
   Bool_t         ValidateAlias();

   static TGSelectBox *GetInstance();

   ClassDef(TGSelectBox,0)  // TreeView dialog widget
};

#endif
 TTVLVContainer.h:1
 TTVLVContainer.h:2
 TTVLVContainer.h:3
 TTVLVContainer.h:4
 TTVLVContainer.h:5
 TTVLVContainer.h:6
 TTVLVContainer.h:7
 TTVLVContainer.h:8
 TTVLVContainer.h:9
 TTVLVContainer.h:10
 TTVLVContainer.h:11
 TTVLVContainer.h:12
 TTVLVContainer.h:13
 TTVLVContainer.h:14
 TTVLVContainer.h:15
 TTVLVContainer.h:16
 TTVLVContainer.h:17
 TTVLVContainer.h:18
 TTVLVContainer.h:19
 TTVLVContainer.h:20
 TTVLVContainer.h:21
 TTVLVContainer.h:22
 TTVLVContainer.h:23
 TTVLVContainer.h:24
 TTVLVContainer.h:25
 TTVLVContainer.h:26
 TTVLVContainer.h:27
 TTVLVContainer.h:28
 TTVLVContainer.h:29
 TTVLVContainer.h:30
 TTVLVContainer.h:31
 TTVLVContainer.h:32
 TTVLVContainer.h:33
 TTVLVContainer.h:34
 TTVLVContainer.h:35
 TTVLVContainer.h:36
 TTVLVContainer.h:37
 TTVLVContainer.h:38
 TTVLVContainer.h:39
 TTVLVContainer.h:40
 TTVLVContainer.h:41
 TTVLVContainer.h:42
 TTVLVContainer.h:43
 TTVLVContainer.h:44
 TTVLVContainer.h:45
 TTVLVContainer.h:46
 TTVLVContainer.h:47
 TTVLVContainer.h:48
 TTVLVContainer.h:49
 TTVLVContainer.h:50
 TTVLVContainer.h:51
 TTVLVContainer.h:52
 TTVLVContainer.h:53
 TTVLVContainer.h:54
 TTVLVContainer.h:55
 TTVLVContainer.h:56
 TTVLVContainer.h:57
 TTVLVContainer.h:58
 TTVLVContainer.h:59
 TTVLVContainer.h:60
 TTVLVContainer.h:61
 TTVLVContainer.h:62
 TTVLVContainer.h:63
 TTVLVContainer.h:64
 TTVLVContainer.h:65
 TTVLVContainer.h:66
 TTVLVContainer.h:67
 TTVLVContainer.h:68
 TTVLVContainer.h:69
 TTVLVContainer.h:70
 TTVLVContainer.h:71
 TTVLVContainer.h:72
 TTVLVContainer.h:73
 TTVLVContainer.h:74
 TTVLVContainer.h:75
 TTVLVContainer.h:76
 TTVLVContainer.h:77
 TTVLVContainer.h:78
 TTVLVContainer.h:79
 TTVLVContainer.h:80
 TTVLVContainer.h:81
 TTVLVContainer.h:82
 TTVLVContainer.h:83
 TTVLVContainer.h:84
 TTVLVContainer.h:85
 TTVLVContainer.h:86
 TTVLVContainer.h:87
 TTVLVContainer.h:88
 TTVLVContainer.h:89
 TTVLVContainer.h:90
 TTVLVContainer.h:91
 TTVLVContainer.h:92
 TTVLVContainer.h:93
 TTVLVContainer.h:94
 TTVLVContainer.h:95
 TTVLVContainer.h:96
 TTVLVContainer.h:97
 TTVLVContainer.h:98
 TTVLVContainer.h:99
 TTVLVContainer.h:100
 TTVLVContainer.h:101
 TTVLVContainer.h:102
 TTVLVContainer.h:103
 TTVLVContainer.h:104
 TTVLVContainer.h:105
 TTVLVContainer.h:106
 TTVLVContainer.h:107
 TTVLVContainer.h:108
 TTVLVContainer.h:109
 TTVLVContainer.h:110
 TTVLVContainer.h:111
 TTVLVContainer.h:112
 TTVLVContainer.h:113
 TTVLVContainer.h:114
 TTVLVContainer.h:115
 TTVLVContainer.h:116
 TTVLVContainer.h:117
 TTVLVContainer.h:118
 TTVLVContainer.h:119
 TTVLVContainer.h:120
 TTVLVContainer.h:121
 TTVLVContainer.h:122
 TTVLVContainer.h:123
 TTVLVContainer.h:124
 TTVLVContainer.h:125
 TTVLVContainer.h:126
 TTVLVContainer.h:127
 TTVLVContainer.h:128
 TTVLVContainer.h:129
 TTVLVContainer.h:130
 TTVLVContainer.h:131
 TTVLVContainer.h:132
 TTVLVContainer.h:133
 TTVLVContainer.h:134
 TTVLVContainer.h:135
 TTVLVContainer.h:136
 TTVLVContainer.h:137
 TTVLVContainer.h:138
 TTVLVContainer.h:139
 TTVLVContainer.h:140
 TTVLVContainer.h:141
 TTVLVContainer.h:142
 TTVLVContainer.h:143
 TTVLVContainer.h:144
 TTVLVContainer.h:145
 TTVLVContainer.h:146
 TTVLVContainer.h:147
 TTVLVContainer.h:148
 TTVLVContainer.h:149
 TTVLVContainer.h:150
 TTVLVContainer.h:151
 TTVLVContainer.h:152
 TTVLVContainer.h:153
 TTVLVContainer.h:154
 TTVLVContainer.h:155
 TTVLVContainer.h:156
 TTVLVContainer.h:157
 TTVLVContainer.h:158
 TTVLVContainer.h:159
 TTVLVContainer.h:160
 TTVLVContainer.h:161
 TTVLVContainer.h:162
 TTVLVContainer.h:163
 TTVLVContainer.h:164
 TTVLVContainer.h:165
 TTVLVContainer.h:166
 TTVLVContainer.h:167
 TTVLVContainer.h:168
 TTVLVContainer.h:169
 TTVLVContainer.h:170
 TTVLVContainer.h:171
 TTVLVContainer.h:172
 TTVLVContainer.h:173
 TTVLVContainer.h:174
 TTVLVContainer.h:175
 TTVLVContainer.h:176
 TTVLVContainer.h:177
 TTVLVContainer.h:178
 TTVLVContainer.h:179
 TTVLVContainer.h:180
 TTVLVContainer.h:181
 TTVLVContainer.h:182
 TTVLVContainer.h:183
 TTVLVContainer.h:184
 TTVLVContainer.h:185
 TTVLVContainer.h:186
 TTVLVContainer.h:187
 TTVLVContainer.h:188
 TTVLVContainer.h:189
 TTVLVContainer.h:190
 TTVLVContainer.h:191
 TTVLVContainer.h:192
 TTVLVContainer.h:193
 TTVLVContainer.h:194
 TTVLVContainer.h:195
 TTVLVContainer.h:196