Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Author: Roel Aaij   21/07/2007
0002 
0003 /*************************************************************************
0004  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
0005  * All rights reserved.                                                  *
0006  *                                                                       *
0007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0009  *************************************************************************/
0010 
0011 #ifndef ROOT_TGTable
0012 #define ROOT_TGTable
0013 
0014 #include "TGCanvas.h"
0015 #include "TGWidget.h"
0016 #include "TGTableHeader.h"
0017 
0018 class TGWindow;
0019 class TGString;
0020 class TGToolTip;
0021 class TGPicture;
0022 class TVirtualTableInterface;
0023 class TGTableCell;
0024 class TGTableHeader;
0025 class TGToolTip;
0026 class TGTableFrame;
0027 class TGTableHeaderFrame;
0028 class TGTextButton;
0029 class TGNumberEntryField;
0030 class TGLabel;
0031 class TGTextEntry;
0032 class TTableRange;
0033 
0034 class TGTable : public TGCompositeFrame, public TGWidget {
0035 
0036 protected:
0037    TObjArray     *fRows;          ///< Array of rows
0038    TObjArray     *fRowHeaders;    ///< Array of row headers
0039    TObjArray     *fColumnHeaders; ///< Array of column headers
0040    TGTableHeader *fTableHeader;   ///< Top left element of the table
0041    Bool_t         fReadOnly;      ///< Table readonly state
0042    Pixel_t        fSelectColor;   ///< Select Color
0043    Int_t          fTMode;         ///< Text justify mode
0044    Bool_t         fAllData;       ///< Is the data bigger than the table
0045    TTableRange   *fCurrentRange;  ///< Range of data currently loaded
0046    TTableRange   *fDataRange;     ///< Full range of the data set
0047    TTableRange   *fGotoRange;     ///< Range used by Goto frame
0048    TGTableFrame  *fTableFrame;    ///< Container for the frames
0049    TGCanvas      *fCanvas;        ///< Canvas that will contains the cells
0050    UInt_t         fCellWidth;     ///< Default cell width
0051    UInt_t         fCellHeight;    ///< Default cell width
0052 
0053    ///@{
0054    ///@name Frames used for layout
0055    TGTableHeaderFrame *fCHdrFrame;     ///< Frame that contains the row headers
0056    TGTableHeaderFrame *fRHdrFrame;     ///< Frame that contains the row headers
0057    TGHorizontalFrame  *fRangeFrame;    ///< Frame that contains the top part
0058    TGHorizontalFrame  *fTopFrame;      ///< Frame that contains the top part
0059    TGHorizontalFrame  *fTopExtraFrame; ///< Dev idea
0060    TGHorizontalFrame  *fBottomFrame;   ///< Frame that contains the bottom part
0061    TGHorizontalFrame  *fButtonFrame;   ///< Contains the buttons
0062    ///@}
0063 
0064    ///@{
0065    ///@name Buttons for interaction
0066    TGTextButton *fNextButton;     ///< Button to view next chunk
0067    TGTextButton *fPrevButton;     ///< Button to view previous chunk
0068    TGTextButton *fUpdateButton;   ///< Button to update current view
0069    TGTextButton *fGotoButton;     ///< Button to goto a new range
0070    ///@}
0071 
0072    ///@{
0073    ///@name Labels and text entries for range information and input
0074    TGLabel     *fFirstCellLabel;  ///< Label for the range frame
0075    TGLabel     *fRangeLabel;      ///< Label for the range frame
0076    TGTextEntry *fFirstCellEntry;  ///< TextEntry for the range frame
0077    TGTextEntry *fRangeEntry;      ///< TextEntry for the range frame
0078 
0079    Pixel_t fOddRowBackground;     ///< Background color for odd numbered rows
0080    Pixel_t fEvenRowBackground;    ///< Background color for even numbered rows
0081    Pixel_t fHeaderBackground;     ///< Background color for headers
0082    ///@}
0083 
0084    // Those are neither used nor even initialized:
0085    // static const TGGC *fgDefaultSelectGC; // Default select GC
0086    // static const TGGC *fgDefaultBckgndGC; // Default cell background GC
0087    // static const Int_t fgDefaultTMode;    // Default text justify mode
0088 
0089    ///@{
0090    ///@name Data members to keep track of LayoutHints that can't be automatically cleaned
0091    TList *fCellHintsList;
0092    TList *fRHdrHintsList;
0093    TList *fCHdrHintsList;
0094    TList *fMainHintsList;   ///< List for all hints used in the main table frame
0095    ///@}
0096 
0097    // Add rows and/or columns to the edge of the table.
0098 
0099    virtual void Init();
0100 
0101    // Remove rows and/or columns from the edge of the table.
0102 protected:
0103    TVirtualTableInterface *fInterface; // Interface to the data source
0104 
0105    void DoRedraw() override;
0106 
0107    virtual void Expand(UInt_t nrows, UInt_t ncolumns);
0108    virtual void ExpandColumns(UInt_t ncolumns);
0109    virtual void ExpandRows(UInt_t nrows);
0110 
0111    virtual UInt_t GetRHdrHeight() const;
0112    virtual UInt_t GetCHdrWidth() const;
0113 
0114    virtual void Shrink(UInt_t nrows, UInt_t ncolumns);
0115    virtual void ShrinkColumns(UInt_t ncolumns);
0116    virtual void ShrinkRows(UInt_t nrows);
0117 
0118    virtual void UpdateHeaders(EHeaderType type);
0119    virtual void SetInterface(TVirtualTableInterface *interface,
0120                              UInt_t nrows = 50, UInt_t ncolumns = 20);
0121    virtual void ResizeTable(UInt_t nrows, UInt_t ncolumns);
0122 
0123    virtual void UpdateRangeFrame();
0124 
0125 public:
0126    TGTable(const TGWindow *p = nullptr, Int_t id = 0,
0127            TVirtualTableInterface *interface = nullptr, UInt_t nrows = 50,
0128            UInt_t ncolumns = 20);
0129    ~TGTable() override;
0130 
0131    virtual TObjArray *GetRow(UInt_t row);
0132    virtual TObjArray *GetColumn(UInt_t columns);
0133 
0134 //    // Selection
0135 //    virtual void Select(TGTableCell *celltl, TGTableCell *cellbr);
0136 //    virtual void Select(UInt_t xcell1, UInt_t ycell1, UInt_t xcell2, UInt_t ycell2);
0137 //    virtual void SelectAll();
0138 //    virtual void SelectRow(TGTableCell *cell);
0139 //    virtual void SelectRow(UInt_t row);
0140 //    virtual void SelectRows(UInt_t row, UInt_t nrows);
0141 //    virtual void SelectColumn(TGTableCell *cell);
0142 //    virtual void SelectColumn(UInt_t column);
0143 //    virtual void SelectColumns(UInt_t column, UInt_t ncolumns);
0144 
0145 //    virtual void SetSelectGC(TGGC *gc);
0146 //    virtual void SetTextJustify(Int_t tmode);
0147 
0148    // Cells
0149    virtual const TGTableCell* GetCell(UInt_t i, UInt_t j) const;
0150    virtual TGTableCell* GetCell(UInt_t i, UInt_t j);
0151 
0152    virtual const TGTableCell* FindCell(TGString label) const;
0153    virtual TGTableCell* FindCell(TGString label);
0154 
0155    virtual void Show();
0156 
0157    // Because insertion and removal of columns in the middle of a data
0158    // set is not yet supported in this design iteration, these methods
0159    // have been commented out.
0160 
0161 //    // Insert a range of columns or rows, if the label is empty, a
0162 //    // default scheme will be used.
0163 //    virtual void InsertRowBefore(UInt_t row, UInt_t nrows);
0164 //    virtual void InsertRowBefore(TGString label, UInt_t nrows);
0165 //    virtual void InsertRowAfter(UInt_t row, UInt_t nrows);
0166 //    virtual void InsertRowAfter(TGString label, UInt_t nrows);
0167 //    virtual void InsertRowAt(UInt_t row, UInt_t nrows = 1);
0168 //    virtual void InsertRowAt(TGString label, UInt_t nrows);
0169 
0170 //    virtual void InsertColumnBefore(UInt_t column, UInt_t ncolumns);
0171 //    virtual void InsertColumnBefore(TGString label, UInt_t ncolumns);
0172 //    virtual void InsertColumnAfter(UInt_t column, UInt_t ncolumns);
0173 //    virtual void InsertColumnAfter(TGString label, UInt_t ncolumns);
0174 //    virtual void InsertColumnAt(UInt_t column, UInt_t ncolumns = 1);
0175 //    virtual void InsertColumnAt(TGString label, UInt_t ncolumns);
0176 
0177 //    // Remove rows or columns.
0178 //    virtual void RemoveRows(UInt_t row, UInt_t nrows = 1);
0179 //    virtual void RemoveColumns(UInt_t column, UInt_t ncolumns = 1);
0180 
0181    // Update view
0182    virtual void UpdateView();
0183 
0184    // Getters
0185    virtual UInt_t       GetNTableRows() const;
0186    virtual UInt_t       GetNDataRows() const;
0187    virtual UInt_t       GetNTableColumns() const;
0188    virtual UInt_t       GetNDataColumns() const;
0189    virtual UInt_t       GetNTableCells() const;
0190    virtual UInt_t       GetNDataCells() const;
0191    virtual const  TTableRange *GetCurrentRange() const;
0192 
0193    virtual TVirtualTableInterface *GetInterface() { return fInterface; }
0194 
0195    virtual TGCanvas                 *GetCanvas() { return fCanvas; }
0196    virtual const TGTableHeaderFrame *GetRHdrFrame() { return fRHdrFrame; }
0197    virtual const TGTableHeaderFrame *GetCHdrFrame() { return fCHdrFrame; }
0198    virtual const TGTableHeader      *GetRowHeader(const UInt_t row) const;
0199    virtual TGTableHeader            *GetRowHeader(const UInt_t row);
0200    virtual const TGTableHeader      *GetColumnHeader(const UInt_t column) const;
0201    virtual TGTableHeader            *GetColumnHeader(const UInt_t column);
0202    virtual TGTableHeader            *GetTableHeader();
0203 
0204 //    virtual const TGGC*  GetSelectGC() const;
0205 //    virtual const TGGC*  GetCellBckgndGC(TGTableCell *cell) const;
0206 //    virtual const TGGC*  GetCellBckgndGC(UInt_t row, UInt_t column) const;
0207 
0208    virtual Pixel_t GetRowBackground(UInt_t row) const;
0209    virtual Pixel_t GetHeaderBackground() const ;
0210 
0211    virtual void SetOddRowBackground(Pixel_t pixel);
0212    virtual void SetEvenRowBackground(Pixel_t pixel);
0213    virtual void SetHeaderBackground(Pixel_t pixel);
0214    virtual void SetDefaultColors();
0215 
0216    // Range manipulators
0217    virtual void MoveTable(Int_t rows, Int_t columns);
0218    virtual void GotoTableRange(Int_t xtl, Int_t ytl,
0219                                Int_t xbr, Int_t ybr);
0220    // Operators
0221    virtual TGTableCell* operator() (UInt_t row, UInt_t column);
0222 
0223    // Internal slots
0224    virtual void ScrollCHeaders(Int_t xpos);
0225    virtual void ScrollRHeaders(Int_t ypos);
0226    virtual void NextChunk();
0227    virtual void PreviousChunk();
0228    virtual void UserRangeChange();
0229    virtual void Goto();
0230    virtual void Update();
0231 
0232    ClassDefOverride(TGTable, 0) // A table used to visualize data from different sources.
0233 };
0234 
0235 class TTableRange {
0236 public:
0237    UInt_t fXtl; ///< Top left X coordinate
0238    UInt_t fYtl; ///< Top left Y coordinate
0239    UInt_t fXbr; ///< Bottom right X coordinate
0240    UInt_t fYbr; ///< Bottom right Y coordinate
0241 
0242    TTableRange();
0243    virtual ~TTableRange() {}
0244    virtual void Print();
0245 
0246    Bool_t operator==(TTableRange &other);
0247 
0248    ClassDef(TTableRange, 0) // Range used in TGTable.
0249 };
0250 
0251 #endif
0252