ROOT
Version v6.34
master
v6.32
v6.30
v6.28
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
Reference Guide
►
ROOT
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
simpleTableTest.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_gui
3
/// This TableTest class is a simple example of how to use a TGSimpleTable that creates and owns it's own TGSimpleTableInterface.
4
/// TableTest inherits from TGMainFrame to create a top level frame to embed the TGTable in.
5
/// First the data needed is created. Then the TGSimpleTable is created using this data.
6
/// 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.
7
/// For more information about the use of TGSimpleTable see it's documentation.
8
///
9
/// \macro_code
10
///
11
/// \author Roel Aaij 13/07/2007
12
13
#include <iostream>
14
#include <
TApplication.h
>
15
#include <
TGClient.h
>
16
#include <
TGButton.h
>
17
#include <
TGFrame.h
>
18
#include <
TGLayout.h
>
19
#include <
TGWindow.h
>
20
#include <
TGLabel.h
>
21
#include <
TGNumberEntry.h
>
22
#include <
TString.h
>
23
#include <
TGButtonGroup.h
>
24
#include <
TGMenu.h
>
25
#include <
TGSimpleTable.h
>
26
27
// A little class to automatically handle the generation of unique
28
// widget ids.
29
class
IDList
{
30
private
:
31
Int_t
nID
;
// Generates unique widget IDs.
32
public
:
33
IDList
() :
nID
(0) {}
34
~IDList
() {}
35
Int_t
GetUnID
(
void
) {
return
++
nID
; }
36
} ;
37
38
class
TableTest
:
public
TGMainFrame
{
39
40
private
:
41
IDList
IDs
;
// Generator for unique widget IDs.
42
Double_t
**fData;
43
UInt_t
fNDataRows
;
44
UInt_t
fNDataColumns
;
45
UInt_t
fNTableRows
;
46
UInt_t
fNTableColumns
;
47
TGSimpleTable
*
fSimpleTable
;
48
49
public
:
50
TableTest
(
const
TGWindow
*
p
,
UInt_t
ndrows
,
UInt_t
ndcols
,
51
UInt_t
ntrows
,
UInt_t
ntcols
,
UInt_t
w
= 100,
UInt_t
h
= 100) ;
52
~TableTest
()
override
;
53
54
void
DoExit() ;
55
56
TGSimpleTable
*GetTable() {
return
fSimpleTable
; }
57
58
ClassDefOverride
(
TableTest
, 0)
59
};
60
61
TableTest::TableTest(
const
TGWindow
*
p
,
UInt_t
ndrows
,
UInt_t
ndcols
,
62
UInt_t
ntrows
,
UInt_t
ntcols
,
UInt_t
w
,
UInt_t
h
)
63
:
TGMainFrame
(
p
,
w
,
h
), fData(nullptr),
fNDataRows
(
ndrows
),
fNDataColumns
(
ndcols
),
64
fNTableRows
(
ntrows
),
fNTableColumns
(
ntcols
),
fSimpleTable
(nullptr)
65
{
66
SetCleanup(
kDeepCleanup
) ;
67
Connect(
"CloseWindow()"
,
"TableTest"
,
this
,
"DoExit()"
) ;
68
DontCallClose() ;
69
70
// Create the needed data.
71
Int_t
i = 0,
j
= 0;
72
fData =
new
Double_t
*[
fNDataRows
];
73
for
(i = 0; i < (
Int_t
)
fNDataRows
; i++) {
74
fData[i] =
new
Double_t
[
fNDataColumns
];
75
for
(
j
= 0;
j
< (
Int_t
)
fNDataColumns
;
j
++) {
76
fData[i][
j
] = 10 * i +
j
;
77
}
78
}
79
80
// Create the table and add it to the TableTest that is a TGMainFrame.
81
fSimpleTable
=
new
TGSimpleTable
(
this
,
IDs
.GetUnID(), fData,
fNTableRows
,
82
fNTableColumns
);
83
AddFrame(
fSimpleTable
,
new
TGLayoutHints
(
kLHintsExpandX
|
kLHintsExpandY
));
84
85
// Calls to layout and draw the TableTest that is a TGMainFrame.
86
SetWindowName(
"TGSimpleTable Test"
) ;
87
MapSubwindows
() ;
88
Layout
();
89
Resize(GetDefaultWidth()+20, 600) ;
90
MapWindow() ;
91
92
} ;
93
94
TableTest::~TableTest()
95
{
96
// Destructor
97
UInt_t
i = 0;
98
for
(i = 0; i <
fNDataRows
; i++) {
99
delete
[] fData[i];
100
}
101
delete
[] fData;
102
Cleanup() ;
103
}
104
105
void
TableTest::DoExit()
106
{
107
// Exit this application via the Exit button or Window Manager.
108
// Use one of the both lines according to your needs.
109
// Please note to re-run this macro in the same ROOT session,
110
// you have to compile it to get signals/slots 'on place'.
111
112
DeleteWindow();
// to stay in the ROOT session
113
// gApplication->Terminate(); // to exit and close the ROOT session
114
}
115
116
TGSimpleTable
*
simpleTableTest
(
UInt_t
ndrows
= 500,
UInt_t
ndcols
= 20,
117
UInt_t
ntrows
= 50,
UInt_t
ntcols
= 10) {
118
TableTest
*
test
=
new
TableTest
(
nullptr
,
ndrows
,
ndcols
,
ntrows
,
ntcols
, 500, 200);
119
return
test
->GetTable();
120
}
h
#define h(i)
Definition
RSha256.hxx:106
Int_t
int Int_t
Definition
RtypesCore.h:45
UInt_t
unsigned int UInt_t
Definition
RtypesCore.h:46
Double_t
double Double_t
Definition
RtypesCore.h:59
ClassDefOverride
#define ClassDefOverride(name, id)
Definition
Rtypes.h:346
TApplication.h
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
TGButtonGroup.h
TGButton.h
TGClient.h
TGFrame.h
kDeepCleanup
@ kDeepCleanup
Definition
TGFrame.h:42
TGLabel.h
TGLayout.h
kLHintsExpandY
@ kLHintsExpandY
Definition
TGLayout.h:31
kLHintsExpandX
@ kLHintsExpandX
Definition
TGLayout.h:30
TGMenu.h
TGNumberEntry.h
TGSimpleTable.h
w
winID w
Definition
TGWin32VirtualGLProxy.cxx:39
p
winID h TVirtualViewer3D TVirtualGLPainter p
Definition
TGWin32VirtualGLProxy.cxx:51
MapSubwindows
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize MapSubwindows
Definition
TGWin32VirtualXProxy.cxx:94
TGWindow.h
TString.h
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TGLayoutHints
This class describes layout hints used by the layout classes.
Definition
TGLayout.h:50
TGMainFrame
Defines top level windows that interact with the system Window Manager.
Definition
TGFrame.h:397
TGSimpleTable
To provide a simple class to visualize an array of doubles, the class TGSimpleTable is provided.
Definition
TGSimpleTable.h:16
TGWindow
ROOT GUI Window base class.
Definition
TGWindow.h:23
RooFit::Layout
RooCmdArg Layout(double xmin, double xmax=0.99, double ymin=0.95)
Definition
RooGlobalFunc.cxx:783
tutorials
gui
simpleTableTest.C
ROOT v6-34 - Reference Guide Generated on Sun Mar 30 2025 16:27:33 (GVA Time) using Doxygen 1.10.0