00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <iostream>
00014 #include <TApplication.h>
00015 #include <TGClient.h>
00016 #include <TGButton.h>
00017 #include <TGFrame.h>
00018 #include <TGLayout.h>
00019 #include <TGWindow.h>
00020 #include <TGLabel.h>
00021 #include <TGNumberEntry.h>
00022 #include <TString.h>
00023 #include <TGButtonGroup.h>
00024 #include <TGMenu.h>
00025 #include <TGSimpleTable.h>
00026
00027
00028
00029 class IDList {
00030 private:
00031 Int_t nID ;
00032 public:
00033 IDList() : nID(0) {}
00034 ~IDList() {}
00035 Int_t GetUnID(void) { return ++nID ; }
00036 } ;
00037
00038 class TableTest : public TGMainFrame {
00039
00040 private:
00041 IDList IDs ;
00042 Double_t **fData;
00043 UInt_t fNDataRows;
00044 UInt_t fNDataColumns;
00045 UInt_t fNTableRows;
00046 UInt_t fNTableColumns;
00047 TGSimpleTable *fSimpleTable;
00048
00049 public:
00050 TableTest(const TGWindow *p, UInt_t ndrows, UInt_t ndcols,
00051 UInt_t ntrows, UInt_t ntcols, UInt_t w = 100, UInt_t h = 100) ;
00052 virtual ~TableTest() ;
00053
00054 void DoExit() ;
00055
00056 TGSimpleTable *GetTable() { return fSimpleTable; }
00057
00058 ClassDef(TableTest, 0)
00059 };
00060
00061 TableTest::TableTest(const TGWindow *p, UInt_t ndrows, UInt_t ndcols,
00062 UInt_t ntrows, UInt_t ntcols, UInt_t w, UInt_t h)
00063 : TGMainFrame(p, w, h), fData(0), fNDataRows(ndrows), fNDataColumns(ndcols),
00064 fNTableRows(ntrows), fNTableColumns(ntcols), fSimpleTable(0)
00065 {
00066 SetCleanup(kDeepCleanup) ;
00067 Connect("CloseWindow()", "TableTest", this, "DoExit()") ;
00068 DontCallClose() ;
00069
00070
00071 Int_t i = 0, j = 0;
00072 fData = new Double_t*[fNDataRows];
00073 for (i = 0; i < (Int_t)fNDataRows; i++) {
00074 fData[i] = new Double_t[fNDataColumns];
00075 for (j = 0; j < (Int_t)fNDataColumns; j++) {
00076 fData[i][j] = 10 * i + j;
00077 }
00078 }
00079
00080
00081 fSimpleTable = new TGSimpleTable(this, IDs.GetUnID(), fData, fNTableRows,
00082 fNTableColumns);
00083 AddFrame(fSimpleTable, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
00084
00085
00086 SetWindowName("TGSimpleTable Test") ;
00087 MapSubwindows() ;
00088 Layout();
00089 Resize(GetDefaultWidth()+20, 600) ;
00090 MapWindow() ;
00091
00092 } ;
00093
00094 TableTest::~TableTest()
00095 {
00096
00097 UInt_t i = 0;
00098 for (i = 0; i < fNDataRows; i++) {
00099 delete[] fData[i];
00100 }
00101 delete[] fData;
00102 Cleanup() ;
00103 }
00104
00105 void TableTest::DoExit()
00106 {
00107
00108
00109
00110
00111
00112 DeleteWindow();
00113
00114 }
00115
00116 TGSimpleTable *simpleTableTest(UInt_t ndrows = 500, UInt_t ndcols = 20,
00117 UInt_t ntrows = 50, UInt_t ntcols = 10) {
00118 TableTest *test = new TableTest(0, ndrows, ndcols, ntrows, ntcols, 500, 200);
00119 return test->GetTable();
00120 }