CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
FWTabularWidget Class Reference

#include <Fireworks/TableWidget/interface/FWTabularWidget.h>

Inheritance diagram for FWTabularWidget:

Public Member Functions

void buttonPressed (Int_t row, Int_t column, Event_t *event, Int_t relX, Int_t relY)
 
void buttonReleased (Int_t row, Int_t column, Event_t *event, Int_t relX, Int_t relY)
 
 ClassDefOverride (FWTabularWidget, 0)
 
void dataChanged ()
 
void disableGrowInWidth ()
 
void DoRedraw () override
 
 FWTabularWidget (FWTableManagerBase *iManager, const TGWindow *p=nullptr, GContext_t context=getDefaultGC()())
 
TGDimension GetDefaultSize () const override
 
Bool_t HandleButton (Event_t *event) override
 
UInt_t horizontalOffset () const
 
void needToRedraw ()
 
void setBackgroundAreaContext (GContext_t iContext)
 
void setHorizontalOffset (UInt_t)
 
void setLineContext (GContext_t iContext)
 
void setVerticalOffset (UInt_t)
 
void setWidthOfTextInColumns (const std::vector< unsigned int > &)
 
UInt_t verticalOffset () const
 
const std::vector< unsigned int > & widthOfTextInColumns () const
 
 ~FWTabularWidget () override
 

Static Public Member Functions

static const TGGC & getDefaultGC ()
 

Static Public Attributes

static const int kSeperatorWidth = 1
 
static const int kTextBuffer = 2
 

Private Member Functions

void translateToRowColumn (Int_t iX, Int_t iY, Int_t &oRow, Int_t &oCol, Int_t &oRelX, Int_t &oRelY) const
 

Private Attributes

GContext_t m_backgroundGC
 
bool m_growInWidth
 
unsigned int m_hOffset
 
GContext_t m_normGC
 
FWTableManagerBasem_table
 
int m_tableWidth
 
int m_textHeight
 
unsigned int m_vOffset
 
std::vector< unsigned int > m_widthOfTextInColumns
 
std::vector< unsigned int > m_widthOfTextInColumnsMax
 

Detailed Description

Description: Widget that draws part of a table [Implementation detail of FWTableWidget]

Usage: This class is used internally by FWTableWidget.

Definition at line 31 of file FWTabularWidget.h.

Constructor & Destructor Documentation

◆ FWTabularWidget()

FWTabularWidget::FWTabularWidget ( FWTableManagerBase iManager,
const TGWindow *  p = nullptr,
GContext_t  context = getDefaultGC()() 
)

Definition at line 38 of file FWTabularWidget.cc.

39  : TGFrame(p),
40  m_table(iTable),
41  m_widthOfTextInColumns(m_table->numberOfColumns(), static_cast<unsigned int>(0)),
42  m_vOffset(0),
43  m_hOffset(0),
44  m_normGC(context),
45  m_backgroundGC(ULONG_MAX),
46  m_growInWidth(true) {
47  m_textHeight = iTable->cellHeight();
49 
51  for (std::vector<unsigned int>::const_iterator it = m_widthOfTextInColumns.begin(),
52  itEnd = m_widthOfTextInColumns.end();
53  it != itEnd;
54  ++it) {
55  m_tableWidth += *it;
56  }
57  Resize();
58 
59  gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier, kButtonPressMask | kButtonReleaseMask, kNone, kNone);
60  m_table->Connect("visualPropertiesChanged()", "FWTabularWidget", this, "needToRedraw()");
61 }

References FWTableManagerBase::cellHeight(), WDecay::kNone, kSeperatorWidth, kTextBuffer, m_table, m_tableWidth, m_textHeight, m_widthOfTextInColumns, and FWTableManagerBase::maxWidthForColumns().

◆ ~FWTabularWidget()

FWTabularWidget::~FWTabularWidget ( )
override

Definition at line 68 of file FWTabularWidget.cc.

68 { m_table->Disconnect("visualPropertiesChanged()", this, "needToRedraw()"); }

References m_table.

Member Function Documentation

◆ buttonPressed()

void FWTabularWidget::buttonPressed ( Int_t  row,
Int_t  column,
Event_t *  event,
Int_t  relX,
Int_t  relY 
)

