Logo ROOT  
Reference Guide
Go to the documentation of this file.
1// Author: Roel Aaij 21/07/2007
4 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
11#ifndef ROOT_TGTable
12#define ROOT_TGTable
14#include "TGCanvas.h"
15#include "TGWidget.h"
16#include "TGTableHeader.h"
18class TGWindow;
19class TGString;
20class TGToolTip;
21class TGPicture;
23class TGTableCell;
24class TGTableHeader;
25class TGToolTip;
26class TGTableFrame;
28class TGTextButton;
30class TGLabel;
31class TGTextEntry;
32class TTableRange;
34class TGTable : public TGCompositeFrame, public TGWidget {
37 TObjArray *fRows; // Array of rows
38 TObjArray *fRowHeaders; // Array of row headers
39 TObjArray *fColumnHeaders; // Array of column headers
40 TGTableHeader *fTableHeader; // Top left element of the table
41 Bool_t fReadOnly; // Table readonly state
42 Pixel_t fSelectColor; // Select Color
43 Int_t fTMode; // Text justify mode
44 Bool_t fAllData; // Is the data bigger than the table
45 TTableRange *fCurrentRange; // Range of data currently loaded
46 TTableRange *fDataRange; // Full range of the data set
47 TTableRange *fGotoRange; // Range used by Goto frame
48 TGTableFrame *fTableFrame; // Container for the frames
49 TGCanvas *fCanvas; // Canvas that will contains the cells
50 UInt_t fCellWidth; // Default cell width
51 UInt_t fCellHeight; // Default cell width
53 // Frames used for layout
54 TGTableHeaderFrame *fCHdrFrame; // Frame that contains the row headers
55 TGTableHeaderFrame *fRHdrFrame; // Frame that contains the row headers
56 TGHorizontalFrame *fRangeFrame; // Frame that contains the top part
57 TGHorizontalFrame *fTopFrame; // Frame that contains the top part
59 TGHorizontalFrame *fBottomFrame; // Frame that contains the bottom part
60 TGHorizontalFrame *fButtonFrame; // Contains the buttons
62 // Buttons for interaction
63 TGTextButton *fNextButton; // Button to view next chunk
64 TGTextButton *fPrevButton; // Button to view previous chunk
65 TGTextButton *fUpdateButton; // Button to update current view
66 TGTextButton *fGotoButton; // Button to goto a new range
68 // Labels and textentries for range information and input
69 TGLabel *fFirstCellLabel; // Label for the range frame
70 TGLabel *fRangeLabel; // Label for the range frame
71 TGTextEntry *fFirstCellEntry; // TextEntry for the range frame
72 TGTextEntry *fRangeEntry; // TextEntry for the range frame
74 Pixel_t fOddRowBackground; // Background color for odd numbered rows
75 Pixel_t fEvenRowBackground; // Background color for even numbered rows
76 Pixel_t fHeaderBackground; // Background color for headers
78 // Those are neither used nor even initialized:
79 // static const TGGC *fgDefaultSelectGC; // Default select GC
80 // static const TGGC *fgDefaultBckgndGC; // Default cell background GC
81 // static const Int_t fgDefaultTMode; // Default text justify mode
83 // Data members to keep track of LayoutHints that can't be
84 // automatically cleaned
88 TList *fMainHintsList; // List for all hints used in the main table frame
90 // Add rows and/or colums to the edge of the table.
92 virtual void Init();
94 // Remove rows and/or colums from the edge of the table.
96 TVirtualTableInterface *fInterface; // Interface to the data source
98 virtual void DoRedraw();
100 virtual void Expand(UInt_t nrows, UInt_t ncolumns);
101 virtual void ExpandColumns(UInt_t ncolumns);
102 virtual void ExpandRows(UInt_t nrows);
104 virtual UInt_t GetRHdrHeight() const;
105 virtual UInt_t GetCHdrWidth() const;
107 virtual void Shrink(UInt_t nrows, UInt_t ncolumns);
108 virtual void ShrinkColumns(UInt_t ncolumns);
109 virtual void ShrinkRows(UInt_t nrows);
111 virtual void UpdateHeaders(EHeaderType type);
112 virtual void SetInterface(TVirtualTableInterface *interface,
113 UInt_t nrows = 50, UInt_t ncolumns = 20);
114 virtual void ResizeTable(UInt_t nrows, UInt_t ncolumns);
116 virtual void UpdateRangeFrame();
119 TGTable(const TGWindow *p = 0, Int_t id = 0,
120 TVirtualTableInterface *interface = 0, UInt_t nrows = 50,
121 UInt_t ncolumns = 20);
122 virtual ~TGTable();
124 virtual TObjArray *GetRow(UInt_t row);
125 virtual TObjArray *GetColumn(UInt_t columns);
127// // Selection
128// virtual void Select(TGTableCell *celltl, TGTableCell *cellbr);
129// virtual void Select(UInt_t xcell1, UInt_t ycell1, UInt_t xcell2, UInt_t ycell2);
130// virtual void SelectAll();
131// virtual void SelectRow(TGTableCell *cell);
132// virtual void SelectRow(UInt_t row);
133// virtual void SelectRows(UInt_t row, UInt_t nrows);
134// virtual void SelectColumn(TGTableCell *cell);
135// virtual void SelectColumn(UInt_t column);
136// virtual void SelectColumns(UInt_t column, UInt_t ncolumns);
138// virtual void SetSelectGC(TGGC *gc);
139// virtual void SetTextJustify(Int_t tmode);
141 // Cells
142 virtual const TGTableCell* GetCell(UInt_t i, UInt_t j) const;
143 virtual TGTableCell* GetCell(UInt_t i, UInt_t j);
145 virtual const TGTableCell* FindCell(TGString label) const;
146 virtual TGTableCell* FindCell(TGString label);
148 virtual void Show();
150 // Because insertion and removal of columns in the middle of a data
151 // set is not yet supported in this design iteration, these methods
152 // have been commented out.
154// // Insert a range of columns or rows, if the label is empty, a
155// // default scheme will be used.
156// virtual void InsertRowBefore(UInt_t row, UInt_t nrows);
157// virtual void InsertRowBefore(TGString label, UInt_t nrows);
158// virtual void InsertRowAfter(UInt_t row, UInt_t nrows);
159// virtual void InsertRowAfter(TGString label, UInt_t nrows);
160// virtual void InsertRowAt(UInt_t row, UInt_t nrows = 1);
161// virtual void InsertRowAt(TGString label, UInt_t nrows);
163// virtual void InsertColumnBefore(UInt_t column, UInt_t ncolumns);
164// virtual void InsertColumnBefore(TGString label, UInt_t ncolumns);
165// virtual void InsertColumnAfter(UInt_t column, UInt_t ncolumns);
166// virtual void InsertColumnAfter(TGString label, UInt_t ncolumns);
167// virtual void InsertColumnAt(UInt_t column, UInt_t ncolumns = 1);
168// virtual void InsertColumnAt(TGString label, UInt_t ncolumns);
170// // Remove rows or columns.
171// virtual void RemoveRows(UInt_t row, UInt_t nrows = 1);
172// virtual void RemoveColumns(UInt_t column, UInt_t ncolumns = 1);
174 // Update view
175 virtual void UpdateView();
177 // Getters
178 virtual UInt_t GetNTableRows() const;
179 virtual UInt_t GetNDataRows() const;
180 virtual UInt_t GetNTableColumns() const;
181 virtual UInt_t GetNDataColumns() const;
182 virtual UInt_t GetNTableCells() const;
183 virtual UInt_t GetNDataCells() const;
184 virtual const TTableRange *GetCurrentRange() const;
188 virtual TGCanvas *GetCanvas() { return fCanvas; }
189 virtual const TGTableHeaderFrame *GetRHdrFrame() { return fRHdrFrame; }
190 virtual const TGTableHeaderFrame *GetCHdrFrame() { return fCHdrFrame; }
191 virtual const TGTableHeader *GetRowHeader(const UInt_t row) const;
192 virtual TGTableHeader *GetRowHeader(const UInt_t row);
193 virtual const TGTableHeader *GetColumnHeader(const UInt_t column) const;
194 virtual TGTableHeader *GetColumnHeader(const UInt_t column);
195 virtual TGTableHeader *GetTableHeader();
197// virtual const TGGC* GetSelectGC() const;
198// virtual const TGGC* GetCellBckgndGC(TGTableCell *cell) const;
199// virtual const TGGC* GetCellBckgndGC(UInt_t row, UInt_t column) const;
201 virtual Pixel_t GetRowBackground(UInt_t row) const;
202 virtual Pixel_t GetHeaderBackground() const ;
204 virtual void SetOddRowBackground(Pixel_t pixel);
205 virtual void SetEvenRowBackground(Pixel_t pixel);
206 virtual void SetHeaderBackground(Pixel_t pixel);
207 virtual void SetDefaultColors();
209 // Range manipulators
210 virtual void MoveTable(Int_t rows, Int_t columns);
211 virtual void GotoTableRange(Int_t xtl, Int_t ytl,
212 Int_t xbr, Int_t ybr);
213 // Operators
214 virtual TGTableCell* operator() (UInt_t row, UInt_t column);
216 // Internal slots
217 virtual void ScrollCHeaders(Int_t xpos);
218 virtual void ScrollRHeaders(Int_t ypos);
219 virtual void NextChunk();
220 virtual void PreviousChunk();
221 virtual void UserRangeChange();
222 virtual void Goto();
223 virtual void Update();
225 ClassDef(TGTable, 0) // A table used to visualize data from diffent sources.
230 UInt_t fXtl; // Top left X coordinate
231 UInt_t fYtl; // Top left Y coordinate
232 UInt_t fXbr; // Bottom right X coordinate
233 UInt_t fYbr; // Bottom right Y coordinate
235 TTableRange();
236 virtual ~TTableRange() {}
237 virtual void Print();
240 ClassDef(TTableRange, 0) // Range used in TGTable.
ULong_t Pixel_t
Definition: GuiTypes.h:39
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
bool Bool_t
Definition: RtypesCore.h:59
#define ClassDef(name, id)
Definition: Rtypes.h:326
Definition: TGTableHeader.h:16
int type
Definition: TGX11.cxx:120
TGHorizontalFrame * fButtonFrame
Definition: TGTable.h:60
virtual void ScrollCHeaders(Int_t xpos)
Scroll the column headers horizontally.
Definition: TGTable.cxx:1444
TGHorizontalFrame * fRangeFrame
Definition: TGTable.h:56
virtual void Shrink(UInt_t nrows, UInt_t ncolumns)
Shrink the TGTable by nrows and ncolumns.
Definition: TGTable.cxx:550
virtual UInt_t GetNDataColumns() const
Return the amount of columns in the data source.
Definition: TGTable.cxx:1129
TTableRange * fCurrentRange
Definition: TGTable.h:45
TGHorizontalFrame * fBottomFrame
Definition: TGTable.h:59
virtual void UserRangeChange()
Slot used when the text in one of the range frame text entries changes.
Definition: TGTable.cxx:1501
virtual const TGTableHeader * GetColumnHeader(const UInt_t column) const
Const version of GetColumnHeader();.
Definition: TGTable.cxx:1177
TVirtualTableInterface * fInterface
Definition: TGTable.h:96
TTableRange * fGotoRange
Definition: TGTable.h:47
TGTableFrame * fTableFrame
Definition: TGTable.h:48
virtual const TGTableHeaderFrame * GetRHdrFrame()
Definition: TGTable.h:189
virtual TObjArray * GetRow(UInt_t row)
Get row.
Definition: TGTable.cxx:806
virtual void Init()
Initialise the TGTable.
Definition: TGTable.cxx:233
virtual void SetInterface(TVirtualTableInterface *interface, UInt_t nrows=50, UInt_t ncolumns=20)
Set the interface that the TGTable uses to interface.
Definition: TGTable.cxx:683
virtual void Update()
Update the range of the available data and refresh the current view.
Definition: TGTable.cxx:1544
virtual void SetEvenRowBackground(Pixel_t pixel)
Set the background color for all even numbered rows.
Definition: TGTable.cxx:1264
TGHorizontalFrame * fTopFrame
Definition: TGTable.h:57
Pixel_t fEvenRowBackground
Definition: TGTable.h:75
virtual TGTableCell * operator()(UInt_t row, UInt_t column)
Operator for easy cell acces.
Definition: TGTable.cxx:1436
virtual TGTableHeader * GetTableHeader()
Return a pointer to the table header.
Definition: TGTable.cxx:1193
virtual const TGTableHeader * GetRowHeader(const UInt_t row) const
Const version of GetRowHeader();.
Definition: TGTable.cxx:1161
virtual TObjArray * GetColumn(UInt_t columns)
Return a pointer to a TObjArray that contains pointers to all the cells in column.
Definition: TGTable.cxx:818
virtual UInt_t GetNDataCells() const
Return the amount of cell in the data source.
Definition: TGTable.cxx:1145
virtual const TGTableCell * FindCell(TGString label) const
Const version of FindCell().
Definition: TGTable.cxx:914
TGHorizontalFrame * fTopExtraFrame
Definition: TGTable.h:58
virtual void ShrinkRows(UInt_t nrows)
Shrink the rows of the TGTable by nrows.
Definition: TGTable.cxx:612
virtual Pixel_t GetRowBackground(UInt_t row) const
Get the background collor for row.
Definition: TGTable.cxx:1216
TList * fMainHintsList
Definition: TGTable.h:88
virtual void SetOddRowBackground(Pixel_t pixel)
Set the background color for all odd numbered rows.
Definition: TGTable.cxx:1236
TGTable(const TGWindow *p=0, Int_t id=0, TVirtualTableInterface *interface=0, UInt_t nrows=50, UInt_t ncolumns=20)
Create an array to hold a bunch of numbers.
Definition: TGTable.cxx:168
virtual void Goto()
Slot used by the Goto button and whenever return is pressed in on of the text entries in the range fr...
Definition: TGTable.cxx:1489
virtual UInt_t GetNTableRows() const
Return the amount of rows in the table.
Definition: TGTable.cxx:1105
TObjArray * fRows
Definition: TGTable.h:37
virtual Pixel_t GetHeaderBackground() const
Get the background color of headers.
Definition: TGTable.cxx:1228
virtual UInt_t GetNDataRows() const
Return the amount of rows in the data source.
Definition: TGTable.cxx:1113
TObjArray * fColumnHeaders
Definition: TGTable.h:39
virtual void SetHeaderBackground(Pixel_t pixel)
Set the background color for the headers.
Definition: TGTable.cxx:1291
virtual void UpdateRangeFrame()
Update the range shown in the range frame.
Definition: TGTable.cxx:785
TGTextButton * fNextButton
Definition: TGTable.h:63
virtual UInt_t GetNTableColumns() const
Return the amount of columns in the table.
Definition: TGTable.cxx:1121
virtual UInt_t GetNTableCells() const
Return the amount of cells in the table.
Definition: TGTable.cxx:1137
virtual void UpdateHeaders(EHeaderType type)
Update the labels of the headers of the given type.
Definition: TGTable.cxx:660
TList * fCHdrHintsList
Definition: TGTable.h:87
virtual const TGTableHeaderFrame * GetCHdrFrame()
Definition: TGTable.h:190
virtual void ShrinkColumns(UInt_t ncolumns)
Shrink the columns of the TGTable by ncolumns.
Definition: TGTable.cxx:559
UInt_t fCellHeight
Definition: TGTable.h:51
virtual UInt_t GetCHdrWidth() const
Get the current width of the column header frame.
Definition: TGTable.cxx:524
virtual ~TGTable()
TGTable destructor.
Definition: TGTable.cxx:203
virtual TVirtualTableInterface * GetInterface()
Definition: TGTable.h:186
virtual UInt_t GetRHdrHeight() const
Get the current height of the row header frame.
Definition: TGTable.cxx:537
TList * fRHdrHintsList
Definition: TGTable.h:86
virtual void ExpandRows(UInt_t nrows)
Expand the rows of a TGTable by nrows.
Definition: TGTable.cxx:488
TTableRange * fDataRange
Definition: TGTable.h:46
virtual void SetDefaultColors()
Set the background color for all rows and headers to their defaults.
Definition: TGTable.cxx:1323
TList * fCellHintsList
Definition: TGTable.h:85
TObjArray * fRowHeaders
Definition: TGTable.h:38
TGTextButton * fPrevButton
Definition: TGTable.h:64
virtual void PreviousChunk()
Move the table to the previous chunk of the data set with the same size.
Definition: TGTable.cxx:1479
virtual const TTableRange * GetCurrentRange() const
Return the current range of the TGTable.
Definition: TGTable.cxx:1153
virtual void NextChunk()
Move the table to the next chunk of the data set with the same size.
Definition: TGTable.cxx:1470
TGTextEntry * fFirstCellEntry
Definition: TGTable.h:71
TGCanvas * fCanvas
Definition: TGTable.h:49
Bool_t fReadOnly
Definition: TGTable.h:41
TGTableHeaderFrame * fRHdrFrame
Definition: TGTable.h:55
virtual void GotoTableRange(Int_t xtl, Int_t ytl, Int_t xbr, Int_t ybr)
Move and resize the table to the specified range.
Definition: TGTable.cxx:1348
Pixel_t fSelectColor
Definition: TGTable.h:42
virtual void MoveTable(Int_t rows, Int_t columns)
Move and layout the table to the specified range.
Definition: TGTable.cxx:1333
virtual void DoRedraw()
Redraw the TGTable.
Definition: TGTable.cxx:431
virtual void Show()
Show the contents of the TGTable in stdout.
Definition: TGTable.cxx:945
TGTextButton * fGotoButton
Definition: TGTable.h:66
virtual const TGTableCell * GetCell(UInt_t i, UInt_t j) const
Const version of GetCell().
Definition: TGTable.cxx:892
virtual void ScrollRHeaders(Int_t ypos)
Scroll the row headers vertically.
Definition: TGTable.cxx:1457
TGLabel * fRangeLabel
Definition: TGTable.h:70
virtual void ResizeTable(UInt_t nrows, UInt_t ncolumns)
Resize the table to newnrows and newncolumns and add all the frames to their parent frames.
Definition: TGTable.cxx:722
virtual void UpdateView()
Update and layout the visible part of the TGTable.
Definition: TGTable.cxx:1060
UInt_t fCellWidth
Definition: TGTable.h:50
TGLabel * fFirstCellLabel
Definition: TGTable.h:69
TGTextButton * fUpdateButton
Definition: TGTable.h:65
virtual void ExpandColumns(UInt_t ncolumns)
Expand the columns of a TGTable by ncolumns.
Definition: TGTable.cxx:449
TGTableHeader * fTableHeader
Definition: TGTable.h:40
Pixel_t fOddRowBackground
Definition: TGTable.h:74
TGTableHeaderFrame * fCHdrFrame
Definition: TGTable.h:54
Pixel_t fHeaderBackground
Definition: TGTable.h:76
Bool_t fAllData
Definition: TGTable.h:44
TGTextEntry * fRangeEntry
Definition: TGTable.h:72
Int_t fTMode
Definition: TGTable.h:43
virtual void Expand(UInt_t nrows, UInt_t ncolumns)
Expand a TGTable by nrows and ncolumns.
Definition: TGTable.cxx:440
virtual TGCanvas * GetCanvas()
Definition: TGTable.h:188
A doubly linked list.
Definition: TList.h:44
An array of TObjects.
Definition: TObjArray.h:37
virtual void Print()
Print the values of a range.
Definition: TGTable.cxx:1565
Bool_t operator==(TTableRange &other)
Operator to determine if 2 ranges are equal.
Definition: TGTable.cxx:1574
TTableRange constuctor.
Definition: TGTable.cxx:1558
UInt_t fXtl
Definition: TGTable.h:230
UInt_t fYbr
Definition: TGTable.h:233
UInt_t fXbr
Definition: TGTable.h:232
virtual ~TTableRange()
Definition: TGTable.h:236
UInt_t fYtl
Definition: TGTable.h:231