diff options
author | Felipe Heidrich <fheidric> | 2003-09-16 22:00:31 +0000 |
---|---|---|
committer | Felipe Heidrich <fheidric> | 2003-09-16 22:00:31 +0000 |
commit | 64eb7bcf81fabc4643beca7e0425a46fe5719d4d (patch) | |
tree | 22beb0e6bbea62439307104b268b1a55843f7482 | |
parent | d7699aef0279f3be5923cf02ea522a19c71c33db (diff) | |
download | eclipse.platform.swt-64eb7bcf81fabc4643beca7e0425a46fe5719d4d.tar.gz eclipse.platform.swt-64eb7bcf81fabc4643beca7e0425a46fe5719d4d.tar.xz eclipse.platform.swt-64eb7bcf81fabc4643beca7e0425a46fe5719d4d.zip |
backport 43125 (part of 42426)
14 files changed, 375 insertions, 7 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.c index 66d3499162..a1c161ae9c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.c @@ -343,6 +343,73 @@ void setCHOOSEFONTFields(JNIEnv *env, jobject lpObject, CHOOSEFONT *lpStruct) } #endif /* NO_CHOOSEFONT */ +#ifndef NO_COMBOBOXINFO +typedef struct COMBOBOXINFO_FID_CACHE { + int cached; + jclass clazz; + jfieldID cbSize, itemLeft, itemTop, itemRight, itemBottom, buttonLeft, buttonTop, buttonRight, buttonBottom, stateButton, hwndCombo, hwndItem, hwndList; +} COMBOBOXINFO_FID_CACHE; + +COMBOBOXINFO_FID_CACHE COMBOBOXINFOFc; + +void cacheCOMBOBOXINFOFields(JNIEnv *env, jobject lpObject) +{ + if (COMBOBOXINFOFc.cached) return; + COMBOBOXINFOFc.clazz = (*env)->GetObjectClass(env, lpObject); + COMBOBOXINFOFc.cbSize = (*env)->GetFieldID(env, COMBOBOXINFOFc.clazz, "cbSize", "I"); + COMBOBOXINFOFc.itemLeft = (*env)->GetFieldID(env, COMBOBOXINFOFc.clazz, "itemLeft", "I"); + COMBOBOXINFOFc.itemTop = (*env)->GetFieldID(env, COMBOBOXINFOFc.clazz, "itemTop", "I"); + COMBOBOXINFOFc.itemRight = (*env)->GetFieldID(env, COMBOBOXINFOFc.clazz, "itemRight", "I"); + COMBOBOXINFOFc.itemBottom = (*env)->GetFieldID(env, COMBOBOXINFOFc.clazz, "itemBottom", "I"); + COMBOBOXINFOFc.buttonLeft = (*env)->GetFieldID(env, COMBOBOXINFOFc.clazz, "buttonLeft", "I"); + COMBOBOXINFOFc.buttonTop = (*env)->GetFieldID(env, COMBOBOXINFOFc.clazz, "buttonTop", "I"); + COMBOBOXINFOFc.buttonRight = (*env)->GetFieldID(env, COMBOBOXINFOFc.clazz, "buttonRight", "I"); + COMBOBOXINFOFc.buttonBottom = (*env)->GetFieldID(env, COMBOBOXINFOFc.clazz, "buttonBottom", "I"); + COMBOBOXINFOFc.stateButton = (*env)->GetFieldID(env, COMBOBOXINFOFc.clazz, "stateButton", "I"); + COMBOBOXINFOFc.hwndCombo = (*env)->GetFieldID(env, COMBOBOXINFOFc.clazz, "hwndCombo", "I"); + COMBOBOXINFOFc.hwndItem = (*env)->GetFieldID(env, COMBOBOXINFOFc.clazz, "hwndItem", "I"); + COMBOBOXINFOFc.hwndList = (*env)->GetFieldID(env, COMBOBOXINFOFc.clazz, "hwndList", "I"); + COMBOBOXINFOFc.cached = 1; +} + +COMBOBOXINFO *getCOMBOBOXINFOFields(JNIEnv *env, jobject lpObject, COMBOBOXINFO *lpStruct) +{ + if (!COMBOBOXINFOFc.cached) cacheCOMBOBOXINFOFields(env, lpObject); + lpStruct->cbSize = (*env)->GetIntField(env, lpObject, COMBOBOXINFOFc.cbSize); + lpStruct->rcItem.left = (*env)->GetIntField(env, lpObject, COMBOBOXINFOFc.itemLeft); + lpStruct->rcItem.top = (*env)->GetIntField(env, lpObject, COMBOBOXINFOFc.itemTop); + lpStruct->rcItem.right = (*env)->GetIntField(env, lpObject, COMBOBOXINFOFc.itemRight); + lpStruct->rcItem.bottom = (*env)->GetIntField(env, lpObject, COMBOBOXINFOFc.itemBottom); + lpStruct->rcButton.left = (*env)->GetIntField(env, lpObject, COMBOBOXINFOFc.buttonLeft); + lpStruct->rcButton.top = (*env)->GetIntField(env, lpObject, COMBOBOXINFOFc.buttonTop); + lpStruct->rcButton.right = (*env)->GetIntField(env, lpObject, COMBOBOXINFOFc.buttonRight); + lpStruct->rcButton.bottom = (*env)->GetIntField(env, lpObject, COMBOBOXINFOFc.buttonBottom); + lpStruct->stateButton = (*env)->GetIntField(env, lpObject, COMBOBOXINFOFc.stateButton); + lpStruct->hwndCombo = (HWND)(*env)->GetIntField(env, lpObject, COMBOBOXINFOFc.hwndCombo); + lpStruct->hwndItem = (HWND)(*env)->GetIntField(env, lpObject, COMBOBOXINFOFc.hwndItem); + lpStruct->hwndList = (HWND)(*env)->GetIntField(env, lpObject, COMBOBOXINFOFc.hwndList); + return lpStruct; +} + +void setCOMBOBOXINFOFields(JNIEnv *env, jobject lpObject, COMBOBOXINFO *lpStruct) +{ + if (!COMBOBOXINFOFc.cached) cacheCOMBOBOXINFOFields(env, lpObject); + (*env)->SetIntField(env, lpObject, COMBOBOXINFOFc.cbSize, (jint)lpStruct->cbSize); + (*env)->SetIntField(env, lpObject, COMBOBOXINFOFc.itemLeft, (jint)lpStruct->rcItem.left); + (*env)->SetIntField(env, lpObject, COMBOBOXINFOFc.itemTop, (jint)lpStruct->rcItem.top); + (*env)->SetIntField(env, lpObject, COMBOBOXINFOFc.itemRight, (jint)lpStruct->rcItem.right); + (*env)->SetIntField(env, lpObject, COMBOBOXINFOFc.itemBottom, (jint)lpStruct->rcItem.bottom); + (*env)->SetIntField(env, lpObject, COMBOBOXINFOFc.buttonLeft, (jint)lpStruct->rcButton.left); + (*env)->SetIntField(env, lpObject, COMBOBOXINFOFc.buttonTop, (jint)lpStruct->rcButton.top); + (*env)->SetIntField(env, lpObject, COMBOBOXINFOFc.buttonRight, (jint)lpStruct->rcButton.right); + (*env)->SetIntField(env, lpObject, COMBOBOXINFOFc.buttonBottom, (jint)lpStruct->rcButton.bottom); + (*env)->SetIntField(env, lpObject, COMBOBOXINFOFc.stateButton, (jint)lpStruct->stateButton); + (*env)->SetIntField(env, lpObject, COMBOBOXINFOFc.hwndCombo, (jint)lpStruct->hwndCombo); + (*env)->SetIntField(env, lpObject, COMBOBOXINFOFc.hwndItem, (jint)lpStruct->hwndItem); + (*env)->SetIntField(env, lpObject, COMBOBOXINFOFc.hwndList, (jint)lpStruct->hwndList); +} +#endif + #ifndef NO_COMPOSITIONFORM typedef struct COMPOSITIONFORM_FID_CACHE { int cached; diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.h index c9467dc1c8..0be97920d1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.h @@ -56,6 +56,7 @@ #ifdef _WIN32_WCE #define NO_BROWSEINFO #define NO_CHOOSEFONT +#define NO_COMBOBOXINFO #define NO_DOCINFO #define NO_GCP_RESULTS #define NO_GRADIENT_RECT @@ -152,6 +153,14 @@ void setCHOOSEFONTFields(JNIEnv *env, jobject lpObject, CHOOSEFONT *lpStruct); #define setCHOOSEFONTFields(a,b,c) #endif /* NO_CHOOSEFONT */ +#ifndef NO_COMBOBOXINFO +COMBOBOXINFO *getCOMBOBOXINFOFields(JNIEnv *env, jobject lpObject, COMBOBOXINFO *lpStruct); +void setCOMBOBOXINFOFields(JNIEnv *env, jobject lpObject, COMBOBOXINFO *lpStruct); +#else +#define getCOMBOBOXINFOFields(a,b,c) NULL +#define setCOMBOBOXINFOFields(a,b,c) +#endif + #ifndef NO_COMPOSITIONFORM COMPOSITIONFORM *getCOMPOSITIONFORMFields(JNIEnv *env, jobject lpObject, COMPOSITIONFORM *lpStruct); void setCOMPOSITIONFORMFields(JNIEnv *env, jobject lpObject, COMPOSITIONFORM *lpStruct); diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c index 81f10b0a56..9ca13a3cc5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c @@ -64,6 +64,7 @@ #define NO_GetCharacterPlacementW #define NO_GetClassInfoA #define NO_GetClipboardFormatNameA +#define NO_GetComboBoxInfo #define NO_GetDIBColorTable #define NO_GetDIBits #define NO_GetFontLanguageInfo @@ -2001,6 +2002,22 @@ JNIEXPORT jint JNICALL OS_NATIVE(GetClipboardFormatNameW) } #endif /* NO_GetClipboardFormatNameW */ +#ifndef NO_GetComboBoxInfo +JNIEXPORT jboolean JNICALL OS_NATIVE(GetComboBoxInfo) + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + COMBOBOXINFO _arg1, *lparg1=NULL; + jboolean rc; + + DEBUG_CALL("GetComboBoxInfo\n\n") + + if (arg1) lparg1 = getCOMBOBOXINFOFields(env, arg1, &_arg1); + rc = (jboolean)GetComboBoxInfo((HWND)arg0, lparg1); + if (arg1) setCOMBOBOXINFOFields(env, arg1, lparg1); + return rc; +} +#endif + #ifndef NO_GetCurrentObject JNIEXPORT jint JNICALL OS_NATIVE(GetCurrentObject) (JNIEnv *env, jclass that, jint arg0, jint arg1) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java index 5680bcedcd..51f060718b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java @@ -2068,6 +2068,7 @@ public static final native int GetClipboardFormatNameA (int format, byte[] lpszF public static final native int GetClipboardFormatNameW (int format, char[] lpszFormatName, int cchMaxCount); public static final native int GetClipBox (int hdc, RECT lprc); public static final native int GetClipRgn (int hdc, int hrgn); +public static final native boolean GetComboBoxInfo (int hwndCombo, COMBOBOXINFO pcbi); public static final native int GetCurrentObject (int hdc, int uObjectType); public static final native int GetCurrentProcessId (); public static final native int GetCurrentThreadId (); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Combo.java index d633ecbb0f..70d9c4c34d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Combo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Combo.java @@ -1267,6 +1267,25 @@ public void setItems (String [] items) { } /** + * Sets the orientation of the receiver, which must be one + * of the constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.LEFT_TO_RIGHT</code>. + * <p> + * + * @param orientation new orientation bit + * @return <code>true</code> if the orientation was changed and <code>false</code> otherwise. + * + * @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 2.1.2 + */ +public boolean setOrientation (int orientation) { + return false; +} + +/** * Sets the selection in the receiver's text field to the * range specified by the argument whose x coordinate is the * start of the selection and whose y coordinate is the end diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Text.java index d31fc19fc4..aeadeef919 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Text.java @@ -1219,6 +1219,25 @@ void setFontStyle (Font font) { } /** + * Sets the orientation of the receiver, which must be one + * of the constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.LEFT_TO_RIGHT</code>. + * <p> + * + * @param orientation new orientation bit + * @return <code>true</code> if the orientation was changed and <code>false</code> otherwise. + * + * @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 2.1.2 + */ +public boolean setOrientation (int orientation) { + return false; +} + +/** * Sets the selection. * <p> * Indexing is zero based. The range of 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 6b4cb845f8..ecc0809ddb 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 @@ -1095,6 +1095,25 @@ void setItems (String [] items, boolean keepText, boolean keepSelection) { } /** + * Sets the orientation of the receiver, which must be one + * of the constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.LEFT_TO_RIGHT</code>. + * <p> + * + * @param orientation new orientation bit + * @return <code>true</code> if the orientation was changed and <code>false</code> otherwise. + * + * @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 2.1.2 + */ +public boolean setOrientation (int orientation) { + return false; +} + +/** * Sets the selection in the receiver's text field to the * range specified by the argument whose x coordinate is the * start of the selection and whose y coordinate is the end 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 6b25560a11..ff52cc34c0 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 @@ -1167,6 +1167,25 @@ void setForegroundColor (GdkColor color) { } /** + * Sets the orientation of the receiver, which must be one + * of the constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.LEFT_TO_RIGHT</code>. + * <p> + * + * @param orientation new orientation bit + * @return <code>true</code> if the orientation was changed and <code>false</code> otherwise. + * + * @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 2.1.2 + */ +public boolean setOrientation (int orientation) { + return false; +} + +/** * Sets the selection. * <p> * Indexing is zero based. The range of diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java index d856e9e1f0..352ddae8b9 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java @@ -1241,6 +1241,24 @@ public void setItems (String [] items) { OS.XtSetValues (argList3 [1], argList4, argList4.length / 2); } /** + * Sets the orientation of the receiver, which must be one + * of the constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.LEFT_TO_RIGHT</code>. + * <p> + * + * @param orientation new orientation bit + * @return <code>true</code> if the orientation was changed and <code>false</code> otherwise. + * + * @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 2.1.2 + */ +public boolean setOrientation (int orientation) { + return false; +} +/** * Sets the selection in the receiver's text field to the * range specified by the argument whose x coordinate is the * start of the selection and whose y coordinate is the end diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java index 38d4e1ea4b..a25469dfcb 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java @@ -1171,6 +1171,24 @@ public void setEditable (boolean editable) { int [] argList = {OS.XmNcursorPositionVisible, editable && hasFocus () ? 1 : 0}; OS.XtSetValues (handle, argList, argList.length / 2); } +/** + * Sets the orientation of the receiver, which must be one + * of the constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.LEFT_TO_RIGHT</code>. + * <p> + * + * @param orientation new orientation bit + * @return <code>true</code> if the orientation was changed and <code>false</code> otherwise. + * + * @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 2.1.2 + */ +public boolean setOrientation (int orientation) { + return false; +} public void setRedraw (boolean redraw) { checkWidget(); if ((style & SWT.SINGLE) != 0) return; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java index 04da0c8fb4..cd5aea45b3 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java @@ -1123,6 +1123,25 @@ public void setItems (String [] items) { } /** + * Sets the orientation of the receiver, which must be one + * of the constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.LEFT_TO_RIGHT</code>. + * <p> + * + * @param orientation new orientation bit + * @return <code>true</code> if the orientation was changed and <code>false</code> otherwise. + * + * @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 2.1.2 + */ +public boolean setOrientation (int orientation) { + return false; +} + +/** * Sets the selection in the receiver's text field to the * range specified by the argument whose x coordinate is the * start of the selection and whose y coordinate is the end diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java index 9e486e77cc..7c668729dd 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java @@ -1161,6 +1161,25 @@ public void setFont (Font font) { } /** + * Sets the orientation of the receiver, which must be one + * of the constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.LEFT_TO_RIGHT</code>. + * <p> + * + * @param orientation new orientation bit + * @return <code>true</code> if the orientation was changed and <code>false</code> otherwise. + * + * @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 2.1.2 + */ +public boolean setOrientation (int orientation) { + return false; +} + +/** * Sets the selection. * <p> * Indexing is zero based. The range of diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java index 6cbec3531a..9e41e9a836 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java @@ -1140,6 +1140,88 @@ public void setItems (String [] items) { } /** + * Sets the orientation of the receiver, which must be one + * of the constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.LEFT_TO_RIGHT</code>. + * <p> + * + * @param orientation new orientation bit + * @return <code>true</code> if the orientation was changed and <code>false</code> otherwise. + * + * @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 2.1.2 + */ +public boolean setOrientation (int orientation) { + checkWidget(); + if (OS.IsWinCE) return false; + if ((OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10)) return false; + int flags = SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT; + if ((orientation & flags) == 0 || (orientation & flags) == flags) return false; + style &= ~flags; + style |= orientation & flags; + int bits = OS.GetWindowLong (handle, OS.GWL_EXSTYLE); + if ((style & SWT.RIGHT_TO_LEFT) != 0) { + style |= SWT.MIRRORED; + bits |= OS.WS_EX_LAYOUTRTL; + } else { + style &= ~SWT.MIRRORED; + bits &= ~OS.WS_EX_LAYOUTRTL; + } + OS.SetWindowLong (handle, OS.GWL_EXSTYLE, bits); + int hwndText = 0, hwndList = 0; + COMBOBOXINFO pcbi = new COMBOBOXINFO (); + pcbi.cbSize = COMBOBOXINFO.sizeof; + if (OS.GetComboBoxInfo (handle, pcbi)) { + hwndText = pcbi.hwndItem; + hwndList = pcbi.hwndList; + } + if (hwndText != 0) { + int bits0 = OS.GetWindowLong (hwndText, OS.GWL_EXSTYLE); + int bits1 = OS.GetWindowLong (hwndText, OS.GWL_STYLE); + if ((style & SWT.RIGHT_TO_LEFT) != 0) { + bits0 |= OS.WS_EX_RIGHT | OS.WS_EX_RTLREADING; + bits1 |= OS.ES_RIGHT; + } else { + bits0 &= ~(OS.WS_EX_RIGHT | OS.WS_EX_RTLREADING); + bits1 &= ~OS.ES_RIGHT; + } + OS.SetWindowLong (hwndText, OS.GWL_EXSTYLE, bits0); + OS.SetWindowLong (hwndText, OS.GWL_STYLE, bits1); + + /* + * Bug in Windows. For some reason, the single line text field + * portion of the combo box does not redraw to reflect the new + * style bits. The fix is to force the widget to be resized by + * temporarily shrinking and then growing the width and height. + */ + RECT rect = new RECT (); + OS.GetWindowRect (hwndText, rect); + int width = rect.right - rect.left, height = rect.bottom - rect.top; + OS.GetWindowRect (handle, rect); + int widthCombo = rect.right - rect.left, heightCombo = rect.bottom - rect.top; + int uFlags = OS.SWP_NOMOVE | OS.SWP_NOZORDER | OS.SWP_NOACTIVATE; + OS.SetWindowPos (hwndText, 0, 0, 0, width - 1, height - 1, uFlags); + OS.SetWindowPos (handle, 0, 0, 0, widthCombo - 1, heightCombo - 1, uFlags); + OS.SetWindowPos (hwndText, 0, 0, 0, width, height, uFlags); + OS.SetWindowPos (handle, 0, 0, 0, widthCombo, heightCombo, uFlags); + OS.InvalidateRect (handle, null, true); + } + if (hwndList != 0) { + int exStyle = OS.GetWindowLong (hwndList, OS.GWL_EXSTYLE); + if ((style & SWT.RIGHT_TO_LEFT) != 0) { + exStyle |= OS.WS_EX_LAYOUTRTL; + } else { + exStyle &= ~OS.WS_EX_LAYOUTRTL; + } + OS.SetWindowLong (hwndList, OS.GWL_EXSTYLE, exStyle); + } + return true; +} + +/** * Sets the selection in the receiver's text field to the * range specified by the argument whose x coordinate is the * start of the selection and whose y coordinate is the end diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java index e60bcfa09b..9c7e319fb7 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java @@ -377,23 +377,32 @@ void fixAlignment () { * according to the orientation and mirroring. */ if ((style & SWT.MIRRORED) != 0) return; - int bits = OS.GetWindowLong (handle, OS.GWL_EXSTYLE); + int bits0 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE); + int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE); if ((style & SWT.LEFT_TO_RIGHT) != 0) { if ((style & SWT.RIGHT) != 0) { - bits |= OS.WS_EX_RIGHT; + bits0 |= OS.WS_EX_RIGHT; + bits1 |= OS.ES_RIGHT; } if ((style & SWT.LEFT) != 0) { - bits &=~ OS.WS_EX_RIGHT; + bits0 &= ~OS.WS_EX_RIGHT; + bits1 &= ~OS.ES_RIGHT; } } else { if ((style & SWT.RIGHT) != 0) { - bits &=~ OS.WS_EX_RIGHT; + bits0 &= ~OS.WS_EX_RIGHT; + bits1 &= ~OS.ES_RIGHT; } if ((style & SWT.LEFT) != 0) { - bits |= OS.WS_EX_RIGHT; + bits0 |= OS.WS_EX_RIGHT; + bits1 |= OS.ES_RIGHT; } } - OS.SetWindowLong (handle, OS.GWL_EXSTYLE, bits); + if ((style & SWT.CENTER) != 0) { + bits1 |= OS.ES_CENTER; + } + OS.SetWindowLong (handle, OS.GWL_EXSTYLE, bits0); + OS.SetWindowLong (handle, OS.GWL_STYLE, bits1); } /** @@ -1223,6 +1232,40 @@ public void setFont (Font font) { } /** + * Sets the orientation of the receiver, which must be one + * of the constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.LEFT_TO_RIGHT</code>. + * <p> + * + * @param orientation new orientation bit + * @return <code>true</code> if the orientation was changed and <code>false</code> otherwise. + * + * @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 2.1.2 + */ +public boolean setOrientation (int orientation) { + checkWidget(); + if (OS.IsWinCE) return false; + if ((OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10)) return false; + int flags = SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT; + if ((orientation & flags) == 0 || (orientation & flags) == flags) return false; + style &= ~flags; + style |= orientation & flags; + int bits = OS.GetWindowLong (handle, OS.GWL_EXSTYLE); + if ((style & SWT.RIGHT_TO_LEFT) != 0) { + bits |= OS.WS_EX_RTLREADING | OS.WS_EX_LEFTSCROLLBAR; + } else { + bits &= ~(OS.WS_EX_RTLREADING | OS.WS_EX_LEFTSCROLLBAR); + } + OS.SetWindowLong (handle, OS.GWL_EXSTYLE, bits); + fixAlignment (); + return true; +} + +/** * Sets the selection. * <p> * Indexing is zero based. The range of @@ -1560,7 +1603,6 @@ int wcsToMbcsPos (int wcsPos) { int widgetStyle () { int bits = super.widgetStyle (); if ((style & SWT.CENTER) != 0) bits |= OS.ES_CENTER; - if ((style & SWT.RIGHT) != 0) bits |= OS.ES_RIGHT; if ((style & SWT.READ_ONLY) != 0) bits |= OS.ES_READONLY; if ((style & SWT.SINGLE) != 0) return bits | OS.ES_AUTOHSCROLL; bits |= OS.ES_MULTILINE | OS.ES_AUTOHSCROLL | OS.ES_NOHIDESEL; |