summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Northover <steve>2004-12-10 22:59:52 +0000
committerSteve Northover <steve>2004-12-10 22:59:52 +0000
commitdf1e25507d722829f9fa73ba90d53bc5c9fda6d8 (patch)
tree0e6ed0871685ea2777c0d91ceca7c82ba99069b1
parentfca875eb72108e60782c178db548975d58286f47 (diff)
downloadeclipse.platform.swt-df1e25507d722829f9fa73ba90d53bc5c9fda6d8.tar.gz
eclipse.platform.swt-df1e25507d722829f9fa73ba90d53bc5c9fda6d8.tar.xz
eclipse.platform.swt-df1e25507d722829f9fa73ba90d53bc5c9fda6d8.zip
& always causes '...', mnemonics don't work in header anyways
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java14
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java19
2 files changed, 23 insertions, 10 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java
index 27a929b7bb..0b72d75438 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java
@@ -467,18 +467,12 @@ public void setText (String string) {
* Bug in Windows. When a column header contains a
* mnemonic character, Windows does not measure the
* text properly. This causes '...' to always appear
- * at the end of the text. The fix is to replace all
- * mnemonic characters with spaces.
+ * at the end of the text. The fix is to remove
+ * mnemonic characters and replace doubled mnemonics
+ * with spaces.
*/
- char [] chars = new char [string.length ()];
- string.getChars (0, string.length (), chars, 0);
- int i = 0;
- while (i < chars.length) {
- if (chars [i] == '&') chars [i] = ' ';
- i++;
- }
int hHeap = OS.GetProcessHeap ();
- TCHAR buffer = new TCHAR (parent.getCodePage (), chars, true);
+ TCHAR buffer = new TCHAR (parent.getCodePage (), fixMnemonic (string), true);
int byteCount = buffer.length () * TCHAR.sizeof;
int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
OS.MoveMemory (pszText, buffer, byteCount);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
index f170f86f8d..6323ca0088 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
@@ -392,6 +392,25 @@ boolean filters (int eventType) {
return display.filters (eventType);
}
+char [] fixMnemonic (String string) {
+ char [] buffer = new char [string.length ()];
+ string.getChars (0, string.length (), buffer, 0);
+ int i = 0, j = 0;
+ while (i < buffer.length) {
+ if (buffer [i] == '&') {
+ if (i + 1 < buffer.length && buffer [i + 1] == '&') {
+ buffer [j++] = ' ';
+ i++;
+ }
+ i++;
+ } else {
+ buffer [j++] = buffer [i++];
+ }
+ }
+ while (j < buffer.length) buffer [j++] = 0;
+ return buffer;
+}
+
/**
* Returns the application defined widget data associated
* with the receiver, or null if it has not been set. The