3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS
14 #pragma implementation
17 #include "emptytable.h"
20 * A simple widget for a quick "preview" in TabularCreateDialog
23 unsigned int const cellsize = 20;
26 EmptyTable::EmptyTable(QWidget * parent, const char * name)
27 : QtTableView(parent, name, WRepaintNoErase)
31 setCellWidth(cellsize);
32 setCellHeight(cellsize);
33 setTableFlags(Tbl_autoScrollBars);
37 QSize EmptyTable::sizeHint() const
39 return QSize(cellsize * numCols(), cellsize * numRows());
43 void EmptyTable::paintCell(QPainter * p, int row, int col)
45 int const x2 = cellWidth(col) - 1;
46 int const y2 = cellHeight(row) - 1;
48 p->fillRect(0, 0, x2, y2, QColor("white"));
49 p->drawLine(x2, 0, x2, y2);
50 p->drawLine(0, y2, x2, y2);
52 if (row + 1 != numRows() || col + 1 != numCols())
56 int const step = cellsize / 5;
58 int x = cellsize - step;
59 int const y = cellsize - space;
60 int const ex = cellsize - space;
61 int ey = cellsize - step;
63 p->drawLine(x, y, ex, ey);
70 void EmptyTable::setNumberColumns(int nr_cols)
74 if (nr_cols == numCols())
81 emit colsChanged(nr_cols);
85 void EmptyTable::setNumberRows(int nr_rows)
89 if (nr_rows == numRows())
96 emit rowsChanged(nr_rows);
100 void EmptyTable::mouseMoveEvent(QMouseEvent *ev)
102 int const x = ev->pos().x();
103 int const y = ev->pos().y();
106 setNumberColumns(x / cellsize + leftCell());
109 setNumberRows(y / cellsize + topCell());