Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGSimpleTableInterface.cxx
Go to the documentation of this file.
1// Author: Roel Aaij 15/08/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
12#include "TGResourcePool.h"
13#include "TError.h"
14
15
16
17/** \class TGSimpleTableInterface
18 \ingroup guiwidgets
19
20TGSimpleTableInterface is a very simple implementation of a
21TVirtualTableInterface. This interface provides a TGTable with data
22from a two dimensional array of doubles in memory. It is mostly
23meant as an example implementation for a TVirtualTableInterface.
24
25*/
26
27
28////////////////////////////////////////////////////////////////////////////////
29/// TGSimpleTableInterface constructor.
30
36
37////////////////////////////////////////////////////////////////////////////////
38/// TGSimpleTableInterface destructor.
39
43
44////////////////////////////////////////////////////////////////////////////////
45/// Return the value of the double in row,column of the data.
46
48{
49 if ((row > fNRows) || (column > fNColumns)) {
50 Error("TGSimpleTableInterface","Non existing value requested.");
51 return 0;
52 }
53 if (fData == nullptr) {
54 Error("TGSimpleTableInterface","Non existing table data.");
55 return 0;
56 }
57 return fData[row][column];
58}
59
60////////////////////////////////////////////////////////////////////////////////
61/// Return the value of the double in row,column of the data as a string.
62
64{
65 // FIXME use template string for string format instead of hardcoded format
66
67 fBuffer.Form("%5.2f", GetValue(row, column));
68 return fBuffer.Data();
69}
70
71////////////////////////////////////////////////////////////////////////////////
72/// Return a name for the header at row.
73
75{
76 fBuffer.Form("DRow %d", row);
77 return fBuffer.Data();
78}
79
80////////////////////////////////////////////////////////////////////////////////
81/// Return a name for the header at column.
82
84{
85 fBuffer.Form("DCol %d", column);
86 return fBuffer.Data();
87}
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:208
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
const char * GetValueAsString(UInt_t row, UInt_t column) override
Return the value of the double in row,column of the data as a string.
TGSimpleTableInterface(Double_t **data, UInt_t nrows=2, UInt_t ncolumns=2)
TGSimpleTableInterface constructor.
Double_t GetValue(UInt_t row, UInt_t column) override
Return the value of the double in row,column of the data.
const char * GetRowHeader(UInt_t row) override
Return a name for the header at row.
~TGSimpleTableInterface() override
TGSimpleTableInterface destructor.
const char * GetColumnHeader(UInt_t column) override
Return a name for the header at column.
const char * Data() const
Definition TString.h:384
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2362