Пример #1
0
 void unhookRowColumnListeners() {
   if (column != null) {
     column.removeListener(SWT.Dispose, disposeColumnListener);
     column.removeListener(SWT.Move, resizeListener);
     column.removeListener(SWT.Resize, resizeListener);
     column = null;
   }
   if (row != null) {
     row.removeListener(SWT.Dispose, disposeItemListener);
     row = null;
   }
 }
Пример #2
0
 void setRowColumn(TableItem row, TableColumn column, boolean notify) {
   if (this.row == row && this.column == column) {
     return;
   }
   if (this.row != null && this.row != row) {
     this.row.removeListener(SWT.Dispose, disposeItemListener);
     this.row = null;
   }
   if (this.column != null && this.column != column) {
     this.column.removeListener(SWT.Dispose, disposeColumnListener);
     this.column.removeListener(SWT.Move, resizeListener);
     this.column.removeListener(SWT.Resize, resizeListener);
     this.column = null;
   }
   if (row != null) {
     if (this.row != row) {
       this.row = row;
       row.addListener(SWT.Dispose, disposeItemListener);
       table.showItem(row);
     }
     if (this.column != column && column != null) {
       this.column = column;
       column.addListener(SWT.Dispose, disposeColumnListener);
       column.addListener(SWT.Move, resizeListener);
       column.addListener(SWT.Resize, resizeListener);
       table.showColumn(column);
     }
     int columnIndex = column == null ? 0 : table.indexOf(column);
     setBounds(row.getBounds(columnIndex));
     redraw();
     if (notify) {
       notifyListeners(SWT.Selection, new Event());
     }
   }
   getAccessible().setFocus(ACC.CHILDID_SELF);
 }
Пример #3
0
 void paint(Event event) {
   if (row == null) return;
   int columnIndex = column == null ? 0 : table.indexOf(column);
   GC gc = event.gc;
   gc.setBackground(getBackground());
   gc.setForeground(getForeground());
   gc.fillRectangle(event.x, event.y, event.width, event.height);
   int x = 0;
   Point size = getSize();
   Image image = row.getImage(columnIndex);
   if (image != null) {
     Rectangle imageSize = image.getBounds();
     int imageY = (size.y - imageSize.height) / 2;
     gc.drawImage(image, x, imageY);
     x += imageSize.width;
   }
   String text = row.getText(columnIndex);
   if (text.length() > 0) {
     Rectangle bounds = row.getBounds(columnIndex);
     Point extent = gc.stringExtent(text);
     // Temporary code - need a better way to determine table trim
     String platform = SWT.getPlatform();
     if ("win32".equals(platform)) { // $NON-NLS-1$
       if (table.getColumnCount() == 0 || columnIndex == 0) {
         x += 2;
       } else {
         int alignmnent = column.getAlignment();
         switch (alignmnent) {
           case SWT.LEFT:
             x += 6;
             break;
           case SWT.RIGHT:
             x = bounds.width - extent.x - 6;
             break;
           case SWT.CENTER:
             x += (bounds.width - x - extent.x) / 2;
             break;
         }
       }
     } else {
       if (table.getColumnCount() == 0) {
         x += 5;
       } else {
         int alignmnent = column.getAlignment();
         switch (alignmnent) {
           case SWT.LEFT:
             x += 5;
             break;
           case SWT.RIGHT:
             x = bounds.width - extent.x - 2;
             break;
           case SWT.CENTER:
             x += (bounds.width - x - extent.x) / 2 + 2;
             break;
         }
       }
     }
     int textY = (size.y - extent.y) / 2;
     gc.drawString(text, x, textY);
   }
   if (isFocusControl()) {
     Display display = getDisplay();
     gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
     gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
     gc.drawFocus(0, 0, size.x, size.y);
   }
 }