コード例 #1
0
 Point minimumSize(int wHint, int hHint, boolean flushCache) {
   Control[] children = _getChildren();
   int width = 0, height = 0;
   for (int i = 0; i < children.length; i++) {
     Control child = children[i];
     int index = 0;
     int count = 0;
     long /*int*/ list = OS.gtk_container_get_children(handle);
     if (list != 0) {
       count = OS.g_list_length(list);
       OS.g_list_free(list);
     }
     while (index < count) {
       if (items[index].control == child) break;
       index++;
     }
     if (index == count) {
       Rectangle rect = child.getBounds();
       width = Math.max(width, rect.x + rect.width);
       height = Math.max(height, rect.y + rect.height);
     } else {
       Point size = child.computeSize(wHint, hHint, flushCache);
       width = Math.max(width, size.x);
       height = Math.max(height, size.y);
     }
   }
   return new Point(width, height);
 }
コード例 #2
0
 public Point computeSize(int wHint, int hHint, boolean changed) {
   checkWidget();
   Point size = super.computeSize(wHint, hHint, changed);
   if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
   if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
   boolean scrollable = OS.gtk_notebook_get_scrollable(handle);
   OS.gtk_notebook_set_scrollable(handle, false);
   Point notebookSize = computeNativeSize(handle, wHint, hHint, changed);
   OS.gtk_notebook_set_scrollable(handle, scrollable);
   size.x = Math.max(notebookSize.x, size.x);
   size.y = Math.max(notebookSize.y, size.y);
   return size;
 }
コード例 #3
0
  /**
   * Sets the font that the receiver will use to paint textual information for the specified cell in
   * this item to the font specified by the argument, or to the default font for that kind of
   * control if the argument is null.
   *
   * @param index the column index
   * @param font the new font (or null)
   * @exception IllegalArgumentException
   *     <ul>
   *       <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed
   *     </ul>
   *
   * @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>
   *
   * @since 3.0
   */
  public void setFont(int index, Font font) {
    checkWidget();
    if (font != null && font.isDisposed()) {
      SWT.error(SWT.ERROR_INVALID_ARGUMENT);
    }
    int count = Math.max(1, parent.getColumnCount());
    if (0 > index || index > count - 1) return;
    if (cellFont == null) {
      if (font == null) return;
      cellFont = new Font[count];
    }
    Font oldFont = cellFont[index];
    if (oldFont == font) return;
    cellFont[index] = font;
    if (oldFont != null && oldFont.equals(font)) return;

    int modelIndex =
        parent.columnCount == 0 ? Table.FIRST_COLUMN : parent.columns[index].modelIndex;
    int /*long*/ fontHandle = font != null ? font.handle : 0;
    OS.gtk_list_store_set(parent.modelHandle, handle, modelIndex + Table.CELL_FONT, fontHandle, -1);
    /*
     * Bug in GTK.  When using fixed-height-mode,
     * row changes do not cause the row to be repainted.  The fix is to
     * invalidate the row when it is cleared.
     */
    if ((parent.style & SWT.VIRTUAL) != 0) {
      if (OS.GTK_VERSION >= OS.VERSION(2, 3, 2) && OS.GTK_VERSION < OS.VERSION(2, 6, 3)) {
        redraw();
      }
    }
    cached = true;

    if (font != null) {
      boolean customDraw =
          (parent.columnCount == 0) ? parent.firstCustomDraw : parent.columns[index].customDraw;
      if (!customDraw) {
        if ((parent.style & SWT.VIRTUAL) == 0) {
          int /*long*/ parentHandle = parent.handle;
          int /*long*/ column = 0;
          if (parent.columnCount > 0) {
            column = parent.columns[index].handle;
          } else {
            column = OS.gtk_tree_view_get_column(parentHandle, index);
          }
          if (column == 0) return;
          int /*long*/ textRenderer = parent.getTextRenderer(column);
          int /*long*/ imageRenderer = parent.getPixbufRenderer(column);
          OS.gtk_tree_view_column_set_cell_data_func(
              column, textRenderer, display.cellDataProc, parentHandle, 0);
          OS.gtk_tree_view_column_set_cell_data_func(
              column, imageRenderer, display.cellDataProc, parentHandle, 0);
        }
        if (parent.columnCount == 0) {
          parent.firstCustomDraw = true;
        } else {
          parent.columns[index].customDraw = true;
        }
      }
    }
  }