Definition at line 200 of file FWTabularWidget.cc.

200  {
201  //std::cout <<"buttonPressed "<<row<<" "<<column<<std::endl;
202  Long_t args[5];
203  args[0] = (Long_t)row;
204  args[1] = (Long_t)column;
205  args[2] = (Long_t)event;
206  args[3] = (Long_t)relX;
207  args[4] = (Long_t)relY;
208  Emit("buttonPressed(Int_t,Int_t,Event_t*,Int_t,Int_t)", args);
209 }

References writedatasetfile::args.

Referenced by HandleButton().

◆ buttonReleased()

void FWTabularWidget::buttonReleased ( Int_t  row,
Int_t  column,
Event_t *  event,
Int_t  relX,
Int_t  relY 
)

Definition at line 210 of file FWTabularWidget.cc.

210  {
211  //std::cout <<"buttonReleased "<<row<<" "<<column<<std::endl;
212  Long_t args[6];
213  args[0] = (Long_t)row;
214  args[1] = (Long_t)column;
215  args[2] = (Long_t)event;
216  args[3] = (Long_t)relX;
217  args[4] = (Long_t)relY;
218  Emit("buttonReleased(Int_t,Int_t,Event_t*,Int_t,Int_t)", args);
219 }

References writedatasetfile::args.

Referenced by HandleButton().

◆ ClassDefOverride()

FWTabularWidget::ClassDefOverride ( FWTabularWidget  ,
 
)

◆ dataChanged()

void FWTabularWidget::dataChanged ( void  )

◆ disableGrowInWidth()

void FWTabularWidget::disableGrowInWidth ( )
inline

Definition at line 69 of file FWTabularWidget.h.

69 { m_growInWidth = false; }

References m_growInWidth.

Referenced by FWTableWidget::disableGrowInWidth().

◆ DoRedraw()

void FWTabularWidget::DoRedraw ( )
override

Definition at line 221 of file FWTabularWidget.cc.

221  {
222  TGFrame::DoRedraw();
223 
224  //std::cout <<"DoRedraw "<<m_tableWidth<<std::endl;
225 
226  const int yOrigin = -m_vOffset;
227  const int xOrigin = -m_hOffset;
228  const int visibleWidth = m_tableWidth + xOrigin - kSeperatorWidth;
229  int y = yOrigin;
230  if (m_backgroundGC != ULONG_MAX) {
231  gVirtualX->FillRectangle(fId, m_backgroundGC, xOrigin, y, m_tableWidth, GetHeight());
232  }
233  gVirtualX->DrawLine(fId, m_normGC, xOrigin, y, visibleWidth, y);
234  //Draw data
235  const int numRows = m_table->numberOfRows();
236 
237  //figure out which rows and columns are visible
238  Int_t startRow, startColumn, relX, relY;
239  translateToRowColumn(0, 0, startRow, startColumn, relX, relY);
240  if (startRow < 0) {
241  startRow = 0;
242  }
243  if (startColumn < 0) {
244  startColumn = 0;
245  }
246  Int_t endRow, endColumn;
247  translateToRowColumn(GetWidth(), GetHeight(), endRow, endColumn, relX, relY);
248  if (endRow >= numRows) {
249  endRow = numRows - 1;
250  }
251  if (endColumn >= static_cast<Int_t>(m_widthOfTextInColumns.size())) {
252  endColumn = m_widthOfTextInColumns.size() - 1;
253  }
254  //std::cout <<"start "<<startRow<<" "<<startColumn<<" end "<<endRow<<" "<<endColumn<<std::endl;
255 
256  //calculate offset for rows and columns
257  Int_t rowOffset = (kSeperatorWidth + 2 * kTextBuffer + m_textHeight) * startRow;
258  Int_t columnOffset = kSeperatorWidth + kTextBuffer + xOrigin;
259  for (std::vector<unsigned int>::iterator itTextWidth = m_widthOfTextInColumns.begin(),
260  itEnd = m_widthOfTextInColumns.begin() + startColumn;
261  itTextWidth != itEnd;
262  ++itTextWidth) {
263  columnOffset += *itTextWidth + kTextBuffer + kSeperatorWidth + kTextBuffer;
264  }
265 
266  y += rowOffset;
267  for (int row = startRow; row <= endRow; ++row) {
268  std::vector<unsigned int>::iterator itTextWidth = m_widthOfTextInColumns.begin() + startColumn;
269  //int x=kSeperatorWidth+kTextBuffer+xOrigin;
270  int x = columnOffset;
272  for (int col = startColumn; col <= endColumn; ++col, ++itTextWidth) {
273  m_table->cellRenderer(row, col)->draw(fId, x, y, *itTextWidth, m_textHeight);
274  //UInt_t textWidth = font->TextWidth(itData->c_str(),-1);
275  x += *itTextWidth + kTextBuffer + kSeperatorWidth + kTextBuffer;
276  }
277  y += +m_textHeight + kTextBuffer;
278  gVirtualX->DrawLine(fId, m_normGC, xOrigin, y, visibleWidth, y);
279  }
280 
281  //draw column separators
282  int x = xOrigin;
283  gVirtualX->DrawLine(fId, m_normGC, x, 0, x, y);
284  x += kSeperatorWidth;
285  for (std::vector<unsigned int>::iterator itTextWidth = m_widthOfTextInColumns.begin();
286  itTextWidth != m_widthOfTextInColumns.end();
287  ++itTextWidth) {
288  x += 2 * kTextBuffer + *itTextWidth;
289  gVirtualX->DrawLine(fId, m_normGC, x, 0, x, y);
290  x += kSeperatorWidth;
291  }
292 }

