Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:31

0001 // @(#)root/treeviewer:$Id$
0002 //Author : Andrei Gheata   16/08/00
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TTVLVContainer
0013 #define ROOT_TTVLVContainer
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TTVLVEntry                                                           //
0019 //                                                                      //
0020 // This class represent entries that goes into the TreeViewer           //
0021 // listview container. It subclasses TGLVEntry and adds 2               //
0022 // data members: the item true name and the alias                       //
0023 //                                                                      //
0024 //////////////////////////////////////////////////////////////////////////
0025 
0026 #include "TGListView.h"
0027 
0028 
0029 class TGLabel;
0030 class TGTextEntry;
0031 class TTreeViewer;
0032 class TGToolTip;
0033 class TTVLVEntry;
0034 class TTVLVContainer;
0035 
0036 class TGItemContext : public TObject {
0037 
0038 protected:
0039    TTVLVEntry *fItem;       // pointer to associated item
0040 public:
0041    TGItemContext();
0042        ~TGItemContext() override { }
0043    void         Associate(TTVLVEntry *item) { fItem = item; }
0044    void Delete(Option_t *) override { }           // *MENU*
0045    void         Draw(Option_t *option="") override;       // *MENU*
0046    void         EditExpression();                // *MENU*
0047    void         Empty();                         // *MENU*
0048    void         RemoveItem();                    // *MENU*
0049    void         Scan();                          // *MENU*
0050    void         SetExpression(const char *name="", const char *alias="-empty-", bool cut=false); // *MENU*
0051 
0052    ClassDefOverride(TGItemContext, 0)  // Context menu for TTVLVEntry
0053 };
0054 
0055 
0056 class TTVLVEntry : public TGLVEntry {
0057 
0058 protected:
0059    TTVLVContainer *fContainer;  ///< Container to whom this item belongs
0060    TString         fTrueName;   ///< Name for this entry
0061    TString         fAlias;      ///< Alias for this entry
0062    TString         fConvName;   ///< Name converted into true expressions
0063    TGToolTip      *fTip;        ///< Tool tip associated with item
0064    bool            fIsCut;      ///< Flag for cut type items
0065    TGItemContext  *fContext;    ///< Associated context menu
0066 
0067 protected:
0068    bool           FullConverted();
0069 
0070 public:
0071    TTVLVEntry(const TGWindow *p,
0072               const TGPicture *bigpic, const TGPicture *smallpic,
0073               TGString *name, TGString **subnames, EListViewMode ViewMode);
0074    ~TTVLVEntry() override;
0075    const char     *ConvertAliases();
0076    void            CopyItem(TTVLVEntry *dest);
0077    const char     *GetAlias() {return fAlias.Data();}
0078    TTVLVContainer *GetContainer() {return fContainer;}
0079    TGItemContext  *GetContext() {return fContext;}
0080    const char     *GetConvName() {return fConvName;}
0081    const char     *GetTrueName() {return fTrueName.Data();}
0082    TGToolTip      *GetTip() {return fTip;}
0083    bool            HandleCrossing(Event_t *event) override;
0084    bool            HasAlias();
0085    bool            IsCut() {return fIsCut;}
0086    void            PrependTilde();
0087    void            SetCutType(bool type=false);
0088    void            SetItemName(const char* name);
0089    void            SetAlias(const char* alias) {fAlias = alias;}
0090    void            SetExpression(const char* name, const char* alias, bool cutType=false);
0091    void            SetTrueName(const char* name) {fTrueName = name;}
0092    void            SetToolTipText(const char *text, Long_t delayms = 1000);
0093    void            SetSmallPic(const TGPicture *spic);
0094    void            Empty();
0095 
0096    ClassDefOverride(TTVLVEntry,0)  // Item that goes into the tree list view widget
0097 };
0098 
0099 
0100 //////////////////////////////////////////////////////////////////////////
0101 //                                                                      //
0102 //   TTVLVContainer                                                     //
0103 //                                                                      //
0104 // This class represent the list view container for the                 //
0105 // TreeView class. It is a TGLVContainer with item dragging             //
0106 // capabilities for the TTVLVEntry objects inside                       //
0107 //                                                                      //
0108 //////////////////////////////////////////////////////////////////////////
0109 
0110 class TTVLVContainer : public TGLVContainer {
0111 
0112 friend class TGClient;
0113 
0114 private:
0115    Cursor_t     fCursor;             ///< Current cursor
0116    Cursor_t     fDefaultCursor;      ///< Default cursor
0117    TGListView  *fListView;           ///< Associated list view
0118    TTreeViewer *fViewer;             ///< Pointer to tree viewer
0119    TList       *fExpressionList;     ///< List of user defined expression widgets
0120 
0121 public:
0122    TTVLVContainer(const TGWindow *p, UInt_t w, UInt_t h, UInt_t options=kSunkenFrame);
0123    ~TTVLVContainer() override;
0124    virtual void AddThisItem(TTVLVEntry *item)
0125                   { AddFrame(item, fItemLayout); item->SetColumns(fCpos, fJmode); }
0126    const char    *Cut();
0127    void           EmptyAll();     // empty all items of expression type
0128    TTVLVEntry    *ExpressionItem(Int_t index);
0129    TList         *ExpressionList();
0130    const char    *Ex();
0131    const char    *Ey();
0132    const char    *Ez();
0133    TTreeViewer   *GetViewer() {return fViewer;}
0134    void           SetListView(TGListView *lv) override {fListView = lv;}
0135    void           SetViewer(TTreeViewer *viewer) {fViewer = viewer;}
0136    void           RemoveNonStatic();
0137    const char    *ScanList();
0138    void           SelectItem(const char* name);
0139    bool           HandleButton(Event_t *event) override;
0140    bool           HandleMotion(Event_t *event) override;
0141 
0142    ClassDefOverride(TTVLVContainer,0)  // A dragging-capable LVContainer
0143 };
0144 
0145 
0146 //////////////////////////////////////////////////////////////////////////
0147 //                                                                      //
0148 // TGSelectBox                                                          //
0149 //                                                                      //
0150 // This class represent a specialized expression editor for             //
0151 // TTVLVEntry 'true name' and 'alias' data members.                     //
0152 // It is a singleton in order to be able to use it for several          //
0153 // expressions.                                                         //
0154 //                                                                      //
0155 //////////////////////////////////////////////////////////////////////////
0156 
0157 class TGSelectBox : public TGTransientFrame {
0158 
0159 private:
0160    TTreeViewer       *fViewer;        ///< Pointer to tree viewer
0161    TGLabel           *fLabel;         ///< Label
0162    TTVLVEntry        *fEntry;         ///< Edited expression entry
0163    TGTextEntry       *fTe;            ///< Text entry box
0164    TGLabel           *fLabelAlias;    ///< Alias label
0165    TGTextEntry       *fTeAlias;       ///< Alias text entry
0166    TString            fOldAlias;      ///< Old alias for edited entry
0167    TGLayoutHints     *fLayout;        ///< Layout hints for widgets inside
0168    TGLayoutHints     *fBLayout;       ///< Layout for cancel button
0169    TGLayoutHints     *fBLayout1;      ///< Layout for close button
0170    TGHorizontalFrame *fBf;            ///< Buttons frame
0171    TGTextButton      *fDONE;          ///< Close button
0172    TGTextButton      *fCANCEL;        ///< Cancel button
0173 
0174 protected:
0175    static TGSelectBox *fgInstance;// pointer to this select box
0176 
0177 public:
0178    TGSelectBox(const TGWindow *p, const TGWindow *main, UInt_t w = 10, UInt_t h = 10);
0179    ~TGSelectBox() override;
0180    void   CloseWindow() override;
0181    TTVLVEntry    *EditedEntry() {return fEntry;}
0182    void           GrabPointer();
0183    void           SetLabel(const char* title);
0184    void           SetEntry(TTVLVEntry *entry);
0185    void           SaveText();
0186    void           InsertText(const char* text);
0187    bool ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override;
0188    bool           ValidateAlias();
0189 
0190    static TGSelectBox *GetInstance();
0191 
0192    ClassDefOverride(TGSelectBox,0)  // TreeView dialog widget
0193 };
0194 
0195 #endif