Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGTable.cxx
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#include "TGCanvas.h"
12#include "TGWindow.h"
13#include "TGResourcePool.h"
14#include <iostream>
15#include <iomanip>
16#include "TGWidget.h"
17#include "TRandom3.h"
19#include "TGTable.h"
20#include "TGTableCell.h"
21#include "TGTableHeader.h"
22#include "TObjArray.h"
23#include "TGTableContainer.h"
24#include "TGScrollBar.h"
25#include "TGButton.h"
26#include "TGTextEntry.h"
27#include "TGLabel.h"
28#include "TColor.h"
29
30
31
32/** \class TGTable
33 \ingroup guiwidgets
34
35Create an array to hold a bunch of numbers
36
37TGTable implements a table widget to display data in rows and
38columns. The data is supplied by a TVirtualTableInterface.
39
40The table is a TGCanvas to make use of already available viewport
41functionality and drawing optimizations.
42
43The top left cell in a table has coordinates (0,0)
44
45A TObjArray is used internally to ensure little overhead and fast
46acces to cells.
47
48If the data source has more rows than the default 50 rows of cells in
49memory, buttons at the bottom of the table can be used to load the
50next or previous chunk of data.
51
52At the top of the table, a frame is visible that shows the coordinates
53of the top left cell currently in memmory in row,column. The amount of
54rows and columns is also shown in rows x columns. These values can be
55edited to move to a different area of the data source or to resize the
56table. Tab will switch between the enties, return will move to the
57currently entered range and resize the table if needed. Clicking the
58goto button has the same effect.
59
60A TGTable is created by first creating an appropriate
61TVirtualTableInterface from the data that needs visualization and
62then creating the TGTable using this interface.
63
64A simple macro to use a TGTable with a TGSimpleTableInterface:
65
66~~~
67{
68 Int_t i = 0, j = 0;
69 UInt_t nrows = 6, ncolumns = 5;
70 Double_t** data = new Double_t*[nrows];
71 for (i = 0; i < nrows; i++) {
72 data[i] = new Double_t[ncolumns];
73 for (j = 0; j < ncolumns; j++) {
74 data[i][j] = 10 * i + j;
75 }
76 }
77
78 // Create a main frame to contain the table
79 TGMainFrame* mainframe = new TGMainFrame(0, 400, 200);
80 mainframe->SetCleanup(kDeepCleanup) ;
81
82 // Create an interface
83 TGSimpleTableInterface *iface = new TGSimpleTableInterface(data, 6, 5);
84
85 // Create the table
86 TGTable *table = new TGTable(mainframe, 999, iface);
87
88 // Add the table to the main frame
89 mainframe->AddFrame(table, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
90
91 //Update data
92 data[5][1] = 3.01;
93 //update the table view
94 table->Update();
95
96 // Layout and map the main frame
97 mainframe->SetWindowName("Tree Table Test") ;
98 mainframe->MapSubwindows() ;
99 mainframe->Layout();
100 mainframe->Resize() ;
101 mainframe->MapWindow() ;
102
103 return mainframe;
104}
105~~~
106
107It is also possible to visualise data from a tree. A simple macro
108showing the use of a TTreeTableInterface follows.
109
110~~~
111{
112 // Open a root file.
113 TFile *file = new TFile("$ROOTSYS/tutorials/hsimple.root");
114 // Load a tree from the file
115 TNtuple *ntuple = (TNtuple *)file->Get("ntuple");
116
117 // Create an interface
118 TTreeTableInterface *iface = new TTreeTableInterface(ntuple);
119
120 // Create a main frame to contain the table
121 TGMainFrame* mainframe = new TGMainFrame(0, 400, 200);
122 mainframe->SetCleanup(kDeepCleanup) ;
123
124 // Create the table
125 TGTable *table = new TGTable(mainframe, 999, iface, 10, 6);
126
127 // Add the table to the main frame
128 mainframe->AddFrame(table, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
129
130 // Set a selection
131 iface->SetSelection("px > 0.");
132 // Add a column
133 iface->AddColumn("(px+py)/(px-py)", 0);
134 //update the table view
135 table->Update();
136
137 // Layout and map the main frame
138 mainframe->SetWindowName("Tree Table Test") ;
139 mainframe->MapSubwindows() ;
140 mainframe->Layout();
141 mainframe->Resize() ;
142 mainframe->MapWindow() ;
143
144 return mainframe;
145}
146~~~
147*/
148
149
150////////////////////////////////////////////////////////////////////////////////
151/// TGTable constuctor.
152
155 : TGCompositeFrame(p, 500, 500, kVerticalFrame), TGWidget(id), fRows(0),
156 fRowHeaders(0), fColumnHeaders(0), fReadOnly(kFALSE), fSelectColor(0),
157 fTMode(0), fAllData(kFALSE), fTableFrame(0), fCanvas(0), fCellWidth(80),
158 fCellHeight(25), fInterface(interface)
159{
161 fDataRange = new TTableRange();
162 fGotoRange = new TTableRange();
163
164 fCellHintsList = new TList();
165 fRHdrHintsList = new TList();
166 fCHdrHintsList = new TList();
167 fMainHintsList = new TList();
168
169 // To be done: GetBackground colors for .rootrc
171 fEvenRowBackground = TColor::RGB2Pixel(204, 255, 204);
172 fOddRowBackground = TColor::RGB2Pixel(255, 255, 255);
173 fHeaderBackground = TColor::RGB2Pixel(204, 204, 255);
174
177
178 Init();
179
182// MapWindow();
183}
184
185////////////////////////////////////////////////////////////////////////////////
186/// TGTable destructor.
187
189{
190 // delete all cells in a good way
191 UInt_t i = 0, j = 0;
192 for (i = 0; i < GetNTableRows(); i++) {
193 for (j = 0; j < GetNTableColumns(); j++) {
194 delete GetCell(i,j);
195 }
196 delete fRows->At(i);
197 }
198 delete fRows;
199 delete fRowHeaders;
200 delete fColumnHeaders;
201
202 delete fCurrentRange;
203 delete fDataRange;
204 delete fGotoRange;
205
207 delete fCellHintsList;
208 delete fRHdrHintsList;
209 delete fCHdrHintsList;
210
212 delete fMainHintsList;
213}
214
215////////////////////////////////////////////////////////////////////////////////
216/// Initialise the TGTable.
217
219{
222
223 // Main layout frames
227 TGString *str = new TGString();
228 *str += GetNTableRows();
229 *str += "x";
230 *str += GetNTableColumns();
231 *str += " Table";
232 fTableHeader = new TGTableHeader(fTopFrame, this, str, 0,
234
240
241 // Frame for the buttons at the bottom
242 fButtonFrame = new TGHorizontalFrame(this, 200, 50);
243 fNextButton = new TGTextButton(fButtonFrame, "Next", WidgetId() + 2000);
244 fPrevButton = new TGTextButton(fButtonFrame, "Previous", WidgetId() + 2001);
245 fUpdateButton = new TGTextButton(fButtonFrame, "Update", WidgetId() + 2002);
246
248 nrows * fCellHeight, 0);
252
253 // Frame to display range info and goto button.
254 fRangeFrame = new TGHorizontalFrame(this, 450, 50);
255 fFirstCellLabel = new TGLabel(fRangeFrame, "Top left cell in range:");
256 fRangeLabel = new TGLabel(fRangeFrame, "Range:");
257 fFirstCellEntry = new TGTextEntry(fRangeFrame, "0,0", WidgetId() + 2050);
260 fFirstCellEntry->Connect("TextChanged(const char *)", "TGTable", this,
261 "UserRangeChange()");
262 fFirstCellEntry->Connect("ReturnPressed()", "TGTable", this, "Goto()");
263
265 range += GetNTableRows();
266 range += "x";
269 fRangeEntry->SetWidth(100);
271 fRangeEntry->Connect("TextChanged(const char *)", "TGTable", this,
272 "UserRangeChange()");
273 fRangeEntry->Connect("ReturnPressed()", "TGTable", this, "Goto()");
274 fRangeEntry->Connect("TabPressed()", "TGTextEntry", fFirstCellEntry,
275 "SetFocus()");
276 fFirstCellEntry->Connect("TabPressed()", "TGTextEntry", fRangeEntry,
277 "SetFocus()");
278
281 fGotoButton = new TGTextButton(fRangeFrame, "Goto", WidgetId() + 2003);
283
284 // Set frame backgrounds
294
295 // Create the cells needed
296 UInt_t i = 0, j = 0;
297 TGString *label = 0;
299 for(i = 0; i < nrows; i++) {
301 label, i, kRowHeader);
302 fRowHeaders->AddAt(hdr, i);
303 }
305 for(i = 0; i < ncolumns; i++) {
307 label, i, kColumnHeader);
309 }
310
311 TGTableCell *cell = 0;
312 TObjArray *row = 0;
313 fRows = new TObjArray(nrows);
314 for (i = 0; i < nrows; i++) {
315 row = new TObjArray(ncolumns);
316 fRows->AddAt(row, i);
317 for (j = 0; j < ncolumns; j++) {
318 cell = new TGTableCell(fCanvas->GetContainer(), this, label, i, j);
319 row->AddAt(cell, j);
320 }
321 }
322
323 // Check if the table covers all the data
324 if ((GetNDataColumns() >= GetNTableColumns()) &&
325 (GetNDataRows() >= GetNTableRows())) {
326 fAllData = kTRUE;
327 } else {
329 }
330
332
333 // Add cells and headers to layout frames
334 for (i = 0; i < nrows; i++) {
338 for (j = 0; j < ncolumns; j++) {
339 if (i == 0) {
343 }
347 }
348 }
349
350 // Add frames to the range frame
351 lhints = new TGLayoutHints(kLHintsRight | kLHintsCenterY, 3, 30, 4, 4);
363 // Range frame size = 448
365
366 // Add table to the main composite frame
378
379 // Add buttons to button frame
380 lhints = new TGLayoutHints(kLHintsRight | kLHintsCenterY, 3, 30, 4, 4);
382 lhints = new TGLayoutHints(kLHintsRight | kLHintsCenterY, 3, 3, 4, 4);
384 lhints = new TGLayoutHints(kLHintsRight | kLHintsCenterY, 3, 30, 4, 4);
388
396
397 // Setup scrolling for the headers
399 sbar->Connect("PositionChanged(Int_t)", "TGTable", this, "ScrollRHeaders(Int_t)");
401 sbar->Connect("PositionChanged(Int_t)", "TGTable", this, "ScrollCHeaders(Int_t)");
402
403 // Connections for buttons
404 fUpdateButton->Connect("Clicked()", "TGTable", this, "Update()");
405 fNextButton->Connect("Clicked()", "TGTable", this, "NextChunk()");
406 fPrevButton->Connect("Clicked()", "TGTable", this, "PreviousChunk()");
407 fGotoButton->Connect("Clicked()", "TGTable", this, "Goto()");
408
409// MapSubwindows();
410// Layout();
411}
412
413////////////////////////////////////////////////////////////////////////////////
414/// Redraw the TGTable.
415
417{
419 Layout();
420}
421
422////////////////////////////////////////////////////////////////////////////////
423/// Expand a TGTable by nrows and ncolumns.
424
430
431////////////////////////////////////////////////////////////////////////////////
432/// Expand the columns of a TGTable by ncolumns.
433
435{
436 UInt_t i = 0, j = 0;
437 TGString *label = 0;
438
441
443
444 for (i = 0; i < ncolumns; i++) {
445 TGTableHeader *header = new TGTableHeader(fCHdrFrame, this, label,
446 ntcolumns + i,
448 fColumnHeaders->AddAt(header, ntcolumns + i);
449 }
450
451 for (i = 0; i < ntrows; i++) {
452 GetRow(i)->Expand(ntcolumns + ncolumns);
453 for (j = 0; j < ncolumns; j++) {
454 TGTableCell *cell = new TGTableCell(fCanvas->GetContainer(), this, label, i,
455 ntcolumns + j);
456 if (GetRow(i)) GetRow(i)->AddAt(cell, ntcolumns + j);
457 }
458 }
459
461
462 if ((GetNDataColumns() == GetNTableColumns()) &&
463 (GetNDataRows() == GetNTableRows())) {
464 fAllData = kTRUE;
465 } else {
467 }
468}
469
470////////////////////////////////////////////////////////////////////////////////
471/// Expand the rows of a TGTable by nrows.
472
474{
475 UInt_t i = 0, j = 0;
476
479
482 for (i = 0; i < nrows; i++) {
483 TObjArray *row = new TObjArray(ntcolumns);
484 fRows->AddAt(row, ntrows + i);
485 TGString *label = 0;
486 TGTableHeader *header = new TGTableHeader(fRHdrFrame, this, label,
487 ntrows + i, kRowHeader);
488 fRowHeaders->AddAt(header, ntrows + i);
489 for (j = 0; j < ntcolumns ; j++) {
490 TGTableCell *cell = new TGTableCell(fCanvas->GetContainer(), this, label,
491 ntrows + i, j);
492 if (GetRow(ntrows + i)) GetRow(ntrows + i)->AddAt(cell, j);
493 }
494 }
495
497
498 if ((GetNDataColumns() == GetNTableColumns()) &&
499 (GetNDataRows() == GetNTableRows())) {
500 fAllData = kTRUE;
501 } else {
503 }
504}
505
506////////////////////////////////////////////////////////////////////////////////
507/// Get the current width of the column header frame.
508
510{
512 UInt_t width = 0;
513 for (Int_t i = 0; i < ncolumns; i++) {
514 if (GetColumnHeader(i)) width += GetColumnHeader(i)->GetWidth();
515 }
516 return width;
517}
518
519////////////////////////////////////////////////////////////////////////////////
520/// Get the current height of the row header frame.
521
523{
525 UInt_t height = 0;
526 for (Int_t i = 0; i < nrows; i++) {
527 if (GetRowHeader(i)) height += GetRowHeader(i)->GetHeight();
528 }
529 return height;
530}
531
532////////////////////////////////////////////////////////////////////////////////
533/// Shrink the TGTable by nrows and ncolumns.
534
540
541////////////////////////////////////////////////////////////////////////////////
542/// Shrink the columns of the TGTable by ncolumns.
543
545{
546 UInt_t i = 0, j = 0, k = 0;
547
548 if(GetNTableColumns() - ncolumns < 1) {
549 Info("TGTable::ShrinkColumns", "Cannot shrink smaller than 1"
550 " column, adjusting");
552 }
553
556
557 TGTableCell *cell = 0;
558
559 //Destroy windows
560
561 for (i = 0; i < ntrows; i++) {
562 for (j = 0; j < ncolumns; j++) {
563 k = ntcolumns - ncolumns + j;
564 if (GetRow(i)) {
565 cell = (TGTableCell *)GetRow(i)->RemoveAt(k);
566 if (cell) {
567 cell->DestroyWindow();
568 delete cell;
569 }
570 }
571 }
572 GetRow(i)->Expand(ntcolumns - ncolumns);
573 }
574
575 TGTableHeader *hdr = 0;
576 for (j = 0; j < ncolumns; j++) {
578 hdr->DestroyWindow();
579 delete hdr;
580 }
582
584
585
586 if ((GetNDataColumns() == GetNTableColumns()) &&
587 (GetNDataRows() == GetNTableRows())) {
588 fAllData = kTRUE;
589 } else {
591 }
592}
593
594////////////////////////////////////////////////////////////////////////////////
595/// Shrink the rows of the TGTable by nrows.
596
598{
599 UInt_t i = 0 , j = 0;
600
601 if(GetNTableRows() - nrows < 1) {
602 Info("TGTable::ShrinkRows", "Cannot shrink smaller than 1 row, adjusting");
603 nrows = GetNTableRows() - 1;
604 }
605
608
609 TObjArray *row = 0;
610 TGTableCell *cell = 0;
611 TGTableHeader *hdr = 0;
612
613 for (i = 0; i < nrows; i++) {
614 for (j = 0; j < ntcolumns ; j++) {
615 if (GetRow(ntrows - nrows + i)) {
616 cell = (TGTableCell *)GetRow(ntrows - nrows + i)->RemoveAt(j);
617 if (cell) {
618 cell->DestroyWindow();
619 delete cell;
620 }
621 }
622 }
623 row = (TObjArray *)fRows->RemoveAt(ntrows - nrows + i);
624 delete row;
626 hdr->DestroyWindow();
627 delete hdr;
628 }
631
633
634 if ((GetNDataColumns() == GetNTableColumns()) &&
635 (GetNDataRows() == GetNTableRows())) {
636 fAllData = kTRUE;
637 } else {
639 }
640}
641
642////////////////////////////////////////////////////////////////////////////////
643/// Update the labels of the headers of the given type
644
646{
647 UInt_t max = 0, i = 0, d = 0;
648 if(type == kColumnHeader) {
649 max = GetNTableColumns();
650 for (i = 0; i < max; i++) {
651 d = fCurrentRange->fXtl + i;
654 }
655 } else if (type == kRowHeader) {
656 max = GetNTableRows();
657 for (i = 0; i < max; i++) {
658 d = fCurrentRange->fYtl + i;
660 GetRowHeader(i)->SetLabel(fInterface->GetRowHeader(d));
661 }
662 }
663}
664
665////////////////////////////////////////////////////////////////////////////////
666/// Set the interface that the TGTable uses to interface.
667
670{
672
673 // Set up ranges
674
675 fDataRange->fXtl = 0;
676 fDataRange->fYtl = 0;
679
680 UInt_t x = 0, y = 0;
681 if (fDataRange->fXbr < ncolumns) {
682 x = fDataRange->fXbr;
683 } else {
684 x = ncolumns;
685 }
686
687 if (fDataRange->fYbr < nrows) {
688 y = fDataRange->fYbr;
689 } else {
690 y = nrows;
691 }
692
693 GotoTableRange(0, 0, x, y);
694
695 if ((GetNDataColumns() == GetNTableColumns()) &&
696 (GetNDataRows() == GetNTableRows())) {
697 fAllData = kTRUE;
698 } else {
700 }
701}
702
703////////////////////////////////////////////////////////////////////////////////
704/// Resize the table to newnrows and newncolumns and add all the frames to
705/// their parent frames.
706
708{
711
712 Int_t i = 0, j = 0;
713
715
716 if (newnrows != oldnrows){
717 if (newnrows > oldnrows) {
719 } else {
721 }
722 }
723
724 if (newncolumns != oldncolumns){
725 if (newncolumns > oldncolumns) {
727 } else {
729 }
730 }
731
732 // Update the layoutmanager and add the frames.
733 if ((newncolumns != oldncolumns) || (newnrows != oldnrows)) {
734 container->RemoveAll();
736
739
742
743 container->SetLayoutManager(new TGMatrixLayout(container,
745 // Add frames to layout frames
747 for (i = 0; i < (Int_t)newnrows; i++) {
751 for (j = 0; j < (Int_t)newncolumns; j++) {
752 if (i == 0) {
756 }
760 }
761 }
762 }
764 fCanvas->Layout();
765}
766
767////////////////////////////////////////////////////////////////////////////////
768/// Update the range shown in the range frame.
769
771{
773
775 tl += ",";
777 fFirstCellEntry->SetText(tl.Data());
778
779 range += GetNTableRows();
780 range += "x";
782 fRangeEntry->SetText(range.Data());
783
785}
786
787////////////////////////////////////////////////////////////////////////////////
788/// Get row. NOTE: Do not delete the TObjArray returned or the cells
789/// it contains, they are owned by the TGTable.
790
792{
793 return (TObjArray *)fRows->At(row);
794}
795
796////////////////////////////////////////////////////////////////////////////////
797/// Return a pointer to a TObjArray that contains pointers to all
798/// the cells in column. NOTE: The user will have to delete the
799/// TObjArray, but do NOT delete the cells it contains, they are
800/// owned by the TGTable and will be deleted from the TGTable with
801/// undefined consequenses.
802
804{
806
807 TObjArray *col = new TObjArray(nrows);
808 for(UInt_t ui = 0; ui < nrows; ui++) {
809 col->AddAt(GetCell(ui, column), ui);
810 }
811 return col;
812}
813
814// //______________________________________________________________________________
815// void TGTable::Select(TGTableCell *celltl, TGTableCell *cellbr)
816// {
817// }
818
819// //______________________________________________________________________________
820// void TGTable::Select(UInt_t xcelltl, UInt_t ycelltl, UInt_t xcell2, UInt_t ycell2)
821// {
822// }
823
824// //______________________________________________________________________________
825// void TGTable::SelectAll()
826// {
827// }
828
829// //______________________________________________________________________________
830// void TGTable::SelectRow(TGTableCell *cell)
831// {
832// }
833
834// //______________________________________________________________________________
835// void TGTable::SelectRow(UInt_t row)
836// {
837// }
838
839// //______________________________________________________________________________
840// void TGTable::SelectRows(UInt_t row, UInt_t nrows)
841// {
842// }
843
844// //______________________________________________________________________________
845// void TGTable::SelectColumn(TGTableCell *cell)
846// {
847// }
848
849// //______________________________________________________________________________
850// void TGTable::SelectColumn(UInt_t column)
851// {
852// }
853
854// //______________________________________________________________________________
855// void TGTable::SelectColumns(UInt_t column, UInt_t ncolumns)
856// {
857// }
858
859// //______________________________________________________________________________
860// void TGTable::SetBckgndGC(TGGC *gc)
861// {
862// }
863
864// //______________________________________________________________________________
865// void TGTable::SetSelectGC(TGGC *gc)
866// {
867// }
868
869// //______________________________________________________________________________
870// void TGTable::SetTextJustify(Int_t tmode)
871// {
872// }
873
874////////////////////////////////////////////////////////////////////////////////
875/// Const version of GetCell().
876
878{
879 return const_cast<TGTable *>(this)->GetCell(i, j);
880}
881
882////////////////////////////////////////////////////////////////////////////////
883/// Return a pointer to the TGTableCell at position i,j.
884
886{
887 TObjArray *row = (TObjArray *)fRows->At(i);
888 if(row) {
889 TGTableCell *cell = (TGTableCell *)row->At(j);
890 return cell;
891 } else {
892 return 0;
893 }
894}
895
896////////////////////////////////////////////////////////////////////////////////
897/// Const version of FindCell().
898
900{
901 return const_cast<TGTable *>(this)->FindCell(label);
902}
903
904////////////////////////////////////////////////////////////////////////////////
905/// Find the TGTableCell with label.
906
908{
909 TObjArray *row = 0;
910 TGTableCell *cell = 0;
911 UInt_t i = 0, j = 0;
912 //continue here
915 for (i = 0; i < nrows; i++) {
916 for (j = 0; j < ncolumns; j++) {
917 row = (TObjArray *)fRows->At(j);
918 cell = (TGTableCell *)row->At(i);
919 if (*(cell->GetLabel()) == label) {
920 return cell;
921 }
922 }
923 }
924 return 0;
925}
926
927////////////////////////////////////////////////////////////////////////////////
928/// Show the contents of the TGTable in stdout.
929
931{
932 TGTableCell *cell = 0;
933 TGTableHeader *hdr = 0;
934 UInt_t i = 0, j = 0;
937
938 // save actual formatting flags
939 std::ios_base::fmtflags org_flags = std::cout.flags();
940
941 for (j = 0; j < ncolumns + 1; j++) {
942 if (j == 0) {
944 if (hdr) std::cout << " " << std::setw(12) << std::right
945 << hdr->GetLabel()->GetString() << " ";
946 } else {
947 hdr = GetColumnHeader(j - 1);
948 if (hdr) std::cout << " " << std::setw(12) << std::right
949 << hdr->GetLabel()->GetString() << " ";
950 }
951 }
952 std::cout << std::endl;
953
954 for (i = 0; i < nrows; i++) {
955 for (j = 0; j < ncolumns + 1; j++) {
956 if (j == 0) {
957 hdr = GetRowHeader(i);
958 if (hdr) std::cout << " " << std::setw(12) << std::right
959 << hdr->GetLabel()->GetString() << " ";
960 } else {
961 cell = GetCell(i, j - 1);
962 if (cell) std::cout << " " << std::setw(12) << std::right
963 << cell->GetLabel()->GetString() << " ";
964 }
965 }
966 std::cout << std::endl;
967 }
968 // restore original formatting flags
969 std::cout.flags(org_flags);
970}
971
972// //______________________________________________________________________________
973// void TGTable::InsertRowBefore(UInt_t row, UInt_t nrows)
974// {
975// }
976
977// //______________________________________________________________________________
978// void TGTable::InsertRowBefore(TGString label, UInt_t nrows)
979// {
980// }
981
982// //______________________________________________________________________________
983// void TGTable::InsertRowAfter(UInt_t row, UInt_t nrows)
984// {
985// }
986
987// //______________________________________________________________________________
988// void TGTable::InsertRowAfter(TGString label, UInt_t nrows)
989// {
990// }
991
992// //______________________________________________________________________________
993// void TGTable::InsertRowAt(UInt_t row, UInt_t nrows)
994// {
995// }
996
997// //______________________________________________________________________________
998// void TGTable::InsertRowAt(TGString label, UInt_t nrows)
999// {
1000// }
1001
1002// //______________________________________________________________________________
1003// void TGTable::InsertColumnBefore(UInt_t column, UInt_t ncolumns)
1004// {
1005// }
1006
1007// //______________________________________________________________________________
1008// void TGTable::InsertColumnBefore(TGString label, UInt_t ncolumns)
1009// {
1010// }
1011
1012// //______________________________________________________________________________
1013// void TGTable::InsertColumnAfter(UInt_t column, UInt_t ncolumns)
1014// {
1015// }
1016
1017// //______________________________________________________________________________
1018// void TGTable::InsertColumnAfter(TGString label, UInt_t ncolumns)
1019// {
1020// }
1021
1022// //______________________________________________________________________________
1023// void TGTable::InsertColumnAt(UInt_t column, UInt_t ncolumns)
1024// {
1025// }
1026
1027// //______________________________________________________________________________
1028// void TGTable::InsertColumnAt(TGString label, UInt_t ncolumns)
1029// {
1030// }
1031
1032// //______________________________________________________________________________
1033// void TGTable::RemoveRows(UInt_t row, UInt_t nrows)
1034// {
1035// }
1036
1037// //______________________________________________________________________________
1038// void TGTable::RemoveColumns(UInt_t column, UInt_t ncolumns)
1039// {
1040// }
1041
1042////////////////////////////////////////////////////////////////////////////////
1043/// Update and layout the visible part of the TGTable.
1044
1046{
1049
1050 TGString *str = new TGString();
1051 *str += nrows;
1052 *str += "x";
1053 *str += ncolumns;
1054 *str += " Table";
1055 fTableHeader->SetLabel(str->GetString());
1056 delete str;
1057
1060
1061 UInt_t i = 0, j = 0;
1062 UInt_t k = 0, l = 0;
1063
1064 TGTableCell * cell = 0;
1065 for (i = 0; i < nrows; i++) {
1066 for (j = 0; j < ncolumns; j++) {
1067 cell = GetCell(i,j);
1068 k = fCurrentRange->fYtl + i;
1069 l = fCurrentRange->fXtl + j;
1070
1071 const char *label = fInterface->GetValueAsString(k,l);
1072 if(cell) cell->SetLabel(label);
1073 }
1074 }
1075
1076 MapSubwindows();
1077 Layout();
1078 gClient->NeedRedraw(fTableHeader);
1080 fTableFrame->DrawRegion(0, 0, vp->GetWidth(), vp->GetHeight());
1083
1085}
1086
1087////////////////////////////////////////////////////////////////////////////////
1088/// Return the amount of rows in the table.
1089
1094
1095////////////////////////////////////////////////////////////////////////////////
1096/// Return the amount of rows in the data source.
1097
1099{
1100 return fDataRange->fYbr - fDataRange->fYtl;
1101}
1102
1103////////////////////////////////////////////////////////////////////////////////
1104/// Return the amount of columns in the table.
1105
1110
1111////////////////////////////////////////////////////////////////////////////////
1112/// Return the amount of columns in the data source.
1113
1115{
1116 return fDataRange->fYbr - fDataRange->fYtl;
1117}
1118
1119////////////////////////////////////////////////////////////////////////////////
1120/// Return the amount of cells in the table.
1121
1123{
1124 return GetNTableRows() * GetNTableColumns();
1125}
1126
1127////////////////////////////////////////////////////////////////////////////////
1128/// Return the amount of cell in the data source.
1129
1131{
1132 return GetNDataRows() * GetNDataColumns();
1133}
1134
1135////////////////////////////////////////////////////////////////////////////////
1136/// Return the current range of the TGTable.
1137
1139{
1140 return fCurrentRange;
1141}
1142
1143////////////////////////////////////////////////////////////////////////////////
1144/// Const version of GetRowHeader();
1145
1147{
1148 return const_cast<TGTable *>(this)->GetRowHeader(row);
1149}
1150
1151////////////////////////////////////////////////////////////////////////////////
1152/// Return a pointer to the header of row.
1153
1155{
1156 return (TGTableHeader *)fRowHeaders->At(row);
1157}
1158
1159////////////////////////////////////////////////////////////////////////////////
1160/// Const version of GetColumnHeader();
1161
1163{
1164 return const_cast<TGTable *>(this)->GetColumnHeader(column);
1165}
1166
1167////////////////////////////////////////////////////////////////////////////////
1168/// Return a pointer to the header of column.
1169
1171{
1172 return (TGTableHeader *)fColumnHeaders->At(column);
1173}
1174
1175////////////////////////////////////////////////////////////////////////////////
1176/// Return a pointer to the table header.
1177
1182
1183// //______________________________________________________________________________
1184// const TGGC* TGTable::GetSelectGC() const
1185// {
1186// }
1187
1188// //______________________________________________________________________________
1189// const TGGC* TGTable::GetCellBckgndGC(TGTableCell *cell) const
1190// {
1191// }
1192
1193// //______________________________________________________________________________
1194// const TGGC* TGTable::GetCellBckgndGC(UInt_t row, UInt_t column) const
1195// {
1196// }
1197
1198////////////////////////////////////////////////////////////////////////////////
1199/// Get the background collor for row.
1200
1202{
1203 if (row % 2 == 0) { // Even rows
1204 return fEvenRowBackground;
1205 } else { // Odd rows
1206 return fOddRowBackground;
1207 }
1208}
1209
1210////////////////////////////////////////////////////////////////////////////////
1211/// Get the background color of headers.
1212
1217
1218////////////////////////////////////////////////////////////////////////////////
1219/// Set the background color for all odd numbered rows.
1220
1222{
1223 if(pixel == fOddRowBackground) return;
1224
1226
1229 UInt_t i = 0, j = 0;
1230 TGTableCell *cell = 0;
1231
1232 for (i = 0; i < nrows; i++) {
1233 for (j = 0; j < ncolumns; j++) {
1234 if (i % 2) {
1235 cell = GetCell(i,j);
1236 if (cell) cell->SetBackgroundColor(fOddRowBackground);
1237 }
1238 }
1239 }
1240
1244}
1245
1246////////////////////////////////////////////////////////////////////////////////
1247/// Set the background color for all even numbered rows.
1248
1250{
1251 if(pixel == fEvenRowBackground) return;
1252
1254
1257 UInt_t i = 0, j = 0;
1258 TGTableCell *cell = 0;
1259
1260 for (i = 0; i < nrows; i++) {
1261 for (j = 0; j < ncolumns; j++) {
1262 if (!(i % 2)) {
1263 cell = GetCell(i,j);
1264 if (cell) cell->SetBackgroundColor(fEvenRowBackground);
1265 }
1266 }
1267 }
1271}
1272
1273////////////////////////////////////////////////////////////////////////////////
1274/// Set the background color for the headers.
1275
1277{
1278 if(pixel == fHeaderBackground) return;
1279
1281
1284 UInt_t i = 0, j = 0;
1285 TGTableHeader *hdr = 0;
1286
1287 for (i = 0; i < nrows; i++) {
1288 hdr = GetRowHeader(i);
1289 if (hdr) hdr->SetBackgroundColor(fHeaderBackground);
1290 }
1294
1295 for (j = 0; j < ncolumns; j++) {
1297 if (hdr) hdr->SetBackgroundColor(fHeaderBackground);
1298// gClient->NeedRedraw(hdr);
1299 }
1303}
1304
1305////////////////////////////////////////////////////////////////////////////////
1306/// Set the background color for all rows and headers to their defaults.
1307
1314
1315////////////////////////////////////////////////////////////////////////////////
1316/// Move and layout the table to the specified range.
1317
1329
1330////////////////////////////////////////////////////////////////////////////////
1331/// Move and resize the table to the specified range.
1332
1334{
1335 if (fAllData) return;
1336
1337 if(xtl == xbr || ytl == ybr) {
1338 Error("TGTable::GotoTableRange","x or y range = 0");
1339 return;
1340 }
1341
1342 Int_t nrows = std::abs(ybr - ytl);
1343 Int_t ncolumns = std::abs(xbr - xtl);
1344
1345 if (xtl > xbr) {
1346 Info("TGTable::GotoTableRange","Swapping x-range boundries");
1347 Int_t temp = xtl;
1348 xtl = xbr;
1349 xbr = temp;
1350 }
1351 if (ytl > ybr) {
1352 Info("TGTable::GotoTableRange","Swapping y-range boundries");
1353 Int_t temp = ytl;
1354 ytl = ybr;
1355 ybr = temp;
1356 }
1357
1358 if((xtl < 0) || (xbr < 0)) {
1359 Info("TGTable::GotoTableRange", "Column boundry out of bounds, adjusting");
1360 xtl = 0;
1361 xbr = ncolumns;
1362 if (xbr > (Int_t)fDataRange->fXbr) {
1363 xbr = fDataRange->fXbr;
1364 ncolumns = std::abs(xbr - xtl);
1365 }
1366 }
1367
1368 if((ytl < 0) || (ybr < 0)) {
1369 Info("TGTable::GotoTableRange", "Row boundry out of bounds, adjusting");
1370 ytl = 0;
1371 ybr = nrows;
1372 if (ybr > (Int_t)fDataRange->fYbr) {
1373 ybr = fDataRange->fYbr;
1374 nrows = std::abs(ybr - ytl);
1375 }
1376 }
1377
1378 if((xtl > (Int_t)fDataRange->fXbr) || (xbr > (Int_t)fDataRange->fXbr)) {
1379 Info("TGTable::GotoTableRange", "Left Column boundry out of bounds, "
1380 "adjusting");
1381 xbr = fDataRange->fXbr;
1382 xtl = xbr - ncolumns;
1383 if (xtl < 0) {
1384 xtl = 0;
1385 Info("TGTable::GotoTableRange", "Right column boundry out of"
1386 " bounds, set to 0");
1387 }
1388 }
1389 if ((ytl > (Int_t)fDataRange->fYbr) || (ybr > (Int_t)fDataRange->fYbr)) {
1390 Info("TGTable::GotoTableRange", "Bottom row boundry out of bounds, "
1391 "adjusting");
1392 ybr = fDataRange->fYbr;
1393 ytl = ybr - nrows;
1394 if (ytl < 0) {
1395 ytl = 0;
1396 nrows = ybr - ytl;
1397 Info("TGTable::GotoTableRange", "Top row boundry out of bounds, "
1398 "set to 0");
1399 }
1400 }
1401
1402 nrows = std::abs(ybr - ytl);
1403 ncolumns = std::abs(xbr - xtl);
1404
1405 // Resize rows and columns if needed
1407
1412
1413 // Update the table view.
1414 UpdateView();
1415}
1416
1417////////////////////////////////////////////////////////////////////////////////
1418/// Operator for easy cell acces.
1419
1421{
1422 return GetCell(row, column);
1423}
1424
1425////////////////////////////////////////////////////////////////////////////////
1426/// Scroll the column headers horizontally.
1427
1429{
1430 if (!fCHdrFrame) return;
1431
1432 fCHdrFrame->Move(- xpos, 0);
1433 fCHdrFrame->Resize();
1436}
1437
1438////////////////////////////////////////////////////////////////////////////////
1439/// Scroll the row headers vertically
1440
1442{
1443 if (!fRHdrFrame) return;
1444
1446 fRHdrFrame->Resize();
1449}
1450
1451////////////////////////////////////////////////////////////////////////////////
1452/// Move the table to the next chunk of the data set with the same size.
1453
1455{
1458}
1459
1460////////////////////////////////////////////////////////////////////////////////
1461/// Move the table to the previous chunk of the data set with the same size.
1462
1464{
1465 MoveTable(-1 * (Int_t)GetNTableRows(), 0);
1467}
1468
1469////////////////////////////////////////////////////////////////////////////////
1470/// Slot used by the Goto button and whenever return is pressed in
1471/// on of the text entries in the range frame.
1472
1481
1482////////////////////////////////////////////////////////////////////////////////
1483/// Slot used when the text in one of the range frame text entries changes.
1484
1486{
1488 if(!topleft.Contains(",")) return;
1489
1490 Int_t pos = topleft.First(',');
1491 TString itl = topleft(0,pos);
1492 TString jtl = topleft(pos+1, topleft.Length());
1493
1494 if (itl.Contains(' ') || itl.Contains('\t') ||
1495 jtl.Contains(' ') || jtl.Contains('\t')) return;
1496
1497 if (!itl.IsAlnum() || !jtl.IsAlnum()) return;
1498
1499 fGotoRange->fXtl = jtl.Atoi();
1500 fGotoRange->fYtl = itl.Atoi();
1501
1503 if(!range.Contains("x")) return;
1504
1505 pos = range.First('x');
1506 TString ir = range(0,pos);
1507 TString jr = range(pos+1, range.Length());
1508
1509 if (ir.Contains(' ') || ir.Contains('\t') ||
1510 jr.Contains(' ') || jr.Contains('\t')) return;
1511 if (!ir.IsAlnum() || !jr.IsAlnum()) return;
1512
1513 fGotoRange->fXbr = jtl.Atoi() + jr.Atoi();
1514 fGotoRange->fYbr = itl.Atoi() + ir.Atoi();
1515
1516 if (*fGotoRange == *fCurrentRange) {
1518 } else {
1520 }
1521
1522}
1523
1524////////////////////////////////////////////////////////////////////////////////
1525/// Update the range of the available data and refresh the current view.
1526
1537
1538////////////////////////////////////////////////////////////////////////////////
1539/// TTableRange constuctor.
1540
1541TTableRange::TTableRange() : fXtl(0), fYtl(0), fXbr(0), fYbr(0)
1542{
1543}
1544
1545////////////////////////////////////////////////////////////////////////////////
1546/// Print the values of a range.
1547
1549{
1550 std::cout << "Range = (" << fXtl << "," << fYtl << ")->("
1551 << fXbr << "," << fYbr << ")" << std::endl;
1552}
1553
1554////////////////////////////////////////////////////////////////////////////////
1555/// Operator to determine if 2 ranges are equal
1556
1558{
1559 if ((fXtl == other.fXtl) && (fYtl == other.fYtl) &&
1560 (fXbr == other.fXbr) && (fYbr == other.fYbr)) {
1561 return kTRUE;
1562 } else {
1563 return kFALSE;
1564 }
1565}
@ kVerticalFrame
Definition GuiTypes.h:381
@ kFixedWidth
Definition GuiTypes.h:387
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
#define d(i)
Definition RSha256.hxx:102
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition TError.cxx:241
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:208
@ kButtonDisabled
Definition TGButton.h:56
@ kButtonUp
Definition TGButton.h:53
#define gClient
Definition TGClient.h:157
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterY
Definition TGLayout.h:28
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
EHeaderType
@ kColumnHeader
@ kRowHeader
@ kTableHeader
@ kTextRight
Definition TGWidget.h:24
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 width
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
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
static ULong_t RGB2Pixel(Int_t r, Int_t g, Int_t b)
Convert r,g,b to graphics system dependent pixel value.
Definition TColor.cxx:2483
virtual EButtonState GetState() const
Definition TGButton.h:112
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition TGButton.cxx:229
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
Definition TGCanvas.h:192
virtual void SetContainer(TGFrame *f)
Definition TGCanvas.h:222
TGFrame * GetContainer() const
Definition TGCanvas.h:216
TGVScrollBar * GetVScrollbar() const
Definition TGCanvas.h:219
TGViewPort * GetViewPort() const
Definition TGCanvas.h:217
void MapSubwindows() override
Map all canvas sub windows.
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Adding a frame to a canvas is actually adding the frame to the viewport container.
void Layout() override
Create layout for canvas.
TGHScrollBar * GetHScrollbar() const
Definition TGCanvas.h:218
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1156
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1249
virtual void RemoveAll()
Remove all frames from composite frame.
Definition TGFrame.cxx:1123
void ChangeOptions(UInt_t options) override
Change composite frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:1035
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:701
UInt_t fHeight
frame height
Definition TGFrame.h:88
void SetBackgroundColor(Pixel_t back) override
Set background color (override from TGWindow base class).
Definition TGFrame.cxx:304
void Move(Int_t x, Int_t y) override
Move frame.
Definition TGFrame.cxx:585
Int_t GetX() const
Definition TGFrame.h:233
virtual UInt_t GetOptions() const
Definition TGFrame.h:199
UInt_t fWidth
frame width
Definition TGFrame.h:87
UInt_t GetHeight() const
Definition TGFrame.h:227
virtual void SetWidth(UInt_t w)
Definition TGFrame.h:248
UInt_t GetWidth() const
Definition TGFrame.h:226
Pixel_t fBackground
frame background color
Definition TGFrame.h:95
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:387
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
This layout managers does not make use of TGLayoutHints.
Definition TGLayout.h:269
The classes in this file implement scrollbars.
Definition TGScrollBar.h:61
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
virtual UInt_t GetWidth() const
Definition TGTableCell.h:93
virtual UInt_t GetHeight() const
Definition TGTableCell.h:94
TGTableFrame contains a composite frame that uses a TGMatrixLayout to Layout the frames it contains.
void SetCanvas(TGCanvas *canvas)
TGFrame * GetFrame() const
virtual void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
Draw a region of container in viewport.
TGTableHeaderFrame implements a frame used to display TGTableHeaders in a TGTable.
virtual void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
Draw a region of container in viewport.
TGTableHeader is the class that implements a header for a row or column.
void SetLabel(const char *label) override
Set the label of the TGTableHeader to label.
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:1428
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:535
virtual UInt_t GetNDataColumns() const
Return the amount of columns in the data source.
Definition TGTable.cxx:1114
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:1485
virtual const TGTableHeader * GetColumnHeader(const UInt_t column) const
Const version of GetColumnHeader();.
Definition TGTable.cxx:1162
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 TObjArray * GetRow(UInt_t row)
Get row.
Definition TGTable.cxx:791
virtual void Init()
Initialise the TGTable.
Definition TGTable.cxx:218
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:668
virtual void Update()
Update the range of the available data and refresh the current view.
Definition TGTable.cxx:1527
virtual void SetEvenRowBackground(Pixel_t pixel)
Set the background color for all even numbered rows.
Definition TGTable.cxx:1249
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:1420
virtual TGTableHeader * GetTableHeader()
Return a pointer to the table header.
Definition TGTable.cxx:1178
virtual const TGTableHeader * GetRowHeader(const UInt_t row) const
Const version of GetRowHeader();.
Definition TGTable.cxx:1146
virtual TObjArray * GetColumn(UInt_t columns)
Return a pointer to a TObjArray that contains pointers to all the cells in column.
Definition TGTable.cxx:803
virtual UInt_t GetNDataCells() const
Return the amount of cell in the data source.
Definition TGTable.cxx:1130
virtual const TGTableCell * FindCell(TGString label) const
Const version of FindCell().
Definition TGTable.cxx:899
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:597
virtual Pixel_t GetRowBackground(UInt_t row) const
Get the background collor for row.
Definition TGTable.cxx:1201
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:1221
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:1473
virtual UInt_t GetNTableRows() const
Return the amount of rows in the table.
Definition TGTable.cxx:1090
TObjArray * fRows
Array of rows.
Definition TGTable.h:37
virtual Pixel_t GetHeaderBackground() const
Get the background color of headers.
Definition TGTable.cxx:1213
virtual UInt_t GetNDataRows() const
Return the amount of rows in the data source.
Definition TGTable.cxx:1098
TObjArray * fColumnHeaders
Array of column headers.
Definition TGTable.h:39
void DoRedraw() override
Redraw the TGTable.
Definition TGTable.cxx:416
virtual void SetHeaderBackground(Pixel_t pixel)
Set the background color for the headers.
Definition TGTable.cxx:1276
virtual void UpdateRangeFrame()
Update the range shown in the range frame.
Definition TGTable.cxx:770
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:1106
virtual UInt_t GetNTableCells() const
Return the amount of cells in the table.
Definition TGTable.cxx:1122
virtual void UpdateHeaders(EHeaderType type)
Update the labels of the headers of the given type.
Definition TGTable.cxx:645
TList * fCHdrHintsList
Definition TGTable.h:93
virtual void ShrinkColumns(UInt_t ncolumns)
Shrink the columns of the TGTable by ncolumns.
Definition TGTable.cxx:544
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:509
~TGTable() override
TGTable destructor.
Definition TGTable.cxx:188
virtual UInt_t GetRHdrHeight() const
Get the current height of the row header frame.
Definition TGTable.cxx:522
TList * fRHdrHintsList
Definition TGTable.h:92
virtual void ExpandRows(UInt_t nrows)
Expand the rows of a TGTable by nrows.
Definition TGTable.cxx:473
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:1308
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:1463
virtual const TTableRange * GetCurrentRange() const
Return the current range of the TGTable.
Definition TGTable.cxx:1138
virtual void NextChunk()
Move the table to the next chunk of the data set with the same size.
Definition TGTable.cxx:1454
TGTextEntry * fFirstCellEntry
TextEntry for the range frame.
Definition TGTable.h:76
TGCanvas * fCanvas
Canvas that will contains the cells.
Definition TGTable.h:49
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:1333
virtual void MoveTable(Int_t rows, Int_t columns)
Move and layout the table to the specified range.
Definition TGTable.cxx:1318
virtual void Show()
Show the contents of the TGTable in stdout.
Definition TGTable.cxx:930
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:877
virtual void ScrollRHeaders(Int_t ypos)
Scroll the row headers vertically.
Definition TGTable.cxx:1441
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:707
virtual void UpdateView()
Update and layout the visible part of the TGTable.
Definition TGTable.cxx:1045
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:434
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
TGTable(const TGWindow *p=nullptr, Int_t id=0, TVirtualTableInterface *interface=nullptr, UInt_t nrows=50, UInt_t ncolumns=20)
TGTable constuctor.
Definition TGTable.cxx:153
virtual void Expand(UInt_t nrows, UInt_t ncolumns)
Expand a TGTable by nrows and ncolumns.
Definition TGTable.cxx:425
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
const char * GetText() const
virtual void SetAlignment(ETextJustification mode=kTextLeft)
Sets the alignment of the text entry.
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Sets text entry to text, clears the selection and moves the cursor to the end of the line.
The widget base class.
Definition TGWidget.h:43
Int_t WidgetId() const
Definition TGWidget.h:68
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual void SetWindowName(const char *name=nullptr)
Set window name.
Definition TGWindow.cxx:127
A doubly linked list.
Definition TList.h:38
void Add(TObject *obj) override
Definition TList.h:81
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:467
An array of TObjects.
Definition TObjArray.h:31
virtual void Expand(Int_t newSize)
Expand or shrink the array to newSize elements.
void AddAt(TObject *obj, Int_t idx) override
Add object at position ids.
TObject * At(Int_t idx) const override
Definition TObjArray.h:164
TObject * RemoveAt(Int_t idx) override
Remove object at index idx.
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition TQObject.cxx:865
Basic string class.
Definition TString.h:138
virtual void Print()
Print the values of a range.
Definition TGTable.cxx:1548
Bool_t operator==(TTableRange &other)
Operator to determine if 2 ranges are equal.
Definition TGTable.cxx:1557
TTableRange()
TTableRange constuctor.
Definition TGTable.cxx:1541
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
UInt_t fYtl
Top left Y coordinate.
Definition TGTable.h:238
virtual UInt_t GetNRows()=0
virtual const char * GetValueAsString(UInt_t row, UInt_t column)=0
virtual const char * GetColumnHeader(UInt_t column)=0
virtual UInt_t GetNColumns()=0
virtual const char * GetRowHeader(UInt_t row)=0
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
TLine l
Definition textangle.C:4