Logo ROOT   6.18/05
Reference Guide
TGTableHeader.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 "TGTableCell.h"
12#include "TClass.h"
13#include "TGWindow.h"
14#include "TGResourcePool.h"
15#include "Riostream.h"
16#include "TSystem.h"
17#include "TImage.h"
18#include "TEnv.h"
19#include "TGToolTip.h"
20#include "TGWidget.h"
21#include "TGPicture.h"
22#include "TGTable.h"
23#include "TRandom3.h"
24
26
27//////////////////////////////////////////////////////////////////////////
28// //
29// TGTableHeader //
30// //
31// TGTableHeader is the class that implements a header for a row or //
32// column. Interactivity on a per column or row basis is implemented //
33// using this header. //
34// //
35// TGTableHeader is for internal use in TGTable only. //
36// //
37//////////////////////////////////////////////////////////////////////////
38
39////////////////////////////////////////////////////////////////////////////////
40/// TGTableHeader constuctor.
41
44 UInt_t height, GContext_t norm, FontStruct_t font,
45 UInt_t option)
46 : TGTableCell(p, table, label, 0, 0, width, height, norm, font, option,
47 kFALSE), fType(type), fReadOnly(kFALSE), fEnabled(kTRUE),
48 fHasOwnLabel(kFALSE)
49{
50 if (type == kColumnHeader) {
51 fWidth = (table) ? table->GetTableHeader()->GetWidth() : 80;
52 fHeight = 25;
53 fRow = 0;
54 fColumn = position;
55 } else if (type == kRowHeader) {
56 fWidth = 80;
57 fHeight = (table) ? table->GetTableHeader()->GetHeight() : 25;
58 fRow = position;
59 fColumn = 0;
60 } else {
61 fWidth = 80;
62 fHeight = 25;
63 }
64
65 if (!label) {
67 } else {
69 }
70
71 Init();
72}
73
74////////////////////////////////////////////////////////////////////////////////
75/// TGTableHeader constuctor.
76
78 const char *label, UInt_t position,
80 GContext_t norm, FontStruct_t font, UInt_t option)
81 : TGTableCell(p, table, label, 0, 0, width, height, norm, font,
82 option, kFALSE), fType(type), fReadOnly(kFALSE), fEnabled(kTRUE),
83 fHasOwnLabel(kFALSE)
84{
85 if (type == kColumnHeader) {
86 fWidth = table->GetTableHeader()->GetWidth();
87 fHeight = 25;
88 fRow = 0;
89 fColumn = position;
90 } else if (type == kRowHeader) {
91 fWidth = 80;
92 fHeight = table->GetTableHeader()->GetHeight();
93 fRow = position;
94 fColumn = 0;
95 } else {
96 fWidth = 80;
97 fHeight = 25;
98 }
99
100 if (!label) {
102 } else {
104 }
105
106 Init();
107}
108
109
110////////////////////////////////////////////////////////////////////////////////
111/// TGTableHeader destructor.
112
114{
115}
116
117////////////////////////////////////////////////////////////////////////////////
118/// Initialize the TGTableHeader
119
121{
122 if (fType == kTableHeader) {
124 } else {
126 }
127
129
130 Int_t max_ascent = 0, max_descent = 0;
131
133 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
134 fTHeight = max_ascent + max_descent;
135
136}
137
138////////////////////////////////////////////////////////////////////////////////
139/// Resize the TGTableHeader.
140
142{
144}
145
146////////////////////////////////////////////////////////////////////////////////
147/// Resize the TGTableHeader.
148
150{
151 Resize(GetDefaultWidth(), height);
152}
153
154////////////////////////////////////////////////////////////////////////////////
155/// Set the label of the TGTableHeader to label.
156
157void TGTableHeader::SetLabel(const char *label)
158{
159 if(label) {
161 } else {
163 }
164}
165
166////////////////////////////////////////////////////////////////////////////////
167/// Set the label of the TGTableHeader to the default label, "Row #"
168/// or "Col #".
169
171{
173 if (fLabel) delete fLabel;
174 fLabel = new TGString();
175 if (fType == kRowHeader) {
176 *fLabel += "Row ";
177 *fLabel += fRow;
178 } else if (fType == kColumnHeader) {
179 *fLabel += "Col ";
180 *fLabel += fColumn;
181 } else {
183 *fLabel += "x";
185 *fLabel += " Table";
186 }
187}
188
189////////////////////////////////////////////////////////////////////////////////
190/// Set the position of the TGTableHeader to pos.
191
193{
194 // Verify functionality
195
196 if (fType == kRowHeader) {
197 fRow = pos;
198 fColumn = 0;
199 } else if (fType == kColumnHeader) {
200 fRow = 0;
201 fColumn = pos;
202 } else {
203 fRow = 0;
204 fColumn = 0;
205 }
206}
207
208////////////////////////////////////////////////////////////////////////////////
209/// Resize the TGTableHeader.
210
212{
213 Resize(newsize.fWidth, newsize.fHeight);
214}
215
216////////////////////////////////////////////////////////////////////////////////
217/// Resize the TGTableHeader.
218
220{
221 // Implementation of resizing of an entire row of columns probably goes here.
222 TGTableCell::Resize(width, height);
223}
224
225////////////////////////////////////////////////////////////////////////////////
226/// Sort the contents of this row or column in given order.
227
229{
230 // Note: not implemented yet.
231
232 if (order == kSortAscending) {
233 } else {
234 }
235}
236
237////////////////////////////////////////////////////////////////////////////////
238/// Update the positon of the TGTableHeader.
239
241{
242 // Verify functionality. If rows are inserted or removed, internal
243 // column numbers are no longer consistent.
244
245 UInt_t nhdr = 0;
246 if (fType == kColumnHeader) {
247 while(fTable->GetColumnHeader(nhdr) != this) {
248 nhdr++;
249 }
250 fColumn = nhdr;
251 } else if (fType == kRowHeader) {
252 while(fTable->GetRowHeader(nhdr) != this) {
253 nhdr++;
254 }
255 fRow = nhdr;
256 } else {
257 fRow = 0;
258 fColumn = 0;
259 }
260}
Handle_t GContext_t
Definition: GuiTypes.h:37
Handle_t FontStruct_t
Definition: GuiTypes.h:38
PyObject * fType
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:365
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
EHeaderType
Definition: TGTableHeader.h:16
@ kColumnHeader
Definition: TGTableHeader.h:17
@ kRowHeader
Definition: TGTableHeader.h:18
@ kTableHeader
Definition: TGTableHeader.h:19
int type
Definition: TGX11.cxx:120
const Bool_t kSortAscending
Definition: TList.h:37
#define gVirtualX
Definition: TVirtualX.h:345
UInt_t fHeight
Definition: TGDimension.h:30
UInt_t fWidth
Definition: TGDimension.h:29
virtual UInt_t GetDefaultWidth() const
Definition: TGFrame.h:237
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:238
virtual void SetBackgroundColor(Pixel_t back)
Set background color (override from TGWindow base class).
Definition: TGFrame.cxx:294
virtual Pixel_t GetBackground() const
Definition: TGFrame.h:239
Int_t GetLength() const
Definition: TGString.h:39
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
Definition: TGTableCell.h:102
virtual void Resize(UInt_t width, UInt_t height)
Resize the TGTableCell.
UInt_t fTWidth
Definition: TGTableCell.h:35
FontStruct_t fFontStruct
Definition: TGTableCell.h:37
TGTable * fTable
Definition: TGTableCell.h:42
UInt_t fTHeight
Definition: TGTableCell.h:36
TGString * fLabel
Definition: TGTableCell.h:29
UInt_t fRow
Definition: TGTableCell.h:41
UInt_t fColumn
Definition: TGTableCell.h:40
virtual UInt_t GetHeight() const
Definition: TGTableCell.h:103
virtual void SetPosition(UInt_t pos)
Set the position of the TGTableHeader to pos.
EHeaderType fType
Definition: TGTableHeader.h:27
virtual void SetLabel(const char *label)
Set the label of the TGTableHeader to label.
virtual void Sort(Bool_t order=kSortAscending)
Sort the contents of this row or column in given order.
void Init()
Initialize the TGTableHeader.
Bool_t fHasOwnLabel
Definition: TGTableHeader.h:32
virtual ~TGTableHeader()
TGTableHeader destructor.
virtual void UpdatePosition()
Update the positon of the TGTableHeader.
virtual void SetDefaultLabel()
Set the label of the TGTableHeader to the default label, "Row #" or "Col #".
virtual void SetWidth(UInt_t width)
Resize the TGTableHeader.
virtual void SetHeight(UInt_t height)
Resize the TGTableHeader.
TGTableHeader(const TGWindow *p=0, TGTable *table=0, TGString *label=0, UInt_t position=0, EHeaderType type=kColumnHeader, UInt_t width=80, UInt_t height=25, GContext_t norm=GetDefaultGC()(), FontStruct_t font=GetDefaultFontStruct(), UInt_t option=0)
TGTableHeader constuctor.
virtual void Resize(UInt_t width, UInt_t height)
Resize the TGTableHeader.
virtual const TGTableHeader * GetColumnHeader(const UInt_t column) const
Const version of GetColumnHeader();.
Definition: TGTable.cxx:1177
virtual TGTableHeader * GetTableHeader()
Return a pointer to the table header.
Definition: TGTable.cxx:1193
virtual const TGTableHeader * GetRowHeader(const UInt_t row) const
Const version of GetRowHeader();.
Definition: TGTable.cxx:1161
virtual UInt_t GetNTableRows() const
Return the amount of rows in the table.
Definition: TGTable.cxx:1105
virtual Pixel_t GetHeaderBackground() const
Get the background color of headers.
Definition: TGTable.cxx:1228
virtual UInt_t GetNTableColumns() const
Return the amount of columns in the table.
Definition: TGTable.cxx:1121