TGTable.h

Go to the documentation of this file.
00001 // Author: Roel Aaij   21/07/2007
00002 
00003 /*************************************************************************
00004  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
00005  * All rights reserved.                                                  *
00006  *                                                                       *
00007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00009  *************************************************************************/
00010 
00011 #ifndef ROOT_TGTable
00012 #define ROOT_TGTable
00013 
00014 #ifndef ROOT_TGCanvas
00015 #include "TGCanvas.h"
00016 #endif
00017 #ifndef ROOT_TGWidget
00018 #include "TGWidget.h"
00019 #endif
00020 #ifndef ROOT_TGTableHeader
00021 #include "TGTableHeader.h"
00022 #endif
00023 
00024 class TGWindow;
00025 class TGString;
00026 class TGToolTip;
00027 class TGPicture;
00028 class TVirtualTableInterface;
00029 class TGTableCell;
00030 class TGTableHeader;
00031 class TGToolTip;
00032 class TGTableFrame;
00033 class TGTableHeaderFrame;
00034 class TGTextButton;
00035 class TGNumberEntryField;
00036 class TGLabel;
00037 class TGTextEntry;
00038 class TTableRange;
00039 
00040 class TGTable : public TGCompositeFrame, public TGWidget {
00041 
00042 protected:
00043    TObjArray     *fRows;          // Array of rows
00044    TObjArray     *fRowHeaders;    // Array of row headers
00045    TObjArray     *fColumnHeaders; // Array of column headers
00046    TGTableHeader *fTableHeader;   // Top left element of the table
00047    Bool_t         fReadOnly;      // Table readonly state
00048    Pixel_t        fSelectColor;      // Select Color
00049    Int_t          fTMode;         // Text justify mode
00050    Bool_t         fAllData;       // Is the data bigger than the table
00051    TTableRange   *fCurrentRange;  // Range of data currently loaded
00052    TTableRange   *fDataRange;     // Full range of the data set
00053    TTableRange   *fGotoRange;     // Range used by Goto frame
00054    TGTableFrame  *fTableFrame;    // Container for the frames 
00055    TGCanvas      *fCanvas;        // Canvas that will contains the cells
00056    UInt_t         fCellWidth;     // Default cell width
00057    UInt_t         fCellHeight;    // Default cell width
00058 
00059    // Frames used for layout
00060    TGTableHeaderFrame *fCHdrFrame;     // Frame that contains the row headers
00061    TGTableHeaderFrame *fRHdrFrame;     // Frame that contains the row headers
00062    TGHorizontalFrame  *fRangeFrame;    // Frame that contains the top part
00063    TGHorizontalFrame  *fTopFrame;      // Frame that contains the top part
00064    TGHorizontalFrame  *fTopExtraFrame; // Dev idea
00065    TGHorizontalFrame  *fBottomFrame;   // Frame that contains the bottom part
00066    TGHorizontalFrame  *fButtonFrame;   // Contains the buttons
00067 
00068    // Buttons for interaction
00069    TGTextButton *fNextButton;     // Button to view next chunk
00070    TGTextButton *fPrevButton;     // Button to view previous chunk
00071    TGTextButton *fUpdateButton;   // Button to update current view
00072    TGTextButton *fGotoButton;     // Button to goto a new range
00073 
00074    // Labels and textentries for range information and input
00075    TGLabel     *fFirstCellLabel;  // Label for the range frame
00076    TGLabel     *fRangeLabel;      // Label for the range frame
00077    TGTextEntry *fFirstCellEntry;  // TextEntry for the range frame
00078    TGTextEntry *fRangeEntry;      // TextEntry for the range frame
00079 
00080    Pixel_t fOddRowBackground;     // Background color for odd numbered rows
00081    Pixel_t fEvenRowBackground;    // Background color for even numbered rows
00082    Pixel_t fHeaderBackground;     // Background color for headers
00083 
00084    // Those are neither used nor even initialized: 
00085    // static const TGGC *fgDefaultSelectGC; // Default select GC
00086    // static const TGGC *fgDefaultBckgndGC; // Default cell background GC
00087    // static const Int_t fgDefaultTMode;    // Default text justify mode
00088 
00089    // Data members to keep track of LayoutHints that can't be
00090    // automatically cleaned
00091    TList *fCellHintsList; 
00092    TList *fRHdrHintsList;
00093    TList *fCHdrHintsList;
00094    TList *fMainHintsList;   // List for all hints used in the main table frame
00095 
00096    // Add rows and/or colums to the edge of the table.
00097 
00098    virtual void Init();
00099 
00100    // Remove rows and/or colums from the edge of the table.
00101 protected:
00102    TVirtualTableInterface *fInterface; // Interface to the data source
00103 
00104    virtual void DoRedraw();
00105 
00106    virtual void Expand(UInt_t nrows, UInt_t ncolumns); 
00107    virtual void ExpandColumns(UInt_t ncolumns); 
00108    virtual void ExpandRows(UInt_t nrows); 
00109 
00110    virtual UInt_t GetRHdrHeight() const;
00111    virtual UInt_t GetCHdrWidth() const;
00112 
00113    virtual void Shrink(UInt_t nrows, UInt_t ncolumns);
00114    virtual void ShrinkColumns(UInt_t ncolumns);
00115    virtual void ShrinkRows(UInt_t nrows);
00116 
00117    virtual void UpdateHeaders(EHeaderType type);
00118    virtual void SetInterface(TVirtualTableInterface *interface, 
00119                              UInt_t nrows = 50, UInt_t ncolumns = 20);
00120    virtual void ResizeTable(UInt_t nrows, UInt_t ncolumns);
00121 
00122    virtual void UpdateRangeFrame();
00123 
00124 public:
00125    TGTable(const TGWindow *p = 0, Int_t id = 0, 
00126            TVirtualTableInterface *interface = 0, UInt_t nrows = 50, 
00127            UInt_t ncolumns = 20);
00128    virtual ~TGTable();
00129 
00130    virtual TObjArray *GetRow(UInt_t row);
00131    virtual TObjArray *GetColumn(UInt_t columns);
00132 
00133 //    // Selection
00134 //    virtual void Select(TGTableCell *celltl, TGTableCell *cellbr);
00135 //    virtual void Select(UInt_t xcell1, UInt_t ycell1, UInt_t xcell2, UInt_t ycell2);
00136 //    virtual void SelectAll();
00137 //    virtual void SelectRow(TGTableCell *cell); 
00138 //    virtual void SelectRow(UInt_t row); 
00139 //    virtual void SelectRows(UInt_t row, UInt_t nrows); 
00140 //    virtual void SelectColumn(TGTableCell *cell); 
00141 //    virtual void SelectColumn(UInt_t column); 
00142 //    virtual void SelectColumns(UInt_t column, UInt_t ncolumns); 
00143 
00144 //    virtual void SetSelectGC(TGGC *gc); 
00145 //    virtual void SetTextJustify(Int_t tmode); 
00146 
00147    // Cells
00148    virtual const TGTableCell* GetCell(UInt_t i, UInt_t j) const; 
00149    virtual TGTableCell* GetCell(UInt_t i, UInt_t j); 
00150    
00151    virtual const TGTableCell* FindCell(TGString label) const; 
00152    virtual TGTableCell* FindCell(TGString label); 
00153 
00154    virtual void Show();
00155 
00156    // Because insertion and removal of columns in the middle of a data
00157    // set is not yet supported in this design iteration, these methods
00158    // have been commented out.
00159 
00160 //    // Insert a range of columns or rows, if the label is empty, a
00161 //    // default scheme will be used.
00162 //    virtual void InsertRowBefore(UInt_t row, UInt_t nrows);
00163 //    virtual void InsertRowBefore(TGString label, UInt_t nrows);
00164 //    virtual void InsertRowAfter(UInt_t row, UInt_t nrows);
00165 //    virtual void InsertRowAfter(TGString label, UInt_t nrows);
00166 //    virtual void InsertRowAt(UInt_t row, UInt_t nrows = 1);
00167 //    virtual void InsertRowAt(TGString label, UInt_t nrows);
00168 
00169 //    virtual void InsertColumnBefore(UInt_t column, UInt_t ncolumns);
00170 //    virtual void InsertColumnBefore(TGString label, UInt_t ncolumns);
00171 //    virtual void InsertColumnAfter(UInt_t column, UInt_t ncolumns);
00172 //    virtual void InsertColumnAfter(TGString label, UInt_t ncolumns);
00173 //    virtual void InsertColumnAt(UInt_t column, UInt_t ncolumns = 1);
00174 //    virtual void InsertColumnAt(TGString label, UInt_t ncolumns);
00175 
00176 //    // Remove rows or columns.
00177 //    virtual void RemoveRows(UInt_t row, UInt_t nrows = 1);
00178 //    virtual void RemoveColumns(UInt_t column, UInt_t ncolumns = 1);
00179    
00180    // Update view
00181    virtual void UpdateView();
00182 
00183    // Getters
00184    virtual UInt_t       GetNTableRows() const;
00185    virtual UInt_t       GetNDataRows() const;
00186    virtual UInt_t       GetNTableColumns() const;
00187    virtual UInt_t       GetNDataColumns() const;
00188    virtual UInt_t       GetNTableCells() const;
00189    virtual UInt_t       GetNDataCells() const;
00190    virtual const  TTableRange *GetCurrentRange() const;
00191    
00192    virtual TVirtualTableInterface *GetInterface() { return fInterface; }
00193 
00194    virtual TGCanvas                 *GetCanvas() { return fCanvas; }
00195    virtual const TGTableHeaderFrame *GetRHdrFrame() { return fRHdrFrame; }
00196    virtual const TGTableHeaderFrame *GetCHdrFrame() { return fCHdrFrame; }
00197    virtual const TGTableHeader      *GetRowHeader(const UInt_t row) const;
00198    virtual TGTableHeader            *GetRowHeader(const UInt_t row);
00199    virtual const TGTableHeader      *GetColumnHeader(const UInt_t column) const;
00200    virtual TGTableHeader            *GetColumnHeader(const UInt_t column);
00201    virtual TGTableHeader            *GetTableHeader();
00202 
00203 //    virtual const TGGC*  GetSelectGC() const; 
00204 //    virtual const TGGC*  GetCellBckgndGC(TGTableCell *cell) const; 
00205 //    virtual const TGGC*  GetCellBckgndGC(UInt_t row, UInt_t column) const; 
00206    
00207    virtual Pixel_t GetRowBackground(UInt_t row) const;
00208    virtual Pixel_t GetHeaderBackground() const ;
00209    
00210    virtual void SetOddRowBackground(Pixel_t pixel);
00211    virtual void SetEvenRowBackground(Pixel_t pixel);
00212    virtual void SetHeaderBackground(Pixel_t pixel);
00213    virtual void SetDefaultColors();
00214 
00215    // Range manipulators
00216    virtual void MoveTable(Int_t rows, Int_t columns);
00217    virtual void GotoTableRange(Int_t xtl, Int_t ytl, 
00218                                Int_t xbr, Int_t ybr);
00219    // Operators
00220    virtual TGTableCell* operator() (UInt_t row, UInt_t column);
00221 
00222    // Internal slots
00223    virtual void ScrollCHeaders(Int_t xpos);
00224    virtual void ScrollRHeaders(Int_t ypos);
00225    virtual void NextChunk();
00226    virtual void PreviousChunk();
00227    virtual void UserRangeChange();
00228    virtual void Goto();
00229    virtual void Update();
00230 
00231    ClassDef(TGTable, 0) // A table used to visualize data from diffent sources.
00232 };
00233 
00234 class TTableRange {
00235 public:
00236    UInt_t fXtl; // Top left X coordinate
00237    UInt_t fYtl; // Top left Y coordinate
00238    UInt_t fXbr; // Bottom right X coordinate
00239    UInt_t fYbr; // Bottom right Y coordinate
00240 
00241    TTableRange();
00242    virtual ~TTableRange() {}
00243    virtual void Print();
00244 
00245    Bool_t operator==(TTableRange &other);
00246    ClassDef(TTableRange, 0) // Range used in TGTable.
00247 };
00248 
00249 #endif
00250 

Generated on Tue Jul 5 14:20:08 2011 for ROOT_528-00b_version by  doxygen 1.5.1