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.

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

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),
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 }
virtual int numberOfColumns() const =0
Number of columns in the table.
virtual std::vector< unsigned int > maxWidthForColumns() const
for each column in the table this returns the present maximum width for that column ...
unsigned int m_vOffset
GContext_t m_backgroundGC
GContext_t m_normGC
std::vector< unsigned int > m_widthOfTextInColumns
unsigned int m_hOffset
FWTableManagerBase * m_table
static const int kSeperatorWidth
static const int kTextBuffer

◆ ~FWTabularWidget()

FWTabularWidget::~FWTabularWidget ( )
override

Definition at line 68 of file FWTabularWidget.cc.

References m_table.

68 { m_table->Disconnect("visualPropertiesChanged()", this, "needToRedraw()"); }
FWTableManagerBase * 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.

References writedatasetfile::args.

Referenced by HandleButton().

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 }
Definition: event.py:1

◆ 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.

References writedatasetfile::args.

Referenced by HandleButton().

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 }
Definition: event.py:1

◆ ClassDefOverride()

FWTabularWidget::ClassDefOverride ( FWTabularWidget  ,
 
)

◆ dataChanged()

void FWTabularWidget::dataChanged ( void  )

Definition at line 85 of file FWTabularWidget.cc.

References FWTableManagerBase::cellHeight(), m_table, m_textHeight, FWTableManagerBase::maxWidthForColumns(), and setWidthOfTextInColumns().

Referenced by FWTableWidget::dataChanged().

85  {
88 }
virtual std::vector< unsigned int > maxWidthForColumns() const
for each column in the table this returns the present maximum width for that column ...
void setWidthOfTextInColumns(const std::vector< unsigned int > &)
virtual unsigned int cellHeight() const
require all cells to be the same height
FWTableManagerBase * m_table

◆ disableGrowInWidth()

void FWTabularWidget::disableGrowInWidth ( )
inline

Definition at line 69 of file FWTabularWidget.h.

References m_growInWidth.

Referenced by FWTableWidget::disableGrowInWidth().

69 { m_growInWidth = false; }

◆ DoRedraw()

void FWTabularWidget::DoRedraw ( )
override

Definition at line 221 of file FWTabularWidget.cc.

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().

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 }
unsigned int m_vOffset
virtual void draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight)=0
virtual int numberOfRows() const =0
Number of rows in the table.
virtual FWTableCellRendererBase * cellRenderer(int iSortedRowNumber, int iCol) const =0
GContext_t m_backgroundGC
GContext_t m_normGC
std::vector< unsigned int > m_widthOfTextInColumns
unsigned int m_hOffset
FWTableManagerBase * m_table
col
Definition: cuy.py:1009
static const int kSeperatorWidth
static const int kTextBuffer
void translateToRowColumn(Int_t iX, Int_t iY, Int_t &oRow, Int_t &oCol, Int_t &oRelX, Int_t &oRelY) const

◆ 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.

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

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

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 }
T w() const
virtual int numberOfRows() const =0
Number of rows in the table.
FWTableManagerBase * m_table
static const int kSeperatorWidth
static const int kTextBuffer
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ HandleButton()

Bool_t FWTabularWidget::HandleButton ( Event_t *  event)
override

Definition at line 132 of file FWTabularWidget.cc.

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

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 }
void buttonReleased(Int_t row, Int_t column, Event_t *event, Int_t relX, Int_t relY)
void buttonPressed(Int_t row, Int_t column, Event_t *event, Int_t relX, Int_t relY)
virtual FWTableCellRendererBase * cellRenderer(int iSortedRowNumber, int iCol) const =0
FWTableManagerBase * m_table
virtual void buttonEvent(Event_t *iClickEvent, int iRelClickX, int iRelClickY)
col
Definition: cuy.py:1009
void translateToRowColumn(Int_t iX, Int_t iY, Int_t &oRow, Int_t &oCol, Int_t &oRelX, Int_t &oRelY) const
Definition: event.py:1

◆ horizontalOffset()

UInt_t FWTabularWidget::horizontalOffset ( ) const
inline

Definition at line 44 of file FWTabularWidget.h.

References m_hOffset.

44 { return m_hOffset; }
unsigned int m_hOffset

◆ needToRedraw()

void FWTabularWidget::needToRedraw ( )

Definition at line 90 of file FWTabularWidget.cc.

References hcaldqm::fClient.

90 { fClient->NeedRedraw(this); }

◆ setBackgroundAreaContext()

void FWTabularWidget::setBackgroundAreaContext ( GContext_t  iContext)

Definition at line 295 of file FWTabularWidget.cc.

References m_backgroundGC.

Referenced by FWTableWidget::SetHeaderBackgroundColor().

295 { m_backgroundGC = iContext; }
GContext_t m_backgroundGC

◆ setHorizontalOffset()

void FWTabularWidget::setHorizontalOffset ( UInt_t  iH)

Definition at line 125 of file FWTabularWidget.cc.

References hcaldqm::fClient, and m_hOffset.

Referenced by FWTableWidget::ProcessMessage().

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

◆ setLineContext()

void FWTabularWidget::setLineContext ( GContext_t  iContext)

Definition at line 294 of file FWTabularWidget.cc.

References m_normGC.

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

294 { m_normGC = iContext; }
GContext_t m_normGC

◆ setVerticalOffset()

void FWTabularWidget::setVerticalOffset ( UInt_t  iV)

Definition at line 119 of file FWTabularWidget.cc.

References hcaldqm::fClient, and m_vOffset.

Referenced by FWTableWidget::ProcessMessage().

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

◆ setWidthOfTextInColumns()

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

Definition at line 92 of file FWTabularWidget.cc.

References cms::cuda::assert(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, 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().

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 }
virtual int numberOfColumns() const =0
Number of columns in the table.
assert(be >=bs)
std::vector< unsigned int > m_widthOfTextInColumns
FWTableManagerBase * m_table
std::vector< unsigned int > m_widthOfTextInColumnsMax
static const int kSeperatorWidth
static const int kTextBuffer

◆ 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.

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

Referenced by DoRedraw(), and HandleButton().

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 }
unsigned int m_vOffset
virtual int numberOfRows() const =0
Number of rows in the table.
std::vector< unsigned int > m_widthOfTextInColumns
unsigned int m_hOffset
FWTableManagerBase * m_table
static const int kSeperatorWidth
static const int kTextBuffer

◆ verticalOffset()

UInt_t FWTabularWidget::verticalOffset ( ) const
inline

Definition at line 43 of file FWTabularWidget.h.

References m_vOffset.

43 { return m_vOffset; }
unsigned int m_vOffset

◆ widthOfTextInColumns()

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

Definition at line 42 of file FWTabularWidget.h.

References m_widthOfTextInColumns.

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

42 { return m_widthOfTextInColumns; }
std::vector< unsigned int > m_widthOfTextInColumns

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().