Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGTable.h
Go to the documentation of this file.
1// Author: Roel Aaij 21/07/2007
2
3/*************************************************************************
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 *************************************************************************/
10
11#ifndef ROOT_TGTable
12#define ROOT_TGTable
13
14#include "TGCanvas.h"
15#include "TGWidget.h"
16#include "TGTableHeader.h"
17
18class TGWindow;
19class TGString;
20class TGToolTip;
21class TGPicture;
23class TGTableCell;
24class TGTableHeader;
25class TGToolTip;
26class TGTableFrame;
28class TGTextButton;
30class TGLabel;
31class TGTextEntry;
32class TTableRange;
33
34class TGTable : public TGCompositeFrame, public TGWidget {
35
36protected:
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
52
53 ///@{
54 ///@name Frames used for layout
55 TGTableHeaderFrame *fCHdrFrame; ///< Frame that contains the row headers
56 TGTableHeaderFrame *fRHdrFrame; ///< Frame that contains the row headers
57 TGHorizontalFrame *fRangeFrame; ///< Frame that contains the top part
58 TGHorizontalFrame *fTopFrame; ///< Frame that contains the top part
60 TGHorizontalFrame *fBottomFrame; ///< Frame that contains the bottom part
61 TGHorizontalFrame *fButtonFrame; ///< Contains the buttons
62 ///@}
63
64 ///@{
65 ///@name Buttons for interaction
66 TGTextButton *fNextButton; ///< Button to view next chunk
67 TGTextButton *fPrevButton; ///< Button to view previous chunk
68 TGTextButton *fUpdateButton; ///< Button to update current view
69 TGTextButton *fGotoButton; ///< Button to goto a new range
70 ///@}
71
72 ///@{
73 ///@name Labels and text entries for range information and input
74 TGLabel *fFirstCellLabel; ///< Label for the range frame
75 TGLabel *fRangeLabel; ///< Label for the range frame
76 TGTextEntry *fFirstCellEntry; ///< TextEntry for the range frame
77 TGTextEntry *fRangeEntry; ///< TextEntry for the range frame
78
79 Pixel_t fOddRowBackground; ///< Background color for odd numbered rows
80 Pixel_t fEvenRowBackground; ///< Background color for even numbered rows
81 Pixel_t fHeaderBackground; ///< Background color for headers
82 ///@}
83
84 // Those are neither used nor even initialized:
85 // static const TGGC *fgDefaultSelectGC; // Default select GC
86 // static const TGGC *fgDefaultBckgndGC; // Default cell background GC
87 // static const Int_t fgDefaultTMode; // Default text justify mode
88
89 ///@{
90 ///@name Data members to keep track of LayoutHints that can't be automatically cleaned
94 TList *fMainHintsList; ///< List for all hints used in the main table frame
95 ///@}
96
97 // Add rows and/or columns to the edge of the table.
98
99 virtual void Init();
100
101 // Remove rows and/or columns from the edge of the table.
102protected:
103 TVirtualTableInterface *fInterface; // Interface to the data source
104
105 void DoRedraw() override;
106
107 virtual void Expand(UInt_t nrows, UInt_t ncolumns);
108 virtual void ExpandColumns(UInt_t ncolumns);
109 virtual void ExpandRows(UInt_t nrows);
110
111 virtual UInt_t GetRHdrHeight() const;
112 virtual UInt_t GetCHdrWidth() const;
113
114 virtual void Shrink(UInt_t nrows, UInt_t ncolumns);
115 virtual void ShrinkColumns(UInt_t ncolumns);
116 virtual void ShrinkRows(UInt_t nrows);
117
118 virtual void UpdateHeaders(EHeaderType type);
119 virtual void SetInterface(TVirtualTableInterface *interface,
120 UInt_t nrows = 50, UInt_t ncolumns = 20);
121 virtual void ResizeTable(UInt_t nrows, UInt_t ncolumns);
122
123 virtual void UpdateRangeFrame();
124
125public:
126 TGTable(const TGWindow *p = nullptr, Int_t id = 0,
127 TVirtualTableInterface *interface = nullptr, UInt_t nrows = 50,
128 UInt_t ncolumns = 20);
129 ~TGTable() override;
130
131 virtual TObjArray *GetRow(UInt_t row);
132 virtual TObjArray *GetColumn(UInt_t columns);
133
134// // Selection
135// virtual void Select(TGTableCell *celltl, TGTableCell *cellbr);
136// virtual void Select(UInt_t xcell1, UInt_t ycell1, UInt_t xcell2, UInt_t ycell2);
137// virtual void SelectAll();
138// virtual void SelectRow(TGTableCell *cell);
139// virtual void SelectRow(UInt_t row);
140// virtual void SelectRows(UInt_t row, UInt_t nrows);
141// virtual void SelectColumn(TGTableCell *cell);
142// virtual void SelectColumn(UInt_t column);
143// virtual void SelectColumns(UInt_t column, UInt_t ncolumns);
144
145// virtual void SetSelectGC(TGGC *gc);
146// virtual void SetTextJustify(Int_t tmode);
147
148 // Cells
149 virtual const TGTableCell* GetCell(UInt_t i, UInt_t j) const;
150 virtual TGTableCell* GetCell(UInt_t i, UInt_t j);
151
152 virtual const TGTableCell* FindCell(TGString label) const;
153 virtual TGTableCell* FindCell(TGString label);
154
155 virtual void Show();
156
157 // Because insertion and removal of columns in the middle of a data
158 // set is not yet supported in this design iteration, these methods
159 // have been commented out.
160
161// // Insert a range of columns or rows, if the label is empty, a
162// // default scheme will be used.
163// virtual void InsertRowBefore(UInt_t row, UInt_t nrows);
164// virtual void InsertRowBefore(TGString label, UInt_t nrows);
165// virtual void InsertRowAfter(UInt_t row, UInt_t nrows);
166// virtual void InsertRowAfter(TGString label, UInt_t nrows);
167// virtual void InsertRowAt(UInt_t row, UInt_t nrows = 1);
168// virtual void InsertRowAt(TGString label, UInt_t nrows);
169
170// virtual void InsertColumnBefore(UInt_t column, UInt_t ncolumns);
171// virtual void InsertColumnBefore(TGString label, UInt_t ncolumns);
172// virtual void InsertColumnAfter(UInt_t column, UInt_t ncolumns);
173// virtual void InsertColumnAfter(TGString label, UInt_t ncolumns);
174// virtual void InsertColumnAt(UInt_t column, UInt_t ncolumns = 1);
175// virtual void InsertColumnAt(TGString label, UInt_t ncolumns);
176
177// // Remove rows or columns.
178// virtual void RemoveRows(UInt_t row, UInt_t nrows = 1);
179// virtual void RemoveColumns(UInt_t column, UInt_t ncolumns = 1);
180
181 // Update view
182 virtual void UpdateView();
183
184 // Getters
185 virtual UInt_t GetNTableRows() const;
186 virtual UInt_t GetNDataRows() const;
187 virtual UInt_t GetNTableColumns() const;
188 virtual UInt_t GetNDataColumns() const;
189 virtual UInt_t GetNTableCells() const;
190 virtual UInt_t GetNDataCells() const;
191 virtual const TTableRange *GetCurrentRange() const;
192
194
195 virtual TGCanvas *GetCanvas() { return fCanvas; }
196 virtual const TGTableHeaderFrame *GetRHdrFrame() { return fRHdrFrame; }
197 virtual const TGTableHeaderFrame *GetCHdrFrame() { return fCHdrFrame; }
198 virtual const TGTableHeader *GetRowHeader(const UInt_t row) const;
199 virtual TGTableHeader *GetRowHeader(const UInt_t row);
200 virtual const TGTableHeader *GetColumnHeader(const UInt_t column) const;
201 virtual TGTableHeader *GetColumnHeader(const UInt_t column);
202 virtual TGTableHeader *GetTableHeader();
203
204// virtual const TGGC* GetSelectGC() const;
205// virtual const TGGC* GetCellBckgndGC(TGTableCell *cell) const;
206// virtual const TGGC* GetCellBckgndGC(UInt_t row, UInt_t column) const;
207
208 virtual Pixel_t GetRowBackground(UInt_t row) const;
209 virtual Pixel_t GetHeaderBackground() const ;
210
211 virtual void SetOddRowBackground(Pixel_t pixel);
212 virtual void SetEvenRowBackground(Pixel_t pixel);
213 virtual void SetHeaderBackground(Pixel_t pixel);
214 virtual void SetDefaultColors();
215
216 // Range manipulators
217 virtual void MoveTable(Int_t rows, Int_t columns);
218 virtual void GotoTableRange(Int_t xtl, Int_t ytl,
219 Int_t xbr, Int_t ybr);
220 // Operators
221 virtual TGTableCell* operator() (UInt_t row, UInt_t column);
222
223 // Internal slots
224 virtual void ScrollCHeaders(Int_t xpos);
225 virtual void ScrollRHeaders(Int_t ypos);
226 virtual void NextChunk();
227 virtual void PreviousChunk();
228 virtual void UserRangeChange();
229 virtual void Goto();
230 virtual void Update();
231
232 ClassDefOverride(TGTable, 0) // A table used to visualize data from different sources.
233};
234
236public:
237 UInt_t fXtl; ///< Top left X coordinate
238 UInt_t fYtl; ///< Top left Y coordinate
239 UInt_t fXbr; ///< Bottom right X coordinate
240 UInt_t fYbr; ///< Bottom right Y coordinate
241
242 TTableRange();
243 virtual ~TTableRange() {}
244 virtual void Print();
245
247
248 ClassDef(TTableRange, 0) // Range used in TGTable.
249};
250
251#endif
252
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
unsigned int UInt_t
Definition RtypesCore.h:46
#define ClassDef(name, id)
Definition Rtypes.h:337
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
EHeaderType
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void pixel
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void xpos
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void ypos
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
Definition TGCanvas.h:192
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:385
This class handles GUI labels.
Definition TGLabel.h:24
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition TGString.h:20
TGTableCell is the class that represents a single cell in a TGTable.
Definition TGTableCell.h:24
TGTableFrame contains a composite frame that uses a TGMatrixLayout to Layout the frames it contains.
TGTableHeaderFrame implements a frame used to display TGTableHeaders in a TGTable.
TGTableHeader is the class that implements a header for a row or column.
Create an array to hold a bunch of numbers.
Definition TGTable.h:34
TGHorizontalFrame * fButtonFrame
Contains the buttons.
Definition TGTable.h:61
virtual void ScrollCHeaders(Int_t xpos)
Scroll the column headers horizontally.
Definition TGTable.cxx:1430
TGHorizontalFrame * fRangeFrame
Frame that contains the top part.
Definition TGTable.h:57
virtual void Shrink(UInt_t nrows, UInt_t ncolumns)
Shrink the TGTable by nrows and ncolumns.
Definition TGTable.cxx:537
virtual UInt_t GetNDataColumns() const
Return the amount of columns in the data source.
Definition TGTable.cxx:1116
TTableRange * fCurrentRange
Range of data currently loaded.
Definition TGTable.h:45
TGHorizontalFrame * fBottomFrame
Frame that contains the bottom part.
Definition TGTable.h:60
virtual void UserRangeChange()
Slot used when the text in one of the range frame text entries changes.
Definition TGTable.cxx:1487
virtual const TGTableHeader * GetColumnHeader(const UInt_t column) const
Const version of GetColumnHeader();.
Definition TGTable.cxx:1164
TVirtualTableInterface * fInterface
Definition TGTable.h:103
TTableRange * fGotoRange
Range used by Goto frame.
Definition TGTable.h:47
TGTableFrame * fTableFrame
Container for the frames.
Definition TGTable.h:48
virtual const TGTableHeaderFrame * GetRHdrFrame()
Definition TGTable.h:196
virtual TObjArray * GetRow(UInt_t row)
Get row.
Definition TGTable.cxx:793
virtual void Init()
Initialise the TGTable.
Definition TGTable.cxx:220
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:670
virtual void Update()
Update the range of the available data and refresh the current view.
Definition TGTable.cxx:1529
virtual void SetEvenRowBackground(Pixel_t pixel)
Set the background color for all even numbered rows.
Definition TGTable.cxx:1251
TGHorizontalFrame * fTopFrame
Frame that contains the top part.
Definition TGTable.h:58
Pixel_t fEvenRowBackground
Background color for even numbered rows.
Definition TGTable.h:80
virtual TGTableCell * operator()(UInt_t row, UInt_t column)
Operator for easy cell acces.
Definition TGTable.cxx:1422
virtual TGTableHeader * GetTableHeader()
Return a pointer to the table header.
Definition TGTable.cxx:1180
virtual const TGTableHeader * GetRowHeader(const UInt_t row) const
Const version of GetRowHeader();.
Definition TGTable.cxx:1148
virtual TObjArray * GetColumn(UInt_t columns)
Return a pointer to a TObjArray that contains pointers to all the cells in column.
Definition TGTable.cxx:805
virtual UInt_t GetNDataCells() const
Return the amount of cell in the data source.
Definition TGTable.cxx:1132
virtual const TGTableCell * FindCell(TGString label) const
Const version of FindCell().
Definition TGTable.cxx:901
TGHorizontalFrame * fTopExtraFrame
Dev idea.
Definition TGTable.h:59
virtual void ShrinkRows(UInt_t nrows)
Shrink the rows of the TGTable by nrows.
Definition TGTable.cxx:599
virtual Pixel_t GetRowBackground(UInt_t row) const
Get the background collor for row.
Definition TGTable.cxx:1203
TList * fMainHintsList
List for all hints used in the main table frame.
Definition TGTable.h:94
virtual void SetOddRowBackground(Pixel_t pixel)
Set the background color for all odd numbered rows.
Definition TGTable.cxx:1223
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:1475
virtual UInt_t GetNTableRows() const
Return the amount of rows in the table.
Definition TGTable.cxx:1092
TObjArray * fRows
Array of rows.
Definition TGTable.h:37
virtual Pixel_t GetHeaderBackground() const
Get the background color of headers.
Definition TGTable.cxx:1215
virtual UInt_t GetNDataRows() const
Return the amount of rows in the data source.
Definition TGTable.cxx:1100
TObjArray * fColumnHeaders
Array of column headers.
Definition TGTable.h:39
void DoRedraw() override
Redraw the TGTable.
Definition TGTable.cxx:418
virtual void SetHeaderBackground(Pixel_t pixel)
Set the background color for the headers.
Definition TGTable.cxx:1278
virtual void UpdateRangeFrame()
Update the range shown in the range frame.
Definition TGTable.cxx:772
TGTextButton * fNextButton
Button to view next chunk.
Definition TGTable.h:66
virtual UInt_t GetNTableColumns() const
Return the amount of columns in the table.
Definition TGTable.cxx:1108
virtual UInt_t GetNTableCells() const
Return the amount of cells in the table.
Definition TGTable.cxx:1124
virtual void UpdateHeaders(EHeaderType type)
Update the labels of the headers of the given type.
Definition TGTable.cxx:647
TList * fCHdrHintsList
Definition TGTable.h:93
virtual const TGTableHeaderFrame * GetCHdrFrame()
Definition TGTable.h:197
virtual void ShrinkColumns(UInt_t ncolumns)
Shrink the columns of the TGTable by ncolumns.
Definition TGTable.cxx:546
UInt_t fCellHeight
Default cell width.
Definition TGTable.h:51
virtual UInt_t GetCHdrWidth() const
Get the current width of the column header frame.
Definition TGTable.cxx:511
~TGTable() override
TGTable destructor.
Definition TGTable.cxx:190
virtual TVirtualTableInterface * GetInterface()
Definition TGTable.h:193
virtual UInt_t GetRHdrHeight() const
Get the current height of the row header frame.
Definition TGTable.cxx:524
TList * fRHdrHintsList
Definition TGTable.h:92
virtual void ExpandRows(UInt_t nrows)
Expand the rows of a TGTable by nrows.
Definition TGTable.cxx:475
TTableRange * fDataRange
Full range of the data set.
Definition TGTable.h:46
virtual void SetDefaultColors()
Set the background color for all rows and headers to their defaults.
Definition TGTable.cxx:1310
TList * fCellHintsList
Definition TGTable.h:91
TObjArray * fRowHeaders
Array of row headers.
Definition TGTable.h:38
TGTextButton * fPrevButton
Button to view previous chunk.
Definition TGTable.h:67
virtual void PreviousChunk()
Move the table to the previous chunk of the data set with the same size.
Definition TGTable.cxx:1465
virtual const TTableRange * GetCurrentRange() const
Return the current range of the TGTable.
Definition TGTable.cxx:1140
virtual void NextChunk()
Move the table to the next chunk of the data set with the same size.
Definition TGTable.cxx:1456
TGTextEntry * fFirstCellEntry
TextEntry for the range frame.
Definition TGTable.h:76
TGCanvas * fCanvas
Canvas that will contains the cells.
Definition TGTable.h:49
Bool_t fReadOnly
Table readonly state.
Definition TGTable.h:41
TGTableHeaderFrame * fRHdrFrame
Frame that contains the row headers.
Definition TGTable.h:56
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:1335
Pixel_t fSelectColor
Select Color.
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:1320
virtual void Show()
Show the contents of the TGTable in stdout.
Definition TGTable.cxx:932
TGTextButton * fGotoButton
Button to goto a new range.
Definition TGTable.h:69
virtual const TGTableCell * GetCell(UInt_t i, UInt_t j) const
Const version of GetCell().
Definition TGTable.cxx:879
virtual void ScrollRHeaders(Int_t ypos)
Scroll the row headers vertically.
Definition TGTable.cxx:1443
TGLabel * fRangeLabel
Label for the range frame.
Definition TGTable.h:75
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:709
virtual void UpdateView()
Update and layout the visible part of the TGTable.
Definition TGTable.cxx:1047
UInt_t fCellWidth
Default cell width.
Definition TGTable.h:50
TGLabel * fFirstCellLabel
Label for the range frame.
Definition TGTable.h:74
TGTextButton * fUpdateButton
Button to update current view.
Definition TGTable.h:68
virtual void ExpandColumns(UInt_t ncolumns)
Expand the columns of a TGTable by ncolumns.
Definition TGTable.cxx:436
TGTableHeader * fTableHeader
Top left element of the table.
Definition TGTable.h:40
Pixel_t fOddRowBackground
Background color for odd numbered rows.
Definition TGTable.h:79
TGTableHeaderFrame * fCHdrFrame
Frame that contains the row headers.
Definition TGTable.h:55
Pixel_t fHeaderBackground
Background color for headers.
Definition TGTable.h:81
Bool_t fAllData
Is the data bigger than the table.
Definition TGTable.h:44
TGTextEntry * fRangeEntry
TextEntry for the range frame.
Definition TGTable.h:77
Int_t fTMode
Text justify mode.
Definition TGTable.h:43
virtual void Expand(UInt_t nrows, UInt_t ncolumns)
Expand a TGTable by nrows and ncolumns.
Definition TGTable.cxx:427
virtual TGCanvas * GetCanvas()
Definition TGTable.h:195
Yield an action as soon as it is clicked.
Definition TGButton.h:142
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
A tooltip can be a one or multiple lines help text that is displayed in a window when the mouse curso...
Definition TGToolTip.h:24
The widget base class.
Definition TGWidget.h:43
ROOT GUI Window base class.
Definition TGWindow.h:23
A doubly linked list.
Definition TList.h:38
An array of TObjects.
Definition TObjArray.h:31
virtual void Print()
Print the values of a range.
Definition TGTable.cxx:1550
Bool_t operator==(TTableRange &other)
Operator to determine if 2 ranges are equal.
Definition TGTable.cxx:1559
TTableRange()
TTableRange constuctor.
Definition TGTable.cxx:1543
UInt_t fXtl
Top left X coordinate.
Definition TGTable.h:237
UInt_t fYbr
Bottom right Y coordinate.
Definition TGTable.h:240
UInt_t fXbr
Bottom right X coordinate.
Definition TGTable.h:239
virtual ~TTableRange()
Definition TGTable.h:243
UInt_t fYtl
Top left Y coordinate.
Definition TGTable.h:238