# HG changeset patch # User Jacob Carlborg # Date 1232145340 -3600 # Node ID 38807a925e248db6b4ccdf03d3b940738d93e9b2 # Parent 5583f8eeee6cee10218b0b378c475fc6a46707a4 Fixed compile errors, support for SWT language files diff -r 5583f8eeee6c -r 38807a925e24 .hgignore --- a/.hgignore Fri Jan 16 12:49:08 2009 +0100 +++ b/.hgignore Fri Jan 16 23:35:40 2009 +0100 @@ -5,4 +5,5 @@ dsss.last *.orig dsss_imports -*.sh \ No newline at end of file +*.sh +*.a \ No newline at end of file diff -r 5583f8eeee6c -r 38807a925e24 dsss.conf --- a/dsss.conf Fri Jan 16 12:49:08 2009 +0100 +++ b/dsss.conf Fri Jan 16 23:35:40 2009 +0100 @@ -1,8 +1,9 @@ [dwt] -version (GDC){ - buildflags+=-framework Cocoa -framework Carbon + +version (GNU){ + buildflags += -Jres -framework Cocoa -framework Carbon } version (LDC){ - buildflags+=-L-framework=Cocoa -L-framework=Carbon + buildflags += -Jres -L-framework=Cocoa -L-framework=Carbon } \ No newline at end of file diff -r 5583f8eeee6c -r 38807a925e24 dwt/browser/Mozilla.d --- a/dwt/browser/Mozilla.d Fri Jan 16 12:49:08 2009 +0100 +++ b/dwt/browser/Mozilla.d Fri Jan 16 23:35:40 2009 +0100 @@ -21,7 +21,11 @@ import tango.sys.Environment; import tango.stdc.string; -import dwt.internal.c.gtk; +version (linux) + import dwt.internal.c.gtk; + +else version (darwin) + import objc = dwt.internal.objc.runtime; import dwt.DWT; import dwt.DWTError; @@ -121,6 +125,8 @@ import dwt.widgets.Shell; import dwt.widgets.Control; +import dwt.dwthelper.array; + class Mozilla : WebBrowser, nsIWeakReference, nsIWebProgressListener, @@ -134,7 +140,11 @@ nsITooltipListener, nsIDOMEventListener { - GtkWidget* embedHandle; + version (linux) + GtkWidget* embedHandle; + else version (darwin) + objc.id embedHandle; + nsIWebBrowser webBrowser; Object webBrowserObject; MozillaDelegate mozDelegate; @@ -155,43 +165,43 @@ static bool Initialized, IsPre_1_8, PerformedVersionCheck, XPCOMWasGlued, XPCOMInitWasGlued; /* XULRunner detect constants */ - static final String GRERANGE_LOWER = "1.8.1.2"; //$NON-NLS-1$ - static final String GRERANGE_LOWER_FALLBACK = "1.8"; //$NON-NLS-1$ - static final bool LowerRangeInclusive = true; - static final String GRERANGE_UPPER = "1.9.*"; //$NON-NLS-1$ - static final bool UpperRangeInclusive = true; + static const String GRERANGE_LOWER = "1.8.1.2"; //$NON-NLS-1$ + static const String GRERANGE_LOWER_FALLBACK = "1.8"; //$NON-NLS-1$ + static const bool LowerRangeInclusive = true; + static const String GRERANGE_UPPER = "1.9.*"; //$NON-NLS-1$ + static const bool UpperRangeInclusive = true; - static final int MAX_PORT = 65535; - static final String SEPARATOR_OS = System.getProperty ("file.separator"); //$NON-NLS-1$ - static final String ABOUT_BLANK = "about:blank"; //$NON-NLS-1$ - static final String DISPOSE_LISTENER_HOOKED = "dwt.browser.Mozilla.disposeListenerHooked"; //$NON-NLS-1$ - static final String PREFIX_JAVASCRIPT = "javascript:"; //$NON-NLS-1$ - static final String PREFERENCE_CHARSET = "intl.charset.default"; //$NON-NLS-1$ - static final String PREFERENCE_DISABLEOPENDURINGLOAD = "dom.disable_open_during_load"; //$NON-NLS-1$ - static final String PREFERENCE_DISABLEWINDOWSTATUSCHANGE = "dom.disable_window_status_change"; //$NON-NLS-1$ - static final String PREFERENCE_LANGUAGES = "intl.accept_languages"; //$NON-NLS-1$ - static final String PREFERENCE_PROXYHOST_FTP = "network.proxy.ftp"; //$NON-NLS-1$ - static final String PREFERENCE_PROXYPORT_FTP = "network.proxy.ftp_port"; //$NON-NLS-1$ - static final String PREFERENCE_PROXYHOST_HTTP = "network.proxy.http"; //$NON-NLS-1$ - static final String PREFERENCE_PROXYPORT_HTTP = "network.proxy.http_port"; //$NON-NLS-1$ - static final String PREFERENCE_PROXYHOST_SSL = "network.proxy.ssl"; //$NON-NLS-1$ - static final String PREFERENCE_PROXYPORT_SSL = "network.proxy.ssl_port"; //$NON-NLS-1$ - static final String PREFERENCE_PROXYTYPE = "network.proxy.type"; //$NON-NLS-1$ - static final String PROFILE_AFTER_CHANGE = "profile-after-change"; //$NON-NLS-1$ - static final String PROFILE_BEFORE_CHANGE = "profile-before-change"; //$NON-NLS-1$ + static const int MAX_PORT = 65535; + static const String SEPARATOR_OS = System.getProperty ("file.separator"); //$NON-NLS-1$ + static const String ABOUT_BLANK = "about:blank"; //$NON-NLS-1$ + static const String DISPOSE_LISTENER_HOOKED = "dwt.browser.Mozilla.disposeListenerHooked"; //$NON-NLS-1$ + static const String PREFIX_JAVASCRIPT = "javascript:"; //$NON-NLS-1$ + static const String PREFERENCE_CHARSET = "intl.charset.default"; //$NON-NLS-1$ + static const String PREFERENCE_DISABLEOPENDURINGLOAD = "dom.disable_open_during_load"; //$NON-NLS-1$ + static const String PREFERENCE_DISABLEWINDOWSTATUSCHANGE = "dom.disable_window_status_change"; //$NON-NLS-1$ + static const String PREFERENCE_LANGUAGES = "intl.accept_languages"; //$NON-NLS-1$ + static const String PREFERENCE_PROXYHOST_FTP = "network.proxy.ftp"; //$NON-NLS-1$ + static const String PREFERENCE_PROXYPORT_FTP = "network.proxy.ftp_port"; //$NON-NLS-1$ + static const String PREFERENCE_PROXYHOST_HTTP = "network.proxy.http"; //$NON-NLS-1$ + static const String PREFERENCE_PROXYPORT_HTTP = "network.proxy.http_port"; //$NON-NLS-1$ + static const String PREFERENCE_PROXYHOST_SSL = "network.proxy.ssl"; //$NON-NLS-1$ + static const String PREFERENCE_PROXYPORT_SSL = "network.proxy.ssl_port"; //$NON-NLS-1$ + static const String PREFERENCE_PROXYTYPE = "network.proxy.type"; //$NON-NLS-1$ + static const String PROFILE_AFTER_CHANGE = "profile-after-change"; //$NON-NLS-1$ + static const String PROFILE_BEFORE_CHANGE = "profile-before-change"; //$NON-NLS-1$ static String PROFILE_DIR; //= SEPARATOR_OS ~ "eclipse" ~ SEPARATOR_OS; //$NON-NLS-1$ - static final String PROFILE_DO_CHANGE = "profile-do-change"; //$NON-NLS-1$ - static final String PROPERTY_PROXYPORT = "network.proxy_port"; //$NON-NLS-1$ - static final String PROPERTY_PROXYHOST = "network.proxy_host"; //$NON-NLS-1$ - static final String SEPARATOR_LOCALE = "-"; //$NON-NLS-1$ - static final String SHUTDOWN_PERSIST = "shutdown-persist"; //$NON-NLS-1$ - static final String STARTUP = "startup"; //$NON-NLS-1$ - static final String TOKENIZER_LOCALE = ","; //$NON-NLS-1$ - static final String URI_FROMMEMORY = "file:///"; //$NON-NLS-1$ - static final String XULRUNNER_PATH = "dwt.browser.XULRunnerPath"; //$NON-NLS-1$ + static const String PROFILE_DO_CHANGE = "profile-do-change"; //$NON-NLS-1$ + static const String PROPERTY_PROXYPORT = "network.proxy_port"; //$NON-NLS-1$ + static const String PROPERTY_PROXYHOST = "network.proxy_host"; //$NON-NLS-1$ + static const String SEPARATOR_LOCALE = "-"; //$NON-NLS-1$ + static const String SHUTDOWN_PERSIST = "shutdown-persist"; //$NON-NLS-1$ + static const String STARTUP = "startup"; //$NON-NLS-1$ + static const String TOKENIZER_LOCALE = ","; //$NON-NLS-1$ + static const String URI_FROMMEMORY = "file:///"; //$NON-NLS-1$ + static const String XULRUNNER_PATH = "dwt.browser.XULRunnerPath"; //$NON-NLS-1$ - // TEMPORARY CODE - static final String GRE_INITIALIZED = "dwt.browser.XULRunnerInitialized"; //$NON-NLS-1$ +// TEMPORARY CODE +static const String GRE_INITIALIZED = "dwt.browser.XULRunnerInitialized"; //$NON-NLS-1$ this () { PROFILE_DIR = SEPARATOR_OS ~ "eclipse" ~ SEPARATOR_OS; @@ -1243,7 +1253,8 @@ extern(D) static Browser findBrowser (void* handle) { - return MozillaDelegate.findBrowser (cast(GtkWidget*)handle); + version (linux) return MozillaDelegate.findBrowser (cast(GtkWidget*)handle); + version (darwin) return MozillaDelegate.findBrowser (cast(objc.id)handle); } extern(D) diff -r 5583f8eeee6c -r 38807a925e24 dwt/browser/Safari.d --- a/dwt/browser/Safari.d Fri Jan 16 12:49:08 2009 +0100 +++ b/dwt/browser/Safari.d Fri Jan 16 23:35:40 2009 +0100 @@ -7,6 +7,9 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ module dwt.browser.Safari; @@ -16,7 +19,6 @@ import dwt.graphics.Point; import dwt.graphics.Rectangle; import dwt.internal.C; -import dwt.internal.Callback; import dwt.internal.Compatibility; import dwt.internal.cocoa.DOMDocument; import dwt.internal.cocoa.DOMKeyboardEvent; @@ -57,13 +59,26 @@ import dwt.widgets.Shell; import dwt.widgets.Widget; -class Safari extends WebBrowser { +import dwt.browser.Browser; +import dwt.browser.LocationEvent; +import dwt.browser.ProgressEvent; +import dwt.browser.ProgressListener; +import dwt.browser.StatusTextEvent; +import dwt.browser.TitleEvent; +import dwt.browser.TitleListener; +import dwt.browser.WebBrowser; +import dwt.browser.WindowEvent; +import Carbon = dwt.internal.c.Carbon; +import dwt.internal.objc.cocoa.Cocoa; +import objc = dwt.internal.objc.runtime; + +class Safari : WebBrowser { WebView webView; - SWTWebViewDelegate delegate; + SWTWebViewDelegate delegate_; bool changingLocation; String lastHoveredLinkURL; String html; - int /*long*/ identifier; + objc.id identifier; int resourceCount; String url = ""; //$NON-NLS-1$ Point location; @@ -74,36 +89,34 @@ // bool doit; static bool Initialized; - // the following Callbacks are never freed - static Callback Callback3, Callback4, Callback5, Callback6, Callback7; - static final int MIN_SIZE = 16; - static final int MAX_PROGRESS = 100; - static final String WebElementLinkURLKey = "WebElementLinkURL"; //$NON-NLS-1$ - static final String AGENT_STRING = "Safari/unknown"; //$NON-NLS-1$ - static final String URI_FROMMEMORY = "file:///"; //$NON-NLS-1$ - static final String PROTOCOL_FILE = "file://"; //$NON-NLS-1$ - static final String PROTOCOL_HTTP = "http://"; //$NON-NLS-1$ - static final String ABOUT_BLANK = "about:blank"; //$NON-NLS-1$ - static final String ADD_WIDGET_KEY = "dwt.internal.addWidget"; //$NON-NLS-1$ - static final String SAFARI_EVENTS_FIX_KEY = "dwt.internal.safariEventsFix"; //$NON-NLS-1$ - static final String DWT_OBJECT = "DWT_OBJECT"; //$NON-NLS-1$ + static const int MIN_SIZE = 16; + static const int MAX_PROGRESS = 100; + static const String WebElementLinkURLKey = "WebElementLinkURL"; //$NON-NLS-1$ + static const String AGENT_STRING = "Safari/unknown"; //$NON-NLS-1$ + static const String URI_FROMMEMORY = "file:///"; //$NON-NLS-1$ + static const String PROTOCOL_FILE = "file://"; //$NON-NLS-1$ + static const String PROTOCOL_HTTP = "http://"; //$NON-NLS-1$ + static const String ABOUT_BLANK = "about:blank"; //$NON-NLS-1$ + static const String ADD_WIDGET_KEY = "dwt.internal.addWidget"; //$NON-NLS-1$ + static const String SAFARI_EVENTS_FIX_KEY = "dwt.internal.safariEventsFix"; //$NON-NLS-1$ + static const String DWT_OBJECT = "DWT_OBJECT"; //$NON-NLS-1$ /* event strings */ - static final String DOMEVENT_KEYUP = "keyup"; //$NON-NLS-1$ - static final String DOMEVENT_KEYDOWN = "keydown"; //$NON-NLS-1$ - static final String DOMEVENT_MOUSEDOWN = "mousedown"; //$NON-NLS-1$ - static final String DOMEVENT_MOUSEUP = "mouseup"; //$NON-NLS-1$ - static final String DOMEVENT_MOUSEMOVE = "mousemove"; //$NON-NLS-1$ - static final String DOMEVENT_MOUSEWHEEL = "mousewheel"; //$NON-NLS-1$ + static const String DOMEVENT_KEYUP = "keyup"; //$NON-NLS-1$ + static const String DOMEVENT_KEYDOWN = "keydown"; //$NON-NLS-1$ + static const String DOMEVENT_MOUSEDOWN = "mousedown"; //$NON-NLS-1$ + static const String DOMEVENT_MOUSEUP = "mouseup"; //$NON-NLS-1$ + static const String DOMEVENT_MOUSEMOVE = "mousemove"; //$NON-NLS-1$ + static const String DOMEVENT_MOUSEWHEEL = "mousewheel"; //$NON-NLS-1$ - static { - NativeClearSessions = new Runnable() { + static this () { + NativeClearSessions = new class () Runnable { public void run() { NSHTTPCookieStorage storage = NSHTTPCookieStorage.sharedHTTPCookieStorage(); NSArray cookies = storage.cookies(); - int /*long*/ count = cookies.count(); - for (int i = 0; i < count; i++) { + NSUInteger count = cookies.count(); + for (NSUInteger i = 0; i < count; i++) { NSHTTPCookie cookie = new NSHTTPCookie(cookies.objectAtIndex(i)); if (cookie.isSessionOnly()) { storage.deleteCookie(cookie); @@ -115,31 +128,20 @@ public void create (Composite parent, int style) { String className = "SWTWebViewDelegate"; //$NON-NLS-1$ - if (OS.objc_lookUpClass(className) is 0) { - Class safariClass = this.getClass(); - Callback3 = new Callback(safariClass, "browserProc", 3); //$NON-NLS-1$ - int /*long*/ proc3 = Callback3.getAddress(); - if (proc3 is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS); - Callback4 = new Callback(safariClass, "browserProc", 4); //$NON-NLS-1$ - int /*long*/ proc4 = Callback4.getAddress(); - if (proc4 is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS); - Callback5 = new Callback(safariClass, "browserProc", 5); //$NON-NLS-1$ - int /*long*/ proc5 = Callback5.getAddress(); - if (proc5 is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS); - Callback6 = new Callback(safariClass, "browserProc", 6); //$NON-NLS-1$ - int /*long*/ proc6 = Callback6.getAddress(); - if (proc6 is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS); - Callback7 = new Callback(safariClass, "browserProc", 7); //$NON-NLS-1$ - int /*long*/ proc7 = Callback7.getAddress(); - if (proc7 is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS); - int /*long*/ setFrameProc = OS.webView_setFrame_CALLBACK(proc4); - if (setFrameProc is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS); + if (OS.objc_lookUpClass(className) is null) { + Class safariClass = this.classinfo; + objc.IMP proc3;// = cast(objc.IMP) &browserProc3; + objc.IMP proc4;// = cast(objc.IMP) &browserProc4; + objc.IMP proc5;// = cast(objc.IMP) &browserProc5; + objc.IMP proc6;// = cast(objc.IMP) &browserProc6; + objc.IMP proc7;// = cast(objc.IMP) &browserProc7; + objc.IMP setFrameProc = OS.webView_setFrame_CALLBACK(proc4); String types = "*"; //$NON-NLS-1$ - int size = C.PTR_SIZEOF, align = C.PTR_SIZEOF is 4 ? 2 : 3; + size_t size = C.PTR_SIZEOF, align_ = C.PTR_SIZEOF is 4 ? 2 : 3; - int /*long*/ cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0); - OS.class_addIvar(cls, DWT_OBJECT, size, (byte)align, types); + objc.Class cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSObject, className, 0); + OS.class_addIvar(cls, DWT_OBJECT, size, cast(byte)align_, types); OS.class_addMethod(cls, OS.sel_webView_didChangeLocationWithinPageForFrame_, proc4, "@:@@"); //$NON-NLS-1$ OS.class_addMethod(cls, OS.sel_webView_didFailProvisionalLoadWithError_forFrame_, proc5, "@:@@@"); //$NON-NLS-1$ OS.class_addMethod(cls, OS.sel_webView_didFinishLoadForFrame_, proc4, "@:@@"); //$NON-NLS-1$ @@ -180,26 +182,26 @@ * Override the default event mechanism to not send key events so * that the browser can send them by listening to the DOM instead. */ - browser.setData(SAFARI_EVENTS_FIX_KEY); + browser.setData(new ArrayWrapperString(SAFARI_EVENTS_FIX_KEY)); - WebView webView = (WebView)new WebView().alloc(); + WebView webView = cast(WebView)(new WebView()).alloc(); if (webView is null) DWT.error(DWT.ERROR_NO_HANDLES); webView.initWithFrame(browser.view.frame(), null, null); webView.setAutoresizingMask(OS.NSViewWidthSizable | OS.NSViewHeightSizable); - final SWTWebViewDelegate delegate = (SWTWebViewDelegate)new SWTWebViewDelegate().alloc().init(); + final SWTWebViewDelegate delegate_ = cast(SWTWebViewDelegate)(new SWTWebViewDelegate()).alloc().init(); Display display = browser.getDisplay(); - display.setData(ADD_WIDGET_KEY, new Object[] {delegate, browser}); - this.delegate = delegate; + display.setData(ADD_WIDGET_KEY, new ArrayWrapperObject([cast(Object) delegate_, browser])); + this.delegate_ = delegate_; this.webView = webView; browser.view.addSubview(webView); final NSNotificationCenter notificationCenter = NSNotificationCenter.defaultCenter(); - Listener listener = new Listener() { + Listener listener = new class () Listener { public void handleEvent(Event e) { switch (e.type) { case DWT.FocusIn: - Safari.this.webView.window().makeFirstResponder(Safari.this.webView); + this.outer.webView.window().makeFirstResponder(this.outer.webView); break; case DWT.Dispose: { /* make this handler run after other dispose listeners */ @@ -211,23 +213,24 @@ browser.notifyListeners (e.type, e); e.type = DWT.NONE; - e.display.setData(ADD_WIDGET_KEY, new Object[] {delegate, null}); + e.display.setData(ADD_WIDGET_KEY, new ArrayWrapperObject([delegate_, null])); - Safari.this.webView.setFrameLoadDelegate(null); - Safari.this.webView.setResourceLoadDelegate(null); - Safari.this.webView.setUIDelegate(null); - Safari.this.webView.setPolicyDelegate(null); - Safari.this.webView.setDownloadDelegate(null); - notificationCenter.removeObserver(delegate); + this.outer.webView.setFrameLoadDelegate(null); + this.outer.webView.setResourceLoadDelegate(null); + this.outer.webView.setUIDelegate(null); + this.outer.webView.setPolicyDelegate(null); + this.outer.webView.setDownloadDelegate(null); + notificationCenter.removeObserver(delegate_); - Safari.this.webView.release(); - Safari.this.webView = null; - Safari.this.delegate.release(); - Safari.this.delegate = null; + this.outer.webView.release(); + this.outer.webView = null; + this.outer.delegate_.release(); + this.outer.delegate_ = null; html = null; lastHoveredLinkURL = null; break; } + default: } } }; @@ -236,12 +239,12 @@ browser.addListener(DWT.KeyDown, listener); browser.addListener(DWT.FocusIn, listener); - webView.setFrameLoadDelegate(delegate); - webView.setResourceLoadDelegate(delegate); - webView.setUIDelegate(delegate); - notificationCenter.addObserver(delegate, OS.sel_handleNotification_, null, webView); - webView.setPolicyDelegate(delegate); - webView.setDownloadDelegate(delegate); + webView.setFrameLoadDelegate(delegate_); + webView.setResourceLoadDelegate(delegate_); + webView.setUIDelegate(delegate_); + notificationCenter.addObserver(delegate_, OS.sel_handleNotification_, null, webView); + webView.setPolicyDelegate(delegate_); + webView.setDownloadDelegate(delegate_); webView.setApplicationNameForUserAgent(NSString.stringWith(AGENT_STRING)); if (!Initialized) { @@ -256,10 +259,10 @@ return webView.goBack(); } -static int /*long*/ browserProc(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0) { +static objc.id browserProc3(objc.id id, objc.SEL sel, objc.id arg0) { Widget widget = Display.getCurrent().findWidget(id); - if (widget is null) return 0; - Safari safari = (Safari)((Browser)widget).webBrowser; + if (widget is null) return null; + Safari safari = cast(Safari)(cast(Browser)widget).webBrowser; if (sel is OS.sel_handleNotification_) { safari.handleNotification(arg0); } else if (sel is OS.sel_webViewShow_) { @@ -273,13 +276,13 @@ } else if (sel is OS.sel_handleEvent_) { safari.handleEvent(arg0); } - return 0; + return null; } -static int /*long*/ browserProc(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0, int /*long*/ arg1) { +static objc.id browserProc4(objc.id id, objc.SEL sel, objc.id arg0, objc.id arg1) { Widget widget = Display.getCurrent().findWidget(id); - if (widget is null) return 0; - Safari safari = (Safari)((Browser)widget).webBrowser; + if (widget is null) return null; + Safari safari = cast(Safari)(cast(Browser)widget).webBrowser; if (sel is OS.sel_webView_didChangeLocationWithinPageForFrame_) { safari.webView_didChangeLocationWithinPageForFrame(arg0, arg1); } else if (sel is OS.sel_webView_didFinishLoadForFrame_) { @@ -293,13 +296,13 @@ } else if (sel is OS.sel_webView_createWebViewWithRequest_) { return safari.webView_createWebViewWithRequest(arg0, arg1); } else if (sel is OS.sel_webView_setStatusBarVisible_) { - safari.webView_setStatusBarVisible(arg0, arg1 !is 0); + safari.webView_setStatusBarVisible(arg0, arg1 !is null); } else if (sel is OS.sel_webView_setResizable_) { - safari.webView_setResizable(arg0, arg1 !is 0); + safari.webView_setResizable(arg0, arg1 !is null); } else if (sel is OS.sel_webView_setStatusText_) { safari.webView_setStatusText(arg0, arg1); } else if (sel is OS.sel_webView_setToolbarsVisible_) { - safari.webView_setToolbarsVisible(arg0, arg1 !is 0); + safari.webView_setToolbarsVisible(arg0, arg1 !is null); } else if (sel is OS.sel_webView_runJavaScriptAlertPanelWithMessage_) { safari.webView_runJavaScriptAlertPanelWithMessage(arg0, arg1); } else if (sel is OS.sel_webView_runJavaScriptConfirmPanelWithMessage_) { @@ -311,13 +314,13 @@ } else if (sel is OS.sel_webView_printFrameView_) { safari.webView_printFrameView(arg0, arg1); } - return 0; + return null; } -static int /*long*/ browserProc(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2) { +static objc.id browserProc5(objc.id id, objc.SEL sel, objc.id arg0, objc.id arg1, objc.id arg2) { Widget widget = Display.getCurrent().findWidget(id); - if (widget is null) return 0; - Safari safari = (Safari)((Browser)widget).webBrowser; + if (widget is null) return null; + Safari safari = cast(Safari)(cast(Browser)widget).webBrowser; if (sel is OS.sel_webView_didFailProvisionalLoadWithError_forFrame_) { safari.webView_didFailProvisionalLoadWithError_forFrame(arg0, arg1, arg2); } else if (sel is OS.sel_webView_didReceiveTitle_forFrame_) { @@ -333,23 +336,23 @@ } else if (sel is OS.sel_webView_unableToImplementPolicyWithError_frame_) { safari.webView_unableToImplementPolicyWithError_frame(arg0, arg1, arg2); } - return 0; + return null; } -static int /*long*/ browserProc(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ arg3) { +static objc.id browserProc6(objc.id id, objc.SEL sel, objc.id arg0, objc.id arg1, objc.id arg2, objc.id arg3) { Widget widget = Display.getCurrent().findWidget(id); - if (widget is null) return 0; - Safari safari = (Safari)((Browser)widget).webBrowser; + if (widget is null) return null; + Safari safari = cast(Safari)(cast(Browser)widget).webBrowser; if (sel is OS.sel_webView_resource_didFailLoadingWithError_fromDataSource_) { safari.webView_resource_didFailLoadingWithError_fromDataSource(arg0, arg1, arg2, arg3); } - return 0; + return null; } -static int /*long*/ browserProc(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ arg3, int /*long*/ arg4) { +static objc.id browserProc7(objc.id id, objc.SEL sel, objc.id arg0, objc.id arg1, objc.id arg2, objc.id arg3, objc.id arg4) { Widget widget = Display.getCurrent().findWidget(id); - if (widget is null) return 0; - Safari safari = (Safari)((Browser)widget).webBrowser; + if (widget is null) return null; + Safari safari = cast(Safari)(cast(Browser)widget).webBrowser; if (sel is OS.sel_webView_resource_willSendRequest_redirectResponse_fromDataSource_) { return safari.webView_resource_willSendRequest_redirectResponse_fromDataSource(arg0, arg1, arg2, arg3, arg4); } else if (sel is OS.sel_webView_decidePolicyForMIMEType_request_frame_decisionListener_) { @@ -359,7 +362,7 @@ } else if (sel is OS.sel_webView_decidePolicyForNewWindowAction_request_newFrameName_decisionListener_) { safari.webView_decidePolicyForNewWindowAction_request_newFrameName_decisionListener(arg0, arg1, arg2, arg3, arg4); } - return 0; + return null; } public bool execute(String script) { @@ -428,15 +431,15 @@ html = null; if (url.indexOf('/') is 0) { - url = PROTOCOL_FILE + url; + url = PROTOCOL_FILE ~ url; } else if (url.indexOf(':') is -1) { - url = PROTOCOL_HTTP + url; + url = PROTOCOL_HTTP ~ url; } NSString str = NSString.stringWith(url); NSString unescapedStr = NSString.stringWith("%#"); //$NON-NLS-1$ - int /*long*/ ptr = OS.CFURLCreateStringByAddingPercentEscapes(0, str.id, unescapedStr.id, 0, OS.kCFStringEncodingUTF8); - NSString escapedString = new NSString(ptr); + Carbon.CFStringRef ptr = OS.CFURLCreateStringByAddingPercentEscapes(null, cast(Carbon.CFStringRef) str.id, cast(Carbon.CFStringRef) unescapedStr.id, null, OS.kCFStringEncodingUTF8); + NSString escapedString = new NSString(cast(objc.id) ptr); NSURL inURL = NSURL.URLWithString(escapedString); OS.CFRelease(ptr); NSURLRequest request = NSURLRequest.requestWithURL(inURL); @@ -452,13 +455,13 @@ /* WebFrameLoadDelegate */ -void webView_didChangeLocationWithinPageForFrame(int /*long*/ sender, int /*long*/ frameID) { +void webView_didChangeLocationWithinPageForFrame(objc.id sender, objc.id frameID) { WebFrame frame = new WebFrame(frameID); WebDataSource dataSource = frame.dataSource(); NSURLRequest request = dataSource.request(); NSURL url = request.URL(); NSString s = url.absoluteString(); - int length = (int)/*64*/s.length(); + NSUInteger length = s.length(); if (length is 0) return; String url2 = s.getString(); /* @@ -489,7 +492,7 @@ } } -void webView_didFailProvisionalLoadWithError_forFrame(int /*long*/ sender, int /*long*/ error, int /*long*/ frame) { +void webView_didFailProvisionalLoadWithError_forFrame(objc.id sender, objc.id error, objc.id frame) { if (frame is webView.mainFrame().id) { /* * Feature on Safari. The identifier is used here as a marker for the events @@ -504,11 +507,11 @@ * when the top frame has either finished loading (didFinishLoadForFrame * event) or failed (didFailProvisionalLoadWithError). */ - identifier = 0; + identifier = null; } NSError nserror = new NSError(error); - int /*long*/ errorCode = nserror.code(); + NSInteger errorCode = nserror.code(); if (errorCode <= OS.NSURLErrorBadURL) { NSString description = nserror.localizedDescription(); if (description !is null) { @@ -516,15 +519,15 @@ String urlString = null; NSDictionary info = nserror.userInfo(); if (info !is null) { - NSString key = new NSString(OS.NSErrorFailingURLStringKey()); + NSString key = new NSString(OS.NSErrorFailingURLStringKey_); id id = info.valueForKey(key); if (id !is null) { NSString url = new NSString(id); urlString = url.getString(); } } - String message = urlString !is null ? urlString + "\n\n" : ""; //$NON-NLS-1$ //$NON-NLS-2$ - message += Compatibility.getMessage ("DWT_Page_Load_Failed", new Object[] {descriptionString}); //$NON-NLS-1$ + String message = urlString !is null ? urlString ~ "\n\n" : ""; //$NON-NLS-1$ //$NON-NLS-2$ + message ~= Compatibility.getMessage ("DWT_Page_Load_Failed", [new ArrayWrapperString(descriptionString)]); //$NON-NLS-1$ MessageBox messageBox = new MessageBox(browser.getShell(), DWT.OK | DWT.ICON_ERROR); messageBox.setMessage(message); messageBox.open(); @@ -532,7 +535,7 @@ } } -void webView_didFinishLoadForFrame(int /*long*/ sender, int /*long*/ frameID) { +void webView_didFinishLoadForFrame(objc.id sender, objc.id frameID) { hookDOMMouseListeners(frameID); if (frameID is webView.mainFrame().id) { hookDOMKeyListeners(frameID); @@ -563,7 +566,19 @@ * so that the Browser does not crash if this is attempted. */ display.asyncExec( - new Runnable() { + new class (display, browser, listener) Runnable { + + Display display; + Browser browser; + TitleListener listener; + + this (Display display, Browser browser, TitleListener listener) + { + this.display = display; + this.browser = browser; + this.listener = listener; + } + public void run() { if (!display.isDisposed() && !browser.isDisposed()) { listener.changed(newEvent); @@ -591,7 +606,19 @@ * selection of the ProgressBar. */ display.asyncExec( - new Runnable() { + new class (display, browser, listener) Runnable { + + Display display; + Browser browser; + ProgressListener listener; + + this (Display display, Browser browser, ProgressListener listener) + { + this.display = display; + this.browser = browser; + this.listener = listener; + } + public void run() { if (!display.isDisposed() && !browser.isDisposed()) { listener.completed(progress); @@ -613,39 +640,39 @@ * when the top frame has either finished loading (didFinishLoadForFrame * event) or failed (didFailProvisionalLoadWithError). */ - identifier = 0; + identifier = null; } } -void hookDOMKeyListeners(int /*long*/ frameID) { +void hookDOMKeyListeners(objc.id frameID) { WebFrame frame = new WebFrame(frameID); - DOMDocument document = frame.DOMDocument(); + DOMDocument document = frame.DOMDocument_(); NSString type = NSString.stringWith(DOMEVENT_KEYDOWN); - document.addEventListener(type, delegate, false); + document.addEventListener(type, delegate_, false); type = NSString.stringWith(DOMEVENT_KEYUP); - document.addEventListener(type, delegate, false); + document.addEventListener(type, delegate_, false); } -void hookDOMMouseListeners(int /*long*/ frameID) { +void hookDOMMouseListeners(objc.id frameID) { WebFrame frame = new WebFrame(frameID); - DOMDocument document = frame.DOMDocument(); + DOMDocument document = frame.DOMDocument_(); NSString type = NSString.stringWith(DOMEVENT_MOUSEDOWN); - document.addEventListener(type, delegate, false); + document.addEventListener(type, delegate_, false); type = NSString.stringWith(DOMEVENT_MOUSEUP); - document.addEventListener(type, delegate, false); + document.addEventListener(type, delegate_, false); type = NSString.stringWith(DOMEVENT_MOUSEMOVE); - document.addEventListener(type, delegate, false); + document.addEventListener(type, delegate_, false); type = NSString.stringWith(DOMEVENT_MOUSEWHEEL); - document.addEventListener(type, delegate, false); + document.addEventListener(type, delegate_, false); } -void webView_didReceiveTitle_forFrame(int /*long*/ sender, int /*long*/ titleID, int /*long*/ frameID) { +void webView_didReceiveTitle_forFrame(objc.id sender, objc.id titleID, objc.id frameID) { if (frameID is webView.mainFrame().id) { NSString title = new NSString(titleID); String newTitle = title.getString(); @@ -659,7 +686,7 @@ } } -void webView_didStartProvisionalLoadForFrame(int /*long*/ sender, int /*long*/ frameID) { +void webView_didStartProvisionalLoadForFrame(objc.id sender, objc.id frameID) { /* * This code is intentionally commented. WebFrameLoadDelegate:didStartProvisionalLoadForFrame is * called before WebResourceLoadDelegate:willSendRequest and @@ -672,13 +699,13 @@ // } } -void webView_didCommitLoadForFrame(int /*long*/ sender, int /*long*/ frameID) { +void webView_didCommitLoadForFrame(objc.id sender, objc.id frameID) { WebFrame frame = new WebFrame(frameID); WebDataSource dataSource = frame.dataSource(); NSURLRequest request = dataSource.request(); NSURL url = request.URL(); NSString s = url.absoluteString(); - int length = (int)/*64*/s.length(); + NSUInteger length = s.length(); if (length is 0) return; String url2 = s.getString(); /* @@ -711,7 +738,19 @@ * selection of the ProgressBar. */ display.asyncExec( - new Runnable() { + new class (display, browser, listener) Runnable { + + Display display; + Browser browser; + ProgressListener listener; + + this (Display display, Browser browser, ProgressListener listener) + { + this.display = display; + this.browser = browser; + this.listener = listener; + } + public void run() { if (!display.isDisposed() && !browser.isDisposed()) listener.changed(progress); @@ -740,7 +779,7 @@ /* WebResourceLoadDelegate */ -void webView_resource_didFinishLoadingFromDataSource(int /*long*/ sender, int /*long*/ identifier, int /*long*/ dataSource) { +void webView_resource_didFinishLoadingFromDataSource(objc.id sender, objc.id identifier, objc.id dataSource) { /* * Feature on Safari. The identifier is used here as a marker for the events * related to the top frame and the URL changes related to that top frame as @@ -758,7 +797,7 @@ //if (this.identifier is identifier) this.identifier = 0; } -void webView_resource_didFailLoadingWithError_fromDataSource(int /*long*/ sender, int /*long*/ identifier, int /*long*/ error, int /*long*/ dataSource) { +void webView_resource_didFailLoadingWithError_fromDataSource(objc.id sender, objc.id identifier, objc.id error, objc.id dataSource) { /* * Feature on Safari. The identifier is used here as a marker for the events * related to the top frame and the URL changes related to that top frame as @@ -776,7 +815,7 @@ //if (this.identifier is identifier) this.identifier = 0; } -int /*long*/ webView_identifierForInitialRequest_fromDataSource(int /*long*/ sender, int /*long*/ request, int /*long*/ dataSourceID) { +objc.id webView_identifierForInitialRequest_fromDataSource(objc.id sender, objc.id request, objc.id dataSourceID) { final Display display = browser.getDisplay(); final ProgressEvent progress = new ProgressEvent(browser); progress.display = display; @@ -795,7 +834,19 @@ * selection of the ProgressBar. */ display.asyncExec( - new Runnable() { + new class (display, browser, listener) Runnable { + + Display display; + Browser browser; + ProgressListener listener; + + this (Display display, Browser browser, ProgressListener listener) + { + this.display = display; + this.browser = browser; + this.listener = listener; + } + public void run() { if (!display.isDisposed() && !browser.isDisposed()) listener.changed(progress); @@ -805,7 +856,7 @@ } NSNumber identifier = NSNumber.numberWithInt(resourceCount++); - if (this.identifier is 0) { + if (this.identifier is null) { WebDataSource dataSource = new WebDataSource(dataSourceID); WebFrame frame = dataSource.webFrame(); if (frame.id is webView.mainFrame().id) this.identifier = identifier.id; @@ -814,18 +865,18 @@ } -int /*long*/ webView_resource_willSendRequest_redirectResponse_fromDataSource(int /*long*/ sender, int /*long*/ identifier, int /*long*/ request, int /*long*/ redirectResponse, int /*long*/ dataSource) { +objc.id webView_resource_willSendRequest_redirectResponse_fromDataSource(objc.id sender, objc.id identifier, objc.id request, objc.id redirectResponse, objc.id dataSource) { return request; } /* handleNotification */ -void handleNotification(int /*long*/ notification) { +void handleNotification(objc.id notification) { } /* UIDelegate */ -int /*long*/ webView_createWebViewWithRequest(int /*long*/ sender, int /*long*/ request) { +objc.id webView_createWebViewWithRequest(objc.id sender, objc.id request) { WindowEvent newEvent = new WindowEvent(browser); newEvent.display = browser.getDisplay(); newEvent.widget = browser; @@ -837,20 +888,20 @@ } WebView result = null; Browser browser = null; - if (newEvent.browser !is null && newEvent.browser.webBrowser instanceof Safari) { + if (newEvent.browser !is null && cast(Safari) newEvent.browser.webBrowser) { browser = newEvent.browser; } if (browser !is null && !browser.isDisposed()) { - result = ((Safari)browser.webBrowser).webView; - if (request !is 0) { + result = (cast(Safari)browser.webBrowser).webView; + if (request !is null) { WebFrame mainFrame = webView.mainFrame(); mainFrame.loadRequest(new NSURLRequest(request)); } } - return result !is null ? result.id : 0; + return result !is null ? result.id : null; } -void webViewShow(int /*long*/ sender) { +void webViewShow(objc.id sender) { /* * Feature on WebKit. The Safari WebKit expects the application * to create a new Window using the Objective C Cocoa API in response @@ -890,22 +941,22 @@ size = null; } -void webView_setFrame(int /*long*/ sender, int /*long*/ frame) { +void webView_setFrame(objc.id sender, objc.id frame) { NSRect rect = NSRect(); - OS.memmove(rect, frame, NSRect.sizeof); + OS.memmove(&rect, frame, NSRect.sizeof); /* convert to DWT system coordinates */ Rectangle bounds = browser.getDisplay().getBounds(); - location = new Point((int)rect.x, bounds.height - (int)rect.y - (int)rect.height); - size = new Point((int)rect.width, (int)rect.height); + location = new Point(cast(int)rect.x, bounds.height - cast(int)rect.y - cast(int)rect.height); + size = new Point(cast(int)rect.width, cast(int)rect.height); } -void webViewFocus(int /*long*/ sender) { +void webViewFocus(objc.id sender) { } -void webViewUnfocus(int /*long*/ sender) { +void webViewUnfocus(objc.id sender) { } -void webView_runJavaScriptAlertPanelWithMessage(int /*long*/ sender, int /*long*/ messageID) { +void webView_runJavaScriptAlertPanelWithMessage(objc.id sender, objc.id messageID) { NSString message = new NSString(messageID); String text = message.getString(); @@ -915,17 +966,17 @@ messageBox.open(); } -int webView_runJavaScriptConfirmPanelWithMessage(int /*long*/ sender, int /*long*/ messageID) { +objc.id webView_runJavaScriptConfirmPanelWithMessage(objc.id sender, objc.id messageID) { NSString message = new NSString(messageID); String text = message.getString(); MessageBox messageBox = new MessageBox(browser.getShell(), DWT.OK | DWT.CANCEL | DWT.ICON_QUESTION); messageBox.setText("Javascript"); //$NON-NLS-1$ messageBox.setMessage(text); - return messageBox.open() is DWT.OK ? 1 : 0; + return messageBox.open() is DWT.OK ? cast(objc.id) 1 : null; } -void webView_runOpenPanelForFileButtonWithResultListener(int /*long*/ sender, int /*long*/ resultListenerID) { +void webView_runOpenPanelForFileButtonWithResultListener(objc.id sender, objc.id resultListenerID) { FileDialog dialog = new FileDialog(browser.getShell(), DWT.NONE); String result = dialog.open(); WebOpenPanelResultListener resultListener = new WebOpenPanelResultListener(resultListenerID); @@ -936,7 +987,7 @@ resultListener.chooseFilename(NSString.stringWith(result)); } -void webViewClose(int /*long*/ sender) { +void webViewClose(objc.id sender) { Shell parent = browser.getShell(); WindowEvent newEvent = new WindowEvent(browser); newEvent.display = browser.getDisplay(); @@ -961,32 +1012,32 @@ parent.setSize(pt.x, pt.y); } -int /*long*/ webView_contextMenuItemsForElement_defaultMenuItems(int /*long*/ sender, int /*long*/ element, int /*long*/ defaultMenuItems) { +objc.id webView_contextMenuItemsForElement_defaultMenuItems(objc.id sender, objc.id element, objc.id defaultMenuItems) { Point pt = browser.getDisplay().getCursorLocation(); Event event = new Event(); event.x = pt.x; event.y = pt.y; browser.notifyListeners(DWT.MenuDetect, event); Menu menu = browser.getMenu(); - if (!event.doit) return 0; + if (!event.doit) return null; if (menu !is null && !menu.isDisposed()) { if (event.x !is pt.x || event.y !is pt.y) { menu.setLocation(event.x, event.y); } menu.setVisible(true); - return 0; + return null; } return defaultMenuItems; } -void webView_setStatusBarVisible(int /*long*/ sender, bool visible) { +void webView_setStatusBarVisible(objc.id sender, bool visible) { /* Note. Webkit only emits the notification when the status bar should be hidden. */ statusBar = visible; } -void webView_setStatusText(int /*long*/ sender, int /*long*/ textID) { +void webView_setStatusText(objc.id sender, objc.id textID) { NSString text = new NSString(textID); - int length = (int)/*64*/text.length(); + NSUInteger length = text.length(); if (length is 0) return; StatusTextEvent statusText = new StatusTextEvent(browser); @@ -998,16 +1049,16 @@ } } -void webView_setResizable(int /*long*/ sender, bool visible) { +void webView_setResizable(objc.id sender, bool visible) { } -void webView_setToolbarsVisible(int /*long*/ sender, bool visible) { +void webView_setToolbarsVisible(objc.id sender, bool visible) { /* Note. Webkit only emits the notification when the tool bar should be hidden. */ toolBar = visible; } -void webView_mouseDidMoveOverElement_modifierFlags (int /*long*/ sender, int /*long*/ elementInformationID, int /*long*/ modifierFlags) { - if (elementInformationID is 0) return; +void webView_mouseDidMoveOverElement_modifierFlags (objc.id sender, objc.id elementInformationID, objc.id modifierFlags) { + if (elementInformationID is null) return; NSString key = NSString.stringWith(WebElementLinkURLKey); NSDictionary elementInformation = new NSDictionary(elementInformationID); @@ -1026,8 +1077,8 @@ return; } - NSString url = new NSURL(value.id).absoluteString(); - int length = (int)/*64*/url.length(); + NSString url = (new NSURL(value.id)).absoluteString(); + NSUInteger length = url.length(); String urlString; if (length is 0) { urlString = ""; //$NON-NLS-1$ @@ -1046,7 +1097,7 @@ } } -void webView_printFrameView (int /*long*/ sender, int /*long*/ frameViewID) { +void webView_printFrameView (objc.id sender, objc.id frameViewID) { WebFrameView view = new WebFrameView(frameViewID); bool viewPrint = view.documentViewShouldHandlePrint(); if (viewPrint) { @@ -1060,7 +1111,7 @@ /* PolicyDelegate */ -void webView_decidePolicyForMIMEType_request_frame_decisionListener(int /*long*/ sender, int /*long*/ type, int /*long*/ request, int /*long*/ frame, int /*long*/ listenerID) { +void webView_decidePolicyForMIMEType_request_frame_decisionListener(objc.id sender, objc.id type, objc.id request, objc.id frame, objc.id listenerID) { bool canShow = WebView.canShowMIMEType(new NSString(type)); WebPolicyDecisionListener listener = new WebPolicyDecisionListener(listenerID); if (canShow) { @@ -1070,8 +1121,8 @@ } } -void webView_decidePolicyForNavigationAction_request_frame_decisionListener(int /*long*/ sender, int /*long*/ actionInformation, int /*long*/ request, int /*long*/ frame, int /*long*/ listenerID) { - NSURL url = new NSURLRequest(request).URL(); +void webView_decidePolicyForNavigationAction_request_frame_decisionListener(objc.id sender, objc.id actionInformation, objc.id request, objc.id frame, objc.id listenerID) { + NSURL url = (new NSURLRequest(request)).URL(); WebPolicyDecisionListener listener = new WebPolicyDecisionListener(listenerID); if (url is null) { /* indicates that a URL with an invalid format was specified */ @@ -1110,17 +1161,17 @@ } } -void webView_decidePolicyForNewWindowAction_request_newFrameName_decisionListener(int /*long*/ sender, int /*long*/ actionInformation, int /*long*/ request, int /*long*/ frameName, int /*long*/ listenerID) { +void webView_decidePolicyForNewWindowAction_request_newFrameName_decisionListener(objc.id sender, objc.id actionInformation, objc.id request, objc.id frameName, objc.id listenerID) { WebPolicyDecisionListener listener = new WebPolicyDecisionListener(listenerID); listener.use(); } -void webView_unableToImplementPolicyWithError_frame(int /*long*/ sender, int /*long*/ error, int /*long*/ frame) { +void webView_unableToImplementPolicyWithError_frame(objc.id sender, objc.id error, objc.id frame) { } /* WebDownload */ -void download_decideDestinationWithSuggestedFilename(int /*long*/ downloadId, int /*long*/ filename) { +void download_decideDestinationWithSuggestedFilename(objc.id downloadId, objc.id filename) { NSString string = new NSString(filename); String name = string.getString(); FileDialog dialog = new FileDialog(browser.getShell(), DWT.SAVE); @@ -1138,7 +1189,7 @@ /* DOMEventListener */ -void handleEvent(int /*long*/ evtId) { +void handleEvent(objc.id evtId) { NSString string = new NSString(OS.objc_msgSend(evtId, OS.sel_type)); String type = string.getString(); @@ -1160,7 +1211,7 @@ keyEvent.type = DWT.KeyUp; } keyEvent.keyCode = translateKey(keyCode); - keyEvent.character = (char)charCode; + keyEvent.character = cast(char)charCode; keyEvent.stateMask = (alt ? DWT.ALT : 0) | (ctrl ? DWT.CTRL : 0) | (shift ? DWT.SHIFT : 0) | (meta ? DWT.COMMAND : 0); browser.notifyListeners(keyEvent.type, keyEvent); if (!keyEvent.doit) { @@ -1219,6 +1270,7 @@ case 3: mouseEvent.stateMask |= DWT.BUTTON3; break; case 4: mouseEvent.stateMask |= DWT.BUTTON4; break; case 5: mouseEvent.stateMask |= DWT.BUTTON5; break; + default: } } else if (DOMEVENT_MOUSEMOVE.equals (type)) { /* diff -r 5583f8eeee6c -r 38807a925e24 dwt/browser/WebBrowser.d --- a/dwt/browser/WebBrowser.d Fri Jan 16 12:49:08 2009 +0100 +++ b/dwt/browser/WebBrowser.d Fri Jan 16 23:35:40 2009 +0100 @@ -40,7 +40,7 @@ static Runnable NativeClearSessions; /* Key Mappings */ - static final int [][] KeyTable = [ + static const int [][] KeyTable = [ /* Keyboard and Mouse Masks */ [18, DWT.ALT], [16, DWT.SHIFT], diff -r 5583f8eeee6c -r 38807a925e24 dwt/dwthelper/ResourceBundle.d --- a/dwt/dwthelper/ResourceBundle.d Fri Jan 16 12:49:08 2009 +0100 +++ b/dwt/dwthelper/ResourceBundle.d Fri Jan 16 23:35:40 2009 +0100 @@ -8,20 +8,50 @@ import dwt.DWT; import dwt.dwthelper.utils; -import dwt.dwthelper.utils : IOException; +import tango.io.File; +import tango.text.locale.Core; -version (LDC) - import tango.io.device.File; - -else - import tango.io.File; +import tango.util.log.Trace; class ResourceBundle { - char[][ char[] ] map; + String[ String ] map; - public this( char[] data ){ - char[] line; + /++ + + First entry is the default entry if no maching locale is found + +/ + public this( ImportData[] data ){ + char[] name = Culture.current().name.dup; + if( name.length is 5 && name[2] is '-' ){ + name[2] = '_'; + char[] end = "_" ~ name ~ ".properties"; + foreach( entry; data ){ + if( entry.name.length > end.length && entry.name[ $-end.length .. $ ] == end ){ + Trace.formatln( "ResourceBundle {}", entry.name ); + initialize( cast(char[])entry.data ); + return; + } + } + } + char[] end = "_" ~ name[0..2] ~ ".properties"; + foreach( entry; data ){ + if( entry.name.length > end.length && entry.name[ $-end.length .. $ ] == end ){ + Trace.formatln( "ResourceBundle {}", entry.name ); + initialize( cast(char[])entry.data ); + return; + } + } + Trace.formatln( "ResourceBundle default" ); + initialize( cast(char[])data[0].data ); + } + public this( ImportData data ){ + initialize( cast(char[])data.data ); + } + public this( String data ){ + initialize( data ); + } + private void initialize( String data ){ + String line; int dataIndex; //tango.io.Stdout.Stdout.formatln( "properties put ..." ); @@ -37,8 +67,8 @@ //tango.io.Stdout.Stdout.formatln( "properties put {}", __LINE__ ); bool linecontinue = false; bool iskeypart = true; - char[] key; - char[] value; + String key; + String value; nextline: while( dataIndex < data.length ){ //tango.io.Stdout.Stdout.formatln( "properties put {} startline", __LINE__ ); @@ -48,7 +78,7 @@ //tango.io.Stdout.Stdout.formatln( "properties put {} was 0 length", __LINE__ ); continue; } - if( line[0] is '#' ){ + if( line[0] == '#' ){ //tango.io.Stdout.Stdout.formatln( "properties put {} was comment", __LINE__ ); continue; } @@ -63,21 +93,25 @@ linecontinue = false; } while( pos < line.length ){ - char c = line[pos]; + char[] c = line[pos .. pos +1]; if( esc ){ esc = false; - switch( c ){ - case 't' : c = '\t'; break; - case 'n' : c = '\n'; break; - case '\\': c = '\\'; break; - case '\"': c = '\"'; break; - //case ':' : c = ':' ; break; + switch( c[0] ){ + case 't' : c[0] = '\t'; break; + case 'n' : c[0] = '\n'; break; + case '\\': c[0] = '\\'; break; + case '\"': c[0] = '\"'; break; + case 'u' : + dchar d = Integer.parseInt( line[ pos+1 .. pos+5 ], 16 ); + c = dcharToString(d); + pos += 4; + break; default: break; } } else{ - if( c is '\\' ){ - if( pos is line.length -1 ){ + if( c == "\\" ){ + if( pos == line.length -1 ){ linecontinue = true; goto nextline; } @@ -85,7 +119,7 @@ pos++; continue; } - else if( iskeypart && c is '=' ){ + else if( iskeypart && c == "=" ){ pos++; iskeypart = false; continue; @@ -113,43 +147,38 @@ } } - public bool hasString( char[] key ){ + public bool hasString( String key ){ return ( key in map ) !is null; } - public char[] getString( char[] key ){ + public String getString( String key ){ if( auto v = key in map ){ return (*v).dup; } throw new MissingResourceException( "key not found", this.classinfo.name, key ); } - public char[][] getKeys(){ + public String[] getKeys(){ return map.keys; } + public static ResourceBundle getBundle( ImportData[] data ){ + return new ResourceBundle( data ); + } public static ResourceBundle getBundle( ImportData data ){ - return new ResourceBundle( cast(char[]) data.data ); + return new ResourceBundle( data ); } - public static ResourceBundle getBundle( char[] name ){ + public static ResourceBundle getBundle( String name ){ try{ - version (LDC) - return new ResourceBundle( cast(char[]) File.read(name) ); - - else - { - scope f = new File(name); - return new ResourceBundle( cast(char[]) f.read() ); - } + scope f = new File(name); + return new ResourceBundle( cast(String) f.read() ); } catch( IOException e){ e.msg ~= " file:" ~ name; throw e; } } - public static ResourceBundle getBundleFromData( char[] data ){ + public static ResourceBundle getBundleFromData( String data ){ return new ResourceBundle( data ); } } - - diff -r 5583f8eeee6c -r 38807a925e24 dwt/dwthelper/System.d --- a/dwt/dwthelper/System.d Fri Jan 16 12:49:08 2009 +0100 +++ b/dwt/dwthelper/System.d Fri Jan 16 23:35:40 2009 +0100 @@ -5,6 +5,7 @@ import tango.core.Exception; import tango.io.Stdout; +import tango.io.model.IFile; version (LDC) { @@ -15,9 +16,13 @@ else import tango.io.Print; +import tango.stdc.locale; import tango.stdc.stdlib : exit; +import tango.sys.Environment; import tango.time.Clock; +import dwt.dwthelper.utils; + template SimpleType(T) { debug{ static void validCheck(uint SrcLen, uint DestLen, uint copyLen){ @@ -170,13 +175,51 @@ return (*cast(Object *)&x).toHash(); } - public static char[] getProperty( char[] key ){ - switch( key ){ - case "os.name": return "windows"; - default: return null; + public static String getProperty( String key, String defval ){ + String res = getProperty(key); + if( res ){ + return res; } + return defval; + } + + public static String getProperty( String key ){ + /* get values for global system keys (environment) */ + switch( key ) { + // Ubuntu Gutsy:Environment.get for OSTYPE is not working + // Force default to "linux" for now -JJR + case "os.name": + version (linux) return Environment.get("OSTYPE","linux"); + version (darwin) return Environment.get("OSTYPE","darwin"); + + case "user.name": return Environment.get("USER"); + case "user.home": return Environment.get("HOME"); + case "user.dir" : return Environment.get("PWD"); + case "file.separator" : return FileConst.PathSeparatorString ; + case "file.encoding" : + char* encoding; + encoding = setlocale(LC_CTYPE, null); + if (encoding is null) + version (linux) return "CP1252"; //default + version (darwin) return "UTF-8"; //default + else + return encoding[0..strlen(encoding)].dup; + default: return null; + } + + /* Get values for local dwt specific keys */ + String* p; + return ((p = key in localProperties) != null) ? *p : null; + } + + public static void setProperty ( String key, String value ) { + /* set property for LOCAL dwt keys */ + if (key !is null && value !is null) + localProperties[ key ] = value; } static Out out_; static Err err; + + private static String[String] localProperties; } diff -r 5583f8eeee6c -r 38807a925e24 dwt/dwthelper/array.d --- a/dwt/dwthelper/array.d Fri Jan 16 12:49:08 2009 +0100 +++ b/dwt/dwthelper/array.d Fri Jan 16 23:35:40 2009 +0100 @@ -192,6 +192,17 @@ */ alias remove removeElement; +T[] arrayIndexRemove(T, U = size_t)(T[] arr, U n) { + if (n is 0) + return arr[1..$]; + if (n > arr.length) + return arr; + if (n is arr.length-1) + return arr[0..n-1]; + // else + return arr[0..n] ~ arr[n+1..$]; +} + /** * Returns the index of the first occurrence of the specified element * in the array, or -1 if the array does not contain the element. @@ -199,6 +210,7 @@ * Params: * arr = the array to get the index of the element from * element = the element to find + * start = the index of where to start searching from * * Returns: the index of the element or -1 if it's not in the array * @@ -206,12 +218,11 @@ * Throws: AssertException if the return value is less than -1 or * greater than the length of the array - 1. */ -size_t indexOf (T, U = uint) (T[] arr, T element, U start = 0) +size_t indexOf (T, U = size_t) (T[] arr, T[] match, U start = 0) in { assert(arr.length > 0); assert(start >= 0); - assert(element !is null); } out (result) { @@ -219,23 +230,59 @@ } body { - uint index; + size_t index = tango.text.Util.locatePattern(arr, match, start); + + if (index != arr.length) + return index; + + else + return -1; +} + +/** + * Returns the index of the first occurrence of the specified element + * in the array, or -1 if the array does not contain the element. + * + * Params: + * arr = the array to get the index of the element from + * element = the element to find + * start = the index of where to start searching from + * + * Returns: the index of the element or -1 if it's not in the array + * + * Throws: AssertException if the length of the array is 0 + * Throws: AssertException if the return value is less than -1 or + * greater than the length of the array - 1. + */ +size_t indexOf (T, U = size_t) (T[] arr, T element, U start = 0) +in +{ + assert(arr.length > 0); + assert(start >= 0); +} +out (result) +{ + assert(result >= -1 && result < arr.length); +} +body +{ + size_t index; version (Tango) - index = tango.text.Util.locate(arr, element); + index = cast(size_t) tango.text.Util.locate(arr, element, start); else { if (start > arr.length) start = arr.length; - index = privateIndexOf(arr.ptr, element, arr.length - start) + start; + index = cast(size_t) privateIndexOf(arr.ptr, element, arr.length - start) + start; } - if (index == arr.length) - index = -1; - - return index; + if (index != arr.length) + return index; + else + return -1; version (Phobos) { diff -r 5583f8eeee6c -r 38807a925e24 dwt/dwthelper/utils.d --- a/dwt/dwthelper/utils.d Fri Jan 16 12:49:08 2009 +0100 +++ b/dwt/dwthelper/utils.d Fri Jan 16 23:35:40 2009 +0100 @@ -4,6 +4,7 @@ module dwt.dwthelper.utils; public import dwt.dwthelper.System; +public import dwt.dwthelper.Runnable; public import Math = tango.math.Math; public import tango.core.Exception : IllegalArgumentException, IOException, PlatformException; @@ -42,6 +43,8 @@ alias ClassInfo Class; +public import dwt.dwthelper.array; + void implMissing( String file, uint line ){ Stderr.formatln( "implementation missing in file {} line {}", file, line ); Stderr.formatln( "exiting ..." ); @@ -269,8 +272,7 @@ public static float NEGATIVE_INFINITY = ((-1.0f) / 0.0f); public static float NaN = (0.0f / 0.0f); public static float MAX_VALUE = 3.4028235e+38f; - public static float MIN_VALUE = float.min; - //public static float MIN_VALUE = 1.4e-45f; + public static float MIN_VALUE = 1.4e-45f; public static int SIZE = 32; this( float value ){ @@ -565,7 +567,7 @@ return tango.text.Unicode.toUpper( str ); } -public int indexOf( String str, char searched ){ +/*public int indexOf( String str, char searched ){ int res = tango.text.Util.locate( str, searched ); if( res is str.length ) res = -1; return res; @@ -575,9 +577,9 @@ int res = tango.text.Util.locate( str, searched, startpos ); if( res is str.length ) res = -1; return res; -} +}*/ -public int indexOf(String str, String ch){ +/*public int indexOf(String str, String ch){ return indexOf( str, ch, 0 ); } @@ -585,7 +587,7 @@ int res = tango.text.Util.locatePattern( str, ch, start ); if( res is str.length ) res = -1; return res; -} +}*/ public int lastIndexOf(String str, char ch){ return lastIndexOf( str, ch, str.length ); @@ -698,10 +700,10 @@ } } -public String fromStringz (char* str) -{ - return tango.stdc.stringz.fromStringz(str); -} +public alias tango.stdc.stringz.toStringz toStringz; +public alias tango.stdc.stringz.toString16z toString16z; +public alias tango.stdc.stringz.fromStringz fromStringz; +public alias tango.stdc.stringz.fromString16z fromString16z; static String toHex(uint value, bool prefix = true, int radix = 8){ return tango.text.convert.Integer.toString( diff -r 5583f8eeee6c -r 38807a925e24 dwt/effects/Effect.d --- a/dwt/effects/Effect.d Fri Jan 16 12:49:08 2009 +0100 +++ b/dwt/effects/Effect.d Fri Jan 16 23:35:40 2009 +0100 @@ -7,8 +7,11 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ -module dwt.effects; +module dwt.effects.Effect; import dwt.dwthelper.utils; diff -r 5583f8eeee6c -r 38807a925e24 dwt/internal/Compatibility.d --- a/dwt/internal/Compatibility.d Fri Jan 16 12:49:08 2009 +0100 +++ b/dwt/internal/Compatibility.d Fri Jan 16 23:35:40 2009 +0100 @@ -7,29 +7,32 @@ * * Contributors: * IBM Corporation - initial API and implementation - * * Port to the D programming language: * Frank Benoit - * Jacob Carlborg *******************************************************************************/ module dwt.internal.Compatibility; -import tango.sys.Process; +import dwt.dwthelper.utils; +/+ +import java.io.File; +import java.text.MessageFormat; +import java.util.MissingResourceException; +import java.util.ResourceBundle; +import java.util.zip.DeflaterOutputStream; +import java.util.zip.InflaterInputStream; ++/ import dwt.DWT; -import dwt.dwthelper.BufferedInputStream; public import dwt.dwthelper.FileInputStream; public import dwt.dwthelper.FileOutputStream; public import dwt.dwthelper.InflaterInputStream; +import dwt.dwthelper.BufferedInputStream; import dwt.dwthelper.ResourceBundle; -import dwt.dwthelper.utils; -/+ -import java.io.File; -import java.text.MessageFormat; -import java.util.zip.DeflaterOutputStream; -import java.util.zip.InflaterInputStream; -+/ +import Math = tango.math.Math; +import Unicode = tango.text.Unicode; +import tango.sys.Process; +import tango.text.convert.Format; /** * This class is a placeholder for utility methods commonly @@ -226,7 +229,7 @@ * @return true when the character is a letter */ public static bool isLetter(dchar c) { - return Character.isLetter(c); + return Unicode.isLetter(c); } /** @@ -236,7 +239,7 @@ * @return true when the character is a letter or a digit */ public static bool isLetterOrDigit(dchar c) { - return Character.isLetterOrDigit(c); + return Unicode.isLetterOrDigit(c); } /** @@ -246,7 +249,7 @@ * @return true when the character is a Unicode space character */ public static bool isSpaceChar(dchar c) { - return Character.isSpaceChar(c); + return Unicode.isSpace(c); } /** @@ -256,7 +259,7 @@ * @return true if the character is whitespace */ public static bool isWhitespace(dchar c) { - return Character.isWhitespace(c); + return Unicode.isWhitespace(c); } /** @@ -293,6 +296,34 @@ proc.execute; } +const ImportData[] SWTMessagesBundleData = [ + getImportData!( "swt.internal.SWTMessages.properties" ), + getImportData!( "swt.internal.SWTMessages_ar.properties" ), + getImportData!( "swt.internal.SWTMessages_cs.properties" ), + getImportData!( "swt.internal.SWTMessages_da.properties" ), + getImportData!( "swt.internal.SWTMessages_de.properties" ), + getImportData!( "swt.internal.SWTMessages_el.properties" ), + getImportData!( "swt.internal.SWTMessages_es.properties" ), + getImportData!( "swt.internal.SWTMessages_fi.properties" ), + getImportData!( "swt.internal.SWTMessages_fr.properties" ), + getImportData!( "swt.internal.SWTMessages_hu.properties" ), + getImportData!( "swt.internal.SWTMessages_it.properties" ), + getImportData!( "swt.internal.SWTMessages_iw.properties" ), + getImportData!( "swt.internal.SWTMessages_ja.properties" ), + getImportData!( "swt.internal.SWTMessages_ko.properties" ), + getImportData!( "swt.internal.SWTMessages_nl.properties" ), + getImportData!( "swt.internal.SWTMessages_no.properties" ), + getImportData!( "swt.internal.SWTMessages_pl.properties" ), + getImportData!( "swt.internal.SWTMessages_pt_BR.properties" ), + getImportData!( "swt.internal.SWTMessages_pt.properties" ), + getImportData!( "swt.internal.SWTMessages_ru.properties" ), + getImportData!( "swt.internal.SWTMessages_sv.properties" ), + getImportData!( "swt.internal.SWTMessages_tr.properties" ), + getImportData!( "swt.internal.SWTMessages_zh_HK.properties" ), + getImportData!( "swt.internal.SWTMessages_zh.properties" ), + getImportData!( "swt.internal.SWTMessages_zh_TW.properties" ) +]; + private static ResourceBundle msgs = null; /** @@ -307,13 +338,13 @@ public static String getMessage(String key) { String answer = key; - /*if (key is null) { + if (key is null) { DWT.error (DWT.ERROR_NULL_ARGUMENT); - }*/ + } if (msgs is null) { try { - msgs = ResourceBundle.getBundle("dwt.internal.SWTMessages"); //$NON-NLS-1$ - } catch (IOException ex) { + msgs = ResourceBundle.getBundle(SWTMessagesBundleData); //$NON-NLS-1$ + } catch (MissingResourceException ex) { answer = key ~ " (no resource bundle)"; //$NON-NLS-1$ } } @@ -324,30 +355,39 @@ } return answer; } -/++ PORTING_LEFT + public static String getMessage(String key, Object[] args) { String answer = key; - if (/*key == null ||*/ args is null) { + if (key is null || args is null) { DWT.error (DWT.ERROR_NULL_ARGUMENT); } if (msgs is null) { try { - msgs = ResourceBundle.getBundle("dwt.internal.SWTMessages"); //$NON-NLS-1$ - } catch (IOException ex) { - answer = key + " (no resource bundle)"; //$NON-NLS-1$ + msgs = ResourceBundle.getBundle(SWTMessagesBundleData); //$NON-NLS-1$ + } catch (MissingResourceException ex) { + answer = key ~ " (no resource bundle)"; //$NON-NLS-1$ } } if (msgs !is null) { try { - MessageFormat formatter = new MessageFormat(""); - formatter.applyPattern(msgs.getString(key)); - answer = formatter.format(args); + char[] frmt = msgs.getString(key); + switch( args.length ){ + case 0: answer = Format(frmt); break; + case 1: answer = Format(frmt, args[0]); break; + case 2: answer = Format(frmt, args[0], args[1]); break; + case 3: answer = Format(frmt, args[0], args[1], args[2]); break; + case 4: answer = Format(frmt, args[0], args[1], args[2], args[3]); break; + case 5: answer = Format(frmt, args[0], args[1], args[2], args[3], args[4]); break; + default: + implMissing(__FILE__, __LINE__ ); + } } catch (MissingResourceException ex2) {} } return answer; } -+/ + + /** * Interrupt the current thread. *

