KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > swt > browser > MozillaDelegate


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 /*long*/ handle) {
26     Display display = Display.getCurrent ();
27     return (Browser)display.findWidget (handle);
28 }
29
30 static char[] mbcsToWcs (String JavaDoc 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 JavaDoc codePage, String JavaDoc 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 /*long*/ getHandle () {
58     return browser.handle;
59 }
60
61 String JavaDoc getLibraryName () {
62     return "xpcom.dll"; //$NON-NLS-1$
63
}
64
65 void handleFocus () {
66 }
67
68 boolean hookEnterExit () {
69     return true;
70 }
71
72 void init () {
73 }
74
75 void onDispose (int /*long*/ embedHandle) {
76     browser = null;
77 }
78
79 void setSize (int /*long*/ embedHandle, int width, int height) {
80 }
81
82 }
83
Popular Tags