summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Kovatch <skovatch>2010-10-22 16:56:12 +0000
committerScott Kovatch <skovatch>2010-10-22 16:56:12 +0000
commit11160fc32a5e37bb28a8748e12eb1179612748aa (patch)
treeae9410cbb576a3076c3efe5cfb9258e2adfe2818
parentdc8212ec50bdd5e996c0c424b5f98eee79b85b71 (diff)
downloadeclipse.platform.swt-11160fc32a5e37bb28a8748e12eb1179612748aa.tar.gz
eclipse.platform.swt-11160fc32a5e37bb28a8748e12eb1179612748aa.tar.xz
eclipse.platform.swt-11160fc32a5e37bb28a8748e12eb1179612748aa.zip
219133 - get printer DPI using PrintCore calls.
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c120
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_custom.h5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_structs.c36
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_structs.h14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSPrintInfo.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java29
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/PMResolution.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Printing/cocoa/org/eclipse/swt/printing/Printer.java33
11 files changed, 279 insertions, 6 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c
index 67207bda64..bfccb3951f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c
@@ -5415,6 +5415,126 @@ JNIEXPORT void JNICALL OS_NATIVE(OpenRgn)
}
#endif
+#ifndef NO_PMPrinterGetIndexedPrinterResolution
+JNIEXPORT jintLong JNICALL OS_NATIVE(PMPrinterGetIndexedPrinterResolution)
+ (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jobject arg2)
+{
+ PMResolution _arg2, *lparg2=NULL;
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, PMPrinterGetIndexedPrinterResolution_FUNC);
+ if (arg2) if ((lparg2 = getPMResolutionFields(env, arg2, &_arg2)) == NULL) goto fail;
+/*
+ rc = (jintLong)PMPrinterGetIndexedPrinterResolution((PMPrinter)arg0, arg1, (PMResolution *)lparg2);
+*/
+ {
+ LOAD_FUNCTION(fp, PMPrinterGetIndexedPrinterResolution)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(PMPrinter, jint, PMResolution *))fp)((PMPrinter)arg0, arg1, (PMResolution *)lparg2);
+ }
+ }
+fail:
+ if (arg2 && lparg2) setPMResolutionFields(env, arg2, lparg2);
+ OS_NATIVE_EXIT(env, that, PMPrinterGetIndexedPrinterResolution_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO_PMPrinterGetOutputResolution
+JNIEXPORT jintLong JNICALL OS_NATIVE(PMPrinterGetOutputResolution)
+ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jobject arg2)
+{
+ PMResolution _arg2, *lparg2=NULL;
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, PMPrinterGetOutputResolution_FUNC);
+ if (arg2) if ((lparg2 = getPMResolutionFields(env, arg2, &_arg2)) == NULL) goto fail;
+/*
+ rc = (jintLong)PMPrinterGetOutputResolution((PMPrinter)arg0, (PMPrintSettings)arg1, (PMResolution *)lparg2);
+*/
+ {
+ LOAD_FUNCTION(fp, PMPrinterGetOutputResolution)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(PMPrinter, PMPrintSettings, PMResolution *))fp)((PMPrinter)arg0, (PMPrintSettings)arg1, (PMResolution *)lparg2);
+ }
+ }
+fail:
+ if (arg2 && lparg2) setPMResolutionFields(env, arg2, lparg2);
+ OS_NATIVE_EXIT(env, that, PMPrinterGetOutputResolution_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO_PMPrinterGetPrinterResolutionCount
+JNIEXPORT jintLong JNICALL OS_NATIVE(PMPrinterGetPrinterResolutionCount)
+ (JNIEnv *env, jclass that, jintLong arg0, jintArray arg1)
+{
+ jint *lparg1=NULL;
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, PMPrinterGetPrinterResolutionCount_FUNC);
+ if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+ rc = (jintLong)PMPrinterGetPrinterResolutionCount((PMPrinter)arg0, lparg1);
+*/
+ {
+ LOAD_FUNCTION(fp, PMPrinterGetPrinterResolutionCount)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(PMPrinter, jint *))fp)((PMPrinter)arg0, lparg1);
+ }
+ }
+fail:
+ if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+ OS_NATIVE_EXIT(env, that, PMPrinterGetPrinterResolutionCount_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO_PMSessionGetCurrentPrinter
+JNIEXPORT jintLong JNICALL OS_NATIVE(PMSessionGetCurrentPrinter)
+ (JNIEnv *env, jclass that, jintLong arg0, jintLongArray arg1)
+{
+ jintLong *lparg1=NULL;
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, PMSessionGetCurrentPrinter_FUNC);
+ if (arg1) if ((lparg1 = (*env)->GetIntLongArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+ rc = (jintLong)PMSessionGetCurrentPrinter((PMPrintSession)arg0, (PMPrinter *)lparg1);
+*/
+ {
+ LOAD_FUNCTION(fp, PMSessionGetCurrentPrinter)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(PMPrintSession, PMPrinter *))fp)((PMPrintSession)arg0, (PMPrinter *)lparg1);
+ }
+ }
+fail:
+ if (arg1 && lparg1) (*env)->ReleaseIntLongArrayElements(env, arg1, lparg1, 0);
+ OS_NATIVE_EXIT(env, that, PMSessionGetCurrentPrinter_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO_PMSessionGetDestinationType
+JNIEXPORT jintLong JNICALL OS_NATIVE(PMSessionGetDestinationType)
+ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jshortArray arg2)
+{
+ jshort *lparg2=NULL;
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, PMSessionGetDestinationType_FUNC);
+ if (arg2) if ((lparg2 = (*env)->GetShortArrayElements(env, arg2, NULL)) == NULL) goto fail;
+/*
+ rc = (jintLong)PMSessionGetDestinationType((PMPrintSession)arg0, arg1, lparg2);
+*/
+ {
+ LOAD_FUNCTION(fp, PMSessionGetDestinationType)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(PMPrintSession, jintLong, jshort *))fp)((PMPrintSession)arg0, arg1, lparg2);
+ }
+ }
+fail:
+ if (arg2 && lparg2) (*env)->ReleaseShortArrayElements(env, arg2, lparg2, 0);
+ OS_NATIVE_EXIT(env, that, PMSessionGetDestinationType_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_PtInRgn
JNIEXPORT jboolean JNICALL OS_NATIVE(PtInRgn)
(JNIEnv *env, jclass that, jshortArray arg0, jintLong arg1)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_custom.h
index 18af205a01..645537369b 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_custom.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_custom.h
@@ -55,3 +55,8 @@
#define GetIconRefFromTypeInfo_LIB "com.apple.LaunchServices"
#define GetIndMenuItemWithCommandID_LIB "com.apple.Carbon"
#define DeleteMenuItem_LIB "com.apple.Carbon"
+#define PMSessionGetCurrentPrinter_LIB "com.apple.ApplicationServices"
+#define PMSessionGetDestinationType_LIB "com.apple.ApplicationServices"
+#define PMPrinterGetPrinterResolutionCount_LIB "com.apple.ApplicationServices"
+#define PMPrinterGetOutputResolution_LIB "com.apple.ApplicationServices"
+#define PMPrinterGetIndexedPrinterResolution_LIB "com.apple.ApplicationServices"
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c
index 295c382773..b3157542d9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c
@@ -14,8 +14,8 @@
#ifdef NATIVE_STATS
-int OS_nativeFunctionCount = 614;
-int OS_nativeFunctionCallCount[614];
+int OS_nativeFunctionCount = 619;
+int OS_nativeFunctionCallCount[619];
char * OS_nativeFunctionNames[] = {
"ATSFontActivateFromFileReference",
"AcquireRootMenu",
@@ -415,6 +415,11 @@ char * OS_nativeFunctionNames[] = {
"NewRgn",
"OffsetRgn",
"OpenRgn",
+ "PMPrinterGetIndexedPrinterResolution",
+ "PMPrinterGetOutputResolution",
+ "PMPrinterGetPrinterResolutionCount",
+ "PMSessionGetCurrentPrinter",
+ "PMSessionGetDestinationType",
"PtInRgn",
"QDRegionToRects",
"RectInRgn",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h
index aa26c57125..bb457e7279 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h
@@ -423,6 +423,11 @@ typedef enum {
NewRgn_FUNC,
OffsetRgn_FUNC,
OpenRgn_FUNC,
+ PMPrinterGetIndexedPrinterResolution_FUNC,
+ PMPrinterGetOutputResolution_FUNC,
+ PMPrinterGetPrinterResolutionCount_FUNC,
+ PMSessionGetCurrentPrinter_FUNC,
+ PMSessionGetDestinationType_FUNC,
PtInRgn_FUNC,
QDRegionToRects_FUNC,
RectInRgn_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_structs.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_structs.c
index 4013ae7de2..b4eb10de59 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_structs.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_structs.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 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
@@ -465,6 +465,40 @@ void setNSSizeFields(JNIEnv *env, jobject lpObject, NSSize *lpStruct)
}
#endif
+#ifndef NO_PMResolution
+typedef struct PMResolution_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID hRes, vRes;
+} PMResolution_FID_CACHE;
+
+PMResolution_FID_CACHE PMResolutionFc;
+
+void cachePMResolutionFields(JNIEnv *env, jobject lpObject)
+{
+ if (PMResolutionFc.cached) return;
+ PMResolutionFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ PMResolutionFc.hRes = (*env)->GetFieldID(env, PMResolutionFc.clazz, "hRes", "D");
+ PMResolutionFc.vRes = (*env)->GetFieldID(env, PMResolutionFc.clazz, "vRes", "D");
+ PMResolutionFc.cached = 1;
+}
+
+PMResolution *getPMResolutionFields(JNIEnv *env, jobject lpObject, PMResolution *lpStruct)
+{
+ if (!PMResolutionFc.cached) cachePMResolutionFields(env, lpObject);
+ lpStruct->hRes = (*env)->GetDoubleField(env, lpObject, PMResolutionFc.hRes);
+ lpStruct->vRes = (*env)->GetDoubleField(env, lpObject, PMResolutionFc.vRes);
+ return lpStruct;
+}
+
+void setPMResolutionFields(JNIEnv *env, jobject lpObject, PMResolution *lpStruct)
+{
+ if (!PMResolutionFc.cached) cachePMResolutionFields(env, lpObject);
+ (*env)->SetDoubleField(env, lpObject, PMResolutionFc.hRes, (jdouble)lpStruct->hRes);
+ (*env)->SetDoubleField(env, lpObject, PMResolutionFc.vRes, (jdouble)lpStruct->vRes);
+}
+#endif
+
#ifndef NO_objc_super
typedef struct objc_super_FID_CACHE {
int cached;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_structs.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_structs.h
index 009ded29f2..101e37531c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_structs.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_structs.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 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
@@ -155,6 +155,18 @@ void setNSSizeFields(JNIEnv *env, jobject lpObject, NSSize *lpStruct);
#define NSSize_sizeof() 0
#endif
+#ifndef NO_PMResolution
+void cachePMResolutionFields(JNIEnv *env, jobject lpObject);
+PMResolution *getPMResolutionFields(JNIEnv *env, jobject lpObject, PMResolution *lpStruct);
+void setPMResolutionFields(JNIEnv *env, jobject lpObject, PMResolution *lpStruct);
+#define PMResolution_sizeof() sizeof(PMResolution)
+#else
+#define cachePMResolutionFields(a,b)
+#define getPMResolutionFields(a,b,c) NULL
+#define setPMResolutionFields(a,b,c)
+#define PMResolution_sizeof() 0
+#endif
+
#ifndef NO_objc_super
void cacheobjc_superFields(JNIEnv *env, jobject lpObject);
struct objc_super *getobjc_superFields(JNIEnv *env, jobject lpObject, struct objc_super *lpStruct);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
index f0217af9f3..8789f18133 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
@@ -2291,6 +2291,12 @@
<class name="NSPredicateEditor" swt_superclass="NSRuleEditor">
</class>
<class name="NSPrintInfo" swt_gen="mixed">
+ <method selector="PMPrintSession" swt_gen="true">
+ <retval swt_gen="true"></retval>
+ </method>
+ <method selector="PMPrintSettings" swt_gen="true">
+ <retval swt_gen="true"></retval>
+ </method>
<method class_method="true" selector="defaultPrinter" swt_gen="true">
<retval swt_gen="true"></retval>
</method>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSPrintInfo.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSPrintInfo.java
index 41a58a9f09..147e5af22c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSPrintInfo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSPrintInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 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
@@ -24,6 +24,14 @@ public NSPrintInfo(id id) {
super(id);
}
+public int /*long*/ PMPrintSession() {
+ return OS.objc_msgSend(this.id, OS.sel_PMPrintSession);
+}
+
+public int /*long*/ PMPrintSettings() {
+ return OS.objc_msgSend(this.id, OS.sel_PMPrintSettings);
+}
+
public static NSPrinter defaultPrinter() {
int /*long*/ result = OS.objc_msgSend(OS.class_NSPrintInfo, OS.sel_defaultPrinter);
return result != 0 ? new NSPrinter(result) : null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
index f4176f1a24..45639696e4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
@@ -62,6 +62,7 @@ public class OS extends C {
public static final int kAXUnderlineStyleSingle = 0x1;
public static final int kAXUnderlineStyleThick = 0x2;
public static final int kAXUnderlineStyleDouble = 0x9;
+ public static final int kPMDestinationPrinter = 1;
public static final int /*long*/ sel_sendSearchSelection = sel_registerName("sendSearchSelection");
@@ -286,6 +287,32 @@ public static final native int GetIndMenuItemWithCommandID(int /*long*/ mHandle,
* @param index cast=(short)
*/
public static final native void DeleteMenuItem(int /*long*/ mHandle, short index);
+/** @method flags=dynamic
+ * @param pmSessionInfo cast=(PMPrintSession)
+ * @param outPMPrinter cast=(PMPrinter *)
+ */
+public static final native int /*long*/ PMSessionGetCurrentPrinter(int /*long*/ pmSessionInfo, int /*long*/[] outPMPrinter);
+/** @method flags=dynamic
+ * @param pmSessionInfo cast=(PMPrintSession)
+ * @param outPMPrinter cast=(PMPrintSettings)
+ */
+public static final native int /*long*/ PMSessionGetDestinationType(int /*long*/ pmSessionInfo, int /*long*/ pmPrintSettings, short[] outDestinationType);
+/** @method flags=dynamic
+ * @param pmPrinter cast=(PMPrinter)
+ * @param pmPrintSettings cast=(PMPrintSettings)
+ */
+public static final native int /*long*/ PMPrinterGetPrinterResolutionCount(int /*long*/ pmPrinter, int[] outNumResolutions);
+/** @method flags=dynamic
+ * @param pmPrinter cast=(PMPrinter)
+ * @param pmPrintSettings cast=(PMPrintSettings)
+ * @param outResolution cast=(PMResolution *)
+ */
+public static final native int /*long*/ PMPrinterGetOutputResolution(int /*long*/ pmPrinter, int /*long*/ pmPrintSettings, PMResolution outResolution);
+/** @method flags=dynamic
+ * @param pmPrinter cast=(PMPrinter)
+ * @param outResolution cast=(PMResolution *)
+ */
+public static final native int /*long*/ PMPrinterGetIndexedPrinterResolution(int /*long*/ pmPrinter, int index, PMResolution outResolution);
/** C calls */
@@ -790,6 +817,8 @@ public static final int /*long*/ protocol_WebUIDelegate = objc_getProtocol("WebU
public static final int /*long*/ sel_CGEvent = sel_registerName("CGEvent");
public static final int /*long*/ sel_DOMDocument = sel_registerName("DOMDocument");
public static final int /*long*/ sel_IBeamCursor = sel_registerName("IBeamCursor");
+public static final int /*long*/ sel_PMPrintSession = sel_registerName("PMPrintSession");
+public static final int /*long*/ sel_PMPrintSettings = sel_registerName("PMPrintSettings");
public static final int /*long*/ sel_TIFFRepresentation = sel_registerName("TIFFRepresentation");
public static final int /*long*/ sel_URL = sel_registerName("URL");
public static final int /*long*/ sel_URLFromPasteboard_ = sel_registerName("URLFromPasteboard:");
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/PMResolution.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/PMResolution.java
new file mode 100755
index 0000000000..bfae489a32
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/PMResolution.java
@@ -0,0 +1,18 @@
+/**********************************************************************
+ * Copyright (c) 2003-2004 IBM Corp.
+ * Portions Copyright (c) 1983-2002, Apple Computer, Inc.
+ *
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ **********************************************************************/
+package org.eclipse.swt.internal.cocoa;
+
+public class PMResolution {
+ public double hRes;
+ public double vRes;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/cocoa/org/eclipse/swt/printing/Printer.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/cocoa/org/eclipse/swt/printing/Printer.java
index 292ef0d558..f47295d667 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/cocoa/org/eclipse/swt/printing/Printer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/cocoa/org/eclipse/swt/printing/Printer.java
@@ -545,7 +545,38 @@ public Point getDPI() {
NSAutoreleasePool pool = null;
if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
try {
- //TODO get output resolution
+ int /*long*/ pmPrintSession = printInfo.PMPrintSession();
+ int /*long*/ printer[] = new int /*long*/ [1];
+ int /*long*/ err = OS.PMSessionGetCurrentPrinter(pmPrintSession, printer);
+
+ if (err == OS.noErr) {
+ int /*long*/ printSettings = printInfo.PMPrintSettings();
+ short[] destType = new short[1];
+ if (OS.PMSessionGetDestinationType(pmPrintSession, printSettings, destType) == OS.noErr) {
+ if (destType[0] == OS.kPMDestinationPrinter) {
+ PMResolution resolution = new PMResolution();
+
+ if (OS.PMPrinterGetOutputResolution(printer[0], printSettings, resolution) != OS.noErr) {
+ int numberOfResolutions[] = new int[1];
+ if (OS.PMPrinterGetPrinterResolutionCount(printer[0], numberOfResolutions) == OS.noErr) {
+ PMResolution tempResolution = new PMResolution();
+ tempResolution.hRes = tempResolution.vRes = 300.0;
+ for (int i = 1; i <= numberOfResolutions[0]; i++) {
+ // PMPrinterGetIndexedPrinterResolution indexes are 1-based.
+ if (OS.PMPrinterGetIndexedPrinterResolution(printer[0], i, tempResolution) == OS.noErr) {
+ if (tempResolution.vRes > resolution.vRes && tempResolution.hRes > resolution.hRes) {
+ resolution = tempResolution;
+ }
+ }
+ }
+ }
+ }
+
+ return new Point((int)resolution.hRes, (int)resolution.vRes);
+ }
+ }
+ }
+
return getIndependentDPI();
} finally {
if (pool != null) pool.release();