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)
 
 ClassDef (FWTabularWidget, 0)
 
void dataChanged ()
 
void disableGrowInWidth ()
 
void DoRedraw ()
 
 FWTabularWidget (FWTableManagerBase *iManager, const TGWindow *p=0, GContext_t context=getDefaultGC()())
 
TGDimension GetDefaultSize () const
 
virtual Bool_t HandleButton (Event_t *event)
 
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
 
virtual ~FWTabularWidget ()
 

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 30 of file FWTabularWidget.h.

Constructor & Destructor Documentation

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

Definition at line 39 of file FWTabularWidget.cc.

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

39  :
40 TGFrame(p),
41 m_table(iTable),
42 m_widthOfTextInColumns(m_table->numberOfColumns(),static_cast<unsigned int>(0)),
43 m_vOffset(0),
44 m_hOffset(0),
45 m_normGC(context),
46 m_backgroundGC(ULONG_MAX),
47 m_growInWidth(true)
48 {
49 
50  m_textHeight = iTable->cellHeight();
52 
54  for(std::vector<unsigned int>::const_iterator it = m_widthOfTextInColumns.begin(), itEnd = m_widthOfTextInColumns.end();
55  it!=itEnd;
56  ++it){
57  m_tableWidth +=*it;
58  }
59  Resize();
60 
61  gVirtualX->GrabButton(fId,kAnyButton, kAnyModifier, kButtonPressMask|kButtonReleaseMask,kNone,kNone);
62  m_table->Connect("visualPropertiesChanged()","FWTabularWidget",this,"needToRedraw()");
63 }
unsigned int m_vOffset
virtual std::vector< unsigned int > maxWidthForColumns() const
for each column in the table this returns the present maximum width for that column ...
virtual int numberOfColumns() const =0
Number of columns in the table.
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 ( )
virtual

Definition at line 70 of file FWTabularWidget.cc.

References m_table.

71 {
72  m_table->Disconnect("visualPropertiesChanged()", this, "needToRedraw()");
73 }
FWTableManagerBase * m_table

Member Function Documentation

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

Definition at line 221 of file FWTabularWidget.cc.

References createfilelist::args.

Referenced by Vispa.Gui.BoxContentDialog.BoxContentDialog::addButton(), HandleButton(), and horizontalOffset().

222 {
223  //std::cout <<"buttonPressed "<<row<<" "<<column<<std::endl;
224  Long_t args[5];
225  args[0]=(Long_t)row;
226  args[1]=(Long_t)column;
227  args[2]=(Long_t)event;
228  args[3]=(Long_t)relX;
229  args[4]=(Long_t)relY;
230  Emit("buttonPressed(Int_t,Int_t,Event_t*,Int_t,Int_t)",args);
231 }
Definition: event.py:1
void FWTabularWidget::buttonReleased ( Int_t  row,
Int_t  column,
Event_t *  event,
Int_t  relX,
Int_t  relY 
)

Definition at line 233 of file FWTabularWidget.cc.

References createfilelist::args.

Referenced by HandleButton(), and horizontalOffset().

234 {
235  //std::cout <<"buttonReleased "<<row<<" "<<column<<std::endl;
236  Long_t args[6];
237  args[0]=(Long_t)row;
238  args[1]=(Long_t)column;
239  args[2]=(Long_t)event;
240  args[3]=(Long_t)relX;
241  args[4]=(Long_t)relY;
242  Emit("buttonReleased(Int_t,Int_t,Event_t*,Int_t,Int_t)",args);
243 }
Definition: event.py:1
FWTabularWidget::ClassDef ( FWTabularWidget  ,
 
)

Referenced by horizontalOffset().

void FWTabularWidget::dataChanged ( void  )

Definition at line 91 of file FWTabularWidget.cc.

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

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

92 {
95 }
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 > &)
FWTableManagerBase * m_table
virtual unsigned int cellHeight() const
require all cells to be the same height
void FWTabularWidget::disableGrowInWidth ( )
inline

Definition at line 70 of file FWTabularWidget.h.

References m_growInWidth, and translateToRowColumn().

Referenced by FWTableWidget::disableGrowInWidth().

70 { m_growInWidth = false; }
void FWTabularWidget::DoRedraw ( )

Definition at line 246 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 horizontalOffset(), and FWPathsPopup::postEvent().

