1 11 package org.eclipse.swt.browser; 12 13 import org.eclipse.swt.browser.Browser; 14 import org.eclipse.swt.internal.win32.OS; 15 import org.eclipse.swt.widgets.*; 16 17 class MozillaDelegate { 18 Browser browser; 19 20 MozillaDelegate (Browser browser) { 21 super (); 22 this.browser = browser; 23 } 24 25 static Browser findBrowser (int handle) { 26 Display display = Display.getCurrent (); 27 return (Browser)display.findWidget (handle); 28 } 29 30 static char[] mbcsToWcs (String codePage, byte[] buffer) { 31 char[] chars = new char[buffer.length]; 32 int charCount = OS.MultiByteToWideChar (OS.CP_ACP, OS.MB_PRECOMPOSED, buffer, buffer.length, chars, chars.length); 33 if (charCount == chars.length) return chars; 34 char[] result = new char[charCount]; 35 System.arraycopy (chars, 0, result, 0, charCount); 36 return result; 37 } 38 39 static byte[] wcsToMbcs (String codePage, String string, boolean terminate) { 40 int byteCount; 41 char[] chars = new char[string.length()]; 42 string.getChars (0, chars.length, chars, 0); 43 byte[] bytes = new byte[byteCount = chars.length * 2 + (terminate ? 1 : 0)]; 44 byteCount = OS.WideCharToMultiByte (OS.CP_ACP, 0, chars, chars.length, bytes, byteCount, null, null); 45 if (terminate) { 46 byteCount++; 47 } else { 48 if (bytes.length != byteCount) { 49 byte[] result = new byte[byteCount]; 50 System.arraycopy (bytes, 0, result, 0, byteCount); 51 bytes = result; 52 } 53 } 54 return bytes; 55 } 56 57 int getHandle () { 58 return browser.handle; 59 } 60 61 String getLibraryName () { 62 return "xpcom.dll"; } 64 65 void handleFocus () { 66 } 67 68 boolean hookEnterExit () { 69 return true; 70 } 71 72 void init () { 73 } 74 75 void onDispose (int embedHandle) { 76 browser = null; 77 } 78 79 void setSize (int embedHandle, int width, int height) { 80 } 81 82 } 83 | Popular Tags |