KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.internal.*;
14
15 class WebKit {
16         
17 static {
18     Library.loadLibrary("swt-webkit"); //$NON-NLS-1$
19
WebInitForCarbon();
20 }
21     
22 /* Objective-C class ids */
23 static final int C_NSNotificationCenter = WebKit.objc_getClass("NSNotificationCenter"); //$NON-NLS-1$
24
static final int C_NSNumber = WebKit.objc_getClass("NSNumber"); //$NON-NLS-1$
25
static final int C_NSURL = WebKit.objc_getClass("NSURL"); //$NON-NLS-1$
26
static final int C_NSURLRequest = WebKit.objc_getClass("NSURLRequest"); //$NON-NLS-1$
27
static final int C_WebKitDelegate = WebKit.objc_getClass("WebKitDelegate"); //$NON-NLS-1$
28

29 /* Objective-C method selectors */
30 static final int S_absoluteString = WebKit.sel_registerName("absoluteString"); //$NON-NLS-1$
31
static final int S_addObserver_selector_name_object = WebKit.sel_registerName("addObserver:selector:name:object:"); //$NON-NLS-1$
32
static final int S_alloc = WebKit.sel_registerName("alloc"); //$NON-NLS-1$
33
static final int S_autorelease = WebKit.sel_registerName("autorelease"); //$NON-NLS-1$
34
static final int S_canGoBack = WebKit.sel_registerName("canGoBack"); //$NON-NLS-1$
35
static final int S_canGoForward = WebKit.sel_registerName("canGoForward"); //$NON-NLS-1$
36
static final int S_dataSource = WebKit.sel_registerName("dataSource"); //$NON-NLS-1$
37
static final int S_defaultCenter = WebKit.sel_registerName("defaultCenter"); //$NON-NLS-1$
38
static final int S_goBack = WebKit.sel_registerName("goBack:"); //$NON-NLS-1$
39
static final int S_goForward = WebKit.sel_registerName("goForward:"); //$NON-NLS-1$
40
static final int S_handleNotification = WebKit.sel_registerName("handleNotification:"); //$NON-NLS-1$
41
static final int S_ignore = WebKit.sel_registerName("ignore"); //$NON-NLS-1$
42
static final int S_initialRequest = WebKit.sel_registerName("initialRequest"); //$NON-NLS-1$
43
static final int S_initWithProc = WebKit.sel_registerName("initWithProc:user_data:"); //$NON-NLS-1$
44
static final int S_loadHTMLStringbaseURL = WebKit.sel_registerName("loadHTMLString:baseURL:"); //$NON-NLS-1$
45
static final int S_loadRequest = WebKit.sel_registerName("loadRequest:"); //$NON-NLS-1$
46
static final int S_mainFrame = WebKit.sel_registerName("mainFrame"); //$NON-NLS-1$
47
static final int S_name = WebKit.sel_registerName("name"); //$NON-NLS-1$
48
static final int S_numberWithInt = WebKit.sel_registerName("numberWithInt:"); //$NON-NLS-1$
49
static final int S_provisionalDataSource = WebKit.sel_registerName("provisionalDataSource"); //$NON-NLS-1$
50
static final int S_release = WebKit.sel_registerName("release"); //$NON-NLS-1$
51
static final int S_reload = WebKit.sel_registerName("reload:"); //$NON-NLS-1$
52
static final int S_retain = WebKit.sel_registerName("retain"); //$NON-NLS-1$
53
static final int S_removeObserver_name_object = WebKit.sel_registerName("removeObserver:name:object:"); //$NON-NLS-1$
54
static final int S_removeObserver = WebKit.sel_registerName("removeObserver:"); //$NON-NLS-1$
55
static final int S_requestWithURL = WebKit.sel_registerName("requestWithURL:"); //$NON-NLS-1$
56
static final int S_request = WebKit.sel_registerName("request"); //$NON-NLS-1$
57
static final int S_retainCount = WebKit.sel_registerName("retainCount"); //$NON-NLS-1$
58
static final int S_setFrameLoadDelegate = WebKit.sel_registerName("setFrameLoadDelegate:"); //$NON-NLS-1$
59
static final int S_setGroupName = WebKit.sel_registerName("setGroupName:"); //$NON-NLS-1$
60
static final int S_setPolicyDelegate = WebKit.sel_registerName("setPolicyDelegate:"); //$NON-NLS-1$
61
static final int S_setResourceLoadDelegate = WebKit.sel_registerName("setResourceLoadDelegate:"); //$NON-NLS-1$
62
static final int S_setStatusText = WebKit.sel_registerName("setStatusText:"); //$NON-NLS-1$
63
static final int S_setUIDelegate = WebKit.sel_registerName("setUIDelegate:"); //$NON-NLS-1$
64
static final int S_stopLoading = WebKit.sel_registerName("stopLoading:"); //$NON-NLS-1$
65
static final int S_stringByEvaluatingJavaScriptFromString = WebKit.sel_registerName("stringByEvaluatingJavaScriptFromString:"); //$NON-NLS-1$
66
static final int S_takeStringURLFrom = WebKit.sel_registerName("takeStringURLFrom:"); //$NON-NLS-1$
67
static final int S_use = WebKit.sel_registerName("use"); //$NON-NLS-1$
68
static final int S_webFrame = WebKit.sel_registerName("webFrame"); //$NON-NLS-1$
69
static final int S_URL = WebKit.sel_registerName("URL"); //$NON-NLS-1$
70
static final int S_URLWithString = WebKit.sel_registerName("URLWithString:"); //$NON-NLS-1$
71

72 /* WebKit */
73 static final native int HIWebViewCreate(int[] outView);
74 static final native int HIWebViewGetWebView(int inView);
75 static final native void WebInitForCarbon();
76     
77 /* OBJ-C runtime primitives */
78 static final native int objc_getClass(byte[] className);
79 static final native int objc_msgSend(int object, int selector);
80 static final native int objc_msgSend(int object, int selector, int arg0);
81 static final native int objc_msgSend(int object, int selector, int arg0, int arg1);
82 static final native int objc_msgSend(int object, int selector, int arg0, int arg1, int arg2);
83 static final native int objc_msgSend(int object, int selector, int arg0, int arg1, int arg2, int arg3);
84 static final native int sel_registerName(byte[] selectorName);
85
86 static byte [] ascii (String JavaDoc name) {
87     int length = name.length ();
88     char [] chars = new char [length];
89     name.getChars (0, length, chars, 0);
90     byte [] buffer = new byte [length + 1];
91     for (int i=0; i<length; i++) {
92         buffer [i] = (byte) chars [i];
93     }
94     return buffer;
95 }
96
97 static int sel_registerName(String JavaDoc selector) {
98     return WebKit.sel_registerName(ascii(selector));
99 }
100     
101 static int objc_getClass(String JavaDoc className) {
102     return WebKit.objc_getClass(ascii(className));
103 }
104 }
105
Popular Tags