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