diff options
6 files changed, 107 insertions, 1 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 526464acbc..282f8fd346 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 @@ -7741,6 +7741,16 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1button_1new) } #endif +#ifndef NO__1gtk_1button_1set_1image +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1button_1set_1image) + (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) +{ + OS_NATIVE_ENTER(env, that, _1gtk_1button_1set_1image_FUNC); + gtk_button_set_image(arg0, arg1); + OS_NATIVE_EXIT(env, that, _1gtk_1button_1set_1image_FUNC); +} +#endif + #ifndef NO__1gtk_1calendar_1clear_1marks JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1calendar_1clear_1marks) (JNIEnv *env, jclass that, jintLong arg0) 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 209d6b4c39..f5bc1cc4c0 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 @@ -633,6 +633,7 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1box_1set_1spacing", "_1gtk_1button_1clicked", "_1gtk_1button_1new", + "_1gtk_1button_1set_1image", "_1gtk_1calendar_1clear_1marks", "_1gtk_1calendar_1get_1date", "_1gtk_1calendar_1mark_1day", 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 7b36883b7f..41480bd6d2 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 @@ -643,6 +643,7 @@ typedef enum { _1gtk_1box_1set_1spacing_FUNC, _1gtk_1button_1clicked_FUNC, _1gtk_1button_1new_FUNC, + _1gtk_1button_1set_1image_FUNC, _1gtk_1calendar_1clear_1marks_FUNC, _1gtk_1calendar_1get_1date_FUNC, _1gtk_1calendar_1mark_1day_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 1a35dee7c9..3fa2ede5c6 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 @@ -6180,6 +6180,15 @@ public static final long /*int*/ gtk_button_new() { lock.unlock(); } } +public static final native void /*int*/ _gtk_button_set_image(long /*int*/ handle, long /*int*/ image); +public static final void /*int*/ gtk_button_set_image(long /*int*/ handle, long /*int*/ image) { + lock.lock(); + try { + _gtk_button_set_image(handle, image); + } finally { + lock.unlock(); + } +} public static final native long /*int*/ _gtk_calendar_new(); public static final long /*int*/ gtk_calendar_new() { lock.lock(); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java index ad13b3ec5f..267b3730d8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java @@ -347,7 +347,13 @@ void createHandle (int index) { break; } if ((style & SWT.ARROW) != 0) { - OS.gtk_container_add (handle, arrowHandle); + // Use gtk_button_set_image() on GTK3 to prevent icons from being + // trimmed with smaller sized buttons; see bug 528284. + if (OS.GTK3) { + OS.gtk_button_set_image(handle, arrowHandle); + } else { + OS.gtk_container_add (handle, arrowHandle); + } } else { boxHandle = gtk_box_new (OS.GTK_ORIENTATION_HORIZONTAL, false, 4); if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES); diff --git a/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug528284_TCFToolBarIssue.java b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug528284_TCFToolBarIssue.java new file mode 100644 index 0000000000..e2f6a6853b --- /dev/null +++ b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug528284_TCFToolBarIssue.java @@ -0,0 +1,79 @@ +package org.eclipse.swt.tests.gtk.snippets; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.ToolBar; +import org.eclipse.swt.widgets.ToolItem; + +/* + * Title: Bug 528284: [GTK3] Toolbar: TCF dropdown control is cutoff + * How to run: launch snippet and observe ToolBar inside the Shell + * Bug description: the Label and Button are cut off on the bottom + * Expected results: the Label and Button should be displayed as expected + * GTK Version(s): GTK3 + */ +public class Bug528284_TCFToolBarIssue { + public static void main(String[] args) { + Display display = new Display(); + Shell shell = new Shell(display); + ToolBar bar = new ToolBar (shell, SWT.HORIZONTAL); + + Composite panel = new Composite(bar, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.marginHeight = 1; layout.marginWidth = 1; + panel.setLayout(layout); + + + Composite labelPanel = new Composite(panel, SWT.BORDER); + labelPanel.setBackground(display.getSystemColor(SWT.COLOR_WHITE)); + GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false); + labelPanel.setLayoutData(layoutData); + layout = new GridLayout(3, false); + layout.marginHeight = 0; + layout.marginWidth = 0; + layout.horizontalSpacing = 0; + labelPanel.setLayout(layout); + + Label image = new Label(labelPanel, SWT.NONE); + layoutData = new GridData(SWT.LEAD, SWT.CENTER, false, true); + layoutData.horizontalIndent = 1; + layoutData.minimumWidth=20; + layoutData.widthHint=20; + image.setLayoutData(layoutData); + + Label text = new Label(labelPanel, SWT.NONE); + layoutData = new GridData(SWT.FILL, SWT.CENTER, true, true); + layoutData.minimumWidth = 25; + text.setLayoutData(layoutData); + + Button button = new Button(labelPanel, SWT.ARROW | SWT.DOWN | SWT.FLAT | SWT.NO_FOCUS); + layoutData = new GridData(SWT.TRAIL, SWT.CENTER, false, true); + layoutData.minimumWidth=20; + layoutData.widthHint = 20; + button.setLayoutData(layoutData); + + text.setText("this is a test"); + + + ToolItem item = new ToolItem(bar, SWT.SEPARATOR); + item.setControl(panel); + item.setWidth(panel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); + + bar.pack(); + shell.pack(); + shell.open(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) { + display.sleep(); + } + } + display.dispose(); + + } +}
\ No newline at end of file |