comparison dwt/browser/MozillaDelegate.d @ 45:d8635bb48c7c

Merge with SWT 3.5
author Jacob Carlborg <doob@me.com>
date Mon, 01 Dec 2008 17:07:00 +0100
parents db5a898b2119
children 540fa4e9974a
comparison
equal deleted inserted replaced
44:ca5e494f2bbf 45:d8635bb48c7c
1 /******************************************************************************* 1 /*******************************************************************************
2 * Copyright (c) 2003, 2007 IBM Corporation and others. 2 * Copyright (c) 2003, 2008 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials 3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0 4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at 5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html 6 * http://www.eclipse.org/legal/epl-v10.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * IBM Corporation - initial API and implementation 9 * IBM Corporation - initial API and implementation
10 * 10 *
11 * Port to the D programming language: 11 * Port to the D programming language:
12 * Jacob Carlborg <jacob.carlborg@gmail.com> 12 * Jacob Carlborg <doob@me.com>
13 *******************************************************************************/ 13 *******************************************************************************/
14 module dwt.browser.MozillaDelegate; 14 module dwt.browser.MozillaDelegate;
15 15
16 import dwt.DWT; 16 import dwt.DWT;
17 import dwt.browser.Browser; 17 import dwt.browser.Browser;
29 this (Browser browser) { 29 this (Browser browser) {
30 super(); 30 super();
31 this.browser = browser; 31 this.browser = browser;
32 } 32 }
33 33
34 static Browser findBrowser (int handle) { 34 static Browser findBrowser (int /*long*/ handle) {
35 Display display = Display.getCurrent(); 35 Display display = Display.getCurrent();
36 return cast(Browser) display.findWidget(handle); 36 return cast(Browser) display.findWidget(handle);
37 } 37 }
38 38
39 static char[] mbcsToWcs (String codePage, byte[] buffer) { 39 static char[] mbcsToWcs (String codePage, byte[] buffer) {
49 // OS.CFStringGetCharacters (cfString, range, chars); 49 // OS.CFStringGetCharacters (cfString, range, chars);
50 // } 50 // }
51 // OS.CFRelease (cfString); 51 // OS.CFRelease (cfString);
52 // } 52 // }
53 // return chars; 53 // return chars;
54 54 // TODO implement mbcsToWcs
55 //return new String(buffer).toCharArray(); commented by Jacob Carlborg 55 //return new String(buffer).toCharArray(); commented by Jacob Carlborg
56 return cast(char[]) buffer.dup; // FIXME 56 return cast(char[]) buffer.dup; // FIXME
57 } 57 }
58 58
59 static byte[] wcsToMbcs (String codePage, String str, bool terminate) { 59 static byte[] wcsToMbcs (String codePage, String str, bool terminate) {
72 // numChars = OS.CFStringGetBytes (cfString, range, encoding, cast(byte)'?', true, buffer, size[0], size); 72 // numChars = OS.CFStringGetBytes (cfString, range, encoding, cast(byte)'?', true, buffer, size[0], size);
73 // } 73 // }
74 // OS.CFRelease (cfString); 74 // OS.CFRelease (cfString);
75 // } 75 // }
76 // return buffer; 76 // return buffer;
77 // TODO implement wcsToMbcs
77 if (terminate) 78 if (terminate)
78 str ~= "\0"; 79 str ~= "\0";
79 80
80 //return str.getBytes(); commented by Jacob Carlborg 81 //return str.getBytes(); commented by Jacob Carlborg
81 return cast(byte[]) str.dup; // FIXME 82 return cast(byte[]) str.dup; // FIXME
82 } 83 }
83 84
84 int getHandle () { 85 int /*long*/ getHandle () {
85 return browser.view.id; 86 return browser.view.id;
86 } 87 }
87 88
88 String getLibraryName () { 89 String getLibraryName () {
89 return "libxpcom.dylib"; //$NON-NLS-1$ 90 return "libxpcom.dylib"; //$NON-NLS-1$
128 129
129 bool needsSpinup () { 130 bool needsSpinup () {
130 return false; 131 return false;
131 } 132 }
132 133
133 void onDispose (int embedHandle) { 134 void onDispose (int /*long*/ embedHandle) {
134 if (listener !is null) { 135 if (listener !is null) {
135 browser.getDisplay().removeFilter(DWT.FocusIn, listener); 136 browser.getDisplay().removeFilter(DWT.FocusIn, listener);
136 browser.getShell().removeListener(DWT.Deactivate, listener); 137 browser.getShell().removeListener(DWT.Deactivate, listener);
137 listener = null; 138 listener = null;
138 } 139 }
139 browser = null; 140 browser = null;
140 } 141 }
141 142
142 void setSize (int embedHandle, int width, int height) { 143 void setSize (int /*long*/ embedHandle, int width, int height) {
143 // TODO 144 // TODO
144 } 145 }
145 146
146 } 147 }