field.setInactiveColorKey("ttable.inactive");
}
+ assert (isVisible() == true);
+
super.draw();
}
activate(columns.get(selectedColumn).get(selectedRow));
alignGrid();
+
+ // Set the menu to match the flags.
+ getApplication().getMenuItem(TMenu.MID_TABLE_VIEW_ROW_LABELS).
+ setChecked(showRowLabels);
+ getApplication().getMenuItem(TMenu.MID_TABLE_VIEW_COLUMN_LABELS).
+ setChecked(showColumnLabels);
+ getApplication().getMenuItem(TMenu.MID_TABLE_VIEW_HIGHLIGHT_ROW).
+ setChecked(highlightRow);
+ getApplication().getMenuItem(TMenu.MID_TABLE_VIEW_HIGHLIGHT_COLUMN).
+ setChecked(highlightColumn);
+
+
}
// ------------------------------------------------------------------------
@Override
public void onMenu(final TMenuEvent menu) {
switch (menu.getId()) {
+ case TMenu.MID_TABLE_VIEW_ROW_LABELS:
+ showRowLabels = getApplication().getMenuItem(menu.getId()).getChecked();
+ break;
+ case TMenu.MID_TABLE_VIEW_COLUMN_LABELS:
+ showColumnLabels = getApplication().getMenuItem(menu.getId()).getChecked();
+ break;
+ case TMenu.MID_TABLE_VIEW_HIGHLIGHT_ROW:
+ highlightRow = getApplication().getMenuItem(menu.getId()).getChecked();
+ break;
+ case TMenu.MID_TABLE_VIEW_HIGHLIGHT_COLUMN:
+ highlightColumn = getApplication().getMenuItem(menu.getId()).getChecked();
+ break;
case TMenu.MID_TABLE_BORDER_NONE:
case TMenu.MID_TABLE_BORDER_ALL:
case TMenu.MID_TABLE_BORDER_RIGHT:
default:
super.onMenu(menu);
}
+
+ alignGrid();
}
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
/**
- * Draw the table row/column headings, and borders.
+ * Draw the table row/column labels, and borders.
*/
@Override
public void draw() {
- CellAttributes headingColor = getTheme().getColor("ttable.heading");
- CellAttributes headingColorSelected = getTheme().getColor("ttable.heading.selected");
+ CellAttributes labelColor = getTheme().getColor("ttable.label");
+ CellAttributes labelColorSelected = getTheme().getColor("ttable.label.selected");
CellAttributes borderColor = getTheme().getColor("ttable.border");
// Column labels.
}
putStringXY(columns.get(i).get(top).getX(), 0,
String.format(" %-6s ", columns.get(i).label),
- (i == selectedColumn ? headingColorSelected : headingColor));
+ (i == selectedColumn ? labelColorSelected : labelColor));
}
}
}
putStringXY(0, rows.get(i).get(left).getY(),
String.format(" %-6s ", rows.get(i).label),
- (i == selectedRow ? headingColorSelected : headingColor));
+ (i == selectedRow ? labelColorSelected : labelColor));
}
}
// Adjust X locations to be visible -----------------------------------
// Determine if we need to shift left or right.
- int width = getMaximumWidth();
int leftCellX = 0;
if (showRowLabels == true) {
// For now, all row labels are 8 cells wide. TODO: make this
// The same logic as above, but applied to the column Y.
// Determine if we need to shift up or down.
- int height = getMaximumHeight();
int topCellY = 0;
if (showColumnLabels == true) {
// For now, all column labels are 1 cell high. TODO: make this
* selected cell Y is topCellY.
*/
for (int x = 0; x < columns.size(); x++) {
- if (columns.get(x).cells.get(0).isVisible() == false) {
- // This entire column will not be visible, as determined by
- // the width checks above. Do no further processing.
- break;
+
+ if (columns.get(x).get(0).isVisible() == false) {
+ // This column won't be visible as determined by the checks
+ // above, just continue to the next.
+ continue;
}
// All cells above the selected cell.
// Selected cell.
columns.get(x).cells.get(selectedRow).setY(topCellY);
- assert (columns.get(x).cells.get(selectedRow).isVisible());
// All cells below the selected cell.
newCellY = topCellY + selectedRowCell.getHeight();