void HexView::paint(QPainter *painter) { int left = 0; int firstRow = getRowForY( viewport_.y() ) - 1; int lastRow = getRowForY( viewport_.y() + viewport_.height() ) + 1; if (firstRow < 0) firstRow = 0; if (lastRow > rowCount() ) lastRow = rowCount(); painter->setFont(QFont("Courier")); qDebug() << "contentlength=" << contentLength() << " firstrow=" << firstRow << " lastRow=" << lastRow << " viewport=" << viewport_; if (showGuidelines_) { QPen backpen(QColor(255,0,0)); painter->setPen(backpen); //painter->drawRect(viewport_); } if (showOffsets()) { paintOffsets(painter,left,firstRow,lastRow); } if (showHex()) { paintHex(painter,left,firstRow,lastRow); } if (showAscii()) { paintAscii(painter,left,firstRow,lastRow); } }
void GuiTable::mouseDragged(gcn::MouseEvent& mouseEvent) { if (mouseEvent.getButton() != gcn::MouseEvent::LEFT) return; // Make table selection update on drag const int x = std::max(0, mouseEvent.getX()); const int y = std::max(0, mouseEvent.getY()); setSelectedRow(getRowForY(y)); setSelectedColumn(getColumnForX(x)); }
// -- MouseListener notifications void GuiTable::mousePressed(gcn::MouseEvent& mouseEvent) { if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) { int row = getRowForY(mouseEvent.getY()); int column = getColumnForX(mouseEvent.getX()); if (row > -1 && column > -1 && row < mModel->getRows() && column < mModel->getColumns()) { mSelectedColumn = column; mSelectedRow = row; } distributeActionEvent(); } }
gcn::Widget *GuiTable::getWidgetAt(int x, int y) const { int row = getRowForY(y); int column = getColumnForX(x); if (mTopWidget && mTopWidget->getDimension().isPointInRect(x, y)) return mTopWidget; if (row > -1 && column > -1) { gcn::Widget *w = mModel->getElementAt(row, column); if (w && w->isFocusable()) return w; else return NULL; // Grab the event locally } else return NULL; }
// -- MouseListener notifications void GuiTable::mousePressed(MouseEvent& event) { if (!mSelectable) return; if (event.getButton() == MouseButton::LEFT) { const int row = getRowForY(event.getY()); const int column = getColumnForX(event.getX()); if (row > -1 && column > -1 && row < mModel->getRows() && column < mModel->getColumns()) { mSelectedColumn = column; mSelectedRow = row; event.consume(); } distributeActionEvent(); } }