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