summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
diff options
context:
space:
mode:
authorSilenio Quarti <silenio_quarti@ca.ibm.com>2012-11-16 15:00:04 -0500
committerSilenio Quarti <silenio_quarti@ca.ibm.com>2012-11-16 15:00:04 -0500
commit589c806f733b6f17cd797f8efe22263b138d8cd1 (patch)
treee01de47db646823d387b5092ed0aadbb99cd56b2 /bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
parent7b284503d08592dbddb77a19eb2de58b2bbcf267 (diff)
downloadeclipse.platform.swt-589c806f733b6f17cd797f8efe22263b138d8cd1.tar.gz
eclipse.platform.swt-589c806f733b6f17cd797f8efe22263b138d8cd1.tar.xz
eclipse.platform.swt-589c806f733b6f17cd797f8efe22263b138d8cd1.zip
Bug 393724 - [GTK3] Owner draw trees are not drawing items
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java98
1 files changed, 64 insertions, 34 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
index 9764196aa3..6765c9e523 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
@@ -180,7 +180,11 @@ long /*int*/ cellDataProc (long /*int*/ tree_column, long /*int*/ cell, long /*i
OS.gtk_tree_path_free (path);
if (item != null) OS.g_object_set_qdata (cell, Display.SWT_OBJECT_INDEX2, item.handle);
boolean isPixbuf = OS.GTK_IS_CELL_RENDERER_PIXBUF (cell);
- if (!(isPixbuf || OS.GTK_IS_CELL_RENDERER_TEXT (cell))) return 0;
+ boolean isText = OS.GTK_IS_CELL_RENDERER_TEXT (cell);
+ if (isText && OS.GTK3) {
+ OS.gtk_cell_renderer_set_fixed_size (cell, -1, -1);
+ }
+ if (!(isPixbuf || isText)) return 0;
int modelIndex = -1;
boolean customDraw = false;
if (columnCount == 0) {
@@ -2497,12 +2501,8 @@ public void removeSelectionListener(SelectionListener listener) {
eventTable.unhook (SWT.DefaultSelection,listener);
}
-long /*int*/ rendererGetSizeProc (long /*int*/ cell, long /*int*/ widget, long /*int*/ cell_area, long /*int*/ x_offset, long /*int*/ y_offset, long /*int*/ width, long /*int*/ height) {
- long /*int*/ g_class = OS.g_type_class_peek_parent (OS.G_OBJECT_GET_CLASS (cell));
- GtkCellRendererClass klass = new GtkCellRendererClass ();
- OS.memmove (klass, g_class);
- OS.call_get_size (klass.get_size, cell, handle, cell_area, x_offset, y_offset, width, height);
- if (!ignoreSize && OS.GTK_IS_CELL_RENDERER_TEXT (cell)) {
+void sendMeasureEvent (long /*int*/ cell, long /*int*/ width, long /*int*/ height) {
+ if (!ignoreSize && OS.GTK_IS_CELL_RENDERER_TEXT (cell) && hooks (SWT.MeasureItem)) {
long /*int*/ iter = OS.g_object_get_qdata (cell, Display.SWT_OBJECT_INDEX2);
TableItem item = null;
boolean isSelected = false;
@@ -2527,38 +2527,60 @@ long /*int*/ rendererGetSizeProc (long /*int*/ cell, long /*int*/ widget, long /
}
}
}
- if (hooks (SWT.MeasureItem)) {
- int [] contentWidth = new int [1], contentHeight = new int [1];
- if (width != 0) OS.memmove (contentWidth, width, 4);
- if (height != 0) OS.memmove (contentHeight, height, 4);
- Image image = item.getImage (columnIndex);
- int imageWidth = 0;
- if (image != null) {
- Rectangle bounds = image.getBounds ();
- imageWidth = bounds.width;
- }
- contentWidth [0] += imageWidth;
- GC gc = new GC (this);
- gc.setFont (item.getFont (columnIndex));
- Event event = new Event ();
- event.item = item;
- event.index = columnIndex;
- event.gc = gc;
- event.width = contentWidth [0];
- event.height = contentHeight [0];
- if (isSelected) event.detail = SWT.SELECTED;
- sendEvent (SWT.MeasureItem, event);
- gc.dispose ();
- contentWidth [0] = event.width - imageWidth;
- if (contentHeight [0] < event.height) contentHeight [0] = event.height;
- if (width != 0) OS.memmove (width, contentWidth, 4);
- if (height != 0) OS.memmove (height, contentHeight, 4);
+ int [] contentWidth = new int [1], contentHeight = new int [1];
+ if (width != 0) OS.memmove (contentWidth, width, 4);
+ if (height != 0) OS.memmove (contentHeight, height, 4);
+ if (OS.GTK3) {
+ OS.gtk_cell_renderer_get_preferred_height_for_width (cell, handle, contentWidth[0], contentHeight, null);
+ }
+ Image image = item.getImage (columnIndex);
+ int imageWidth = 0;
+ if (image != null) {
+ Rectangle bounds = image.getBounds ();
+ imageWidth = bounds.width;
+ }
+ contentWidth [0] += imageWidth;
+ GC gc = new GC (this);
+ gc.setFont (item.getFont (columnIndex));
+ Event event = new Event ();
+ event.item = item;
+ event.index = columnIndex;
+ event.gc = gc;
+ event.width = contentWidth [0];
+ event.height = contentHeight [0];
+ if (isSelected) event.detail = SWT.SELECTED;
+ sendEvent (SWT.MeasureItem, event);
+ gc.dispose ();
+ contentWidth [0] = event.width - imageWidth;
+ if (contentHeight [0] < event.height) contentHeight [0] = event.height;
+ if (width != 0) OS.memmove (width, contentWidth, 4);
+ if (height != 0) OS.memmove (height, contentHeight, 4);
+ if (OS.GTK3) {
+ OS.gtk_cell_renderer_set_fixed_size (cell, contentWidth [0], contentHeight [0]);
}
}
}
+}
+
+long /*int*/ rendererGetPreferredWidthProc (long /*int*/ cell, long /*int*/ handle, long /*int*/ minimun_size, long /*int*/ natural_size) {
+ long /*int*/ g_class = OS.g_type_class_peek_parent (OS.G_OBJECT_GET_CLASS (cell));
+ GtkCellRendererClass klass = new GtkCellRendererClass ();
+ OS.memmove (klass, g_class);
+ OS.call (klass.get_preferred_width, cell, handle, minimun_size, natural_size);
+ sendMeasureEvent (cell, minimun_size, 0);
return 0;
}
+long /*int*/ rendererGetSizeProc (long /*int*/ cell, long /*int*/ widget, long /*int*/ cell_area, long /*int*/ x_offset, long /*int*/ y_offset, long /*int*/ width, long /*int*/ height) {
+ long /*int*/ g_class = OS.g_type_class_peek_parent (OS.G_OBJECT_GET_CLASS (cell));
+ GtkCellRendererClass klass = new GtkCellRendererClass ();
+ OS.memmove (klass, g_class);
+ OS.call_get_size (klass.get_size, cell, handle, cell_area, x_offset, y_offset, width, height);
+ sendMeasureEvent (cell, width, height);
+ return 0;
+}
+
+
long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ cr, long /*int*/ widget, long /*int*/ background_area, long /*int*/ cell_area, long /*int*/ flags) {
rendererRender (cell, cr, 0, widget, background_area, cell_area, 0, flags);
return 0;
@@ -2675,7 +2697,15 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo
if ((drawState & SWT.FOCUSED) != 0) drawFlags |= OS.GTK_CELL_RENDERER_FOCUSED;
if ((drawState & SWT.SELECTED) != 0) {
if (OS.GTK3) {
- //TODO draw selection on GTK3
+ Cairo.cairo_save (cr);
+ Cairo.cairo_reset_clip (cr);
+ long /*int*/ context = OS.gtk_widget_get_style_context (widget);
+ OS.gtk_style_context_save (context);
+ OS.gtk_style_context_add_class (context, OS.GTK_STYLE_CLASS_CELL);
+ OS.gtk_style_context_set_state (context, OS.GTK_STATE_FLAG_SELECTED);
+ OS.gtk_render_background(context, cr, rect.x, rect.y, rect.width, rect.height);
+ OS.gtk_style_context_restore (context);
+ Cairo.cairo_restore (cr);
} else {
long /*int*/ style = OS.gtk_widget_get_style (widget);
//TODO - parity and sorted