コード例 #4
0
ファイル: ProgressBar.java プロジェクト: neelance/swt4ruby
 /**
  * Sets the minimum value that the receiver will allow. This new value will be ignored if it is
  * negative or is not less than the receiver's current maximum value. If the new minimum is
  * applied then the receiver's selection value will be adjusted if necessary to fall within its
  * new range.
  *
  * @param value the new minimum, which must be nonnegative and less than the current maximum
  * @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 void setMinimum(int value) {
   checkWidget();
   if (value < 0 || value >= maximum) return;
   minimum = value;
   selection = Math.max(selection, minimum);
   updateBar(selection, minimum, maximum);
 }
コード例 #5
0
 /**
  * Returns the font that the receiver will use to paint textual information for the specified cell
  * in this item.
  *
  * @param index the column index
  * @return the receiver's font
  * @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>
  *
  * @since 3.0
  */
 public Font getFont(int index) {
   checkWidget();
   if (!parent.checkData(this)) error(SWT.ERROR_WIDGET_DISPOSED);
   int count = Math.max(1, parent.columnCount);
   if (0 > index || index > count - 1) return getFont();
   if (cellFont == null || cellFont[index] == null) return getFont();
   return cellFont[index];
 }
コード例 #6
0
 /**
  * Sets the receiver's image at a column.
  *
  * @param index the column index
  * @param image the new image
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_INVALID_ARGUMENT - if the image has been disposed
  *     </ul>
  *
  * @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 void setImage(int index, Image image) {
   checkWidget();
   if (image != null && image.isDisposed()) {
     error(SWT.ERROR_INVALID_ARGUMENT);
   }
   if (image != null && image.type == SWT.ICON) {
     if (image.equals(_getImage(index))) return;
   }
   int count = Math.max(1, parent.getColumnCount());
   if (0 > index || index > count - 1) return;
   int /*long*/ pixbuf = 0;
   if (image != null) {
     ImageList imageList = parent.imageList;
     if (imageList == null) imageList = parent.imageList = new ImageList();
     int imageIndex = imageList.indexOf(image);
     if (imageIndex == -1) imageIndex = imageList.add(image);
     pixbuf = imageList.getPixbuf(imageIndex);
   }
   int modelIndex =
       parent.columnCount == 0 ? Table.FIRST_COLUMN : parent.columns[index].modelIndex;
   OS.gtk_list_store_set(parent.modelHandle, handle, modelIndex + Table.CELL_PIXBUF, pixbuf, -1);
   /*
    * Bug in GTK.  When using fixed-height-mode,
    * row changes do not cause the row to be repainted.  The fix is to
    * invalidate the row when it is cleared.
    */
   if ((parent.style & SWT.VIRTUAL) != 0) {
     if (OS.GTK_VERSION >= OS.VERSION(2, 3, 2) && OS.GTK_VERSION < OS.VERSION(2, 6, 3)) {
       redraw();
     }
   }
   /*
    * Bug in GTK.  When in fixed height mode, GTK does not recalculate the cell renderer width
    * when the image is changed in the model.  The fix is to force it to recalculate the width if
    * more space is required.
    */
   if ((parent.style & SWT.VIRTUAL) != 0 && parent.currentItem == null) {
     if (OS.GTK_VERSION >= OS.VERSION(2, 3, 2)) {
       if (image != null) {
         int /*long*/ parentHandle = parent.handle;
         int /*long*/ column = OS.gtk_tree_view_get_column(parentHandle, index);
         int[] w = new int[1];
         int /*long*/ pixbufRenderer = parent.getPixbufRenderer(column);
         OS.gtk_tree_view_column_cell_get_position(column, pixbufRenderer, null, w);
         if (w[0] < image.getBounds().width) {
           /*
            * There is no direct way to clear the cell renderer width so we
            * are relying on the fact that it is done as part of modifying
            * the style.
            */
           int /*long*/ style = OS.gtk_widget_get_modifier_style(parentHandle);
           parent.modifyStyle(parentHandle, style);
         }
       }
     }
   }
   cached = true;
 }
