#include <Fireworks/TableWidget/interface/FWTabularWidget.h>
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 |
FWTableManagerBase * | m_table |
int | m_tableWidth |
int | m_textHeight |
unsigned int | m_vOffset |
std::vector< unsigned int > | m_widthOfTextInColumns |
std::vector< unsigned int > | m_widthOfTextInColumnsMax |
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.
FWTabularWidget::FWTabularWidget | ( | FWTableManagerBase * | iManager, |
const TGWindow * | p = 0 , |
||
GContext_t | context = getDefaultGC()() |
||
) |
Definition at line 40 of file FWTabularWidget.cc.
References FWTableManagerBase::cellHeight(), WDecay::kNone, kSeperatorWidth, kTextBuffer, m_table, m_tableWidth, m_textHeight, m_widthOfTextInColumns, and FWTableManagerBase::maxWidthForColumns().
: TGFrame(p), m_table(iTable), m_widthOfTextInColumns(m_table->numberOfColumns(),static_cast<unsigned int>(0)), m_vOffset(0), m_hOffset(0), m_normGC(context), m_backgroundGC(ULONG_MAX), m_growInWidth(true) { m_textHeight = iTable->cellHeight(); m_widthOfTextInColumns = m_table->maxWidthForColumns(); m_tableWidth=(kTextBuffer+kTextBuffer+kSeperatorWidth)*(m_widthOfTextInColumns.size())+kSeperatorWidth; for(std::vector<unsigned int>::const_iterator it = m_widthOfTextInColumns.begin(), itEnd = m_widthOfTextInColumns.end(); it!=itEnd; ++it){ m_tableWidth +=*it; } Resize(); gVirtualX->GrabButton(fId,kAnyButton, kAnyModifier, kButtonPressMask|kButtonReleaseMask,kNone,kNone); m_table->Connect("visualPropertiesChanged()","FWTabularWidget",this,"needToRedraw()"); }
FWTabularWidget::~FWTabularWidget | ( | ) | [virtual] |
Definition at line 71 of file FWTabularWidget.cc.
References m_table.
{ m_table->Disconnect("visualPropertiesChanged()", this, "needToRedraw()"); }
void FWTabularWidget::buttonPressed | ( | Int_t | row, |
Int_t | column, | ||
Event_t * | event, | ||
Int_t | relX, | ||
Int_t | relY | ||
) |
Definition at line 222 of file FWTabularWidget.cc.
References harvestRelVal::args.
Referenced by HandleButton().
void FWTabularWidget::buttonReleased | ( | Int_t | row, |
Int_t | column, | ||
Event_t * | event, | ||
Int_t | relX, | ||
Int_t | relY | ||
) |
Definition at line 234 of file FWTabularWidget.cc.
References harvestRelVal::args.
Referenced by HandleButton().
FWTabularWidget::ClassDef | ( | FWTabularWidget | , |
0 | |||
) |
void FWTabularWidget::dataChanged | ( | void | ) |
Definition at line 92 of file FWTabularWidget.cc.
References FWTableManagerBase::cellHeight(), m_table, m_textHeight, FWTableManagerBase::maxWidthForColumns(), and setWidthOfTextInColumns().
Referenced by FWTableWidget::dataChanged().
{ m_textHeight = m_table->cellHeight(); setWidthOfTextInColumns(m_table->maxWidthForColumns()); }
void FWTabularWidget::disableGrowInWidth | ( | ) | [inline] |
Definition at line 71 of file FWTabularWidget.h.
References m_growInWidth.
Referenced by FWTableWidget::disableGrowInWidth().
{ m_growInWidth = false; }
void FWTabularWidget::DoRedraw | ( | ) |
Definition at line 247 of file FWTabularWidget.cc.
References FWTableManagerBase::cellRenderer(), 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 detailsBasic3DVector::y.
Referenced by FWPathsPopup::postProcessEvent().
{ TGFrame::DoRedraw(); //std::cout <<"DoRedraw "<<m_tableWidth<<std::endl; const int yOrigin = -m_vOffset; const int xOrigin = -m_hOffset; const int visibleWidth = m_tableWidth+xOrigin-kSeperatorWidth; int y=yOrigin; if(m_backgroundGC != ULONG_MAX) { gVirtualX->FillRectangle(fId,m_backgroundGC,xOrigin,y,m_tableWidth, GetHeight()); } gVirtualX->DrawLine(fId, m_normGC, xOrigin, y, visibleWidth, y); //Draw data const int numRows=m_table->numberOfRows(); //figure out which rows and columns are visible Int_t startRow, startColumn,relX,relY; translateToRowColumn(0,0,startRow,startColumn,relX,relY); if(startRow<0) { startRow = 0;} if(startColumn<0) { startColumn=0;} Int_t endRow, endColumn; translateToRowColumn(GetWidth(),GetHeight(),endRow,endColumn,relX,relY); if(endRow >= numRows) { endRow = numRows-1; } if(endColumn >= static_cast<Int_t>(m_widthOfTextInColumns.size())) { endColumn = m_widthOfTextInColumns.size()-1; } //std::cout <<"start "<<startRow<<" "<<startColumn<<" end "<<endRow<<" "<<endColumn<<std::endl; //calculate offset for rows and columns Int_t rowOffset = (kSeperatorWidth+2*kTextBuffer+m_textHeight)*startRow; Int_t columnOffset=kSeperatorWidth+kTextBuffer+xOrigin; for(std::vector<unsigned int>::iterator itTextWidth = m_widthOfTextInColumns.begin(), itEnd = m_widthOfTextInColumns.begin()+startColumn; itTextWidth != itEnd; ++itTextWidth) { columnOffset+=*itTextWidth+kTextBuffer+kSeperatorWidth+kTextBuffer; } y+=rowOffset; for(int row = startRow; row <= endRow; ++row) { std::vector<unsigned int>::iterator itTextWidth = m_widthOfTextInColumns.begin()+startColumn; //int x=kSeperatorWidth+kTextBuffer+xOrigin; int x = columnOffset; y+=kTextBuffer+kSeperatorWidth; for(int col = startColumn; col <= endColumn; ++col,++itTextWidth) { m_table->cellRenderer(row,col)->draw(fId,x,y,*itTextWidth,m_textHeight); //UInt_t textWidth = font->TextWidth(itData->c_str(),-1); x+=*itTextWidth+kTextBuffer+kSeperatorWidth+kTextBuffer; } y+=+m_textHeight+kTextBuffer; gVirtualX->DrawLine(fId, m_normGC, xOrigin, y, visibleWidth, y); } //draw column separators int x=xOrigin; gVirtualX->DrawLine(fId,m_normGC,x,0,x,y); x+=kSeperatorWidth; for(std::vector<unsigned int>::iterator itTextWidth = m_widthOfTextInColumns.begin(); itTextWidth != m_widthOfTextInColumns.end(); ++itTextWidth) { x+=2*kTextBuffer+*itTextWidth; gVirtualX->DrawLine(fId,m_normGC,x,0,x,y); x+=kSeperatorWidth; } }
const TGGC & FWTabularWidget::getDefaultGC | ( | ) | [static] |
Definition at line 355 of file FWTabularWidget.cc.
{ static const TGGC* s_default = gClient->GetResourcePool()->GetFrameGC(); return *s_default; }
TGDimension FWTabularWidget::GetDefaultSize | ( | ) | const |
Definition at line 334 of file FWTabularWidget.cc.
References h, kSeperatorWidth, kTextBuffer, m_table, m_tableWidth, m_textHeight, and FWTableManagerBase::numberOfRows().
Referenced by FWTableWidget::GetDefaultSize(), and FWTableWidget::handleResize().
{ // returns default size UInt_t w = fWidth; if(! (GetOptions() & kFixedWidth) ) { w=m_tableWidth; } UInt_t h = fHeight; if(! (GetOptions() & kFixedHeight) ) { unsigned int numRows = m_table->numberOfRows(); h = kSeperatorWidth+(m_textHeight+2*kTextBuffer+kSeperatorWidth)*(numRows); } return TGDimension(w, h); }
Bool_t FWTabularWidget::HandleButton | ( | Event_t * | event | ) | [virtual] |
Definition at line 152 of file FWTabularWidget.cc.
References FWTableCellRendererBase::buttonEvent(), buttonPressed(), buttonReleased(), FWTableManagerBase::cellRenderer(), m_table, and translateToRowColumn().
{ if (event->fType==kButtonPress) { Int_t row,col,relX,relY; translateToRowColumn(event->fX, event->fY, row, col,relX,relY); //std::cout <<"Press: "<<relX<<" "<<relY<<" "<<row<<" "<<col<<" "<<m_table->numberOfRows()<<" "<<m_table->numberOfColumns()<<std::endl; if (row >= 0 && row < m_table->numberOfRows() && col >= 0 && col < m_table->numberOfColumns()) { FWTableCellRendererBase* renderer = m_table->cellRenderer(row,col); if (renderer) { renderer->buttonEvent(event,relX,relY); } buttonPressed(row,col,event,relX,relY); } return true; } if (event->fType==kButtonRelease) { Int_t row,col,relX,relY; translateToRowColumn(event->fX, event->fY, row, col,relX, relY); //std::cout <<"Release: "<<relX<<" "<<relY<<" "<<row<<" "<<col<<" "<<m_table->numberOfRows()<<" "<<m_table->numberOfColumns()<<std::endl; if (row >= 0 && row < m_table->numberOfRows() && col >= 0 && col < m_table->numberOfColumns()) { FWTableCellRendererBase* renderer = m_table->cellRenderer(row,col); if (renderer) { renderer->buttonEvent(event,relX,relY); } buttonReleased(row,col,event,relX,relY); } return true; } return false; }
UInt_t FWTabularWidget::horizontalOffset | ( | ) | const [inline] |
void FWTabularWidget::needToRedraw | ( | ) |
Definition at line 99 of file FWTabularWidget.cc.
{
fClient->NeedRedraw(this);
}
void FWTabularWidget::setBackgroundAreaContext | ( | GContext_t | iContext | ) |
Definition at line 325 of file FWTabularWidget.cc.
References m_backgroundGC.
Referenced by FWTableWidget::SetHeaderBackgroundColor().
{ m_backgroundGC = iContext; }
void FWTabularWidget::setHorizontalOffset | ( | UInt_t | iH | ) |
Definition at line 143 of file FWTabularWidget.cc.
References m_hOffset.
Referenced by FWTableWidget::ProcessMessage().
void FWTabularWidget::setLineContext | ( | GContext_t | iContext | ) |
Definition at line 320 of file FWTabularWidget.cc.
References m_normGC.
Referenced by FWTableWidget::SetHeaderForegroundColor(), and FWTableWidget::SetLineSeparatorColor().
{ m_normGC = iContext; }
void FWTabularWidget::setVerticalOffset | ( | UInt_t | iV | ) |
Definition at line 135 of file FWTabularWidget.cc.
References m_vOffset.
Referenced by FWTableWidget::ProcessMessage().
void FWTabularWidget::setWidthOfTextInColumns | ( | const std::vector< unsigned int > & | iNew | ) |
Definition at line 106 of file FWTabularWidget.cc.
References gen::k, kSeperatorWidth, kTextBuffer, m_growInWidth, m_table, m_tableWidth, m_widthOfTextInColumns, m_widthOfTextInColumnsMax, and FWTableManagerBase::numberOfColumns().
Referenced by FWTableWidget::dataChanged(), dataChanged(), and FWTableWidget::FWTableWidget().
{ assert(iNew.size() == static_cast<unsigned int>(m_table->numberOfColumns())); m_widthOfTextInColumns=iNew; if (m_growInWidth) { // with of columns grow to prevent resizing/flickering on next event m_widthOfTextInColumnsMax.resize(iNew.size()); std::vector<unsigned int>::iterator k = m_widthOfTextInColumnsMax.begin(); for(std::vector<unsigned int>::iterator it = m_widthOfTextInColumns.begin(); it != m_widthOfTextInColumns.end(); ++it, ++k) { if ( *it < *k ) *it = *k; else *k = *it; } } m_tableWidth=0; for(std::vector<unsigned int>::const_iterator it = m_widthOfTextInColumns.begin(), itEnd = m_widthOfTextInColumns.end(); it!=itEnd; ++it){ m_tableWidth +=*it+kTextBuffer+kTextBuffer+kSeperatorWidth; } m_tableWidth +=kSeperatorWidth; }
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 184 of file FWTabularWidget.cc.
References kSeperatorWidth, kTextBuffer, m_hOffset, m_table, m_tableWidth, m_textHeight, m_vOffset, m_widthOfTextInColumns, and FWTableManagerBase::numberOfRows().
Referenced by DoRedraw(), and HandleButton().
{ if( iX < 0 ) { oCol = -1; oRelX = 0; } else { if(iX+static_cast<Int_t>(m_hOffset) > static_cast<Int_t>(m_tableWidth) ) { oCol = m_widthOfTextInColumns.size(); oRelX = 0; } else { iX +=m_hOffset; oCol = 0; for(std::vector<unsigned int>::const_iterator it = m_widthOfTextInColumns.begin(), itEnd = m_widthOfTextInColumns.end(); it!=itEnd; ++it,++oCol){ oRelX=iX-kTextBuffer; iX-=2*kTextBuffer+kSeperatorWidth+*it; if(iX <= 0) { break; } } } } if( iY < 0) { oRow = -1; oRelY=0; } else { oRow = (int)(float(iY+m_vOffset)/(m_textHeight+2*kTextBuffer+kSeperatorWidth)); oRelY = iY-oRow*(m_textHeight+2*kTextBuffer+kSeperatorWidth)+m_vOffset-kTextBuffer; Int_t numRows = m_table->numberOfRows(); if(oRow > numRows) { oRow = numRows; oRelY=0; } } }
UInt_t FWTabularWidget::verticalOffset | ( | ) | const [inline] |
const std::vector<unsigned int>& FWTabularWidget::widthOfTextInColumns | ( | ) | const [inline] |
Definition at line 44 of file FWTabularWidget.h.
References m_widthOfTextInColumns.
Referenced by FWTableWidget::dataChanged(), and FWTableWidget::FWTableWidget().
{ return m_widthOfTextInColumns;}
const int FWTabularWidget::kSeperatorWidth = 1 [static] |
Definition at line 38 of file FWTabularWidget.h.
Referenced by DoRedraw(), FWTabularWidget(), GetDefaultSize(), setWidthOfTextInColumns(), and translateToRowColumn().
const int FWTabularWidget::kTextBuffer = 2 [static] |
Definition at line 37 of file FWTabularWidget.h.
Referenced by DoRedraw(), FWTextTableCellRenderer::draw(), FWTextTreeCellRenderer::draw(), FWGeometryTableManager::ColorBoxRenderer::draw(), FWTabularWidget(), GetDefaultSize(), setWidthOfTextInColumns(), and translateToRowColumn().
GContext_t FWTabularWidget::m_backgroundGC [private] |
Definition at line 92 of file FWTabularWidget.h.
Referenced by DoRedraw(), and setBackgroundAreaContext().
bool FWTabularWidget::m_growInWidth [private] |
Definition at line 94 of file FWTabularWidget.h.
Referenced by disableGrowInWidth(), and setWidthOfTextInColumns().
unsigned int FWTabularWidget::m_hOffset [private] |
Definition at line 89 of file FWTabularWidget.h.
Referenced by DoRedraw(), horizontalOffset(), setHorizontalOffset(), and translateToRowColumn().
GContext_t FWTabularWidget::m_normGC [private] |
Definition at line 91 of file FWTabularWidget.h.
Referenced by DoRedraw(), and setLineContext().
FWTableManagerBase* FWTabularWidget::m_table [private] |
Definition at line 82 of file FWTabularWidget.h.
Referenced by dataChanged(), DoRedraw(), FWTabularWidget(), GetDefaultSize(), HandleButton(), setWidthOfTextInColumns(), translateToRowColumn(), and ~FWTabularWidget().
int FWTabularWidget::m_tableWidth [private] |
Definition at line 86 of file FWTabularWidget.h.
Referenced by DoRedraw(), FWTabularWidget(), GetDefaultSize(), setWidthOfTextInColumns(), and translateToRowColumn().
int FWTabularWidget::m_textHeight [private] |
Definition at line 85 of file FWTabularWidget.h.
Referenced by dataChanged(), DoRedraw(), FWTabularWidget(), GetDefaultSize(), and translateToRowColumn().
unsigned int FWTabularWidget::m_vOffset [private] |
Definition at line 88 of file FWTabularWidget.h.
Referenced by DoRedraw(), setVerticalOffset(), translateToRowColumn(), and verticalOffset().
std::vector<unsigned int> FWTabularWidget::m_widthOfTextInColumns [private] |
Definition at line 83 of file FWTabularWidget.h.
Referenced by DoRedraw(), FWTabularWidget(), setWidthOfTextInColumns(), translateToRowColumn(), and widthOfTextInColumns().
std::vector<unsigned int> FWTabularWidget::m_widthOfTextInColumnsMax [private] |
Definition at line 84 of file FWTabularWidget.h.
Referenced by setWidthOfTextInColumns().