References FWTableManagerBase::cellRenderer(), cuy::col, FWTableCellRendererBase::draw(), kSeperatorWidth, kTextBuffer, m_backgroundGC, m_hOffset, m_normGC, m_table, m_tableWidth, m_textHeight, m_vOffset, m_widthOfTextInColumns, FWTableManagerBase::numberOfRows(), translateToRowColumn(), x, and y.

Referenced by FWPathsPopup::postEvent().

◆ getDefaultGC()

const TGGC & FWTabularWidget::getDefaultGC ( )
static

Definition at line 319 of file FWTabularWidget.cc.

319  {
320  static const TGGC* s_default = gClient->GetResourcePool()->GetFrameGC();
321  return *s_default;
322 }

◆ GetDefaultSize()

TGDimension FWTabularWidget::GetDefaultSize ( ) const
override

Definition at line 300 of file FWTabularWidget.cc.

300  {
301  // returns default size
302 
303  UInt_t w = fWidth;
304  if (!(GetOptions() & kFixedWidth)) {
305  w = m_tableWidth;
306  }
307  UInt_t h = fHeight;
308  if (!(GetOptions() & kFixedHeight)) {
309  unsigned int numRows = m_table->numberOfRows();
310 
311  h = kSeperatorWidth + (m_textHeight + 2 * kTextBuffer + kSeperatorWidth) * (numRows);
312  }
313  return TGDimension(w, h);
314 }

References kSeperatorWidth, kTextBuffer, m_table, m_tableWidth, m_textHeight, FWTableManagerBase::numberOfRows(), and w.

Referenced by FWTableWidget::GetDefaultSize(), and FWTableWidget::handleResize().

◆ HandleButton()

Bool_t FWTabularWidget::HandleButton ( Event_t *  event)
override

Definition at line 132 of file FWTabularWidget.cc.

132  {
133  if (event->fType == kButtonPress) {
134  Int_t row, col, relX, relY;
135  translateToRowColumn(event->fX, event->fY, row, col, relX, relY);
136  //std::cout <<"Press: "<<relX<<" "<<relY<<" "<<row<<" "<<col<<" "<<m_table->numberOfRows()<<" "<<m_table->numberOfColumns()<<std::endl;
137  if (row >= 0 && row < m_table->numberOfRows() && col >= 0 && col < m_table->numberOfColumns()) {
138  FWTableCellRendererBase* renderer = m_table->cellRenderer(row, col);
139  if (renderer) {
140  renderer->buttonEvent(event, relX, relY);
141  }
142  buttonPressed(row, col, event, relX, relY);
143  }
144  return true;
145  }
146  if (event->fType == kButtonRelease) {
147  Int_t row, col, relX, relY;
148  translateToRowColumn(event->fX, event->fY, row, col, relX, relY);
149  //std::cout <<"Release: "<<relX<<" "<<relY<<" "<<row<<" "<<col<<" "<<m_table->numberOfRows()<<" "<<m_table->numberOfColumns()<<std::endl;
150  if (row >= 0 && row < m_table->numberOfRows() && col >= 0 && col < m_table->numberOfColumns()) {
151  FWTableCellRendererBase* renderer = m_table->cellRenderer(row, col);
152  if (renderer) {
153  renderer->buttonEvent(event, relX, relY);
154  }
155  buttonReleased(row, col, event, relX, relY);
156  }
157  return true;
158  }
159  return false;
160 }