コード例 #7
0
 Color _getForeground(int index) {
   int count = Math.max(1, parent.columnCount);
   if (0 > index || index > count - 1) return _getForeground();
   int /*long*/[] ptr = new int /*long*/[1];
   int modelIndex =
       parent.columnCount == 0 ? Table.FIRST_COLUMN : parent.columns[index].modelIndex;
   OS.gtk_tree_model_get(parent.modelHandle, handle, modelIndex + Table.CELL_FOREGROUND, ptr, -1);
   if (ptr[0] == 0) return _getForeground();
   GdkColor gdkColor = new GdkColor();
   OS.memmove(gdkColor, ptr[0], GdkColor.sizeof);
   return Color.gtk_new(display, gdkColor);
 }
コード例 #8
0
 void setBounds(int x, int y, int width, int height, boolean move, boolean size) {
   redraw();
   int headerHeight = parent.getBandHeight();
   if (move) {
     if (imageHeight > headerHeight) {
       y += (imageHeight - headerHeight);
     }
     this.x = x;
     this.y = y;
     redraw();
   }
   if (size) {
     this.width = width;
     this.height = height;
     redraw();
   }
   if (control != null && !control.isDisposed()) {
     if (move) control.setLocation(x + BORDER, y + headerHeight);
     if (size) control.setSize(Math.max(0, width - 2 * BORDER), Math.max(0, height - BORDER));
   }
 }
コード例 #9
0
ファイル: ToolItem.java プロジェクト: fzoli/RemoteControlCar
 /**
  * Returns a rectangle describing the receiver's size and location relative to its parent.
  *
  * @return the receiver's bounding 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() {
   checkWidget();
   parent.forceResize();
   long /*int*/ topHandle = topHandle();
   int x, y, width, height;
   x = OS.GTK_WIDGET_X(topHandle);
   y = OS.GTK_WIDGET_Y(topHandle);
   width = OS.GTK_WIDGET_WIDTH(topHandle);
   height = OS.GTK_WIDGET_HEIGHT(topHandle);
   if ((parent.style & SWT.MIRRORED) != 0) x = parent.getClientWidth() - width - x;
   if ((style & SWT.SEPARATOR) != 0 && control != null) height = Math.max(height, 23);
   return new Rectangle(x, y, width, height);
 }
コード例 #10
0
 Image _getImage(int index) {
   int count = Math.max(1, parent.getColumnCount());
   if (0 > index || index > count - 1) return null;
   int /*long*/[] ptr = new int /*long*/[1];
   int modelIndex =
       parent.columnCount == 0 ? Table.FIRST_COLUMN : parent.columns[index].modelIndex;
   OS.gtk_tree_model_get(parent.modelHandle, handle, modelIndex + Table.CELL_PIXBUF, ptr, -1);
   if (ptr[0] == 0) return null;
   ImageList imageList = parent.imageList;
   int imageIndex = imageList.indexOf(ptr[0]);
   if (imageIndex == -1) return null;
   return imageList.get(imageIndex);
 }
コード例 #11
0
 String _getText(int index) {
   int count = Math.max(1, parent.getColumnCount());
   if (0 > index || index > count - 1) return "";
   int /*long*/[] ptr = new int /*long*/[1];
   int modelIndex =
       parent.columnCount == 0 ? Table.FIRST_COLUMN : parent.columns[index].modelIndex;
   OS.gtk_tree_model_get(parent.modelHandle, handle, modelIndex + Table.CELL_TEXT, ptr, -1);
   if (ptr[0] == 0) return "";
   int length = OS.strlen(ptr[0]);
   byte[] buffer = new byte[length];
   OS.memmove(buffer, ptr[0], length);
   OS.g_free(ptr[0]);
   return new String(Converter.mbcsToWcs(null, buffer));
 }
コード例 #12
0
 /**
  * Sets the receiver's text at a column
  *
  * @param index the column index
  * @param string the new text
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_NULL_ARGUMENT - if the text is null
  *     </ul>
  *
  * @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 void setText(int index, String string) {
   checkWidget();
   if (string == null) error(SWT.ERROR_NULL_ARGUMENT);
   if (_getText(index).equals(string)) return;
   int count = Math.max(1, parent.getColumnCount());
   if (0 > index || index > count - 1) return;
   byte[] buffer = Converter.wcsToMbcs(null, string, true);
   int modelIndex =
       parent.columnCount == 0 ? Table.FIRST_COLUMN : parent.columns[index].modelIndex;
   OS.gtk_list_store_set(parent.modelHandle, handle, modelIndex + Table.CELL_TEXT, buffer, -1);
   /*
    * Bug in GTK.  When using fixed-height-mode,
    * row changes do not cause the row to be repainted.  The fix is to
    * invalidate the row when it is cleared.
    */
   if ((parent.style & SWT.VIRTUAL) != 0) {
     if (OS.GTK_VERSION >= OS.VERSION(2, 3, 2) && OS.GTK_VERSION < OS.VERSION(2, 6, 3)) {
       redraw();
     }
   }
   cached = true;
 }
