summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorAlexander Kurtakov2012-03-06 11:00:48 (EST)
committer Silenio Quarti2012-03-09 17:31:51 (EST)
commit679890a84222ce0160d339b7b083b9284b56677d (patch)
treeefd8f2eec5ce600835bfdc10963be5798ffef818
parentcf2b66d490bff744ecd1ca3533d187040b308649 (diff)
downloadeclipse.platform.swt-679890a84222ce0160d339b7b083b9284b56677d.zip
eclipse.platform.swt-679890a84222ce0160d339b7b083b9284b56677d.tar.gz
eclipse.platform.swt-679890a84222ce0160d339b7b083b9284b56677d.tar.bz2
Cleanup TableItem and TreeItem.
Remove all pre-2.4 gtk checks from the code. There is no need for them now that gtk 2.4+ is required.
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java120
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java119
2 files changed, 75 insertions, 164 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
index 7119af4..105363b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
@@ -223,7 +223,7 @@ void clear () {
* 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)) {
+ if (OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
redraw ();
}
}
@@ -308,17 +308,9 @@ public Rectangle getBounds () {
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;
- }
+ OS.gtk_tree_view_column_cell_get_position (column, textRenderer, x, null);
+ rect.x += x [0];
+
if (parent.columnCount > 0) {
if (rect.x + rect.width > right) {
rect.width = Math.max (0, right - rect.x);
@@ -378,19 +370,10 @@ public Rectangle getBounds (int index) {
if ((parent.getStyle () & SWT.MIRRORED) != 0) rect.x = parent.getClientWidth () - rect.width - rect.x;
if (index == 0 && (parent.style & SWT.CHECK) != 0) {
- if (OS.GTK_VERSION >= OS.VERSION (2, 1, 3)) {
- int [] x = new int [1], w = new int [1];
- OS.gtk_tree_view_column_cell_get_position (column, parent.checkRenderer, x, w);
- rect.x += x [0] + w [0];
- rect.width -= x [0] + w [0];
- } else {
- int [] w = new int [1];
- OS.gtk_cell_renderer_get_size (parent.checkRenderer, parentHandle, null, null, null, w, null);
- int [] buffer = new int [1];
- OS.gtk_widget_style_get (parentHandle, OS.horizontal_separator, buffer, 0);
- rect.x += w [0] + buffer [0];
- rect.width -= w [0] + buffer [0];
- }
+ int [] x = new int [1], w = new int [1];
+ OS.gtk_tree_view_column_cell_get_position (column, parent.checkRenderer, x, w);
+ rect.x += x [0] + w [0];
+ rect.width -= x [0] + w [0];
}
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);
@@ -570,26 +553,10 @@ public Rectangle getImageBounds (int index) {
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;
- /*
- * The OS call gtk_cell_renderer_get_size() provides the width of image to be drawn
- * by the cell renderer. If there is no image in the cell, the width is zero. If the table contains
- * images of varying widths, gtk_cell_renderer_get_size() will return the width of the image,
- * not the width of the area in which the image is drawn.
- * New API was added in GTK 2.1.3 for determining the full width of the renderer area.
- * For earlier versions of GTK, the result is only correct if all rows have images of the same
- * width.
- */
- if (OS.GTK_VERSION >= OS.VERSION (2, 1, 3)) {
- int [] x = new int [1], w = new int[1];
- OS.gtk_tree_view_column_cell_get_position (column, pixbufRenderer, x, w);
- rect.x += x [0];
- rect.width = w [0];
- } else {
- int [] w = new int [1];
- OS.gtk_tree_view_column_cell_set_cell_data (column, parent.modelHandle, handle, false, false);
- OS.gtk_cell_renderer_get_size (pixbufRenderer, parentHandle, null, null, null, w, null);
- rect.width = w [0];
- }
+ int [] x = new int [1], w = new int[1];
+ OS.gtk_tree_view_column_cell_get_position (column, pixbufRenderer, x, w);
+ rect.x += x [0];
+ rect.width = w [0];
int width = OS.gtk_tree_view_column_get_visible (column) ? rect.width : 0;
return new Rectangle (rect.x, rect.y, width, rect.height + 1);
}
@@ -718,17 +685,8 @@ public Rectangle getTextBounds (int index) {
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;
- }
+ OS.gtk_tree_view_column_cell_get_position (column, textRenderer, x, null);
+ rect.x += x [0];
if (parent.columnCount > 0) {
if (rect.x + rect.width > right) {
rect.width = Math.max (0, right - rect.x);
@@ -798,7 +756,7 @@ public void setBackground (Color color) {
* 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)) {
+ if (OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
redraw ();
}
}
@@ -840,7 +798,7 @@ public void setBackground (int index, Color color) {
* 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)) {
+ if (OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
redraw ();
}
}
@@ -931,7 +889,7 @@ public void setFont (Font font){
* 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)) {
+ if (OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
redraw ();
}
}
@@ -982,7 +940,7 @@ public void setFont (int index, Font font) {
* 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)) {
+ if (OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
redraw ();
}
}
@@ -1045,7 +1003,7 @@ public void setForeground (Color color){
* 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)) {
+ if (OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
redraw ();
}
}
@@ -1087,7 +1045,7 @@ public void setForeground (int index, Color color){
* 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)) {
+ if (OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
redraw ();
}
}
@@ -1185,7 +1143,7 @@ public void setImage (int index, Image image) {
* 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)) {
+ if (OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
redraw ();
}
}
@@ -1195,24 +1153,22 @@ public void setImage (int index, Image image) {
* 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);
- }
- }
- }
+ 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;
}
@@ -1293,7 +1249,7 @@ public void setText (int index, String string) {
* 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)) {
+ if (OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
redraw ();
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
index da70cac..6c6ad36 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
@@ -304,7 +304,7 @@ void clear () {
* 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)) {
+ if (OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
redraw ();
}
}
@@ -465,19 +465,10 @@ public Rectangle getBounds (int index) {
OS.gtk_tree_path_free (path);
if (index == 0 && (parent.style & SWT.CHECK) != 0) {
- if (OS.GTK_VERSION >= OS.VERSION (2, 1, 3)) {
- int [] x = new int [1], w = new int [1];
- OS.gtk_tree_view_column_cell_get_position (column, parent.checkRenderer, x, w);
- rect.x += x [0] + w [0];
- rect.width -= x [0] + w [0];
- } else {
- int [] w = new int [1];
- OS.gtk_cell_renderer_get_size (parent.checkRenderer, parentHandle, null, null, null, w, null);
- int [] buffer = new int [1];
- OS.gtk_widget_style_get (parentHandle, OS.horizontal_separator, buffer, 0);
- rect.x += w [0] + buffer [0];
- rect.width -= w [0] + buffer [0];
- }
+ int [] x = new int [1], w = new int [1];
+ OS.gtk_tree_view_column_cell_get_position (column, parent.checkRenderer, x, w);
+ rect.x += x [0] + w [0];
+ rect.width -= x [0] + w [0];
}
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);
@@ -545,17 +536,8 @@ public Rectangle getBounds () {
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;
- }
+ OS.gtk_tree_view_column_cell_get_position (column, textRenderer, x, null);
+ rect.x += x [0];
if (parent.columnCount > 0) {
if (rect.x + rect.width > right) {
rect.width = Math.max (0, right - rect.x);
@@ -788,26 +770,10 @@ public Rectangle getImageBounds (int index) {
}
OS.gtk_tree_path_free (path);
- /*
- * The OS call gtk_cell_renderer_get_size() provides the width of image to be drawn
- * by the cell renderer. If there is no image in the cell, the width is zero. If the table contains
- * images of varying widths, gtk_cell_renderer_get_size() will return the width of the image,
- * not the width of the area in which the image is drawn.
- * New API was added in GTK 2.1.3 for determining the full width of the renderer area.
- * For earlier versions of GTK, the result is only correct if all rows have images of the same
- * width.
- */
- if (OS.GTK_VERSION >= OS.VERSION (2, 1, 3)) {
- int [] x = new int [1], w = new int[1];
- OS.gtk_tree_view_column_cell_get_position (column, pixbufRenderer, x, w);
- rect.x += x [0];
- rect.width = w [0];
- } else {
- int [] w = new int [1];
- OS.gtk_tree_view_column_cell_set_cell_data (column, parent.modelHandle, handle, false, false);
- OS.gtk_cell_renderer_get_size (pixbufRenderer, parentHandle, null, null, null, w, null);
- rect.width = w [0];
- }
+ int [] x = new int [1], w = new int[1];
+ OS.gtk_tree_view_column_cell_get_position (column, pixbufRenderer, x, w);
+ rect.x += x [0];
+ rect.width = w [0];
int width = OS.gtk_tree_view_column_get_visible (column) ? rect.width : 0;
return new Rectangle (rect.x, rect.y, width, rect.height + 1);
}
@@ -1025,17 +991,8 @@ public Rectangle getTextBounds (int index) {
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;
- }
+ OS.gtk_tree_view_column_cell_get_position (column, textRenderer, x, null);
+ rect.x += x [0];
if (parent.columnCount > 0) {
if (rect.x + rect.width > right) {
rect.width = Math.max (0, right - rect.x);
@@ -1201,7 +1158,7 @@ public void setBackground (Color color) {
* 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)) {
+ if (OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
redraw ();
}
}
@@ -1244,7 +1201,7 @@ public void setBackground (int index, Color color) {
* 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)) {
+ if (OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
redraw ();
}
}
@@ -1365,7 +1322,7 @@ public void setFont (Font font){
* 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)) {
+ if (OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
redraw ();
}
}
@@ -1416,7 +1373,7 @@ public void setFont (int index, Font font) {
* 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)) {
+ if (OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
redraw ();
}
}
@@ -1480,7 +1437,7 @@ public void setForeground (Color color){
* 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)) {
+ if (OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
redraw ();
}
}
@@ -1523,7 +1480,7 @@ public void setForeground (int index, Color color){
* 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)) {
+ if (OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
redraw ();
}
}
@@ -1623,7 +1580,7 @@ public void setImage (int index, Image image) {
* invalidate the row when the image changes.
*/
if ((parent.style & SWT.VIRTUAL) != 0) {
- if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2) && OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
+ if (OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
if (parent.columnCount == 0) {
redraw ();
}
@@ -1635,24 +1592,22 @@ public void setImage (int index, Image image) {
* 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);
- }
- }
- }
+ 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;
}
@@ -1735,7 +1690,7 @@ public void setText (int index, String string) {
* invalidate the row when the text changes.
*/
if ((parent.style & SWT.VIRTUAL) != 0) {
- if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2) && OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
+ if (OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
redraw ();
}
}