Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikita Nemkin2019-01-31 06:54:35 -0500
committerNikita Nemkin2019-04-16 05:41:59 -0400
commitc64218f83b34c6936c38d867bf5bfa4cfa76fdef (patch)
treeba9b963163b5d4f5846aad636344768bf54b834a
parent580b0e95b8c566f33cd479080d52608e07b040dd (diff)
downloadeclipse.platform.swt-c64218f83b34c6936c38d867bf5bfa4cfa76fdef.tar.gz
eclipse.platform.swt-c64218f83b34c6936c38d867bf5bfa4cfa76fdef.tar.xz
eclipse.platform.swt-c64218f83b34c6936c38d867bf5bfa4cfa76fdef.zip
Bug 545884 - [Win32] Remove TCHAR string wrapper (Part 1)
Replace TCHARs that are used as fixed-size buffers with plain char[] arrays of the same size. Change-Id: Ic54bafb4e865dff62de67a0efefc6020aa5349f3 Signed-off-by: Nikita Nemkin <nikita@nemkin.ru>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Clipboard.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/FileTransfer.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/PrintDialog.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/browser/WebFrameLoadDelegate.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java49
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/BidiUtil.java25
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java54
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java21
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FileDialog.java27
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/IME.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java60
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java29
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskBar.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskItem.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java34
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java24
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java1
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet83.java5
34 files changed, 246 insertions, 324 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Clipboard.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Clipboard.java
index f3149429bf..7a5ef22c0c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Clipboard.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Clipboard.java
@@ -743,10 +743,10 @@ public String[] getAvailableTypeNames() {
String[] names = new String[types.length];
int maxSize = 128;
for (int i = 0; i < types.length; i++){
- TCHAR buffer = new TCHAR(0, maxSize);
+ char [] buffer = new char [maxSize];
int size = OS.GetClipboardFormatName(types[i].cfFormat, buffer, maxSize);
if (size != 0) {
- names[i] = buffer.toString(0, size);
+ names[i] = new String (buffer, 0, size);
} else {
switch (types[i].cfFormat) {
case COM.CF_HDROP: names[i] = "CF_HDROP"; break; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/FileTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/FileTransfer.java
index d9786b721e..caab8e35bd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/FileTransfer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/FileTransfer.java
@@ -41,7 +41,6 @@ public class FileTransfer extends ByteArrayTransfer {
private static FileTransfer _instance = new FileTransfer();
private static final String CF_HDROP = "CF_HDROP "; //$NON-NLS-1$
private static final int CF_HDROPID = COM.CF_HDROP;
- private static final String CF_HDROP_SEPARATOR = "\0"; //$NON-NLS-1$
private FileTransfer() {}
@@ -75,9 +74,11 @@ public void javaToNative(Object object, TransferData transferData) {
StringBuffer allFiles = new StringBuffer();
for (int i = 0; i < fileNames.length; i++) {
allFiles.append(fileNames[i]);
- allFiles.append(CF_HDROP_SEPARATOR); // each name is null terminated
+ allFiles.append('\0'); // each name is null terminated
}
- TCHAR buffer = new TCHAR(0, allFiles.toString(), true); // there is an extra null terminator at the very end
+ allFiles.append('\0'); // there is an extra null terminator at the very end
+ char [] buffer = new char [allFiles.length()];
+ allFiles.getChars(0, allFiles.length(), buffer, 0);
DROPFILES dropfiles = new DROPFILES();
dropfiles.pFiles = DROPFILES.sizeof;
dropfiles.pt_x = dropfiles.pt_y = 0;
@@ -85,7 +86,7 @@ public void javaToNative(Object object, TransferData transferData) {
dropfiles.fWide = 1;
// Allocate the memory because the caller (DropTarget) has not handed it in
// The caller of this method must release the data when it is done with it.
- int byteCount = buffer.length() * TCHAR.sizeof;
+ int byteCount = buffer.length * TCHAR.sizeof;
long /*int*/ newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, DROPFILES.sizeof + byteCount);
OS.MoveMemory(newPtr, dropfiles, DROPFILES.sizeof);
OS.MoveMemory(newPtr + DROPFILES.sizeof, buffer, byteCount);
@@ -130,11 +131,11 @@ public Object nativeToJava(TransferData transferData) {
String[] fileNames = new String[count];
for (int i = 0; i < count; i++) {
// How long is the name ?
- int size = OS.DragQueryFile(stgmedium.unionField, i, null, 0) + 1;
- TCHAR lpszFile = new TCHAR(0, size);
+ int size = OS.DragQueryFile(stgmedium.unionField, i, null, 0);
+ char [] lpszFile = new char [size + 1];
// Get file name and append it to string
- OS.DragQueryFile(stgmedium.unionField, i, lpszFile.chars, size);
- fileNames[i] = lpszFile.toString(0, lpszFile.strlen());
+ OS.DragQueryFile(stgmedium.unionField, i, lpszFile, size + 1);
+ fileNames[i] = new String(lpszFile, 0, size);
}
OS.DragFinish(stgmedium.unionField); // frees data associated with HDROP data
return fileNames;
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 3e0eb8a503..2e77e7ecf9 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
@@ -2174,16 +2174,6 @@ public static final int ExtractIconEx (TCHAR lpszFile, int nIconIndex, long /*in
return ExtractIconEx (lpszFile1, nIconIndex, phiconLarge, phiconSmall, nIcons);
}
-public static final boolean ExtTextOut(long /*int*/ hdc, int X, int Y, int fuOptions, RECT lprc, TCHAR lpString, int cbCount, int[] lpDx) {
- char [] lpString1 = lpString == null ? null : lpString.chars;
- return ExtTextOut (hdc, X, Y, fuOptions, lprc, lpString1, cbCount, lpDx);
-}
-
-public static final int GetCharacterPlacement (long /*int*/ hdc, TCHAR lpString, int nCount, int nMaxExtent, GCP_RESULTS lpResults, int dwFlags) {
- char [] lpString1 = lpString == null ? null : lpString.chars;
- return GetCharacterPlacement (hdc, lpString1, nCount, nMaxExtent, lpResults, dwFlags);
-}
-
public static final boolean GetClassInfo (long /*int*/ hInstance, TCHAR lpClassName, WNDCLASS lpWndClass) {
boolean result;
@@ -2202,16 +2192,6 @@ public static final boolean GetClassInfo (long /*int*/ hInstance, TCHAR lpClassN
return result;
}
-public static final int GetClassName (long /*int*/ hWnd, TCHAR lpClassName, int nMaxCount) {
- char [] lpClassName1 = lpClassName == null ? null : lpClassName.chars;
- return GetClassName (hWnd, lpClassName1, nMaxCount);
-}
-
-public static final int GetClipboardFormatName (int format, TCHAR lpszFormatName, int cchMaxCount) {
- char [] lpszFormatName1 = lpszFormatName == null ? null : lpszFormatName.chars;
- return GetClipboardFormatName (format, lpszFormatName1, cchMaxCount);
-}
-
public static final int GetLocaleInfo (int Locale, int LCType, TCHAR lpLCData, int cchData) {
char [] lpLCData1 = lpLCData == null ? null : lpLCData.chars;
return GetLocaleInfo (Locale, LCType, lpLCData1, cchData);
@@ -2230,11 +2210,6 @@ public static final int GetProfileString (TCHAR lpAppName, TCHAR lpKeyName, TCHA
return GetProfileString (lpAppName1, lpKeyName1, lpDefault1, lpReturnedString1, nSize);
}
-public static final boolean GetTextExtentPoint32 (long /*int*/ hdc, TCHAR lpString, int cbString, SIZE lpSize) {
- char [] lpString1 = lpString == null ? null : lpString.chars;
- return GetTextExtentPoint32 (hdc, lpString1, cbString, lpSize);
-}
-
public static final int GetWindowText (long /*int*/ hWnd, TCHAR lpString, int nMaxCount) {
char [] lpString1 = lpString == null ? null : lpString.chars;
return GetWindowText (hWnd, lpString1, nMaxCount);
@@ -2250,11 +2225,6 @@ public static final long /*int*/ ImmEscape (long /*int*/ hKL,long /*int*/ hIMC,
return ImmEscape (hKL, hIMC, uEscape, lpData1);
}
-public static final int ImmGetCompositionString (long /*int*/ hIMC, int dwIndex, TCHAR lpBuf, int dwBufLen) {
- char [] lpBuf1 = lpBuf == null ? null : lpBuf.chars;
- return ImmGetCompositionString (hIMC, dwIndex, lpBuf1, dwBufLen);
-}
-
public static final boolean InternetGetCookie (TCHAR lpszUrl, TCHAR lpszCookieName, TCHAR lpszCookieData, int[] lpdwSize) {
char [] url = lpszUrl == null ? null : lpszUrl.chars;
char [] cookieName = lpszCookieName == null ? null : lpszCookieName.chars;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/PrintDialog.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/PrintDialog.java
index e84429dfd9..aaf0ad6fbb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/PrintDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/PrintDialog.java
@@ -463,25 +463,25 @@ public PrinterData open() {
ptr = OS.GlobalLock(hMem);
short[] offsets = new short[4];
OS.MoveMemory(offsets, ptr, 2 * offsets.length);
- TCHAR buffer = new TCHAR(0, size);
+ char [] buffer = new char [size];
OS.MoveMemory(buffer, ptr, size);
OS.GlobalUnlock(hMem);
int driverOffset = offsets[0];
int i = 0;
while (driverOffset + i < size) {
- if (buffer.tcharAt(driverOffset + i) == 0) break;
+ if (buffer [driverOffset + i] == 0) break;
i++;
}
- String driver = buffer.toString(driverOffset, i);
+ String driver = new String(buffer, driverOffset, i);
int deviceOffset = offsets[1];
i = 0;
while (deviceOffset + i < size) {
- if (buffer.tcharAt(deviceOffset + i) == 0) break;
+ if (buffer [deviceOffset + i] == 0) break;
i++;
}
- String device = buffer.toString(deviceOffset, i);
+ String device = new String(buffer, deviceOffset, i);
/* Create PrinterData object and set fields from PRINTDLG */
data = new PrinterData(driver, device);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java b/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java
index 82541648ee..f0ccac8d63 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java
@@ -113,14 +113,13 @@ public static Program findProgram (String extension) {
*/
public static String [] getExtensions () {
String [] extensions = new String [1024];
- /* Use the character encoding for the default locale */
- TCHAR lpName = new TCHAR (0, 1024);
- int [] lpcName = new int [] {lpName.length ()};
+ char [] lpName = new char [1024];
+ int [] lpcName = {lpName.length};
FILETIME ft = new FILETIME ();
int dwIndex = 0, count = 0;
while (OS.RegEnumKeyEx (OS.HKEY_CLASSES_ROOT, dwIndex, lpName, lpcName, null, null, null, ft) != OS.ERROR_NO_MORE_ITEMS) {
- String extension = lpName.toString (0, lpcName [0]);
- lpcName [0] = lpName.length ();
+ String extension = new String (lpName, 0, lpcName [0]);
+ lpcName [0] = lpName.length;
if (extension.length () > 0 && extension.charAt (0) == '.') {
if (count == extensions.length) {
String [] newExtensions = new String [extensions.length + 1024];
@@ -165,19 +164,17 @@ static String getKeyValue (String string, boolean expand) {
length++;
}
if (length != 0) {
- /* Use the character encoding for the default locale */
- TCHAR lpData = new TCHAR (0, length);
+ char [] lpData = new char [length];
if (OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData) == 0) {
if (expand) {
length = OS.ExpandEnvironmentStrings (lpData, null, 0);
if (length != 0) {
- TCHAR lpDst = new TCHAR (0, length);
+ char [] lpDst = new char [length];
OS.ExpandEnvironmentStrings (lpData, lpDst, length);
- result = lpDst.toString (0, Math.max (0, length - 1));
+ result = new String (lpDst, 0, length - 1);
}
} else {
- length = Math.max (0, lpData.length () - 1);
- result = lpData.toString (0, length);
+ result = new String (lpData, 0, length - 1);
}
}
}
@@ -225,14 +222,13 @@ static Program getProgram (String key, String extension) {
*/
public static Program [] getPrograms () {
LinkedHashSet<Program> programs = new LinkedHashSet<>(1024);
- /* Use the character encoding for the default locale */
- TCHAR lpName = new TCHAR (0, 1024);
- int [] lpcName = new int [] {lpName.length ()};
+ char [] lpName = new char [1024];
+ int [] lpcName = new int [] {lpName.length};
FILETIME ft = new FILETIME ();
int dwIndex = 0;
while (OS.RegEnumKeyEx (OS.HKEY_CLASSES_ROOT, dwIndex, lpName, lpcName, null, null, null, ft) != OS.ERROR_NO_MORE_ITEMS) {
- String path = lpName.toString (0, lpcName [0]);
- lpcName [0] = lpName.length ();
+ String path = new String (lpName, 0, lpcName [0]);
+ lpcName [0] = lpName.length;
Program program = getProgram (path, null);
if (program != null) {
programs.add(program);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/browser/WebFrameLoadDelegate.java b/bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/browser/WebFrameLoadDelegate.java
index 830fefe60a..26ac077c77 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/browser/WebFrameLoadDelegate.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/win32/org/eclipse/swt/browser/WebFrameLoadDelegate.java
@@ -636,14 +636,14 @@ void showCertificate (Shell parent, long /*int*/ certificate) {
OS.MoveMemory (info, context.pCertInfo, CERT_INFO.sizeof);
int length = OS.CertNameToStr (OS.X509_ASN_ENCODING, info.Issuer, OS.CERT_SIMPLE_NAME_STR, null, 0);
- TCHAR tchar = new TCHAR (0, length);
- OS.CertNameToStr (OS.X509_ASN_ENCODING, info.Issuer, OS.CERT_SIMPLE_NAME_STR, tchar.chars, length);
- String issuer = tchar.toString (0, tchar.strlen ());
+ char [] buffer = new char [length];
+ OS.CertNameToStr (OS.X509_ASN_ENCODING, info.Issuer, OS.CERT_SIMPLE_NAME_STR, buffer, length);
+ String issuer = new String (buffer, 0, length - 1);
length = OS.CertNameToStr (OS.X509_ASN_ENCODING, info.Subject, OS.CERT_SIMPLE_NAME_STR, null, 0);
- tchar = new TCHAR (0, length);
- OS.CertNameToStr (OS.X509_ASN_ENCODING, info.Subject, OS.CERT_SIMPLE_NAME_STR, tchar.chars, length);
- String subject = tchar.toString (0, tchar.strlen ());
+ buffer = new char [length];
+ OS.CertNameToStr (OS.X509_ASN_ENCODING, info.Subject, OS.CERT_SIMPLE_NAME_STR, buffer, length);
+ String subject = new String (buffer, 0, length - 1);
final String SEPARATOR_DATE = "/"; //$NON-NLS-1$
final String SEPARATOR_TIME = ":"; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java
index f4d6cdf57f..c20659002d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java
@@ -577,10 +577,10 @@ String getLastErrorText () {
int dwFlags = OS.FORMAT_MESSAGE_ALLOCATE_BUFFER | OS.FORMAT_MESSAGE_FROM_SYSTEM | OS.FORMAT_MESSAGE_IGNORE_INSERTS;
int length = OS.FormatMessage(dwFlags, 0, error, OS.LANG_USER_DEFAULT, buffer, 0, 0);
if (length == 0) return " [GetLastError=0x" + Integer.toHexString(error) + "]"; //$NON-NLS-1$ //$NON-NLS-2$
- TCHAR buffer1 = new TCHAR(0, length);
+ char [] buffer1 = new char [length];
OS.MoveMemory(buffer1, buffer[0], length * TCHAR.sizeof);
if (buffer[0] != 0) OS.LocalFree(buffer[0]);
- return buffer1.toString(0, length);
+ return new String(buffer1);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
index 44350b9454..d803d32e2a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
@@ -2090,11 +2090,8 @@ public void drawString (String string, int x, int y, boolean isTransparent) {
void drawStringInPixels (String string, int x, int y, boolean isTransparent) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
-// TCHAR buffer = new TCHAR (getCodePage(), string, false);
- int length = string.length();
- if (length == 0) return;
- char[] buffer = new char [length];
- string.getChars(0, length, buffer, 0);
+ if (string.isEmpty()) return;
+ char[] buffer = string.toCharArray();
long /*int*/ gdipGraphics = data.gdipGraphics;
if (gdipGraphics != 0) {
checkGC(FONT | FOREGROUND | (isTransparent ? 0 : BACKGROUND));
@@ -2109,7 +2106,7 @@ void drawStringInPixels (String string, int x, int y, boolean isTransparent) {
if ((data.style & SWT.MIRRORED) != 0) {
if (!isTransparent) {
size = new SIZE();
- OS.GetTextExtentPoint32(handle, buffer, length, size);
+ OS.GetTextExtentPoint32(handle, buffer, buffer.length, size);
rect = new RECT ();
rect.left = x;
rect.right = x + size.cx;
@@ -2120,13 +2117,13 @@ void drawStringInPixels (String string, int x, int y, boolean isTransparent) {
x--;
}
if (OS.GetROP2(handle) != OS.R2_XORPEN) {
- OS.ExtTextOut(handle, x, y, flags, rect, buffer, length, null);
+ OS.ExtTextOut(handle, x, y, flags, rect, buffer, buffer.length, null);
} else {
int foreground = OS.GetTextColor(handle);
if (isTransparent) {
if (size == null) {
size = new SIZE();
- OS.GetTextExtentPoint32(handle, buffer, length, size);
+ OS.GetTextExtentPoint32(handle, buffer, buffer.length, size);
}
int width = size.cx, height = size.cy;
long /*int*/ hBitmap = OS.CreateCompatibleBitmap(handle, width, height);
@@ -2137,7 +2134,7 @@ void drawStringInPixels (String string, int x, int y, boolean isTransparent) {
OS.SetBkMode(memDC, OS.TRANSPARENT);
OS.SetTextColor(memDC, foreground);
OS.SelectObject(memDC, OS.GetCurrentObject(handle, OS.OBJ_FONT));
- OS.ExtTextOut(memDC, 0, 0, 0, null, buffer, length, null);
+ OS.ExtTextOut(memDC, 0, 0, 0, null, buffer, buffer.length, null);
OS.BitBlt(handle, x, y, width, height, memDC, 0, 0, OS.SRCINVERT);
OS.SelectObject(memDC, hOldBitmap);
OS.DeleteDC(memDC);
@@ -2145,7 +2142,7 @@ void drawStringInPixels (String string, int x, int y, boolean isTransparent) {
} else {
int background = OS.GetBkColor(handle);
OS.SetTextColor(handle, foreground ^ background);
- OS.ExtTextOut(handle, x, y, flags, rect, buffer, length, null);
+ OS.ExtTextOut(handle, x, y, flags, rect, buffer, buffer.length, null);
OS.SetTextColor(handle, foreground);
}
}
@@ -2255,16 +2252,14 @@ public void drawText (String string, int x, int y, int flags) {
void drawTextInPixels (String string, int x, int y, int flags) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (string.length() == 0) return;
+ if (string.isEmpty()) return;
long /*int*/ gdipGraphics = data.gdipGraphics;
if (gdipGraphics != 0) {
checkGC(FONT | FOREGROUND | ((flags & SWT.DRAW_TRANSPARENT) != 0 ? 0 : BACKGROUND));
drawText(gdipGraphics, string, x, y, flags, null);
return;
}
- TCHAR buffer = new TCHAR(getCodePage(), string, false);
- int length = buffer.length();
- if (length == 0) return;
+ char [] buffer = string.toCharArray();
RECT rect = new RECT();
OS.SetRect(rect, x, y, 0x6FFFFFF, 0x6FFFFFF);
int uFormat = OS.DT_LEFT;
@@ -2277,11 +2272,11 @@ void drawTextInPixels (String string, int x, int y, int flags) {
checkGC(FONT | FOREGROUND_TEXT | BACKGROUND_TEXT);
int oldBkMode = OS.SetBkMode(handle, (flags & SWT.DRAW_TRANSPARENT) != 0 ? OS.TRANSPARENT : OS.OPAQUE);
if (OS.GetROP2(handle) != OS.R2_XORPEN) {
- OS.DrawText(handle, buffer, length, rect, uFormat);
+ OS.DrawText(handle, buffer, buffer.length, rect, uFormat);
} else {
int foreground = OS.GetTextColor(handle);
if ((flags & SWT.DRAW_TRANSPARENT) != 0) {
- OS.DrawText(handle, buffer, buffer.length(), rect, uFormat | OS.DT_CALCRECT);
+ OS.DrawText(handle, buffer, buffer.length, rect, uFormat | OS.DT_CALCRECT);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
long /*int*/ hBitmap = OS.CreateCompatibleBitmap(handle, width, height);
@@ -2293,7 +2288,7 @@ void drawTextInPixels (String string, int x, int y, int flags) {
OS.SetTextColor(memDC, foreground);
OS.SelectObject(memDC, OS.GetCurrentObject(handle, OS.OBJ_FONT));
OS.SetRect(rect, 0, 0, 0x7FFF, 0x7FFF);
- OS.DrawText(memDC, buffer, length, rect, uFormat);
+ OS.DrawText(memDC, buffer, buffer.length, rect, uFormat);
OS.BitBlt(handle, x, y, width, height, memDC, 0, 0, OS.SRCINVERT);
OS.SelectObject(memDC, hOldBitmap);
OS.DeleteDC(memDC);
@@ -2301,7 +2296,7 @@ void drawTextInPixels (String string, int x, int y, int flags) {
} else {
int background = OS.GetBkColor(handle);
OS.SetTextColor(handle, foreground ^ background);
- OS.DrawText(handle, buffer, length, rect, uFormat);
+ OS.DrawText(handle, buffer, buffer.length, rect, uFormat);
OS.SetTextColor(handle, foreground);
}
}
@@ -2328,8 +2323,7 @@ boolean useGDIP (long /*int*/ hdc, char[] buffer) {
void drawText(long /*int*/ gdipGraphics, String string, int x, int y, int flags, Point size) {
int length = string.length();
- char[] chars = new char [length];
- string.getChars(0, length, chars, 0);
+ char[] chars = string.toCharArray();
long /*int*/ hdc = Gdip.Graphics_GetHDC(gdipGraphics);
long /*int*/ hFont = data.hGDIFont;
if (hFont == 0 && data.font != null) hFont = data.font.handle;
@@ -2516,8 +2510,7 @@ void drawTextGDIP(long /*int*/ gdipGraphics, String string, int x, int y, int fl
char[] buffer;
int length = string.length();
if (length != 0) {
- buffer = new char [length];
- string.getChars(0, length, buffer, 0);
+ buffer = string.toCharArray();
} else {
if (draw) return;
buffer = new char[]{' '};
@@ -3377,10 +3370,6 @@ public void getClipping (Region region) {
}
}
-int getCodePage () {
- return OS.CP_ACP;
-}
-
long /*int*/ getFgBrush() {
return data.foregroundPattern != null ? data.foregroundPattern.handle : data.gdipFgBrush;
}
@@ -4893,9 +4882,7 @@ Point stringExtentInPixels (String string) {
OS.GetTextExtentPoint32(handle, new char[]{' '}, 1, size);
return new Point(0, size.cy);
} else {
-// TCHAR buffer = new TCHAR (getCodePage(), string, false);
- char[] buffer = new char [length];
- string.getChars(0, length, buffer, 0);
+ char[] buffer = string.toCharArray();
OS.GetTextExtentPoint32(handle, buffer, length, size);
return new Point(size.cx, size.cy);
}
@@ -4975,12 +4962,12 @@ Point textExtentInPixels(String string, int flags) {
return new Point(0, size.cy);
}
RECT rect = new RECT();
- TCHAR buffer = new TCHAR(getCodePage(), string, false);
+ char [] buffer = string.toCharArray();
int uFormat = OS.DT_LEFT | OS.DT_CALCRECT;
if ((flags & SWT.DRAW_DELIMITER) == 0) uFormat |= OS.DT_SINGLELINE;
if ((flags & SWT.DRAW_TAB) != 0) uFormat |= OS.DT_EXPANDTABS;
if ((flags & SWT.DRAW_MNEMONIC) == 0) uFormat |= OS.DT_NOPREFIX;
- OS.DrawText(handle, buffer, buffer.length(), rect, uFormat);
+ OS.DrawText(handle, buffer, buffer.length, rect, uFormat);
return new Point(rect.right, rect.bottom);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java
index 177756e280..cd8d2bc3e7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java
@@ -315,9 +315,7 @@ void addStringInPixels(String string, float x, float y, Font font) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (font == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- int length = string.length();
- char[] buffer = new char[length];
- string.getChars(0, length, buffer, 0);
+ char[] buffer = string.toCharArray();
long /*int*/ hDC = device.internal_new_GC(null);
long /*int*/ [] family = new long /*int*/ [1];
long /*int*/ gdipFont = GC.createGdipFont(hDC, font.handle, 0, device.fontCollection, family, null);
@@ -326,7 +324,7 @@ void addStringInPixels(String string, float x, float y, Font font) {
point.Y = y;
int style = Gdip.Font_GetStyle(gdipFont);
float size = Gdip.Font_GetSize(gdipFont);
- Gdip.GraphicsPath_AddString(handle, buffer, length, family[0], style, size, point, 0);
+ Gdip.GraphicsPath_AddString(handle, buffer, buffer.length, family[0], style, size, point, 0);
Gdip.GraphicsPath_GetLastPoint(handle, currentPoint);
Gdip.FontFamily_delete(family[0]);
Gdip.Font_delete(gdipFont);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/BidiUtil.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/BidiUtil.java
index 9c9c31e6b2..992b0b4df4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/BidiUtil.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/BidiUtil.java
@@ -14,11 +14,10 @@
package org.eclipse.swt.internal;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.widgets.*;
/*
@@ -175,10 +174,9 @@ public static void drawGlyphs(GC gc, char[] renderBuffer, int[] renderDx, int x,
public static char[] getRenderInfo(GC gc, String text, int[] order, byte[] classBuffer, int[] dx, int flags, int [] offsets) {
int fontLanguageInfo = OS.GetFontLanguageInfo(gc.handle);
long /*int*/ hHeap = OS.GetProcessHeap();
- int[] lpCs = new int[8];
boolean isRightOriented = OS.GetLayout(gc.handle) != 0;
- TCHAR textBuffer = new TCHAR(lpCs[1], text, false);
- int byteCount = textBuffer.length();
+ char [] textBuffer = text.toCharArray();
+ int byteCount = textBuffer.length;
boolean linkBefore = (flags & LINKBEFORE) == LINKBEFORE;
boolean linkAfter = (flags & LINKAFTER) == LINKAFTER;
@@ -235,8 +233,8 @@ public static char[] getRenderInfo(GC gc, String text, int[] order, byte[] class
// The number of glyphs expected is <= length (segment length);
// the actual number returned may be less in case of Arabic ligatures.
result.nGlyphs = length;
- TCHAR textBuffer2 = new TCHAR(lpCs[1], text.substring(offset, offset + length), false);
- OS.GetCharacterPlacement(gc.handle, textBuffer2, textBuffer2.length(), 0, result, dwFlags);
+ text.getChars(offset, offset + length, textBuffer, 0);
+ OS.GetCharacterPlacement(gc.handle, textBuffer, length, 0, result, dwFlags);
if (dx != null) {
int [] dx2 = new int [result.nGlyphs];
@@ -303,9 +301,8 @@ public static char[] getRenderInfo(GC gc, String text, int[] order, byte[] class
public static void getOrderInfo(GC gc, String text, int[] order, byte[] classBuffer, int flags, int [] offsets) {
int fontLanguageInfo = OS.GetFontLanguageInfo(gc.handle);
long /*int*/ hHeap = OS.GetProcessHeap();
- int[] lpCs = new int[8];
- TCHAR textBuffer = new TCHAR(lpCs[1], text, false);
- int byteCount = textBuffer.length();
+ char [] textBuffer = text.toCharArray();
+ int byteCount = textBuffer.length;
boolean isRightOriented = OS.GetLayout(gc.handle) != 0;
GCP_RESULTS result = new GCP_RESULTS();
@@ -340,8 +337,8 @@ public static void getOrderInfo(GC gc, String text, int[] order, byte[] classBuf
// The number of glyphs expected is <= length (segment length);
// the actual number returned may be less in case of Arabic ligatures.
result.nGlyphs = length;
- TCHAR textBuffer2 = new TCHAR(lpCs[1], text.substring(offset, offset + length), false);
- OS.GetCharacterPlacement(gc.handle, textBuffer2, textBuffer2.length(), 0, result, dwFlags);
+ text.getChars(offset, offset + length, textBuffer, 0);
+ OS.GetCharacterPlacement(gc.handle, textBuffer, length, 0, result, dwFlags);
if (order != null) {
int [] order2 = new int [length];
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
index 3761ba2ce6..20fcc839ba 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
@@ -293,10 +293,10 @@ int computeLeftMargin () {
long /*int*/ hDC = OS.GetDC (handle);
long /*int*/ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
- TCHAR buffer = new TCHAR (getCodePage (), text, true);
+ char [] buffer = text.toCharArray ();
RECT rect = new RECT ();
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE;
- OS.DrawText (hDC, buffer, -1, rect, flags);
+ OS.DrawText (hDC, buffer, buffer.length, rect, flags);
margin += rect.right - rect.left;
if (newFont != 0) OS.SelectObject (hDC, oldFont);
OS.ReleaseDC (handle, hDC);
@@ -362,7 +362,7 @@ int computeLeftMargin () {
height = Math.max (height, lptm.tmHeight);
} else {
extra = Math.max (MARGIN * 2, lptm.tmAveCharWidth);
- TCHAR buffer = new TCHAR (getCodePage (), text, true);
+ char [] buffer = text.toCharArray ();
RECT rect = new RECT ();
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE;
if ((style & SWT.WRAP) != 0 && wHint != SWT.DEFAULT) {
@@ -380,7 +380,7 @@ int computeLeftMargin () {
}
}
}
- OS.DrawText (hDC, buffer, -1, rect, flags);
+ OS.DrawText (hDC, buffer, buffer.length, rect, flags);
width += rect.right - rect.left;
height = Math.max (height, rect.bottom - rect.top);
}
@@ -1382,7 +1382,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
OS.SetRect (textRect, left, nmcd.top + border, right, nmcd.bottom - border);
// draw text
- TCHAR buffer = new TCHAR (getCodePage (), text, false);
+ char [] buffer = text.toCharArray ();
int flags = 0;
if ((style & SWT.WRAP) != 0) {
flags |= OS.DT_WORDBREAK;
@@ -1392,7 +1392,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
} else {
flags |= OS.DT_SINGLELINE; // TODO: this always draws the prefix
}
- OS.DrawText(nmcd.hdc, buffer, buffer.length(), textRect, flags | OS.DT_CALCRECT);
+ OS.DrawText(nmcd.hdc, buffer, buffer.length, textRect, flags | OS.DT_CALCRECT);
OS.OffsetRect(textRect, 0, Math.max(0, (nmcd.bottom - textRect.bottom - border) / 2));
if (image != null) {
// The default button with an image doesn't respect the text alignment. So we do the same for styled buttons.
@@ -1411,7 +1411,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
}
OS.SetBkMode(nmcd.hdc, OS.TRANSPARENT);
OS.SetTextColor(nmcd.hdc, foreground);
- OS.DrawText(nmcd.hdc, buffer, buffer.length(), textRect, flags);
+ OS.DrawText(nmcd.hdc, buffer, buffer.length, textRect, flags);
// draw focus rect
if ((nmcd.uItemState & OS.CDIS_FOCUS) != 0) {
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 f5dc2fc0f4..66623517f1 100644
--- 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
@@ -172,7 +172,7 @@ public void add (String string) {
int result = (int)/*64*/OS.SendMessage (handle, OS.CB_ADDSTRING, 0, buffer);
if (result == OS.CB_ERR) error (SWT.ERROR_ITEM_NOT_ADDED);
if (result == OS.CB_ERRSPACE) error (SWT.ERROR_ITEM_NOT_ADDED);
- if ((style & SWT.H_SCROLL) != 0) setScrollWidth (buffer, true);
+ if ((style & SWT.H_SCROLL) != 0) setScrollWidth (buffer.chars, true);
}
/**
@@ -213,7 +213,7 @@ public void add (String string, int index) {
if (result == OS.CB_ERRSPACE || result == OS.CB_ERR) {
error (SWT.ERROR_ITEM_NOT_ADDED);
}
- if ((style & SWT.H_SCROLL) != 0) setScrollWidth (buffer, true);
+ if ((style & SWT.H_SCROLL) != 0) setScrollWidth (buffer.chars, true);
}
/**
@@ -357,10 +357,9 @@ void applyEditSegments () {
if (!hooks (SWT.Segments) && !filters (SWT.Segments) && (state & HAS_AUTO_DIRECTION) == 0) return;
long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
int length = OS.GetWindowTextLength (hwndText);
- int cp = getCodePage ();
- TCHAR buffer = new TCHAR (cp, length + 1);
+ char [] buffer = new char [length + 1];
if (length > 0) OS.GetWindowText (hwndText, buffer, length + 1);
- String string = buffer.toString (0, length);
+ String string = new String (buffer, 0, length);
/* Get segments */
segments = null;
Event event = getSegments (string);
@@ -400,10 +399,9 @@ void applyEditSegments () {
* Sending OS.EM_REPLACESEL message instead.
*/
newChars [length] = 0;
- buffer = new TCHAR (cp, newChars, false);
OS.SendMessage (hwndText, OS.EM_SETSEL, 0, -1);
long /*int*/ undo = OS.SendMessage (hwndText, OS.EM_CANUNDO, 0, 0);
- OS.SendMessage (hwndText, OS.EM_REPLACESEL, undo, buffer);
+ OS.SendMessage (hwndText, OS.EM_REPLACESEL, undo, newChars);
/* Restore selection */
start [0] = translateOffset (start [0]);
end [0] = translateOffset (end [0]);
@@ -482,9 +480,9 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
if (lockText && msg == OS.WM_SETTEXT) {
long /*int*/ hHeap = OS.GetProcessHeap ();
int length = OS.GetWindowTextLength (handle);
- TCHAR buffer = new TCHAR (getCodePage (), length + 1);
+ char [] buffer = new char [length + 1];
OS.GetWindowText (handle, buffer, length + 1);
- int byteCount = buffer.length () * TCHAR.sizeof;
+ int byteCount = buffer.length * TCHAR.sizeof;
long /*int*/ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
OS.MoveMemory (pszText, buffer, byteCount);
long /*int*/ code = OS.CallWindowProc (EditProc, hwndText, msg, wParam, pszText);
@@ -502,9 +500,9 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
long /*int*/ CBTProc (long /*int*/ nCode, long /*int*/ wParam, long /*int*/ lParam) {
if ((int)/*64*/nCode == OS.HCBT_CREATEWND) {
- TCHAR buffer = new TCHAR (0, 128);
- OS.GetClassName (wParam, buffer, buffer.length ());
- String className = buffer.toString (0, buffer.strlen ());
+ char [] buffer = new char [128];
+ int length = OS.GetClassName (wParam, buffer, buffer.length);
+ String className = new String (buffer, 0, length);
if (className.equals ("Edit") || className.equals ("EDIT")) { //$NON-NLS-1$ //$NON-NLS-2$
int bits = OS.GetWindowLong (wParam, OS.GWL_STYLE);
OS.SetWindowLong (wParam, OS.GWL_STYLE, bits & ~OS.ES_NOHIDESEL);
@@ -626,8 +624,7 @@ public void clearSelection () {
int flags = OS.DT_CALCRECT | OS.DT_NOPREFIX;
if ((style & SWT.READ_ONLY) == 0) flags |= OS.DT_EDITCONTROL;
int length = OS.GetWindowTextLength (handle);
- int cp = getCodePage ();
- TCHAR buffer = new TCHAR (cp, length + 1);
+ char [] buffer = new char [length + 1];
OS.GetWindowText (handle, buffer, length + 1);
OS.DrawText (hDC, buffer, length, rect, flags);
width = Math.max (width, rect.right - rect.left);
@@ -637,7 +634,7 @@ public void clearSelection () {
for (int i=0; i<count; i++) {
length = (int)/*64*/OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, i, 0);
if (length != OS.CB_ERR) {
- if (length + 1 > buffer.length ()) buffer = new TCHAR (cp, length + 1);
+ if (length + 1 > buffer.length) buffer = new char [length + 1];
int result = (int)/*64*/OS.SendMessage (handle, OS.CB_GETLBTEXT, i, buffer);
if (result != OS.CB_ERR) {
OS.DrawText (hDC, buffer, length, rect, flags);
@@ -950,7 +947,6 @@ Point getCaretLocationInPixels () {
if (caretPos == -1) {
caretPos = 0;
if (position >= OS.GetWindowTextLength (hwndText)) {
- int cp = getCodePage ();
int [] start = new int [1], end = new int [1];
OS.SendMessage (hwndText, OS.EM_GETSEL, start, end);
OS.SendMessage (hwndText, OS.EM_SETSEL, position, position);
@@ -966,10 +962,10 @@ Point getCaretLocationInPixels () {
* handler from WM_CHAR.
*/
ignoreCharacter = ignoreModify = true;
- OS.SendMessage (hwndText, OS.EM_REPLACESEL, 0, new TCHAR (cp, " ", true));
+ OS.SendMessage (hwndText, OS.EM_REPLACESEL, 0, new char [] {' ', '\0'});
caretPos = OS.SendMessage (hwndText, OS.EM_POSFROMCHAR, position, 0);
OS.SendMessage (hwndText, OS.EM_SETSEL, position, position + 1);
- OS.SendMessage (hwndText, OS.EM_REPLACESEL, 0, new TCHAR (cp, "", true));
+ OS.SendMessage (hwndText, OS.EM_REPLACESEL, 0, new char [1]);
ignoreCharacter = ignoreModify = false;
OS.SendMessage (hwndText, OS.EM_SETSEL, start [0], start [0]);
OS.SendMessage (hwndText, OS.EM_SETSEL, start [0], end [0]);
@@ -1058,9 +1054,9 @@ public String getItem (int index) {
int length = (int)/*64*/OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, index, 0);
if (length != OS.CB_ERR) {
if (hooks (SWT.Segments) || filters (SWT.Segments) || (state & HAS_AUTO_DIRECTION) != 0) return items [index];
- TCHAR buffer = new TCHAR (getCodePage (), length + 1);
+ char [] buffer = new char [length + 1];
int result = (int)/*64*/OS.SendMessage (handle, OS.CB_GETLBTEXT, index, buffer);
- if (result != OS.CB_ERR) return buffer.toString (0, length);
+ if (result != OS.CB_ERR) return new String (buffer, 0, length);
}
int count = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
if (0 <= index && index < count) error (SWT.ERROR_CANNOT_GET_ITEM);
@@ -1586,7 +1582,7 @@ public void remove (int index) {
}
void remove (int index, boolean notify) {
- TCHAR buffer = null;
+ char [] buffer = null;
if ((style & SWT.H_SCROLL) != 0) {
int length = (int)/*64*/OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, index, 0);
if (length == OS.CB_ERR) {
@@ -1594,7 +1590,7 @@ void remove (int index, boolean notify) {
if (0 <= index && index < count) error (SWT.ERROR_ITEM_NOT_REMOVED);
error (SWT.ERROR_INVALID_RANGE);
}
- buffer = new TCHAR (getCodePage (), length + 1);
+ buffer = new char [length + 1];
int result = (int)/*64*/OS.SendMessage (handle, OS.CB_GETLBTEXT, index, buffer);
if (result == OS.CB_ERR) {
int count = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
@@ -1657,14 +1653,13 @@ public void remove (int start, int end) {
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
}
- int cp = getCodePage ();
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
for (int i=start; i<=end; i++) {
- TCHAR buffer = null;
+ char [] buffer = null;
if ((style & SWT.H_SCROLL) != 0) {
int length = (int)/*64*/OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, start, 0);
if (length == OS.CB_ERR) break;
- buffer = new TCHAR (cp, length + 1);
+ buffer = new char [length + 1];
int result = (int)/*64*/OS.SendMessage (handle, OS.CB_GETLBTEXT, start, buffer);
if (result == OS.CB_ERR) break;
}
@@ -2166,13 +2161,12 @@ void setScrollWidth () {
long /*int*/ hDC = OS.GetDC (handle);
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
- int cp = getCodePage ();
int count = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
for (int i=0; i<count; i++) {
int length = (int)/*64*/OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, i, 0);
if (length != OS.CB_ERR) {
- TCHAR buffer = new TCHAR (cp, length + 1);
+ char [] buffer = new char [length + 1];
int result = (int)/*64*/OS.SendMessage (handle, OS.CB_GETLBTEXT, i, buffer);
if (result != OS.CB_ERR) {
OS.DrawText (hDC, buffer, -1, rect, flags);
@@ -2223,7 +2217,7 @@ void setScrollWidth (int scrollWidth) {
if ((style & SWT.READ_ONLY) == 0) lockText = oldLockText;
}
-void setScrollWidth (TCHAR buffer, boolean grow) {
+void setScrollWidth (char[] buffer, boolean grow) {
RECT rect = new RECT ();
long /*int*/ newFont, oldFont = 0;
long /*int*/ hDC = OS.GetDC (handle);
@@ -3133,9 +3127,9 @@ LRESULT wmClipboard (long /*int*/ hwndText, int msg, long /*int*/ wParam, long /
int [] newStart = new int [1], newEnd = new int [1];
OS.SendMessage (hwndText, OS.EM_GETSEL, newStart, newEnd);
if (length != 0 && newStart [0] != newEnd [0]) {
- TCHAR buffer = new TCHAR (getCodePage (), length + 1);
+ char [] buffer = new char [length + 1];
OS.GetWindowText (hwndText, buffer, length + 1);
- newText = buffer.toString (newStart [0], newEnd [0] - newStart [0]);
+ newText = new String (buffer, newStart [0], newEnd [0] - newStart [0]);
} else {
newText = "";
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
index 54269f2c65..97e04a6c81 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
@@ -683,10 +683,9 @@ public String getText () {
checkWidget ();
int length = OS.GetWindowTextLength (handle);
if (length == 0) return "";
- /* Use the character encoding for the default locale */
- TCHAR buffer = new TCHAR (0, length + 1);
+ char [] buffer = new char [length + 1];
OS.GetWindowText (handle, buffer, length + 1);
- return buffer.toString (0, length);
+ return new String (buffer, 0, length);
}
@Override
@@ -1519,9 +1518,9 @@ LRESULT WM_ACTIVATE (long /*int*/ wParam, long /*int*/ lParam) {
* WM_ACTIVATE messages that come from AWT Windows.
*/
if (OS.GetParent (lParam) == handle) {
- TCHAR buffer = new TCHAR (0, 128);
- OS.GetClassName (lParam, buffer, buffer.length ());
- String className = buffer.toString (0, buffer.strlen ());
+ char [] buffer = new char [128];
+ int length = OS.GetClassName (lParam, buffer, buffer.length);
+ String className = new String (buffer, 0, length);
if (className.equals (Display.AWT_WINDOW_CLASS)) {
return LRESULT.ZERO;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
index 512d58815e..c19d155ddf 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
@@ -4788,8 +4788,8 @@ int textWidth (String text, long /*int*/ handle) {
long /*int*/ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
- TCHAR buffer = new TCHAR(0, text, false);
- OS.DrawText (hDC, buffer, buffer.length (), rect, flags);
+ char [] buffer = text.toCharArray ();
+ OS.DrawText (hDC, buffer, buffer.length, rect, flags);
if (newFont != 0) OS.SelectObject (hDC, oldFont);
OS.ReleaseDC (handle, hDC);
return (rect.right - rect.left);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java
index 110a815849..086c471e92 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java
@@ -200,22 +200,23 @@ void drawItem (GC gc, long /*int*/ hTheme, RECT clipRect, boolean drawFocus) {
}
if (text.length () > 0) {
rect.left += ExpandItem.TEXT_INSET;
- TCHAR buffer;
+ char [] buffer;
if ((style & SWT.FLIP_TEXT_DIRECTION) != 0) {
int bits = OS.GetWindowLong (parent.handle, OS.GWL_EXSTYLE);
if ((bits & OS.WS_EX_LAYOUTRTL) != 0) {
- buffer = new TCHAR (parent.getCodePage (), LRE + text, false);
+ buffer = (LRE + text).toCharArray ();
} else {
- buffer = new TCHAR (parent.getCodePage (), RLE + text, false);
+ buffer = (RLE + text).toCharArray ();
}
}
- else
- buffer = new TCHAR (parent.getCodePage (), text, false);
+ else {
+ buffer = text.toCharArray ();
+ }
if (hTheme != 0) {
- OS.DrawThemeText (hTheme, hDC, OS.EBP_NORMALGROUPHEAD, 0, buffer.chars, buffer.length(), OS.DT_VCENTER | OS.DT_SINGLELINE, 0, rect);
+ OS.DrawThemeText (hTheme, hDC, OS.EBP_NORMALGROUPHEAD, 0, buffer, buffer.length, OS.DT_VCENTER | OS.DT_SINGLELINE, 0, rect);
} else {
int oldBkMode = OS.SetBkMode (hDC, OS.TRANSPARENT);
- OS.DrawText (hDC, buffer, buffer.length (), rect, OS.DT_VCENTER | OS.DT_SINGLELINE);
+ OS.DrawText (hDC, buffer, buffer.length, rect, OS.DT_VCENTER | OS.DT_SINGLELINE);
OS.SetBkMode (hDC, oldBkMode);
}
}
@@ -348,11 +349,11 @@ int getPreferredWidth (long /*int*/ hTheme, long /*int*/ hDC) {
}
if (text.length() > 0) {
RECT rect = new RECT ();
- TCHAR buffer = new TCHAR (parent.getCodePage (), text, false);
+ char [] buffer = text.toCharArray ();
if (hTheme != 0) {
- OS.GetThemeTextExtent (hTheme, hDC, OS.EBP_NORMALGROUPHEAD, 0, buffer.chars, buffer.length(), OS.DT_SINGLELINE, null, rect);
+ OS.GetThemeTextExtent (hTheme, hDC, OS.EBP_NORMALGROUPHEAD, 0, buffer, buffer.length, OS.DT_SINGLELINE, null, rect);
} else {
- OS.DrawText (hDC, buffer, buffer.length (), rect, OS.DT_CALCRECT);
+ OS.DrawText (hDC, buffer, buffer.length, rect, OS.DT_CALCRECT);
}
width += (rect.right - rect.left);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FileDialog.java
index 0cbe1d214b..9c7e8fd3d8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FileDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FileDialog.java
@@ -14,9 +14,9 @@
package org.eclipse.swt.widgets;
+import org.eclipse.swt.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
/**
* Instances of this class allow the user to navigate
@@ -386,7 +386,7 @@ public String open () {
display.sendPostExternalEventDispatchEvent ();
switch (OS.CommDlgExtendedError ()) {
case OS.FNERR_INVALIDFILENAME:
- OS.MoveMemory (lpstrFile, new TCHAR (0, "", true), TCHAR.sizeof);
+ OS.MoveMemory (lpstrFile, new char [1], TCHAR.sizeof);
display.sendPreExternalEventDispatchEvent ();
success = (save) ? OS.GetSaveFileName (struct) : OS.GetOpenFileName (struct);
display.sendPostExternalEventDispatchEvent ();
@@ -410,19 +410,11 @@ public String open () {
fileNames = new String [0];
String fullPath = null;
if (success) {
-
- /* Use the character encoding for the default locale */
- TCHAR buffer = new TCHAR (0, struct.nMaxFile);
- int byteCount1 = buffer.length () * TCHAR.sizeof;
- OS.MoveMemory (buffer, lpstrFile, byteCount1);
+ char [] buffer = new char [struct.nMaxFile];
+ OS.MoveMemory (buffer, lpstrFile, buffer.length * TCHAR.sizeof);
int nFileOffset = struct.nFileOffset;
if (nFileOffset > 0) {
-
- /* Use the character encoding for the default locale */
- TCHAR prefix = new TCHAR (0, nFileOffset - 1);
- int byteCount2 = prefix.length () * TCHAR.sizeof;
- OS.MoveMemory (prefix, lpstrFile, byteCount2);
- filterPath = prefix.toString (0, prefix.length ());
+ filterPath = new String (buffer, 0, nFileOffset - 1);
/*
* Get each file from the buffer. Files are delimited
@@ -433,9 +425,9 @@ public String open () {
int start = nFileOffset;
do {
int end = start;
- while (end < buffer.length () && buffer.tcharAt (end) != 0) end++;
- String string = buffer.toString (start, end - start);
- start = end;
+ while (end < buffer.length && buffer [end] != 0) end++;
+ String string = new String (buffer, start, end - start);
+ start = end + 1;
if (count == fileNames.length) {
String [] newFileNames = new String [fileNames.length + 4];
System.arraycopy (fileNames, 0, newFileNames, 0, fileNames.length);
@@ -443,8 +435,7 @@ public String open () {
}
fileNames [count++] = string;
if ((style & SWT.MULTI) == 0) break;
- start++;
- } while (start < buffer.length () && buffer.tcharAt (start) != 0);
+ } while (start < buffer.length && buffer[start] != 0);
if (fileNames.length > 0) fileName = fileNames [0];
String separator = "";
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
index fd6ade22a2..9cfb4ba2a0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
@@ -149,14 +149,14 @@ protected void checkSubclass () {
* If the group has text, and the text is wider than the
* client area, pad the width so the text is not clipped.
*/
- TCHAR buffer = new TCHAR (getCodePage (), string == null ? text : string, true);
+ char [] buffer = (string == null ? text : string).toCharArray ();
long /*int*/ newFont, oldFont = 0;
long /*int*/ hDC = OS.GetDC (handle);
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
RECT rect = new RECT ();
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE;
- OS.DrawText (hDC, buffer, -1, rect, flags);
+ OS.DrawText (hDC, buffer, buffer.length, rect, flags);
if (newFont != 0) OS.SelectObject (hDC, oldFont);
OS.ReleaseDC (handle, hDC);
int offsetY = OS.IsAppThemed () ? 0 : 1;
@@ -502,7 +502,7 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
if (hasCustomForeground() && text.length () != 0) {
String string = fixText (false);
- TCHAR buffer = new TCHAR (getCodePage (), string == null ? text : string, false);
+ char [] buffer = (string == null ? text : string).toCharArray ();
// We cannot use BeginPaint and EndPaint, because that removes the group border
long /*int*/ hDC = OS.GetDC(handle);
@@ -514,13 +514,13 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
- OS.DrawText(hDC, buffer, buffer.length(), rect, OS.DT_SINGLELINE | OS.DT_LEFT | OS.DT_TOP | OS.DT_CALCRECT);
+ OS.DrawText(hDC, buffer, buffer.length, rect, OS.DT_SINGLELINE | OS.DT_LEFT | OS.DT_TOP | OS.DT_CALCRECT);
// The calculated rectangle is a little bit too small. Italic fonts would show some small part in the default color.
rect.right += CLIENT_INSET;
drawBackground(hDC, rect);
OS.SetBkMode(hDC, OS.TRANSPARENT);
OS.SetTextColor(hDC, getForegroundPixel());
- OS.DrawText(hDC, buffer, buffer.length(), rect, OS.DT_SINGLELINE | OS.DT_LEFT | OS.DT_TOP);
+ OS.DrawText(hDC, buffer, buffer.length, rect, OS.DT_SINGLELINE | OS.DT_LEFT | OS.DT_TOP);
if (newFont != 0) OS.SelectObject (hDC, oldFont);
OS.ReleaseDC(handle, hDC);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/IME.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/IME.java
index f6ecbd3622..9e3e860ae6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/IME.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/IME.java
@@ -369,13 +369,12 @@ LRESULT WM_IME_COMPOSITION (long /*int*/ wParam, long /*int*/ lParam) {
caretOffset = commitCount = 0;
long /*int*/ hwnd = parent.handle;
long /*int*/ hIMC = OS.ImmGetContext (hwnd);
- int codePage = parent.getCodePage ();
if (hIMC != 0) {
- TCHAR buffer = null;
+ char [] buffer = null;
if ((lParam & OS.GCS_RESULTSTR) != 0) {
- int length = OS.ImmGetCompositionString (hIMC, OS.GCS_RESULTSTR, (TCHAR)null, 0);
+ int length = OS.ImmGetCompositionString (hIMC, OS.GCS_RESULTSTR, (char [])null, 0);
if (length > 0) {
- buffer = new TCHAR (codePage, length / TCHAR.sizeof);
+ buffer = new char [length / TCHAR.sizeof];
OS.ImmGetCompositionString (hIMC, OS.GCS_RESULTSTR, buffer, length);
if (startOffset == -1) {
Event event = new Event ();
@@ -387,7 +386,7 @@ LRESULT WM_IME_COMPOSITION (long /*int*/ wParam, long /*int*/ lParam) {
event.detail = SWT.COMPOSITION_CHANGED;
event.start = startOffset;
event.end = startOffset + text.length();
- event.text = text = buffer != null ? buffer.toString () : ""; //$NON-NLS-1$
+ event.text = text = buffer != null ? new String (buffer) : ""; //$NON-NLS-1$
commitCount = text.length ();
sendEvent (SWT.ImeComposition, event);
String chars = text;
@@ -412,12 +411,12 @@ LRESULT WM_IME_COMPOSITION (long /*int*/ wParam, long /*int*/ lParam) {
}
buffer = null;
if ((lParam & OS.GCS_COMPSTR) != 0) {
- int length = OS.ImmGetCompositionString (hIMC, OS.GCS_COMPSTR, (TCHAR)null, 0);
+ int length = OS.ImmGetCompositionString (hIMC, OS.GCS_COMPSTR, (char [])null, 0);
if (length > 0) {
- buffer = new TCHAR (codePage, length / TCHAR.sizeof);
+ buffer = new char [length / TCHAR.sizeof];
OS.ImmGetCompositionString (hIMC, OS.GCS_COMPSTR, buffer, length);
if ((lParam & OS.GCS_CURSORPOS) != 0) {
- caretOffset = OS.ImmGetCompositionString (hIMC, OS.GCS_CURSORPOS, (TCHAR) null, 0);
+ caretOffset = OS.ImmGetCompositionString (hIMC, OS.GCS_CURSORPOS, (char [])null, 0);
}
int [] clauses = null;
if ((lParam & OS.GCS_COMPCLAUSE) != 0) {
@@ -509,7 +508,7 @@ LRESULT WM_IME_COMPOSITION (long /*int*/ wParam, long /*int*/ lParam) {
event.detail = SWT.COMPOSITION_CHANGED;
event.start = startOffset;
event.end = end;
- event.text = text = buffer != null ? buffer.toString () : ""; //$NON-NLS-1$
+ event.text = text = buffer != null ? new String (buffer) : ""; //$NON-NLS-1$
sendEvent (SWT.ImeComposition, event);
if (text.length() == 0) {
startOffset = -1;
@@ -581,7 +580,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
long /*int*/ hIMC = OS.ImmGetContext (hwnd);
if (hIMC != 0) {
if (OS.ImmGetOpenStatus (hIMC)) {
- if (OS.ImmGetCompositionString (hIMC, OS.GCS_COMPSTR, (TCHAR)null, 0) > 0) {
+ if (OS.ImmGetCompositionString (hIMC, OS.GCS_COMPSTR, (char [])null, 0) > 0) {
Event event = new Event ();
event.detail = SWT.COMPOSITION_OFFSET;
event.setLocationInPixels(OS.GET_X_LPARAM (lParam), OS.GET_Y_LPARAM (lParam));
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
index fbfe3348ea..4c8ddfeaec 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
@@ -177,7 +177,7 @@ static int checkStyle (int style) {
flags |= OS.DT_WORDBREAK;
rect.right = Math.max (0, wHint - width);
}
- TCHAR buffer = new TCHAR (getCodePage (), length + 1);
+ char [] buffer = new char [length + 1];
OS.GetWindowText (handle, buffer, length + 1);
OS.DrawText (hDC, buffer, length, rect, flags);
width += rect.right - rect.left;
@@ -555,7 +555,7 @@ LRESULT wmDrawChild (long /*int*/ wParam, long /*int*/ lParam) {
imageHeight = rect.height;
}
RECT rect = null;
- TCHAR buffer = null;
+ char [] buffer = null;
int textWidth = 0, textHeight = 0, flags = 0;
if (drawText) {
rect = new RECT ();
@@ -567,8 +567,8 @@ LRESULT wmDrawChild (long /*int*/ wParam, long /*int*/ lParam) {
flags |= OS.DT_WORDBREAK;
rect.right = Math.max (0, width - imageWidth - margin);
}
- buffer = new TCHAR (getCodePage (), text, true);
- OS.DrawText (struct.hDC, buffer, -1, rect, flags);
+ buffer = text.toCharArray ();
+ OS.DrawText (struct.hDC, buffer, buffer.length, rect, flags);
textWidth = rect.right - rect.left;
textHeight = rect.bottom - rect.top;
}
@@ -596,7 +596,7 @@ LRESULT wmDrawChild (long /*int*/ wParam, long /*int*/ lParam) {
rect.right += rect.left;
rect.top = Math.max (0, (height - textHeight) / 2);
rect.bottom += rect.top;
- OS.DrawText (struct.hDC, buffer, -1, rect, flags);
+ OS.DrawText (struct.hDC, buffer, buffer.length, rect, flags);
}
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
index 94a5a65122..11ffbedc50 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
@@ -176,14 +176,14 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
long /*int*/ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
long /*int*/ oldFont = OS.SelectObject (hDC, newFont);
if (text.length () > 0) {
- TCHAR buffer = new TCHAR (getCodePage (), parse (text), false);
+ char [] buffer = parse (text).toCharArray ();
RECT rect = new RECT ();
int flags = OS.DT_CALCRECT | OS.DT_NOPREFIX;
if (wHint != SWT.DEFAULT) {
flags |= OS.DT_WORDBREAK;
rect.right = wHint;
}
- OS.DrawText (hDC, buffer, buffer.length (), rect, flags);
+ OS.DrawText (hDC, buffer, buffer.length, rect, flags);
width = rect.right - rect.left;
height = rect.bottom;
} else {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
index 36800dff5c..0aa83f7cb3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
@@ -109,7 +109,7 @@ public void add (String string) {
int result = (int)/*64*/OS.SendMessage (handle, OS.LB_ADDSTRING, 0, buffer);
if (result == OS.LB_ERR) error (SWT.ERROR_ITEM_NOT_ADDED);
if (result == OS.LB_ERRSPACE) error (SWT.ERROR_ITEM_NOT_ADDED);
- if ((style & SWT.H_SCROLL) != 0) setScrollWidth (buffer, true);
+ if ((style & SWT.H_SCROLL) != 0) setScrollWidth (buffer.chars, true);
}
/**
* Adds the argument to the receiver's list at the given
@@ -152,7 +152,7 @@ public void add (String string, int index) {
error (SWT.ERROR_INVALID_RANGE);
}
}
- if ((style & SWT.H_SCROLL) != 0) setScrollWidth (buffer, true);
+ if ((style & SWT.H_SCROLL) != 0) setScrollWidth (buffer.chars, true);
}
/**
@@ -232,13 +232,12 @@ static int checkStyle (int style) {
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
RECT rect = new RECT ();
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
- int cp = getCodePage ();
- TCHAR buffer = new TCHAR (cp, 64 + 1);
+ char [] buffer = new char [64 + 1];
for (int i=0; i<count; i++) {
int length = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXTLEN, i, 0);
if (length != OS.LB_ERR) {
- if (length + 1 > buffer.length ()) {
- buffer = new TCHAR (cp, length + 1);
+ if (length + 1 > buffer.length) {
+ buffer = new char [length + 1];
}
int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXT, i, buffer);
if (result != OS.LB_ERR) {
@@ -438,9 +437,9 @@ public String getItem (int index) {
checkWidget ();
int length = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0);
if (length != OS.LB_ERR) {
- TCHAR buffer = new TCHAR (getCodePage (), length + 1);
+ char [] buffer = new char [length + 1];
int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer);
- if (result != OS.LB_ERR) return ((state & HAS_AUTO_DIRECTION) != 0) ? buffer.toString (1, length - 1) : buffer.toString (0, length);
+ if (result != OS.LB_ERR) return ((state & HAS_AUTO_DIRECTION) != 0) ? new String (buffer, 1, length - 1) : new String (buffer, 0, length);
}
int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
if (0 <= index && index < count) error (SWT.ERROR_CANNOT_GET_ITEM);
@@ -764,16 +763,16 @@ public void remove (int [] indices) {
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
}
- int cp = getCodePage ();
int i = 0, topCount = 0, last = -1;
while (i < newIndices.length) {
int index = newIndices [i];
if (index != last) {
- TCHAR buffer = null;
+ char [] buffer = null;
+ int length = 0;
if ((style & SWT.H_SCROLL) != 0) {
- int length = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0);
+ length = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0);
if (length == OS.LB_ERR) break;
- buffer = new TCHAR (cp, length + 1);
+ buffer = new char [length + 1];
int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer);
if (result == OS.LB_ERR) break;
}
@@ -781,7 +780,7 @@ public void remove (int [] indices) {
if (result == OS.LB_ERR) break;
if ((style & SWT.H_SCROLL) != 0) {
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
- OS.DrawText (hDC, buffer, -1, rect, flags);
+ OS.DrawText (hDC, buffer, length, rect, flags);
newWidth = Math.max (newWidth, rect.right - rect.left);
}
if (index < topIndex) topCount++;
@@ -817,7 +816,7 @@ public void remove (int [] indices) {
*/
public void remove (int index) {
checkWidget ();
- TCHAR buffer = null;
+ char [] buffer = null;
if ((style & SWT.H_SCROLL) != 0) {
int length = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0);
if (length == OS.LB_ERR) {
@@ -825,7 +824,7 @@ public void remove (int index) {
if (0 <= index && index < count) error (SWT.ERROR_ITEM_NOT_REMOVED);
error (SWT.ERROR_INVALID_RANGE);
}
- buffer = new TCHAR (getCodePage (), length + 1);
+ buffer = new char [length + 1];
int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer);
if (result == OS.LB_ERR) {
int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
@@ -884,22 +883,22 @@ public void remove (int start, int end) {
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
}
- int cp = getCodePage ();
int index = start;
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
while (index <= end) {
- TCHAR buffer = null;
+ char [] buffer = null;
+ int length = 0;
if ((style & SWT.H_SCROLL) != 0) {
- int length = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXTLEN, start, 0);
+ length = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXTLEN, start, 0);
if (length == OS.LB_ERR) break;
- buffer = new TCHAR (cp, length + 1);
+ buffer = new char [length + 1];
int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXT, start, buffer);
if (result == OS.LB_ERR) break;
}
int result = (int)/*64*/OS.SendMessage (handle, OS.LB_DELETESTRING, start, 0);
if (result == OS.LB_ERR) break;
if ((style & SWT.H_SCROLL) != 0) {
- OS.DrawText (hDC, buffer, -1, rect, flags);
+ OS.DrawText (hDC, buffer, length, rect, flags);
newWidth = Math.max (newWidth, rect.right - rect.left);
}
index++;
@@ -1276,16 +1275,15 @@ void setScrollWidth () {
long /*int*/ hDC = OS.GetDC (handle);
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
- int cp = getCodePage ();
int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
for (int i=0; i<count; i++) {
int length = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXTLEN, i, 0);
if (length != OS.LB_ERR) {
- TCHAR buffer = new TCHAR (cp, length + 1);
+ char [] buffer = new char [length + 1];
int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXT, i, buffer);
if (result != OS.LB_ERR) {
- OS.DrawText (hDC, buffer, -1, rect, flags);
+ OS.DrawText (hDC, buffer, length, rect, flags);
newWidth = Math.max (newWidth, rect.right - rect.left);
}
}
@@ -1295,7 +1293,7 @@ void setScrollWidth () {
OS.SendMessage (handle, OS.LB_SETHORIZONTALEXTENT, newWidth + INSET, 0);
}
-void setScrollWidth (TCHAR buffer, boolean grow) {
+void setScrollWidth (char[] buffer, boolean grow) {
RECT rect = new RECT ();
long /*int*/ newFont, oldFont = 0;
long /*int*/ hDC = OS.GetDC (handle);
@@ -1540,12 +1538,11 @@ void updateMenuLocation (Event event) {
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
- int cp = getCodePage ();
- TCHAR buffer = new TCHAR (cp, 64 + 1);
+ char [] buffer = new char [64 + 1];
int length = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXTLEN, focusIndex, 0);
if (length != OS.LB_ERR) {
- if (length + 1 > buffer.length ()) {
- buffer = new TCHAR (cp, length + 1);
+ if (length + 1 > buffer.length) {
+ buffer = new char [length + 1];
}
int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXT, focusIndex, buffer);
if (result != OS.LB_ERR) {
@@ -1580,20 +1577,17 @@ boolean updateTextDirection (int textDirection) {
int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
if (count == OS.LB_ERR) return false;
int selection = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
- int cp = getCodePage ();
addedUCC = false;
while (count-- > 0) {
int length = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXTLEN, count, 0);
if (length == OS.LB_ERR) break;
if (length == 0) continue;
- TCHAR buffer = new TCHAR (cp, length + 1);
+ char [] buffer = new char [length + 1];
if (OS.SendMessage (handle, OS.LB_GETTEXT, count, buffer) == OS.LB_ERR) break;
if (OS.SendMessage (handle, OS.LB_DELETESTRING, count, 0) == OS.LB_ERR) break;
if ((state & HAS_AUTO_DIRECTION) == 0) {
/* Should remove UCC */
- char [] chars = new char [length - 1];
- System.arraycopy (buffer.chars, 1, chars, 0, length - 1); // buffer.chars as we are always Unicode here
- buffer = new TCHAR (cp, chars, true);
+ System.arraycopy(buffer, 1, buffer, 0, length);
}
/* Adding UCC is handled in OS.LB_INSERTSTRING */
if (OS.SendMessage (handle, OS.LB_INSERTSTRING, count, buffer) == OS.LB_ERR) break;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java
index 4d112577c8..1c5c4cb0b0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java
@@ -15,9 +15,9 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class are selectable user interface
@@ -197,8 +197,7 @@ void createHandle () {
OS.SendMessage (hwndUpDown, OS.UDM_SETPOS32, 0, 0);
pageIncrement = 10;
digits = 0;
- TCHAR buffer = new TCHAR (getCodePage (), "0", true);
- OS.SetWindowText (hwndText, buffer);
+ OS.SetWindowText (hwndText, new char [] {'0', '\0'});
}
/**
@@ -316,9 +315,9 @@ long /*int*/ borderHandle () {
}
string = buffer.toString ();
}
- TCHAR buffer = new TCHAR (getCodePage (), string, false);
+ char [] buffer = string.toCharArray ();
int flags = OS.DT_CALCRECT | OS.DT_EDITCONTROL | OS.DT_NOPREFIX;
- OS.DrawText (hDC, buffer, buffer.length (), rect, flags);
+ OS.DrawText (hDC, buffer, buffer.length, rect, flags);
width = rect.right - rect.left;
if (newFont != 0) OS.SelectObject (hDC, oldFont);
OS.ReleaseDC (hwndText, hDC);
@@ -445,9 +444,9 @@ public int getDigits () {
}
String getDecimalSeparator () {
- TCHAR tchar = new TCHAR (getCodePage (), 4);
- int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SDECIMAL, tchar, 4);
- return size != 0 ? tchar.toString (0, size - 1) : ".";
+ char [] data = new char [4];
+ int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SDECIMAL, data, 4);
+ return size != 0 ? new String (data, 0, size - 1) : ".";
}
/**
@@ -535,9 +534,9 @@ public int getSelection () {
int getSelectionText (boolean [] parseFail) {
int length = OS.GetWindowTextLength (hwndText);
- TCHAR buffer = new TCHAR (getCodePage (), length + 1);
+ char [] buffer = new char [length + 1];
OS.GetWindowText (hwndText, buffer, length + 1);
- String string = buffer.toString (0, length);
+ String string = new String (buffer, 0, length);
try {
int value;
if (digits > 0) {
@@ -594,9 +593,9 @@ public String getText () {
checkWidget ();
int length = OS.GetWindowTextLength (hwndText);
if (length == 0) return "";
- TCHAR buffer = new TCHAR (getCodePage (), length + 1);
+ char [] buffer = new char [length + 1];
OS.GetWindowText (hwndText, buffer, length + 1);
- return buffer.toString (0, length);
+ return new String (buffer, 0, length);
}
/**
@@ -1334,9 +1333,9 @@ LRESULT wmClipboard (long /*int*/ hwndText, int msg, long /*int*/ wParam, long /
int [] newStart = new int [1], newEnd = new int [1];
OS.SendMessage (hwndText, OS.EM_GETSEL, newStart, newEnd);
if (length != 0 && newStart [0] != newEnd [0]) {
- TCHAR buffer = new TCHAR (getCodePage (), length + 1);
+ char [] buffer = new char [length + 1];
OS.GetWindowText (hwndText, buffer, length + 1);
- newText = buffer.toString (newStart [0], newEnd [0] - newStart [0]);
+ newText = new String (buffer, newStart [0], newEnd [0] - newStart [0]);
} else {
newText = "";
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
index ba8e42a2ca..ea336bef0c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
@@ -819,9 +819,9 @@ void updateOrientation () {
super.updateOrientation ();
long /*int*/ hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
while (hwndChild != 0) {
- TCHAR buffer = new TCHAR (0, 128);
- OS.GetClassName (hwndChild, buffer, buffer.length ());
- String className = buffer.toString (0, buffer.strlen ());
+ char [] buffer = new char [128];
+ int length = OS.GetClassName (hwndChild, buffer, buffer.length);
+ String className = new String (buffer, 0, length);
if (className.equals ("msctls_updown32")) { //$NON-NLS-1$
int bits = OS.GetWindowLong (hwndChild, OS.GWL_EXSTYLE);
if ((style & SWT.RIGHT_TO_LEFT) != 0) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
index a9153709d9..9418c1352a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
@@ -4853,9 +4853,9 @@ boolean setScrollWidth (TableItem item, boolean force) {
long /*int*/ hDC = OS.GetDC (handle);
long /*int*/ oldFont = OS.SelectObject (hDC, hFont);
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
- TCHAR buffer = new TCHAR (getCodePage (), string, false);
+ char [] buffer = string.toCharArray ();
RECT rect = new RECT ();
- OS.DrawText (hDC, buffer, buffer.length (), rect, flags);
+ OS.DrawText (hDC, buffer, buffer.length, rect, flags);
OS.SelectObject (hDC, oldFont);
OS.ReleaseDC (handle, hDC);
newWidth = Math.max (newWidth, rect.right - rect.left);
@@ -4878,7 +4878,7 @@ boolean setScrollWidth (TableItem item, boolean force) {
* space.
*/
if (newWidth == 0) {
- TCHAR buffer = new TCHAR (getCodePage (), " ", true);
+ char [] buffer = {' ', '\0'};
newWidth = Math.max (newWidth, (int)/*64*/OS.SendMessage (handle, OS.LVM_GETSTRINGWIDTH, 0, buffer));
}
long /*int*/ hStateList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
@@ -6996,7 +6996,7 @@ LRESULT wmNotifyHeader (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
int flags = OS.DT_NOPREFIX | OS.DT_SINGLELINE | OS.DT_VCENTER;
if ((columns[i].style & SWT.CENTER) != 0) flags |= OS.DT_CENTER;
if ((columns[i].style & SWT.RIGHT) != 0) flags |= OS.DT_RIGHT;
- TCHAR buffer = new TCHAR (getCodePage (), columns[i].text, false);
+ char [] buffer = columns[i].text.toCharArray ();
OS.SetBkMode(nmcd.hdc, OS.TRANSPARENT);
OS.SetTextColor(nmcd.hdc, getHeaderForegroundPixel());
RECT textRect = new RECT();
@@ -7004,7 +7004,7 @@ LRESULT wmNotifyHeader (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
textRect.top = rects[i].top;
textRect.right = rects[i].right;
textRect.bottom = rects[i].bottom;
- OS.DrawText (nmcd.hdc, buffer, buffer.length (), textRect, flags);
+ OS.DrawText (nmcd.hdc, buffer, buffer.length, textRect, flags);
}
}
@@ -7330,10 +7330,10 @@ LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long /*int*/ lParam) {
if ((column.style & SWT.CENTER) != 0) flags |= OS.DT_CENTER;
if ((column.style & SWT.RIGHT) != 0) flags |= OS.DT_RIGHT;
}
- TCHAR buffer = new TCHAR (getCodePage (), string, false);
+ char [] buffer = string.toCharArray ();
RECT textRect = new RECT ();
OS.SetRect (textRect, x, cellRect.top, cellRect.right, cellRect.bottom);
- OS.DrawText (nmcd.hdc, buffer, buffer.length (), textRect, flags);
+ OS.DrawText (nmcd.hdc, buffer, buffer.length, textRect, flags);
}
gc.dispose ();
OS.RestoreDC (nmcd.hdc, nSavedDC);
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 7b488a8ac4..b6bc0cb37e 100644
--- 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
@@ -752,8 +752,8 @@ public void setText (String string) {
* mnemonic characters.
*/
long /*int*/ hHeap = OS.GetProcessHeap ();
- TCHAR buffer = new TCHAR (parent.getCodePage (), fixMnemonic (string), true);
- int byteCount = buffer.length () * TCHAR.sizeof;
+ char [] buffer = fixMnemonic (string);
+ int byteCount = buffer.length * TCHAR.sizeof;
long /*int*/ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
OS.MoveMemory (pszText, buffer, byteCount);
lvColumn.mask |= OS.LVCF_TEXT;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java
index 63e5ae1870..c58affa272 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java
@@ -280,7 +280,7 @@ RECT getBounds (int row, int column, boolean getText, boolean getImage, boolean
TCHAR buffer = new TCHAR (parent.getCodePage (), text, true);
width = (int)/*64*/OS.SendMessage (hwnd, OS.LVM_GETSTRINGWIDTH, 0, buffer);
} else {
- TCHAR buffer = new TCHAR (parent.getCodePage (), text, false);
+ char [] buffer = text.toCharArray ();
long /*int*/ textDC = hDC != 0 ? hDC : OS.GetDC (hwnd), oldFont = -1;
if (hDC == 0) {
if (hFont == -1) hFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);
@@ -288,7 +288,7 @@ RECT getBounds (int row, int column, boolean getText, boolean getImage, boolean
}
RECT textRect = new RECT ();
int flags = OS.DT_NOPREFIX | OS.DT_SINGLELINE | OS.DT_CALCRECT;
- OS.DrawText (textDC, buffer, buffer.length (), textRect, flags);
+ OS.DrawText (textDC, buffer, buffer.length, textRect, flags);
width = textRect.right - textRect.left;
if (hDC == 0) {
if (oldFont != -1) OS.SelectObject (textDC, oldFont);
@@ -397,9 +397,9 @@ RECT getBounds (int row, int column, boolean getText, boolean getImage, boolean
String string = column == 0 ? text : strings != null ? strings [column] : null;
if (string != null) {
RECT textRect = new RECT ();
- TCHAR buffer = new TCHAR (parent.getCodePage (), string, false);
+ char [] buffer = string.toCharArray ();
int flags = OS.DT_NOPREFIX | OS.DT_SINGLELINE | OS.DT_CALCRECT;
- OS.DrawText (hDC, buffer, buffer.length (), textRect, flags);
+ OS.DrawText (hDC, buffer, buffer.length, textRect, flags);
rect.right += textRect.right - textRect.left + Table.INSET * 3 + 2;
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskBar.java
index a9a4f53804..ed3c218b2c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskBar.java
@@ -81,13 +81,11 @@ public class TaskBar extends Widget {
OS.IIDFromString ("{F1B32785-6FBA-4FCF-9D55-7B8E7F157091}\0".toCharArray (), FOLDERID_LocalAppData); //$NON-NLS-1$
OS.PSPropertyKeyFromString ("{F29F85E0-4FF9-1068-AB91-08002B27B3D9} 2\0".toCharArray (), PKEY_Title); //$NON-NLS-1$
OS.PSPropertyKeyFromString ("{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}, 6\0".toCharArray (), PKEY_AppUserModel_IsDestListSeparator); //$NON-NLS-1$
- TCHAR buffer = new TCHAR (0, OS.MAX_PATH);
- while (OS.GetModuleFileName (0, buffer, buffer.length ()) == buffer.length ()) {
- buffer = new TCHAR (0, buffer.length () + OS.MAX_PATH);
+ char [] buffer = new char [OS.MAX_PATH];
+ while (OS.GetModuleFileName (0, buffer, buffer.length) == buffer.length) {
+ buffer = new char [buffer.length + OS.MAX_PATH];
}
- int length = buffer.strlen ();
- EXE_PATH = new char [length + 1];
- System.arraycopy (buffer.chars, 0, EXE_PATH, 0, length);
+ EXE_PATH = buffer;
}
TaskBar (Display display, int style) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskItem.java
index dfe6af9b96..575c6fdd02 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskItem.java
@@ -517,8 +517,8 @@ void updateText () {
int uFormat = OS.DT_LEFT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
RECT rect = new RECT ();
- TCHAR buffer = new TCHAR (shell.getCodePage (), overlayText, false);
- int length = buffer.length();
+ char [] buffer = overlayText.toCharArray ();
+ int length = buffer.length;
long /*int*/ hFont = 0, oldHFont = 0;
NONCLIENTMETRICS info = new NONCLIENTMETRICS ();
info.cbSize = NONCLIENTMETRICS.sizeof;
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 186bb398b1..020f5bf972 100644
--- 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
@@ -14,6 +14,8 @@
package org.eclipse.swt.widgets;
+import java.util.*;
+
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
@@ -227,7 +229,7 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
rect.right--;
rect.bottom--;
}
- TCHAR buffer = new TCHAR (getCodePage (), message, false);
+ char [] buffer = message.toCharArray ();
int uFormat = OS.DT_EDITCONTROL;
boolean rtl = (style & SWT.RIGHT_TO_LEFT) != 0;
if (rtl) uFormat |= OS.DT_RTLREADING;
@@ -241,7 +243,7 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
long /*int*/ hOldFont = OS.SelectObject (hDC, hFont);
OS.SetTextColor (hDC, OS.GetSysColor (OS.COLOR_GRAYTEXT));
OS.SetBkMode (hDC, OS.TRANSPARENT);
- OS.DrawText (hDC, buffer, buffer.length (), rect, uFormat);
+ OS.DrawText (hDC, buffer, buffer.length, rect, uFormat);
OS.SelectObject (hDC, hOldFont);
}
@@ -479,10 +481,9 @@ void applySegments () {
if (isDisposed() || --clearSegmentsCount != 0) return;
if (!hooks (SWT.Segments) && !filters (SWT.Segments)) return;
int length = OS.GetWindowTextLength (handle);
- int cp = getCodePage ();
- TCHAR buffer = new TCHAR (cp, length + 1);
+ char [] buffer = new char [length + 1];
if (length > 0) OS.GetWindowText (handle, buffer, length + 1);
- String string = buffer.toString (0, length);
+ String string = new String (buffer, 0, length);
/* Get segments text */
Event event = new Event ();
event.text = string;
@@ -545,10 +546,9 @@ void applySegments () {
* Sending OS.EM_REPLACESEL message instead.
*/
newChars [length] = 0;
- buffer = new TCHAR (cp, newChars, false);
OS.SendMessage (handle, OS.EM_SETSEL, 0, -1);
long /*int*/ undo = OS.SendMessage (handle, OS.EM_CANUNDO, 0, 0);
- OS.SendMessage (handle, OS.EM_REPLACESEL, undo, buffer);
+ OS.SendMessage (handle, OS.EM_REPLACESEL, undo, newChars);
/* Restore selection */
start [0] = translateOffset (start [0]);
end [0] = translateOffset (end [0]);
@@ -656,10 +656,10 @@ public void clearSelection () {
}
int length = OS.GetWindowTextLength (handle);
if (length != 0) {
- TCHAR buffer = new TCHAR (getCodePage (), length + 1);
+ char [] buffer = new char [length + 1];
OS.GetWindowText (handle, buffer, length + 1);
OS.DrawText (hDC, buffer, length, rect, flags);
- buffer.clear ();
+ Arrays.fill (buffer, '\0'); // erase sensitive data
width = rect.right - rect.left;
}
if (wrap && hHint == SWT.DEFAULT) {
@@ -668,8 +668,8 @@ public void clearSelection () {
}
if ((style & SWT.SINGLE) != 0 && message.length () > 0) {
OS.SetRect (rect, 0, 0, 0, 0);
- TCHAR buffer = new TCHAR (getCodePage (), message, false);
- OS.DrawText (hDC, buffer, buffer.length (), rect, flags);
+ char [] buffer = message.toCharArray ();
+ OS.DrawText (hDC, buffer, buffer.length, rect, flags);
width = Math.max (width, rect.right - rect.left);
}
if (newFont != 0) OS.SelectObject (hDC, oldFont);
@@ -916,7 +916,6 @@ Point getCaretLocationInPixels () {
if (caretPos == -1) {
caretPos = 0;
if (position >= OS.GetWindowTextLength (handle)) {
- int cp = getCodePage ();
int [] start = new int [1], end = new int [1];
OS.SendMessage (handle, OS.EM_GETSEL, start, end);
OS.SendMessage (handle, OS.EM_SETSEL, position, position);
@@ -932,10 +931,10 @@ Point getCaretLocationInPixels () {
* handler from WM_CHAR.
*/
ignoreCharacter = ignoreModify = true;
- OS.SendMessage (handle, OS.EM_REPLACESEL, 0, new TCHAR (cp, " ", true));
+ OS.SendMessage (handle, OS.EM_REPLACESEL, 0, new char [] {' ', '\0'});
caretPos = OS.SendMessage (handle, OS.EM_POSFROMCHAR, position, 0);
OS.SendMessage (handle, OS.EM_SETSEL, position, position + 1);
- OS.SendMessage (handle, OS.EM_REPLACESEL, 0, new TCHAR (cp, "", true));
+ OS.SendMessage (handle, OS.EM_REPLACESEL, 0, new char [] {'\0'});
ignoreCharacter = ignoreModify = false;
OS.SendMessage (handle, OS.EM_SETSEL, start [0], start [0]);
OS.SendMessage (handle, OS.EM_SETSEL, start [0], end [0]);
@@ -1296,8 +1295,7 @@ int getTabWidth (int tabs) {
long /*int*/ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
- TCHAR SPACE = new TCHAR (getCodePage (), " ", false);
- OS.DrawText (hDC, SPACE, SPACE.length (), rect, flags);
+ OS.DrawText (hDC, new char [] {' '}, 1, rect, flags);
if (newFont != 0) OS.SelectObject (hDC, oldFont);
OS.ReleaseDC (handle, hDC);
return (rect.right - rect.left) * tabs;
@@ -2793,9 +2791,9 @@ LRESULT wmClipboard (int msg, long /*int*/ wParam, long /*int*/ lParam) {
int [] newStart = new int [1], newEnd = new int [1];
OS.SendMessage (handle, OS.EM_GETSEL, newStart, newEnd);
if (length != 0 && newStart [0] != newEnd [0]) {
- TCHAR buffer = new TCHAR (getCodePage (), length + 1);
+ char [] buffer = new char [length + 1];
OS.GetWindowText (handle, buffer, length + 1);
- newText = buffer.toString (newStart [0], newEnd [0] - newStart [0]);
+ newText = new String (buffer, newStart [0], newEnd [0] - newStart [0]);
} else {
newText = "";
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
index 7c16faa14e..877edcd18d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
@@ -823,9 +823,9 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int
if ((string != null) && (string.length() > Item.TEXT_LIMIT)) {
string = string.substring(0, Item.TEXT_LIMIT - Item.ELLIPSIS.length()) + Item.ELLIPSIS;
}
- TCHAR buffer = new TCHAR (getCodePage (), string, false);
- if (!ignoreDrawForeground) OS.DrawText (hDC, buffer, buffer.length (), rect, flags);
- OS.DrawText (hDC, buffer, buffer.length (), rect, flags | OS.DT_CALCRECT);
+ char [] buffer = string.toCharArray ();
+ if (!ignoreDrawForeground) OS.DrawText (hDC, buffer, buffer.length, rect, flags);
+ OS.DrawText (hDC, buffer, buffer.length, rect, flags | OS.DT_CALCRECT);
if (hFont != -1) hFont = OS.SelectObject (hDC, hFont);
if (clrText != -1) clrText = OS.SetTextColor (hDC, clrText);
if (clrTextBk != -1) clrTextBk = OS.SetBkColor (hDC, clrTextBk);
@@ -7324,11 +7324,11 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
if (strings != null) string = strings [index];
}
if (string != null) {
- TCHAR buffer = new TCHAR (getCodePage (), string, false);
- int byteCount = Math.min (buffer.length (), lptvdi.cchTextMax - 1) * TCHAR.sizeof;
- OS.MoveMemory (lptvdi.pszText, buffer, byteCount);
- OS.MoveMemory (lptvdi.pszText + byteCount, new byte [TCHAR.sizeof], TCHAR.sizeof);
- lptvdi.cchTextMax = Math.min (lptvdi.cchTextMax, string.length () + 1);
+ int length = Math.min (string.length() + 1, lptvdi.cchTextMax);
+ char [] buffer = new char [length];
+ string.getChars(0, length - 1, buffer, 0);
+ OS.MoveMemory (lptvdi.pszText, buffer, length * TCHAR.sizeof);
+ lptvdi.cchTextMax = length;
}
}
if ((lptvdi.mask & (OS.TVIF_IMAGE | OS.TVIF_SELECTEDIMAGE)) != 0) {
@@ -7744,7 +7744,7 @@ LRESULT wmNotifyHeader (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
int flags = OS.DT_NOPREFIX | OS.DT_SINGLELINE | OS.DT_VCENTER;
if ((columns[i].style & SWT.CENTER) != 0) flags |= OS.DT_CENTER;
if ((columns[i].style & SWT.RIGHT) != 0) flags |= OS.DT_RIGHT;
- TCHAR buffer = new TCHAR (getCodePage (), columns[i].text, false);
+ char [] buffer = columns[i].text.toCharArray ();
OS.SetBkMode(nmcd.hdc, OS.TRANSPARENT);
OS.SetTextColor(nmcd.hdc, getHeaderForegroundPixel());
RECT textRect = new RECT();
@@ -7752,7 +7752,7 @@ LRESULT wmNotifyHeader (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
textRect.top = rects[i].top;
textRect.right = rects[i].right;
textRect.bottom = rects[i].bottom;
- OS.DrawText (nmcd.hdc, buffer, buffer.length (), textRect, flags);
+ OS.DrawText (nmcd.hdc, buffer, buffer.length, textRect, flags);
}
}
@@ -8043,10 +8043,10 @@ LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long /*int*/ lParam) {
if ((column.style & SWT.CENTER) != 0) flags |= OS.DT_CENTER;
if ((column.style & SWT.RIGHT) != 0) flags |= OS.DT_RIGHT;
}
- TCHAR buffer = new TCHAR (getCodePage (), string, false);
+ char [] buffer = string.toCharArray ();
RECT textRect = new RECT ();
OS.SetRect (textRect, x, cellRect [0].top, cellRect [0].right, cellRect [0].bottom);
- OS.DrawText (nmcd.hdc, buffer, buffer.length (), textRect, flags);
+ OS.DrawText (nmcd.hdc, buffer, buffer.length, textRect, flags);
}
gc.dispose ();
OS.RestoreDC (nmcd.hdc, nSavedDC);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java
index 7bded099db..1cd30929ad 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java
@@ -378,8 +378,8 @@ public void pack () {
}
RECT rect = new RECT ();
int flags = OS.DT_CALCRECT | OS.DT_NOPREFIX;
- TCHAR buffer = new TCHAR (parent.getCodePage (), text, false);
- OS.DrawText (hDC, buffer, buffer.length (), rect, flags);
+ char [] buffer = text.toCharArray ();
+ OS.DrawText (hDC, buffer, buffer.length, rect, flags);
int headerWidth = rect.right - rect.left + Tree.HEADER_MARGIN;
if (OS.IsAppThemed ()) headerWidth += Tree.HEADER_EXTRA;
if (image != null || parent.sortColumn == this) {
@@ -659,8 +659,8 @@ public void setText (String string) {
* mnemonic characters.
*/
long /*int*/ hHeap = OS.GetProcessHeap ();
- TCHAR buffer = new TCHAR (parent.getCodePage (), fixMnemonic (string), true);
- int byteCount = buffer.length () * TCHAR.sizeof;
+ char [] buffer = fixMnemonic (string);
+ int byteCount = buffer.length * TCHAR.sizeof;
long /*int*/ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
OS.MoveMemory (pszText, buffer, byteCount);
long /*int*/ hwndHeader = parent.hwndHeader;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java
index 4823e5000b..1dd27b6dd0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java
@@ -523,7 +523,7 @@ RECT getBounds (int index, boolean getText, boolean getImage, boolean fullText,
String string = index == 0 ? text : strings != null ? strings [index] : null;
if (string != null) {
RECT textRect = new RECT ();
- TCHAR buffer = new TCHAR (parent.getCodePage (), string, false);
+ char [] buffer = string.toCharArray ();
int flags = OS.DT_NOPREFIX | OS.DT_SINGLELINE | OS.DT_CALCRECT;
long /*int*/ hNewDC = hDC, hFont = 0;
if (hDC == 0) {
@@ -532,7 +532,7 @@ RECT getBounds (int index, boolean getText, boolean getImage, boolean fullText,
if (hFont == -1) hFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);
hFont = OS.SelectObject (hNewDC, hFont);
}
- OS.DrawText (hNewDC, buffer, buffer.length (), textRect, flags);
+ OS.DrawText (hNewDC, buffer, buffer.length, textRect, flags);
if (hDC == 0) {
OS.SelectObject (hNewDC, hFont);
OS.ReleaseDC (hwnd, hNewDC);
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 a6794898bf..d8b2584dcb 100644
--- 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
@@ -468,6 +468,7 @@ char [] fixMnemonic (String string, boolean spaces) {
}
char [] fixMnemonic (String string, boolean spaces, boolean removeAppended) {
+ // fixMnemonic must return a null-terminated array
char [] buffer = new char [string.length () + 1];
string.getChars (0, string.length (), buffer, 0);
int i = 0, j = 0;
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet83.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet83.java
index 25e1d6892b..53d4659189 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet83.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet83.java
@@ -24,7 +24,6 @@ package org.eclipse.swt.snippets;
import org.eclipse.swt.*;
import org.eclipse.swt.dnd.*;
import org.eclipse.swt.internal.ole.win32.*;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
@@ -112,10 +111,10 @@ protected int[] getTypeIds(){
static String getNameFromId(int id) {
String name = null;
int maxSize = 128;
- TCHAR buffer = new TCHAR(0, maxSize);
+ char [] buffer = new char [maxSize];
int size = COM.GetClipboardFormatName(id, buffer, maxSize);
if (size != 0) {
- name = buffer.toString(0, size);
+ name = new String (buffer, 0, size);
} else {
switch (id) {
case COM.CF_HDROP:

Back to the top