References FWTableCellRendererBase::buttonEvent(), buttonPressed(), buttonReleased(), FWTableManagerBase::cellRenderer(), cuy::col, m_table, and translateToRowColumn().

◆ horizontalOffset()

UInt_t FWTabularWidget::horizontalOffset ( ) const
inline

Definition at line 44 of file FWTabularWidget.h.

44 { return m_hOffset; }

References m_hOffset.

◆ needToRedraw()

void FWTabularWidget::needToRedraw ( )

Definition at line 90 of file FWTabularWidget.cc.

90 { fClient->NeedRedraw(this); }

References hcaldqm::fClient.

◆ setBackgroundAreaContext()

void FWTabularWidget::setBackgroundAreaContext ( GContext_t  iContext)

Definition at line 295 of file FWTabularWidget.cc.

295 { m_backgroundGC = iContext; }

References m_backgroundGC.

Referenced by FWTableWidget::SetHeaderBackgroundColor().

◆ setHorizontalOffset()

void FWTabularWidget::setHorizontalOffset ( UInt_t  iH)

Definition at line 125 of file FWTabularWidget.cc.

125  {
126  if (iH != m_hOffset) {
127  m_hOffset = iH;
128  fClient->NeedRedraw(this);
129  }
130 }

References hcaldqm::fClient, and m_hOffset.

Referenced by FWTableWidget::ProcessMessage().

◆ setLineContext()

void FWTabularWidget::setLineContext ( GContext_t  iContext)

Definition at line 294 of file FWTabularWidget.cc.

294 { m_normGC = iContext; }

References m_normGC.

Referenced by FWTableWidget::SetHeaderForegroundColor(), and FWTableWidget::SetLineSeparatorColor().

◆ setVerticalOffset()

void FWTabularWidget::setVerticalOffset ( UInt_t  iV)

Definition at line 119 of file FWTabularWidget.cc.

119  {
120  if (iV != m_vOffset) {
121  m_vOffset = iV;
122  fClient->NeedRedraw(this);
123  }
124 }

References hcaldqm::fClient, and m_vOffset.

Referenced by FWTableWidget::ProcessMessage().

◆ setWidthOfTextInColumns()

void FWTabularWidget::setWidthOfTextInColumns ( const std::vector< unsigned int > &  iNew)

Definition at line 92 of file FWTabularWidget.cc.

92  {
93  assert(iNew.size() == static_cast<unsigned int>(m_table->numberOfColumns()));
94 
96  if (m_growInWidth) {
97  // with of columns grow to prevent resizing/flickering on next event
98  m_widthOfTextInColumnsMax.resize(iNew.size());
99  std::vector<unsigned int>::iterator k = m_widthOfTextInColumnsMax.begin();
100  for (std::vector<unsigned int>::iterator it = m_widthOfTextInColumns.begin(); it != m_widthOfTextInColumns.end();
101  ++it, ++k) {
102  if (*it < *k)
103  *it = *k;
104  else
105  *k = *it;
106  }
107  }
108 
109  m_tableWidth = 0;
110  for (std::vector<unsigned int>::const_iterator it = m_widthOfTextInColumns.begin(),
111  itEnd = m_widthOfTextInColumns.end();
112  it != itEnd;
113  ++it) {
115  }
117 }