@@ -368,7 +408,15 @@ * @return true if the two instances of class String are equal */ public static bool equalsIgnoreCase(String s1, String s2) { - return s1.equalsIgnoreCase(s2); + String s1b = new char[ s1.length ]; + String s2b = new char[ s1.length ]; + scope(exit){ + delete s1b; + delete s2b; + } + String s1c = Unicode.toFold( s1, s1b ); + String s2c = Unicode.toFold( s2, s2b ); + return s1c == s2c; } } diff -r 5583f8eeee6c -r 38807a925e24 dwt/internal/cocoa/OS.d --- a/dwt/internal/cocoa/OS.d Fri Jan 16 12:49:08 2009 +0100 +++ b/dwt/internal/cocoa/OS.d Fri Jan 16 23:35:40 2009 +0100 @@ -3577,13 +3577,13 @@ public static const int NSVariableStatusItemLength = -1; public static const int NSVerticalRuler = 1; public static const int NSViaPanelFontAction = 1; -public static const int NSViewHeightSizable = 16; +public static const Cocoa.NSUInteger NSViewHeightSizable = 16; public static const int NSViewMaxXMargin = 4; public static const int NSViewMaxYMargin = 32; public static const int NSViewMinXMargin = 1; public static const int NSViewMinYMargin = 8; public static const int NSViewNotSizable = 0; -public static const int NSViewWidthSizable = 2; +public static const Cocoa.NSUInteger NSViewWidthSizable = 2; public static const int NSWantsBidiLevels = 4; alias Cocoa.NSAlertStyle.NSWarningAlertStyle NSWarningAlertStyle; public static const int NSWheelModeColorPanel = 6; @@ -3623,7 +3623,7 @@ public static const int NSWritingDirectionRightToLeft = 1; alias Cocoa.NSDatePickerElementFlags.NSYearMonthDatePickerElementFlag NSYearMonthDatePickerElementFlag; alias Cocoa.NSDatePickerElementFlags.NSYearMonthDayDatePickerElementFlag NSYearMonthDayDatePickerElementFlag; -public static const int kCFStringEncodingUTF8 = 134217984; +public static const Carbon.CFStringEncoding kCFStringEncodingUTF8 = 134217984; public static const int NSASCIIStringEncoding = 1; public static const int NSAdminApplicationDirectory = 4; public static const int NSAggregateExpressionType = 14; @@ -3990,7 +3990,7 @@ public static const int NSURLCredentialPersistenceNone = 0; public static const int NSURLCredentialPersistencePermanent = 2; public static const int NSURLErrorBadServerResponse = -1011; -public static const int NSURLErrorBadURL = -1000; +public static const Cocoa.NSInteger NSURLErrorBadURL = -1000; public static const int NSURLErrorCancelled = -999; public static const int NSURLErrorCannotCloseFile = -3002; public static const int NSURLErrorCannotConnectToHost = -1004; diff -r 5583f8eeee6c -r 38807a925e24 dwt/internal/theme/TabItemDrawData.d --- a/dwt/internal/theme/TabItemDrawData.d Fri Jan 16 12:49:08 2009 +0100 +++ b/dwt/internal/theme/TabItemDrawData.d Fri Jan 16 23:35:40 2009 +0100 @@ -13,7 +13,6 @@ *******************************************************************************/ module dwt.internal.theme.TabItemDrawData; -import minid.compiler; import dwt.dwthelper.utils; import dwt.internal.theme.DrawData; import dwt.internal.theme.TabFolderDrawData; diff -r 5583f8eeee6c -r 38807a925e24 dwt/widgets/Label.d --- a/dwt/widgets/Label.d Fri Jan 16 12:49:08 2009 +0100 +++ b/dwt/widgets/Label.d Fri Jan 16 23:35:40 2009 +0100 @@ -81,6 +81,12 @@ * @see Sample code and further information */ public class Label : Control { + + alias Control.computeSize computeSize; + alias Control.setBounds setBounds; + alias Control.setBackground setBackground; + alias Control.setForeground setForeground; + String text = ""; Image image; bool isImage; diff -r 5583f8eeee6c -r 38807a925e24 dwt/widgets/Listener.d --- a/dwt/widgets/Listener.d Fri Jan 16 12:49:08 2009 +0100 +++ b/dwt/widgets/Listener.d Fri Jan 16 23:35:40 2009 +0100 @@ -10,12 +10,16 @@ * * Port to the D programming language: * Jacob Carlborg + * Frank Benoit *******************************************************************************/ module dwt.widgets.Listener; import dwt.widgets.Event; +import tango.core.Traits; +import tango.core.Tuple; + /** * Implementers of Listener provide a simple * handleEvent() method that is used internally @@ -55,3 +59,41 @@ */ void handleEvent (Event event); } + +/// Helper class for the dgListener template function +private class _DgListenerT(Dg,T...) : Listener { + + alias ParameterTupleOf!(Dg) DgArgs; + static assert( is(DgArgs == Tuple!(Event,T)), + "Delegate args not correct: delegate args: ("~DgArgs.stringof~") vs. passed args: ("~Tuple!(Event,T).stringof~")" ); + + Dg dg; + T t; + + private this( Dg dg, T t ){ + this.dg = dg; + static if( T.length > 0 ){ + this.t = t; + } + } + + void handleEvent( Event e ){ + dg(e,t); + } +} + +/++ ++ dgListener creates a class implementing the Listener interface and delegating the call to ++ handleEvent to the users delegate. This template function will store also additional parameters. ++ ++ Examle of usage: ++ --- ++ void handleTextEvent (Event e, int inset ) { + + // ... ++ } ++ text.addListener (DWT.FocusOut, dgListener( &handleTextEvent, inset )); ++ --- ++/ +Listener dgListener( Dg, T... )( Dg dg, T args ){ + return new _DgListenerT!( Dg, T )( dg, args ); +} \ No newline at end of file diff -r 5583f8eeee6c -r 38807a925e24 dwt/widgets/Text.d --- a/dwt/widgets/Text.d Fri Jan 16 12:49:08 2009 +0100 +++ b/dwt/widgets/Text.d Fri Jan 16 23:35:40 2009 +0100 @@ -88,10 +88,13 @@ */ public class Text : Scrollable { + alias Scrollable.computeSize computeSize; + alias Scrollable.dragDetect dragDetect; alias Scrollable.setBackground setBackground; alias Scrollable.setFont setFont; alias Scrollable.setForeground setForeground; - + alias Scrollable.translateTraversal translateTraversal; + int textLimit, tabs = 8; char echoCharacter; bool doubleClick, receivingFocus;