use of de.jaret.util.ui.table.model.IColumn in project translationstudio8 by heartsome.
the class JaretTable method getTotalWidth.
/**
* Retrieve total width of the first n columns.
*
* @param n number of colums to take into account
* @return sum of the first n column withs
*/
public int getTotalWidth(int n) {
if (_cols != null) {
int width = 0;
for (int i = 0; i < n; i++) {
IColumn col = _cols.get(i);
width += _tvs.getColumnWidth(col);
}
return width;
} else {
return 0;
}
}
use of de.jaret.util.ui.table.model.IColumn in project translationstudio8 by heartsome.
the class JaretTable method getCell.
/**
* Retrieve TableXCell for given pixel coordinates.
*
* @param x pixel coordinate x
* @param y pixel coordinate y
* @return table cel if found or <code>null</code> if no cell can be found
*/
public IJaretTableCell getCell(int x, int y) {
if (_tableRect.contains(x, y)) {
IRow row = rowForY(y);
IColumn col = colForX(x);
if (row == null || col == null) {
return null;
}
return new JaretTableCellImpl(row, col);
}
return null;
}
use of de.jaret.util.ui.table.model.IColumn in project translationstudio8 by heartsome.
the class JaretTable method drawHeader.
/**
* Draw the table header.
*
* @param gc gc
* @param width width of the table
* @param height height of the table
*/
private void drawHeader(GC gc, int width, int height) {
if (_headerRenderer != null && _drawHeader) {
// draw headers for fixed columns
for (int cIdx = 0; cIdx < _fixedColumns; cIdx++) {
int x = getAbsBeginXForColIdx(cIdx);
IColumn col = _cols.get(cIdx);
int colwidth = _tvs.getColumnWidth(col);
// fixed cols may render wherever they want if they disable clipping
if (!_headerRenderer.disableClipping()) {
gc.setClipping(x, _headerRect.y, colwidth, _headerRect.height);
}
// column may indicate that no header should be painted
if (col.displayHeader()) {
drawHeader(gc, x, colwidth, col);
}
}
// draw headers table area
int x = -_firstColPixelOffset;
x += _tableRect.x;
int cIdx = _firstColIdx;
while (x < getWidth() && cIdx < _cols.size()) {
IColumn col = _cols.get(cIdx);
int colwidth = _tvs.getColumnWidth(col);
int xx = x > _headerRect.x ? x : _headerRect.x;
int clipWidth = x > _headerRect.x ? colwidth : colwidth - _firstColPixelOffset;
if (!_headerRenderer.disableClipping()) {
gc.setClipping(xx, _headerRect.y, clipWidth, _headerRect.height);
} else if (_fixedColumns > 0) {
// if fixed columns are present the header renderer of ordinary columns may not interfere with the
// fixed region
gc.setClipping(xx, _headerRect.y, _tableRect.width - xx, _headerRect.height);
}
// column may indicate that no header should be painted
if (col.displayHeader()) {
drawHeader(gc, x, colwidth, col);
}
x += colwidth;
cIdx++;
}
}
}
use of de.jaret.util.ui.table.model.IColumn in project translationstudio8 by heartsome.
the class JaretTable method getColIdxForAbsX.
/**
* Return the (internal) index of the column corresponding to the given x coordinate value (absolute value taking
* all visible columns into account).
*
* @param absX absolute x coordinate
* @return the column index in the internal list of columns (or -1 if none could be determined)
*/
public int getColIdxForAbsX(int absX) {
int idx = 0;
int x = 0;
while (x <= absX && idx < _cols.size()) {
IColumn col = _cols.get(idx);
int colWidth = _tvs.getColumnWidth(col);
x += colWidth;
idx++;
}
return idx < _cols.size() ? idx - 1 : -1;
}
use of de.jaret.util.ui.table.model.IColumn in project translationstudio8 by heartsome.
the class SimpleJaretTableModel method setValueAt.
/**
* Set a value.
*
* @param colIdx index of the column (x)
* @param rowIdx index of the row (y)
* @param value value
*/
public void setValueAt(int colIdx, int rowIdx, Object value) {
IColumn col = getColumn(colIdx);
IRow row = getRow(rowIdx);
col.setValue(row, value);
}
Aggregations