References cms::cuda::assert(), dqmdumpme::k, kSeperatorWidth, kTextBuffer, m_growInWidth, m_table, m_tableWidth, m_widthOfTextInColumns, m_widthOfTextInColumnsMax, and FWTableManagerBase::numberOfColumns().

Referenced by dataChanged(), FWTableWidget::dataChanged(), and FWTableWidget::FWTableWidget().

◆ translateToRowColumn()

void FWTabularWidget::translateToRowColumn ( Int_t  iX,
Int_t  iY,
Int_t &  oRow,
Int_t &  oCol,
Int_t &  oRelX,
Int_t &  oRelY 
) const
private

Definition at line 162 of file FWTabularWidget.cc.

163  {
164  if (iX < 0) {
165  oCol = -1;
166  oRelX = 0;
167  } else {
168  if (iX + static_cast<Int_t>(m_hOffset) > static_cast<Int_t>(m_tableWidth)) {
169  oCol = m_widthOfTextInColumns.size();
170  oRelX = 0;
171  } else {
172  iX += m_hOffset;
173  oCol = 0;
174  for (std::vector<unsigned int>::const_iterator it = m_widthOfTextInColumns.begin(),
175  itEnd = m_widthOfTextInColumns.end();
176  it != itEnd;
177  ++it, ++oCol) {
178  oRelX = iX - kTextBuffer;
179  iX -= 2 * kTextBuffer + kSeperatorWidth + *it;
180  if (iX <= 0) {
181  break;
182  }
183  }
184  }
185  }
186  if (iY < 0) {
187  oRow = -1;
188  oRelY = 0;
189  } else {
190  oRow = (int)(float(iY + m_vOffset) / (m_textHeight + 2 * kTextBuffer + kSeperatorWidth));
191  oRelY = iY - oRow * (m_textHeight + 2 * kTextBuffer + kSeperatorWidth) + m_vOffset - kTextBuffer;
192  Int_t numRows = m_table->numberOfRows();
193  if (oRow > numRows) {
194  oRow = numRows;
195  oRelY = 0;
196  }
197  }
198 }

References createfilelist::int, kSeperatorWidth, kTextBuffer, m_hOffset, m_table, m_tableWidth, m_textHeight, m_vOffset, m_widthOfTextInColumns, and FWTableManagerBase::numberOfRows().

Referenced by DoRedraw(), and HandleButton().

◆ verticalOffset()

UInt_t FWTabularWidget::verticalOffset ( ) const
inline

Definition at line 43 of file FWTabularWidget.h.

43 { return m_vOffset; }

References m_vOffset.

◆ widthOfTextInColumns()

const std::vector<unsigned int>& FWTabularWidget::widthOfTextInColumns ( ) const
inline

Definition at line 42 of file FWTabularWidget.h.

42 { return m_widthOfTextInColumns; }

References m_widthOfTextInColumns.

Referenced by FWTableWidget::dataChanged(), and FWTableWidget::FWTableWidget().

Member Data Documentation

◆ kSeperatorWidth

const int FWTabularWidget::kSeperatorWidth = 1
static

◆ kTextBuffer

const int FWTabularWidget::kTextBuffer = 2
static

◆ m_backgroundGC

GContext_t FWTabularWidget::m_backgroundGC
private

Definition at line 90 of file FWTabularWidget.h.

Referenced by DoRedraw(), and setBackgroundAreaContext().

◆ m_growInWidth

bool FWTabularWidget::m_growInWidth
private

Definition at line 92 of file FWTabularWidget.h.

Referenced by disableGrowInWidth(), and setWidthOfTextInColumns().

◆ m_hOffset

unsigned int FWTabularWidget::m_hOffset
private

◆ m_normGC

GContext_t FWTabularWidget::m_normGC
private

Definition at line 89 of file FWTabularWidget.h.

Referenced by DoRedraw(), and setLineContext().

◆ m_table

FWTableManagerBase* FWTabularWidget::m_table
private

◆ m_tableWidth

int FWTabularWidget::m_tableWidth
private

◆ m_textHeight

int FWTabularWidget::m_textHeight
private

◆ m_vOffset

unsigned int FWTabularWidget::m_vOffset
private

◆ m_widthOfTextInColumns

std::vector<unsigned int> FWTabularWidget::m_widthOfTextInColumns
private