247 {
248  TGFrame::DoRedraw();
249 
250  //std::cout <<"DoRedraw "<<m_tableWidth<<std::endl;
251 
252  const int yOrigin = -m_vOffset;
253  const int xOrigin = -m_hOffset;
254  const int visibleWidth = m_tableWidth+xOrigin-kSeperatorWidth;
255  int y=yOrigin;
256  if(m_backgroundGC != ULONG_MAX) {
257  gVirtualX->FillRectangle(fId,m_backgroundGC,xOrigin,y,m_tableWidth,
258  GetHeight());
259  }
260  gVirtualX->DrawLine(fId, m_normGC, xOrigin, y, visibleWidth, y);
261  //Draw data
262  const int numRows=m_table->numberOfRows();
263 
264  //figure out which rows and columns are visible
265  Int_t startRow, startColumn,relX,relY;
266  translateToRowColumn(0,0,startRow,startColumn,relX,relY);
267  if(startRow<0) { startRow = 0;}
268  if(startColumn<0) { startColumn=0;}
269  Int_t endRow, endColumn;
270  translateToRowColumn(GetWidth(),GetHeight(),endRow,endColumn,relX,relY);
271  if(endRow >= numRows) {
272  endRow = numRows-1;
273  }
274  if(endColumn >= static_cast<Int_t>(m_widthOfTextInColumns.size())) {
275  endColumn = m_widthOfTextInColumns.size()-1;
276  }
277  //std::cout <<"start "<<startRow<<" "<<startColumn<<" end "<<endRow<<" "<<endColumn<<std::endl;
278 
279  //calculate offset for rows and columns
280  Int_t rowOffset = (kSeperatorWidth+2*kTextBuffer+m_textHeight)*startRow;
281  Int_t columnOffset=kSeperatorWidth+kTextBuffer+xOrigin;
282  for(std::vector<unsigned int>::iterator itTextWidth = m_widthOfTextInColumns.begin(), itEnd = m_widthOfTextInColumns.begin()+startColumn;
283  itTextWidth != itEnd; ++itTextWidth) {
284  columnOffset+=*itTextWidth+kTextBuffer+kSeperatorWidth+kTextBuffer;
285  }
286 
287 
288  y+=rowOffset;
289  for(int row = startRow; row <= endRow; ++row) {
290  std::vector<unsigned int>::iterator itTextWidth = m_widthOfTextInColumns.begin()+startColumn;
291  //int x=kSeperatorWidth+kTextBuffer+xOrigin;
292  int x = columnOffset;
294  for(int col = startColumn;
295  col <= endColumn;
296  ++col,++itTextWidth) {
297  m_table->cellRenderer(row,col)->draw(fId,x,y,*itTextWidth,m_textHeight);
298  //UInt_t textWidth = font->TextWidth(itData->c_str(),-1);
299  x+=*itTextWidth+kTextBuffer+kSeperatorWidth+kTextBuffer;
300  }
302  gVirtualX->DrawLine(fId, m_normGC, xOrigin, y, visibleWidth, y);
303  }
304 
305  //draw column separators
306  int x=xOrigin;
307  gVirtualX->DrawLine(fId,m_normGC,x,0,x,y);
308  x+=kSeperatorWidth;
309  for(std::vector<unsigned int>::iterator itTextWidth = m_widthOfTextInColumns.begin();
310  itTextWidth != m_widthOfTextInColumns.end();
311  ++itTextWidth) {
312  x+=2*kTextBuffer+*itTextWidth;
313  gVirtualX->DrawLine(fId,m_normGC,x,0,x,y);
314  x+=kSeperatorWidth;
315  }
316 }
virtual FWTableCellRendererBase * cellRenderer(int iSortedRowNumber, int iCol) const =0
virtual int numberOfRows() const =0
Number of rows in the table.
void translateToRowColumn(Int_t iX, Int_t iY, Int_t &oRow, Int_t &oCol, Int_t &oRelX, Int_t &oRelY) const
unsigned int m_vOffset
virtual void draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight)=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:1008
static const int kSeperatorWidth
static const int kTextBuffer
const TGGC & FWTabularWidget::getDefaultGC ( )
static

Definition at line 354 of file FWTabularWidget.cc.

References ClassImp().

355 {
356  static const TGGC* s_default = gClient->GetResourcePool()->GetFrameGC();
357  return *s_default;
358 }
TGDimension FWTabularWidget::GetDefaultSize ( ) const

Definition at line 333 of file FWTabularWidget.cc.

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

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

334 {
335  // returns default size
336 
337  UInt_t w = fWidth;
338  if(! (GetOptions() & kFixedWidth) ) {
339  w=m_tableWidth;
340  }
341  UInt_t h = fHeight;
342  if(! (GetOptions() & kFixedHeight) ) {
343  unsigned int numRows = m_table->numberOfRows();
344 
346  }
347  return TGDimension(w, h);
348 }
virtual int numberOfRows() const =0
Number of rows in the table.
const double w
Definition: UKUtility.cc:23
FWTableManagerBase * m_table
static const int kSeperatorWidth
static const int kTextBuffer
Bool_t FWTabularWidget::HandleButton ( Event_t *  event)
virtual

