Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 "TGWindow.h"
13#include "TGResourcePool.h"
14#include "TGWidget.h"
15#include "TGTable.h"
16#include "TRandom3.h"
17#include "TVirtualX.h"
18
20
21//////////////////////////////////////////////////////////////////////////
22// //
23// TGTableHeader //
24// //
25// TGTableHeader is the class that implements a header for a row or //
26// column. Interactivity on a per column or row basis is implemented //
27// using this header. //
28// //
29// TGTableHeader is for internal use in TGTable only. //
30// //
31//////////////////////////////////////////////////////////////////////////
32
33////////////////////////////////////////////////////////////////////////////////
34/// TGTableHeader constuctor.
35
38 UInt_t height, GContext_t norm, FontStruct_t font,
39 UInt_t option)
40 : TGTableCell(p, table, label, 0, 0, width, height, norm, font, option,
41 kFALSE), fType(type), fReadOnly(kFALSE), fEnabled(kTRUE),
42 fHasOwnLabel(kFALSE)
43{
44 if (type == kColumnHeader) {
45 fWidth = (table) ? table->GetTableHeader()->GetWidth() : 80;
46 fHeight = 25;
47 fRow = 0;
48 fColumn = position;
49 } else if (type == kRowHeader) {
50 fWidth = 80;
51 fHeight = (table) ? table->GetTableHeader()->GetHeight() : 25;
52 fRow = position;
53 fColumn = 0;
54 } else {
55 fWidth = 80;
56 fHeight = 25;
57 }
58
59 if (!label) {
61 } else {
63 }
64
65 Init();
66}
67
68////////////////////////////////////////////////////////////////////////////////
69/// TGTableHeader constuctor.
70
72 const char *label, UInt_t position,
74 GContext_t norm, FontStruct_t font, UInt_t option)
75 : TGTableCell(p, table, label, 0, 0, width, height, norm, font,
76 option, kFALSE), fType(type), fReadOnly(kFALSE), fEnabled(kTRUE),
77 fHasOwnLabel(kFALSE)
78{
79 if (type == kColumnHeader) {
80 fWidth = table->GetTableHeader()->GetWidth();
81 fHeight = 25;
82 fRow = 0;
83 fColumn = position;
84 } else if (type == kRowHeader) {
85 fWidth = 80;
86 fHeight = table->GetTableHeader()->GetHeight();
87 fRow = position;
88 fColumn = 0;
89 } else {
90 fWidth = 80;
91 fHeight = 25;
92 }
93
94 if (!label) {
96 } else {
98 }
99
100 Init();
101}
102
103
104////////////////////////////////////////////////////////////////////////////////
105/// TGTableHeader destructor.
106
108{
109}
110
111////////////////////////////////////////////////////////////////////////////////
112/// Initialize the TGTableHeader
113
115{
116 if (fType == kTableHeader) {
118 } else {
120 }
121
123
124 Int_t max_ascent = 0, max_descent = 0;
125
127 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
128 fTHeight = max_ascent + max_descent;
129
130}
131
132////////////////////////////////////////////////////////////////////////////////
133/// Resize the TGTableHeader.
134
136{
138}
139
140////////////////////////////////////////////////////////////////////////////////
141/// Resize the TGTableHeader.
142
144{
145 Resize(GetDefaultWidth(), height);
146}
147
148////////////////////////////////////////////////////////////////////////////////
149/// Set the label of the TGTableHeader to label.
150
151void TGTableHeader::SetLabel(const char *label)
152{
153 if(label) {
155 } else {
157 }
158}
159
160////////////////////////////////////////////////////////////////////////////////
161/// Set the label of the TGTableHeader to the default label, "Row #"
162/// or "Col #".
163
165{
167 if (fLabel) delete fLabel;
168 fLabel = new TGString();
169 if (fType == kRowHeader) {
170 *fLabel += "Row ";
171 *fLabel += fRow;
172 } else if (fType == kColumnHeader) {
173 *fLabel += "Col ";
174 *fLabel += fColumn;
175 } else {
177 *fLabel += "x";
179 *fLabel += " Table";
180 }
181}
182
183////////////////////////////////////////////////////////////////////////////////
184/// Set the position of the TGTableHeader to pos.
185
187{
188 // Verify functionality
189
190 if (fType == kRowHeader) {
191 fRow = pos;
192 fColumn = 0;
193 } else if (fType == kColumnHeader) {
194 fRow = 0;
195 fColumn = pos;
196 } else {
197 fRow = 0;
198 fColumn = 0;
199 }
200}
201
202////////////////////////////////////////////////////////////////////////////////
203/// Resize the TGTableHeader.
204
206{
207 Resize(newsize.fWidth, newsize.fHeight);
208}
209
210////////////////////////////////////////////////////////////////////////////////
211/// Resize the TGTableHeader.
212
214{
215 // Implementation of resizing of an entire row of columns probably goes here.
216 TGTableCell::Resize(width, height);
217}
218
219////////////////////////////////////////////////////////////////////////////////
220/// Sort the contents of this row or column in given order.
221
223{
224 // Note: not implemented yet.
225
226 if (order == kSortAscending) {
227 } else {
228 }
229}
230
231////////////////////////////////////////////////////////////////////////////////
232/// Update the positon of the TGTableHeader.
233
235{
236 // Verify functionality. If rows are inserted or removed, internal
237 // column numbers are no longer consistent.
238
239 UInt_t nhdr = 0;
240 if (fType == kColumnHeader) {
241 while(fTable->GetColumnHeader(nhdr) != this) {
242 nhdr++;
243 }
244 fColumn = nhdr;
245 } else if (fType == kRowHeader) {
246 while(fTable->GetRowHeader(nhdr) != this) {
247 nhdr++;
248 }
249 fRow = nhdr;
250 } else {
251 fRow = 0;
252 fColumn = 0;
253 }
254}
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
const Bool_t kFALSE
Definition RtypesCore.h:92
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassImp(name)
Definition Rtypes.h:364
include TDocParser_001 C image html pict1_TDocParser_001 png width
EHeaderType
@ kColumnHeader
@ kRowHeader
@ kTableHeader
int type
Definition TGX11.cxx:121
const Bool_t kSortAscending
Definition TList.h:37
#define gVirtualX
Definition TVirtualX.h:338
UInt_t fHeight
Definition TGDimension.h:30
UInt_t fWidth
Definition TGDimension.h:29
virtual UInt_t GetDefaultWidth() const
Definition TGFrame.h:214
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:215
virtual void SetBackgroundColor(Pixel_t back)
Set background color (override from TGWindow base class).
Definition TGFrame.cxx:297
virtual Pixel_t GetBackground() const
Definition TGFrame.h:216
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
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
virtual void SetPosition(UInt_t pos)
Set the position of the TGTableHeader to pos.
EHeaderType fType
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
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:1170
virtual TGTableHeader * GetTableHeader()
Return a pointer to the table header.
Definition TGTable.cxx:1186
virtual const TGTableHeader * GetRowHeader(const UInt_t row) const
Const version of GetRowHeader();.
Definition TGTable.cxx:1154
virtual UInt_t GetNTableRows() const
Return the amount of rows in the table.
Definition TGTable.cxx:1098
virtual Pixel_t GetHeaderBackground() const
Get the background color of headers.
Definition TGTable.cxx:1221
virtual UInt_t GetNTableColumns() const
Return the amount of columns in the table.
Definition TGTable.cxx:1114