01: /*******************************************************************************
02: * Copyright (c) 2005, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.swt.browser;
11:
12: import org.eclipse.swt.browser.Browser;
13: import org.eclipse.swt.internal.win32.OS;
14: import org.eclipse.swt.widgets.*;
15:
16: class MozillaDelegate {
17: Browser browser;
18:
19: MozillaDelegate(Browser browser) {
20: super ();
21: this .browser = browser;
22: }
23:
24: static Browser findBrowser(int /*long*/handle) {
25: Display display = Display.getCurrent();
26: return (Browser) display.findWidget(handle);
27: }
28:
29: static char[] mbcsToWcs(String codePage, byte[] buffer) {
30: char[] chars = new char[buffer.length];
31: int charCount = OS.MultiByteToWideChar(OS.CP_ACP,
32: OS.MB_PRECOMPOSED, buffer, buffer.length, chars,
33: chars.length);
34: if (charCount == chars.length)
35: return chars;
36: char[] result = new char[charCount];
37: System.arraycopy(chars, 0, result, 0, charCount);
38: return result;
39: }
40:
41: static byte[] wcsToMbcs(String codePage, String string,
42: boolean terminate) {
43: int byteCount;
44: char[] chars = new char[string.length()];
45: string.getChars(0, chars.length, chars, 0);
46: byte[] bytes = new byte[byteCount = chars.length * 2
47: + (terminate ? 1 : 0)];
48: byteCount = OS.WideCharToMultiByte(OS.CP_ACP, 0, chars,
49: chars.length, bytes, byteCount, null, null);
50: if (terminate) {
51: byteCount++;
52: } else {
53: if (bytes.length != byteCount) {
54: byte[] result = new byte[byteCount];
55: System.arraycopy(bytes, 0, result, 0, byteCount);
56: bytes = result;
57: }
58: }
59: return bytes;
60: }
61:
62: int /*long*/getHandle() {
63: return browser.handle;
64: }
65:
66: String getLibraryName() {
67: return "xpcom.dll"; //$NON-NLS-1$
68: }
69:
70: void handleFocus() {
71: }
72:
73: boolean hookEnterExit() {
74: return true;
75: }
76:
77: void init() {
78: }
79:
80: void onDispose(int /*long*/embedHandle) {
81: browser = null;
82: }
83:
84: void setSize(int /*long*/embedHandle, int width, int height) {
85: }
86:
87: }
|