Composite table = null;
Composite tableItem = null;
Composite tableColumn = null;
- private int width = 0;
private int tableWidth = 0;
private int tableHeight = 0;
focusIndex = -1;
sortDirection = SWT.None;
- setTableEmpty();
if ((style & SWT.CHECK) != 0) {
isCheck = true;
}
+ setTableEmpty();
+
addListener();
}
int width = Math.max(tableWidth, rect.width);
int height = Math.max(tableHeight, rect.height);
-
-
table.setSize(width, height);
- tableColumn.setBounds(0, 0, width, 30);
+ if (rect.width == width && rect.height == height) {
+ redraw();
+ }
+ tableColumn.setBounds(0, 0, width, columnHeight);
tableItem.setBounds(0, columnHeight, width, height - columnHeight);
}
return width;
}
- int getWidth() {
- return width;
+ // for table item
+ int getTableWidth() {
+ return table.getSize().x;
}
public void showColumn(TableColumn column) {}
@Override
public void controlResized(ControlEvent e) {
updateScrollBars(false);
-
- for (TableItem item : items) {
- if (item != null) {
- item.updateSizeAndLocation(-1);
- }
- }
}
};
@Override
public void paintControl(PaintEvent e) {
Rectangle rect= ((Composite)e.widget).getClientArea();
- width = rect.width;
GC gc = e.gc;
if (headerVisible) {
@Override
public void paintControl(PaintEvent e) {
Rectangle rect= ((Composite)e.widget).getClientArea();
- width = rect.width;
GC gc = e.gc;
int top = 0;
}
this.width = width;
- setBounds(getLeft(), getBounds().y, width, parent.getColumnHeightSize());
+ setBounds(getLeft(), 0, width, parent.getColumnHeightSize());
parent.updateScrollBars(true);
processNextColumnsMoveEvent();
}
return;
}
- TableColumn column = (TableColumn) event.widget;
if (event.type == SWT.MouseEnter) {
isHoverState = true;
redraw();
isResizeableState = false;
if (setCursor) {
setCursor = false;
- column.setCursor(backupCursor);
+ setCursor(backupCursor);
}
}
- // TODO
- column.redraw();
- column.update();
+ redraw();
+ update();
} else if (event.type == SWT.MouseMove) {
if (!resizable) {
return;
isResizeableState = true;
if (!setCursor) {
setCursor = true;
- backupCursor = column.getCursor();
- column.setCursor(new Cursor(Display.getCurrent(), SWT.CURSOR_SIZEWE));
+ backupCursor = getCursor();
+ setCursor(new Cursor(Display.getCurrent(), SWT.CURSOR_SIZEWE));
}
} else {
isResizeableState = false;
if (setCursor) {
setCursor = false;
- column.setCursor(backupCursor);
+ setCursor(backupCursor);
}
}
if (isResizedState) {
if (event.x > MIN_WIDTH) {
setWidth(event.x);
- redraw();
}
}
}
@Override
public void controlResized(ControlEvent e) {
needRedrawingText = true;
- parent.redraw();
for (TableItem item : parent.getItems()) {
if (item != null) {
item.updateSizeAndLocation(getOrderIndex());
}
}
- redraw();
}
};
public void mouseDoubleClick(MouseEvent e) {
if (isResizeableState) {
setWidth(getPreferredWidth());
- redraw();
}
}
Font font;
Color backgroundColor;
Color foregroundColor;
+ int textWidth = -1;
// for drawing table item
- int textWidth = -1;
+ int drawingTextWidth = 0;
boolean needRedrawingText = true;
String drawingText = "";
result = new Rectangle(0, 0, 0, 0);
} else {
int left = getLeft(index);
- int top = getTop(parent.indexOf(this));
+ int top = getTop(this.index);
int width = 0;
if (index == 0 && columnCount == 0) {
int spacing = getSpacing(index);
if (rect.width == 0) {
updateSizeAndLocation(-1);
} else {
- setBounds(new Rectangle(rect.x, getTop(index), rect.width, rect.height));
+ setLocation(rect.x, getTop(index));
}
}
int width = 0;
for (int i = 0; i < parent.getColumnCount(); i++) {
- width += getBounds(i).width;
+ width += parent.getColumn(i).getWidth();
}
- width = Math.max(width, parent.getWidth());
+ width = Math.max(width, parent.getTableWidth());
int top = getTop(index);
int height = getHeight();
GC gc = e.gc;
Rectangle rect = ((Composite)e.widget).getClientArea();
-
int imageX = rect.x;
int textX = rect.x;
int imageY = rect.y;
}
data.needRedrawingText = false;
data.drawingText = drawingText;
- data.textWidth = TextSizeUtil.textExtent(getFont(), drawingText);
+ data.drawingTextWidth = TextSizeUtil.textExtent(getFont(), drawingText);
}
switch(item.getParent().getColumn(index).getAlignment()) {
break;
case SWT.RIGHT:
imageX += (image != null
- ? rect.width - imageSize.x - data.textWidth - 10
- : rect.width - data.textWidth - 10);
+ ? rect.width - imageSize.x - data.drawingTextWidth - 10
+ : rect.width - data.drawingTextWidth - 10);
textX += imageX + imageSize.x + 5;
break;
case SWT.CENTER:
imageX += (image != null
- ? (rect.width - imageSize.x - data.textWidth) / 2 + 5
- : (rect.width - data.textWidth) / 2) - 5;
+ ? (rect.width - imageSize.x - data.drawingTextWidth) / 2 + 5
+ : (rect.width - data.drawingTextWidth) / 2) - 5;
textX += imageX + imageSize.x + 5;
break;
default: