diff options
author | Anatoly Spektor <aspektor@redhat.com> | 2012-10-15 10:50:57 -0400 |
---|---|---|
committer | Anatoly Spektor <aspektor@redhat.com> | 2012-10-15 10:50:57 -0400 |
commit | fc98cd751b8c1b27cccb5e11eb43951d62444bc4 (patch) | |
tree | ca02321c7db4a8f529ec93818bae5cdf1c2842ee | |
parent | b16cc7ac5911d04bae872f4c5c032f451e75a127 (diff) | |
download | eclipse.platform.swt-fc98cd751b8c1b27cccb5e11eb43951d62444bc4.tar.gz eclipse.platform.swt-fc98cd751b8c1b27cccb5e11eb43951d62444bc4.tar.xz eclipse.platform.swt-fc98cd751b8c1b27cccb5e11eb43951d62444bc4.zip |
Use gtk_cell_renderer_get_preferred_size() for GTK+ 3 gtk3_cell_renderer
This patch replaces gtk_cell_renderer_get_size wth
gtk_cell_renderer_get_preferred_size for GTK+ 3
10 files changed, 75 insertions, 11 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c index aeab8e68b7..d3e5f4eeb2 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c @@ -8108,6 +8108,31 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1cell_1layout_1pack_1start) } #endif +#ifndef NO__1gtk_1cell_1renderer_1get_1preferred_1size +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1cell_1renderer_1get_1preferred_1size) + (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jobject arg2, jobject arg3) +{ + GtkRequisition _arg2, *lparg2=NULL; + GtkRequisition _arg3, *lparg3=NULL; + OS_NATIVE_ENTER(env, that, _1gtk_1cell_1renderer_1get_1preferred_1size_FUNC); + if (arg2) if ((lparg2 = getGtkRequisitionFields(env, arg2, &_arg2)) == NULL) goto fail; + if (arg3) if ((lparg3 = getGtkRequisitionFields(env, arg3, &_arg3)) == NULL) goto fail; +/* + gtk_cell_renderer_get_preferred_size((GtkCellRenderer *)arg0, (GtkWidget *)arg1, (GtkRequisition *)lparg2, (GtkRequisition *)lparg3); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_cell_renderer_get_preferred_size) + if (fp) { + ((void (CALLING_CONVENTION*)(GtkCellRenderer *, GtkWidget *, GtkRequisition *, GtkRequisition *))fp)((GtkCellRenderer *)arg0, (GtkWidget *)arg1, (GtkRequisition *)lparg2, (GtkRequisition *)lparg3); + } + } +fail: + if (arg3 && lparg3) setGtkRequisitionFields(env, arg3, lparg3); + if (arg2 && lparg2) setGtkRequisitionFields(env, arg2, lparg2); + OS_NATIVE_EXIT(env, that, _1gtk_1cell_1renderer_1get_1preferred_1size_FUNC); +} +#endif + #ifndef NO__1gtk_1cell_1renderer_1get_1size JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1cell_1renderer_1get_1size) (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jobject arg2, jintArray arg3, jintArray arg4, jintArray arg5, jintArray arg6) @@ -8123,7 +8148,15 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1cell_1renderer_1get_1size) if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail; if (arg5) if ((lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL)) == NULL) goto fail; if (arg6) if ((lparg6 = (*env)->GetIntArrayElements(env, arg6, NULL)) == NULL) goto fail; +/* gtk_cell_renderer_get_size((GtkCellRenderer *)arg0, (GtkWidget *)arg1, (GdkRectangle *)lparg2, (gint *)lparg3, (gint *)lparg4, (gint *)lparg5, (gint *)lparg6); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_cell_renderer_get_size) + if (fp) { + ((void (CALLING_CONVENTION*)(GtkCellRenderer *, GtkWidget *, GdkRectangle *, gint *, gint *, gint *, gint *))fp)((GtkCellRenderer *)arg0, (GtkWidget *)arg1, (GdkRectangle *)lparg2, (gint *)lparg3, (gint *)lparg4, (gint *)lparg5, (gint *)lparg6); + } + } fail: if (arg6 && lparg6) (*env)->ReleaseIntArrayElements(env, arg6, lparg6, 0); if (arg5 && lparg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h index b4b96bc1ab..ee5be24b22 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h @@ -90,6 +90,8 @@ #define gtk_cell_layout_set_attributes_LIB LIB_GTK #define gtk_cell_layout_clear_LIB LIB_GTK #define gtk_cell_layout_pack_start_LIB LIB_GTK +#define gtk_cell_renderer_get_preferred_size_LIB LIB_GTK +#define gtk_cell_renderer_get_size_LIB LIB_GTK #define gtk_combo_box_entry_new_text_LIB LIB_GTK #define gtk_combo_box_new_text_LIB LIB_GTK #define gtk_combo_box_insert_text_LIB LIB_GTK diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c index 2e93db0168..cbbd0e4c79 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c @@ -624,6 +624,7 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1cell_1layout_1get_1cells", "_1gtk_1cell_1layout_1pack_1start", "_1gtk_1cell_1layout_1set_1attributes", + "_1gtk_1cell_1renderer_1get_1preferred_1size", "_1gtk_1cell_1renderer_1get_1size", "_1gtk_1cell_1renderer_1pixbuf_1new", "_1gtk_1cell_1renderer_1text_1new", diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h index 64c93e3041..9614c64526 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h @@ -634,6 +634,7 @@ typedef enum { _1gtk_1cell_1layout_1get_1cells_FUNC, _1gtk_1cell_1layout_1pack_1start_FUNC, _1gtk_1cell_1layout_1set_1attributes_FUNC, + _1gtk_1cell_1renderer_1get_1preferred_1size_FUNC, _1gtk_1cell_1renderer_1get_1size_FUNC, _1gtk_1cell_1renderer_1pixbuf_1new_FUNC, _1gtk_1cell_1renderer_1text_1new_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java index a8edc1713b..b5f0f639b6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java @@ -5993,6 +5993,7 @@ public static final void gtk_cell_layout_pack_start(long /*int*/ cell_layout, lo } } /** + * @method flags=dynamic * @param cell cast=(GtkCellRenderer *) * @param widget cast=(GtkWidget *) * @param area cast=(GdkRectangle *),flags=no_in @@ -6010,6 +6011,22 @@ public static final void gtk_cell_renderer_get_size(long /*int*/ cell, long /*in lock.unlock(); } } +/** + * @method flags=dynamic + * @param cell cast=(GtkCellRenderer *) + * @param widget cast=(GtkWidget *) + * @param minimum_size cast=(GtkRequisition *) + * @param natural_size cast=(GtkRequisition *) + */ +public static final native void _gtk_cell_renderer_get_preferred_size(long /*int*/ cell, long /*int*/ widget, GtkRequisition minimum_size, GtkRequisition natural_size); +public static final void gtk_cell_renderer_get_preferred_size(long /*int*/ cell, long /*int*/ widget, GtkRequisition minimum_size, GtkRequisition natural_size) { + lock.lock(); + try { + _gtk_cell_renderer_get_preferred_size(cell, widget, minimum_size, natural_size); + } finally { + lock.unlock(); + } +} public static final native long /*int*/ _gtk_cell_renderer_pixbuf_new(); public static final long /*int*/ gtk_cell_renderer_pixbuf_new() { lock.lock(); 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 f078527b24..a02b2ed3b7 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 @@ -334,7 +334,7 @@ int calculateWidth (long /*int*/ column, long /*int*/ iter) { while (temp != 0) { long /*int*/ renderer = OS.g_list_data (temp); if (renderer != 0) { - OS.gtk_cell_renderer_get_size (renderer, handle, null, null, null, w, null); + gtk_cell_renderer_get_preferred_size (renderer, handle, w, null); width += w [0]; } temp = OS.g_list_next (temp); @@ -2590,7 +2590,7 @@ long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ window, long /* //send out measure before erase long /*int*/ textRenderer = getTextRenderer (columnHandle); - if (textRenderer != 0) OS.gtk_cell_renderer_get_size (textRenderer, handle, null, null, null, null, null); + if (textRenderer != 0) gtk_cell_renderer_get_preferred_size (textRenderer, handle, null, null); if (hooks (SWT.EraseItem)) { @@ -2664,8 +2664,8 @@ long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ window, long /* OS.gtk_tree_view_get_background_area (handle, path, columnHandle, rect); OS.gtk_tree_path_free (path); ignoreSize = true; - int [] contentX = new int [1], contentWidth = new int [1]; - OS.gtk_cell_renderer_get_size (cell, handle, null, null, null, contentWidth, null); + int [] contentX = new int [1], contentWidth = new int [1]; + gtk_cell_renderer_get_preferred_size (cell, handle, contentWidth, null); OS.gtk_tree_view_column_cell_get_position (columnHandle, cell, contentX, null); ignoreSize = false; Image image = item.getImage (columnIndex); 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 618367bb66..510138dfa3 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 @@ -300,7 +300,7 @@ public Rectangle getBounds () { 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); + gtk_cell_renderer_get_preferred_size (textRenderer, parentHandle, w, null); parent.ignoreSize = false; rect.width = w [0]; int [] buffer = new int [1]; @@ -678,7 +678,7 @@ public Rectangle getTextBounds (int index) { 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); + gtk_cell_renderer_get_preferred_size (textRenderer, parentHandle, w, null); parent.ignoreSize = false; int [] buffer = new int [1]; if (OS.gtk_tree_view_get_expander_column (parentHandle) == column) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java index b873d6fc0e..ef6005a1ae 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java @@ -421,7 +421,7 @@ int calculateWidth (long /*int*/ column, long /*int*/ iter, boolean recurse) { while (temp != 0) { long /*int*/ renderer = OS.g_list_data (temp); if (renderer != 0) { - OS.gtk_cell_renderer_get_size (renderer, handle, null, null, null, w, null); + gtk_cell_renderer_get_preferred_size (renderer, handle, w, null); width += w [0]; } temp = OS.g_list_next (temp); @@ -2581,7 +2581,7 @@ long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ window, long /* //send out measure before erase long /*int*/ textRenderer = getTextRenderer (columnHandle); - if (textRenderer != 0) OS.gtk_cell_renderer_get_size (textRenderer, handle, null, null, null, null, null); + if (textRenderer != 0) gtk_cell_renderer_get_preferred_size (textRenderer, handle, null, null); if (hooks (SWT.EraseItem)) { boolean wasSelected = (drawState & SWT.SELECTED) != 0; @@ -2666,7 +2666,7 @@ long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ window, long /* } ignoreSize = true; int [] contentX = new int [1], contentWidth = new int [1]; - OS.gtk_cell_renderer_get_size (cell, handle, null, null, null, contentWidth, null); + gtk_cell_renderer_get_preferred_size (cell, handle, contentWidth, null); OS.gtk_tree_view_column_cell_get_position (columnHandle, cell, contentX, null); ignoreSize = false; Image image = item.getImage (columnIndex); 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 4efb9a692f..4c88cbfdb0 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 @@ -515,7 +515,7 @@ public Rectangle getBounds () { 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); + gtk_cell_renderer_get_preferred_size (textRenderer, parentHandle, w, null); parent.ignoreSize = false; rect.width = w [0]; int [] buffer = new int [1]; @@ -972,7 +972,7 @@ public Rectangle getTextBounds (int index) { 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); + gtk_cell_renderer_get_preferred_size (textRenderer, parentHandle, w, null); parent.ignoreSize = false; int [] buffer = new int [1]; if (OS.GTK_VERSION < OS.VERSION (2, 8, 18) && OS.gtk_tree_view_get_expander_column (parentHandle) == column) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java index e03d9664a6..0d8f47da10 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java @@ -2043,4 +2043,14 @@ void gtk_render_frame (long /*int*/ style, long /*int*/ window, int state_type, } } +void gtk_cell_renderer_get_preferred_size (long /*int*/ cell, long /*int*/ widget, int[] width, int[] height) { + if (OS.GTK_VERSION >= OS.VERSION (3, 0, 0)) { + GtkRequisition minimum_size = new GtkRequisition (); + OS.gtk_cell_renderer_get_preferred_size (cell, widget, minimum_size, null); + if (width != null) width [0] = minimum_size.width; + if (height != null) height[0] = minimum_size.height; + } else { + OS.gtk_cell_renderer_get_size (cell, widget, null, null, null, width, height); + } +} } |