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
19
20
21/** \class TGTableHeader
22 \ingroup guiwidgets
23
24TGTableHeader is the class that implements a header for a row or
25column. Interactivity on a per column or row basis is implemented
26using this header.
27
28TGTableHeader is for internal use in TGTable only.
29
30*/
31
32
33////////////////////////////////////////////////////////////////////////////////
34/// TGTableHeader constructor.
35
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 constructor.
70
72 const char *label, UInt_t position,
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
110
111////////////////////////////////////////////////////////////////////////////////
112/// Initialize the TGTableHeader
113
115{
116 if (fType == kTableHeader) {
118 } else {
120 }
121
123
125
127 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
129
130}
131
132////////////////////////////////////////////////////////////////////////////////
133/// Resize the TGTableHeader.
134
139
140////////////////////////////////////////////////////////////////////////////////
141/// Resize the TGTableHeader.
142
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.
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
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
EHeaderType
@ kColumnHeader
@ kRowHeader
@ kTableHeader
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
const Bool_t kSortAscending
Definition TList.h:31
#define gVirtualX
Definition TVirtualX.h:337
virtual UInt_t GetDefaultWidth() const
Definition TGFrame.h:192
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:193
void SetBackgroundColor(Pixel_t back) override
Set background color (override from TGWindow base class).
Definition TGFrame.cxx:304
virtual Pixel_t GetBackground() const
Definition TGFrame.h:194
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition TGString.h:20
Int_t GetLength() const
Definition TGString.h:29
const char * GetString() const
Definition TGString.h:30
TGTableCell is the class that represents a single cell in a TGTable.
Definition TGTableCell.h:24
virtual void SetLabel(const char *label)
Set the label of this cell to label.
UInt_t fTWidth
Label width.
Definition TGTableCell.h:35
FontStruct_t fFontStruct
Font of the label.
Definition TGTableCell.h:37
TGTable * fTable
TGTable that a cell belongs to.
Definition TGTableCell.h:42
UInt_t fTHeight
Label height.
Definition TGTableCell.h:36
TGString * fLabel
Text as shown in the cell.
Definition TGTableCell.h:29
UInt_t fRow
Row this cell belongs to.
Definition TGTableCell.h:41
void Resize(UInt_t width, UInt_t height) override
Resize the TGTableCell.
UInt_t fColumn
Column this cell belongs to.
Definition TGTableCell.h:40
void Resize(UInt_t width, UInt_t height) override
Resize the TGTableHeader.
void SetWidth(UInt_t width) override
Resize the TGTableHeader.
virtual void SetPosition(UInt_t pos)
Set the position of the TGTableHeader to pos.
UInt_t fWidth
Width for the column.
EHeaderType fType
Type of header.
UInt_t fHeight
Height of the row.
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
Flag on default or specific label usage.
TGTableHeader(const TGWindow *p=nullptr, TGTable *table=nullptr, TGString *label=nullptr, 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 constructor.
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 #".
void SetLabel(const char *label) override
Set the label of the TGTableHeader to label.
void SetHeight(UInt_t height) override
Resize the TGTableHeader.
~TGTableHeader() override
TGTableHeader destructor.
Create an array to hold a bunch of numbers.
Definition TGTable.h:34
virtual const TGTableHeader * GetColumnHeader(const UInt_t column) const
Const version of GetColumnHeader();.
Definition TGTable.cxx:1162
virtual TGTableHeader * GetTableHeader()
Return a pointer to the table header.
Definition TGTable.cxx:1178
virtual const TGTableHeader * GetRowHeader(const UInt_t row) const
Const version of GetRowHeader();.
Definition TGTable.cxx:1146
virtual UInt_t GetNTableRows() const
Return the amount of rows in the table.
Definition TGTable.cxx:1090
virtual Pixel_t GetHeaderBackground() const
Get the background color of headers.
Definition TGTable.cxx:1213
virtual UInt_t GetNTableColumns() const
Return the amount of columns in the table.
Definition TGTable.cxx:1106
ROOT GUI Window base class.
Definition TGWindow.h:23