diff options
author | Carolyn MacLeod <Carolyn_MacLeod@ca.ibm.com> | 2012-03-07 16:17:05 -0500 |
---|---|---|
committer | Carolyn MacLeod <Carolyn_MacLeod@ca.ibm.com> | 2012-03-07 16:17:05 -0500 |
commit | 4cf183f94d4d4d275955b891045c44c32b075e0a (patch) | |
tree | c838e3ad4e10341221c5dbd6882a73e439f6d3a0 | |
parent | 0baf41d40f3dd8716522c72f50e1eb2c9697bedd (diff) | |
download | eclipse.platform.swt-4cf183f94d4d4d275955b891045c44c32b075e0a.tar.gz eclipse.platform.swt-4cf183f94d4d4d275955b891045c44c32b075e0a.tar.xz eclipse.platform.swt-4cf183f94d4d4d275955b891045c44c32b075e0a.zip |
Bug 212023 - limitation of SWT ColorDialog
12 files changed, 508 insertions, 16 deletions
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 91bea9339a..68769bb8d6 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 @@ -906,7 +906,38 @@ <retval swt_gen="true"></retval> </method> </class> + <class name="NSColorList" swt_gen="mixed"> + <method selector="allKeys" swt_gen="true"> + <retval swt_gen="true"></retval> + </method> + <method class_method="true" selector="colorListNamed:" swt_gen="true"> + <arg swt_gen="true"></arg> + <retval swt_gen="true"></retval> + </method> + <method selector="colorWithKey:" swt_gen="true"> + <arg swt_gen="true"></arg> + <retval swt_gen="true"></retval> + </method> + <method selector="initWithName:" swt_gen="true"> + <arg swt_gen="true"></arg> + <retval swt_gen="true"></retval> + </method> + <method selector="insertColor:key:atIndex:" swt_gen="true"> + <arg swt_gen="true"></arg> + <arg swt_gen="true"></arg> + <arg swt_gen="true"></arg> + <retval swt_gen="true"></retval> + </method> + <method selector="removeColorWithKey:" swt_gen="true"> + <arg swt_gen="true"></arg> + <retval swt_gen="true"></retval> + </method> + </class> <class name="NSColorPanel" swt_gen="mixed" swt_superclass="NSPanel"> + <method selector="attachColorList:" swt_gen="true"> + <arg swt_gen="true"></arg> + <retval swt_gen="true"></retval> + </method> <method selector="color" 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/NSColorList.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSColorList.java new file mode 100644 index 0000000000..0e209f5081 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSColorList.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2000, 2012 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.internal.cocoa; + +public class NSColorList extends NSObject { + +public NSColorList() { + super(); +} + +public NSColorList(int /*long*/ id) { + super(id); +} + +public NSColorList(id id) { + super(id); +} + +public NSArray allKeys() { + int /*long*/ result = OS.objc_msgSend(this.id, OS.sel_allKeys); + return result != 0 ? new NSArray(result) : null; +} + +public static NSColorList colorListNamed(NSString name) { + int /*long*/ result = OS.objc_msgSend(OS.class_NSColorList, OS.sel_colorListNamed_, name != null ? name.id : 0); + return result != 0 ? new NSColorList(result) : null; +} + +public NSColor colorWithKey(NSString key) { + int /*long*/ result = OS.objc_msgSend(this.id, OS.sel_colorWithKey_, key != null ? key.id : 0); + return result != 0 ? new NSColor(result) : null; +} + +public id initWithName(NSString name) { + int /*long*/ result = OS.objc_msgSend(this.id, OS.sel_initWithName_, name != null ? name.id : 0); + return result != 0 ? new id(result) : null; +} + +public void insertColor(NSColor color, NSString key, int /*long*/ loc) { + OS.objc_msgSend(this.id, OS.sel_insertColor_key_atIndex_, color != null ? color.id : 0, key != null ? key.id : 0, loc); +} + +public void removeColorWithKey(NSString key) { + OS.objc_msgSend(this.id, OS.sel_removeColorWithKey_, key != null ? key.id : 0); +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSColorPanel.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSColorPanel.java index e1a8dbdddf..2cb3edb7ef 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSColorPanel.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSColorPanel.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2012 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,10 @@ public NSColorPanel(id id) { super(id); } +public void attachColorList(NSColorList colorList) { + OS.objc_msgSend(this.id, OS.sel_attachColorList_, colorList != null ? colorList.id : 0); +} + public NSColor color() { int /*long*/ result = OS.objc_msgSend(this.id, OS.sel_color); return result != 0 ? new NSColor(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 d70304cca2..e7e74e3bf9 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 @@ -731,6 +731,7 @@ public static final int /*long*/ class_NSCharacterSet = objc_getClass("NSCharact public static final int /*long*/ class_NSClipView = objc_getClass("NSClipView"); public static final int /*long*/ class_NSCoder = objc_getClass("NSCoder"); public static final int /*long*/ class_NSColor = objc_getClass("NSColor"); +public static final int /*long*/ class_NSColorList = objc_getClass("NSColorList"); public static final int /*long*/ class_NSColorPanel = objc_getClass("NSColorPanel"); public static final int /*long*/ class_NSColorSpace = objc_getClass("NSColorSpace"); public static final int /*long*/ class_NSComboBox = objc_getClass("NSComboBox"); @@ -984,6 +985,7 @@ public static final int /*long*/ sel_arrayWithCapacity_ = sel_registerName("arra public static final int /*long*/ sel_arrayWithObject_ = sel_registerName("arrayWithObject:"); public static final int /*long*/ sel_arrowCursor = sel_registerName("arrowCursor"); public static final int /*long*/ sel_ascender = sel_registerName("ascender"); +public static final int /*long*/ sel_attachColorList_ = sel_registerName("attachColorList:"); public static final int /*long*/ sel_attribute_atIndex_effectiveRange_ = sel_registerName("attribute:atIndex:effectiveRange:"); public static final int /*long*/ sel_attributedStringValue = sel_registerName("attributedStringValue"); public static final int /*long*/ sel_attributedStringWithAttachment_ = sel_registerName("attributedStringWithAttachment:"); @@ -1075,12 +1077,14 @@ public static final int /*long*/ sel_collapseItem_ = sel_registerName("collapseI public static final int /*long*/ sel_collapseItem_collapseChildren_ = sel_registerName("collapseItem:collapseChildren:"); public static final int /*long*/ sel_color = sel_registerName("color"); public static final int /*long*/ sel_colorAtX_y_ = sel_registerName("colorAtX:y:"); +public static final int /*long*/ sel_colorListNamed_ = sel_registerName("colorListNamed:"); public static final int /*long*/ sel_colorSpace = sel_registerName("colorSpace"); public static final int /*long*/ sel_colorSpaceModel = sel_registerName("colorSpaceModel"); public static final int /*long*/ sel_colorSpaceName = sel_registerName("colorSpaceName"); public static final int /*long*/ sel_colorUsingColorSpaceName_ = sel_registerName("colorUsingColorSpaceName:"); public static final int /*long*/ sel_colorWithCalibratedRed_green_blue_alpha_ = sel_registerName("colorWithCalibratedRed:green:blue:alpha:"); public static final int /*long*/ sel_colorWithDeviceRed_green_blue_alpha_ = sel_registerName("colorWithDeviceRed:green:blue:alpha:"); +public static final int /*long*/ sel_colorWithKey_ = sel_registerName("colorWithKey:"); public static final int /*long*/ sel_colorWithPatternImage_ = sel_registerName("colorWithPatternImage:"); public static final int /*long*/ sel_columnAtPoint_ = sel_registerName("columnAtPoint:"); public static final int /*long*/ sel_columnIndexesInRect_ = sel_registerName("columnIndexesInRect:"); @@ -1382,6 +1386,7 @@ public static final int /*long*/ sel_initWithIndexSet_ = sel_registerName("initW public static final int /*long*/ sel_initWithIndexesInRange_ = sel_registerName("initWithIndexesInRange:"); public static final int /*long*/ sel_initWithItemIdentifier_ = sel_registerName("initWithItemIdentifier:"); public static final int /*long*/ sel_initWithLocaleIdentifier_ = sel_registerName("initWithLocaleIdentifier:"); +public static final int /*long*/ sel_initWithName_ = sel_registerName("initWithName:"); public static final int /*long*/ sel_initWithRect_options_owner_userInfo_ = sel_registerName("initWithRect:options:owner:userInfo:"); public static final int /*long*/ sel_initWithSize_ = sel_registerName("initWithSize:"); public static final int /*long*/ sel_initWithStartingColor_endingColor_ = sel_registerName("initWithStartingColor:endingColor:"); @@ -1392,6 +1397,7 @@ public static final int /*long*/ sel_initWithTitle_action_keyEquivalent_ = sel_r public static final int /*long*/ sel_initWithTransform_ = sel_registerName("initWithTransform:"); public static final int /*long*/ sel_initWithType_location_ = sel_registerName("initWithType:location:"); public static final int /*long*/ sel_initWithURL_ = sel_registerName("initWithURL:"); +public static final int /*long*/ sel_insertColor_key_atIndex_ = sel_registerName("insertColor:key:atIndex:"); public static final int /*long*/ sel_insertItem_atIndex_ = sel_registerName("insertItem:atIndex:"); public static final int /*long*/ sel_insertItemWithItemIdentifier_atIndex_ = sel_registerName("insertItemWithItemIdentifier:atIndex:"); public static final int /*long*/ sel_insertItemWithObjectValue_atIndex_ = sel_registerName("insertItemWithObjectValue:atIndex:"); @@ -1659,6 +1665,7 @@ public static final int /*long*/ sel_removeAllItems = sel_registerName("removeAl public static final int /*long*/ sel_removeAllPoints = sel_registerName("removeAllPoints"); public static final int /*long*/ sel_removeAttribute_range_ = sel_registerName("removeAttribute:range:"); public static final int /*long*/ sel_removeChildWindow_ = sel_registerName("removeChildWindow:"); +public static final int /*long*/ sel_removeColorWithKey_ = sel_registerName("removeColorWithKey:"); public static final int /*long*/ sel_removeFromSuperview = sel_registerName("removeFromSuperview"); public static final int /*long*/ sel_removeIndex_ = sel_registerName("removeIndex:"); public static final int /*long*/ sel_removeItem_ = sel_registerName("removeItem:"); 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 d74153f857..bdd7f7430c 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 @@ -5030,6 +5030,25 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1color_1free) } #endif +#ifndef NO__1gdk_1color_1parse +JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1color_1parse) + (JNIEnv *env, jclass that, jbyteArray arg0, jobject arg1) +{ + jbyte *lparg0=NULL; + GdkColor _arg1, *lparg1=NULL; + jboolean rc = 0; + OS_NATIVE_ENTER(env, that, _1gdk_1color_1parse_FUNC); + if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail; + if (arg1) if ((lparg1 = &_arg1) == NULL) goto fail; + rc = (jboolean)gdk_color_parse((const gchar *)lparg0, (GdkColor *)lparg1); +fail: + if (arg1 && lparg1) setGdkColorFields(env, arg1, lparg1); + if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0); + OS_NATIVE_EXIT(env, that, _1gdk_1color_1parse_FUNC); + return rc; +} +#endif + #ifndef NO__1gdk_1color_1white JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1color_1white) (JNIEnv *env, jclass that, jintLong arg0, jobject arg1) @@ -8164,6 +8183,35 @@ fail: } #endif +#ifndef NO__1gtk_1color_1selection_1palette_1from_1string +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1color_1selection_1palette_1from_1string) + (JNIEnv *env, jclass that, jbyteArray arg0, jintLong arg1, jintArray arg2) +{ + jbyte *lparg0=NULL; + jint *lparg2=NULL; + OS_NATIVE_ENTER(env, that, _1gtk_1color_1selection_1palette_1from_1string_FUNC); + if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail; + if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail; + gtk_color_selection_palette_from_string((const gchar *)lparg0, (GdkColor **)arg1, (gint *)lparg2); +fail: + if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0); + OS_NATIVE_EXIT(env, that, _1gtk_1color_1selection_1palette_1from_1string_FUNC); +} +#endif + +#ifndef NO__1gtk_1color_1selection_1palette_1to_1string +JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1color_1selection_1palette_1to_1string) + (JNIEnv *env, jclass that, jintLong arg0, jint arg1) +{ + jintLong rc = 0; + OS_NATIVE_ENTER(env, that, _1gtk_1color_1selection_1palette_1to_1string_FUNC); + rc = (jintLong)gtk_color_selection_palette_to_string((GdkColor *)arg0, (gint)arg1); + OS_NATIVE_EXIT(env, that, _1gtk_1color_1selection_1palette_1to_1string_FUNC); + return rc; +} +#endif + #ifndef NO__1gtk_1color_1selection_1set_1current_1color JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1color_1selection_1set_1current_1color) (JNIEnv *env, jclass that, jintLong arg0, jobject arg1) @@ -13057,6 +13105,26 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1settings_1get_1default) } #endif +#ifndef NO__1gtk_1settings_1set_1string_1property +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1settings_1set_1string_1property) + (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jbyteArray arg2, jbyteArray arg3) +{ + jbyte *lparg1=NULL; + jbyte *lparg2=NULL; + jbyte *lparg3=NULL; + OS_NATIVE_ENTER(env, that, _1gtk_1settings_1set_1string_1property_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; + gtk_settings_set_string_property((GtkSettings *)arg0, (const gchar *)lparg1, (const gchar *)lparg2, (const gchar *)lparg3); +fail: + 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, _1gtk_1settings_1set_1string_1property_FUNC); +} +#endif + #ifndef NO__1gtk_1socket_1get_1id JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1socket_1get_1id) (JNIEnv *env, jclass that, jintLong arg0) @@ -18854,6 +18922,30 @@ fail: } #endif +#if (!defined(NO_memmove__ILorg_eclipse_swt_internal_gtk_GdkColor_2I) && !defined(JNI64)) || (!defined(NO_memmove__JLorg_eclipse_swt_internal_gtk_GdkColor_2J) && defined(JNI64)) +#ifndef JNI64 +JNIEXPORT void JNICALL OS_NATIVE(memmove__ILorg_eclipse_swt_internal_gtk_GdkColor_2I)(JNIEnv *env, jclass that, jintLong arg0, jobject arg1, jintLong arg2) +#else +JNIEXPORT void JNICALL OS_NATIVE(memmove__JLorg_eclipse_swt_internal_gtk_GdkColor_2J)(JNIEnv *env, jclass that, jintLong arg0, jobject arg1, jintLong arg2) +#endif +{ + GdkColor _arg1, *lparg1=NULL; +#ifndef JNI64 + OS_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GdkColor_2I_FUNC); +#else + OS_NATIVE_ENTER(env, that, memmove__JLorg_eclipse_swt_internal_gtk_GdkColor_2J_FUNC); +#endif + if (arg1) if ((lparg1 = getGdkColorFields(env, arg1, &_arg1)) == NULL) goto fail; + memmove((void *)arg0, (const void *)lparg1, (size_t)arg2); +fail: +#ifndef JNI64 + OS_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GdkColor_2I_FUNC); +#else + OS_NATIVE_EXIT(env, that, memmove__JLorg_eclipse_swt_internal_gtk_GdkColor_2J_FUNC); +#endif +} +#endif + #if (!defined(NO_memmove__ILorg_eclipse_swt_internal_gtk_GdkEventButton_2I) && !defined(JNI64)) || (!defined(NO_memmove__JLorg_eclipse_swt_internal_gtk_GdkEventButton_2J) && defined(JNI64)) #ifndef JNI64 JNIEXPORT void JNICALL OS_NATIVE(memmove__ILorg_eclipse_swt_internal_gtk_GdkEventButton_2I)(JNIEnv *env, jclass that, jintLong arg0, jobject arg1, jintLong arg2) 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 e8b8307784..32b218c46f 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 @@ -18,8 +18,8 @@ #ifdef NATIVE_STATS -int OS_nativeFunctionCount = 1379; -int OS_nativeFunctionCallCount[1379]; +int OS_nativeFunctionCount = 1384; +int OS_nativeFunctionCallCount[1384]; char * OS_nativeFunctionNames[] = { #ifndef JNI64 "Call__IIII", @@ -430,6 +430,7 @@ char * OS_nativeFunctionNames[] = { "_1gdk_1cairo_1set_1source_1color", "_1gdk_1cairo_1set_1source_1window", "_1gdk_1color_1free", + "_1gdk_1color_1parse", "_1gdk_1color_1white", "_1gdk_1colormap_1alloc_1color", "_1gdk_1colormap_1free_1colors", @@ -660,6 +661,8 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1clipboard_1wait_1for_1contents", "_1gtk_1color_1selection_1dialog_1new", "_1gtk_1color_1selection_1get_1current_1color", + "_1gtk_1color_1selection_1palette_1from_1string", + "_1gtk_1color_1selection_1palette_1to_1string", "_1gtk_1color_1selection_1set_1current_1color", "_1gtk_1color_1selection_1set_1has_1palette", "_1gtk_1combo_1box_1entry_1new_1text", @@ -1009,6 +1012,7 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1separator_1menu_1item_1new", "_1gtk_1set_1locale", "_1gtk_1settings_1get_1default", + "_1gtk_1settings_1set_1string_1property", "_1gtk_1socket_1get_1id", "_1gtk_1socket_1new", "_1gtk_1spin_1button_1configure", @@ -1511,6 +1515,11 @@ char * OS_nativeFunctionNames[] = { "memmove__JLorg_eclipse_swt_internal_gtk_GTypeInfo_2I", #endif #ifndef JNI64 + "memmove__ILorg_eclipse_swt_internal_gtk_GdkColor_2I", +#else + "memmove__JLorg_eclipse_swt_internal_gtk_GdkColor_2J", +#endif +#ifndef JNI64 "memmove__ILorg_eclipse_swt_internal_gtk_GdkEventButton_2I", #else "memmove__JLorg_eclipse_swt_internal_gtk_GdkEventButton_2J", 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 cbe5eae5de..ccbe80c7c7 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 @@ -438,6 +438,7 @@ typedef enum { _1gdk_1cairo_1set_1source_1color_FUNC, _1gdk_1cairo_1set_1source_1window_FUNC, _1gdk_1color_1free_FUNC, + _1gdk_1color_1parse_FUNC, _1gdk_1color_1white_FUNC, _1gdk_1colormap_1alloc_1color_FUNC, _1gdk_1colormap_1free_1colors_FUNC, @@ -668,6 +669,8 @@ typedef enum { _1gtk_1clipboard_1wait_1for_1contents_FUNC, _1gtk_1color_1selection_1dialog_1new_FUNC, _1gtk_1color_1selection_1get_1current_1color_FUNC, + _1gtk_1color_1selection_1palette_1from_1string_FUNC, + _1gtk_1color_1selection_1palette_1to_1string_FUNC, _1gtk_1color_1selection_1set_1current_1color_FUNC, _1gtk_1color_1selection_1set_1has_1palette_FUNC, _1gtk_1combo_1box_1entry_1new_1text_FUNC, @@ -1017,6 +1020,7 @@ typedef enum { _1gtk_1separator_1menu_1item_1new_FUNC, _1gtk_1set_1locale_FUNC, _1gtk_1settings_1get_1default_FUNC, + _1gtk_1settings_1set_1string_1property_FUNC, _1gtk_1socket_1get_1id_FUNC, _1gtk_1socket_1new_FUNC, _1gtk_1spin_1button_1configure_FUNC, @@ -1519,6 +1523,11 @@ typedef enum { memmove__JLorg_eclipse_swt_internal_gtk_GTypeInfo_2I_FUNC, #endif #ifndef JNI64 + memmove__ILorg_eclipse_swt_internal_gtk_GdkColor_2I_FUNC, +#else + memmove__JLorg_eclipse_swt_internal_gtk_GdkColor_2J_FUNC, +#endif +#ifndef JNI64 memmove__ILorg_eclipse_swt_internal_gtk_GdkEventButton_2I_FUNC, #else memmove__JLorg_eclipse_swt_internal_gtk_GdkEventButton_2J_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 e6c52f5135..ecda2599ed 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 @@ -549,6 +549,7 @@ public class OS extends C { public static final byte[] foreground_gdk = ascii("foreground-gdk"); public static final byte[] grid_line_width = ascii("grid-line-width"); public static final byte[] gtk_alternative_button_order = ascii("gtk-alternative-button-order"); + public static final byte[] gtk_color_palette = ascii("gtk-color-palette"); public static final byte[] gtk_cursor_blink = ascii("gtk-cursor-blink"); public static final byte[] gtk_cursor_blink_time = ascii("gtk-cursor-blink-time"); public static final byte[] gtk_double_click_time = ascii("gtk-double-click-time"); @@ -3676,16 +3677,6 @@ public static final void gdk_cairo_set_source_color(int /*long*/ cairo, GdkColor lock.unlock(); } } -/** @param color cast=(GdkColor *) */ -public static final native void _gdk_color_free(int /*long*/ color); -public static final void gdk_color_free(int /*long*/ color) { - lock.lock(); - try { - _gdk_color_free(color); - } finally { - lock.unlock(); - } -} /** * @method flags=dynamic * @param window cast=(GdkWindow *) @@ -3700,6 +3691,29 @@ public static final void gdk_cairo_set_source_window(int /*long*/ cairo, int /*l lock.unlock(); } } +/** @param color cast=(GdkColor *) */ +public static final native void _gdk_color_free(int /*long*/ color); +public static final void gdk_color_free(int /*long*/ color) { + lock.lock(); + try { + _gdk_color_free(color); + } finally { + lock.unlock(); + } +} +/** + * @param spec cast=(const gchar *) + * @param color cast=(GdkColor *),flags=no_in + */ +public static final native boolean _gdk_color_parse(byte[] spec, GdkColor color); +public static final boolean gdk_color_parse(byte[] spec, GdkColor color) { + lock.lock(); + try { + return _gdk_color_parse(spec, color); + } finally { + lock.unlock(); + } +} /** * @param colormap cast=(GdkColormap *) * @param color cast=(GdkColor *),flags=no_in @@ -6366,6 +6380,33 @@ public static final void gtk_color_selection_get_current_color(int /*long*/ colo } } /** + * @param str cast=(const gchar *) + * @param colors cast=(GdkColor **) + * @param n_colors cast=(gint *) + */ +public static final native void _gtk_color_selection_palette_from_string(byte[] str, int /*long*/ colors, int[] n_colors); +public static final void gtk_color_selection_palette_from_string(byte[] str, int /*long*/ colors, int[] n_colors) { + lock.lock(); + try { + _gtk_color_selection_palette_from_string(str, colors, n_colors); + } finally { + lock.unlock(); + } +} +/** + * @param colors cast=(GdkColor *) + * @param n_colors cast=(gint) + */ +public static final native int /*long*/ _gtk_color_selection_palette_to_string(int /*long*/ colors, int n_colors); +public static final int /*long*/ gtk_color_selection_palette_to_string(int /*long*/ colors, int n_colors) { + lock.lock(); + try { + return _gtk_color_selection_palette_to_string(colors, n_colors); + } finally { + lock.unlock(); + } +} +/** * @param colorsel cast=(GtkColorSelection *) * @param color cast=(GdkColor *),flags=no_out */ @@ -10008,6 +10049,21 @@ public static final int /*long*/ gtk_settings_get_default() { lock.unlock(); } } +/** + * @param settings cast=(GtkSettings *) + * @param name cast=(const gchar *) + * @param v_string cast=(const gchar *) + * @param origin cast=(const gchar *) + */ +public static final native void _gtk_settings_set_string_property(int /*long*/ settings, byte[] name, byte[] v_string, byte[] origin); +public static final void gtk_settings_set_string_property(int /*long*/ settings, byte[] name, byte[] v_string, byte[] origin) { + lock.lock(); + try { + _gtk_settings_set_string_property(settings, name, v_string, origin); + } finally { + lock.unlock(); + } +} /** @param selection_data cast=(GtkSelectionData *) */ public static final native void _gtk_selection_data_free(int /*long*/ selection_data); public static final void gtk_selection_data_free(int /*long*/ selection_data) { @@ -13768,6 +13824,12 @@ public static final native void memmove(int /*long*/ dest, GtkAdjustment src); * @param src cast=(const void *),flags=no_out * @param size cast=(size_t) */ +public static final native void memmove(int /*long*/ dest, GdkColor src, int /*long*/ size); +/** + * @param dest cast=(void *) + * @param src cast=(const void *),flags=no_out + * @param size cast=(size_t) + */ public static final native void memmove(int /*long*/ dest, GdkEventButton src, int /*long*/ size); /** * @param dest cast=(void *) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ColorDialog.java index 908cc57869..6810c32d96 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ColorDialog.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ColorDialog.java @@ -34,6 +34,7 @@ import org.eclipse.swt.internal.cocoa.*; */ public class ColorDialog extends Dialog { RGB rgb; + RGB [] rgbs; boolean selected; /** @@ -106,6 +107,19 @@ public RGB getRGB() { } /** + * Returns an array of <code>RGB</code>s which are the list of + * custom colors selected by the user in the receiver, or null + * if no custom colors were selected. + * + * @return the array of RGBs, which may be null + * + * @since 3.8 + */ +public RGB[] getRGBs() { + return rgbs; +} + +/** * Makes the receiver visible and brings it to the front * of the display. * @@ -127,6 +141,33 @@ public RGB open() { NSColor color = NSColor.colorWithDeviceRed(rgb.red / 255f, rgb.green / 255f, rgb.blue / 255f, 1); panel.setColor(color); } + NSString appName = Display.getApplicationName(); + NSColorList colorList = NSColorList.colorListNamed(appName); + if (colorList == null) { + colorList = (NSColorList)new NSColorList().alloc(); + colorList.initWithName(appName); + panel.attachColorList(colorList); + } else { + colorList.retain(); + } + if (rgbs != null) { + NSArray keys = colorList.allKeys(); + int length = keys.count(); + for (int i=length-1; i>=0; i--) { + colorList.removeColorWithKey(new NSString(keys.objectAtIndex(i))); + } + for (int i=0; i<rgbs.length; i++) { + RGB rgb = rgbs [i]; + if (rgb != null) { + NSColor color = NSColor.colorWithDeviceRed(rgb.red / 255f, rgb.green / 255f, rgb.blue / 255f, 1); + NSString key = appName; + if (i > 0) { + key = key.stringByAppendingString(NSString.stringWith(" "+i)); + } + colorList.insertColor(color, key, i); + } + } + } SWTPanelDelegate delegate = (SWTPanelDelegate)new SWTPanelDelegate().alloc().init(); int /*long*/ jniRef = OS.NewGlobalRef(this); if (jniRef == 0) SWT.error(SWT.ERROR_NO_HANDLES); @@ -148,6 +189,15 @@ public RGB open() { rgb = new RGB((int)(handle[0] * 255), (int)(handle[1] * 255), (int)(handle[2] * 255)); } } + NSArray keys = colorList.allKeys(); + int length = keys.count(); + rgbs = new RGB[length]; + for (int i=0; i<length; i++) { + NSString key = new NSString(keys.objectAtIndex(i)); + float /*double*/ [] handle = display.getNSColorRGB(colorList.colorWithKey(key)); + rgbs[i] = new RGB((int)(handle[0] * 255), (int)(handle[1] * 255), (int)(handle[2] * 255)); + } + colorList.release(); return rgb; } @@ -163,6 +213,19 @@ public void setRGB(RGB rgb) { this.rgb = rgb; } +/** + * Sets the receiver's list of custom colors to be the given array + * of <code>RGB</code>s, which may be null to let the platform select + * a default when open() is called. + * + * @param rgbs the array of RGBs, which may be null + * + * @since 3.8 + */ +public void setRGBs(RGB[] rgbs) { + this.rgbs = rgbs; +} + void windowWillClose(int /*long*/ id, int /*long*/ sel, int /*long*/ sender) { NSApplication.sharedApplication().stop(null); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java index 0a0c7357a6..4d18517410 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java @@ -35,6 +35,7 @@ import org.eclipse.swt.graphics.*; */ public class ColorDialog extends Dialog { RGB rgb; + RGB [] rgbs; /** * Constructs a new instance of this class given only its parent. * @@ -99,6 +100,18 @@ public RGB getRGB () { return rgb; } /** + * Returns an array of <code>RGB</code>s which are the list of + * custom colors selected by the user in the receiver, or null + * if no custom colors were selected. + * + * @return the array of RGBs, which may be null + * + * @since 3.8 + */ +public RGB[] getRGBs() { + return rgbs; +} +/** * Makes the receiver visible and brings it to the front * of the display. * @@ -139,6 +152,29 @@ public RGB open () { OS.gtk_color_selection_set_current_color (dialog.colorsel, color); } OS.gtk_color_selection_set_has_palette (dialog.colorsel, true); + if (rgbs != null) { + int /*long*/ colors = OS.g_malloc(GdkColor.sizeof * rgbs.length); + for (int i=0; i<rgbs.length; i++) { + RGB rgb = rgbs[i]; + if (rgb != null) { + color.red = (short)((rgb.red & 0xFF) | ((rgb.red & 0xFF) << 8)); + color.green = (short)((rgb.green & 0xFF) | ((rgb.green & 0xFF) << 8)); + color.blue = (short)((rgb.blue & 0xFF) | ((rgb.blue & 0xFF) << 8)); + OS.memmove (colors + i * GdkColor.sizeof, color, GdkColor.sizeof); + } + } + int /*long*/ strPtr = OS.gtk_color_selection_palette_to_string(colors, rgbs.length); + int length = OS.strlen (strPtr); + buffer = new byte [length]; + OS.memmove (buffer, strPtr, length); + String paletteString = new String (Converter.mbcsToWcs (null, buffer)); + buffer = Converter.wcsToMbcs (null, paletteString, true); + OS.g_free (colors); + int /*long*/ settings = OS.gtk_settings_get_default (); + if (settings != 0) { + OS.gtk_settings_set_string_property(settings, OS.gtk_color_palette, buffer, Converter.wcsToMbcs (null, "gtk_color_selection_palette_to_string", true)); + } + } display.addIdleProc (); Dialog oldModal = null; if (OS.gtk_window_get_modal (handle)) { @@ -173,6 +209,29 @@ public RGB open () { int blue = (color.blue >> 8) & 0xFF; rgb = new RGB (red, green, blue); } + int /*long*/ settings = OS.gtk_settings_get_default (); + if (settings != 0) { + int /*long*/ [] ptr = new int /*long*/ [1]; + OS.g_object_get (settings, OS.gtk_color_palette, ptr, 0); + if (ptr [0] != 0) { + int length = OS.strlen (ptr [0]); + buffer = new byte [length]; + OS.memmove (buffer, ptr [0], length); + OS.g_free (ptr [0]); + String [] gdkColorStrings = new String(Converter.mbcsToWcs (null, buffer)).split(":"); + length = length == 0 ? 0 : gdkColorStrings.length; + rgbs = new RGB [length]; + for (int i=0; i<length; i++) { + String colorString = gdkColorStrings[i]; + buffer = Converter.wcsToMbcs (null, colorString, true); + OS.gdk_color_parse(buffer, color); + int red = (color.red >> 8) & 0xFF; + int green = (color.green >> 8) & 0xFF; + int blue = (color.blue >> 8) & 0xFF; + rgbs [i] = new RGB (red, green, blue); + } + } + } display.removeIdleProc (); OS.gtk_widget_destroy (handle); if (!success) return null; @@ -189,4 +248,16 @@ public RGB open () { public void setRGB (RGB rgb) { this.rgb = rgb; } +/** + * Sets the receiver's list of custom colors to be the given array + * of <code>RGB</code>s. + * + * @param rgbs the array of RGBs, which may be null to let the platform + * select a default when open() is called + * + * @since 3.8 + */ +public void setRGBs(RGB[] rgbs) { + this.rgbs = rgbs; +} } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ColorDialog.java index e939e6242c..be00a74d7e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ColorDialog.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ColorDialog.java @@ -35,9 +35,12 @@ import org.eclipse.swt.graphics.*; */ public class ColorDialog extends Dialog { + static final int CUSTOM_COLOR_COUNT = 16; // from the MS spec for CHOOSECOLOR.lpCustColors Display display; int width, height; RGB rgb; + RGB [] rgbs; + int [] colors = new int [CUSTOM_COLOR_COUNT]; /** * Constructs a new instance of this class given only its parent. @@ -137,6 +140,19 @@ public RGB getRGB () { } /** + * Returns an array of <code>RGB</code>s which are the list of + * custom colors selected by the user in the receiver, or null + * if no custom colors were selected. + * + * @return the array of RGBs, which may be null + * + * @since 3.8 + */ +public RGB[] getRGBs() { + return rgbs; +} + +/** * Makes the receiver visible and brings it to the front * of the display. * @@ -188,11 +204,31 @@ public RGB open () { int /*long*/ lpfnHook = callback.getAddress (); if (lpfnHook == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS); - /* Allocate the Custom Colors */ + /* Allocate the Custom Colors and initialize to white */ display = parent.display; if (display.lpCustColors == 0) { int /*long*/ hHeap = OS.GetProcessHeap (); - display.lpCustColors = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, 16 * 4); + display.lpCustColors = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, CUSTOM_COLOR_COUNT * 4); + for (int i=0; i < CUSTOM_COLOR_COUNT; i++) { + colors[i] = 0x00FFFFFF; + } + OS.MoveMemory (display.lpCustColors, colors, CUSTOM_COLOR_COUNT * 4); + } + + /* Set the Custom Colors (if any) into the dialog */ + if (rgbs != null) { + int length = rgbs.length > CUSTOM_COLOR_COUNT ? CUSTOM_COLOR_COUNT : rgbs.length; + for (int i=0; i<length; i++) { + RGB rgb = rgbs [i]; + int red = rgb.red & 0xFF; + int green = (rgb.green << 8) & 0xFF00; + int blue = (rgb.blue << 16) & 0xFF0000; + colors[i] = red | green | blue; + } + for (int i=length; i < CUSTOM_COLOR_COUNT; i++) { + colors[i] = 0x00FFFFFF; + } + OS.MoveMemory (display.lpCustColors, colors, CUSTOM_COLOR_COUNT * 4); } /* Open the dialog */ @@ -226,6 +262,26 @@ public RGB open () { display.setModalDialog (oldModal); } + /* Get the Custom Colors (if the user defined any) from the dialog */ + boolean customColor = false; + OS.MoveMemory (colors, display.lpCustColors, colors.length * 4); + for (int i=0; i<colors.length; i++) { + if (colors[i] != 0x00FFFFFF) { + customColor = true; + break; + } + } + if (customColor) { + rgbs = new RGB [CUSTOM_COLOR_COUNT]; + for (int i=0; i<colors.length; i++) { + int color = colors[i]; + int red = color & 0xFF; + int green = (color >> 8) & 0xFF; + int blue = (color >> 16) & 0xFF; + rgbs[i] = new RGB (red, green, blue); + } + } + if (success) { int red = lpcc.rgbResult & 0xFF; int green = (lpcc.rgbResult >> 8) & 0xFF; @@ -277,4 +333,26 @@ public void setRGB (RGB rgb) { this.rgb = rgb; } +/** + * Sets the receiver's list of custom colors to be the given array + * of <code>RGB</code>s, which may be null to let the platform select + * a default when open() is called. + * + * @param rgbs the array of RGBs, which may be null + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_INVALID_ARGUMENT - if an RGB in the rgbs array is null</li> + * </ul> + * + * @since 3.8 + */ +public void setRGBs(RGB[] rgbs) { + if (rgbs != null) { + for (int i=0; i<rgbs.length; i++) { + if (rgbs [i] == null) error (SWT.ERROR_INVALID_ARGUMENT); + } + } + this.rgbs = rgbs; } + +}
\ No newline at end of file diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/DialogTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/DialogTab.java index f3a33e39e7..033bb2a72f 100644 --- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/DialogTab.java +++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/DialogTab.java @@ -37,6 +37,7 @@ class DialogTab extends Tab { Button effectsVisibleButton, usePreviousResultButton; Button saveButton, openButton, multiButton; RGB colorDialogResult, fontDialogColorResult; + RGB[] colorDialogCustomColors; String directoryDialogResult; String fileDialogResult; int fileDialogIndexResult; @@ -131,13 +132,23 @@ class DialogTab extends Tab { ColorDialog dialog = new ColorDialog (shell ,style); if (usePreviousResultButton.getSelection()) { dialog.setRGB (colorDialogResult); + dialog.setRGBs(colorDialogCustomColors); } dialog.setText (ControlExample.getResourceString("Title")); RGB result = dialog.open (); textWidget.append (ControlExample.getResourceString("ColorDialog") + Text.DELIMITER); textWidget.append (ControlExample.getResourceString("Result", new String [] {"" + result}) + Text.DELIMITER); - textWidget.append ("getRGB() = " + dialog.getRGB() + Text.DELIMITER + Text.DELIMITER); + textWidget.append ("getRGB() = " + dialog.getRGB() + Text.DELIMITER); + textWidget.append ("getRGBs() =" + Text.DELIMITER); + RGB[] rgbs = dialog.getRGBs(); + if (rgbs != null) { + for (int i=0; i<rgbs.length; i++) { + textWidget.append ("\t" + rgbs [i] + Text.DELIMITER); + } + } + textWidget.append (Text.DELIMITER); colorDialogResult = result; + colorDialogCustomColors = rgbs; return; } |