Definition at line 151 of file FWTabularWidget.cc.

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

Referenced by horizontalOffset().

152 {
153  if (event->fType==kButtonPress) {
154  Int_t row,col,relX,relY;
155  translateToRowColumn(event->fX, event->fY, row, col,relX,relY);
156  //std::cout <<"Press: "<<relX<<" "<<relY<<" "<<row<<" "<<col<<" "<<m_table->numberOfRows()<<" "<<m_table->numberOfColumns()<<std::endl;
157  if (row >= 0 && row < m_table->numberOfRows() && col >= 0 && col < m_table->numberOfColumns()) {
158  FWTableCellRendererBase* renderer = m_table->cellRenderer(row,col);
159  if (renderer) {
160  renderer->buttonEvent(event,relX,relY);
161  }
162  buttonPressed(row,col,event,relX,relY);
163  }
164  return true;
165  }
166  if (event->fType==kButtonRelease) {
167  Int_t row,col,relX,relY;
168  translateToRowColumn(event->fX, event->fY, row, col,relX, relY);
169  //std::cout <<"Release: "<<relX<<" "<<relY<<" "<<row<<" "<<col<<" "<<m_table->numberOfRows()<<" "<<m_table->numberOfColumns()<<std::endl;
170  if (row >= 0 && row < m_table->numberOfRows() && col >= 0 && col < m_table->numberOfColumns()) {
171  FWTableCellRendererBase* renderer = m_table->cellRenderer(row,col);
172  if (renderer) {
173  renderer->buttonEvent(event,relX,relY);
174  }
175  buttonReleased(row,col,event,relX,relY);
176  }
177  return true;
178  }
179  return false;
180 }
void buttonReleased(Int_t row, Int_t column, Event_t *event, Int_t relX, Int_t relY)
virtual FWTableCellRendererBase * cellRenderer(int iSortedRowNumber, int iCol) const =0
void translateToRowColumn(Int_t iX, Int_t iY, Int_t &oRow, Int_t &oCol, Int_t &oRelX, Int_t &oRelY) const
void buttonPressed(Int_t row, Int_t column, Event_t *event, Int_t relX, Int_t relY)
FWTableManagerBase * m_table
virtual void buttonEvent(Event_t *iClickEvent, int iRelClickX, int iRelClickY)
col
Definition: cuy.py:1008
Definition: event.py:1
UInt_t FWTabularWidget::horizontalOffset ( ) const
inline
void FWTabularWidget::needToRedraw ( )

Definition at line 98 of file FWTabularWidget.cc.

References hcaldqm::fClient.

Referenced by horizontalOffset().

99 {
100  fClient->NeedRedraw(this);
101 }
void FWTabularWidget::setBackgroundAreaContext ( GContext_t  iContext)

Definition at line 324 of file FWTabularWidget.cc.

References m_backgroundGC.

Referenced by horizontalOffset(), and FWTableWidget::SetHeaderBackgroundColor().

325 {
326  m_backgroundGC = iContext;
327 }
GContext_t m_backgroundGC
void FWTabularWidget::setHorizontalOffset ( UInt_t  iH)

Definition at line 142 of file FWTabularWidget.cc.

References hcaldqm::fClient, and m_hOffset.

Referenced by horizontalOffset(), and FWTableWidget::ProcessMessage().

143 {
144  if(iH != m_hOffset){
145  m_hOffset = iH;
146  fClient->NeedRedraw(this);
147  }
148 }
unsigned int m_hOffset
void FWTabularWidget::setLineContext ( GContext_t  iContext)

Definition at line 319 of file FWTabularWidget.cc.

References m_normGC.

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

320 {
321  m_normGC = iContext;
322 }
GContext_t m_normGC
void FWTabularWidget::setVerticalOffset ( UInt_t  iV)

Definition at line 134 of file FWTabularWidget.cc.

References hcaldqm::fClient, and m_vOffset.

Referenced by horizontalOffset(), and FWTableWidget::ProcessMessage().

135 {
136  if(iV != m_vOffset) {
137  m_vOffset = iV;
138  fClient->NeedRedraw(this);
139  }
140 }
unsigned int m_vOffset
void FWTabularWidget::setWidthOfTextInColumns ( const std::vector< unsigned int > &  iNew)

Definition at line 105 of file FWTabularWidget.cc.

References gen::k, kSeperatorWidth, kTextBuffer, m_growInWidth, m_table, m_tableWidth, m_widthOfTextInColumns, m_widthOfTextInColumnsMax, and FWTableManagerBase::numberOfColumns().

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