コード例 #13
0
  void resizeControl(int yScroll) {
    if (control != null && !control.isDisposed()) {
      boolean visible = OS.gtk_expander_get_expanded(handle);
      if (visible) {
        int x = OS.GTK_WIDGET_X(clientHandle);
        int y = OS.GTK_WIDGET_Y(clientHandle);
        if (x != -1 && y != -1) {
          int width = OS.GTK_WIDGET_WIDTH(clientHandle);
          int height = OS.GTK_WIDGET_HEIGHT(clientHandle);
          int[] property = new int[1];
          OS.gtk_widget_style_get(handle, OS.focus_line_width, property, 0);
          y += property[0] * 2;
          height -= property[0] * 2;

          /*
           * Feature in GTK. When the ExpandBar is resize too small the control
           * shows up on top of the vertical scrollbar. This happen because the
           * GtkExpander does not set the size of child smaller than the request
           * size of its parent and because the control is not parented in the
           * hierarchy of the GtkScrolledWindow.
           * The fix is calculate the width ourselves when the scrollbar is visible.
           */
          ScrollBar vBar = parent.verticalBar;
          if (vBar != null) {
            if (OS.GTK_WIDGET_VISIBLE(vBar.handle)) {
              width =
                  OS.GTK_WIDGET_WIDTH(parent.scrolledHandle)
                      - parent.vScrollBarWidth()
                      - 2 * parent.spacing;
            }
          }
          control.setBounds(x, y - yScroll, width, Math.max(0, height), true, true);
        }
      }
      control.setVisible(visible);
    }
  }
コード例 #14
0
  Image getDragSourceImage(DragSourceEvent event) {
    if (dragSourceImage != null) dragSourceImage.dispose();
    dragSourceImage = null;

    Table table = (Table) control;
    if (OS.GTK_VERSION < OS.VERSION(2, 2, 0)) return null;
    // TEMPORARY CODE
    if (table.isListening(SWT.EraseItem) || table.isListening(SWT.PaintItem)) return null;
    /*
     * Bug in GTK.  gtk_tree_selection_get_selected_rows() segmentation faults
     * in versions smaller than 2.2.4 if the model is NULL.  The fix is
     * to give a valid pointer instead.
     */
    long /*int*/ handle = table.handle;
    long /*int*/ selection = OS.gtk_tree_view_get_selection(handle);
    long /*int*/[] model = OS.GTK_VERSION < OS.VERSION(2, 2, 4) ? new long /*int*/[1] : null;
    long /*int*/ list = OS.gtk_tree_selection_get_selected_rows(selection, model);
    if (list == 0) return null;
    int count = Math.min(10, OS.g_list_length(list));

    Display display = table.getDisplay();
    if (count == 1) {
      long /*int*/ path = OS.g_list_nth_data(list, 0);
      long /*int*/ pixmap = OS.gtk_tree_view_create_row_drag_icon(handle, path);
      dragSourceImage = Image.gtk_new(display, SWT.ICON, pixmap, 0);
    } else {
      int width = 0, height = 0;
      int[] w = new int[1], h = new int[1];
      int[] yy = new int[count], hh = new int[count];
      long /*int*/[] pixmaps = new long /*int*/[count];
      GdkRectangle rect = new GdkRectangle();
      for (int i = 0; i < count; i++) {
        long /*int*/ path = OS.g_list_nth_data(list, i);
        OS.gtk_tree_view_get_cell_area(handle, path, 0, rect);
        pixmaps[i] = OS.gtk_tree_view_create_row_drag_icon(handle, path);
        OS.gdk_drawable_get_size(pixmaps[i], w, h);
        width = Math.max(width, w[0]);
        height = rect.y + h[0] - yy[0];
        yy[i] = rect.y;
        hh[i] = h[0];
      }
      long /*int*/ source = OS.gdk_pixmap_new(OS.GDK_ROOT_PARENT(), width, height, -1);
      long /*int*/ gcSource = OS.gdk_gc_new(source);
      long /*int*/ mask = OS.gdk_pixmap_new(OS.GDK_ROOT_PARENT(), width, height, 1);
      long /*int*/ gcMask = OS.gdk_gc_new(mask);
      GdkColor color = new GdkColor();
      color.pixel = 0;
      OS.gdk_gc_set_foreground(gcMask, color);
      OS.gdk_draw_rectangle(mask, gcMask, 1, 0, 0, width, height);
      color.pixel = 1;
      OS.gdk_gc_set_foreground(gcMask, color);
      for (int i = 0; i < count; i++) {
        OS.gdk_draw_drawable(source, gcSource, pixmaps[i], 0, 0, 0, yy[i] - yy[0], -1, -1);
        OS.gdk_draw_rectangle(mask, gcMask, 1, 0, yy[i] - yy[0], width, hh[i]);
        OS.g_object_unref(pixmaps[i]);
      }
      OS.g_object_unref(gcSource);
      OS.g_object_unref(gcMask);
      dragSourceImage = Image.gtk_new(display, SWT.ICON, source, mask);
    }
    OS.g_list_free(list);

    return dragSourceImage;
  }
