Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ImageTransfer.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk/org/eclipse/swt/opengl/GLCanvas.java3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c.c247
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c_stats.c3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c_stats.h3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/C.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c489
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java189
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java74
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Transform.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java110
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontMetrics.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java201
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java180
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java73
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java85
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java65
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java25
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java80
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java192
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java44
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java86
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java23
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java71
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java51
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java24
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java75
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java18
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java46
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java33
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java46
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java75
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java18
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java34
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java6
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java4
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Image.java1
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Region.java20
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java2
65 files changed, 2556 insertions, 491 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java b/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java
index 9852f995f3..b3b0d42c97 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java
@@ -19,6 +19,7 @@ import java.lang.reflect.*;
/* SWT Imports */
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
@@ -249,7 +250,7 @@ public static Frame new_Frame (final Composite parent) {
});
break;
case SWT.Resize:
- final Rectangle clientArea = parent.getClientArea();
+ final Rectangle clientArea = DPIUtil.autoScaleUp(parent.getClientArea());
EventQueue.invokeLater(new Runnable () {
@Override
public void run () {
@@ -267,7 +268,7 @@ public static Frame new_Frame (final Composite parent) {
@Override
public void run () {
if (parent.isDisposed()) return;
- final Rectangle clientArea = parent.getClientArea();
+ final Rectangle clientArea = DPIUtil.autoScaleUp(parent.getClientArea());
EventQueue.invokeLater(new Runnable () {
@Override
public void run () {
@@ -317,7 +318,7 @@ public static Shell new_Shell (final Display display, final Canvas parent) {
public void run () {
if (shell.isDisposed()) return;
Dimension dim = parent.getSize ();
- shell.setSize (dim.width, dim.height);
+ shell.setSize (DPIUtil.autoScaleDown(new Point(dim.width, dim.height)));
}
});
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ImageTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ImageTransfer.java
index aa3c1f6059..04cf42ccb0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ImageTransfer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ImageTransfer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.swt.dnd;
-import org.eclipse.swt.SWT;
+import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java
index 7f5bd1be5b..1e06d0f45a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java
@@ -361,6 +361,8 @@ boolean sendTraverse () {
}
void setSize (long /*int*/ embedHandle, int width, int height) {
+ width = DPIUtil.autoScaleUp(width);
+ height = DPIUtil.autoScaleUp(height);
OS.gtk_widget_set_size_request (embedHandle, width, height);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk/org/eclipse/swt/opengl/GLCanvas.java b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk/org/eclipse/swt/opengl/GLCanvas.java
index acf9111c84..247aa7f6b5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk/org/eclipse/swt/opengl/GLCanvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk/org/eclipse/swt/opengl/GLCanvas.java
@@ -12,6 +12,7 @@ package org.eclipse.swt.opengl;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.internal.opengl.glx.*;
import org.eclipse.swt.widgets.*;
@@ -161,7 +162,7 @@ public GLCanvas (Composite parent, int style, GLData data) {
GLX.glViewport (viewport [0],viewport [1],viewport [2],viewport [3]);
break;
case SWT.Resize:
- Rectangle clientArea = getClientArea();
+ Rectangle clientArea = DPIUtil.autoScaleUp(getClientArea());
OS.gdk_window_move (glWindow, clientArea.x, clientArea.y);
OS.gdk_window_resize (glWindow, clientArea.width, clientArea.height);
break;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c.c b/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c.c
index 67018e9a64..7aeca2a702 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -101,10 +101,24 @@ JNIEXPORT void JNICALL C_NATIVE(memmove__J_3BJ)(JNIEnv *env, jclass that, jintLo
#else
C_NATIVE_ENTER(env, that, memmove__J_3BJ_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
#ifndef JNI64
C_NATIVE_EXIT(env, that, memmove__I_3BI_FUNC);
#else
@@ -126,10 +140,24 @@ JNIEXPORT void JNICALL C_NATIVE(memmove__J_3CJ)(JNIEnv *env, jclass that, jintLo
#else
C_NATIVE_ENTER(env, that, memmove__J_3CJ_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
#ifndef JNI64
C_NATIVE_EXIT(env, that, memmove__I_3CI_FUNC);
#else
@@ -151,10 +179,24 @@ JNIEXPORT void JNICALL C_NATIVE(memmove__J_3DJ)(JNIEnv *env, jclass that, jintLo
#else
C_NATIVE_ENTER(env, that, memmove__J_3DJ_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
#ifndef JNI64
C_NATIVE_EXIT(env, that, memmove__I_3DI_FUNC);
#else
@@ -176,10 +218,24 @@ JNIEXPORT void JNICALL C_NATIVE(memmove__J_3FJ)(JNIEnv *env, jclass that, jintLo
#else
C_NATIVE_ENTER(env, that, memmove__J_3FJ_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetFloatArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseFloatArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
#ifndef JNI64
C_NATIVE_EXIT(env, that, memmove__I_3FI_FUNC);
#else
@@ -201,10 +257,24 @@ JNIEXPORT void JNICALL C_NATIVE(memmove__J_3IJ)(JNIEnv *env, jclass that, jintLo
#else
C_NATIVE_ENTER(env, that, memmove__J_3IJ_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
#ifndef JNI64
C_NATIVE_EXIT(env, that, memmove__I_3II_FUNC);
#else
@@ -226,10 +296,24 @@ JNIEXPORT void JNICALL C_NATIVE(memmove__J_3JJ)(JNIEnv *env, jclass that, jintLo
#else
C_NATIVE_ENTER(env, that, memmove__J_3JJ_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetLongArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseLongArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
#ifndef JNI64
C_NATIVE_EXIT(env, that, memmove__I_3JI_FUNC);
#else
@@ -251,10 +335,24 @@ JNIEXPORT void JNICALL C_NATIVE(memmove__J_3SJ)(JNIEnv *env, jclass that, jintLo
#else
C_NATIVE_ENTER(env, that, memmove__J_3SJ_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetShortArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseShortArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
#ifndef JNI64
C_NATIVE_EXIT(env, that, memmove__I_3SI_FUNC);
#else
@@ -276,10 +374,24 @@ JNIEXPORT void JNICALL C_NATIVE(memmove___3BJJ)(JNIEnv *env, jclass that, jbyteA
#else
C_NATIVE_ENTER(env, that, memmove___3BJJ_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ }
memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+ } else
+#endif
+ {
+ if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ }
#ifndef JNI64
C_NATIVE_EXIT(env, that, memmove___3BII_FUNC);
#else
@@ -302,12 +414,28 @@ JNIEXPORT void JNICALL C_NATIVE(memmove___3B_3CJ)(JNIEnv *env, jclass that, jbyt
#else
C_NATIVE_ENTER(env, that, memmove___3B_3CJ_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ if (arg1) if ((lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
memmove((void *)lparg0, (const void *)lparg1, (size_t)arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, JNI_ABORT);
+ if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ }
#ifndef JNI64
C_NATIVE_EXIT(env, that, memmove___3B_3CI_FUNC);
#else
@@ -329,10 +457,24 @@ JNIEXPORT void JNICALL C_NATIVE(memmove___3CJJ)(JNIEnv *env, jclass that, jcharA
#else
C_NATIVE_ENTER(env, that, memmove___3CJJ_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ }
memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+ } else
+#endif
+ {
+ if (arg0 && lparg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
+ }
#ifndef JNI64
C_NATIVE_EXIT(env, that, memmove___3CII_FUNC);
#else
@@ -354,10 +496,24 @@ JNIEXPORT void JNICALL C_NATIVE(memmove___3DJJ)(JNIEnv *env, jclass that, jdoubl
#else
C_NATIVE_ENTER(env, that, memmove___3DJJ_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetDoubleArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ }
memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+ } else
+#endif
+ {
+ if (arg0 && lparg0) (*env)->ReleaseDoubleArrayElements(env, arg0, lparg0, 0);
+ }
#ifndef JNI64
C_NATIVE_EXIT(env, that, memmove___3DII_FUNC);
#else
@@ -379,10 +535,24 @@ JNIEXPORT void JNICALL C_NATIVE(memmove___3FJJ)(JNIEnv *env, jclass that, jfloat
#else
C_NATIVE_ENTER(env, that, memmove___3FJJ_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetFloatArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ }
memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+ } else
+#endif
+ {
+ if (arg0 && lparg0) (*env)->ReleaseFloatArrayElements(env, arg0, lparg0, 0);
+ }
#ifndef JNI64
C_NATIVE_EXIT(env, that, memmove___3FII_FUNC);
#else
@@ -404,10 +574,24 @@ JNIEXPORT void JNICALL C_NATIVE(memmove___3IJJ)(JNIEnv *env, jclass that, jintAr
#else
C_NATIVE_ENTER(env, that, memmove___3IJJ_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ }
memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+ } else
+#endif
+ {
+ if (arg0 && lparg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0);
+ }
#ifndef JNI64
C_NATIVE_EXIT(env, that, memmove___3III_FUNC);
#else
@@ -431,10 +615,24 @@ JNIEXPORT void JNICALL C_NATIVE(memmove___3I_3BJ)(JNIEnv *env, jclass that, jint
C_NATIVE_ENTER(env, that, memmove___3I_3BJ_FUNC);
#endif
if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ }
memmove((void *)lparg0, (const void *)lparg1, (size_t)arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+ } else
+#endif
+ {
+ if (arg0 && lparg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0);
+ }
if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
#ifndef JNI64
C_NATIVE_EXIT(env, that, memmove___3I_3BI_FUNC);
@@ -457,10 +655,24 @@ JNIEXPORT void JNICALL C_NATIVE(memmove___3JJJ)(JNIEnv *env, jclass that, jlongA
#else
C_NATIVE_ENTER(env, that, memmove___3JJJ_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetLongArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ }
memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+ } else
+#endif
+ {
+ if (arg0 && lparg0) (*env)->ReleaseLongArrayElements(env, arg0, lparg0, 0);
+ }
#ifndef JNI64
C_NATIVE_EXIT(env, that, memmove___3JII_FUNC);
#else
@@ -482,10 +694,24 @@ JNIEXPORT void JNICALL C_NATIVE(memmove___3SJJ)(JNIEnv *env, jclass that, jshort
#else
C_NATIVE_ENTER(env, that, memmove___3SJJ_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetShortArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ }
memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+ } else
+#endif
+ {
+ if (arg0 && lparg0) (*env)->ReleaseShortArrayElements(env, arg0, lparg0, 0);
+ }
#ifndef JNI64
C_NATIVE_EXIT(env, that, memmove___3SII_FUNC);
#else
@@ -506,6 +732,25 @@ JNIEXPORT jintLong JNICALL C_NATIVE(memset)
}
#endif
+#ifndef NO_setenv
+JNIEXPORT jint JNICALL C_NATIVE(setenv)
+ (JNIEnv *env, jclass that, jbyteArray arg0, jbyteArray arg1, jint arg2)
+{
+ jbyte *lparg0=NULL;
+ jbyte *lparg1=NULL;
+ jint rc = 0;
+ C_NATIVE_ENTER(env, that, setenv_FUNC);
+ if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ rc = (jint)setenv((const char *)lparg0, (const char *)lparg1, arg2);
+fail:
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ C_NATIVE_EXIT(env, that, setenv_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_strlen
JNIEXPORT jint JNICALL C_NATIVE(strlen)
(JNIEnv *env, jclass that, jintLong arg0)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c_stats.c
index 932c91cfbd..d763ed6ea0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c_stats.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -105,6 +105,7 @@ char * C_nativeFunctionNames[] = {
"memmove___3SJJ",
#endif
"memset",
+ "setenv",
"strlen",
};
#define NATIVE_FUNCTION_COUNT sizeof(C_nativeFunctionNames) / sizeof(char*)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c_stats.h
index cc34b1cb8b..e0da1090fd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/common/library/c_stats.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -115,5 +115,6 @@ typedef enum {
memmove___3SJJ_FUNC,
#endif
memset_FUNC,
+ setenv_FUNC,
strlen_FUNC,
} C_FUNCS;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/C.java b/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/C.java
index dcafafe853..c511494c22 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/C.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/C.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,6 +22,11 @@ public class C extends Platform {
public static final native void free (long /*int*/ ptr);
/** @param env cast=(const char *) */
public static final native long /*int*/ getenv (byte[] env);
+/**
+ * @param env cast=(const char *)
+ * @param value cast=(const char *)
+ */
+public static final native int setenv (byte[] env, byte[] value, int overwrite);
public static final native long /*int*/ malloc (long /*int*/ size);
/**
* @param dest cast=(void *)
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 02dbadddf1..c367399fa7 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
@@ -3861,6 +3861,129 @@ fail:
}
#endif
+#ifndef NO__1g_1settings_1get
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1settings_1get)
+ (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jbyteArray arg2, jbyteArray arg3, jintArray arg4)
+{
+ jbyte *lparg1=NULL;
+ jbyte *lparg2=NULL;
+ jbyte *lparg3=NULL;
+ jint *lparg4=NULL;
+ OS_NATIVE_ENTER(env, that, _1g_1settings_1get_FUNC);
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+/*
+ g_settings_get((GSettings *)arg0, (const gchar *)lparg1, lparg2, lparg3, lparg4);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_settings_get)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(GSettings *, const gchar *, jbyte *, jbyte *, jint *))fp)((GSettings *)arg0, (const gchar *)lparg1, lparg2, lparg3, lparg4);
+ }
+ }
+fail:
+ if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+ if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+ if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ OS_NATIVE_EXIT(env, that, _1g_1settings_1get_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1settings_1get_1value
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1settings_1get_1value)
+ (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1)
+{
+ jbyte *lparg1=NULL;
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1settings_1get_1value_FUNC);
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+ rc = (jintLong)g_settings_get_value((GSettings *)arg0, (const gchar *)lparg1);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_settings_get_value)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GSettings *, const gchar *))fp)((GSettings *)arg0, (const gchar *)lparg1);
+ }
+ }
+fail:
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ OS_NATIVE_EXIT(env, that, _1g_1settings_1get_1value_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1settings_1new
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1settings_1new)
+ (JNIEnv *env, jclass that, jbyteArray arg0)
+{
+ jbyte *lparg0=NULL;
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1settings_1new_FUNC);
+ if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+/*
+ rc = (jintLong)g_settings_new((const gchar *)lparg0);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_settings_new)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(const gchar *))fp)((const gchar *)lparg0);
+ }
+ }
+fail:
+ if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ OS_NATIVE_EXIT(env, that, _1g_1settings_1new_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1settings_1schema_1source_1get_1default
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1settings_1schema_1source_1get_1default)
+ (JNIEnv *env, jclass that)
+{
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1settings_1schema_1source_1get_1default_FUNC);
+/*
+ rc = (jintLong)g_settings_schema_source_get_default();
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_settings_schema_source_get_default)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)())fp)();
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1g_1settings_1schema_1source_1get_1default_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1settings_1schema_1source_1lookup
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1settings_1schema_1source_1lookup)
+ (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jboolean arg2)
+{
+ jbyte *lparg1=NULL;
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1settings_1schema_1source_1lookup_FUNC);
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+ rc = (jintLong)g_settings_schema_source_lookup((GSettingsSchemaSource *)arg0, (const gchar *)lparg1, (gboolean)arg2);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_settings_schema_source_lookup)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GSettingsSchemaSource *, const gchar *, gboolean))fp)((GSettingsSchemaSource *)arg0, (const gchar *)lparg1, (gboolean)arg2);
+ }
+ }
+fail:
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ OS_NATIVE_EXIT(env, that, _1g_1settings_1schema_1source_1lookup_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1g_1signal_1add_1emission_1hook
JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1signal_1add_1emission_1hook)
(JNIEnv *env, jclass that, jint arg0, jint arg1, jintLong arg2, jintLong arg3, jintLong arg4)
@@ -4476,16 +4599,36 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1utf16_1to_1utf8)
jintLong *lparg4=NULL;
jintLong rc = 0;
OS_NATIVE_ENTER(env, that, _1g_1utf16_1to_1utf8_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
if (arg4) if ((lparg4 = (*env)->GetPrimitiveArrayCritical(env, arg4, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ if (arg2) if ((lparg2 = (*env)->GetIntLongArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ if (arg3) if ((lparg3 = (*env)->GetIntLongArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ if (arg4) if ((lparg4 = (*env)->GetIntLongArrayElements(env, arg4, NULL)) == NULL) goto fail;
+ }
rc = (jintLong)g_utf16_to_utf8((const gunichar2 *)lparg0, (glong)arg1, (glong *)lparg2, (glong *)lparg3, (GError **)lparg4);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg4 && lparg4) (*env)->ReleasePrimitiveArrayCritical(env, arg4, lparg4, 0);
if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, 0);
if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, 0);
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg4 && lparg4) (*env)->ReleaseIntLongArrayElements(env, arg4, lparg4, 0);
+ if (arg3 && lparg3) (*env)->ReleaseIntLongArrayElements(env, arg3, lparg3, 0);
+ if (arg2 && lparg2) (*env)->ReleaseIntLongArrayElements(env, arg2, lparg2, 0);
+ if (arg0 && lparg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, _1g_1utf16_1to_1utf8_FUNC);
return rc;
}
@@ -4543,14 +4686,32 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1utf8_1to_1utf16__JJ_3J_3J_3J)(JNIEnv *
#else
OS_NATIVE_ENTER(env, that, _1g_1utf8_1to_1utf16__JJ_3J_3J_3J_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
if (arg4) if ((lparg4 = (*env)->GetPrimitiveArrayCritical(env, arg4, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg2) if ((lparg2 = (*env)->GetIntLongArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ if (arg3) if ((lparg3 = (*env)->GetIntLongArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ if (arg4) if ((lparg4 = (*env)->GetIntLongArrayElements(env, arg4, NULL)) == NULL) goto fail;
+ }
rc = (jintLong)g_utf8_to_utf16((const gchar *)arg0, (glong)arg1, (glong *)lparg2, (glong *)lparg3, (GError **)lparg4);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg4 && lparg4) (*env)->ReleasePrimitiveArrayCritical(env, arg4, lparg4, 0);
if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, 0);
if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, 0);
+ } else
+#endif
+ {
+ if (arg4 && lparg4) (*env)->ReleaseIntLongArrayElements(env, arg4, lparg4, 0);
+ if (arg3 && lparg3) (*env)->ReleaseIntLongArrayElements(env, arg3, lparg3, 0);
+ if (arg2 && lparg2) (*env)->ReleaseIntLongArrayElements(env, arg2, lparg2, 0);
+ }
#ifndef JNI64
OS_NATIVE_EXIT(env, that, _1g_1utf8_1to_1utf16__II_3I_3I_3I_FUNC);
#else
@@ -4577,16 +4738,36 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1utf8_1to_1utf16___3BJ_3J_3J_3J)(JNIEnv
#else
OS_NATIVE_ENTER(env, that, _1g_1utf8_1to_1utf16___3BJ_3J_3J_3J_FUNC);
#endif
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
if (arg4) if ((lparg4 = (*env)->GetPrimitiveArrayCritical(env, arg4, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ if (arg2) if ((lparg2 = (*env)->GetIntLongArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ if (arg3) if ((lparg3 = (*env)->GetIntLongArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ if (arg4) if ((lparg4 = (*env)->GetIntLongArrayElements(env, arg4, NULL)) == NULL) goto fail;
+ }
rc = (jintLong)g_utf8_to_utf16((const gchar *)lparg0, (glong)arg1, (glong *)lparg2, (glong *)lparg3, (GError **)lparg4);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg4 && lparg4) (*env)->ReleasePrimitiveArrayCritical(env, arg4, lparg4, 0);
if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, 0);
if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, 0);
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg4 && lparg4) (*env)->ReleaseIntLongArrayElements(env, arg4, lparg4, 0);
+ if (arg3 && lparg3) (*env)->ReleaseIntLongArrayElements(env, arg3, lparg3, 0);
+ if (arg2 && lparg2) (*env)->ReleaseIntLongArrayElements(env, arg2, lparg2, 0);
+ if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, JNI_ABORT);
+ }
#ifndef JNI64
OS_NATIVE_EXIT(env, that, _1g_1utf8_1to_1utf16___3BI_3I_3I_3I_FUNC);
#else
@@ -4608,6 +4789,30 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1value_1peek_1pointer)
}
#endif
+#ifndef NO__1g_1variant_1dict_1lookup_1value
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1variant_1dict_1lookup_1value)
+ (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jintLong arg2)
+{
+ jbyte *lparg1=NULL;
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1variant_1dict_1lookup_1value_FUNC);
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+ rc = (jintLong)g_variant_dict_lookup_value((GVariant *)arg0, (const gchar *)lparg1, (const GVariantType *)arg2);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_variant_dict_lookup_value)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GVariant *, const gchar *, const GVariantType *))fp)((GVariant *)arg0, (const gchar *)lparg1, (const GVariantType *)arg2);
+ }
+ }
+fail:
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ OS_NATIVE_EXIT(env, that, _1g_1variant_1dict_1lookup_1value_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1g_1variant_1get_1boolean
JNIEXPORT jboolean JNICALL OS_NATIVE(_1g_1variant_1get_1boolean)
(JNIEnv *env, jclass that, jintLong arg0)
@@ -4776,6 +4981,108 @@ fail:
}
#endif
+#ifndef NO__1g_1variant_1iter_1free
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1variant_1iter_1free)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ OS_NATIVE_ENTER(env, that, _1g_1variant_1iter_1free_FUNC);
+/*
+ g_variant_iter_free((GVariantIter *)arg0);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_variant_iter_free)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(GVariantIter *))fp)((GVariantIter *)arg0);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1g_1variant_1iter_1free_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1variant_1iter_1init
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1variant_1iter_1init)
+ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1)
+{
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1variant_1iter_1init_FUNC);
+/*
+ rc = (jint)g_variant_iter_init((GVariantIter *)arg0, (GVariant *)arg1);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_variant_iter_init)
+ if (fp) {
+ rc = (jint)((jint (CALLING_CONVENTION*)(GVariantIter *, GVariant *))fp)((GVariantIter *)arg0, (GVariant *)arg1);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1g_1variant_1iter_1init_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1variant_1iter_1new
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1variant_1iter_1new)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1variant_1iter_1new_FUNC);
+/*
+ rc = (jintLong)g_variant_iter_new((GVariant *)arg0);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_variant_iter_new)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GVariant *))fp)((GVariant *)arg0);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1g_1variant_1iter_1new_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1variant_1iter_1next
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1g_1variant_1iter_1next)
+ (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jintLong arg2, jintLong arg3)
+{
+ jbyte *lparg1=NULL;
+ jboolean rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1variant_1iter_1next_FUNC);
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+ rc = (jboolean)g_variant_iter_next((const GVariantIter *)arg0, lparg1, (gchar *)arg2, arg3);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_variant_iter_next)
+ if (fp) {
+ rc = (jboolean)((jboolean (CALLING_CONVENTION*)(const GVariantIter *, jbyte *, gchar *, jintLong))fp)((const GVariantIter *)arg0, lparg1, (gchar *)arg2, arg3);
+ }
+ }
+fail:
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ OS_NATIVE_EXIT(env, that, _1g_1variant_1iter_1next_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1variant_1iter_1next_1value
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1variant_1iter_1next_1value)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1variant_1iter_1next_1value_FUNC);
+/*
+ rc = (jintLong)g_variant_iter_next_value((const GVariantIter *)arg0);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_variant_iter_next_value)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(const GVariantIter *))fp)((const GVariantIter *)arg0);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1g_1variant_1iter_1next_1value_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1g_1variant_1n_1children
JNIEXPORT jlong JNICALL OS_NATIVE(_1g_1variant_1n_1children)
(JNIEnv *env, jclass that, jlong arg0)
@@ -4968,6 +5275,44 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1variant_1new_1uint64)
}
#endif
+#ifndef NO__1g_1variant_1print
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1variant_1print)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1variant_1print_FUNC);
+/*
+ rc = (jintLong)g_variant_print((const GVariant *)arg0);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_variant_print)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(const GVariant *))fp)((const GVariant *)arg0);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1g_1variant_1print_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1variant_1unref
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1variant_1unref)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ OS_NATIVE_ENTER(env, that, _1g_1variant_1unref_FUNC);
+/*
+ g_variant_unref((GVariant *)arg0);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, g_variant_unref)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(GVariant *))fp)((GVariant *)arg0);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1g_1variant_1unref_FUNC);
+}
+#endif
+
#ifndef NO__1gdk_1atom_1intern
JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1atom_1intern)
(JNIEnv *env, jclass that, jbyteArray arg0, jboolean arg1)
@@ -4975,10 +5320,24 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1atom_1intern)
jbyte *lparg0=NULL;
jintLong rc = 0;
OS_NATIVE_ENTER(env, that, _1gdk_1atom_1intern_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ }
rc = (jintLong)gdk_atom_intern((const gchar *)lparg0, arg1);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, _1gdk_1atom_1intern_FUNC);
return rc;
}
@@ -5013,7 +5372,14 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1bitmap_1create_1from_1data)
jbyte *lparg1=NULL;
jintLong rc = 0;
OS_NATIVE_ENTER(env, that, _1gdk_1bitmap_1create_1from_1data_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
/*
rc = (jintLong)gdk_bitmap_create_from_data((GdkWindow *)arg0, (const gchar *)lparg1, (gint)arg2, (gint)arg3);
*/
@@ -5024,7 +5390,14 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1bitmap_1create_1from_1data)
}
}
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, _1gdk_1bitmap_1create_1from_1data_FUNC);
return rc;
}
@@ -5773,7 +6146,14 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1draw_1lines)
{
jint *lparg2=NULL;
OS_NATIVE_ENTER(env, that, _1gdk_1draw_1lines_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ }
/*
gdk_draw_lines(arg0, arg1, (GdkPoint *)lparg2, (gint)arg3);
*/
@@ -5784,7 +6164,14 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1draw_1lines)
}
}
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, _1gdk_1draw_1lines_FUNC);
}
#endif
@@ -5831,7 +6218,14 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1draw_1polygon)
{
jint *lparg3=NULL;
OS_NATIVE_ENTER(env, that, _1gdk_1draw_1polygon_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ }
/*
gdk_draw_polygon(arg0, arg1, arg2, lparg3, arg4);
*/
@@ -5842,7 +6236,14 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1draw_1polygon)
}
}
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, _1gdk_1draw_1polygon_FUNC);
}
#endif
@@ -5912,8 +6313,16 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1drawable_1get_1size)
jint *lparg1=NULL;
jint *lparg2=NULL;
OS_NATIVE_ENTER(env, that, _1gdk_1drawable_1get_1size_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ }
/*
gdk_drawable_get_size(arg0, (gint *)lparg1, (gint *)lparg2);
*/
@@ -5924,8 +6333,16 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1drawable_1get_1size)
}
}
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, 0);
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, 0);
+ } else
+#endif
+ {
+ if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+ }
OS_NATIVE_EXIT(env, that, _1gdk_1drawable_1get_1size_FUNC);
}
#endif
@@ -6257,7 +6674,14 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1gc_1set_1dashes)
{
jbyte *lparg2=NULL;
OS_NATIVE_ENTER(env, that, _1gdk_1gc_1set_1dashes_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ }
/*
gdk_gc_set_dashes(arg0, (gint)arg1, (gint8 *)lparg2, (gint)arg3);
*/
@@ -6268,7 +6692,14 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1gc_1set_1dashes)
}
}
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, _1gdk_1gc_1set_1dashes_FUNC);
}
#endif
@@ -6876,8 +7307,16 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1pixmap_1get_1size)
jint *lparg1=NULL;
jint *lparg2=NULL;
OS_NATIVE_ENTER(env, that, _1gdk_1pixmap_1get_1size_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ }
/*
gdk_pixmap_get_size(arg0, (gint *)lparg1, (gint *)lparg2);
*/
@@ -6888,8 +7327,16 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1pixmap_1get_1size)
}
}
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, 0);
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, 0);
+ } else
+#endif
+ {
+ if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+ }
OS_NATIVE_EXIT(env, that, _1gdk_1pixmap_1get_1size_FUNC);
}
#endif
@@ -20303,10 +20750,24 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1pango_1font_1description_1from_1string)
jbyte *lparg0=NULL;
jintLong rc = 0;
OS_NATIVE_ENTER(env, that, _1pango_1font_1description_1from_1string_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+ }
rc = (jintLong)pango_font_description_from_string((const char *)lparg0);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, _1pango_1font_1description_1from_1string_FUNC);
return rc;
}
@@ -20402,10 +20863,24 @@ JNIEXPORT void JNICALL OS_NATIVE(_1pango_1font_1description_1set_1family)
{
jbyte *lparg1=NULL;
OS_NATIVE_ENTER(env, that, _1pango_1font_1description_1set_1family_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
pango_font_description_set_family((PangoFontDescription *)arg0, (const char *)lparg1);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, _1pango_1font_1description_1set_1family_FUNC);
}
#endif
@@ -21113,10 +21588,24 @@ JNIEXPORT void JNICALL OS_NATIVE(_1pango_1layout_1set_1text)
{
jbyte *lparg1=NULL;
OS_NATIVE_ENTER(env, that, _1pango_1layout_1set_1text_FUNC);
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+ } else
+#endif
+ {
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ }
pango_layout_set_text((PangoLayout *)arg0, (const char *)lparg1, (int)arg2);
fail:
+#ifdef JNI_VERSION_1_2
+ if (IS_JNI_1_2) {
if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+ } else
+#endif
+ {
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+ }
OS_NATIVE_EXIT(env, that, _1pango_1layout_1set_1text_FUNC);
}
#endif
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 8e5844b3f7..13d853ed87 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
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2000, 2015 IBM Corporation and others. All rights reserved.
+* Copyright (c) 2000, 2016 IBM Corporation and others. All rights reserved.
* The contents of this file are made available under the terms
* of the GNU Lesser General Public License (LGPL) Version 2.1 that
* accompanies this distribution (lgpl-v21.txt). The LGPL is also
@@ -500,6 +500,19 @@
#define g_icon_to_string_LIB LIB_GIO
#define g_icon_new_for_string_LIB LIB_GIO
#define g_file_query_info_LIB LIB_GIO
+#define g_settings_get_LIB LIB_GIO
+#define g_settings_new_LIB LIB_GIO
+#define g_settings_get_value_LIB LIB_GIO
+#define g_variant_dict_lookup_value_LIB LIB_GIO
+#define g_variant_iter_next_LIB LIB_GIO
+#define g_variant_iter_next_value_LIB LIB_GIO
+#define g_variant_iter_init_LIB LIB_GIO
+#define g_variant_iter_free_LIB LIB_GIO
+#define g_variant_iter_new_LIB LIB_GIO
+#define g_variant_unref_LIB LIB_GIO
+#define g_variant_print_LIB LIB_GIO
+#define g_settings_schema_source_get_default_LIB LIB_GIO
+#define g_settings_schema_source_lookup_LIB LIB_GIO
// GTK3 only
#define gtk_widget_draw_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 670adf8eec..14313dfa97 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
@@ -331,6 +331,11 @@ char * OS_nativeFunctionNames[] = {
"_1g_1object_1unref",
"_1g_1quark_1from_1string",
"_1g_1set_1prgname",
+ "_1g_1settings_1get",
+ "_1g_1settings_1get_1value",
+ "_1g_1settings_1new",
+ "_1g_1settings_1schema_1source_1get_1default",
+ "_1g_1settings_1schema_1source_1lookup",
"_1g_1signal_1add_1emission_1hook",
"_1g_1signal_1connect",
"_1g_1signal_1connect_1closure",
@@ -409,6 +414,7 @@ char * OS_nativeFunctionNames[] = {
"_1g_1utf8_1to_1utf16___3BJ_3J_3J_3J",
#endif
"_1g_1value_1peek_1pointer",
+ "_1g_1variant_1dict_1lookup_1value",
"_1g_1variant_1get_1boolean",
"_1g_1variant_1get_1child_1value",
"_1g_1variant_1get_1double",
@@ -417,6 +423,11 @@ char * OS_nativeFunctionNames[] = {
"_1g_1variant_1get_1type_1string",
"_1g_1variant_1get_1uint64",
"_1g_1variant_1is_1of_1type",
+ "_1g_1variant_1iter_1free",
+ "_1g_1variant_1iter_1init",
+ "_1g_1variant_1iter_1new",
+ "_1g_1variant_1iter_1next",
+ "_1g_1variant_1iter_1next_1value",
"_1g_1variant_1n_1children",
"_1g_1variant_1new_1boolean",
"_1g_1variant_1new_1byte",
@@ -426,6 +437,8 @@ char * OS_nativeFunctionNames[] = {
"_1g_1variant_1new_1string",
"_1g_1variant_1new_1tuple",
"_1g_1variant_1new_1uint64",
+ "_1g_1variant_1print",
+ "_1g_1variant_1unref",
"_1gdk_1atom_1intern",
"_1gdk_1atom_1name",
"_1gdk_1beep",
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 11fdfe428e..cbf1649f7a 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
@@ -341,6 +341,11 @@ typedef enum {
_1g_1object_1unref_FUNC,
_1g_1quark_1from_1string_FUNC,
_1g_1set_1prgname_FUNC,
+ _1g_1settings_1get_FUNC,
+ _1g_1settings_1get_1value_FUNC,
+ _1g_1settings_1new_FUNC,
+ _1g_1settings_1schema_1source_1get_1default_FUNC,
+ _1g_1settings_1schema_1source_1lookup_FUNC,
_1g_1signal_1add_1emission_1hook_FUNC,
_1g_1signal_1connect_FUNC,
_1g_1signal_1connect_1closure_FUNC,
@@ -419,6 +424,7 @@ typedef enum {
_1g_1utf8_1to_1utf16___3BJ_3J_3J_3J_FUNC,
#endif
_1g_1value_1peek_1pointer_FUNC,
+ _1g_1variant_1dict_1lookup_1value_FUNC,
_1g_1variant_1get_1boolean_FUNC,
_1g_1variant_1get_1child_1value_FUNC,
_1g_1variant_1get_1double_FUNC,
@@ -427,6 +433,11 @@ typedef enum {
_1g_1variant_1get_1type_1string_FUNC,
_1g_1variant_1get_1uint64_FUNC,
_1g_1variant_1is_1of_1type_FUNC,
+ _1g_1variant_1iter_1free_FUNC,
+ _1g_1variant_1iter_1init_FUNC,
+ _1g_1variant_1iter_1new_FUNC,
+ _1g_1variant_1iter_1next_FUNC,
+ _1g_1variant_1iter_1next_1value_FUNC,
_1g_1variant_1n_1children_FUNC,
_1g_1variant_1new_1boolean_FUNC,
_1g_1variant_1new_1byte_FUNC,
@@ -436,6 +447,8 @@ typedef enum {
_1g_1variant_1new_1string_FUNC,
_1g_1variant_1new_1tuple_FUNC,
_1g_1variant_1new_1uint64_FUNC,
+ _1g_1variant_1print_FUNC,
+ _1g_1variant_1unref_FUNC,
_1gdk_1atom_1intern_FUNC,
_1gdk_1atom_1name_FUNC,
_1gdk_1beep_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 353d4b7b37..9a0230d6f1 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2000, 2016 IBM Corporation and others. All rights reserved.
* The contents of this file are made available under the terms
* of the GNU Lesser General Public License (LGPL) Version 2.1 that
* accompanies this distribution (lgpl-v21.txt). The LGPL is also
@@ -20,6 +20,8 @@ import org.eclipse.swt.internal.cairo.*;
public class OS extends C {
static {
+ String scalingProperty = "GDK_SCALE";
+ OS.setenv(ascii(scalingProperty), ascii("1"), 1);
String propertyName = "SWT_GTK3";
String gtk3 = getEnvironmentalVariable (propertyName);
if (gtk3 != null && gtk3.equals("0")) {
@@ -17073,4 +17075,189 @@ public static final void setDarkThemePreferred(boolean preferred){
g_object_notify(gtk_settings_get_default(),
gtk_application_prefer_dark_theme);
}
+
+/**
+ * @method flags=dynamic
+ * @param schema_id cast=(const gchar *)
+ */
+public static final native long /*int*/ _g_settings_new (byte[] schema_id);
+public static final long /*int*/ g_settings_new (byte[] schema_id) {
+ lock.lock();
+ try {
+ return _g_settings_new (schema_id);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param settings cast=(GSettings *)
+ * @param key cast=(const gchar *)
+ * @param format = (const gchar *)
+ * @param monitorId = (const gchar *)
+ * @param scalingfactor = (gint *)
+ */
+public static final native void _g_settings_get (long /*int*/ settings, byte[] key, byte[] format, byte[] monitorId, int[] scalingfactor);
+public static final void g_settings_get (long /*int*/ settings, byte[] key, byte[] format, byte[] monitorId, int[] scalingfactor) {
+ lock.lock();
+ try {
+ _g_settings_get (settings, key, format, monitorId, scalingfactor);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param settings cast=(GSettings *)
+ * @param key cast=(const gchar *)
+ */
+public static final native long /*int*/ _g_settings_get_value (long /*int*/ settings, byte[] key);
+public static final long /*int*/ g_settings_get_value (long /*int*/ settings, byte[] key) {
+ lock.lock();
+ try {
+ return _g_settings_get_value (settings, key);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param variant cast=(GVariant *)
+ * @param key cast=(const gchar *)
+ * @param expectedType cast=(const GVariantType *)
+ */
+public static final native long /*int*/ _g_variant_dict_lookup_value (long /*int*/ variant, byte[] key, long /*int*/ expectedType);
+public static final long /*int*/ g_variant_dict_lookup_value (long /*int*/ variant, byte[] key, long /*int*/ expectedType) {
+ lock.lock();
+ try {
+ return _g_variant_dict_lookup_value (variant, key, expectedType);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param variant cast=(GVariant *)
+ */
+public static final native long /*int*/ _g_variant_iter_new (long /*int*/ variant);
+public static final long /*int*/ g_variant_iter_new (long /*int*/ variant) {
+ lock.lock();
+ try {
+ return _g_variant_iter_new (variant);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param variant cast=(GVariantIter *)
+ */
+public static final native void _g_variant_iter_free (long /*int*/ variant);
+public static final void g_variant_iter_free (long /*int*/ variant) {
+ lock.lock();
+ try {
+ _g_variant_iter_free (variant);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param iter cast=(GVariantIter *)
+ * @param variant cast=(GVariant *)
+ */
+public static final native int _g_variant_iter_init (long /*int*/ iter, long /*int*/ variant);
+public static final int g_variant_iter_init (long /*int*/ iter, long /*int*/ variant) {
+ lock.lock();
+ try {
+ return _g_variant_iter_init (iter, variant);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param iter cast=(const GVariantIter *)
+ * @param key cast = (gchar *)
+ * @param format = (const gchar *)
+ * @param value = (GVariant *)
+ */
+public static final native boolean _g_variant_iter_next (long /*int*/ iter, byte[] format, long /*int*/ key, long /*int*/ value);
+public static final boolean g_variant_iter_next (long /*int*/ iter, byte[] format, long /*int*/ key, long /*int*/ value) {
+ lock.lock();
+ try {
+ return _g_variant_iter_next (iter, format, key, value);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param iter cast=(const GVariantIter *)
+ */
+public static final native long /*int*/ _g_variant_iter_next_value (long /*int*/ iter);
+public static final long /*int*/ g_variant_iter_next_value (long /*int*/ iter) {
+ lock.lock();
+ try {
+ return _g_variant_iter_next_value (iter);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param value cast=(const GVariant *)
+ */
+public static final native long /*int*/ _g_variant_print (long /*int*/ value);
+public static final long /*int*/ g_variant_print (long /*int*/ value) {
+ lock.lock();
+ try {
+ return _g_variant_print (value);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param variant cast=(GVariant *)
+ */
+public static final native void _g_variant_unref (long /*int*/ variant);
+public static final void g_variant_unref (long /*int*/ variant) {
+ lock.lock();
+ try {
+ _g_variant_unref (variant);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ */
+public static final native long /*int*/ _g_settings_schema_source_get_default ();
+public static final long /*int*/ g_settings_schema_source_get_default () {
+ lock.lock();
+ try {
+ return _g_settings_schema_source_get_default ();
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param schemaSource cast = (GSettingsSchemaSource *)
+ * @param schema_id cast = (const gchar *)
+ * @param recursive cast = (gboolean)
+ */
+public static final native long /*int*/ _g_settings_schema_source_lookup (long /*int*/ schemaSource, byte[] schema_id, boolean recursive);
+public static final long /*int*/ g_settings_schema_source_lookup (long /*int*/ schemaSource, byte[] schema_id, boolean recursive) {
+ lock.lock();
+ try {
+ return _g_settings_schema_source_lookup (schemaSource, schema_id, recursive);
+ } finally {
+ lock.unlock();
+ }
+}
+
+
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java
index af64cf0773..d65638e0ca 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java
@@ -1554,7 +1554,7 @@ void onDispose (Event e) {
}
void onResize (Event e) {
- Rectangle rect = browser.getClientArea ();
+ Rectangle rect = DPIUtil.autoScaleUp(browser.getClientArea ());
if (WEBKIT2){
OS.gtk_widget_set_size_request (webView, rect.width, rect.height);
} else {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java
index 63ee440475..0855bbfe85 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,6 +11,7 @@
package org.eclipse.swt.graphics;
import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;
/**
@@ -215,6 +216,14 @@ public Path (Device device, PathData data) {
*/
public void addArc(float x, float y, float width, float height, float startAngle, float arcAngle) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ width = DPIUtil.autoScaleUp(width);
+ height = DPIUtil.autoScaleUp(height);
+ addArcInPixels(x, y, width, height, startAngle, arcAngle);
+}
+
+void addArcInPixels(float x, float y, float width, float height, float startAngle, float arcAngle) {
moved = true;
if (width == height) {
float angle = -startAngle * (float)Math.PI / 180;
@@ -280,6 +289,14 @@ public void addPath(Path path) {
*/
public void addRectangle(float x, float y, float width, float height) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ width = DPIUtil.autoScaleUp(width);
+ height = DPIUtil.autoScaleUp(height);
+ addRectangleInPixels(x, y, width, height);
+}
+
+void addRectangleInPixels(float x, float y, float width, float height) {
moved = false;
Cairo.cairo_rectangle(handle, x, y, width, height);
closed = true;
@@ -306,6 +323,11 @@ public void addString(String string, float x, float y, Font font) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (font == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ addStringInPixels(string, x, y, font);
+}
+void addStringInPixels(String string, float x, float y, Font font) {
moved = false;
GC.addCairoString(handle, string, x, y, font);
closed = true;
@@ -354,6 +376,11 @@ public boolean contains(float x, float y, GC gc, boolean outline) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ return containsInPixels(x, y, gc, outline);
+}
+boolean containsInPixels(float x, float y, GC gc, boolean outline) {
//TODO - see Windows
gc.initCairo();
gc.checkGC(GC.LINE_CAP | GC.LINE_JOIN | GC.LINE_STYLE | GC.LINE_WIDTH);
@@ -388,6 +415,13 @@ public boolean contains(float x, float y, GC gc, boolean outline) {
*/
public void cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ cx1 = DPIUtil.autoScaleUp(cx1);
+ cy1 = DPIUtil.autoScaleUp(cy1);
+ cx2 = DPIUtil.autoScaleUp(cx2);
+ cy2 = DPIUtil.autoScaleUp(cy2);
+ cubicToInPixels(cx1, cy1, cx2, cy2, x, y);
+}
+void cubicToInPixels(float cx1, float cy1, float cx2, float cy2, float x, float y) {
if (!moved) {
double[] currentX = new double[1], currentY = new double[1];
Cairo.cairo_get_current_point(handle, currentX, currentY);
@@ -417,6 +451,12 @@ public void getBounds(float[] bounds) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (bounds.length < 4) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ getBoundsInPixels(bounds);
+ for (int i = 0; i < bounds.length; i++) {
+ bounds [i] = DPIUtil.autoScaleDown(bounds[i]);
+ }
+}
+void getBoundsInPixels(float[] bounds) {
long /*int*/ copy = Cairo.cairo_copy_path(handle);
if (copy == 0) SWT.error(SWT.ERROR_NO_HANDLES);
cairo_path_t path = new cairo_path_t();
@@ -489,6 +529,13 @@ public void getBounds(float[] bounds) {
*/
public void getCurrentPoint(float[] point) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ getCurrentPointInPixels(point);
+ for (int i = 0; i < point.length; i++) {
+ point [i] = DPIUtil.autoScaleDown(point[i]);
+ }
+}
+
+void getCurrentPointInPixels(float[] point) {
if (point == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (point.length < 2) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
double[] x = new double[1], y = new double[1];
@@ -584,6 +631,11 @@ public PathData getPathData() {
*/
public void lineTo(float x, float y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ lineToInPixels(x, y);
+}
+void lineToInPixels(float x, float y) {
if (!moved) {
double[] currentX = new double[1], currentY = new double[1];
Cairo.cairo_get_current_point(handle, currentX, currentY);
@@ -608,6 +660,11 @@ public void lineTo(float x, float y) {
*/
public void moveTo(float x, float y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ moveToInPixels(x, y);
+}
+void moveToInPixels(float x, float y) {
/*
* Bug in Cairo. If cairo_move_to() is not called at the
* begining of a subpath, the first cairo_line_to() or
@@ -634,6 +691,13 @@ public void moveTo(float x, float y) {
*/
public void quadTo(float cx, float cy, float x, float y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ cx = DPIUtil.autoScaleUp(cx);
+ cy = DPIUtil.autoScaleUp(cy);
+ quadToInPixels(cx, cy, x, y);
+}
+void quadToInPixels(float cx, float cy, float x, float y) {
double[] currentX = new double[1], currentY = new double[1];
Cairo.cairo_get_current_point(handle, currentX, currentY);
if (!moved) {
@@ -662,16 +726,16 @@ void init(PathData data) {
for (int i = 0, j = 0; i < types.length; i++) {
switch (types[i]) {
case SWT.PATH_MOVE_TO:
- moveTo(points[j++], points[j++]);
+ moveToInPixels(points[j++], points[j++]);
break;
case SWT.PATH_LINE_TO:
- lineTo(points[j++], points[j++]);
+ lineToInPixels(points[j++], points[j++]);
break;
case SWT.PATH_CUBIC_TO:
- cubicTo(points[j++], points[j++], points[j++], points[j++], points[j++], points[j++]);
+ cubicToInPixels(points[j++], points[j++], points[j++], points[j++], points[j++], points[j++]);
break;
case SWT.PATH_QUAD_TO:
- quadTo(points[j++], points[j++], points[j++], points[j++]);
+ quadToInPixels(points[j++], points[j++], points[j++], points[j++]);
break;
case SWT.PATH_CLOSE:
close();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java
index 17918869c8..82ee23b94d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java
@@ -11,6 +11,7 @@
package org.eclipse.swt.graphics;
import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;
/**
@@ -170,6 +171,10 @@ public Pattern(Device device, float x1, float y1, float x2, float y2, Color colo
*/
public Pattern(Device device, float x1, float y1, float x2, float y2, Color color1, int alpha1, Color color2, int alpha2) {
super(device);
+ x1 = DPIUtil.autoScaleUp(x1);
+ y1 = DPIUtil.autoScaleUp(y1);
+ x2 = DPIUtil.autoScaleUp(x2);
+ y2 = DPIUtil.autoScaleUp(y2);
if (color1 == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (color1.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
if (color2 == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Transform.java b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Transform.java
index fc9f40d4ed..5c29a8dd69 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Transform.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Transform.java
@@ -11,6 +11,7 @@
package org.eclipse.swt.graphics;
import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;
/**
@@ -144,7 +145,7 @@ public Transform (Device device, float m11, float m12, float m21, float m22, flo
this.device.checkCairo();
handle = new double[6];
if (handle == null) SWT.error(SWT.ERROR_NO_HANDLES);
- Cairo.cairo_matrix_init(handle, m11, m12, m21, m22, dx, dy);
+ Cairo.cairo_matrix_init(handle, m11, m12, m21, m22, DPIUtil.autoScaleUp(dx), DPIUtil.autoScaleUp(dy));
init();
}
@@ -181,8 +182,8 @@ public void getElements(float[] elements) {
elements[1] = (float)handle[1];
elements[2] = (float)handle[2];
elements[3] = (float)handle[3];
- elements[4] = (float)handle[4];
- elements[5] = (float)handle[5];
+ elements[4] = DPIUtil.autoScaleDown((float)handle[4]);
+ elements[5] = DPIUtil.autoScaleDown((float)handle[5]);
}
/**
@@ -317,7 +318,7 @@ public void scale(float scaleX, float scaleY) {
*/
public void setElements(float m11, float m12, float m21, float m22, float dx, float dy) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- Cairo.cairo_matrix_init(handle, m11, m12, m21, m22, dx, dy);
+ Cairo.cairo_matrix_init(handle, m11, m12, m21, m22, DPIUtil.autoScaleUp(dx), DPIUtil.autoScaleUp(dy));
}
/**
@@ -359,11 +360,11 @@ public void transform(float[] pointArray) {
double[] dx = new double[1], dy = new double[1];
int length = pointArray.length / 2;
for (int i = 0, j = 0; i < length; i++, j += 2) {
- dx[0] = pointArray[j];
- dy[0] = pointArray[j + 1];
+ dx[0] = DPIUtil.autoScaleUp(pointArray[j]);
+ dy[0] = DPIUtil.autoScaleUp(pointArray[j + 1]);
Cairo.cairo_matrix_transform_point(handle, dx, dy);
- pointArray[j] = (float)dx[0];
- pointArray[j + 1] = (float)dy[0];
+ pointArray[j] = DPIUtil.autoScaleDown((float)dx[0]);
+ pointArray[j + 1] = DPIUtil.autoScaleDown((float)dy[0]);
}
}
@@ -380,7 +381,7 @@ public void transform(float[] pointArray) {
*/
public void translate(float offsetX, float offsetY) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- Cairo.cairo_matrix_translate(handle, offsetX, offsetY);
+ Cairo.cairo_matrix_translate(handle, DPIUtil.autoScaleUp(offsetX), DPIUtil.autoScaleUp(offsetY));
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
index eb29d04f48..e129711c32 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
@@ -25,6 +25,17 @@ import org.eclipse.swt.internal.gtk.*;
*/
public abstract class Device implements Drawable {
/**
+ * @noreference This field is not intended to be referenced by clients.
+ * @since 3.105
+ */
+ protected static final int CHANGE_SCALEFACTOR = 1;
+ /* Settings callbacks */
+ long /*int*/ gsettingsProc;
+ Callback gsettingsCallback;
+ boolean isConnected = false;
+ long /*int*/ displaySettings; //gsettings Dictionary
+
+ /**
* the handle to the X Display
* (Warning: This field is platform dependent)
* <p>
@@ -82,6 +93,13 @@ public abstract class Device implements Drawable {
/* Device dpi */
Point dpi;
+ /*Device Scale Factor in percentage*/
+ /**
+ * @noreference This field is not intended to be referenced by clients.
+ * @since 3.105
+ */
+ protected int scaleFactor;
+
long /*int*/ emptyTab;
boolean useXRender;
@@ -316,6 +334,10 @@ protected void destroy () {
*/
public Rectangle getBounds () {
checkDevice ();
+ return DPIUtil.autoScaleDown (getBoundsInPixels ());
+}
+
+private Rectangle getBoundsInPixels () {
return new Rectangle(0, 0, 0, 0);
}
@@ -375,7 +397,11 @@ public DeviceData getDeviceData () {
*/
public Rectangle getClientArea () {
checkDevice ();
- return getBounds ();
+ return DPIUtil.autoScaleDown (getClientAreaInPixels ());
+}
+
+private Rectangle getClientAreaInPixels () {
+ return getBoundsInPixels ();
}
/**
@@ -579,6 +605,8 @@ public boolean getWarnings () {
*/
protected void init () {
this.dpi = getDPI();
+ this.scaleFactor = getDeviceZoom ();
+ DPIUtil.setDeviceZoom (scaleFactor);
if (xDisplay != 0 && !OS.USE_CAIRO) {
int[] event_basep = new int[1], error_basep = new int [1];
@@ -910,6 +938,11 @@ protected void release () {
handler_ids = null; log_domains = null;
logProc = 0;
}
+ /* Dispose the settings callback */
+ gsettingsCallback.dispose(); gsettingsCallback = null;
+ gsettingsProc = 0;
+
+
}
/**
@@ -991,13 +1024,80 @@ static long /*int*/ XIOErrorProc (long /*int*/ xDisplay) {
* @return the horizontal DPI
*/
int _getDPIx () {
+ return scaleFactor * 96/100;
+}
+/**
+ * Gets the scaling factor from the device and calculates the zoom level.
+ * @return zoom in percentage
+ *
+ * @noreference This method is not intended to be referenced by clients.
+ * @nooverride This method is not intended to be re-implemented or extended by clients.
+ * @since 3.105
+ */
+protected int getDeviceZoom() {
long /*int*/ screen = OS.gdk_screen_get_default();
int monitor = OS.gdk_screen_get_monitor_at_point(screen, 0, 0);
- GdkRectangle dest = new GdkRectangle ();
- OS.gdk_screen_get_monitor_geometry(screen, monitor, dest);
- int widthMM = OS.gdk_screen_get_monitor_width_mm(screen, monitor);
- return Compatibility.round (254 * dest.width, widthMM * 10);
+ final String schemaId = "com.ubuntu.user-interface";
+ final String key = "scale-factor";
+ int fontHeight = 0;
+ byte[] schema_id = Converter.wcsToMbcs (null, schemaId, true);
+ long /*int*/ schemaSource = OS.g_settings_schema_source_get_default ();
+ if (OS.g_settings_schema_source_lookup(schemaSource, schema_id, false) != 0) {
+ displaySettings = OS.g_settings_new (schema_id);
+ byte[] keyString = Converter.wcsToMbcs (null, key, true);
+ long /*int*/ settingsDict = OS.g_settings_get_value (displaySettings, keyString);
+ long /*int*/ keyArray = 0;
+ if (!isConnected) {
+ gsettingsCallback = new Callback (this, "gsettingsProc", 3); //$NON-NLS-1$
+ gsettingsProc = gsettingsCallback.getAddress ();
+ if (gsettingsProc == 0) {
+ SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+ }
+ int retVal = OS.g_signal_connect (displaySettings, OS.changed, gsettingsProc, CHANGE_SCALEFACTOR);
+ if (retVal > 0) {
+ isConnected = true;
+ }
+ }
+
+
+ long /*int*/ iter = OS.g_variant_iter_new (settingsDict);
+ int size = OS.g_variant_iter_init(iter, settingsDict);
+ for (int i =0; i<size; i++) {
+ long /*int*/ iterValue = OS.g_variant_iter_next_value(iter);
+ keyArray = OS.g_variant_print(iterValue);
+ int len = OS.strlen(keyArray);
+ byte[] buffer = new byte [len];
+ OS.memmove (buffer, keyArray, len);
+ String type = new String(Converter.mbcsToWcs(null, buffer));
+ int index = type.indexOf(",");
+ String height = type.substring((index + 1), (type.length() - 1));
+ fontHeight = Math.max(fontHeight, Integer.valueOf(height.trim()));
+ OS.g_free(keyArray);
+ OS.g_variant_unref(iterValue);
+ }
+
+ OS.g_variant_iter_free(iter);
+ return DPIUtil.mapSFToZoom(fontHeight/ 8f);
+ } else {
+ GdkRectangle dest = new GdkRectangle ();
+ OS.gdk_screen_get_monitor_geometry(screen, monitor, dest);
+ int widthMM = OS.gdk_screen_get_monitor_width_mm(screen, monitor);
+ return (DPIUtil.mapDPIToZoom(Compatibility.round (254 * dest.width, widthMM * 10)));
+ }
+}
+/**
+ * @noreference This method is not intended to be referenced by clients.
+ * @nooverride This method is not intended to be re-implemented or extended by clients.
+ * @since 3.105
+ */
+protected long /*int*/ gsettingsProc (long /*int*/ gobject, long /*int*/ arg1, long /*int*/ user_data) {
+ switch((int)/*64*/user_data) {
+ case CHANGE_SCALEFACTOR:
+ this.scaleFactor = getDeviceZoom ();
+ DPIUtil.setDeviceZoom (scaleFactor);
+ }
+ return 0;
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontMetrics.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontMetrics.java
index 555eebc983..c5426d2129 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontMetrics.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontMetrics.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.swt.graphics;
+import org.eclipse.swt.internal.*;
/**
* Instances of this class provide measurement information
@@ -56,7 +57,7 @@ public boolean equals (Object object) {
* @return the ascent of the font
*/
public int getAscent() {
- return ascent;
+ return DPIUtil.autoScaleDown(ascent);
}
/**
@@ -66,7 +67,7 @@ public int getAscent() {
* @return the average character width of the font
*/
public int getAverageCharWidth() {
- return averageCharWidth;
+ return DPIUtil.autoScaleDown(averageCharWidth);
}
/**
@@ -78,7 +79,7 @@ public int getAverageCharWidth() {
* @return the descent of the font
*/
public int getDescent() {
- return descent;
+ return DPIUtil.autoScaleDown(descent);
}
/**
@@ -93,7 +94,7 @@ public int getDescent() {
* @see #getLeading
*/
public int getHeight() {
- return height;
+ return DPIUtil.autoScaleDown(height);
}
/**
@@ -104,7 +105,7 @@ public int getHeight() {
* @return the leading space of the font
*/
public int getLeading() {
- return leading;
+ return DPIUtil.autoScaleDown(leading);
}
public static FontMetrics gtk_new(int ascent, int descent, int averageCharWidth, int leading, int height) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
index de06b27787..c7ae51f567 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,6 +15,7 @@ import org.eclipse.swt.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;
import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.widgets.*;
/**
* Class <code>GC</code> is where all of the drawing capabilities that are
@@ -297,7 +298,7 @@ void checkGC (int mask) {
Cairo.cairo_set_line_join(cairo, join_style);
}
if ((state & LINE_WIDTH) != 0) {
- Cairo.cairo_set_line_width(cairo, data.lineWidth == 0 ? 1 : data.lineWidth);
+ Cairo.cairo_set_line_width(cairo, data.lineWidth == 0 ? DPIUtil.autoScaleUp(1) : data.lineWidth);
switch (data.lineStyle) {
case SWT.LINE_DOT:
case SWT.LINE_DASH:
@@ -477,6 +478,10 @@ public void copyArea(Image image, int x, int y) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ Point loc = DPIUtil.autoScaleUp(new Point(x, y));
+ copyAreaInPixels(image, loc.x, loc.y);
+}
+void copyAreaInPixels(Image image, int x, int y) {
if (OS.USE_CAIRO) {
long /*int*/ cairo = Cairo.cairo_create(image.surface);
if (cairo == 0) SWT.error(SWT.ERROR_NO_HANDLES);
@@ -508,7 +513,7 @@ public void copyArea(Image image, int x, int y) {
Cairo.cairo_destroy(cairo);
return;
}
- Rectangle rect = image.getBounds();
+ Rectangle rect = image.getBoundsInPixels();
long /*int*/ gdkGC = OS.gdk_gc_new(image.pixmap);
if (gdkGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
OS.gdk_gc_set_subwindow(gdkGC, OS.GDK_INCLUDE_INFERIORS);
@@ -532,7 +537,14 @@ public void copyArea(Image image, int x, int y) {
* </ul>
*/
public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY) {
- copyArea(srcX, srcY, width, height, destX, destY, true);
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Rectangle src = DPIUtil.autoScaleUp(new Rectangle(srcX, srcY, width, height));
+ Point dest = DPIUtil.autoScaleUp(new Point(destX, destY));
+ copyAreaInPixels(src.x, src.y, src.width, src.height, dest.x, dest.y);
+}
+
+void copyAreaInPixels(int srcX, int srcY, int width, int height, int destX, int destY) {
+ copyAreaInPixels(srcX, srcY, width, height, destX, destY, true);
}
/**
* Copies a rectangular area of the receiver at the source
@@ -554,6 +566,11 @@ public void copyArea(int srcX, int srcY, int width, int height, int destX, int d
*/
public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY, boolean paint) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Rectangle srcLoc = DPIUtil.autoScaleUp(new Rectangle(srcX, srcY, width, height));
+ Point destLoc = DPIUtil.autoScaleUp(new Point(destX, destY));
+ copyAreaInPixels(srcLoc.x, srcLoc.y, srcLoc.width, srcLoc.height, destLoc.x, destLoc.y, paint);
+}
+void copyAreaInPixels(int srcX, int srcY, int width, int height, int destX, int destY, boolean paint) {
if (width <= 0 || height <= 0) return;
int deltaX = destX - srcX, deltaY = destY - srcY;
if (deltaX == 0 && deltaY == 0) return;
@@ -722,6 +739,10 @@ void destroy() {
*/
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Rectangle loc = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ drawArcInPixels(loc.x, loc.y, loc.width, loc.height, startAngle, arcAngle);
+}
+void drawArcInPixels(int x, int y, int width, int height, int startAngle, int arcAngle) {
checkGC(DRAW);
if (width < 0) {
x = x + width;
@@ -777,6 +798,10 @@ public void drawArc(int x, int y, int width, int height, int startAngle, int arc
*/
public void drawFocus(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Rectangle loc = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ drawFocusInPixels(loc.x, loc.y, loc.width, loc.height);
+}
+void drawFocusInPixels(int x, int y, int width, int height) {
long /*int*/ cairo = data.cairo;
if (cairo != 0) {
checkGC(FOREGROUND);
@@ -831,6 +856,10 @@ public void drawImage(Image image, int x, int y) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ Point loc = DPIUtil.autoScaleUp(new Point(x, y));
+ drawImageInPixels(image, loc.x, loc.y);
+}
+void drawImageInPixels(Image image, int x, int y) {
drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true);
}
@@ -846,12 +875,12 @@ public void drawImage(Image image, int x, int y) {
* @param image the source image
* @param srcX the x coordinate in the source image to copy from
* @param srcY the y coordinate in the source image to copy from
- * @param srcWidth the width in pixels to copy from the source
- * @param srcHeight the height in pixels to copy from the source
+ * @param srcWidth the width in points to copy from the source
+ * @param srcHeight the height in points to copy from the source
* @param destX the x coordinate in the destination to copy to
* @param destY the y coordinate in the destination to copy to
- * @param destWidth the width in pixels of the destination rectangle
- * @param destHeight the height in pixels of the destination rectangle
+ * @param destWidth the width in points of the destination rectangle
+ * @param destHeight the height in points of the destination rectangle
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the image is null</li>
@@ -874,9 +903,10 @@ public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeig
}
if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false);
+ Rectangle srcRect = DPIUtil.autoScaleUp(new Rectangle(srcX, srcY, srcWidth, srcHeight));
+ Rectangle destRect = DPIUtil.autoScaleUp(new Rectangle(destX, destY, destWidth, destHeight));
+ drawImage(image, srcRect.x, srcRect.y, srcRect.width, srcRect.height, destRect.x, destRect.y, destRect.width, destRect.height, false);
}
-
void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) {
/* Refresh Image as per zoom level, if required. */
srcImage.refreshImageForZoom ();
@@ -903,7 +933,7 @@ void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight,
simple = srcX == 0 && srcY == 0 &&
srcWidth == destWidth && destWidth == imgWidth &&
srcHeight == destHeight && destHeight == imgHeight;
- if (srcX + srcWidth > imgWidth || srcY + srcHeight > imgHeight) {
+ if (srcX + srcWidth > imgWidth + 1 || srcY + srcHeight > imgHeight + 1) { //rounding error correction for hidpi
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
}
@@ -1256,6 +1286,11 @@ long /*int*/ scale(long /*int*/ src, int srcX, int srcY, int srcWidth, int srcHe
*/
public void drawLine(int x1, int y1, int x2, int y2) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Point loc1 = DPIUtil.autoScaleUp(new Point(x1, y1));
+ Point loc2 = DPIUtil.autoScaleUp(new Point(x2, y2));
+ drawLineInPixels(loc1.x, loc1.y, loc2.x, loc2.y);
+}
+void drawLineInPixels(int x1, int y1, int x2, int y2) {
checkGC(DRAW);
long /*int*/ cairo = data.cairo;
if (cairo != 0) {
@@ -1291,6 +1326,10 @@ public void drawLine(int x1, int y1, int x2, int y2) {
*/
public void drawOval(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Rectangle rect = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ drawOvalInPixels(rect.x, rect.y, rect.width, rect.height);
+}
+void drawOvalInPixels(int x, int y, int width, int height) {
checkGC(DRAW);
if (width < 0) {
x = x + width;
@@ -1378,6 +1417,10 @@ public void drawPath(Path path) {
*/
public void drawPoint (int x, int y) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Point loc = DPIUtil.autoScaleUp(new Point(x, y));
+ drawPointInPixels(loc.x, loc.y);
+}
+void drawPointInPixels (int x, int y) {
checkGC(DRAW);
long /*int*/ cairo = data.cairo;
if (cairo != 0) {
@@ -1408,6 +1451,10 @@ public void drawPoint (int x, int y) {
public void drawPolygon(int[] pointArray) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int [] scaledPointArray = DPIUtil.autoScaleUp(pointArray);
+ drawPolygonInPixels(scaledPointArray);
+}
+void drawPolygonInPixels(int[] pointArray) {
checkGC(DRAW);
long /*int*/ cairo = data.cairo;
if (cairo != 0) {
@@ -1438,6 +1485,10 @@ public void drawPolygon(int[] pointArray) {
public void drawPolyline(int[] pointArray) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int [] scaledPointArray = DPIUtil.autoScaleUp(pointArray);
+ drawPolylineInPixels(scaledPointArray);
+}
+void drawPolylineInPixels(int[] pointArray) {
checkGC(DRAW);
long /*int*/ cairo = data.cairo;
if (cairo != 0) {
@@ -1476,6 +1527,9 @@ void drawPolyline(long /*int*/ cairo, int[] pointArray, boolean close) {
*/
public void drawRectangle(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ drawRectangle(new Rectangle(x, y, width, height));
+}
+void drawRectangleInPixels(int x, int y, int width, int height) {
checkGC(DRAW);
if (width < 0) {
x = x + width;
@@ -1513,7 +1567,10 @@ public void drawRectangle(int x, int y, int width, int height) {
*/
public void drawRectangle(Rectangle rect) {
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- drawRectangle (rect.x, rect.y, rect.width, rect.height);
+ drawRectangleInPixels(DPIUtil.autoScaleUp(rect));
+}
+void drawRectangleInPixels(Rectangle rect) {
+ drawRectangleInPixels (rect.x, rect.y, rect.width, rect.height);
}
/**
* Draws the outline of the round-cornered rectangle specified by
@@ -1538,6 +1595,11 @@ public void drawRectangle(Rectangle rect) {
*/
public void drawRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Rectangle rect = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ Point arcSize = DPIUtil.autoScaleUp(new Point(arcWidth, arcHeight));
+ drawRoundRectangleInPixels(rect.x, rect.y, rect.width, rect.height, arcSize.x, arcSize.y);
+}
+void drawRoundRectangleInPixels(int x, int y, int width, int height, int arcWidth, int arcHeight) {
checkGC(DRAW);
int nx = x;
int ny = y;
@@ -1629,7 +1691,13 @@ public void drawRoundRectangle(int x, int y, int width, int height, int arcWidth
* </ul>
*/
public void drawString (String string, int x, int y) {
- drawString(string, x, y, false);
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ drawString (string, x, y, false);
+}
+
+void drawStringInPixels (String string, int x, int y) {
+ drawStringInPixels(string, x, y, false);
}
/**
* Draws the given string, using the receiver's current font and
@@ -1652,7 +1720,14 @@ public void drawString (String string, int x, int y) {
* </ul>
*/
public void drawString(String string, int x, int y, boolean isTransparent) {
- drawText(string, x, y, isTransparent ? SWT.DRAW_TRANSPARENT : 0);
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ Point loc = DPIUtil.autoScaleUp(new Point(x, y));
+ drawStringInPixels(string, loc.x, loc.y, isTransparent);
+}
+
+void drawStringInPixels(String string, int x, int y, boolean isTransparent) {
+ drawTextInPixels(string, x, y, isTransparent ? SWT.DRAW_TRANSPARENT : 0);
}
/**
@@ -1676,6 +1751,9 @@ public void drawString(String string, int x, int y, boolean isTransparent) {
public void drawText(String string, int x, int y) {
drawText(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
}
+void drawTextInPixels(String string, int x, int y) {
+ drawTextInPixels(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
+}
/**
* Draws the given string, using the receiver's current font and
@@ -1698,9 +1776,13 @@ public void drawText(String string, int x, int y) {
* </ul>
*/
public void drawText(String string, int x, int y, boolean isTransparent) {
+ Point loc = DPIUtil.autoScaleUp(new Point (x, y));
+ drawTextInPixels(string, loc.x, loc.y, isTransparent);
+}
+void drawTextInPixels(String string, int x, int y, boolean isTransparent) {
int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB;
if (isTransparent) flags |= SWT.DRAW_TRANSPARENT;
- drawText(string, x, y, flags);
+ drawTextInPixels(string, x, y, flags);
}
/**
@@ -1738,6 +1820,10 @@ public void drawText(String string, int x, int y, boolean isTransparent) {
* </ul>
*/
public void drawText (String string, int x, int y, int flags) {
+ Point loc = DPIUtil.autoScaleUp(new Point (x, y));
+ drawTextInPixels(string, loc.x, loc.y, flags);
+}
+void drawTextInPixels (String string, int x, int y, int flags) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (string.length() == 0) return;
@@ -1846,6 +1932,10 @@ public boolean equals(Object object) {
*/
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Rectangle rect = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ fillArcInPixels(rect.x, rect.y, rect.width, rect.height, startAngle, arcAngle);
+}
+void fillArcInPixels(int x, int y, int width, int height, int startAngle, int arcAngle) {
checkGC(FILL);
if (width < 0) {
x = x + width;
@@ -1905,6 +1995,11 @@ public void fillArc(int x, int y, int width, int height, int startAngle, int arc
*/
public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Rectangle rect = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ fillGradientRectangleInPixels(rect.x, rect.y, rect.width, rect.height, vertical);
+}
+
+void fillGradientRectangleInPixels(int x, int y, int width, int height, boolean vertical) {
if ((width == 0) || (height == 0)) return;
/* Rewrite this to use GdkPixbuf */
@@ -1930,7 +2025,7 @@ public void fillGradientRectangle(int x, int y, int width, int height, boolean v
toRGB = foregroundRGB;
}
if (fromRGB.equals(toRGB)) {
- fillRectangle(x, y, width, height);
+ fillRectangleInPixels(x, y, width, height);
return;
}
long /*int*/ cairo = data.cairo;
@@ -1954,8 +2049,9 @@ public void fillGradientRectangle(int x, int y, int width, int height, boolean v
return;
}
ImageData.fillGradientRectangle(this, data.device,
- x, y, width, height, vertical, fromRGB, toRGB,
- 8, 8, 8);
+ DPIUtil.autoScaleDown(x), DPIUtil.autoScaleDown(y),
+ DPIUtil.autoScaleDown(width), DPIUtil.autoScaleDown(height),
+ vertical, fromRGB, toRGB, 8, 8, 8);
}
/**
@@ -1976,6 +2072,10 @@ public void fillGradientRectangle(int x, int y, int width, int height, boolean v
*/
public void fillOval(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Rectangle rect = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ fillOvalInPixels(rect.x, rect.y, rect.width, rect.height);
+}
+void fillOvalInPixels(int x, int y, int width, int height) {
checkGC(FILL);
if (width < 0) {
x = x + width;
@@ -2061,6 +2161,10 @@ public void fillPath (Path path) {
public void fillPolygon(int[] pointArray) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int [] scaledPointArray = DPIUtil.autoScaleUp(pointArray);
+ fillPolygonInPixels(scaledPointArray);
+}
+void fillPolygonInPixels(int[] pointArray) {
checkGC(FILL);
long /*int*/ cairo = data.cairo;
if (cairo != 0) {
@@ -2088,6 +2192,9 @@ public void fillPolygon(int[] pointArray) {
*/
public void fillRectangle(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ fillRectangle(new Rectangle(x, y, width, height));
+}
+void fillRectangleInPixels(int x, int y, int width, int height) {
checkGC(FILL);
if (width < 0) {
x = x + width;
@@ -2124,7 +2231,10 @@ public void fillRectangle(int x, int y, int width, int height) {
public void fillRectangle(Rectangle rect) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- fillRectangle(rect.x, rect.y, rect.width, rect.height);
+ fillRectangleInPixels(DPIUtil.autoScaleUp(rect));
+}
+void fillRectangleInPixels(Rectangle rect) {
+ fillRectangleInPixels(rect.x, rect.y, rect.width, rect.height);
}
/**
@@ -2146,6 +2256,11 @@ public void fillRectangle(Rectangle rect) {
*/
public void fillRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ Rectangle rect = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ Point arcSize = DPIUtil.autoScaleUp(new Point(arcWidth, arcHeight));
+ fillRoundRectangleInPixels(rect.x, rect.y, rect.width, rect.height, arcSize.x, arcSize.y);
+}
+void fillRoundRectangleInPixels(int x, int y, int width, int height, int arcWidth, int arcHeight) {
checkGC(FILL);
int nx = x;
int ny = y;
@@ -2247,7 +2362,7 @@ int fixMnemonic (char [] buffer) {
public int getAdvanceWidth(char ch) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
//BOGUS
- return stringExtent(new String(new char[]{ch})).x;
+ return stringExtentInPixels(new String(new char[]{ch})).x;
}
/**
@@ -2378,7 +2493,7 @@ public Pattern getBackgroundPattern() {
public int getCharWidth(char ch) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
//BOGUS
- return stringExtent(new String(new char[]{ch})).x;
+ return stringExtentInPixels(new String(new char[]{ch})).x;
}
/**
@@ -2395,6 +2510,9 @@ public int getCharWidth(char ch) {
*/
public Rectangle getClipping() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return DPIUtil.autoScaleDown(getClippingInPixels());
+}
+Rectangle getClippingInPixels() {
/* Calculate visible bounds in device space */
int x = 0, y = 0, width = 0, height = 0;
int[] w = new int[1], h = new int[1];
@@ -2651,6 +2769,11 @@ public int getInterpolation() {
*/
public LineAttributes getLineAttributes() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ LineAttributes attributes = getLineAttributesInPixels();
+ attributes.width = DPIUtil.autoScaleDown(attributes.width);
+ return attributes;
+}
+LineAttributes getLineAttributesInPixels() {
float[] dashes = null;
if (data.lineDashes != null) {
dashes = new float[data.lineDashes.length];
@@ -2748,6 +2871,9 @@ public int getLineStyle() {
*/
public int getLineWidth() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return (int)DPIUtil.autoScaleDown(data.lineWidth);
+}
+int getLineWidthInPixels() {
return (int)data.lineWidth;
}
@@ -3330,6 +3456,9 @@ void setClipping(long /*int*/ clipRgn) {
*/
public void setClipping(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ setClippingInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y), DPIUtil.autoScaleUp(width), DPIUtil.autoScaleUp(height));
+}
+void setClippingInPixels(int x, int y, int width, int height) {
if (width < 0) {
x = x + width;
width = -width;
@@ -3405,13 +3534,16 @@ public void setClipping(Path path) {
*/
public void setClipping(Rectangle rect) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (OS.GTK_VERSION >= OS.VERSION(3, 9, 0)) {
- return;
+ setClippingInPixels(DPIUtil.autoScaleUp(rect));
+}
+void setClippingInPixels(Rectangle rect) {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 9, 0) && (drawable instanceof Tree || drawable instanceof Table)) {
+ return; //FIXME: This is an atrocious hack for bug 446075
}
if (rect == null) {
setClipping(0);
} else {
- setClipping(rect.x, rect.y, rect.width, rect.height);
+ setClippingInPixels(rect.x, rect.y, rect.width, rect.height);
}
}
/**
@@ -3619,6 +3751,9 @@ public void setInterpolation(int interpolation) {
public void setLineAttributes(LineAttributes attributes) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (attributes == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ attributes.width = DPIUtil.autoScaleUp(attributes.width);
+}
+void setLineAttributesInPixels(LineAttributes attributes) {
int mask = 0;
float lineWidth = attributes.width;
if (lineWidth != data.lineWidth) {
@@ -3867,6 +4002,9 @@ public void setLineStyle(int lineStyle) {
*/
public void setLineWidth(int lineWidth) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ setLineWidthInPixels(DPIUtil.autoScaleUp(lineWidth));
+}
+void setLineWidthInPixels(int lineWidth) {
if (data.lineWidth == lineWidth) return;
data.lineWidth = lineWidth;
data.state &= ~(LINE_WIDTH | DRAW_OFFSET);
@@ -4037,7 +4175,6 @@ public void setXORMode(boolean xor) {
}
data.xorMode = xor;
}
-
/**
* Returns the extent of the given string. No tab
* expansion or carriage return processing will be performed.
@@ -4058,7 +4195,10 @@ public void setXORMode(boolean xor) {
* </ul>
*/
public Point stringExtent(String string) {
- return textExtent(string, 0);
+ return DPIUtil.autoScaleDown(stringExtentInPixels(string));
+}
+Point stringExtentInPixels(String string) {
+ return textExtentInPixels(string, 0);
}
/**
@@ -4081,7 +4221,11 @@ public Point stringExtent(String string) {
* </ul>
*/
public Point textExtent(String string) {
- return textExtent(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
+ return DPIUtil.autoScaleDown(textExtentInPixels(string));
+}
+
+Point textExtentInPixels(String string) {
+ return textExtentInPixels(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
}
/**
@@ -4118,6 +4262,9 @@ public Point textExtent(String string) {
public Point textExtent(String string, int flags) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return DPIUtil.autoScaleDown(textExtentInPixels(string, flags));
+}
+Point textExtentInPixels(String string, int flags) {
setString(string, flags);
checkGC(FONT);
if (data.stringWidth == -1) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
index 7d2ca6b3e0..c593caa28d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
@@ -164,20 +164,21 @@ public final class Image extends Resource implements Drawable {
/**
* ImageFileNameProvider to provide file names at various Zoom levels
*/
- ImageFileNameProvider imageFileNameProvider;
+ private ImageFileNameProvider imageFileNameProvider;
/**
* ImageDataProvider to provide ImageData at various Zoom levels
*/
- ImageDataProvider imageDataProvider;
+ private ImageDataProvider imageDataProvider;
/**
* Attribute to cache current device zoom level
*/
- int currentDeviceZoom = 100;
+ private int currentDeviceZoom = 100;
Image(Device device) {
super(device);
+ currentDeviceZoom = DPIUtil.getDeviceZoom();
}
/**
@@ -217,7 +218,9 @@ Image(Device device) {
*/
public Image(Device device, int width, int height) {
super(device);
- init(width, height);
+ Point size = DPIUtil.autoScaleUp(new Point(width, height));
+ currentDeviceZoom = DPIUtil.getDeviceZoom();
+ init(size.x, size.y);
init();
}
@@ -383,6 +386,7 @@ public Image(Device device, Image srcImage, int flag) {
}
}
init();
+ currentDeviceZoom = DPIUtil.getDeviceZoom();
return;
}
@@ -502,6 +506,7 @@ public Image(Device device, Image srcImage, int flag) {
OS.g_object_unref(gdkGC);
}
init();
+ currentDeviceZoom = DPIUtil.getDeviceZoom();
}
/**
@@ -542,7 +547,9 @@ public Image(Device device, Image srcImage, int flag) {
public Image(Device device, Rectangle bounds) {
super(device);
if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- init(bounds.width, bounds.height);
+ currentDeviceZoom = DPIUtil.getDeviceZoom();
+ Rectangle bounds1 = DPIUtil.autoScaleUp (bounds);
+ init(bounds1.width, bounds1.height);
init();
}
@@ -571,6 +578,9 @@ public Image(Device device, Rectangle bounds) {
*/
public Image(Device device, ImageData data) {
super(device);
+ if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ currentDeviceZoom = DPIUtil.getDeviceZoom();
+ data = DPIUtil.autoScaleUp (data);
init(data);
init();
}
@@ -612,6 +622,9 @@ public Image(Device device, ImageData source, ImageData mask) {
if (source.width != mask.width || source.height != mask.height) {
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
+ currentDeviceZoom = DPIUtil.getDeviceZoom();
+ source = DPIUtil.autoScaleUp (source);
+ mask = DPIUtil.autoScaleUp (mask);
mask = ImageData.convertMask (mask);
ImageData image = new ImageData(source.width, source.height, source.depth, source.palette, source.scanlinePad, source.data);
image.maskPad = mask.scanlinePad;
@@ -675,7 +688,10 @@ public Image(Device device, ImageData source, ImageData mask) {
*/
public Image(Device device, InputStream stream) {
super(device);
- init(new ImageData(stream));
+ ImageData data = new ImageData(stream);
+ currentDeviceZoom = DPIUtil.getDeviceZoom();
+ data = DPIUtil.autoScaleUp (data);
+ init(data);
init();
}
@@ -714,8 +730,11 @@ public Image(Device device, InputStream stream) {
public Image(Device device, String filename) {
super(device);
if (filename == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- initNative(filename);
- if (this.pixmap == 0 && this.surface == 0) init(new ImageData(filename));
+
+ ImageData data = new ImageData(filename);
+ currentDeviceZoom = DPIUtil.getDeviceZoom();
+ data = DPIUtil.autoScaleUp (data);
+ init(data);
init();
}
@@ -751,10 +770,20 @@ public Image(Device device, String filename) {
public Image(Device device, ImageFileNameProvider imageFileNameProvider) {
super(device);
this.imageFileNameProvider = imageFileNameProvider;
- currentDeviceZoom = getDeviceZoom ();
- String filename = DPIUtil.validateAndGetImagePathAtZoom (imageFileNameProvider, currentDeviceZoom, new boolean[1]);
- initNative (filename);
- if (this.pixmap == 0 && this.surface == 0) init(new ImageData(filename));
+ currentDeviceZoom = DPIUtil.getDeviceZoom();
+ boolean[] found = new boolean[1];
+ String filename = DPIUtil.validateAndGetImagePathAtZoom (imageFileNameProvider, currentDeviceZoom, found);
+ if (found[0]) {
+ initNative (filename);
+ if (this.pixmap == 0 && this.surface == 0) {
+ ImageData data = new ImageData(filename);
+ init(data);
+ }
+ } else {
+ ImageData imageData = new ImageData (filename);
+ ImageData resizedData = DPIUtil.autoScaleUp (imageData);
+ init(resizedData);
+ }
init ();
}
@@ -790,16 +819,18 @@ public Image(Device device, ImageFileNameProvider imageFileNameProvider) {
public Image(Device device, ImageDataProvider imageDataProvider) {
super(device);
this.imageDataProvider = imageDataProvider;
- currentDeviceZoom = getDeviceZoom ();
- ImageData data = DPIUtil.validateAndGetImageDataAtZoom(imageDataProvider, currentDeviceZoom, new boolean[1]);
- init (data);
+ currentDeviceZoom = DPIUtil.getDeviceZoom();
+ boolean[] found = new boolean[1];
+ ImageData data = DPIUtil.validateAndGetImageDataAtZoom(imageDataProvider, currentDeviceZoom, found);
+ if (found[0]) {
+ init (data);
+ } else {
+ ImageData resizedData = DPIUtil.autoScaleUp (data);
+ init (resizedData);
+ }
init ();
}
-int getDeviceZoom () {
- return DPIUtil.mapDPIToZoom (device._getDPIx ());
-}
-
/**
* Refresh the Image based on the zoom level, if required.
*
@@ -807,8 +838,9 @@ int getDeviceZoom () {
*/
boolean refreshImageForZoom () {
boolean refreshed = false;
+ int deviceZoom = DPIUtil.getDeviceZoom();
if (imageFileNameProvider != null) {
- int deviceZoomLevel = getDeviceZoom();
+ int deviceZoomLevel = deviceZoom;
if (deviceZoomLevel != currentDeviceZoom) {
boolean[] found = new boolean[1];
String filename = DPIUtil.validateAndGetImagePathAtZoom (imageFileNameProvider, deviceZoomLevel, found);
@@ -817,14 +849,26 @@ boolean refreshImageForZoom () {
/* Release current native resources */
destroy ();
initNative(filename);
- if (this.pixmap == 0 && this.surface == 0) init(new ImageData(filename));
+ if (this.pixmap == 0 && this.surface == 0) {
+ ImageData data = new ImageData(filename);
+ init(data);
+ }
+ init ();
+ refreshed = true;
+ }
+ if (!found[0]) {
+ /* Release current native resources */
+ destroy ();
+ ImageData imageData = new ImageData (filename);
+ ImageData resizedData = DPIUtil.autoScaleUp (imageData);
+ init(resizedData);
init ();
refreshed = true;
}
currentDeviceZoom = deviceZoomLevel;
}
} else if (imageDataProvider != null) {
- int deviceZoomLevel = getDeviceZoom();
+ int deviceZoomLevel = deviceZoom;
if (deviceZoomLevel != currentDeviceZoom) {
boolean[] found = new boolean[1];
ImageData data = DPIUtil.validateAndGetImageDataAtZoom (imageDataProvider, deviceZoomLevel, found);
@@ -836,6 +880,25 @@ boolean refreshImageForZoom () {
init();
refreshed = true;
}
+ if (!found[0]) {
+ /* Release current native resources */
+ destroy ();
+ ImageData resizedData = DPIUtil.autoScaleImageData(data, deviceZoomLevel, 100);
+ init(resizedData);
+ init();
+ refreshed = true;
+ }
+ currentDeviceZoom = deviceZoomLevel;
+ }
+ } else {
+ int deviceZoomLevel = deviceZoom;
+ if (deviceZoomLevel != currentDeviceZoom) {
+ ImageData data = getImageDataAtCurrentZoom();
+ destroy ();
+ ImageData resizedData = DPIUtil.autoScaleImageData(data, deviceZoomLevel, currentDeviceZoom);
+ init(resizedData);
+ init();
+ refreshed = true;
currentDeviceZoom = deviceZoomLevel;
}
}
@@ -1023,7 +1086,7 @@ void createMask() {
return;
}
if (mask != 0) return;
- mask = createMask(getImageData(), false);
+ mask = createMask(getImageDataAtCurrentZoom(), false);
if (mask == 0) SWT.error(SWT.ERROR_NO_HANDLES);
}
@@ -1242,13 +1305,12 @@ public Color getBackground() {
//NOT DONE
return null;
}
-
/**
* Returns the bounds of the receiver. The rectangle will always
* have x and y values of 0, and the width and height of the
* image.
*
- * @return a rectangle specifying the image's bounds
+ * @return a rectangle specifying the image's bounds in points
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
@@ -1257,6 +1319,24 @@ public Color getBackground() {
*/
public Rectangle getBounds() {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return DPIUtil.autoScaleBounds(getBoundsInPixels(), 100, currentDeviceZoom);
+}
+
+/**
+ * Returns the bounds of the receiver. The rectangle will always
+ * have x and y values of 0, and the width and height of the
+ * image in Pixels.
+ *
+ * @return a rectangle specifying the image's bounds in pixels
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
+ * </ul>
+ * @since 3.105
+ */
+public Rectangle getBoundsInPixels() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width != -1 && height != -1) {
return new Rectangle(0, 0, width, height);
}
@@ -1283,7 +1363,29 @@ public Rectangle getBounds() {
*
* @see ImageData
*/
-public ImageData getImageData() {
+public ImageData getImageData () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return getImageData(100);
+
+}
+
+/**
+ * Returns an <code>ImageData</code> based on the receiver
+ * Modifications made to this <code>ImageData</code> will not
+ * affect the Image.
+ *
+ * @return an <code>ImageData</code> containing the image's data
+ * and attributes at the current zoom level.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
+ * </ul>
+ *
+ * @see ImageData
+ * @since 3.105
+ */
+public ImageData getImageDataAtCurrentZoom () {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (OS.USE_CAIRO) {
@@ -1396,6 +1498,32 @@ public ImageData getImageData() {
}
/**
+ * Returns an <code>ImageData</code> for specified zoom, based on the receiver
+ * Modifications made to this <code>ImageData</code> will not affect the
+ * Image.
+ *
+ * @param zoom
+ * The zoom level in % of the standard resolution (which is 1
+ * physical monitor pixel == 1 SWT logical pixel). Typically 100,
+ * 150, or 200.
+ * @return an <code>ImageData</code> containing the image's data and
+ * attributes at specified zoom if present else null is returned.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
+ * </ul>
+ *
+ * @see ImageData
+ *
+ * @since 3.105
+ */
+ImageData getImageData (int zoom) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return DPIUtil.autoScaleImageData (getImageDataAtCurrentZoom (), zoom, currentDeviceZoom);
+}
+
+/**
* Invokes platform specific functionality to allocate a new image.
* <p>
* <b>IMPORTANT:</b> This method is <em>not</em> part of the public
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java
index 096cd33812..d629618ab9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,9 +11,10 @@
package org.eclipse.swt.graphics;
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;
import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.*;
/**
* Instances of this class represent areas of an x-y coordinate
@@ -160,6 +161,9 @@ static void gdk_region_get_rectangles(long /*int*/ region, long /*int*/[] rectan
public void add (int[] pointArray) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ addInPixels(DPIUtil.autoScaleUp(pointArray));
+}
+void addInPixels (int[] pointArray) {
/*
* Bug in GTK. If gdk_region_polygon() is called with one point,
* it segment faults. The fix is to make sure that it is called
@@ -188,7 +192,10 @@ public void add (int[] pointArray) {
public void add(Rectangle rect) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- add (rect.x, rect.y, rect.width, rect.height);
+ addInPixels(DPIUtil.autoScaleUp(rect));
+}
+void addInPixels(Rectangle rect) {
+ addInPixels (rect.x, rect.y, rect.width, rect.height);
}
/**
@@ -212,6 +219,9 @@ public void add(Rectangle rect) {
public void add(int x, int y, int width, int height) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ add(new Rectangle(x, y, width, height));
+}
+void addInPixels(int x, int y, int width, int height) {
GdkRectangle gdkRect = new GdkRectangle();
gdkRect.x = x;
gdkRect.y = y;
@@ -257,6 +267,9 @@ public void add(Region region) {
*/
public boolean contains(int x, int y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return contains(new Point(x, y));
+}
+boolean containsInPixels(int x, int y) {
return OS.gdk_region_point_in(handle, x, y);
}
@@ -276,8 +289,12 @@ public boolean contains(int x, int y) {
* </ul>
*/
public boolean contains(Point pt) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return containsInPixels(DPIUtil.autoScaleUp(pt));
+}
+boolean containsInPixels(Point pt) {
if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- return contains(pt.x, pt.y);
+ return containsInPixels(pt.x, pt.y);
}
@Override
@@ -319,6 +336,9 @@ public boolean equals(Object object) {
*/
public Rectangle getBounds() {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return DPIUtil.autoScaleDown(getBoundsInPixels());
+}
+Rectangle getBoundsInPixels() {
GdkRectangle gdkRect = new GdkRectangle();
OS.gdk_region_get_clipbox(handle, gdkRect);
return new Rectangle(gdkRect.x, gdkRect.y, gdkRect.width, gdkRect.height);
@@ -378,7 +398,11 @@ public int hashCode() {
public void intersect(Rectangle rect) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- intersect (rect.x, rect.y, rect.width, rect.height);
+ intersectInPixels(DPIUtil.autoScaleUp(rect));
+}
+
+void intersectInPixels(Rectangle rect) {
+ intersectInPixels (rect.x, rect.y, rect.width, rect.height);
}
/**
@@ -402,6 +426,10 @@ public void intersect(Rectangle rect) {
public void intersect(int x, int y, int width, int height) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ intersect(new Rectangle(x, y, width, height));
+}
+
+void intersectInPixels(int x, int y, int width, int height) {
GdkRectangle gdkRect = new GdkRectangle();
gdkRect.x = x;
gdkRect.y = y;
@@ -455,6 +483,10 @@ public void intersect(Region region) {
*/
public boolean intersects (int x, int y, int width, int height) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return intersects(new Rectangle(x, y, width, height));
+}
+
+boolean intersectsInPixels (int x, int y, int width, int height) {
GdkRectangle gdkRect = new GdkRectangle();
gdkRect.x = x;
gdkRect.y = y;
@@ -481,7 +513,11 @@ public boolean intersects (int x, int y, int width, int height) {
*/
public boolean intersects(Rectangle rect) {
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- return intersects(rect.x, rect.y, rect.width, rect.height);
+ return intersectsInPixels(DPIUtil.autoScaleUp(rect));
+}
+
+boolean intersectsInPixels(Rectangle rect) {
+ return intersectsInPixels(rect.x, rect.y, rect.width, rect.height);
}
/**
@@ -533,6 +569,10 @@ public boolean isEmpty() {
public void subtract (int[] pointArray) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ subtractInPixels(DPIUtil.autoScaleUp(pointArray));
+}
+
+void subtractInPixels (int[] pointArray) {
/*
* Bug in GTK. If gdk_region_polygon() is called with one point,
* it segment faults. The fix is to make sure that it is called
@@ -543,7 +583,6 @@ public void subtract (int[] pointArray) {
OS.gdk_region_subtract(handle, polyRgn);
OS.gdk_region_destroy(polyRgn);
}
-
/**
* Subtracts the given rectangle from the collection of polygons
* the receiver maintains to describe its area.
@@ -563,7 +602,11 @@ public void subtract (int[] pointArray) {
public void subtract(Rectangle rect) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- subtract (rect.x, rect.y, rect.width, rect.height);
+ subtractInPixels(DPIUtil.autoScaleUp(rect));
+}
+
+void subtractInPixels(Rectangle rect) {
+ subtractInPixels (rect.x, rect.y, rect.width, rect.height);
}
/**
@@ -587,6 +630,10 @@ public void subtract(Rectangle rect) {
public void subtract(int x, int y, int width, int height) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ subtract(new Rectangle(x, y, width, height));
+}
+
+void subtractInPixels(int x, int y, int width, int height) {
GdkRectangle gdkRect = new GdkRectangle();
gdkRect.x = x;
gdkRect.y = y;
@@ -636,6 +683,10 @@ public void subtract(Region region) {
*/
public void translate (int x, int y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ translate(new Point(x, y));
+}
+
+void translateInPixels (int x, int y) {
OS.gdk_region_offset (handle, x, y);
}
@@ -657,7 +708,11 @@ public void translate (int x, int y) {
public void translate (Point pt) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- translate (pt.x, pt.y);
+ translate(DPIUtil.autoScaleUp(pt));
+}
+
+void translateInPixels (Point pt) {
+ translateInPixels (pt.x, pt.y);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java
index 2c11cb88fb..52c8c6ec6f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,10 +10,10 @@
*******************************************************************************/
package org.eclipse.swt.graphics;
+import org.eclipse.swt.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;
import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.*;
/**
* <code>TextLayout</code> is a graphic object that represents
@@ -367,7 +367,13 @@ void destroy() {
* </ul>
*/
public void draw(GC gc, int x, int y) {
- draw(gc, x, y, -1, -1, null, null);
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ drawInPixels(gc, x, y);
+}
+
+void drawInPixels(GC gc, int x, int y) {
+ drawInPixels(gc, x, y, -1, -1, null, null);
}
/**
@@ -390,7 +396,13 @@ public void draw(GC gc, int x, int y) {
* </ul>
*/
public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) {
- draw(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground, 0);
+ checkLayout ();
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ drawInPixels(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground);
+}
+void drawInPixels(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) {
+ drawInPixels(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground, 0);
}
/**
@@ -422,6 +434,12 @@ public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Colo
*/
public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground, int flags) {
checkLayout ();
+ x = DPIUtil.autoScaleUp(x);
+ y = DPIUtil.autoScaleUp(y);
+ drawInPixels(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground, flags);
+}
+void drawInPixels(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground, int flags) {
+ checkLayout ();
computeRuns();
if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
@@ -776,6 +794,10 @@ public int getAscent () {
*/
public Rectangle getBounds() {
checkLayout();
+ return DPIUtil.autoScaleDown(getBoundsInPixels());
+}
+Rectangle getBoundsInPixels() {
+ checkLayout();
computeRuns();
int[] w = new int[1], h = new int[1];
OS.pango_layout_get_size(layout, w, h);
@@ -806,6 +828,11 @@ public Rectangle getBounds() {
*/
public Rectangle getBounds(int start, int end) {
checkLayout();
+ return DPIUtil.autoScaleDown(getBoundsInPixels(start, end));
+}
+
+Rectangle getBoundsInPixels(int start, int end) {
+ checkLayout();
computeRuns();
int length = text.length();
if (length == 0) return new Rectangle(0, 0, 0, 0);
@@ -910,6 +937,10 @@ public Font getFont () {
*/
public int getIndent () {
checkLayout();
+ return DPIUtil.autoScaleDown(getIndentInPixels());
+}
+
+int getIndentInPixels () {
return indent;
}
@@ -988,6 +1019,10 @@ public int getLevel(int offset) {
*/
public Rectangle getLineBounds(int lineIndex) {
checkLayout();
+ return DPIUtil.autoScaleDown(getLineBoundsInPixels(lineIndex));
+}
+
+Rectangle getLineBoundsInPixels(int lineIndex) {
computeRuns();
int lineCount = OS.pango_layout_get_line_count(layout);
if (!(0 <= lineIndex && lineIndex < lineCount)) SWT.error(SWT.ERROR_INVALID_RANGE);
@@ -1147,6 +1182,10 @@ public int[] getLineOffsets() {
*/
public Point getLocation(int offset, boolean trailing) {
checkLayout();
+ return DPIUtil.autoScaleDown(getLocationInPixels(offset, trailing));
+}
+
+Point getLocationInPixels(int offset, boolean trailing) {
computeRuns();
int length = text.length();
if (!(0 <= offset && offset <= length)) SWT.error(SWT.ERROR_INVALID_RANGE);
@@ -1282,8 +1321,12 @@ int _getOffset (int offset, int movement, boolean forward) {
*/
public int getOffset(Point point, int[] trailing) {
checkLayout();
+ return getOffsetInPixels(DPIUtil.autoScaleUp(point), trailing);
+}
+
+int getOffsetInPixels(Point point, int[] trailing) {
if (point == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- return getOffset(point.x, point.y, trailing);
+ return getOffsetInPixels(point.x, point.y, trailing);
}
/**
@@ -1311,6 +1354,10 @@ public int getOffset(Point point, int[] trailing) {
*/
public int getOffset(int x, int y, int[] trailing) {
checkLayout();
+ return getOffset(new Point(x, y), trailing);
+}
+
+int getOffsetInPixels(int x, int y, int[] trailing) {
computeRuns();
if (trailing != null && trailing.length < 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
x -= Math.min (indent, wrapIndent);
@@ -1500,6 +1547,10 @@ String getSegmentsText() {
*/
public int getSpacing () {
checkLayout();
+ return DPIUtil.autoScaleDown(getSpacingInPixels());
+}
+
+int getSpacingInPixels () {
return OS.PANGO_PIXELS(OS.pango_layout_get_spacing(layout));
}
@@ -1613,6 +1664,10 @@ public int getTextDirection () {
*/
public int getWidth () {
checkLayout ();
+ return DPIUtil.autoScaleDown(getWidthInPixels());
+}
+
+int getWidthInPixels () {
return wrapWidth;
}
@@ -1629,6 +1684,9 @@ public int getWidth () {
*/
public int getWrapIndent () {
checkLayout ();
+ return DPIUtil.autoScaleDown(getWrapIndentInPixels());
+}
+int getWrapIndentInPixels () {
return wrapIndent;
}
@@ -1780,6 +1838,11 @@ public void setFont (Font font) {
* @since 3.2
*/
public void setIndent (int indent) {
+ checkLayout ();
+ setIndentInPixels(DPIUtil.autoScaleUp(indent));
+}
+
+void setIndentInPixels (int indent) {
checkLayout();
if (indent < 0) return;
if (this.indent == indent) return;
@@ -1849,6 +1912,10 @@ public void setOrientation(int orientation) {
public void setSpacing (int spacing) {
checkLayout();
if (spacing < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ setSpacingInPixels(DPIUtil.autoScaleUp(spacing));
+}
+
+void setSpacingInPixels (int spacing) {
OS.pango_layout_set_spacing(layout, spacing * OS.PANGO_SCALE);
}
@@ -2146,6 +2213,10 @@ public void setTextDirection (int textDirection) {
public void setWidth (int width) {
checkLayout ();
if (width < -1 || width == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ setWidthInPixels(DPIUtil.autoScaleUp(width));
+}
+
+void setWidthInPixels (int width) {
if (wrapWidth == width) return;
freeRuns();
wrapWidth = width;
@@ -2180,6 +2251,10 @@ void setWidth () {
public void setWrapIndent (int wrapIndent) {
checkLayout();
if (wrapIndent < 0) return;
+ setWrapIndentInPixels(DPIUtil.autoScaleUp(wrapIndent));
+}
+
+void setWrapIndentInPixels (int wrapIndent) {
if (this.wrapIndent == wrapIndent) return;
this.wrapIndent = wrapIndent;
OS.pango_layout_set_indent(layout, (indent - wrapIndent) * OS.PANGO_SCALE);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java
index 60c30d1bc3..1d919cd733 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,10 +11,10 @@
package org.eclipse.swt.internal;
-import org.eclipse.swt.SWT;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.cairo.*;
import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
public class ImageList {
long /*int*/ [] pixbufs;
@@ -30,7 +30,7 @@ public static long /*int*/ convertSurface(Image image) {
long /*int*/ newSurface = image.surface;
int type = Cairo.cairo_surface_get_type(newSurface);
if (type != Cairo.CAIRO_SURFACE_TYPE_IMAGE) {
- Rectangle bounds = image.getBounds();
+ Rectangle bounds = image.getBoundsInPixels();
int format = Cairo.cairo_surface_get_content(newSurface) == Cairo.CAIRO_CONTENT_COLOR ? Cairo.CAIRO_FORMAT_RGB24 : Cairo.CAIRO_FORMAT_ARGB32;
newSurface = Cairo.cairo_image_surface_create(format, bounds.width, bounds.height);
if (newSurface == 0) SWT.error(SWT.ERROR_NO_HANDLES);
@@ -136,7 +136,7 @@ public static long /*int*/ createPixbuf(Image image) {
}
OS.g_object_unref(maskPixbuf);
} else {
- ImageData data = image.getImageData ();
+ ImageData data = image.getImageDataAtCurrentZoom ();
boolean hasAlpha = data.getTransparencyType () == SWT.TRANSPARENCY_ALPHA;
pixbuf = OS.gdk_pixbuf_new (OS.GDK_COLORSPACE_RGB, hasAlpha, 8, w [0], h [0]);
if (pixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES);
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 44d476634b..967550cf3f 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -166,7 +166,7 @@ public void addSelectionListener (SelectionListener listener) {
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java
index 86119022e3..dff797a026 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,6 +13,7 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;
import org.eclipse.swt.internal.gtk.*;
@@ -259,6 +260,12 @@ void reskinChildren (int flags) {
public void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) {
checkWidget();
if (width <= 0 || height <= 0) return;
+ Point destination = DPIUtil.autoScaleUp (new Point (destX, destY));
+ Rectangle srcRect = DPIUtil.autoScaleUp (new Rectangle (x, y, width, height));
+ scrollInPixels(destination.x, destination.y, srcRect.x, srcRect.y, srcRect.width, srcRect.height, all);
+}
+
+void scrollInPixels (int destX, int destY, int x, int y, int width, int height, boolean all) {
if ((style & SWT.MIRRORED) != 0) {
int clientWidth = getClientWidth ();
x = clientWidth - width - x;
@@ -357,10 +364,10 @@ public void scroll (int destX, int destY, int x, int y, int width, int height, b
Control [] children = _getChildren ();
for (int i=0; i<children.length; i++) {
Control child = children [i];
- Rectangle rect = child.getBounds ();
+ Rectangle rect = child.getBoundsInPixels ();
if (Math.min(x + width, rect.x + rect.width) >= Math.max (x, rect.x) &&
Math.min(y + height, rect.y + rect.height) >= Math.max (y, rect.y)) {
- child.setLocation (rect.x + deltaX, rect.y + deltaY);
+ child.setLocationInPixels (rect.x + deltaX, rect.y + deltaY);
}
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java
index aca785f36a..9bc1bebbbb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,9 +12,10 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;
import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
/**
* Instances of this class provide an i-beam that is typically used
@@ -171,8 +172,13 @@ boolean drawCaret () {
*/
public Rectangle getBounds () {
checkWidget();
+ return DPIUtil.autoScaleDown(getBoundsInPixels());
+}
+
+Rectangle getBoundsInPixels () {
+ checkWidget();
if (image != null) {
- Rectangle rect = image.getBounds ();
+ Rectangle rect = image.getBoundsInPixels ();
return new Rectangle (x, y, rect.width, rect.height);
} else {
if (width == 0) {
@@ -226,6 +232,11 @@ public Image getImage () {
*/
public Point getLocation () {
checkWidget();
+ return DPIUtil.autoScaleDown(getLocationInPixels());
+}
+
+Point getLocationInPixels () {
+ checkWidget();
return new Point (x, y);
}
@@ -256,8 +267,13 @@ public Canvas getParent () {
*/
public Point getSize () {
checkWidget();
+ return DPIUtil.autoScaleDown(getSizeInPixels());
+}
+
+Point getSizeInPixels () {
+ checkWidget();
if (image != null) {
- Rectangle rect = image.getBounds ();
+ Rectangle rect = image.getBoundsInPixels ();
return new Point (rect.width, rect.height);
} else {
if (width == 0) {
@@ -359,6 +375,11 @@ void releaseWidget () {
*/
public void setBounds (int x, int y, int width, int height) {
checkWidget();
+ setBounds (new Rectangle (x, y, width, height));
+}
+
+void setBoundsInPixels (int x, int y, int width, int height) {
+ checkWidget();
if (this.x == x && this.y == y && this.width == width && this.height == height) return;
boolean isFocus = isFocusCaret ();
if (isFocus && isVisible) hideCaret ();
@@ -383,8 +404,14 @@ public void setBounds (int x, int y, int width, int height) {
*/
public void setBounds (Rectangle rect) {
checkWidget();
+ rect = DPIUtil.autoScaleUp(rect);
+ setBoundsInPixels(rect);
+}
+
+void setBoundsInPixels (Rectangle rect) {
+ checkWidget();
if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
- setBounds (rect.x, rect.y, rect.width, rect.height);
+ setBoundsInPixels (rect.x, rect.y, rect.width, rect.height);
}
void setFocus () {
@@ -457,7 +484,12 @@ public void setImage (Image image) {
*/
public void setLocation (int x, int y) {
checkWidget();
- setBounds (x, y, width, height);
+ setLocation (new Point (x, y));
+}
+
+void setLocationInPixels (int x, int y) {
+ checkWidget();
+ setBoundsInPixels (x, y, width, height);
}
/**
@@ -474,8 +506,13 @@ public void setLocation (int x, int y) {
*/
public void setLocation (Point location) {
checkWidget();
+ setLocationInPixels (DPIUtil.autoScaleUp (location));
+}
+
+void setLocationInPixels (Point location) {
+ checkWidget();
if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
- setLocation (location.x, location.y);
+ setLocationInPixels (location.x, location.y);
}
/**
@@ -491,7 +528,12 @@ public void setLocation (Point location) {
*/
public void setSize (int width, int height) {
checkWidget();
- setBounds (x, y, width, height);
+ setSize (new Point (width,height));
+}
+
+void setSizeInPixels (int width, int height) {
+ checkWidget();
+ setBoundsInPixels (x, y, width, height);
}
/**
@@ -509,8 +551,13 @@ public void setSize (int width, int height) {
*/
public void setSize (Point size) {
checkWidget();
+ setSizeInPixels(DPIUtil.autoScaleUp (size));
+}
+
+void setSizeInPixels (Point size) {
+ checkWidget();
if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
- setSize (size.x, size.y);
+ setSizeInPixels (size.x, size.y);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
index 6ad07a5551..18643b4d3f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -394,7 +394,7 @@ void clearText () {
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
if ((style & SWT.READ_ONLY) != 0 || OS.GTK3) {
return computeNativeSize (handle, wHint, hHint, changed);
@@ -850,6 +850,12 @@ GdkColor getBackgroundColor () {
*/
public Point getCaretLocation () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getCaretLocationInPixels());
+}
+
+
+Point getCaretLocationInPixels () {
+ checkWidget ();
if ((style & SWT.READ_ONLY) != 0) {
return new Point (0, 0);
}
@@ -860,7 +866,7 @@ public Point getCaretLocation () {
long /*int*/ layout = OS.gtk_entry_get_layout (entryHandle);
PangoRectangle pos = new PangoRectangle ();
OS.pango_layout_index_to_pos (layout, index, pos);
- int x = offset_x [0] + OS.PANGO_PIXELS (pos.x) - getBorderWidth ();
+ int x = offset_x [0] + OS.PANGO_PIXELS (pos.x) - getBorderWidthInPixels ();
int y = offset_y [0] + OS.PANGO_PIXELS (pos.y);
return new Point (x, y);
}
@@ -1133,6 +1139,12 @@ String getText (int start, int stop) {
*/
public int getTextHeight () {
checkWidget();
+ return DPIUtil.autoScaleDown(getTextHeightInPixels());
+}
+
+
+int getTextHeightInPixels () {
+ checkWidget();
GtkRequisition requisition = new GtkRequisition ();
gtk_widget_size_request (handle, requisition);
if (OS.GTK3) {
@@ -1911,7 +1923,7 @@ void setBackgroundColor (GdkColor color) {
@Override
int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
int newHeight = height;
- if (resize) newHeight = Math.max (getTextHeight (), height);
+ if (resize) newHeight = Math.max (getTextHeightInPixels (), height);
return super.setBounds (x, y, width, newHeight, move, resize);
}
@@ -2142,6 +2154,11 @@ public void setOrientation (int orientation) {
*/
public void setSelection (Point selection) {
checkWidget();
+ selection = DPIUtil.autoScaleUp(selection);
+}
+
+void setSelectionInPixels (Point selection) {
+ checkWidget();
if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
if ((style & SWT.READ_ONLY) != 0) return;
if (entryHandle != 0) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
index 28c4d56fae..6d83315116 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,6 +13,7 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;
import org.eclipse.swt.internal.gtk.*;
@@ -64,6 +65,7 @@ public class Composite extends Scrollable {
Layout layout;
Control[] tabList;
int layoutCount, backgroundMode;
+ GdkRGBA background;
static final String NO_INPUT_METHOD = "org.eclipse.swt.internal.gtk.noInputMethod"; //$NON-NLS-1$
@@ -227,7 +229,7 @@ long /*int*/ childStyle () {
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
display.runSkin();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
@@ -236,7 +238,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
if (layout != null) {
if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
changed |= (state & LAYOUT_CHANGED) != 0;
- size = layout.computeSize (this, wHint, hHint, changed);
+ size = DPIUtil.autoScaleUp(layout.computeSize (this, DPIUtil.autoScaleDown(wHint), DPIUtil.autoScaleDown(hHint), changed));
state &= ~LAYOUT_CHANGED;
} else {
size = new Point (wHint, hHint);
@@ -248,7 +250,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
}
if (wHint != SWT.DEFAULT) size.x = wHint;
if (hHint != SWT.DEFAULT) size.y = hHint;
- Rectangle trim = computeTrim (0, 0, size.x, size.y);
+ Rectangle trim = DPIUtil.autoScaleUp (computeTrim (0, 0, DPIUtil.autoScaleDown(size.x), DPIUtil.autoScaleDown(size.y)));
return new Point (trim.width, trim.height);
}
@@ -400,6 +402,14 @@ void deregister () {
* @since 3.6
*/
public void drawBackground (GC gc, int x, int y, int width, int height, int offsetX, int offsetY) {
+ checkWidget();
+ Rectangle rect = DPIUtil.autoScaleUp(new Rectangle (x, y, width, height));
+ offsetX = DPIUtil.autoScaleUp(offsetX);
+ offsetY = DPIUtil.autoScaleUp(offsetY);
+ drawBackgroundInPixels(gc, rect.x, rect.y, rect.width, rect.height, offsetX, offsetY);
+}
+
+void drawBackgroundInPixels (GC gc, int x, int y, int width, int height, int offsetX, int offsetY) {
checkWidget ();
if (gc == null) error (SWT.ERROR_NULL_ARGUMENT);
if (gc.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
@@ -410,7 +420,7 @@ public void drawBackground (GC gc, int x, int y, int width, int height, int offs
if (cairo != 0) {
Cairo.cairo_save (cairo);
if (control.backgroundImage != null) {
- Point pt = display.map (this, control, 0, 0);
+ Point pt = display.mapInPixels (this, control, 0, 0);
Cairo.cairo_translate (cairo, -pt.x - offsetX, -pt.y - offsetY);
x += pt.x + offsetX;
y += pt.y + offsetY;
@@ -454,7 +464,7 @@ public void drawBackground (GC gc, int x, int y, int width, int height, int offs
GdkGCValues values = new GdkGCValues ();
OS.gdk_gc_get_values (gdkGC, values);
if (control.backgroundImage != null) {
- Point pt = display.map (this, control, 0, 0);
+ Point pt = display.mapInPixels (this, control, 0, 0);
OS.gdk_gc_set_fill (gdkGC, OS.GDK_TILED);
OS.gdk_gc_set_ts_origin (gdkGC, -pt.x - offsetX, -pt.y - offsetY);
OS.gdk_gc_set_tile (gdkGC, control.backgroundImage.pixmap);
@@ -470,7 +480,8 @@ public void drawBackground (GC gc, int x, int y, int width, int height, int offs
}
}
} else {
- gc.fillRectangle (x, y, width, height);
+ gc.fillRectangle(DPIUtil.autoScaleDown(new Rectangle(x, y, width, height)));
+
}
}
@@ -649,7 +660,7 @@ int getChildrenCount () {
}
@Override
-public Rectangle getClientArea () {
+Rectangle getClientAreaInPixels () {
checkWidget();
if ((state & CANVAS) != 0) {
if ((state & ZERO_WIDTH) != 0 && (state & ZERO_HEIGHT) != 0) {
@@ -663,7 +674,24 @@ public Rectangle getClientArea () {
int height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
return new Rectangle (0, 0, width, height);
}
- return super.getClientArea();
+ return super.getClientAreaInPixels();
+}
+
+@Override
+GdkColor getContextBackground () {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ if (background != null) {
+ GdkColor color = new GdkColor ();
+ color.red = (short)(background.red * 0xFFFF);
+ color.green = (short)(background.green * 0xFFFF);
+ color.blue = (short)(background.blue * 0xFFFF);
+ return color;
+ } else {
+ return display.COLOR_WIDGET_BACKGROUND;
+ }
+ } else {
+ return super.getContextBackground();
+ }
}
/**
@@ -770,11 +798,8 @@ long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ eventPtr) {
for (int i=0; i<n_rectangles[0]; i++) {
Event event = new Event ();
OS.memmove (rect, rectangles [0] + i * GdkRectangle.sizeof, GdkRectangle.sizeof);
- event.x = rect.x;
- event.y = rect.y;
- event.width = rect.width;
- event.height = rect.height;
- if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.width - event.x;
+ event.setBounds (DPIUtil.autoScaleDown (new Rectangle(rect.x, rect.y, rect.width, rect.height)));
+ if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (getClientWidth ()) - event.width - event.x;
long /*int*/ damageRgn = OS.gdk_region_new ();
OS.gdk_region_union_with_rect (damageRgn, rect);
GCData data = new GCData ();
@@ -1340,10 +1365,10 @@ void moveChildren(int oldWidth) {
Point minimumSize (int wHint, int hHint, boolean changed) {
Control [] children = _getChildren ();
- Rectangle clientArea = getClientArea ();
+ Rectangle clientArea = getClientAreaInPixels ();
int width = 0, height = 0;
for (int i=0; i<children.length; i++) {
- Rectangle rect = children [i].getBounds ();
+ Rectangle rect = children [i].getBoundsInPixels ();
width = Math.max (width, rect.x - clientArea.x + rect.width);
height = Math.max (height, rect.y - clientArea.y + rect.height);
}
@@ -1359,23 +1384,24 @@ long /*int*/ parentingHandle () {
void printWidget (GC gc, long /*int*/ drawable, int depth, int x, int y) {
Region oldClip = new Region (gc.getDevice ());
Region newClip = new Region (gc.getDevice ());
+ Point loc = DPIUtil.autoScaleDown(new Point (x, y));
gc.getClipping (oldClip);
Rectangle rect = getBounds ();
newClip.add (oldClip);
- newClip.intersect (x, y, rect.width, rect.height);
+ newClip.intersect (loc.x, loc.y, rect.width, rect.height);
gc.setClipping (newClip);
super.printWidget (gc, drawable, depth, x, y);
- Rectangle clientRect = getClientArea ();
- Point pt = display.map (this, parent, clientRect.x, clientRect.y);
+ Rectangle clientRect = getClientAreaInPixels ();
+ Point pt = display.mapInPixels (this, parent, clientRect.x, clientRect.y);
clientRect.x = x + pt.x - rect.x;
clientRect.y = y + pt.y - rect.y;
- newClip.intersect (clientRect);
+ newClip.intersect (DPIUtil.autoScaleDown(clientRect));
gc.setClipping (newClip);
Control [] children = _getChildren ();
for (int i=children.length-1; i>=0; --i) {
Control child = children [i];
if (child.getVisible ()) {
- Point location = child.getLocation ();
+ Point location = child.getLocationInPixels ();
child.printWidget (gc, drawable, depth, x + location.x, y + location.y);
}
}
@@ -1483,6 +1509,18 @@ public void setBackgroundMode (int mode) {
}
@Override
+void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ background = rgba;
+ String color = gtk_rgba_to_css_string(background);
+ String css = "SwtFixed {background-color: " + color + "}";
+ gtk_css_provider_load_from_css(context, css);
+ } else {
+ super.setBackgroundColor(context, handle, rgba);
+ }
+}
+
+@Override
int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
int result = super.setBounds (x, y, width, height, move, resize);
if ((result & RESIZED) != 0 && layout != null) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index 9fe8dbf881..ed36380842 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -130,7 +130,7 @@ void drawBackground (Control control, long /*int*/ window, long /*int*/ cr, long
Cairo.cairo_clip(cairo);
}
if (control.backgroundImage != null) {
- Point pt = display.map (this, control, 0, 0);
+ Point pt = display.mapInPixels (this, control, 0, 0);
Cairo.cairo_translate (cairo, -pt.x, -pt.y);
x += pt.x;
y += pt.y;
@@ -156,7 +156,7 @@ void drawBackground (Control control, long /*int*/ window, long /*int*/ cr, long
long /*int*/ gdkGC = OS.gdk_gc_new (window);
if (region != 0) OS.gdk_gc_set_clip_region (gdkGC, region);
if (control.backgroundImage != null) {
- Point pt = display.map (this, control, 0, 0);
+ Point pt = display.mapInPixels (this, control, 0, 0);
OS.gdk_gc_set_fill (gdkGC, OS.GDK_TILED);
OS.gdk_gc_set_ts_origin (gdkGC, -pt.x, -pt.y);
OS.gdk_gc_set_tile (gdkGC, control.backgroundImage.pixmap);
@@ -561,7 +561,7 @@ void printWindow (boolean first, Control control, GC gc, long /*int*/ drawable,
}
/**
- * Returns the preferred size of the receiver.
+ * Returns the preferred size(in Points) of the receiver.
* <p>
* The <em>preferred size</em> of a control is the size that it would
* best be displayed at. The width hint and height hint arguments
@@ -591,6 +591,10 @@ public Point computeSize (int wHint, int hHint) {
return computeSize (wHint, hHint, true);
}
+Point computeSizeInPixels (int wHint, int hHint) {
+ return computeSizeInPixels (wHint, hHint, true);
+}
+
Widget computeTabGroup () {
if (isTabGroup()) return this;
return parent.computeTabGroup ();
@@ -661,7 +665,7 @@ void checkForeground () {
}
void checkBorder () {
- if (getBorderWidth () == 0) style &= ~SWT.BORDER;
+ if (getBorderWidthInPixels () == 0) style &= ~SWT.BORDER;
}
void checkMirrored () {
@@ -690,7 +694,7 @@ void createWidget (int index) {
}
/**
- * Returns the preferred size of the receiver.
+ * Returns the preferred size (in points) of the receiver.
* <p>
* The <em>preferred size</em> of a control is the size that it would
* best be displayed at. The width hint and height hint arguments
@@ -727,6 +731,15 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
+ wHint = DPIUtil.autoScaleUp(wHint);
+ hHint = DPIUtil.autoScaleUp(hHint);
+ return DPIUtil.autoScaleDown (computeSizeInPixels (wHint, hHint, changed));
+}
+
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
+ checkWidget();
+ if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
+ if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
return computeNativeSize (handle, wHint, hHint, changed);
}
@@ -815,7 +828,7 @@ Accessible _getAccessible () {
}
/**
- * Returns a rectangle describing the receiver's size and location
+ * Returns a rectangle describing the receiver's size and location in points
* relative to its parent (or its display if its parent is null),
* unless the receiver is a shell. In this case, the location is
* relative to the display.
@@ -829,6 +842,11 @@ Accessible _getAccessible () {
*/
public Rectangle getBounds () {
checkWidget();
+ return DPIUtil.autoScaleDown(getBoundsInPixels());
+}
+
+Rectangle getBoundsInPixels () {
+ checkWidget();
long /*int*/ topHandle = topHandle ();
GtkAllocation allocation = new GtkAllocation ();
OS.gtk_widget_get_allocation (topHandle, allocation);
@@ -841,7 +859,7 @@ public Rectangle getBounds () {
}
/**
- * Sets the receiver's size and location to the rectangular
+ * Sets the receiver's size and location in points to the rectangular
* area specified by the argument. The <code>x</code> and
* <code>y</code> fields of the rectangle are relative to
* the receiver's parent (or its display if its parent is null).
@@ -866,11 +884,18 @@ public Rectangle getBounds () {
public void setBounds (Rectangle rect) {
checkWidget ();
if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
+ rect = DPIUtil.autoScaleUp(rect);
+ setBounds (rect.x, rect.y, Math.max (0, rect.width), Math.max (0, rect.height), true, true);
+}
+
+void setBoundsInPixels (Rectangle rect) {
+ checkWidget ();
+ if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
setBounds (rect.x, rect.y, Math.max (0, rect.width), Math.max (0, rect.height), true, true);
}
/**
- * Sets the receiver's size and location to the rectangular
+ * Sets the receiver's size and location in points to the rectangular
* area specified by the arguments. The <code>x</code> and
* <code>y</code> arguments are relative to the receiver's
* parent (or its display if its parent is null), unless
@@ -899,6 +924,12 @@ public void setBounds (Rectangle rect) {
*/
public void setBounds (int x, int y, int width, int height) {
checkWidget();
+ Rectangle rect = DPIUtil.autoScaleUp(new Rectangle (x, y, width, height));
+ setBounds (rect.x, rect.y, Math.max (0, rect.width), Math.max (0, rect.height), true, true);
+}
+
+void setBoundsInPixels (int x, int y, int width, int height) {
+ checkWidget();
setBounds (x, y, Math.max (0, width), Math.max (0, height), true, true);
}
@@ -1075,7 +1106,7 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
/**
* Returns a point describing the receiver's location relative
- * to its parent (or its display if its parent is null), unless
+ * to its parent in points (or its display if its parent is null), unless
* the receiver is a shell. In this case, the point is
* relative to the display.
*
@@ -1088,6 +1119,11 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
*/
public Point getLocation () {
checkWidget();
+ return DPIUtil.autoScaleDown(getLocationInPixels());
+}
+
+Point getLocationInPixels () {
+ checkWidget();
long /*int*/ topHandle = topHandle ();
GtkAllocation allocation = new GtkAllocation ();
OS.gtk_widget_get_allocation (topHandle, allocation);
@@ -1117,6 +1153,13 @@ public Point getLocation () {
public void setLocation (Point location) {
checkWidget ();
if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
+ location = DPIUtil.autoScaleUp(location);
+ setBounds (location.x, location.y, 0, 0, true, false);
+}
+
+void setLocationInPixels (Point location) {
+ checkWidget ();
+ if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
setBounds (location.x, location.y, 0, 0, true, false);
}
@@ -1127,7 +1170,7 @@ public void setLocation (Point location) {
* the receiver is a shell. In this case, the point is
* relative to the display.
*
- * @param x the new x coordinate for the receiver
+ * @param x the new x coordinate in for the receiver
* @param y the new y coordinate for the receiver
*
* @exception SWTException <ul>
@@ -1137,11 +1180,17 @@ public void setLocation (Point location) {
*/
public void setLocation(int x, int y) {
checkWidget();
+ Point loc = DPIUtil.autoScaleUp(new Point (x, y));
+ setBounds (loc.x, loc.y, 0, 0, true, false);
+}
+
+void setLocationInPixels(int x, int y) {
+ checkWidget();
setBounds (x, y, 0, 0, true, false);
}
/**
- * Returns a point describing the receiver's size. The
+ * Returns a point describing the receiver's size in points. The
* x coordinate of the result is the width of the receiver.
* The y coordinate of the result is the height of the
* receiver.
@@ -1155,6 +1204,11 @@ public void setLocation(int x, int y) {
*/
public Point getSize () {
checkWidget();
+ return DPIUtil.autoScaleDown(getSizeInPixels());
+}
+
+Point getSizeInPixels () {
+ checkWidget();
long /*int*/ topHandle = topHandle ();
GtkAllocation allocation = new GtkAllocation ();
OS.gtk_widget_get_allocation (topHandle, allocation);
@@ -1176,7 +1230,7 @@ public Point getSize () {
* set to (2^14)-1 instead.
* </p>
*
- * @param size the new size for the receiver
+ * @param size the new size in points for the receiver
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the point is null</li>
@@ -1185,10 +1239,18 @@ public Point getSize () {
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
+ * @since 3.105
*/
public void setSize (Point size) {
checkWidget ();
if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+ size = DPIUtil.autoScaleUp(size);
+ setBounds (0, 0, Math.max (0, size.x), Math.max (0, size.y), false, true);
+}
+
+void setSizeInPixels (Point size) {
+ checkWidget ();
+ if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
setBounds (0, 0, Math.max (0, size.x), Math.max (0, size.y), false, true);
}
@@ -1255,8 +1317,8 @@ void setRelations () {
* set to (2^14)-1 instead.
* </p>
*
- * @param width the new width for the receiver
- * @param height the new height for the receiver
+ * @param width the new width in points for the receiver
+ * @param height the new height in points for the receiver
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
@@ -1265,6 +1327,12 @@ void setRelations () {
*/
public void setSize (int width, int height) {
checkWidget();
+ Point size = DPIUtil.autoScaleUp(new Point (width, height));
+ setBounds (0, 0, Math.max (0, size.x), Math.max (0, size.y), false, true);
+}
+
+void setSizeInPixels (int width, int height) {
+ checkWidget();
setBounds (0, 0, Math.max (0, width), Math.max (0, height), false, true);
}
@@ -1414,8 +1482,8 @@ public void setLayoutData (Object layoutData) {
* {@link Display#map(Control, Control, Rectangle)}.
* </p>
*
- * @param x the x coordinate to be translated
- * @param y the y coordinate to be translated
+ * @param x the x coordinate in points to be translated
+ * @param y the y coordinate in points to be translated
* @return the translated coordinates
*
* @exception SWTException <ul>
@@ -1427,6 +1495,11 @@ public void setLayoutData (Object layoutData) {
*/
public Point toControl (int x, int y) {
checkWidget ();
+ return toControl (new Point (x, y));
+}
+
+Point toControlInPixels (int x, int y) {
+ checkWidget ();
long /*int*/ window = eventWindow ();
int [] origin_x = new int [1], origin_y = new int [1];
OS.gdk_window_get_origin (window, origin_x, origin_y);
@@ -1459,7 +1532,14 @@ public Point toControl (int x, int y) {
public Point toControl (Point point) {
checkWidget ();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- return toControl (point.x, point.y);
+ point = DPIUtil.autoScaleUp(point);
+ return DPIUtil.autoScaleDown(toControlInPixels (point.x, point.y));
+}
+
+Point toControlInPixels (Point point) {
+ checkWidget ();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ return toControlInPixels (point.x, point.y);
}
/**
@@ -1484,6 +1564,11 @@ public Point toControl (Point point) {
*/
public Point toDisplay (int x, int y) {
checkWidget();
+ return toDisplay (new Point (x, y));
+}
+
+Point toDisplayInPixels (int x, int y) {
+ checkWidget();
long /*int*/ window = eventWindow ();
int [] origin_x = new int [1], origin_y = new int [1];
OS.gdk_window_get_origin (window, origin_x, origin_y);
@@ -1516,9 +1601,15 @@ public Point toDisplay (int x, int y) {
public Point toDisplay (Point point) {
checkWidget();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- return toDisplay (point.x, point.y);
+ point = DPIUtil.autoScaleUp(point);
+ return DPIUtil.autoScaleDown(toDisplayInPixels (point.x, point.y));
}
+Point toDisplayInPixels (Point point) {
+ checkWidget();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ return toDisplayInPixels (point.x, point.y);
+}
/**
* Adds the listener to the collection of listeners who will
* be notified when the control is moved or resized, by sending
@@ -2395,7 +2486,7 @@ boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean
Point startPos = null;
Point currPos = null;
if (OS.GTK3) {
- startPos = display.getCursorLocation();
+ startPos = display.getCursorLocationInPixels();
}
while (!quit) {
@@ -2413,7 +2504,7 @@ boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean
break;
} else {
if (OS.GTK3) { //428852
- currPos = display.getCursorLocation();
+ currPos = display.getCursorLocationInPixels();
dragging = OS.gtk_drag_check_threshold (handle,
startPos.x, startPos.y, currPos.x, currPos.y);
if (dragging) break;
@@ -2669,7 +2760,7 @@ GdkColor getBaseColor () {
}
/**
- * Returns the receiver's border width.
+ * Returns the receiver's border width in points.
*
* @return the border width
*
@@ -2679,6 +2770,10 @@ GdkColor getBaseColor () {
* </ul>
*/
public int getBorderWidth () {
+ return DPIUtil.autoScaleDown(getBorderWidthInPixels());
+}
+
+int getBorderWidthInPixels () {
checkWidget();
return 0;
}
@@ -3255,18 +3350,18 @@ long /*int*/ gtk_draw (long /*int*/ widget, long /*int*/ cairo) {
OS.gdk_cairo_get_clip_rectangle (cairo, rect);
Event event = new Event ();
event.count = 1;
- event.x = rect.x;
- event.y = rect.y;
- event.width = rect.width;
- event.height = rect.height;
- if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.width - event.x;
+ Rectangle eventRect = new Rectangle (rect.x, rect.y, rect.width, rect.height);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
+ if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (getClientWidth ()) - event.width - event.x;
GCData data = new GCData ();
// data.damageRgn = gdkEvent.region;
if (OS.GTK_VERSION <= OS.VERSION (3, 9, 0)) {
data.cairo = cairo;
}
GC gc = event.gc = GC.gtk_new (this, data);
- gc.setClipping (rect.x, rect.y, rect.width, rect.height);
+ Rectangle rect2 = DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height));
+ // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075
+ gc.setClipping (rect2.x, rect2.y, rect2.width, rect2.height);
drawWidget (gc);
sendEvent (SWT.Paint, event);
gc.dispose ();
@@ -3282,11 +3377,9 @@ long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ eventPtr) {
OS.memmove(gdkEvent, eventPtr, GdkEventExpose.sizeof);
Event event = new Event ();
event.count = gdkEvent.count;
- event.x = gdkEvent.area_x;
- event.y = gdkEvent.area_y;
- event.width = gdkEvent.area_width;
- event.height = gdkEvent.area_height;
- if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.width - event.x;
+ Rectangle eventRect = new Rectangle (gdkEvent.area_x, gdkEvent.area_y, gdkEvent.area_width, gdkEvent.area_height);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
+ if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (getClientWidth ()) - event.width - event.x;
GCData data = new GCData ();
data.damageRgn = gdkEvent.region;
GC gc = event.gc = GC.gtk_new (this, data);
@@ -3633,7 +3726,7 @@ boolean isShowing () {
if (!isVisible ()) return false;
Control control = this;
while (control != null) {
- Point size = control.getSize ();
+ Point size = control.getSizeInPixels ();
if (size.x == 0 || size.y == 0) {
return false;
}
@@ -3831,6 +3924,12 @@ void redraw (boolean all) {
*/
public void redraw (int x, int y, int width, int height, boolean all) {
checkWidget();
+ Rectangle rect = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
+ redrawInPixels(rect.x, rect.y, rect.width, rect.height, all);
+}
+
+void redrawInPixels (int x, int y, int width, int height, boolean all) {
+ checkWidget();
if (!OS.gtk_widget_get_visible (topHandle ())) return;
if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - width - x;
redrawWidget (x, y, width, height, false, all, false);
@@ -3931,9 +4030,9 @@ void restackWindow (long /*int*/ window, long /*int*/ sibling, boolean above) {
boolean sendDragEvent (int button, int stateMask, int x, int y, boolean isStateMask) {
Event event = new Event ();
event.button = button;
- event.x = x;
- event.y = y;
- if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.x;
+ Rectangle eventRect = new Rectangle (x, y, 0, 0);
+ event.setBounds (eventRect);
+ if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown(getClientWidth ()) - event.x;
if (isStateMask) {
event.stateMask = stateMask;
} else {
@@ -4000,16 +4099,16 @@ boolean sendMouseEvent (int type, int button, int count, int detail, boolean sen
event.detail = detail;
event.count = count;
if (is_hint) {
- event.x = (int)x;
- event.y = (int)y;
+ Rectangle eventRect = new Rectangle ((int)x, (int)y, 0, 0);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
} else {
long /*int*/ window = eventWindow ();
int [] origin_x = new int [1], origin_y = new int [1];
OS.gdk_window_get_origin (window, origin_x, origin_y);
- event.x = (int)x - origin_x [0];
- event.y = (int)y - origin_y [0];
+ Rectangle eventRect = new Rectangle ((int)x - origin_x [0], (int)y - origin_y [0], 0, 0);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
}
- if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.x;
+ if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (getClientWidth ()) - event.x;
setInputState (event, state);
if (send) {
sendEvent (type, event);
@@ -4873,7 +4972,7 @@ public void setRedraw (boolean redraw) {
if (drawCount++ == 0) {
if (gtk_widget_get_realized (handle)) {
long /*int*/ window = paintWindow ();
- Rectangle rect = getBounds ();
+ Rectangle rect = getBoundsInPixels ();
GdkWindowAttr attributes = new GdkWindowAttr ();
attributes.width = rect.width;
attributes.height = rect.height;
@@ -5196,8 +5295,8 @@ boolean showMenu (int x, int y) {
boolean showMenu (int x, int y, int detail) {
Event event = new Event ();
- event.x = x;
- event.y = y;
+ Rectangle eventRect = new Rectangle (x, y, 0, 0);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
event.detail = detail;
sendEvent (SWT.MenuDetect, event);
//widget could be disposed at this point
@@ -5206,8 +5305,9 @@ boolean showMenu (int x, int y, int detail) {
if (menu != null && !menu.isDisposed ()) {
boolean hooksKeys = hooks (SWT.KeyDown) || hooks (SWT.KeyUp);
menu.createIMMenu (hooksKeys ? imHandle() : 0);
- if (event.x != x || event.y != y) {
- menu.setLocation (event.x, event.y);
+ Rectangle rect = DPIUtil.autoScaleUp (event.getBounds ());
+ if (rect.x != x || rect.y != y) {
+ menu.setLocationInPixels (rect.x, rect.y);
}
menu.setVisible (true);
return true;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java
index 7e792c1e28..cfefd0eee0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java
@@ -159,8 +159,8 @@ public DateTime (Composite parent, int style) {
if (isDateWithDropDownButton ()) {
//Date w/ drop down button is in containers.
//first time round we set the bounds manually for correct Right_to_left behaviour
- Point size = computeSize (SWT.DEFAULT, SWT.DEFAULT);
- setBounds (0, 0, size.x, size.y);
+ Point size = computeSizeInPixels (SWT.DEFAULT, SWT.DEFAULT);
+ setBoundsInPixels (0, 0, size.x, size.y);
}
}
@@ -236,7 +236,7 @@ protected void checkSubclass () {
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
int width = 0, height = 0;
@@ -254,9 +254,9 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
height = size.y;
} else {
Point textSize = computeNativeSize (textEntryHandle, wHint, hHint, changed);
- Rectangle trim = computeTrim (0,0, textSize.x,textSize.y);
+ Rectangle trim = computeTrimInPixels (0,0, textSize.x,textSize.y);
if (isDateWithDropDownButton ()){
- Point buttonSize = down.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed);
+ Point buttonSize = down.computeSizeInPixels (SWT.DEFAULT, SWT.DEFAULT, changed);
width = trim.width + buttonSize.x;
height = Math.max (trim.height, buttonSize.y);
} else if (isDate () || isTime ()) {
@@ -275,7 +275,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
if (height == 0) height = DEFAULT_HEIGHT;
if (wHint != SWT.DEFAULT) width = wHint;
if (hHint != SWT.DEFAULT) height = hHint;
- int borderWidth = getBorderWidth ();
+ int borderWidth = getBorderWidthInPixels ();
if (prefferedSize == null && (isDateWithDropDownButton () && OS.GTK3)) {
prefferedSize = new Point (width + 2*borderWidth, height+ 2*borderWidth);
@@ -286,13 +286,13 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
}
@Override
-public Rectangle computeTrim (int x, int y, int width, int height) {
+Rectangle computeTrimInPixels (int x, int y, int width, int height) {
if (isCalendar ()) {
- return super.computeTrim (x, y, width, height);
+ return super.computeTrimInPixels (x, y, width, height);
}
checkWidget ();
- Rectangle trim = super.computeTrim (x, y, width, height);
+ Rectangle trim = super.computeTrimInPixels (x, y, width, height);
int xborder = 0, yborder = 0;
if (OS.GTK3) {
GtkBorder tmp = new GtkBorder ();
@@ -559,11 +559,11 @@ void dropDownCalendar (boolean drop) {
}
//This is the x/y/width/height of the container of DateTime
- Point containerBounds = getSize ();
- Point calendarSize = popupCalendar.computeSize (SWT.DEFAULT, SWT.DEFAULT, false);
+ Point containerBounds = getSizeInPixels ();
+ Point calendarSize = popupCalendar.computeSizeInPixels (SWT.DEFAULT, SWT.DEFAULT, false);
//Set the inner calendar pos/size. (not the popup shell pos/size)
- popupCalendar.setBounds (1, 1, Math.max (containerBounds.x - 2, calendarSize.x), calendarSize.y);
+ popupCalendar.setBoundsInPixels (1, 1, Math.max (containerBounds.x - 2, calendarSize.x), calendarSize.y);
//Set Date & focus current day
popupCalendar.setDate (savedYear, savedMonth, savedDay);
@@ -572,7 +572,7 @@ void dropDownCalendar (boolean drop) {
Display display = getDisplay ();
//To display popup calendar, we need to know where the parent is relative to the whole screen.
- Rectangle coordsRelativeToScreen = display.map (getParent (), null, getBounds ());
+ Rectangle coordsRelativeToScreen = display.mapInPixels (getParent (), null, getBoundsInPixels ());
Rectangle displayRect = getMonitor ().getClientArea ();
showPopupShell (containerBounds, calendarSize, coordsRelativeToScreen, displayRect);
@@ -587,7 +587,7 @@ private void showPopupShell (Point containerBounds, Point calendarSize, Rectangl
int y = calculateCalendarYpos (containerBounds, coordsRelativeToScreen, height, displayRect);
int x = calculateCalendarXpos (calendarSize, coordsRelativeToScreen, displayRect, width);
- popupShell.setBounds (x, y, width, height);
+ popupShell.setBoundsInPixels (x, y, width, height);
popupShell.setVisible (true);
if (isFocusControl ()) {
popupCalendar.setFocus ();
@@ -1071,7 +1071,7 @@ void initAccessible () {
@Override
public void getLocation (AccessibleControlEvent e) {
- Rectangle rect = display.map (getParent (), null, getBounds ());
+ Rectangle rect = display.mapInPixels (getParent (), null, getBoundsInPixels ());
e.x = rect.x;
e.y = rect.y;
e.width = rect.width;
@@ -1691,7 +1691,7 @@ public void setYear (int year) {
}
@Override
-public void setBounds (int x, int y, int width, int height) {
+void setBoundsInPixels (int x, int y, int width, int height) {
//Date with Drop down is in container. Needs extra handling.
if (isDateWithDropDownButton () && OS.GTK3) {
@@ -1699,7 +1699,7 @@ public void setBounds (int x, int y, int width, int height) {
OS.gtk_widget_get_preferred_size (textEntryHandle, null, requisition);
int oldHeight = requisition.height; //Entry should not expand vertically. It is single liner.
- int newWidth = width - (down.getSize ().x + getGtkBorderPadding ().right);
+ int newWidth = width - (down.getSizeInPixels ().x + getGtkBorderPadding ().right);
OS.gtk_widget_set_size_request (textEntryHandle, (newWidth >= 0) ? newWidth : 0, oldHeight);
}
@@ -1718,12 +1718,12 @@ public void setBounds (int x, int y, int width, int height) {
*/
int fixedGtkVersion = OS.VERSION (3, 14, 2);
if (isCalendar () && OS.GTK3 && (OS.GTK_VERSION < fixedGtkVersion)) {
- int calendarPrefferedVerticalSize = computeSize (SWT.DEFAULT, SWT.DEFAULT, true).y;
+ int calendarPrefferedVerticalSize = computeSizeInPixels (SWT.DEFAULT, SWT.DEFAULT, true).y;
if (height > calendarPrefferedVerticalSize) {
height = calendarPrefferedVerticalSize;
}
}
- super.setBounds (x, y, width, height);
+ super.setBoundsInPixels (x, y, width, height);
}
@@ -1731,10 +1731,10 @@ public void setBounds (int x, int y, int width, int height) {
* Usually called when control is resized or first initialized.
*/
private void setDropDownButtonSize () {
- Rectangle rect = getClientArea ();
+ Rectangle rect = getClientAreaInPixels ();
int parentWidth = rect.width;
int parentHeight = rect.height;
- Point buttonSize = down.computeSize (SWT.DEFAULT, parentHeight);
+ Point buttonSize = down.computeSizeInPixels (SWT.DEFAULT, parentHeight);
//TAG_GTK3__NO_VERTICAL_FILL_ADJUSTMENT
int dateEntryHeight = computeNativeSize (textEntryHandle, SWT.DEFAULT, SWT.DEFAULT, false).y;
@@ -1744,7 +1744,7 @@ private void setDropDownButtonSize () {
int newXpos = parentWidth - buttonSize.x;
int newYPos = parentHeight/2 - dateEntryHeight/2;
- down.setBounds (newXpos, newYPos, buttonSize.x, newHeight);
+ down.setBoundsInPixels (newXpos, newYPos, buttonSize.x, newHeight);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index 7dee6d79dd..eff7dfea0b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -1402,20 +1402,14 @@ public Shell getActiveShell () {
return activeShell;
}
-/**
- * Returns a rectangle describing the receiver's size and location. Note that
- * on multi-monitor systems the origin can be negative.
- *
- * @return the bounding rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
@Override
public Rectangle getBounds () {
checkDevice ();
+ return DPIUtil.autoScaleDown (getBoundsInPixels ());
+}
+
+Rectangle getBoundsInPixels () {
+ checkDevice ();
return new Rectangle (0, 0, OS.gdk_screen_width (), OS.gdk_screen_height ());
}
@@ -1579,6 +1573,10 @@ long /*int*/ filterProc (long /*int*/ xEvent, long /*int*/ gdkEvent, long /*int*
* </ul>
*/
public Point getCursorLocation () {
+ return DPIUtil.autoScaleDown(getCursorLocationInPixels());
+}
+
+Point getCursorLocationInPixels () {
checkDevice ();
int [] x = new int [1], y = new int [1];
gdk_window_get_device_position (0, x, y, null);
@@ -2025,7 +2023,7 @@ Rectangle getWorkArea() {
public Monitor [] getMonitors () {
checkDevice ();
Monitor [] monitors = null;
- Rectangle workArea = getWorkArea ();
+ Rectangle workArea = DPIUtil.autoScaleDown (getWorkArea ());
long /*int*/ screen = OS.gdk_screen_get_default ();
if (screen != 0) {
int monitorCount = OS.gdk_screen_get_n_monitors (screen);
@@ -2036,19 +2034,19 @@ public Monitor [] getMonitors () {
OS.gdk_screen_get_monitor_geometry (screen, i, dest);
Monitor monitor = new Monitor ();
monitor.handle = i;
- monitor.x = dest.x;
- monitor.y = dest.y;
- monitor.width = dest.width;
- monitor.height = dest.height;
+ monitor.x = DPIUtil.autoScaleDown (dest.x);
+ monitor.y = DPIUtil.autoScaleDown (dest.y);
+ monitor.width = DPIUtil.autoScaleDown (dest.width);
+ monitor.height = DPIUtil.autoScaleDown (dest.height);
if (OS.GTK_VERSION >= OS.VERSION (3, 4, 0)) {
// workarea was defined in GTK 3.4. If present, it will return the best results
// since it takes into account per-monitor trim
OS.gdk_screen_get_monitor_workarea (screen, i, dest);
- monitor.clientX = dest.x;
- monitor.clientY = dest.y;
- monitor.clientWidth = dest.width;
- monitor.clientHeight = dest.height;
+ monitor.clientX = DPIUtil.autoScaleDown (dest.x);
+ monitor.clientY = DPIUtil.autoScaleDown (dest.y);
+ monitor.clientWidth = DPIUtil.autoScaleDown (dest.width);
+ monitor.clientHeight = DPIUtil.autoScaleDown (dest.height);
} else {
// If we're on an older version of gtk without the workarea function, see if we can use
// the getWorkArea function. In the case of multi-monitors, this will return something that
@@ -3144,9 +3142,14 @@ boolean isValidThread () {
* @since 2.1.2
*/
public Point map (Control from, Control to, Point point) {
+ checkDevice();
+ return DPIUtil.autoScaleDown(mapInPixels(from, to, DPIUtil.autoScaleUp(point)));
+}
+
+Point mapInPixels (Control from, Control to, Point point) {
checkDevice ();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- return map (from, to, point.x, point.y);
+ return mapInPixels (from, to, point.x, point.y);
}
/**
@@ -3186,6 +3189,11 @@ public Point map (Control from, Control to, Point point) {
* @since 2.1.2
*/
public Point map (Control from, Control to, int x, int y) {
+ checkDevice();
+ return map(from, to, new Point(x, y));
+}
+
+Point mapInPixels (Control from, Control to, int x, int y) {
checkDevice ();
if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
@@ -3244,8 +3252,13 @@ public Point map (Control from, Control to, int x, int y) {
*/
public Rectangle map (Control from, Control to, Rectangle rectangle) {
checkDevice();
+ return DPIUtil.autoScaleDown(mapInPixels(from, to, DPIUtil.autoScaleUp(rectangle)));
+}
+
+Rectangle mapInPixels (Control from, Control to, Rectangle rectangle) {
+ checkDevice();
if (rectangle == null) error (SWT.ERROR_NULL_ARGUMENT);
- return map (from, to, rectangle.x, rectangle.y, rectangle.width, rectangle.height);
+ return mapInPixels (from, to, rectangle.x, rectangle.y, rectangle.width, rectangle.height);
}
static char mbcsToWcs (char ch) {
@@ -3311,6 +3324,11 @@ long /*int*/ menuPositionProc (long /*int*/ menu, long /*int*/ x, long /*int*/ y
*/
public Rectangle map (Control from, Control to, int x, int y, int width, int height) {
checkDevice();
+ return map(from, to, new Rectangle(x, y, width, height));
+}
+
+Rectangle mapInPixels (Control from, Control to, int x, int y, int width, int height) {
+ checkDevice();
if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
Rectangle rect = new Rectangle (x, y, width, height);
@@ -3445,7 +3463,8 @@ public boolean post (Event event) {
case SWT.MouseMove:
case SWT.MouseUp: {
if (type == SWT.MouseMove) {
- OS.XTestFakeMotionEvent (xDisplay, -1, event.x, event.y, 0);
+ Rectangle loc = DPIUtil.autoScaleUp(event.getBounds ());
+ OS.XTestFakeMotionEvent (xDisplay, -1, loc.x, loc.y, 0);
} else {
int button = event.button;
switch (button) {
@@ -4370,7 +4389,7 @@ void showIMWindow (Control control) {
widget.setFontDescription (preeditLabel, control.getFontDescription ());
if (pangoAttrs [0] != 0) OS.gtk_label_set_attributes (preeditLabel, pangoAttrs[0]);
OS.gtk_label_set_text (preeditLabel, preeditString [0]);
- Point point = control.toDisplay (control.getIMCaretPos ());
+ Point point = control.toDisplayInPixels (control.getIMCaretPos ());
OS.gtk_window_move (preeditWindow, point.x, point.y);
GtkRequisition requisition = new GtkRequisition ();
if (OS.GTK3) {
@@ -4892,4 +4911,23 @@ long /*int*/ gdk_device_get_window_at_position (int[] win_x, int[] win_y) {
}
}
+/**
+ * @noreference This method is not intended to be referenced by clients.
+ * @nooverride This method is not intended to be re-implemented or extended by clients.
+ */
+@Override
+protected long /*int*/ gsettingsProc (long /*int*/ gobject, long /*int*/ arg1, long /*int*/ user_data) {
+ switch((int)/*64*/user_data) {
+ case CHANGE_SCALEFACTOR:
+ this.scaleFactor = getDeviceZoom ();
+ DPIUtil.setDeviceZoom (scaleFactor);
+ Shell[] shells = getShells();
+ for (int i = 0; i < shells.length; i++) {
+ shells[i].layout(true, true);
+ }
+ }
+ return 0;
+}
+
+
}
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 1d11275f1b..33c693e127 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,6 +13,7 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
/**
@@ -115,7 +116,7 @@ protected void checkSubclass () {
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
Point size = computeNativeSize (handle, wHint, hHint, changed);
@@ -168,7 +169,7 @@ void createItem (ExpandItem item, int style, int index) {
System.arraycopy (items, index, items, index + 1, itemCount - index);
items [index] = item;
itemCount++;
- item.width = Math.max (0, getClientArea ().width - spacing * 2);
+ item.width = Math.max (0, getClientAreaInPixels ().width - spacing * 2);
layoutItems (index, true);
}
@@ -302,6 +303,11 @@ public ExpandItem [] getItems () {
*/
public int getSpacing () {
checkWidget ();
+ return DPIUtil.autoScaleDown(spacing);
+}
+
+int getSpacingInPixels () {
+ checkWidget ();
return spacing;
}
@@ -466,7 +472,7 @@ void setOrientation (boolean create) {
void setScrollbar () {
if (itemCount == 0) return;
if ((style & SWT.V_SCROLL) == 0) return;
- int height = getClientArea ().height;
+ int height = getClientAreaInPixels ().height;
ExpandItem item = items [itemCount - 1];
int maxHeight = item.y + getBandHeight () + spacing;
if (item.expanded) maxHeight += item.height;
@@ -518,6 +524,11 @@ void setScrollbar () {
*/
public void setSpacing (int spacing) {
checkWidget ();
+ setSpacingInPixels(DPIUtil.autoScaleUp(spacing));
+}
+
+void setSpacingInPixels (int spacing) {
+ checkWidget ();
if (spacing < 0) return;
if (spacing == this.spacing) return;
this.spacing = spacing;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java
index e67abedd6e..90fdeaea37 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -200,8 +200,8 @@ void drawChevron (GC gc, int x, int y) {
px+3,py+2, px+4,py+2, px+4,py+1, px+5,py+1, px+5,py, px+6,py};
}
gc.setForeground (display.getSystemColor (SWT.COLOR_TITLE_FOREGROUND));
- gc.drawPolyline (polyline1);
- gc.drawPolyline (polyline2);
+ gc.drawPolyline (DPIUtil.autoScaleDown(polyline1));
+ gc.drawPolyline (DPIUtil.autoScaleDown(polyline2));
}
void drawItem (GC gc, boolean drawFocus) {
@@ -283,11 +283,15 @@ public boolean getExpanded () {
*/
public int getHeaderHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown (getHeaderHeightInPixels ());
+}
+
+int getHeaderHeightInPixels () {
+ checkWidget ();
GtkAllocation allocation = new GtkAllocation ();
OS.gtk_widget_get_allocation (handle, allocation);
return allocation.height - (expanded ? height : 0);
}
-
/**
* Gets the height of the receiver.
*
@@ -300,6 +304,11 @@ public int getHeaderHeight () {
*/
public int getHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getHeightInPixels());
+}
+
+int getHeightInPixels () {
+ checkWidget ();
return height;
}
@@ -472,8 +481,8 @@ void setBounds (int x, int y, int width, int height, boolean move, boolean size)
redraw ();
}
if (control != null && !control.isDisposed ()) {
- if (move) control.setLocation (x + BORDER, y + headerHeight);
- if (size) control.setSize (Math.max (0, width - 2 * BORDER), Math.max (0, height - BORDER));
+ if (move) control.setLocationInPixels (x + BORDER, y + headerHeight);
+ if (size) control.setSizeInPixels (Math.max (0, width - 2 * BORDER), Math.max (0, height - BORDER));
}
}
@@ -574,6 +583,11 @@ void setForegroundColor (GdkColor color) {
*/
public void setHeight (int height) {
checkWidget ();
+ setHeightInPixels(DPIUtil.autoScaleUp(height));
+}
+
+void setHeightInPixels (int height) {
+ checkWidget ();
if (height < 0) return;
this.height = height;
OS.gtk_widget_set_size_request (clientHandle, -1, height);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
index 9eb61201cd..fb69dcd51b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -103,14 +103,14 @@ long /*int*/ clientHandle () {
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
- Point size = super.computeSize(wHint, hHint, changed);
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
+ Point size = super.computeSizeInPixels(wHint, hHint, changed);
int width = computeNativeSize (handle, SWT.DEFAULT, SWT.DEFAULT, false).x;
size.x = Math.max (size.x, width);
return size;
}
@Override
-public Rectangle computeTrim (int x, int y, int width, int height) {
+Rectangle computeTrimInPixels (int x, int y, int width, int height) {
checkWidget();
forceResize ();
GtkAllocation allocation = new GtkAllocation();
@@ -125,8 +125,8 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
}
@Override
-public Rectangle getClientArea () {
- Rectangle clientRectangle = super.getClientArea ();
+Rectangle getClientAreaInPixels () {
+ Rectangle clientRectangle = super.getClientAreaInPixels ();
/*
* Bug 453827 Child position fix.
* SWT's calls to gtk_widget_size_allocate and gtk_widget_set_allocation
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 e9dbbe8269..88fe1b178b 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -114,7 +114,7 @@ void addRelation (Control control) {
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
@@ -297,7 +297,7 @@ public int getAlignment () {
}
@Override
-public int getBorderWidth () {
+int getBorderWidthInPixels () {
checkWidget();
if (frameHandle != 0) {
return getThickness (frameHandle).x;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
index 5172fcf57a..d6c87c845a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
@@ -15,6 +15,7 @@ import org.eclipse.swt.*;
import org.eclipse.swt.accessibility.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
/**
@@ -115,7 +116,7 @@ public void addSelectionListener (SelectionListener listener) {
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
@@ -124,19 +125,19 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
//TEMPORARY CODE
if (wHint == 0) {
layout.setWidth (1);
- Rectangle rect = layout.getBounds ();
+ Rectangle rect = DPIUtil.autoScaleUp(layout.getBounds ());
width = 0;
height = rect.height;
} else {
layout.setWidth (wHint);
- Rectangle rect = layout.getBounds ();
+ Rectangle rect = DPIUtil.autoScaleUp(layout.getBounds ());
width = rect.width;
height = rect.height;
}
layout.setWidth (layoutWidth);
if (wHint != SWT.DEFAULT) width = wHint;
if (hHint != SWT.DEFAULT) height = hHint;
- int border = getBorderWidth ();
+ int border = getBorderWidthInPixels ();
width += border * 2;
height += border * 2;
return new Point (width, height);
@@ -217,7 +218,7 @@ void initAccessible () {
@Override
public void getLocation (AccessibleControlEvent e) {
- Rectangle rect = display.map (getParent (), null, getBounds ());
+ Rectangle rect = display.mapInPixels (getParent (), null, getBoundsInPixels ());
e.x = rect.x;
e.y = rect.y;
e.width = rect.width;
@@ -334,7 +335,7 @@ long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) {
int x = (int) gdkEvent.x;
int y = (int) gdkEvent.y;
if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - x;
- int offset = layout.getOffset (x, y, null);
+ int offset = DPIUtil.autoScaleUp(layout.getOffset (x, y, null));
int oldSelectionX = selection.x;
int oldSelectionY = selection.y;
selection.x = offset;
@@ -345,8 +346,8 @@ long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) {
oldSelectionX = oldSelectionY;
oldSelectionY = temp;
}
- Rectangle rect = layout.getBounds (oldSelectionX, oldSelectionY);
- redraw (rect.x, rect.y, rect.width, rect.height, false);
+ Rectangle rect = DPIUtil.autoScaleUp(layout.getBounds (oldSelectionX, oldSelectionY));
+ redrawInPixels (rect.x, rect.y, rect.width, rect.height, false);
}
for (int j = 0; j < offsets.length; j++) {
Rectangle [] rects = getRectangles (j);
@@ -458,7 +459,7 @@ long /*int*/ gtk_motion_notify_event (long /*int*/ widget, long /*int*/ event) {
if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - x;
if ((gdkEvent.state & OS.GDK_BUTTON1_MASK) != 0) {
int oldSelection = selection.y;
- selection.y = layout.getOffset (x, y, null);
+ selection.y = DPIUtil.autoScaleUp(layout.getOffset (x, y, null));
if (selection.y != oldSelection) {
int newSelection = selection.y;
if (oldSelection > newSelection) {
@@ -467,7 +468,7 @@ long /*int*/ gtk_motion_notify_event (long /*int*/ widget, long /*int*/ event) {
newSelection = temp;
}
Rectangle rect = layout.getBounds (oldSelection, newSelection);
- redraw (rect.x, rect.y, rect.width, rect.height, false);
+ redrawInPixels (rect.x, rect.y, rect.width, rect.height, false);
}
} else {
for (int j = 0; j < offsets.length; j++) {
@@ -716,7 +717,7 @@ int parseMnemonics (char[] buffer, int start, int end, StringBuffer result) {
int setBounds(int x, int y, int width, int height, boolean move, boolean resize) {
int result = super.setBounds (x, y, width,height, move, resize);
if ((result & RESIZED) != 0) {
- layout.setWidth (width > 0 ? width : -1);
+ layout.setWidth (DPIUtil.autoScaleDown((width > 0 ? width : -1)));
redraw ();
}
return result;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
index b7d2fc60a0..ae75d62637 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -252,7 +252,7 @@ int applyThemeBackground () {
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
@@ -265,7 +265,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
* based on the number of items in the table
*/
if (OS.GTK3 && size.y == 0 && hHint == SWT.DEFAULT) {
- size.y = getItemCount() * getItemHeight();
+ size.y = getItemCount() * getItemHeightInPixels();
}
/*
@@ -274,7 +274,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
* so need to assign default height
*/
if (size.y == 0 && hHint == SWT.DEFAULT) size.y = DEFAULT_HEIGHT;
- Rectangle trim = computeTrim (0, 0, size.x, size.y);
+ Rectangle trim = computeTrimInPixels (0, 0, size.x, size.y);
size.x = trim.width;
size.y = trim.height;
return size;
@@ -527,6 +527,11 @@ public int getItemCount () {
*/
public int getItemHeight () {
checkWidget();
+ return DPIUtil.autoScaleDown(getItemHeightInPixels());
+}
+
+int getItemHeightInPixels () {
+ checkWidget();
int itemCount = OS.gtk_tree_model_iter_n_children (modelHandle, 0);
long /*int*/ column = OS.gtk_tree_view_get_column (handle, 0);
if (itemCount == 0) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
index 458c2e27a6..c1ac0aafbc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -1012,6 +1012,11 @@ public void setEnabled (boolean enabled) {
* </ul>
*/
public void setLocation (int x, int y) {
+ checkWidget ();
+ setLocation (new Point (x, y));
+}
+
+void setLocationInPixels (int x, int y) {
checkWidget();
if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
this.x = x;
@@ -1044,9 +1049,14 @@ public void setLocation (int x, int y) {
* @since 2.1
*/
public void setLocation (Point location) {
+ checkWidget ();
+ setLocationInPixels (DPIUtil.autoScaleUp (location));
+}
+
+void setLocationInPixels (Point location) {
checkWidget();
if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
- setLocation (location.x, location.y);
+ setLocationInPixels (location.x, location.y);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
index 58406f749a..e3f783127c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,6 +14,7 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
/**
@@ -120,11 +121,11 @@ static int checkStyle (int style) {
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
- int border = getBorderWidth ();
+ int border = getBorderWidthInPixels ();
int width = border * 2, height = border * 2;
if ((style & SWT.HORIZONTAL) != 0) {
width += DEFAULT_WIDTH; height += 3;
@@ -192,25 +193,24 @@ long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ eventPtr)
lastY = y;
Event event = new Event ();
event.time = gdkEvent.time;
- event.x = lastX;
- event.y = lastY;
- event.width = width;
- event.height = height;
+ Rectangle eventRect = new Rectangle (lastX, lastY, width, height);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
if ((style & SWT.SMOOTH) == 0) {
event.detail = SWT.DRAG;
}
- if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth () - width - event.x;
+ if ((parent.style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (parent.getClientWidth () - width) - event.x;
sendSelectionEvent (SWT.Selection, event, true);
if (isDisposed ()) return 0;
if (event.doit) {
dragging = true;
- lastX = event.x;
- lastY = event.y;
- if ((parent.style & SWT.MIRRORED) != 0) lastX = parent.getClientWidth () - width - lastX;
+ Rectangle rect = DPIUtil.autoScaleUp (event.getBounds ());
+ lastX = rect.x;
+ lastY = rect.y;
+ if ((parent.style & SWT.MIRRORED) != 0) lastX = parent.getClientWidth () - width - lastX;
parent.update (true, (style & SWT.SMOOTH) == 0);
- drawBand (lastX, event.y, width, height);
+ drawBand (lastX, rect.y, width, height);
if ((style & SWT.SMOOTH) != 0) {
- setBounds (event.x, event.y, width, height);
+ setBoundsInPixels (rect.x, rect.y, width, height);
// widget could be disposed at this point
}
}
@@ -233,17 +233,16 @@ long /*int*/ gtk_button_release_event (long /*int*/ widget, long /*int*/ eventPt
int height = allocation.height;
Event event = new Event ();
event.time = gdkEvent.time;
- event.x = lastX;
- event.y = lastY;
- event.width = width;
- event.height = height;
+ Rectangle eventRect = new Rectangle (lastX, lastY, width, height);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
drawBand (lastX, lastY, width, height);
- if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth () - width - event.x;
+ if ((parent.style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (parent.getClientWidth () - width) - event.x;
sendSelectionEvent (SWT.Selection, event, true);
if (isDisposed ()) return result;
if (event.doit) {
if ((style & SWT.SMOOTH) != 0) {
- setBounds (event.x, event.y, width, height);
+ Rectangle rect = DPIUtil.autoScaleUp (event.getBounds ());
+ setBoundsInPixels (rect.x, rect.y, width, height);
// widget could be disposed at this point
}
}
@@ -326,30 +325,29 @@ long /*int*/ gtk_key_press_event (long /*int*/ widget, long /*int*/ eventPtr) {
/* The event must be sent because its doit flag is used. */
Event event = new Event ();
event.time = gdkEvent.time;
- event.x = newX;
- event.y = newY;
- event.width = width;
- event.height = height;
- if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth () - width - event.x;
+ Rectangle eventRect = new Rectangle (newX, newY, width, height);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
+ if ((parent.style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (parent.getClientWidth () - width) - event.x;
sendSelectionEvent (SWT.Selection, event, true);
if (ptrGrabResult == OS.GDK_GRAB_SUCCESS) gdk_pointer_ungrab (window, OS.GDK_CURRENT_TIME);
if (isDisposed ()) break;
if (event.doit) {
- lastX = event.x;
- lastY = event.y;
+ Rectangle rect = DPIUtil.autoScaleUp (event.getBounds ());
+ lastX = rect.x;
+ lastY = rect.y;
if ((parent.style & SWT.MIRRORED) != 0) lastX = parent.getClientWidth () - width - lastX;
if ((style & SWT.SMOOTH) != 0) {
- setBounds (event.x, event.y, width, height);
+ setBoundsInPixels (rect.x, rect.y, width, height);
if (isDisposed ()) break;
}
- int cursorX = event.x, cursorY = event.y;
+ int cursorX = rect.x, cursorY = rect.y;
if ((style & SWT.VERTICAL) != 0) {
cursorY += height / 2;
} else {
cursorX += width / 2;
}
- display.setCursorLocation (parent.toDisplay (cursorX, cursorY));
+ display.setCursorLocation (parent.toDisplayInPixels (cursorX, cursorY));
}
break;
}
@@ -400,25 +398,24 @@ long /*int*/ gtk_motion_notify_event (long /*int*/ widget, long /*int*/ eventPtr
Event event = new Event ();
event.time = gdkEvent.time;
- event.x = newX;
- event.y = newY;
- event.width = width;
- event.height = height;
+ Rectangle eventRect = new Rectangle (newX, newY, width, height);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
if ((style & SWT.SMOOTH) == 0) {
event.detail = SWT.DRAG;
}
- if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth() - width - event.x;
+ if ((parent.style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (parent.getClientWidth () - width) - event.x;
sendSelectionEvent (SWT.Selection, event, true);
if (isDisposed ()) return 0;
+ Rectangle rect = DPIUtil.autoScaleUp (event.getBounds ());
if (event.doit) {
- lastX = event.x;
- lastY = event.y;
+ lastX = rect.x;
+ lastY = rect.y;
if ((parent.style & SWT.MIRRORED) != 0) lastX = parent.getClientWidth () - width - lastX;
}
parent.update (true, (style & SWT.SMOOTH) == 0);
drawBand (lastX, lastY, width, height);
if ((style & SWT.SMOOTH) != 0) {
- setBounds (event.x, lastY, width, height);
+ setBoundsInPixels (rect.x, lastY, width, height);
// widget could be disposed at this point
}
return result;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java
index 464bb490d8..d1d7b88b05 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -109,7 +109,7 @@ static int checkStyle (int style) {
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
index 015b969800..3adbce1540 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,6 +14,7 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
/**
@@ -276,6 +277,7 @@ public int getSelection () {
return (int) OS.gtk_adjustment_get_value (adjustmentHandle);
}
+
/**
* Returns a point describing the receiver's size. The
* x coordinate of the result is the width of the receiver.
@@ -291,6 +293,11 @@ public int getSelection () {
*/
public Point getSize () {
checkWidget ();
+ return DPIUtil.autoScaleDown (getSizeInPixels ());
+}
+
+Point getSizeInPixels () {
+ checkWidget ();
if (handle == 0) return new Point (0,0);
GtkRequisition requisition = new GtkRequisition ();
gtk_widget_get_preferred_size (handle, requisition);
@@ -328,6 +335,11 @@ public int getThumb () {
* @since 3.6
*/
public Rectangle getThumbBounds () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown(getThumbBoundsInPixels());
+}
+
+Rectangle getThumbBoundsInPixels () {
checkWidget();
int [] slider_start = new int [1], slider_end = new int [1];
gtk_range_get_slider_range (handle, slider_start, slider_end);
@@ -373,6 +385,11 @@ public Rectangle getThumbBounds () {
* @since 3.6
*/
public Rectangle getThumbTrackBounds () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown(getThumbTrackBoundsInPixels());
+}
+
+Rectangle getThumbTrackBoundsInPixels () {
checkWidget();
int x = 0, y = 0, width, height;
int[] has_stepper = new int[1];
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 c336798959..caca280db8 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,6 +13,7 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
/**
@@ -107,6 +108,12 @@ long /*int*/ clientHandle () {
*/
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget();
+ Rectangle rect = DPIUtil.autoScaleUp(new Rectangle (x, y, width, height));
+ return DPIUtil.autoScaleDown(computeTrimInPixels(rect.x, rect.y, rect.width, rect.height));
+}
+
+Rectangle computeTrimInPixels (int x, int y, int width, int height) {
+ checkWidget();
int border = 0;
if (fixedHandle != 0) border += OS.gtk_container_get_border_width (fixedHandle);
if (scrolledHandle != 0) border += OS.gtk_container_get_border_width (scrolledHandle);
@@ -189,7 +196,7 @@ void destroyScrollBar (ScrollBar bar) {
}
@Override
-public int getBorderWidth () {
+int getBorderWidthInPixels () {
checkWidget();
int border = 0;
if (fixedHandle != 0) border += OS.gtk_container_get_border_width (fixedHandle);
@@ -201,7 +208,6 @@ public int getBorderWidth () {
}
return border;
}
-
/**
* Returns a rectangle which describes the area of the
* receiver which is capable of displaying data (that is,
@@ -218,6 +224,11 @@ public int getBorderWidth () {
*/
public Rectangle getClientArea () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getClientAreaInPixels());
+}
+
+Rectangle getClientAreaInPixels () {
+ checkWidget ();
forceResize ();
long /*int*/ clientHandle = clientHandle ();
GtkAllocation allocation = new GtkAllocation ();
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 0a5f9fee5d..a8abd17b28 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -600,8 +600,8 @@ void bringToTop (boolean force) {
void center () {
if (parent == null) return;
- Rectangle rect = getBounds ();
- Rectangle parentRect = display.map (parent, null, parent.getClientArea());
+ Rectangle rect = getBoundsInPixels ();
+ Rectangle parentRect = display.mapInPixels (parent, null, parent.getClientAreaInPixels());
int x = Math.max (parentRect.x, parentRect.x + (parentRect.width - rect.width) / 2);
int y = Math.max (parentRect.y, parentRect.y + (parentRect.height - rect.height) / 2);
Rectangle monitorRect = parent.getMonitor ().getClientArea();
@@ -615,7 +615,7 @@ void center () {
} else {
y = Math.max (y, monitorRect.y);
}
- setLocation (x, y);
+ setLocationInPixels (x, y);
}
@Override
@@ -659,9 +659,9 @@ void closeWidget () {
}
@Override
-public Rectangle computeTrim (int x, int y, int width, int height) {
+Rectangle computeTrimInPixels (int x, int y, int width, int height) {
checkWidget();
- Rectangle trim = super.computeTrim (x, y, width, height);
+ Rectangle trim = super.computeTrimInPixels (x, y, width, height);
int border = 0;
if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0) {
border = OS.gtk_container_get_border_width (shellHandle);
@@ -1053,7 +1053,7 @@ public boolean getFullScreen () {
}
@Override
-public Point getLocation () {
+Point getLocationInPixels () {
checkWidget ();
int [] x = new int [1], y = new int [1];
OS.gtk_window_get_position (shellHandle, x,y);
@@ -1079,10 +1079,15 @@ public boolean getMaximized () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
- * @since 3.1
+ * @since 3.105
*/
public Point getMinimumSize () {
checkWidget ();
+ return DPIUtil.autoScaleDown (getMinimumSizeInPixels ());
+}
+
+Point getMinimumSizeInPixels () {
+ checkWidget ();
int width = Math.max (1, minWidth + trimWidth ());
int height = Math.max (1, minHeight + trimHeight ());
return new Point (width, height);
@@ -1134,7 +1139,7 @@ public boolean getModified () {
}
@Override
-public Point getSize () {
+Point getSizeInPixels () {
checkWidget ();
GtkAllocation allocation = new GtkAllocation ();
OS.gtk_widget_get_allocation (vboxHandle, allocation);
@@ -1869,7 +1874,7 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
* anything different from the current bounds.
*/
if (getMaximized ()) {
- Rectangle rect = getBounds ();
+ Rectangle rect = getBoundsInPixels ();
boolean sameOrigin = !move || (rect.x == x && rect.y == y);
boolean sameExtent = !resize || (rect.width == width && rect.height == height);
if (sameOrigin && sameExtent) return 0;
@@ -1950,7 +1955,7 @@ public void setEnabled (boolean enabled) {
long /*int*/ parentHandle = shellHandle;
OS.gtk_widget_realize (parentHandle);
long /*int*/ window = gtk_widget_get_window (parentHandle);
- Rectangle rect = getBounds ();
+ Rectangle rect = getBoundsInPixels ();
GdkWindowAttr attributes = new GdkWindowAttr ();
attributes.width = rect.width;
attributes.height = rect.height;
@@ -2138,6 +2143,11 @@ public void setMinimized (boolean minimized) {
*/
public void setMinimumSize (int width, int height) {
checkWidget ();
+ setMinimumSize (new Point (width, height));
+}
+
+void setMinimumSizeInPixels (int width, int height) {
+ checkWidget ();
GdkGeometry geometry = new GdkGeometry ();
minWidth = geometry.min_width = Math.max (width, trimWidth ()) - trimWidth ();
minHeight = geometry.min_height = Math.max (height, trimHeight ()) - trimHeight ();
@@ -2163,8 +2173,13 @@ public void setMinimumSize (int width, int height) {
*/
public void setMinimumSize (Point size) {
checkWidget ();
+ setMinimumSizeInPixels (DPIUtil.autoScaleUp (size));
+}
+
+void setMinimumSizeInPixels (Point size) {
+ checkWidget ();
if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
- setMinimumSize (size.x, size.y);
+ setMinimumSizeInPixels (size.x, size.y);
}
/**
@@ -2254,7 +2269,7 @@ static Region mirrorRegion (Region region) {
int [] nRects = new int [1];
long /*int*/ [] rects = new long /*int*/ [1];
gdk_region_get_rectangles (rgn, rects, nRects);
- Rectangle bounds = region.getBounds ();
+ Rectangle bounds = DPIUtil.autoScaleUp(region.getBounds ());
GdkRectangle rect = new GdkRectangle ();
for (int i = 0; i < nRects [0]; i++) {
OS.memmove (rect, rects[0] + (i * GdkRectangle.sizeof), GdkRectangle.sizeof);
@@ -2296,7 +2311,7 @@ public void setVisible (boolean visible) {
checkWidget();
if (moved) { //fix shell location if it was moved.
- setLocation(oldX, oldY);
+ setLocationInPixels(oldX, oldY);
}
int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
if ((style & mask) != 0) {
@@ -2377,7 +2392,7 @@ public void setVisible (boolean visible) {
opened = true;
if (!moved) {
moved = true;
- Point location = getLocation();
+ Point location = getLocationInPixels();
oldX = location.x;
oldY = location.y;
sendEvent (SWT.Move);
@@ -2385,7 +2400,7 @@ public void setVisible (boolean visible) {
}
if (!resized) {
resized = true;
- Point size = getSize ();
+ Point size = getSizeInPixels ();
oldWidth = size.x - trimWidth ();
oldHeight = size.y - trimHeight ();
sendEvent (SWT.Resize);
@@ -2654,7 +2669,7 @@ public void forceActive () {
}
@Override
-public Rectangle getBounds () {
+Rectangle getBoundsInPixels () {
checkWidget ();
int [] x = new int [1], y = new int [1];
OS.gtk_window_get_position (shellHandle, x, y);
@@ -2751,7 +2766,7 @@ Point getWindowOrigin () {
* window trims etc. from the window manager. That's why getLocation ()
* is not safe to use for coordinate mappings after the shell has been made visible.
*/
- return getLocation ();
+ return getLocationInPixels ();
}
return super.getWindowOrigin( );
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java
index 3089ecd965..a3d8fd638e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -264,7 +264,7 @@ void deregister () {
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget();
OS.gtk_widget_realize(handle);
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java
index 6f3b1614da..4ad4a572d2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -204,7 +204,7 @@ protected void checkSubclass () {
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
@@ -247,15 +247,15 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
width = wHint == SWT.DEFAULT ? w [0] : wHint;
height = hHint == SWT.DEFAULT ? h [0] : hHint;
}
- Rectangle trim = computeTrim (0, 0, width, height);
+ Rectangle trim = computeTrimInPixels (0, 0, width, height);
return new Point (trim.width, trim.height);
}
@Override
-public Rectangle computeTrim (int x, int y, int width, int height) {
+Rectangle computeTrimInPixels (int x, int y, int width, int height) {
checkWidget ();
int xborder = 0, yborder = 0;
- Rectangle trim = super.computeTrim (x, y, width, height);
+ Rectangle trim = super.computeTrimInPixels (x, y, width, height);
if (OS.GTK3) {
GtkBorder tmp = new GtkBorder();
long /*int*/ context = OS.gtk_widget_get_style_context (handle);
@@ -420,7 +420,7 @@ GdkColor getBackgroundColor () {
}
@Override
-public int getBorderWidth () {
+int getBorderWidthInPixels () {
checkWidget();
if ((this.style & SWT.BORDER) != 0) {
return getThickness (handle).x;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
index 00e157cf6b..b30e9a6337 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -189,9 +189,9 @@ long /*int*/ clientHandle () {
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
- Point size = super.computeSize (wHint, hHint, changed);
+ Point size = super.computeSizeInPixels (wHint, hHint, changed);
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
boolean scrollable = OS.gtk_notebook_get_scrollable (handle);
@@ -209,7 +209,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
}
@Override
-public Rectangle computeTrim (int x, int y, int width, int height) {
+Rectangle computeTrimInPixels (int x, int y, int width, int height) {
checkWidget();
forceResize ();
long /*int*/ clientHandle = clientHandle ();
@@ -232,8 +232,8 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
}
@Override
-public Rectangle getClientArea () {
- Rectangle clientRectangle = super.getClientArea ();
+Rectangle getClientAreaInPixels () {
+ Rectangle clientRectangle = super.getClientAreaInPixels ();
if (OS.GTK3) {
/*
@@ -352,7 +352,7 @@ void destroyItem (TabItem item) {
if (newIndex != -1) {
Control control = items [newIndex].getControl ();
if (control != null && !control.isDisposed ()) {
- control.setBounds (getClientArea());
+ control.setBoundsInPixels (getClientAreaInPixels());
control.setVisible (true);
}
Event event = new Event ();
@@ -571,7 +571,7 @@ long /*int*/ gtk_switch_page (long /*int*/ widget, long /*int*/ page, long /*int
TabItem item = items [(int)/*64*/page_num];
Control control = item.getControl ();
if (control != null && !control.isDisposed ()) {
- control.setBounds(getClientArea());
+ control.setBoundsInPixels(getClientAreaInPixels());
control.setVisible (true);
}
Event event = new Event();
@@ -634,11 +634,11 @@ Point minimumSize (int wHint, int hHint, boolean flushCache) {
index++;
}
if (index == count) {
- Rectangle rect = child.getBounds ();
+ Rectangle rect = child.getBoundsInPixels ();
width = Math.max (width, rect.x + rect.width);
height = Math.max (height, rect.y + rect.height);
} else {
- Point size = child.computeSize (wHint, hHint, flushCache);
+ Point size = child.computeSizeInPixels (wHint, hHint, flushCache);
width = Math.max (width, size.x);
height = Math.max (height, size.y);
}
@@ -747,7 +747,7 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
TabItem item = items [index];
Control control = item.control;
if (control != null && !control.isDisposed ()) {
- control.setBounds (getClientArea ());
+ control.setBoundsInPixels (getClientAreaInPixels ());
}
}
}
@@ -824,7 +824,7 @@ void setSelection (int index, boolean notify) {
TabItem item = items [newIndex];
Control control = item.control;
if (control != null && !control.isDisposed ()) {
- control.setBounds (getClientArea ());
+ control.setBoundsInPixels (getClientAreaInPixels ());
control.setVisible (true);
}
if (notify) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
index 90e28ee79f..19feb362c2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -153,6 +153,11 @@ void destroyWidget () {
* @since 3.4
*/
public Rectangle getBounds () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown (getBoundsInPixels ());
+}
+
+Rectangle getBoundsInPixels () {
checkWidget();
GtkAllocation allocation = new GtkAllocation ();
OS.gtk_widget_get_allocation (handle, allocation);
@@ -306,7 +311,7 @@ public void setControl (Control control) {
}
}
if (newControl != null) {
- newControl.setBounds (parent.getClientArea ());
+ newControl.setBoundsInPixels (parent.getClientAreaInPixels ());
newControl.setVisible (true);
}
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 991d93094f..3b6d8693c1 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
@@ -486,7 +486,7 @@ public void clearAll () {
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
@@ -499,7 +499,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
* the number of items in the table.
*/
if (OS.GTK3 && hHint == SWT.DEFAULT && size.y == getHeaderHeight()) {
- size.y = getItemCount() * getItemHeight() + getHeaderHeight();
+ size.y = getItemCount() * getItemHeightInPixels() + getHeaderHeight();
}
/*
@@ -508,7 +508,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
* so need to assign default height
*/
if (size.y == 0 && hHint == SWT.DEFAULT) size.y = DEFAULT_HEIGHT;
- Rectangle trim = computeTrim (0, 0, size.x, size.y);
+ Rectangle trim = computeTrimInPixels (0, 0, size.x, size.y);
size.x = trim.width;
size.y = trim.height;
return size;
@@ -1153,7 +1153,7 @@ GdkColor getBackgroundColor () {
}
@Override
-public Rectangle getClientArea () {
+Rectangle getClientAreaInPixels () {
checkWidget ();
forceResize ();
OS.gtk_widget_realize (handle);
@@ -1170,7 +1170,7 @@ public Rectangle getClientArea () {
int height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
Rectangle rect = new Rectangle (fixedX [0] - binX [0], fixedY [0] - binY [0], width, height);
if (getHeaderVisible() && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) {
- rect.y += getHeaderHeight();
+ rect.y += getHeaderHeightInPixels();
}
return rect;
}
@@ -1386,6 +1386,11 @@ GdkColor getForegroundColor () {
* </ul>
*/
public int getGridLineWidth () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown (getGridLineWidthInPixels ());
+}
+
+int getGridLineWidthInPixels () {
checkWidget();
return 0;
}
@@ -1404,6 +1409,11 @@ public int getGridLineWidth () {
*/
public int getHeaderHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown (getHeaderHeightInPixels ());
+}
+
+int getHeaderHeightInPixels () {
+ checkWidget ();
if (!OS.gtk_tree_view_get_headers_visible (handle)) return 0;
if (columnCount > 0) {
GtkRequisition requisition = new GtkRequisition ();
@@ -1495,12 +1505,17 @@ public TableItem getItem (int index) {
*/
public TableItem getItem (Point point) {
checkWidget();
+ return getItemInPixels(DPIUtil.autoScaleUp(point));
+}
+
+TableItem getItemInPixels (Point point) {
+ checkWidget();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
long /*int*/ [] path = new long /*int*/ [1];
OS.gtk_widget_realize (handle);
int y = point.y;
if (getHeaderVisible() && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) {
- y -= getHeaderHeight();
+ y -= getHeaderHeightInPixels();
}
if (!OS.gtk_tree_view_get_path_at_pos (handle, point.x, y, path, null, null, null)) return null;
if (path [0] == 0) return null;
@@ -1542,6 +1557,11 @@ public int getItemCount () {
* </ul>
*/
public int getItemHeight () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown (getItemHeightInPixels ());
+}
+
+int getItemHeightInPixels () {
checkWidget();
if (itemCount == 0) {
long /*int*/ column = OS.gtk_tree_view_get_column (handle, 0);
@@ -2609,7 +2629,7 @@ void sendMeasureEvent (long /*int*/ cell, long /*int*/ width, long /*int*/ heigh
Image image = item.getImage (columnIndex);
int imageWidth = 0;
if (image != null) {
- Rectangle bounds = image.getBounds ();
+ Rectangle bounds = image.getBoundsInPixels ();
imageWidth = bounds.width;
}
contentWidth [0] += imageWidth;
@@ -2619,13 +2639,14 @@ void sendMeasureEvent (long /*int*/ cell, long /*int*/ width, long /*int*/ heigh
event.item = item;
event.index = columnIndex;
event.gc = gc;
- event.width = contentWidth [0];
- event.height = contentHeight [0];
+ Rectangle eventRect = new Rectangle (0, 0, contentWidth [0], contentHeight [0]);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
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;
+ Rectangle rect = DPIUtil.autoScaleUp (event.getBounds ());
+ contentWidth [0] = rect.width - imageWidth;
+ if (contentHeight [0] < rect.height) contentHeight [0] = rect.height;
if (width != 0) OS.memmove (width, contentWidth, 4);
if (height != 0) OS.memmove (height, contentHeight, 4);
if (OS.GTK3) {
@@ -2772,22 +2793,26 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo
if (OS.GTK_VERSION >= OS.VERSION(3, 9, 0) && cr != 0) {
GdkRectangle r = new GdkRectangle();
OS.gdk_cairo_get_clip_rectangle(cr, r);
- gc.setClipping(rect.x, r.y, r.width, r.height);
+ Rectangle rect2 = DPIUtil.autoScaleDown(new Rectangle(rect.x, r.y, r.width, r.height));
+ // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075
+ gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height);
+
if (OS.GTK_VERSION <= OS.VERSION(3, 14, 8)) {
rect.width = r.width;
}
} else {
- gc.setClipping (rect.x, rect.y, rect.width, rect.height);
+ Rectangle rect2 = DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height));
+ // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075
+ gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height);
+
}
Event event = new Event ();
event.item = item;
event.index = columnIndex;
event.gc = gc;
- event.x = rect.x;
- event.y = rect.y;
- event.width = rect.width;
- event.height = rect.height;
event.detail = drawState;
+ Rectangle eventRect = new Rectangle (rect.x, rect.y, rect.width, rect.height);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
sendEvent (SWT.EraseItem, event);
drawForeground = null;
drawState = event.doit ? event.detail : 0;
@@ -2823,7 +2848,7 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo
gc.setBackground (item.getBackground (columnIndex));
GdkRectangle rect = new GdkRectangle ();
OS.memmove (rect, background_area, GdkRectangle.sizeof);
- gc.fillRectangle (rect.x, rect.y, rect.width, rect.height);
+ gc.fillRectangle(DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height)));
gc.dispose ();
}
if ((drawState & SWT.FOREGROUND) != 0 || OS.GTK_IS_CELL_RENDERER_TOGGLE (cell)) {
@@ -2861,7 +2886,7 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo
Image image = item.getImage (columnIndex);
int imageWidth = 0;
if (image != null) {
- Rectangle bounds = image.getBounds ();
+ Rectangle bounds = image.getBoundsInPixels ();
imageWidth = bounds.width;
}
// On gtk >3.9 and <3.14.8 the clip rectangle does not have image area into clip rectangle
@@ -2896,15 +2921,17 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo
}
gc.setFont (item.getFont (columnIndex));
if ((style & SWT.MIRRORED) != 0) rect.x = getClientWidth () - rect.width - rect.x;
- gc.setClipping (rect.x, rect.y, rect.width, rect.height);
+
+ Rectangle rect2 = DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height));
+ // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075
+ gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height);
+
Event event = new Event ();
event.item = item;
event.index = columnIndex;
event.gc = gc;
- event.x = rect.x + contentX [0];
- event.y = rect.y;
- event.width = contentWidth [0];
- event.height = rect.height;
+ Rectangle eventRect = new Rectangle (rect.x + contentX [0], rect.y, contentWidth [0], rect.height);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
event.detail = drawState;
sendEvent (SWT.PaintItem, event);
gc.dispose();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
index 47ab2110cd..9c80d2caaf 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,10 +12,10 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
/**
* Instances of this class represent a column in a table widget.
@@ -320,6 +320,11 @@ public String getToolTipText () {
* </ul>
*/
public int getWidth () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown(getWidthInPixels());
+}
+
+int getWidthInPixels () {
checkWidget();
if (!OS.gtk_tree_view_column_get_visible (handle)) {
return 0;
@@ -447,7 +452,7 @@ public void pack () {
}
OS.g_free (iter);
}
- setWidth(width);
+ setWidthInPixels(width);
}
@Override
@@ -689,6 +694,11 @@ void setToolTipText (Shell shell, String newString) {
* </ul>
*/
public void setWidth (int width) {
+ checkWidget ();
+ setWidthInPixels (DPIUtil.autoScaleUp (width));
+}
+
+void setWidthInPixels (int width) {
checkWidget();
if (width < 0) return;
if (width == lastWidth) return;
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 192f0e70e3..51db5f90b5 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -267,6 +267,23 @@ public Color getBackground () {
* @since 3.2
*/
public Rectangle getBounds () {
+ return DPIUtil.autoScaleDown (getBoundsinPixels ());
+}
+
+/**
+ * Returns a rectangle describing the size and location of the receiver's
+ * text relative to its parent.
+ *
+ * @return the bounding rectangle of the receiver's text
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.105
+ */
+Rectangle getBoundsinPixels () {
// TODO fully test on early and later versions of GTK
// shifted a bit too far right on later versions of GTK - however, old Tree also had this problem
checkWidget ();
@@ -316,7 +333,7 @@ public Rectangle getBounds () {
int width = OS.gtk_tree_view_column_get_visible (column) ? rect.width + 1 : 0;
Rectangle r = new Rectangle (rect.x, rect.y, width, rect.height + 1);
if (parent.getHeaderVisible() && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) {
- r.y += parent.getHeaderHeight();
+ r.y += parent.getHeaderHeightInPixels();
}
return r;
}
@@ -353,6 +370,11 @@ public Color getBackground (int index) {
* </ul>
*/
public Rectangle getBounds (int index) {
+ checkWidget ();
+ return DPIUtil.autoScaleDown (getBoundsInPixels (index));
+}
+
+Rectangle getBoundsInPixels (int index) {
checkWidget();
if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
long /*int*/ parentHandle = parent.handle;
@@ -379,7 +401,7 @@ public Rectangle getBounds (int index) {
int width = OS.gtk_tree_view_column_get_visible (column) ? rect.width + 1 : 0;
Rectangle r = new Rectangle (rect.x, rect.y, width, rect.height + 1);
if (parent.getHeaderVisible() && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) {
- r.y += parent.getHeaderHeight();
+ r.y += parent.getHeaderHeightInPixels();
}
return r;
}
@@ -542,6 +564,11 @@ public Image getImage (int index) {
*/
public Rectangle getImageBounds (int index) {
checkWidget ();
+ return DPIUtil.autoScaleDown (getImageBoundsInPixels (index));
+}
+
+Rectangle getImageBoundsInPixels (int index) {
+ checkWidget ();
if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
long /*int*/ parentHandle = parent.handle;
long /*int*/ column = 0;
@@ -676,6 +703,11 @@ public String getText (int index) {
*/
public Rectangle getTextBounds (int index) {
checkWidget ();
+ return DPIUtil.autoScaleDown (getTextBoundsInPixels (index));
+}
+
+Rectangle getTextBoundsInPixels (int index) {
+ checkWidget ();
if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
int count = Math.max (1, parent.getColumnCount ());
if (0 > index || index > count - 1) return new Rectangle (0, 0, 0, 0);
@@ -731,7 +763,7 @@ public Rectangle getTextBounds (int index) {
Image image = _getImage(index);
int imageWidth = 0;
if (image != null) {
- imageWidth = image.getBounds ().width;
+ imageWidth = image.getBoundsInPixels ().width;
}
if (x [0] < imageWidth) {
rect.x += imageWidth;
@@ -1134,8 +1166,8 @@ public void setImage (int index, Image image) {
OS.gtk_cell_renderer_get_fixed_size (pixbufRenderer, currentWidth, currentHeight);
if (!parent.pixbufSizeSet) {
if (image != null) {
- int iWidth = image.getBounds ().width;
- int iHeight = image.getBounds ().height;
+ int iWidth = image.getBoundsInPixels ().width;
+ int iHeight = image.getBoundsInPixels ().height;
if (iWidth > currentWidth [0] || iHeight > currentHeight [0]) {
OS.gtk_cell_renderer_set_fixed_size (pixbufRenderer, iWidth, iHeight);
parent.pixbufSizeSet = true;
@@ -1167,7 +1199,7 @@ public void setImage (int index, Image image) {
int [] w = new int [1];
long /*int*/ pixbufRenderer = parent.getPixbufRenderer(column);
OS.gtk_tree_view_column_cell_get_position (column, pixbufRenderer, null, w);
- if (w[0] < image.getBounds().width) {
+ if (w[0] < image.getBoundsInPixels().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
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 a2ee2e1312..4a8f500525 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -549,7 +549,7 @@ public void clearSelection () {
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
@@ -582,14 +582,14 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
if (height == 0) height = DEFAULT_HEIGHT;
width = wHint == SWT.DEFAULT ? width : wHint;
height = hHint == SWT.DEFAULT ? height : hHint;
- Rectangle trim = computeTrim (0, 0, width, height);
+ Rectangle trim = computeTrimInPixels (0, 0, width, height);
return new Point (trim.width, trim.height);
}
@Override
-public Rectangle computeTrim (int x, int y, int width, int height) {
+Rectangle computeTrimInPixels (int x, int y, int width, int height) {
checkWidget ();
- Rectangle trim = super.computeTrim (x, y, width, height);
+ Rectangle trim = super.computeTrimInPixels (x, y, width, height);
int xborder = 0, yborder = 0;
if ((style & SWT.SINGLE) != 0) {
if (OS.GTK3) {
@@ -833,9 +833,9 @@ GdkColor getBackgroundColor () {
}
@Override
-public int getBorderWidth () {
+int getBorderWidthInPixels () {
checkWidget();
- if ((style & SWT.MULTI) != 0) return super.getBorderWidth ();
+ if ((style & SWT.MULTI) != 0) return super.getBorderWidthInPixels ();
if ((this.style & SWT.BORDER) != 0) {
return getThickness (handle).x;
}
@@ -877,6 +877,11 @@ public int getCaretLineNumber () {
*/
public Point getCaretLocation () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getCaretLocationInPixels());
+}
+
+Point getCaretLocationInPixels () {
+ checkWidget ();
if ((style & SWT.SINGLE) != 0) {
int index = OS.gtk_editable_get_position (handle);
index = OS.gtk_entry_text_index_to_layout_index (handle, index);
@@ -885,7 +890,7 @@ public Point getCaretLocation () {
long /*int*/ layout = OS.gtk_entry_get_layout (handle);
PangoRectangle pos = new PangoRectangle ();
OS.pango_layout_index_to_pos (layout, index, pos);
- int x = offset_x [0] + OS.PANGO_PIXELS (pos.x) - getBorderWidth ();
+ int x = offset_x [0] + OS.PANGO_PIXELS (pos.x) - getBorderWidthInPixels ();
int y = offset_y [0] + OS.PANGO_PIXELS (pos.y);
return new Point (x, y);
}
@@ -1409,7 +1414,7 @@ public int getTopIndex () {
* The top pixel does not include the widget trimming.
* </p>
*
- * @return the pixel position of the top line
+ * @return the point position of the top line
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
@@ -1418,6 +1423,11 @@ public int getTopIndex () {
*/
public int getTopPixel () {
checkWidget ();
+ return DPIUtil.autoScaleDown(getTopPixelInPixels());
+}
+
+int getTopPixelInPixels () {
+ checkWidget ();
if ((style & SWT.SINGLE) != 0) return 0;
byte [] position = new byte [ITER_SIZEOF];
GdkRectangle rect = new GdkRectangle ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
index fa5807ba6a..12e223f6b7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -162,7 +162,7 @@ int applyThemeBackground () {
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
@@ -299,10 +299,15 @@ public ToolItem getItem (int index) {
*/
public ToolItem getItem (Point point) {
checkWidget();
+ return getItemInPixels(DPIUtil.autoScaleUp(point));
+}
+
+
+ToolItem getItemInPixels (Point point) {
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
ToolItem[] items = getItems();
for (int i=0; i<items.length; i++) {
- if (items[i].getBounds().contains(point)) return items[i];
+ if (items[i].getBoundsInPixels().contains(point)) return items[i];
}
return null;
}
@@ -475,9 +480,9 @@ long /*int*/ menuItemSelected (long /*int*/ widget, ToolItem item) {
event.detail = SWT.ARROW;
GtkAllocation allocation = new GtkAllocation ();
OS.gtk_widget_get_allocation (widget, allocation);
- event.x = allocation.x;
- if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - allocation.width - event.x;
- event.y = allocation.y + allocation.height;
+ event.x = DPIUtil.autoScaleDown(allocation.x);
+ if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (getClientWidth () - allocation.width) - event.x;
+ event.y = DPIUtil.autoScaleDown(allocation.y + allocation.height);
break;
case SWT.RADIO :
if ((style & SWT.NO_RADIO_GROUP) == 0) item.selectRadio ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
index 0c03576edd..d785bab813 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -299,6 +299,11 @@ public void dispose () {
* </ul>
*/
public Rectangle getBounds () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown (getBoundsInPixels ());
+}
+
+Rectangle getBoundsInPixels () {
checkWidget();
parent.forceResize ();
long /*int*/ topHandle = topHandle ();
@@ -453,6 +458,11 @@ public String getToolTipText () {
* </ul>
*/
public int getWidth () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown (getWidthInPixels ());
+}
+
+int getWidthInPixels () {
checkWidget();
parent.forceResize ();
long /*int*/ topHandle = topHandle ();
@@ -523,9 +533,9 @@ long /*int*/ gtk_clicked (long /*int*/ widget) {
event.detail = SWT.ARROW;
GtkAllocation allocation = new GtkAllocation ();
OS.gtk_widget_get_allocation (topHandle, allocation);
- event.x = allocation.x;
- if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth () - allocation.width - event.x;
- event.y = allocation.y + allocation.height;
+ event.x = DPIUtil.autoScaleDown(allocation.x);
+ if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (parent.getClientWidth ()- allocation.width) - event.x;
+ event.y = DPIUtil.autoScaleDown(allocation.y + allocation.height);
}
break;
}
@@ -869,13 +879,13 @@ void resizeControl () {
* case can occur when the control is a
* combo box.
*/
- Rectangle itemRect = getBounds ();
- control.setSize (itemRect.width, itemRect.height);
+ Rectangle itemRect = getBoundsInPixels ();
+ control.setSizeInPixels (itemRect.width, itemRect.height);
resizeHandle(itemRect.width, itemRect.height);
- Rectangle rect = control.getBounds ();
+ Rectangle rect = control.getBoundsInPixels ();
rect.x = itemRect.x + (itemRect.width - rect.width) / 2;
rect.y = itemRect.y + (itemRect.height - rect.height) / 2;
- control.setLocation (rect.x, rect.y);
+ control.setLocationInPixels (rect.x, rect.y);
}
}
@@ -988,7 +998,7 @@ public void setEnabled (boolean enabled) {
*/
int [] x = new int [1], y = new int [1];
gdk_window_get_device_position (parent.paintWindow (), x, y, null);
- if (getBounds ().contains (x [0], y [0])) {
+ if (getBoundsInPixels ().contains (x [0], y [0])) {
OS.gtk_widget_hide (handle);
OS.gtk_widget_show (handle);
}
@@ -1249,6 +1259,11 @@ void setToolTipText (Shell shell, String newString) {
* </ul>
*/
public void setWidth (int width) {
+ checkWidget ();
+ setWidthInPixels(DPIUtil.autoScaleUp(width));
+}
+
+void setWidthInPixels (int width) {
checkWidget();
if ((style & SWT.SEPARATOR) == 0) return;
if (width < 0) return;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
index 8ad085a5e9..2b0f892335 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -252,7 +252,7 @@ void configure () {
}
OS.gtk_widget_realize(handle);
Region region = new Region (display);
- region.add(polyline);
+ region.add(DPIUtil.autoScaleDown(polyline));
if (OS.GTK3) {
OS.gtk_widget_shape_combine_region (handle, region.handle);
} else {
@@ -711,13 +711,17 @@ public void setAutoHide (boolean autoHide) {
*/
public void setLocation (int x, int y) {
checkWidget ();
+ setLocation (new Point (x, y));
+}
+
+void setLocationInPixels (int x, int y) {
+ checkWidget ();
this.x = x;
this.y = y;
if ((style & SWT.BALLOON) != 0) {
if (OS.gtk_widget_get_visible (handle)) configure ();
}
}
-
/**
* Sets the location of the receiver, which must be a tooltip,
* to the point specified by the argument which is relative
@@ -742,8 +746,13 @@ public void setLocation (int x, int y) {
*/
public void setLocation (Point location) {
checkWidget ();
+ setLocationInPixels(DPIUtil.autoScaleUp(location));
+}
+
+void setLocationInPixels (Point location) {
+ checkWidget ();
if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
- setLocation (location.x, location.y);
+ setLocationInPixels (location.x, location.y);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
index 1870a87315..cfb001969a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -195,7 +195,7 @@ Point adjustMoveCursor () {
int newX = bounds.x + bounds.width / 2;
int newY = bounds.y;
- Point point = display.map (parent, null, newX, newY);
+ Point point = display.mapInPixels (parent, null, newX, newY);
display.setCursorLocation (point);
/*
@@ -228,7 +228,7 @@ Point adjustResizeCursor () {
newY = bounds.y + bounds.height / 2;
}
- Point point = display.map (parent, null, newX, newY);
+ Point point = display.mapInPixels (parent, null, newX, newY);
display.setCursorLocation (point);
/*
@@ -318,7 +318,7 @@ void drawRectangles (Rectangle [] rects) {
long /*int*/ region = OS.gdk_region_new ();
GdkRectangle rect = new GdkRectangle();
for (int i = 0; i < rects.length; i++) {
- Rectangle r = parent != null ? display.map(parent, null, rects[i]) : rects[i];
+ Rectangle r = parent != null ? display.mapInPixels(parent, null, rects[i]) : rects[i];
rect.x = r.x;
rect.y = r.y;
rect.width = r.width + 1;
@@ -376,6 +376,16 @@ public Rectangle [] getRectangles () {
Rectangle [] result = new Rectangle [rectangles.length];
for (int i = 0; i < rectangles.length; i++) {
Rectangle current = rectangles [i];
+ result [i] = DPIUtil.autoScaleDown (new Rectangle (current.x, current.y, current.width, current.height));
+ }
+ return result;
+}
+
+Rectangle [] getRectanglesInPixels () {
+ checkWidget();
+ Rectangle [] result = new Rectangle [rectangles.length];
+ for (int i = 0; i < rectangles.length; i++) {
+ Rectangle current = rectangles [i];
result [i] = new Rectangle (current.x, current.y, current.width, current.height);
}
return result;
@@ -443,10 +453,10 @@ long /*int*/ gtk_key_press_event (long /*int*/ widget, long /*int*/ eventPtr) {
rectsToErase [i] = new Rectangle (current.x, current.y, current.width, current.height);
}
Event event = new Event ();
- event.x = oldX + xChange;
- event.y = oldY + yChange;
+ Rectangle eventRect = new Rectangle (oldX + xChange, oldY + yChange, 0, 0);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
if (parent != null && (parent.style & SWT.MIRRORED) != 0) {
- event.x = parent.getClientWidth () - event.width - event.x;
+ event.x = DPIUtil.autoScaleDown (parent.getClientWidth ()) - event.width - event.x;
}
if ((style & SWT.RESIZE) != 0) {
resizeRectangles (xChange, yChange);
@@ -568,12 +578,12 @@ long /*int*/ gtk_mouse (int eventType, long /*int*/ widget, long /*int*/ eventPt
}
Event event = new Event ();
if (parent == null) {
- event.x = newX [0];
- event.y = newY [0];
+ Rectangle eventRect = new Rectangle (newX [0], newY [0], 0, 0);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
} else {
- Point screenCoord = display.map (parent, null, newX [0], newY [0]);
- event.x = screenCoord.x;
- event.y = screenCoord.y;
+ Point screenCoord = display.mapInPixels (parent, null, newX [0], newY [0]);
+ Rectangle eventRect = new Rectangle (screenCoord.x, screenCoord.y, 0, 0);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
}
if ((style & SWT.RESIZE) != 0) {
resizeRectangles (newX [0] - oldX, newY [0] - oldY);
@@ -772,7 +782,7 @@ public boolean open () {
OS.gtk_widget_shape_combine_region (overlay, region);
OS.gtk_widget_input_shape_combine_region (overlay, region);
OS.gdk_region_destroy (region);
- Rectangle bounds = display.getBounds();
+ Rectangle bounds = display.getBoundsInPixels();
OS.gtk_window_move (overlay, bounds.x, bounds.y);
OS.gtk_window_resize (overlay, bounds.width, bounds.height);
OS.gtk_widget_show (overlay);
@@ -1050,6 +1060,16 @@ public void setRectangles (Rectangle [] rectangles) {
checkWidget();
if (rectangles == null) error (SWT.ERROR_NULL_ARGUMENT);
int length = rectangles.length;
+ for (int i = 0; i < length; i++) {
+ rectangles [i] = DPIUtil.autoScaleUp (rectangles [i]);
+ }
+ setRectanglesInPixels (rectangles);
+}
+
+void setRectanglesInPixels (Rectangle [] rectangles) {
+ checkWidget();
+ if (rectangles == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int length = rectangles.length;
this.rectangles = new Rectangle [length];
for (int i = 0; i < length; i++) {
Rectangle current = rectangles [i];
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java
index 6d8ede3ad2..36b8edc874 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -293,7 +293,7 @@ long /*int*/ gtk_size_allocate (long /*int*/ widget, long /*int*/ allocation) {
OS.gtk_widget_get_allocation (widget, widgetAllocation);
int xoffset = (int) Math.floor (widgetAllocation.x + ((widgetAllocation.width -OS.GTK_WIDGET_REQUISITION_WIDTH (widget)) * 0.5) + 0.5);
int yoffset = (int) Math.floor (widgetAllocation.y + ((widgetAllocation.height - OS.GTK_WIDGET_REQUISITION_HEIGHT (widget)) * 0.5) + 0.5);
- Rectangle b = image.getBounds();
+ Rectangle b = image.getBoundsInPixels();
long /*int*/ gdkImagePtr = OS.gdk_drawable_get_image (image.mask, 0, 0, b.width, b.height);
if (gdkImagePtr == 0) error(SWT.ERROR_NO_HANDLES);
GdkImage gdkImage = new GdkImage();
@@ -308,7 +308,8 @@ long /*int*/ gtk_size_allocate (long /*int*/ widget, long /*int*/ allocation) {
int theByte = maskData [index] & 0xFF;
int mask = 1 << (x & 0x7);
if ((theByte & mask) != 0) {
- region.add (xoffset + x, yoffset + y, 1, 1);
+ Rectangle rect = DPIUtil.autoScaleDown(new Rectangle(xoffset + x, yoffset + y, 1, 1));
+ region.add(rect.x, rect.y, rect.width, rect.height);
}
}
}
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 c70aa25ce6..bf9660d56b 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -537,7 +537,7 @@ void clearAll (boolean all, long /*int*/ parentIter) {
}
@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
@@ -551,7 +551,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
* the number of items in the table.
*/
if (OS.GTK3 && hHint == SWT.DEFAULT && size.y == getHeaderHeight()) {
- size.y = getItemCount() * getItemHeight() + getHeaderHeight();
+ size.y = getItemCount() * getItemHeightInPixels() + getHeaderHeight();
}
/*
@@ -560,7 +560,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
* so need to assign default height
*/
if (size.y == 0 && hHint == SWT.DEFAULT) size.y = DEFAULT_HEIGHT;
- Rectangle trim = computeTrim (0, 0, size.x, size.y);
+ Rectangle trim = computeTrimInPixels (0, 0, size.x, size.y);
size.x = trim.width;
size.y = trim.height;
return size;
@@ -1146,7 +1146,7 @@ GdkColor getBackgroundColor () {
}
@Override
-public Rectangle getClientArea () {
+Rectangle getClientAreaInPixels () {
checkWidget ();
forceResize ();
OS.gtk_widget_realize (handle);
@@ -1163,7 +1163,7 @@ public Rectangle getClientArea () {
int height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
Rectangle rect = new Rectangle (fixedX [0] - binX [0], fixedY [0] - binY [0], width, height);
if (getHeaderVisible() && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) {
- rect.y += getHeaderHeight();
+ rect.y += getHeaderHeightInPixels();
}
return rect;
}
@@ -1389,6 +1389,11 @@ GdkColor getForegroundColor () {
* @since 3.1
*/
public int getGridLineWidth () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown (getGridLineWidthInPixels ());
+}
+
+int getGridLineWidthInPixels () {
checkWidget();
return 0;
}
@@ -1407,6 +1412,11 @@ public int getGridLineWidth () {
*/
public int getHeaderHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown (getHeaderHeightInPixels ());
+}
+
+int getHeaderHeightInPixels () {
+ checkWidget ();
if (!OS.gtk_tree_view_get_headers_visible (handle)) return 0;
if (columnCount > 0) {
GtkRequisition requisition = new GtkRequisition ();
@@ -1503,6 +1513,11 @@ public TreeItem getItem (int index) {
* </ul>
*/
public TreeItem getItem (Point point) {
+ checkWidget();
+ return getItemInPixels(DPIUtil.autoScaleUp(point));
+}
+
+TreeItem getItemInPixels (Point point) {
checkWidget ();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
long /*int*/ [] path = new long /*int*/ [1];
@@ -1510,7 +1525,7 @@ public TreeItem getItem (Point point) {
int x = point.x;
int y = point.y;
if (getHeaderVisible() && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) {
- y -= getHeaderHeight();
+ y -= getHeaderHeightInPixels();
}
if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - x;
long /*int*/ [] columnHandle = new long /*int*/ [1];
@@ -1569,6 +1584,11 @@ public int getItemCount () {
*/
public int getItemHeight () {
checkWidget ();
+ return DPIUtil.autoScaleDown (getItemHeightInPixels ());
+}
+
+int getItemHeightInPixels () {
+ checkWidget ();
int itemCount = OS.gtk_tree_model_iter_n_children (modelHandle, 0);
if (itemCount == 0) {
long /*int*/ column = OS.gtk_tree_view_get_column (handle, 0);
@@ -2626,7 +2646,7 @@ void sendMeasureEvent (long /*int*/ cell, long /*int*/ width, long /*int*/ heigh
Image image = item.getImage (columnIndex);
int imageWidth = 0;
if (image != null) {
- Rectangle bounds = image.getBounds ();
+ Rectangle bounds = image.getBoundsInPixels ();
imageWidth = bounds.width;
}
contentWidth [0] += imageWidth;
@@ -2636,8 +2656,8 @@ void sendMeasureEvent (long /*int*/ cell, long /*int*/ width, long /*int*/ heigh
event.item = item;
event.index = columnIndex;
event.gc = gc;
- event.width = contentWidth [0];
- event.height = contentHeight [0];
+ Rectangle eventRect = new Rectangle (0, 0, contentWidth [0], contentHeight [0]);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
long /*int*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
if (OS.gtk_tree_selection_path_is_selected (selection, path)) {
@@ -2646,8 +2666,9 @@ void sendMeasureEvent (long /*int*/ cell, long /*int*/ width, long /*int*/ heigh
OS.gtk_tree_path_free (path);
sendEvent (SWT.MeasureItem, event);
gc.dispose ();
- contentWidth [0] = event.width - imageWidth;
- if (contentHeight [0] < event.height) contentHeight [0] = event.height;
+ Rectangle rect = DPIUtil.autoScaleUp (event.getBounds ());
+ contentWidth [0] = rect.width - imageWidth;
+ if (contentHeight [0] < rect.height) contentHeight [0] = rect.height;
if (width != 0) OS.memmove (width, contentWidth, 4);
if (height != 0) OS.memmove (height, contentHeight, 4);
if (OS.GTK3) {
@@ -2786,21 +2807,23 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo
if (OS.GTK_VERSION >= OS.VERSION(3, 9, 0) && cr != 0) {
GdkRectangle r = new GdkRectangle();
OS.gdk_cairo_get_clip_rectangle(cr, r);
- gc.setClipping(rect.x, r.y, r.width, r.height);
+ Rectangle rect2 = DPIUtil.autoScaleDown(new Rectangle(rect.x, r.y, r.width, r.height));
+ // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075
+ gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height);
if (OS.GTK_VERSION <= OS.VERSION(3, 14, 8)) {
rect.width = r.width;
}
} else {
- gc.setClipping (rect.x, rect.y, rect.width, rect.height);
+ Rectangle rect2 = DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height));
+ // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075
+ gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height);
}
Event event = new Event ();
event.item = item;
event.index = columnIndex;
event.gc = gc;
- event.x = rect.x;
- event.y = rect.y;
- event.width = rect.width;
- event.height = rect.height;
+ Rectangle eventRect = new Rectangle (rect.x, rect.y, rect.width, rect.height);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
event.detail = drawState;
sendEvent (SWT.EraseItem, event);
drawForeground = null;
@@ -2828,7 +2851,7 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo
gc.setBackground (item.getBackground (columnIndex));
GdkRectangle rect = new GdkRectangle ();
OS.memmove (rect, background_area, GdkRectangle.sizeof);
- gc.fillRectangle (rect.x, rect.y, rect.width, rect.height);
+ gc.fillRectangle(DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height)));
gc.dispose ();
}
if ((drawState & SWT.FOREGROUND) != 0 || OS.GTK_IS_CELL_RENDERER_TOGGLE (cell)) {
@@ -2866,7 +2889,7 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo
Image image = item.getImage (columnIndex);
int imageWidth = 0;
if (image != null) {
- Rectangle bounds = image.getBounds ();
+ Rectangle bounds = image.getBoundsInPixels ();
imageWidth = bounds.width;
}
// On gtk >3.9 and <3.14.8 the clip rectangle does not have image area into clip rectangle
@@ -2904,16 +2927,16 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo
rect.x = getClientWidth () - rect.width - rect.x;
}
- gc.setClipping (rect.x, rect.y, rect.width, rect.height);
+ Rectangle rect2 = DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height));
+ // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075
+ gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height);
Event event = new Event ();
event.item = item;
event.index = columnIndex;
event.gc = gc;
- event.x = rect.x + contentX [0];
- event.y = rect.y;
- event.width = contentWidth [0];
- event.height = rect.height;
+ Rectangle eventRect = new Rectangle (rect.x + contentX [0], rect.y, contentWidth [0], rect.height);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
event.detail = drawState;
sendEvent(SWT.PaintItem, event);
gc.dispose();
@@ -2995,7 +3018,7 @@ public void setInsertMark (TreeItem item, boolean before) {
}
if (item.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
if (item.parent != this) return;
- Rectangle rect = item.getBounds();
+ Rectangle rect = item.getBoundsInPixels();
long /*int*/ [] path = new long /*int*/ [1];
OS.gtk_widget_realize (handle);
if (!OS.gtk_tree_view_get_path_at_pos(handle, rect.x, rect.y, path, null, null, null)) return;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java
index 4457e6b916..ff689dd33a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,10 +12,10 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
/**
* Instances of this class represent a column in a tree widget.
@@ -322,6 +322,11 @@ public String getToolTipText () {
* </ul>
*/
public int getWidth () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown (getWidthInPixels ());
+}
+
+int getWidthInPixels () {
checkWidget();
if (!OS.gtk_tree_view_column_get_visible (handle)) {
return 0;
@@ -449,7 +454,7 @@ public void pack () {
}
OS.g_free (iter);
}
- setWidth(width);
+ setWidthInPixels(width);
}
@Override
@@ -689,6 +694,11 @@ void setToolTipText (Shell shell, String newString) {
* </ul>
*/
public void setWidth (int width) {
+ checkWidget ();
+ setWidthInPixels (DPIUtil.autoScaleUp (width));
+}
+
+void setWidthInPixels (int width) {
checkWidget();
if (width < 0) return;
if (width == lastWidth) return;
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 6bdf35a4ed..c160728e31 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -422,6 +422,11 @@ public Color getBackground (int index) {
* @since 3.1
*/
public Rectangle getBounds (int index) {
+ checkWidget ();
+ return DPIUtil.autoScaleDown (getBoundsInPixels (index));
+}
+
+Rectangle getBoundsInPixels (int index) {
// TODO fully test on early and later versions of GTK
checkWidget();
if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -450,7 +455,7 @@ public Rectangle getBounds (int index) {
int width = OS.gtk_tree_view_column_get_visible (column) ? rect.width + 1 : 0;
Rectangle r = new Rectangle (rect.x, rect.y, width, rect.height + 1);
if (parent.getHeaderVisible() && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) {
- r.y += parent.getHeaderHeight();
+ r.y += parent.getHeaderHeightInPixels();
}
return r;
}
@@ -467,6 +472,11 @@ public Rectangle getBounds (int index) {
* </ul>
*/
public Rectangle getBounds () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown (getBoundsInPixels ());
+}
+
+Rectangle getBoundsInPixels () {
// TODO fully test on early and later versions of GTK
// shifted a bit too far right on later versions of GTK - however, old Tree also had this problem
checkWidget ();
@@ -512,7 +522,7 @@ public Rectangle getBounds () {
int width = OS.gtk_tree_view_column_get_visible (column) ? rect.width + 1 : 0;
Rectangle r = new Rectangle (rect.x, rect.y, width, rect.height + 1);
if (parent.getHeaderVisible() && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) {
- r.y += parent.getHeaderHeight();
+ r.y += parent.getHeaderHeightInPixels();
}
return r;
}
@@ -701,6 +711,11 @@ public Image getImage (int index) {
* @since 3.1
*/
public Rectangle getImageBounds (int index) {
+ checkWidget ();
+ return DPIUtil.autoScaleDown(getImageBoundsInPixels(index));
+}
+
+Rectangle getImageBoundsInPixels (int index) {
// TODO fully test on early and later versions of GTK
checkWidget ();
if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -915,6 +930,11 @@ public String getText (int index) {
*/
public Rectangle getTextBounds (int index) {
checkWidget ();
+ return DPIUtil.autoScaleDown(getTextBoundsInPixels(index));
+}
+
+Rectangle getTextBoundsInPixels (int index) {
+ checkWidget ();
if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
int count = Math.max (1, parent.getColumnCount ());
if (0 > index || index > count - 1) return new Rectangle (0, 0, 0, 0);
@@ -966,7 +986,7 @@ public Rectangle getTextBounds (int index) {
Image image = _getImage(index);
int imageWidth = 0;
if (image != null) {
- imageWidth = image.getBounds ().width;
+ imageWidth = image.getBoundsInPixels ().width;
}
if (x [0] < imageWidth) {
rect.x += imageWidth;
@@ -1502,8 +1522,8 @@ public void setImage (int index, Image image) {
OS.gtk_cell_renderer_get_fixed_size (pixbufRenderer, currentWidth, currentHeight);
if (!parent.pixbufSizeSet) {
if (image != null) {
- int iWidth = image.getBounds ().width;
- int iHeight = image.getBounds ().height;
+ int iWidth = image.getBoundsInPixels ().width;
+ int iHeight = image.getBoundsInPixels ().height;
if (iWidth > currentWidth [0] || iHeight > currentHeight [0]) {
OS.gtk_cell_renderer_set_fixed_size (pixbufRenderer, iWidth, iHeight);
parent.pixbufSizeSet = true;
@@ -1535,7 +1555,7 @@ public void setImage (int index, Image image) {
int [] w = new int [1];
long /*int*/ pixbufRenderer = parent.getPixbufRenderer(column);
OS.gtk_tree_view_column_cell_get_position (column, pixbufRenderer, null, w);
- if (w[0] < image.getBounds().width) {
+ if (w[0] < image.getBoundsInPixels().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
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 76adec892d..3ef6774ae7 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -1352,7 +1352,9 @@ void sendEvent (int eventType, Event event, boolean send) {
if (eventTable == null && !display.filters (eventType)) {
return;
}
- if (event == null) event = new Event ();
+ if (event == null) {
+ event = new Event();
+ }
event.type = eventType;
event.display = display;
event.widget = this;
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java
index 6e69e0bfcd..6c6dbdf1c1 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java
@@ -139,11 +139,11 @@ public void test_copyAreaIIIIII() {
PaletteData palette = imageData.palette;
int pixel = imageData.getPixel(destX + 4, destY);
assertEquals(":a:", whiteRGB, palette.getRGB(pixel));
- pixel = imageData.getPixel(destX + 5, destY);
+ pixel = imageData.getPixel(destX + 6 , destY);
assertEquals(":b:", blueRGB, palette.getRGB(pixel));
pixel = imageData.getPixel(destX + 10, destY);
assertEquals(":c:", blueRGB, palette.getRGB(pixel));
- pixel = imageData.getPixel(destX + 11, destY);
+ pixel = imageData.getPixel(destX + 12, destY);
assertEquals(":d:", whiteRGB, palette.getRGB(pixel));
}
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Image.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Image.java
index 32379e5caf..27f794d155 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Image.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Image.java
@@ -733,6 +733,7 @@ public void test_getBounds() {
assertEquals(":c:", bounds, bounds1);
}
+
@Test
public void test_getImageData() {
getImageData1();
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Region.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Region.java
index 0dc9fcb37f..078e94527f 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Region.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Region.java
@@ -382,11 +382,11 @@ public void test_hashCode() {
@Test
public void test_intersectLorg_eclipse_swt_graphics_Rectangle() {
- Rectangle rect1 = new Rectangle(0,0,50,25);
- Rectangle rect2 = new Rectangle(0,0,50,25);
+ Rectangle rect1 = new Rectangle(0,0,48,24);
+ Rectangle rect2 = new Rectangle(0,0,48,24);
Rectangle rect3 = new Rectangle(10,10,10,10);
- Rectangle rect4 = new Rectangle(50,25,10,10);
- Rectangle rect5 = new Rectangle(25,20,25,10);
+ Rectangle rect4 = new Rectangle(48,24,10,10);
+ Rectangle rect5 = new Rectangle(24,20,24,10);
Region reg = new Region(display);
reg.dispose();
@@ -435,7 +435,7 @@ public void test_intersectLorg_eclipse_swt_graphics_Rectangle() {
reg.add(rect4);
reg.intersect(rect5);
box = reg.getBounds();
- if (!box.equals(new Rectangle(25,20,25,5))) {
+ if (!box.equals(new Rectangle(24,20,24,4))) {
reg.dispose();
fail("intersect failed 5");
}
@@ -446,7 +446,7 @@ public void test_intersectLorg_eclipse_swt_graphics_Rectangle() {
public void test_intersectLorg_eclipse_swt_graphics_Region() {
Region reg = new Region(display);
Region reg1 = new Region(display);
- reg1.add(new Rectangle(0,0,50,25));
+ reg1.add(new Rectangle(0,0,48,24));
reg.dispose();
try {
@@ -466,7 +466,7 @@ public void test_intersectLorg_eclipse_swt_graphics_Region() {
}
Region reg2 = new Region(display);
- reg2.add(new Rectangle(0,0,50,25));
+ reg2.add(new Rectangle(0,0,48,24));
reg.add(reg1);
reg.intersect(reg2);
@@ -493,7 +493,7 @@ public void test_intersectLorg_eclipse_swt_graphics_Region() {
reg3.dispose();
Region reg4 = new Region(display);
- reg4.add(new Rectangle(50,25,10,10));
+ reg4.add(new Rectangle(48,24,10,10));
reg.intersect(reg4);
if (!reg.isEmpty()) {
@@ -504,7 +504,7 @@ public void test_intersectLorg_eclipse_swt_graphics_Region() {
}
Region reg5 = new Region(display);
- reg5.add(new Rectangle(25,20,25,10));
+ reg5.add(new Rectangle(24,20,24,10));
reg.add(reg1.getBounds().union(reg4.getBounds()));
reg.intersect(reg5);
@@ -522,7 +522,7 @@ public void test_intersectLorg_eclipse_swt_graphics_Region() {
reg.add(reg4);
reg.intersect(reg5);
box = reg.getBounds();
- if (!box.equals(new Rectangle(25,20,25,5))) {
+ if (!box.equals(new Rectangle(24,20,24,4))) {
reg.dispose();
reg1.dispose();
reg4.dispose();
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java
index ad6e9cd480..73d2d12ddb 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java
@@ -520,7 +520,7 @@ public void test_mapLorg_eclipse_swt_widgets_ControlLorg_eclipse_swt_widgets_Con
result = display.map(button2, null, 0, 0);
assertEquals(new Point(shellOffset.x + 200,shellOffset.y + 100), result);
result = display.map(button2, null, -3, -6);
- assertEquals(new Point(shellOffset.x + 197,shellOffset.y + 94), result);
+ assertEquals(new Point(shellOffset.x + 197, shellOffset.y + 94), result);
result = display.map(button2, null, 9, 12);
assertEquals(new Point(shellOffset.x + 209,shellOffset.y + 112), result);

Back to the top