blob: 5e274da71fed94b6fde542428b48c8cb2b7b74c7 [file] [log] [blame]
package org.eclipse.swt.browser;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.internal.win32.OS;
import org.eclipse.swt.widgets.*;
class MozillaDelegate {
Browser browser;
MozillaDelegate (Browser browser) {
super ();
this.browser = browser;
}
static Browser findBrowser (int /*long*/ handle) {
Display display = Display.getCurrent ();
return (Browser)display.findWidget (handle);
}
public static char[] mbcsToWcs (String codePage, byte[] buffer) {
char[] chars = new char[buffer.length];
int charCount = OS.MultiByteToWideChar (OS.CP_ACP, OS.MB_PRECOMPOSED, buffer, buffer.length, chars, chars.length);
if (charCount == chars.length) return chars;
char[] result = new char[charCount];
System.arraycopy (chars, 0, result, 0, charCount);
return result;
}
public static byte[] wcsToMbcs (String codePage, String string, boolean terminate) {
int byteCount;
char[] chars = new char[string.length()];
string.getChars (0, chars.length, chars, 0);
byte[] bytes = new byte[byteCount = chars.length * 2 + (terminate ? 1 : 0)];
byteCount = OS.WideCharToMultiByte (OS.CP_ACP, 0, chars, chars.length, bytes, byteCount, null, null);
if (terminate) {
byteCount++;
} else {
if (bytes.length != byteCount) {
byte[] result = new byte[byteCount];
System.arraycopy (bytes, 0, result, 0, byteCount);
bytes = result;
}
}
return bytes;
}
int /*long*/ getHandle () {
return browser.handle;
}
String getLibraryName () {
return "xpcom.dll";
}
void onDispose (int /*long*/ embedHandle) {
}
void setSize (int /*long*/ embedHandle, int width, int height) {
}
}