コード例 #15
0
ファイル: ProgressBar.java プロジェクト: neelance/swt4ruby
 /**
  * Sets the single 'selection' that is the receiver's position to the argument which must be
  * greater than or equal to zero.
  *
  * @param value the new selection (must be zero or greater)
  * @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 void setSelection(int value) {
   checkWidget();
   selection = Math.max(minimum, Math.min(maximum, value));
   updateBar(selection, minimum, maximum);
 }
コード例 #16
0
 String parse(String string) {
   int length = string.length();
   offsets = new Point[length / 4];
   ids = new String[length / 4];
   mnemonics = new int[length / 4 + 1];
   StringBuffer result = new StringBuffer();
   char[] buffer = new char[length];
   string.getChars(0, string.length(), buffer, 0);
   int index = 0, state = 0, linkIndex = 0;
   int start = 0, tagStart = 0, linkStart = 0, endtagStart = 0, refStart = 0;
   while (index < length) {
     char c = Character.toLowerCase(buffer[index]);
     switch (state) {
       case 0:
         if (c == '<') {
           tagStart = index;
           state++;
         }
         break;
       case 1:
         if (c == 'a') state++;
         break;
       case 2:
         switch (c) {
           case 'h':
             state = 7;
             break;
           case '>':
             linkStart = index + 1;
             state++;
             break;
           default:
             if (Character.isWhitespace(c)) break;
             else state = 13;
         }
         break;
       case 3:
         if (c == '<') {
           endtagStart = index;
           state++;
         }
         break;
       case 4:
         state = c == '/' ? state + 1 : 3;
         break;
       case 5:
         state = c == 'a' ? state + 1 : 3;
         break;
       case 6:
         if (c == '>') {
           mnemonics[linkIndex] = parseMnemonics(buffer, start, tagStart, result);
           int offset = result.length();
           parseMnemonics(buffer, linkStart, endtagStart, result);
           offsets[linkIndex] = new Point(offset, result.length() - 1);
           if (ids[linkIndex] == null) {
             ids[linkIndex] = new String(buffer, linkStart, endtagStart - linkStart);
           }
           linkIndex++;
           start = tagStart = linkStart = endtagStart = refStart = index + 1;
           state = 0;
         } else {
           state = 3;
         }
         break;
       case 7:
         state = c == 'r' ? state + 1 : 0;
         break;
       case 8:
         state = c == 'e' ? state + 1 : 0;
         break;
       case 9:
         state = c == 'f' ? state + 1 : 0;
         break;
       case 10:
         state = c == '=' ? state + 1 : 0;
         break;
       case 11:
         if (c == '"') {
           state++;
           refStart = index + 1;
         } else {
           state = 0;
         }
         break;
       case 12:
         if (c == '"') {
           ids[linkIndex] = new String(buffer, refStart, index - refStart);
           state = 2;
         }
         break;
       case 13:
         if (Character.isWhitespace(c)) {
           state = 0;
         } else if (c == '=') {
           state++;
         }
         break;
       case 14:
         state = c == '"' ? state + 1 : 0;
         break;
       case 15:
         if (c == '"') state = 2;
         break;
       default:
         state = 0;
         break;
     }
     index++;
   }
   if (start < length) {
     int tmp = parseMnemonics(buffer, start, tagStart, result);
     int mnemonic = parseMnemonics(buffer, Math.max(tagStart, linkStart), length, result);
     if (mnemonic == -1) mnemonic = tmp;
     mnemonics[linkIndex] = mnemonic;
   } else {
     mnemonics[linkIndex] = -1;
   }
   if (offsets.length != linkIndex) {
     Point[] newOffsets = new Point[linkIndex];
     System.arraycopy(offsets, 0, newOffsets, 0, linkIndex);
     offsets = newOffsets;
     String[] newIDs = new String[linkIndex];
     System.arraycopy(ids, 0, newIDs, 0, linkIndex);
     ids = newIDs;
     int[] newMnemonics = new int[linkIndex + 1];
     System.arraycopy(mnemonics, 0, newMnemonics, 0, linkIndex + 1);
     mnemonics = newMnemonics;
   }
   return result.toString();
 }
コード例 #17
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>
   *
   * @since 3.3
   */
  public Rectangle getTextBounds(int index) {
    checkWidget();
    if (!parent.checkData(this)) error(SWT.ERROR_WIDGET_DISPOSED);
    int count = Math.max(1, parent.getColumnCount());
    if (0 > index || index > count - 1) return new Rectangle(0, 0, 0, 0);
    // TODO fully test on early and later versions of GTK
    // shifted a bit too far right on later versions of GTK - however, old Tree also had this
    // problem
    int /*long*/ parentHandle = parent.handle;
    int /*long*/ column = 0;
    if (index >= 0 && index < parent.columnCount) {
      column = parent.columns[index].handle;
    } else {
      column = OS.gtk_tree_view_get_column(parentHandle, index);
    }
    if (column == 0) return new Rectangle(0, 0, 0, 0);
    int /*long*/ textRenderer = parent.getTextRenderer(column);
    int /*long*/ pixbufRenderer = parent.getPixbufRenderer(column);
    if (textRenderer == 0 || pixbufRenderer == 0) return new Rectangle(0, 0, 0, 0);

    int /*long*/ path = OS.gtk_tree_model_get_path(parent.modelHandle, handle);
    OS.gtk_widget_realize(parentHandle);

    boolean isExpander = OS.gtk_tree_model_iter_n_children(parent.modelHandle, handle) > 0;
    boolean isExpanded = OS.gtk_tree_view_row_expanded(parentHandle, path);
    OS.gtk_tree_view_column_cell_set_cell_data(
        column, parent.modelHandle, handle, isExpander, isExpanded);

    GdkRectangle rect = new GdkRectangle();
    OS.gtk_tree_view_get_cell_area(parentHandle, path, column, rect);
    OS.gtk_tree_path_free(path);
    if ((parent.getStyle() & SWT.MIRRORED) != 0)
      rect.x = parent.getClientWidth() - rect.width - rect.x;
    int right = rect.x + rect.width;

    int[] x = new int[1], w = new int[1];
    parent.ignoreSize = true;
    OS.gtk_cell_renderer_get_size(textRenderer, parentHandle, null, null, null, w, null);
    parent.ignoreSize = false;
    int[] buffer = new int[1];
    if (OS.gtk_tree_view_get_expander_column(parentHandle) == column) {
      OS.gtk_widget_style_get(parentHandle, OS.expander_size, buffer, 0);
      rect.x += buffer[0] + TreeItem.EXPANDER_EXTRA_PADDING;
    }
    OS.gtk_widget_style_get(parentHandle, OS.horizontal_separator, buffer, 0);
    int horizontalSeparator = buffer[0];
    rect.x += horizontalSeparator;

    if (OS.GTK_VERSION >= OS.VERSION(2, 1, 3)) {
      OS.gtk_tree_view_column_cell_get_position(column, textRenderer, x, null);
      rect.x += x[0];
    } else {
      if ((parent.style & SWT.CHECK) != 0) {
        OS.gtk_cell_renderer_get_size(
            parent.checkRenderer, parentHandle, null, null, null, w, null);
        rect.x += w[0] + horizontalSeparator;
      }
      OS.gtk_cell_renderer_get_size(pixbufRenderer, parentHandle, null, null, null, w, null);
      rect.x += w[0] + horizontalSeparator;
    }
    if (parent.columnCount > 0) {
      if (rect.x + rect.width > right) {
        rect.width = Math.max(0, right - rect.x);
      }
    }
    int width = OS.gtk_tree_view_column_get_visible(column) ? rect.width + 1 : 0;
    return new Rectangle(rect.x, rect.y, width, rect.height + 1);
  }