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