diff options
author | Steve Northover <steve> | 2002-03-16 21:06:28 +0000 |
---|---|---|
committer | Steve Northover <steve> | 2002-03-16 21:06:28 +0000 |
commit | 21892980b713722b00fd37f2cf57ebee1e87ffdb (patch) | |
tree | b625444ff13423e2d023f1b3e4b3ee0db162d2a1 | |
parent | 0a0d68ccc965d964425467b0f4596a46bebec755 (diff) | |
download | eclipse.platform.swt-21892980b713722b00fd37f2cf57ebee1e87ffdb.tar.gz eclipse.platform.swt-21892980b713722b00fd37f2cf57ebee1e87ffdb.tar.xz eclipse.platform.swt-21892980b713722b00fd37f2cf57ebee1e87ffdb.zip |
*** empty log message ***
9 files changed, 92 insertions, 79 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkcontrols.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkcontrols.c index ec8f9504fd..0bd2258603 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkcontrols.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkcontrols.c @@ -485,4 +485,49 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1hseparator_1new return (jint)gtk_hseparator_new(); } +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1label_1set_1text_1with_1mnemonic + (JNIEnv *env, jclass that, jint label, jbyteArray str) +{ + jbyte *str1 = NULL; +#ifdef DEBUG_CALL_PRINTS + fprintf(stderr, "gtk_label_set_text_with_mnemonic"); +#endif + + if (str) { + str1 = (*env)->GetByteArrayElements(env, str, NULL); + } + gtk_label_set_text_with_mnemonic((GtkLabel*)label, (gchar*)str1); + if (str) { + (*env)->ReleaseByteArrayElements(env, str, str1, 0); + } +} + +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1label_1new_1with_1mnemonic + (JNIEnv *env, jclass that, jbyteArray str) +{ + jbyte *str1 = NULL; + GtkWidget * result; +#ifdef DEBUG_CALL_PRINTS + fprintf(stderr, "gtk_label_new_with_mnemonic"); +#endif + + if (str) { + str1 = (*env)->GetByteArrayElements(env, str, NULL); + } + result = gtk_label_new_with_mnemonic((gchar*)str1); + if (str) { + (*env)->ReleaseByteArrayElements(env, str, str1, 0); + } + return (jint) result; +} + + +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1frame_1get_1label_1widget + (JNIEnv *env, jclass that, jint frame) +{ +#ifdef DEBUG_CALL_PRINTS + fprintf(stderr, "gtk_frame_get_label_widget"); +#endif + return (jint)gtk_frame_get_label_widget((GtkFrame*)frame); +} 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 0466c69aaf..912d38f28a 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 @@ -772,4 +772,7 @@ public static final native void gdk_window_process_all_updates(); public static final native void gdk_window_process_updates(int window, boolean update_children); //public static final native boolean gtk_widget_translate_coordinates(int src_widget, int dest_widget, int src_x, int src_y, int [] dest_x, int [] dest_y); +public static final native void gtk_label_set_text_with_mnemonic(int label, byte[] str); +public static final native int gtk_label_new_with_mnemonic(byte[] str); +public static final native int gtk_frame_get_label_widget(int frame); } 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 514ceb9819..3b62919112 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 @@ -439,34 +439,19 @@ public void setText (String string) { if ((style & SWT.ARROW) != 0) return; int length = string.length (); char [] text = new char [length + 1]; - char [] pattern = new char [length + 1]; string.getChars (0, length, text, 0); - int i = 0, j = 0; - while (i < length) { - pattern [j] = ' '; - if (text [i] == '&') { - i++; - if (i < length && text [i] != '&') { - pattern [j] = '_'; - } - } - text [j++] = text [i++]; - } - while (j < i) { - text [j] = pattern [j] = '\0'; - j++; + for (int i=0; i<length; i++) { + if (text [i] == '&') text [i] = '_'; } int list = OS.gtk_container_children (handle); if (list != 0) { int widget = OS.g_list_nth_data (list, 0); if (widget != 0) OS.gtk_widget_destroy (widget); } - /* FIXME - accels */ - int label = OS.gtk_label_new (string); -/* byte [] buffer2 = Converter.wcsToMbcs (null, pattern); - OS.gtk_label_set_pattern (label, buffer2);*/ + byte [] buffer = Converter.wcsToMbcs (null, text); + int label = OS.gtk_label_new_with_mnemonic (buffer); OS.gtk_container_add (handle, label); - OS.gtk_widget_show (label); + OS.gtk_widget_show (label); } int processSelection (int int0, int int1, int int2) { 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 4aaa0ff0fd..48550f2e11 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 @@ -233,8 +233,16 @@ public String getText () { public void setText (String string) { checkWidget(); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); - OS.gtk_frame_set_label (frameHandle, string2bytesConvertMnemonic(string)); - text=string; + text = string; + int length = string.length (); + char [] text = new char [length + 1]; + string.getChars (0, length, text, 0); + for (int i=0; i<length; i++) { + if (text [i] == '&') text [i] = '_'; + } + int label = OS.gtk_frame_get_label_widget (frameHandle); + byte [] buffer = Converter.wcsToMbcs (null, text); + OS.gtk_label_set_text_with_mnemonic (label, buffer); } } 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 93f70839f5..f8a467f80c 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 @@ -342,7 +342,14 @@ public void setText (String string) { break; } } - OS.gtk_label_parse_uline (handle, string2bytesConvertMnemonic(string)); + int length = string.length (); + char [] text = new char [length + 1]; + string.getChars (0, length, text, 0); + for (int i=0; i<length; i++) { + if (text [i] == '&') text [i] = '_'; + } + byte [] buffer = Converter.wcsToMbcs (null, text); + OS.gtk_label_set_text_with_mnemonic (handle, buffer); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java index 44306c6006..2a77a476d8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java @@ -590,34 +590,18 @@ public void setText (String string) { checkWidget();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
if ((style & SWT.SEPARATOR) != 0) return;
- text = string;
- if ((style & SWT.ARROW) != 0) return;
+ super.setText (string);
int length = string.length ();
- int index = string.indexOf('\t');
+ int index = string.indexOf ('\t');
if (index != -1) length = index;
char [] text = new char [length + 1];
- char [] pattern = new char [length + 1];
string.getChars (0, length, text, 0);
- int i = 0, j = 0;
- while (i < length) {
- pattern [j] = ' ';
- if (text [i] == '&') {
- i++;
- if (i < length && text [i] != '&') {
- pattern [j] = '_';
- }
- }
- text [j++] = text [i++];
- }
- while (j < i) {
- text [j] = pattern [j] = '\0';
- j++;
+ for (int i=0; i<length; i++) {
+ if (text [i] == '&') text [i] = '_';
}
int list = OS.gtk_container_children (handle);
int label = OS.g_list_nth_data (list, 0);
- byte [] buffer1 = Converter.wcsToMbcs (null, text);
- OS.gtk_label_set_text (label, buffer1);
- byte [] buffer2 = Converter.wcsToMbcs (null, pattern);
- OS.gtk_label_set_pattern (label, buffer2);
+ byte [] buffer = Converter.wcsToMbcs (null, text);
+ OS.gtk_label_set_text_with_mnemonic (label, buffer);
}
}
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 8454cc3d3b..ac67526950 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 @@ -193,12 +193,17 @@ public void setImage (Image image) { super.setImage (image);
}
public void setText (String string) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
super.setText (string);
- byte [] buffer = string2bytesConvertMnemonic(string);
- OS.gtk_label_parse_uline(handle, buffer);
+ int length = string.length ();
+ char [] text = new char [length + 1];
+ string.getChars (0, length, text, 0);
+ for (int i=0; i<length; i++) {
+ if (text [i] == '&') text [i] = '_';
+ }
+ byte [] buffer = Converter.wcsToMbcs (null, text);
+ OS.gtk_label_set_text_with_mnemonic (handle, buffer);
}
/** * Sets the receiver's tool tip text to the argument, which 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 8d8c8409c0..fdb41d18fe 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 @@ -635,37 +635,22 @@ public void setText (String string) { checkWidget(); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); if ((style & SWT.SEPARATOR) != 0) return; - text = string; - if ((style & SWT.ARROW) != 0) return; + super.setText (string); int length = string.length (); char [] text = new char [length + 1]; - char [] pattern = new char [length + 1]; string.getChars (0, length, text, 0); - int i = 0, j = 0; - while (i < length) { - pattern [j] = ' '; - if (text [i] == '&') { - i++; - if (i < length && text [i] != '&') { - pattern [j] = '_'; - } - } - text [j++] = text [i++]; - } - while (j < i) { - text [j] = pattern [j] = '\0'; - j++; + for (int i=0; i<length; i++) { + if (text [i] == '&') text [i] = '_'; } int list = OS.gtk_container_children (handle); if (list != 0) { int widget = OS.g_list_nth_data (list, 0); if (widget != 0) OS.gtk_widget_destroy (widget); } - int label = OS.gtk_label_new (string); - byte [] buffer2 = Converter.wcsToMbcs (null, pattern); - OS.gtk_label_set_pattern (label, buffer2); + byte [] buffer = Converter.wcsToMbcs (null, text); + int label = OS.gtk_label_new_with_mnemonic (buffer); OS.gtk_container_add (handle, label); - OS.gtk_widget_show (label); + OS.gtk_widget_show (label); } /** * Sets the receiver's tool tip text to the argument, which 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 1a8997a702..be276ebc48 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 @@ -911,13 +911,4 @@ char wcsToMbcs (char ch) { } return 0; } - -byte[] string2bytesConvertMnemonic(String string) { - //FIXME need to double _'s - char [] t = new char [string.length ()]; - string.getChars (0, t.length, t, 0); - for (int i=0; i<t.length; i++) {if (t [i] == '&') t [i] = '_';} - return Converter.wcsToMbcs (null, t, true); -} - } |