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