This TableTest class is a simple example of how to use a TGSimpleTable that creates and owns it's own TGSimpleTableInterface.
TableTest inherits from TGMainFrame to create a top level frame to embed the TGTable in. First the data needed is created. Then the TGSimpleTable is created using this data. In the end, the table is added to the TGMainFrame that is the TableTest and the necessary calls to correctly draw the window are made. For more information about the use of TGSimpleTable see it's documentation.
#include <iostream>
class IDList {
private:
public:
IDList() : nID(0) {}
~IDList() {}
Int_t GetUnID(
void) {
return ++nID ; }
} ;
private:
IDList IDs ;
public:
virtual ~TableTest() ;
void DoExit() ;
};
:
TGMainFrame(p, w,
h), fData(0), fNDataRows(ndrows), fNDataColumns(ndcols),
fNTableRows(ntrows), fNTableColumns(ntcols), fSimpleTable(0)
{
Connect("CloseWindow()", "TableTest", this, "DoExit()") ;
DontCallClose() ;
for (i = 0; i < (
Int_t)fNDataRows; i++) {
for (j = 0; j < (
Int_t)fNDataColumns; j++) {
fData[i][j] = 10 * i + j;
}
}
fSimpleTable =
new TGSimpleTable(
this, IDs.GetUnID(), fData, fNTableRows,
fNTableColumns);
SetWindowName("TGSimpleTable Test") ;
MapSubwindows() ;
Resize(GetDefaultWidth()+20, 600) ;
MapWindow() ;
} ;
TableTest::~TableTest()
{
for (i = 0; i < fNDataRows; i++) {
delete[] fData[i];
}
delete[] fData;
Cleanup() ;
}
void TableTest::DoExit()
{
DeleteWindow();
}
TableTest *
test =
new TableTest(0, ndrows, ndcols, ntrows, ntcols, 500, 200);
}
#define ClassDef(name, id)
RooCmdArg Layout(Double_t xmin, Double_t xmax=0.99, Double_t ymin=0.95)
- Author
- Roel Aaij 13/07/2007
Definition in file simpleTableTest.C.