Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXi Yan2018-12-12 11:27:23 -0500
committerEric Williams2018-12-12 14:22:42 -0500
commit79883b32745e9d7a70a79ad10b4e4b702b0fab9d (patch)
treee8388828482d72b8b26f25fcb8998e94369abdb8
parent255fa872c6469a5eeacee480f8ad37cd246c1f99 (diff)
downloadeclipse.platform.swt-79883b32745e9d7a70a79ad10b4e4b702b0fab9d.tar.gz
eclipse.platform.swt-79883b32745e9d7a70a79ad10b4e4b702b0fab9d.tar.xz
eclipse.platform.swt-79883b32745e9d7a70a79ad10b4e4b702b0fab9d.zip
Bug 541381 - [GTK4] Replace gtk_container_get_border_width()
Replaced with gtk_widget_get_margin_*. Change-Id: I38a78ea6eb8cc5c8724d07fd8462fd8d8b3b0e88 Signed-off-by: Xi Yan <xixiyan@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c152
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java108
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java33
11 files changed, 330 insertions, 21 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 1d972c0e01..7f7bb12201 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
@@ -11816,6 +11816,86 @@ JNIEXPORT jboolean JNICALL GTK_NATIVE(_1gtk_1widget_1get_1mapped)
}
#endif
+#ifndef NO__1gtk_1widget_1get_1margin_1bottom
+JNIEXPORT jint JNICALL GTK_NATIVE(_1gtk_1widget_1get_1margin_1bottom)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jint rc = 0;
+ GTK_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1margin_1bottom_FUNC);
+/*
+ rc = (jint)gtk_widget_get_margin_bottom((GtkWidget *)arg0);
+*/
+ {
+ GTK_LOAD_FUNCTION(fp, gtk_widget_get_margin_bottom)
+ if (fp) {
+ rc = (jint)((jint (CALLING_CONVENTION*)(GtkWidget *))fp)((GtkWidget *)arg0);
+ }
+ }
+ GTK_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1margin_1bottom_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1get_1margin_1end
+JNIEXPORT jint JNICALL GTK_NATIVE(_1gtk_1widget_1get_1margin_1end)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jint rc = 0;
+ GTK_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1margin_1end_FUNC);
+/*
+ rc = (jint)gtk_widget_get_margin_end((GtkWidget *)arg0);
+*/
+ {
+ GTK_LOAD_FUNCTION(fp, gtk_widget_get_margin_end)
+ if (fp) {
+ rc = (jint)((jint (CALLING_CONVENTION*)(GtkWidget *))fp)((GtkWidget *)arg0);
+ }
+ }
+ GTK_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1margin_1end_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1get_1margin_1start
+JNIEXPORT jint JNICALL GTK_NATIVE(_1gtk_1widget_1get_1margin_1start)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jint rc = 0;
+ GTK_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1margin_1start_FUNC);
+/*
+ rc = (jint)gtk_widget_get_margin_start((GtkWidget *)arg0);
+*/
+ {
+ GTK_LOAD_FUNCTION(fp, gtk_widget_get_margin_start)
+ if (fp) {
+ rc = (jint)((jint (CALLING_CONVENTION*)(GtkWidget *))fp)((GtkWidget *)arg0);
+ }
+ }
+ GTK_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1margin_1start_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1get_1margin_1top
+JNIEXPORT jint JNICALL GTK_NATIVE(_1gtk_1widget_1get_1margin_1top)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jint rc = 0;
+ GTK_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1margin_1top_FUNC);
+/*
+ rc = (jint)gtk_widget_get_margin_top((GtkWidget *)arg0);
+*/
+ {
+ GTK_LOAD_FUNCTION(fp, gtk_widget_get_margin_top)
+ if (fp) {
+ rc = (jint)((jint (CALLING_CONVENTION*)(GtkWidget *))fp)((GtkWidget *)arg0);
+ }
+ }
+ GTK_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1margin_1top_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1gtk_1widget_1get_1name
JNIEXPORT jintLong JNICALL GTK_NATIVE(_1gtk_1widget_1get_1name)
(JNIEnv *env, jclass that, jintLong arg0)
@@ -12514,6 +12594,78 @@ JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1widget_1set_1has_1window)
}
#endif
+#ifndef NO__1gtk_1widget_1set_1margin_1bottom
+JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1widget_1set_1margin_1bottom)
+ (JNIEnv *env, jclass that, jintLong arg0, jint arg1)
+{
+ GTK_NATIVE_ENTER(env, that, _1gtk_1widget_1set_1margin_1bottom_FUNC);
+/*
+ gtk_widget_set_margin_bottom((GtkWidget *)arg0, (gint)arg1);
+*/
+ {
+ GTK_LOAD_FUNCTION(fp, gtk_widget_set_margin_bottom)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(GtkWidget *, gint))fp)((GtkWidget *)arg0, (gint)arg1);
+ }
+ }
+ GTK_NATIVE_EXIT(env, that, _1gtk_1widget_1set_1margin_1bottom_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1set_1margin_1end
+JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1widget_1set_1margin_1end)
+ (JNIEnv *env, jclass that, jintLong arg0, jint arg1)
+{
+ GTK_NATIVE_ENTER(env, that, _1gtk_1widget_1set_1margin_1end_FUNC);
+/*
+ gtk_widget_set_margin_end((GtkWidget *)arg0, (gint)arg1);
+*/
+ {
+ GTK_LOAD_FUNCTION(fp, gtk_widget_set_margin_end)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(GtkWidget *, gint))fp)((GtkWidget *)arg0, (gint)arg1);
+ }
+ }
+ GTK_NATIVE_EXIT(env, that, _1gtk_1widget_1set_1margin_1end_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1set_1margin_1start
+JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1widget_1set_1margin_1start)
+ (JNIEnv *env, jclass that, jintLong arg0, jint arg1)
+{
+ GTK_NATIVE_ENTER(env, that, _1gtk_1widget_1set_1margin_1start_FUNC);
+/*
+ gtk_widget_set_margin_start((GtkWidget *)arg0, (gint)arg1);
+*/
+ {
+ GTK_LOAD_FUNCTION(fp, gtk_widget_set_margin_start)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(GtkWidget *, gint))fp)((GtkWidget *)arg0, (gint)arg1);
+ }
+ }
+ GTK_NATIVE_EXIT(env, that, _1gtk_1widget_1set_1margin_1start_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1set_1margin_1top
+JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1widget_1set_1margin_1top)
+ (JNIEnv *env, jclass that, jintLong arg0, jint arg1)
+{
+ GTK_NATIVE_ENTER(env, that, _1gtk_1widget_1set_1margin_1top_FUNC);
+/*
+ gtk_widget_set_margin_top((GtkWidget *)arg0, (gint)arg1);
+*/
+ {
+ GTK_LOAD_FUNCTION(fp, gtk_widget_set_margin_top)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(GtkWidget *, gint))fp)((GtkWidget *)arg0, (gint)arg1);
+ }
+ }
+ GTK_NATIVE_EXIT(env, that, _1gtk_1widget_1set_1margin_1top_FUNC);
+}
+#endif
+
#ifndef NO__1gtk_1widget_1set_1name
JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1widget_1set_1name)
(JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1)
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 861bff696b..f3098d3565 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
@@ -1067,6 +1067,10 @@ char * GTK_nativeFunctionNames[] = {
"_1gtk_1widget_1get_1has_1surface",
"_1gtk_1widget_1get_1has_1window",
"_1gtk_1widget_1get_1mapped",
+ "_1gtk_1widget_1get_1margin_1bottom",
+ "_1gtk_1widget_1get_1margin_1end",
+ "_1gtk_1widget_1get_1margin_1start",
+ "_1gtk_1widget_1get_1margin_1top",
"_1gtk_1widget_1get_1name",
"_1gtk_1widget_1get_1opacity",
"_1gtk_1widget_1get_1pango_1context",
@@ -1115,6 +1119,10 @@ char * GTK_nativeFunctionNames[] = {
"_1gtk_1widget_1set_1halign",
"_1gtk_1widget_1set_1has_1surface",
"_1gtk_1widget_1set_1has_1window",
+ "_1gtk_1widget_1set_1margin_1bottom",
+ "_1gtk_1widget_1set_1margin_1end",
+ "_1gtk_1widget_1set_1margin_1start",
+ "_1gtk_1widget_1set_1margin_1top",
"_1gtk_1widget_1set_1name",
"_1gtk_1widget_1set_1opacity",
"_1gtk_1widget_1set_1parent_1surface",
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 c83011da67..7162d38da0 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
@@ -1065,6 +1065,10 @@ typedef enum {
_1gtk_1widget_1get_1has_1surface_FUNC,
_1gtk_1widget_1get_1has_1window_FUNC,
_1gtk_1widget_1get_1mapped_FUNC,
+ _1gtk_1widget_1get_1margin_1bottom_FUNC,
+ _1gtk_1widget_1get_1margin_1end_FUNC,
+ _1gtk_1widget_1get_1margin_1start_FUNC,
+ _1gtk_1widget_1get_1margin_1top_FUNC,
_1gtk_1widget_1get_1name_FUNC,
_1gtk_1widget_1get_1opacity_FUNC,
_1gtk_1widget_1get_1pango_1context_FUNC,
@@ -1113,6 +1117,10 @@ typedef enum {
_1gtk_1widget_1set_1halign_FUNC,
_1gtk_1widget_1set_1has_1surface_FUNC,
_1gtk_1widget_1set_1has_1window_FUNC,
+ _1gtk_1widget_1set_1margin_1bottom_FUNC,
+ _1gtk_1widget_1set_1margin_1end_FUNC,
+ _1gtk_1widget_1set_1margin_1start_FUNC,
+ _1gtk_1widget_1set_1margin_1top_FUNC,
_1gtk_1widget_1set_1name_FUNC,
_1gtk_1widget_1set_1opacity_FUNC,
_1gtk_1widget_1set_1parent_1surface_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
index 1d866c5f0f..b1d119bc9d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
@@ -2874,6 +2874,62 @@ public class GTK extends OS {
}
}
/**
+ * @method flags=dynamic
+ * @param widget cast=(GtkWidget *)
+ * @param margin cast=(gint)
+ */
+ public static final native void _gtk_widget_set_margin_start (long /*int*/ widget, int margin);
+ public static final void gtk_widget_set_margin_start (long /*int*/ widget, int margin) {
+ lock.lock();
+ try {
+ _gtk_widget_set_margin_start(widget, margin);
+ } finally {
+ lock.unlock();
+ }
+ }
+ /**
+ * @method flags=dynamic
+ * @param widget cast=(GtkWidget *)
+ * @param margin cast=(gint)
+ */
+ public static final native void _gtk_widget_set_margin_end (long /*int*/ widget, int margin);
+ public static final void gtk_widget_set_margin_end (long /*int*/ widget, int margin) {
+ lock.lock();
+ try {
+ _gtk_widget_set_margin_end(widget, margin);
+ } finally {
+ lock.unlock();
+ }
+ }
+ /**
+ * @method flags=dynamic
+ * @param widget cast=(GtkWidget *)
+ * @param margin cast=(gint)
+ */
+ public static final native void _gtk_widget_set_margin_top (long /*int*/ widget, int margin);
+ public static final void gtk_widget_set_margin_top (long /*int*/ widget, int margin) {
+ lock.lock();
+ try {
+ _gtk_widget_set_margin_top(widget, margin);
+ } finally {
+ lock.unlock();
+ }
+ }
+ /**
+ * @method flags=dynamic
+ * @param widget cast=(GtkWidget *)
+ * @param margin cast=(gint)
+ */
+ public static final native void _gtk_widget_set_margin_bottom (long /*int*/ widget, int margin);
+ public static final void gtk_widget_set_margin_bottom (long /*int*/ widget, int margin) {
+ lock.lock();
+ try {
+ _gtk_widget_set_margin_bottom(widget, margin);
+ } finally {
+ lock.unlock();
+ }
+ }
+ /**
* @param title cast=(const gchar *)
* @param parent cast=(GtkWindow *)
*/
@@ -8256,6 +8312,58 @@ public class GTK extends OS {
lock.unlock();
}
}
+ /**
+ * @method flags=dynamic
+ * @param widget cast=(GtkWidget *)
+ */
+ public static final native int _gtk_widget_get_margin_start (long /*int*/ widget);
+ public static final int gtk_widget_get_margin_start (long /*int*/ widget) {
+ lock.lock();
+ try {
+ return gtk_widget_get_margin_start(widget);
+ } finally {
+ lock.unlock();
+ }
+ }
+ /**
+ * @method flags=dynamic
+ * @param widget cast=(GtkWidget *)
+ */
+ public static final native int _gtk_widget_get_margin_end (long /*int*/ widget);
+ public static final int gtk_widget_get_margin_end (long /*int*/ widget) {
+ lock.lock();
+ try {
+ return gtk_widget_get_margin_end(widget);
+ } finally {
+ lock.unlock();
+ }
+ }
+ /**
+ * @method flags=dynamic
+ * @param widget cast=(GtkWidget *)
+ */
+ public static final native int _gtk_widget_get_margin_top (long /*int*/ widget);
+ public static final int gtk_widget_get_margin_top (long /*int*/ widget) {
+ lock.lock();
+ try {
+ return _gtk_widget_get_margin_top(widget);
+ } finally {
+ lock.unlock();
+ }
+ }
+ /**
+ * @method flags=dynamic
+ * @param widget cast=(GtkWidget *)
+ */
+ public static final native int _gtk_widget_get_margin_bottom (long /*int*/ widget);
+ public static final int gtk_widget_get_margin_bottom (long /*int*/ widget) {
+ lock.lock();
+ try {
+ return _gtk_widget_get_margin_bottom(widget);
+ } finally {
+ lock.unlock();
+ }
+ }
/** @param widget cast=(GtkWidget *) */
public static final native boolean _gtk_widget_get_mapped(long /*int*/ widget);
public static final boolean gtk_widget_get_mapped(long /*int*/ widget) {
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 6d90fae241..f484c68dcf 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
@@ -199,7 +199,7 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
Point size;
boolean wrap = labelHandle != 0 && (style & SWT.WRAP) != 0 && GTK.gtk_widget_get_visible (labelHandle);
if (wrap) {
- int borderWidth = GTK.gtk_container_get_border_width (handle);
+ int borderWidth = gtk_container_get_border_width_or_margin (handle);
int[] focusWidth = new int[1];
GTK.gtk_widget_style_get (handle, OS.focus_line_width, focusWidth, 0);
int[] focusPadding = new int[1];
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java
index ee85511ece..602aa41621 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java
@@ -125,7 +125,7 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
Point size = computeNativeSize (handle, wHint, hHint, changed);
if (size.x == 0 && wHint == SWT.DEFAULT) size.x = DEFAULT_WIDTH;
if (size.y == 0 && hHint == SWT.DEFAULT) size.y = DEFAULT_HEIGHT;
- int border = GTK.gtk_container_get_border_width (handle);
+ int border = gtk_container_get_border_width_or_margin (handle);
size.x += 2 * border;
size.y += 2 * border;
return size;
@@ -150,7 +150,7 @@ void createHandle (int index) {
} else {
GTK.gtk_container_add (fixedHandle, handle);
}
- GTK.gtk_container_set_border_width (handle, 0);
+ gtk_container_set_border_width (handle, 0);
// In GTK 3 font description is inherited from parent widget which is not how SWT has always worked,
// reset to default font to get the usual behavior
setFontDescription(defaultFont().handle);
@@ -530,7 +530,7 @@ void setSpacingInPixels (int spacing) {
if (spacing == this.spacing) return;
this.spacing = spacing;
GTK.gtk_box_set_spacing (handle, spacing);
- GTK.gtk_container_set_border_width (handle, spacing);
+ gtk_container_set_border_width (handle, spacing);
}
void showItem (ExpandItem item) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
index 43f0474ed3..7ed8daa2f3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
@@ -218,7 +218,7 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
fontHeight += bufferBottom [0] + bufferTop [0];
if (frameHandle != 0) {
fontHeight += 2 * getThickness (frameHandle).y;
- fontHeight += 2 * GTK.gtk_container_get_border_width (frameHandle);
+ fontHeight += 2 * gtk_container_get_border_width_or_margin (frameHandle);
}
size.y = Math.max (size.y, fontHeight);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
index f9345b0f70..3e2825f5ee 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
@@ -118,8 +118,8 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
Rectangle computeTrimInPixels (int x, int y, int width, int height) {
checkWidget();
int border = 0;
- if (fixedHandle != 0) border += GTK.gtk_container_get_border_width (fixedHandle);
- if (scrolledHandle != 0) border += GTK.gtk_container_get_border_width (scrolledHandle);
+ if (fixedHandle != 0) border += gtk_container_get_border_width_or_margin (fixedHandle);
+ if (scrolledHandle != 0) border += gtk_container_get_border_width_or_margin (scrolledHandle);
int trimX = x - border, trimY = y - border;
int trimWidth = width + (border * 2), trimHeight = height + (border * 2);
trimHeight += hScrollBarWidth ();
@@ -202,9 +202,9 @@ void destroyScrollBar (ScrollBar bar) {
int getBorderWidthInPixels () {
checkWidget();
int border = 0;
- if (fixedHandle != 0) border += GTK.gtk_container_get_border_width (fixedHandle);
+ if (fixedHandle != 0) border += gtk_container_get_border_width_or_margin (fixedHandle);
if (scrolledHandle != 0) {
- border += GTK.gtk_container_get_border_width (scrolledHandle);
+ border += gtk_container_get_border_width_or_margin (scrolledHandle);
if (GTK.gtk_scrolled_window_get_shadow_type (scrolledHandle) != GTK.GTK_SHADOW_NONE) {
border += getThickness (scrolledHandle).x;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
index d4aa51e429..525397d7ce 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
@@ -693,7 +693,7 @@ Rectangle computeTrimInPixels (int x, int y, int width, int height) {
Rectangle trim = super.computeTrimInPixels (x, y, width, height);
int border = 0;
if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0 || isCustomResize()) {
- border = GTK.gtk_container_get_border_width (shellHandle);
+ border = gtk_container_get_border_width_or_margin (shellHandle);
}
int trimWidth = trimWidth (), trimHeight = trimHeight ();
trim.x -= (trimWidth / 2) + border;
@@ -789,7 +789,7 @@ void createHandle (int index) {
}
GTK.gtk_window_set_title (shellHandle, new byte [1]);
if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0) {
- GTK.gtk_container_set_border_width (shellHandle, 1);
+ gtk_container_set_border_width (shellHandle, 1);
if (GTK.GTK_VERSION < OS.VERSION (3, 14, 0)) {
GTK.gtk_widget_override_background_color (shellHandle, GTK.GTK_STATE_FLAG_NORMAL, new GdkRGBA());
}
@@ -809,7 +809,7 @@ void createHandle (int index) {
GTK.gtk_window_set_decorated(shellHandle, false);
}
if (isCustomResize ()) {
- GTK.gtk_container_set_border_width (shellHandle, BORDER);
+ gtk_container_set_border_width (shellHandle, BORDER);
}
}
vboxHandle = gtk_box_new (GTK.GTK_ORIENTATION_VERTICAL, false, 0);
@@ -1040,7 +1040,7 @@ void forceResize () {
* before Shell is fully opened, which gets an incorrect allocation.
* Fix is to use the calculated box width/height if bounds have been set.
*/
- int border = GTK.gtk_container_get_border_width (shellHandle);
+ int border = gtk_container_get_border_width_or_margin (shellHandle);
int boxWidth = oldWidth - 2*border;
int boxHeight = oldHeight - 2*border;
if (boxWidth != allocation.width || boxHeight != allocation.height) {
@@ -1055,7 +1055,7 @@ void forceResize (int width, int height) {
int clientWidth = 0;
if ((style & SWT.MIRRORED) != 0) clientWidth = getClientWidth ();
GtkAllocation allocation = new GtkAllocation ();
- int border = GTK.GTK4 ? 0 : GTK.gtk_container_get_border_width (shellHandle);
+ int border = gtk_container_get_border_width_or_margin (shellHandle);
allocation.x = border;
allocation.y = border;
allocation.width = width;
@@ -1116,7 +1116,7 @@ int getResizeMode (double x, double y) {
GTK.gtk_widget_get_allocation (shellHandle, allocation);
int width = allocation.width;
int height = allocation.height;
- int border = GTK.gtk_container_get_border_width (shellHandle);
+ int border = gtk_container_get_border_width_or_margin (shellHandle);
int mode = 0;
if (y >= height - border) {
mode = GDK.GDK_BOTTOM_SIDE ;
@@ -1257,7 +1257,7 @@ Point getSizeInPixels () {
int height = allocation.height;
int border = 0;
if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0 || isCustomResize()) {
- border = GTK.gtk_container_get_border_width (shellHandle);
+ border = gtk_container_get_border_width_or_margin (shellHandle);
}
return new Point (width + trimWidth () + 2*border, height + trimHeight () + 2*border);
}
@@ -1435,7 +1435,7 @@ long /*int*/ gtk_draw (long /*int*/ widget, long /*int*/ cairo) {
int [] height = new int [1];
long /*int*/ window = gtk_widget_get_window (widget);
gdk_window_get_size (window, width, height);
- int border = GTK.gtk_container_get_border_width (widget);
+ int border = gtk_container_get_border_width_or_margin (widget);
long /*int*/ context = GTK.gtk_widget_get_style_context (shellHandle);
//TODO draw shell frame on GTK3
GTK.gtk_style_context_save (context);
@@ -1547,7 +1547,7 @@ long /*int*/ gtk_motion_notify_event (long /*int*/ widget, long /*int*/ event) {
GdkEventMotion gdkEvent = new GdkEventMotion ();
OS.memmove (gdkEvent, event, GdkEventMotion.sizeof);
if ((gdkEvent.state & GDK.GDK_BUTTON1_MASK) != 0) {
- int border = GTK.gtk_container_get_border_width (shellHandle);
+ int border = gtk_container_get_border_width_or_margin (shellHandle);
int dx = (int)(gdkEvent.x_root - display.resizeLocationX);
int dy = (int)(gdkEvent.y_root - display.resizeLocationY);
int x = display.resizeBoundsX;
@@ -1982,7 +1982,7 @@ void resizeBounds (int width, int height, boolean notify) {
if (enableWindow != 0) {
GDK.gdk_window_resize (enableWindow, width, height);
}
- border = GTK.gtk_container_get_border_width (shellHandle);
+ border = gtk_container_get_border_width_or_margin (shellHandle);
}
int boxWidth = width - 2*border;
int boxHeight = height - 2*border;
@@ -2990,7 +2990,7 @@ Rectangle getBoundsInPixels () {
int height = allocation.height;
int border = 0;
if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0 || isCustomResize()) {
- border = GTK.gtk_container_get_border_width (shellHandle);
+ border = gtk_container_get_border_width_or_margin (shellHandle);
}
return new Rectangle (x [0], y [0], width + trimWidth () + 2*border, height + trimHeight () + 2*border);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
index a43c243c4f..aa40e5784c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
@@ -665,7 +665,7 @@ Rectangle computeTrimInPixels (int x, int y, int width, int height) {
GTK.gtk_entry_get_icon_area(handle, GTK.GTK_ENTRY_ICON_SECONDARY, icon_area);
trim.width += icon_area.width;
} else {
- int borderWidth = GTK.gtk_container_get_border_width (handle);
+ int borderWidth = gtk_container_get_border_width_or_margin (handle);
xborder += borderWidth;
yborder += borderWidth;
}
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 5e0ed43028..7f7fbbba5e 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
@@ -2050,5 +2050,38 @@ void gtk_widget_get_preferred_size (long /*int*/ widget, GtkRequisition requisit
void gtk_image_set_from_gicon (long /*int*/ imageHandle, long /*int*/ pixbuf){
GTK.gtk_image_set_from_gicon(imageHandle, pixbuf, GTK.GTK_ICON_SIZE_SMALL_TOOLBAR);
}
+/**
+ * Retrieves the amount of space around the outside of the container.
+ * On GTK3: this is done using gtk_container_get_border_width.
+ * On GTK4: this is done by returning the max margin on any side.
+ * @param handle
+ * @return amount of space around the outside of the container.
+ */
+int gtk_container_get_border_width_or_margin (long /*int*/ handle) {
+ if (GTK.GTK4) {
+ int marginTop = GTK.gtk_widget_get_margin_top(handle);
+ int marginBottom = GTK.gtk_widget_get_margin_bottom(handle);
+ int marginStart = GTK.gtk_widget_get_margin_start(handle);
+ int marginEnd = GTK.gtk_widget_get_margin_end(handle);
+ return Math.max(Math.max(marginTop, marginBottom), Math.max(marginStart, marginEnd));
+ } else {
+ return GTK.gtk_container_get_border_width(handle);
+ }
+}
+/**
+ * Sets the border width of the container to all sides of the container.
+ * @param handle
+ * @param border_width
+ */
+void gtk_container_set_border_width (long /*int*/ handle, int border_width) {
+ if (GTK.GTK4) {
+ GTK.gtk_widget_set_margin_top(handle, border_width);
+ GTK.gtk_widget_set_margin_bottom(handle, border_width);
+ GTK.gtk_widget_set_margin_start(handle, border_width);
+ GTK.gtk_widget_set_margin_end(handle, border_width);
+ } else {
+ GTK.gtk_container_set_border_width (handle, border_width);
+ }
+}
}

Back to the top