items[index] = item;
itemCount++;
- if (itemCount == 1 &&isCheck) {
+ if (itemCount == 1 && isCheck) {
checkBox.setEnabled(true);
}
- adjustItemIndices( index );
+ adjustItemIndices(index);
// advance focusIndex when an item is inserted before the focused item
if( index <= focusIndex ) {
}
setTableSize();
+
}
void computeTableSize() {
if (hVisible) {
tableHeight += this.getScrollBarWidth();
}
- int width = Math.max(tableWidth, rect.width);
- int height = Math.max(tableHeight, rect.height);
+ tableWidth = Math.max(tableWidth, rect.width);
+ tableHeight = Math.max(tableHeight, rect.height);
+
+ table.setSize(tableWidth, tableHeight);
+
+ if (tableColumn.getBounds().width != tableWidth) {
+ tableColumn.setBounds(0, 0, tableWidth, columnHeight);
+ }
- table.setSize(width, height);
- tableColumn.setBounds(0, 0, width, columnHeight);
- tableItem.setBounds(0, columnHeight, width, height - columnHeight);
+ if (tableItem.getBounds().width != tableWidth) {
+ tableItem.setBounds(0, columnHeight, tableWidth, tableHeight - columnHeight);
+ for (TableItem item : items) {
+ if (item != null) {
+ item.updateSizeAndLocation(-1);
+ }
+ }
+ }
- if (rect.width == width && rect.height == height) {
+ if (rect.width == tableWidth && rect.height == tableHeight) {
redraw();
}
// for table item
int getTableWidth() {
- return table.getSize().x;
+ return tableWidth;
}
public void showColumn(TableColumn column) {}
@Override
public void paintControl(PaintEvent e) {
Rectangle rect= ((Composite)e.widget).getClientArea();
-
GC gc = e.gc;
int top = 0;
int height = getItemHeight();
private boolean checked;
private boolean grayed;
- private int index;
+ private int index = -1;
//private boolean isHoverState = false;
private boolean isSelected = false;
public TableItem(final Table parent, int style, int index) {
super(parent.tableItem, style);
this.parent = parent;
- this.index = index;
+ //this.index = index;
makeTableItemCanvas();
}
}
- @Override
- public Rectangle getBounds() {
- return getBounds(0);
- }
-
public Rectangle getBounds(int index) {
checkWidget();
if (!parent.checkData(this, parent.indexOf(this))) {
width += parent.getColumn(i).getWidth();
}
+ if (parent.isChecked()) {
+ width += parent.getCheckBoxWidth();
+ }
+
width = Math.max(width, parent.getTableWidth());
int top = getTop(index);
int height = getHeight();