Example #1
0
 /**
  * Returns a rectangle describing the receiver's size and location relative to its parent at a
  * column in the table.
  *
  * @param index the index that specifies the column
  * @return the receiver's bounding column rectangle
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public Rectangle getBounds(final int index) {
   checkWidget();
   if (!parent.checkData(this, parent.indexOf(this))) {
     error(SWT.ERROR_WIDGET_DISPOSED);
   }
   Rectangle result;
   int columnCount = parent.getColumnCount();
   if (columnCount > 0 && (index < 0 || index >= columnCount)) {
     result = new Rectangle(0, 0, 0, 0);
   } else {
     Rectangle textBounds = getTextBounds(index);
     int left = getLeft(index);
     int itemIndex = parent.indexOf(this);
     int top = getTop(itemIndex);
     int width = 0;
     if (index == 0 && columnCount == 0) {
       Rectangle imageBounds = getImageBounds(index);
       int spacing = getSpacing(index);
       int paddingWidth = parent.getCellPadding().width;
       width = imageBounds.width + spacing + textBounds.width + paddingWidth;
     } else if (index >= 0 && index < columnCount) {
       width = parent.getColumn(index).getWidth() - getCheckWidth(index);
     }
     int height = getHeight(index);
     result = new Rectangle(left, top, width, height);
   }
   return result;
 }
Example #2
0
 /**
  * Returns a rectangle describing the size and location relative to its parent of an image at a
  * column in the table. An empty rectangle is returned if index exceeds the index of the table's
  * last column.
  *
  * @param index the index that specifies the column
  * @return the receiver's bounding image rectangle
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public Rectangle getImageBounds(final int index) {
   checkWidget();
   if (!parent.checkData(this, parent.indexOf(this))) {
     error(SWT.ERROR_WIDGET_DISPOSED);
   }
   int itemIndex = parent.indexOf(this);
   Rectangle cellPadding = parent.getCellPadding();
   int left = getLeft(index) + cellPadding.x;
   int top = getTop(itemIndex);
   int width = getImageWidth(index);
   int height = getHeight(index);
   return new Rectangle(left, top, width, height);
 }
Example #3
0
 /**
  * Returns a rectangle describing the size and location relative to its parent of the text at a
  * column in the table. An empty rectangle is returned if index exceeds the index of the table's
  * last column.
  *
  * @param index the index that specifies the column
  * @return the receiver's bounding text rectangle
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public Rectangle getTextBounds(final int index) {
   checkWidget();
   int itemIndex = parent.indexOf(this);
   if (!parent.checkData(this, itemIndex)) {
     error(SWT.ERROR_WIDGET_DISPOSED);
   }
   int left = 0;
   int top = 0;
   int width = 0;
   Rectangle cellPadding = parent.getCellPadding();
   if (index == 0 && parent.getColumnCount() == 0) {
     int imageWidth = 0;
     int spacing = 0;
     if (parent.hasColumnImages(0)) {
       imageWidth = parent.getItemImageSize().x;
       spacing = getSpacing(0);
     }
     left = getLeft(0) + cellPadding.x + imageWidth + spacing;
     top = getTop(itemIndex);
     Font font = getFont();
     width = Graphics.stringExtent(font, getText(0)).x;
   } else if (itemIndex != -1 && index < parent.getColumnCount()) {
     int imageWidth = 0;
     if (parent.hasColumnImages(index)) {
       imageWidth = parent.getItemImageSize().x;
     }
     int spacing = getSpacing(index);
     left = getLeft(index) + cellPadding.x + imageWidth + spacing;
     top = getTop(itemIndex);
     width = getColumnWidth(index) - cellPadding.width - imageWidth - spacing;
     if (width < 0) {
       width = 0;
     }
   }
   int height = getHeight(index);
   return new Rectangle(left, top, width, height);
 }
Example #4
0
 final int getPackWidth(final int index) {
   return getImageWidth(index)
       + getSpacing(index)
       + getTextWidth(index)
       + parent.getCellPadding().width;
 }