◆ m_widthOfTextInColumnsMax

std::vector<unsigned int> FWTabularWidget::m_widthOfTextInColumnsMax
private

Definition at line 82 of file FWTabularWidget.h.

Referenced by setWidthOfTextInColumns().

FWTableManagerBase::cellRenderer
virtual FWTableCellRendererBase * cellRenderer(int iSortedRowNumber, int iCol) const =0
writedatasetfile.args
args
Definition: writedatasetfile.py:18
FWTabularWidget::m_normGC
GContext_t m_normGC
Definition: FWTabularWidget.h:89
DDAxes::y
FWTabularWidget::buttonPressed
void buttonPressed(Int_t row, Int_t column, Event_t *event, Int_t relX, Int_t relY)
Definition: FWTabularWidget.cc:200
FWTabularWidget::m_widthOfTextInColumnsMax
std::vector< unsigned int > m_widthOfTextInColumnsMax
Definition: FWTabularWidget.h:82
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
cuy.col
col
Definition: cuy.py:1010
cms::cuda::assert
assert(be >=bs)
DDAxes::x
FWTableManagerBase::numberOfRows
virtual int numberOfRows() const =0
Number of rows in the table.
FWTabularWidget::setWidthOfTextInColumns
void setWidthOfTextInColumns(const std::vector< unsigned int > &)
Definition: FWTabularWidget.cc:92
FWTabularWidget::kTextBuffer
static const int kTextBuffer
Definition: FWTabularWidget.h:35
FWTableCellRendererBase::draw
virtual void draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight)=0
w
const double w
Definition: UKUtility.cc:23
FWTabularWidget::m_textHeight
int m_textHeight
Definition: FWTabularWidget.h:83
h
dqmdumpme.k
k
Definition: dqmdumpme.py:60
FWTabularWidget::m_table
FWTableManagerBase * m_table
Definition: FWTabularWidget.h:80
hcaldqm::fClient
Definition: DQModule.h:24
FWTabularWidget::kSeperatorWidth
static const int kSeperatorWidth
Definition: FWTabularWidget.h:36
FWTableManagerBase::numberOfColumns
virtual int numberOfColumns() const =0
Number of columns in the table.
createfilelist.int
int
Definition: createfilelist.py:10
FWTableCellRendererBase
Definition: FWTableCellRendererBase.h:44
FWTabularWidget::m_growInWidth
bool m_growInWidth
Definition: FWTabularWidget.h:92
FWTabularWidget::m_vOffset
unsigned int m_vOffset
Definition: FWTabularWidget.h:86
FWTabularWidget::buttonReleased
void buttonReleased(Int_t row, Int_t column, Event_t *event, Int_t relX, Int_t relY)
Definition: FWTabularWidget.cc:210
FWTabularWidget::m_tableWidth
int m_tableWidth
Definition: FWTabularWidget.h:84
WDecay::kNone
Definition: TopGenEvent.h:27
FWTabularWidget::translateToRowColumn
void translateToRowColumn(Int_t iX, Int_t iY, Int_t &oRow, Int_t &oCol, Int_t &oRelX, Int_t &oRelY) const
Definition: FWTabularWidget.cc:162
FWTabularWidget::m_backgroundGC
GContext_t m_backgroundGC
Definition: FWTabularWidget.h:90
FWTabularWidget::m_hOffset
unsigned int m_hOffset
Definition: FWTabularWidget.h:87
FWTabularWidget::m_widthOfTextInColumns
std::vector< unsigned int > m_widthOfTextInColumns
Definition: FWTabularWidget.h:81
event
Definition: event.py:1
FWTableCellRendererBase::buttonEvent
virtual void buttonEvent(Event_t *iClickEvent, int iRelClickX, int iRelClickY)
Definition: FWTableCellRendererBase.cc:53
FWTableManagerBase::cellHeight
virtual unsigned int cellHeight() const
require all cells to be the same height
Definition: FWTableManagerBase.cc:75
FWTableManagerBase::maxWidthForColumns
virtual std::vector< unsigned int > maxWidthForColumns() const
for each column in the table this returns the present maximum width for that column
Definition: FWTableManagerBase.cc:89