106 {
107  assert(iNew.size() == static_cast<unsigned int>(m_table->numberOfColumns()));
108 
110  if (m_growInWidth)
111  {
112  // with of columns grow to prevent resizing/flickering on next event
113  m_widthOfTextInColumnsMax.resize(iNew.size());
114  std::vector<unsigned int>::iterator k = m_widthOfTextInColumnsMax.begin();
115  for(std::vector<unsigned int>::iterator it = m_widthOfTextInColumns.begin(); it != m_widthOfTextInColumns.end(); ++it, ++k)
116  {
117  if ( *it < *k )
118  *it = *k;
119  else
120  *k = *it;
121  }
122  }
123 
124  m_tableWidth=0;
125  for(std::vector<unsigned int>::const_iterator it = m_widthOfTextInColumns.begin(), itEnd = m_widthOfTextInColumns.end();
126  it!=itEnd;
127  ++it){
129  }
131 }
virtual int numberOfColumns() const =0
Number of columns in the table.
std::vector< unsigned int > m_widthOfTextInColumns
int k[5][pyjets_maxn]
FWTableManagerBase * m_table
std::vector< unsigned int > m_widthOfTextInColumnsMax
static const int kSeperatorWidth
static const int kTextBuffer
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 183 of file FWTabularWidget.cc.

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

Referenced by disableGrowInWidth(), DoRedraw(), and HandleButton().

184 {
185  if( iX < 0 ) {
186  oCol = -1;
187  oRelX = 0;
188  } else {
189  if(iX+static_cast<Int_t>(m_hOffset) > static_cast<Int_t>(m_tableWidth) ) {
190  oCol = m_widthOfTextInColumns.size();
191  oRelX = 0;
192  } else {
193  iX +=m_hOffset;
194  oCol = 0;
195  for(std::vector<unsigned int>::const_iterator it = m_widthOfTextInColumns.begin(), itEnd = m_widthOfTextInColumns.end();
196  it!=itEnd;
197  ++it,++oCol){
198  oRelX=iX-kTextBuffer;
199  iX-=2*kTextBuffer+kSeperatorWidth+*it;
200  if(iX <= 0) {
201  break;
202  }
203  }
204  }
205  }
206  if( iY < 0) {
207  oRow = -1;
208  oRelY=0;
209  } else {
210  oRow = (int)(float(iY+m_vOffset)/(m_textHeight+2*kTextBuffer+kSeperatorWidth));
212  Int_t numRows = m_table->numberOfRows();
213  if(oRow > numRows) {
214  oRow = numRows;
215  oRelY=0;
216  }
217  }
218 }
virtual int numberOfRows() const =0
Number of rows in the table.
unsigned int m_vOffset
std::vector< unsigned int > m_widthOfTextInColumns
unsigned int m_hOffset
FWTableManagerBase * m_table
static const int kSeperatorWidth
static const int kTextBuffer
UInt_t FWTabularWidget::verticalOffset ( ) const
inline

Definition at line 44 of file FWTabularWidget.h.

References m_vOffset.

44 {return m_vOffset;}
unsigned int m_vOffset
const std::vector<unsigned int>& FWTabularWidget::widthOfTextInColumns ( ) const
inline

Definition at line 43 of file FWTabularWidget.h.

References m_widthOfTextInColumns.

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

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

Member Data Documentation

const int FWTabularWidget::kSeperatorWidth = 1
static
const int FWTabularWidget::kTextBuffer = 2
static
GContext_t FWTabularWidget::m_backgroundGC
private

Definition at line 91 of file FWTabularWidget.h.

Referenced by DoRedraw(), and setBackgroundAreaContext().

bool FWTabularWidget::m_growInWidth
private

Definition at line 93 of file FWTabularWidget.h.

Referenced by disableGrowInWidth(), and setWidthOfTextInColumns().

unsigned int FWTabularWidget::m_hOffset
private
GContext_t FWTabularWidget::m_normGC
private

Definition at line 90 of file FWTabularWidget.h.

Referenced by DoRedraw(), and setLineContext().

FWTableManagerBase* FWTabularWidget::m_table
private
int FWTabularWidget::m_tableWidth
private
int FWTabularWidget::m_textHeight
private
unsigned int FWTabularWidget::m_vOffset
private
std::vector<unsigned int> FWTabularWidget::m_widthOfTextInColumns
private
std::vector<unsigned int> FWTabularWidget::m_widthOfTextInColumnsMax
private

Definition at line 83 of file FWTabularWidget.h.

Referenced by setWidthOfTextInColumns().