Browse Source

add support for WebViewListener

Redmond Urbino 16 years ago
parent
commit
79b6b53d32

+ 6 - 4
panda/src/awesomium/Sources.pp

@@ -17,18 +17,20 @@
   #define SOURCES \
   #define SOURCES \
     awesomium_includes.h config_awesomium.h \
     awesomium_includes.h config_awesomium.h \
     awWebCore.I awWebCore.h \
     awWebCore.I awWebCore.h \
-    awWebView.I awWebView.h
+    awWebView.I awWebView.h \
+    awWebViewListener.I awWebViewListener.h
 
 
   #define INCLUDED_SOURCES \
   #define INCLUDED_SOURCES \
     config_awesomium.cxx \
     config_awesomium.cxx \
     awWebCore.cxx \
     awWebCore.cxx \
-    awWebView.cxx
-
+    awWebView.cxx \
+    awWebViewListener.cxx
 
 
   #define INSTALL_HEADERS \
   #define INSTALL_HEADERS \
     awesomium_includes.h config_awesomium.h \
     awesomium_includes.h config_awesomium.h \
     awWebCore.h awWebCore.I \
     awWebCore.h awWebCore.I \
-    awWebView.h awWebView.I
+    awWebView.h awWebView.I \
+    awWebViewListener.I awWebViewListener.h    
 
 
   #define IGATESCAN all
   #define IGATESCAN all
 
 

+ 13 - 0
panda/src/awesomium/awWebViewListener.I

@@ -0,0 +1,13 @@
+// Filename: awWebViewListener.I
+// Created by:  rurbino (12Oct09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////

+ 81 - 0
panda/src/awesomium/awWebViewListener.cxx

@@ -0,0 +1,81 @@
+// Filename: awWebView.cxx
+// Created by:  rurbino (12Oct09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+#include "config_awesomium.h"
+#include "awWebViewListener.h"
+
+TypeHandle AwWebViewListener::_type_handle;
+
+AwWebViewListener::
+AwWebViewListener()  {  
+  awesomium_cat.info() << "constructing WebViewListner" ;
+}
+
+void AwWebViewListener::onBeginNavigation(const std::string& url, const std::wstring& frameName){
+}
+
+void AwWebViewListener::onBeginLoading(const std::string& url, const std::wstring& frameName, int statusCode, const std::wstring& mimeType) {
+  awesomium_cat.info() << "onBeginLoading" ;
+}
+
+	/**
+	* This event is fired when all loads have finished for a WebView.
+	*/
+void AwWebViewListener::onFinishLoading() {
+}
+
+	/**
+	* This event is fired when a Client callback has been invoked via Javascript from a page.
+	*
+	* @param	name	The name of the client callback that was invoked (specifically, "Client._this_name_here_(...)").
+	*
+	* @param	args	The arguments passed to the callback.
+	*/
+void AwWebViewListener::onCallback(const std::string& name, const Awesomium::JSArguments& args) {
+}
+	
+	/**
+	* This event is fired when a page title is received.
+	*
+	* @param	title	The page title.
+	*
+	* @param	frameName	The name of the frame that this event originated from.
+	*/
+void AwWebViewListener::onReceiveTitle(const std::wstring& title, const std::wstring& frameName) {
+}
+
+	/**
+	* This event is fired when a tooltip has changed state.
+	*
+	* @param	tooltip		The tooltip text (or, is an empty string when the tooltip should disappear).
+	*/
+void AwWebViewListener::onChangeTooltip(const std::wstring& tooltip) {
+}
+
+	/**
+	* This event is fired when keyboard focus has changed.
+	*
+	* @param	isFocused	Whether or not the keyboard is currently focused.
+	*/
+void AwWebViewListener::onChangeKeyboardFocus(bool isFocused) {
+}
+
+	/**
+	* This event is fired when the target URL has changed. This is usually the result of 
+	* hovering over a link on the page.
+	*
+	* @param	url	The updated target URL (or empty if the target URL is cleared).
+	*/
+void AwWebViewListener::onChangeTargetURL(const std::string& url) {
+}

+ 124 - 0
panda/src/awesomium/awWebViewListener.h

@@ -0,0 +1,124 @@
+// Filename: awWebViewListener.h
+// Created by:  rurbino (12Oct09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+#ifndef AWWEBVIEWLISTENER_H
+#define AWWEBVIEWLISTENER_H
+
+#include "pandabase.h"
+#include "typedReferenceCount.h"
+#include "luse.h"
+
+#include "awesomium_includes.h"
+
+////////////////////////////////////////////////////////////////////
+//       Class : AwWebViewListener
+// Description : Thin bindings, wraps a WebViewListener
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDAAWESOMIUM AwWebViewListener : public TypedReferenceCount, public Awesomium::WebCore {
+PUBLISHED:
+
+
+PUBLISHED:
+        AwWebViewListener();
+  
+        virtual ~AwWebViewListener() {}
+   
+	/**
+	* This event is fired when a WebView begins navigating to a new URL.
+	*
+	* @param	url		The URL that is being navigated to.
+	*
+	* @param	frameName	The name of the frame that this event originated from.
+	*/
+	void onBeginNavigation(const std::string& url, const std::wstring& frameName) ;
+
+	/**
+	* This event is fired when a WebView begins to actually receive data from a server.
+	*
+	* @param	url		The URL of the frame that is being loaded.
+	*
+	* @param	frameName	The name of the frame that this event originated from.
+	*
+	* @param	statusCode	The HTTP status code returned by the server.
+	*
+	* @param	mimeType	The mime-type of the content that is being loaded.
+	*/
+        void onBeginLoading(const std::string& url, const std::wstring& frameName, int statusCode, const std::wstring& mimeType);
+
+	/**
+	* This event is fired when all loads have finished for a WebView.
+	*/
+        void onFinishLoading();
+
+	/**
+	* This event is fired when a Client callback has been invoked via Javascript from a page.
+	*
+	* @param	name	The name of the client callback that was invoked (specifically, "Client._this_name_here_(...)").
+	*
+	* @param	args	The arguments passed to the callback.
+	*/
+  void onCallback(const std::string& name, const Awesomium::JSArguments& args);
+	
+	/**
+	* This event is fired when a page title is received.
+	*
+	* @param	title	The page title.
+	*
+	* @param	frameName	The name of the frame that this event originated from.
+	*/
+  void onReceiveTitle(const std::wstring& title, const std::wstring& frameName) ;
+
+	/**
+	* This event is fired when a tooltip has changed state.
+	*
+	* @param	tooltip		The tooltip text (or, is an empty string when the tooltip should disappear).
+	*/
+	void onChangeTooltip(const std::wstring& tooltip);
+
+	/**
+	* This event is fired when keyboard focus has changed.
+	*
+	* @param	isFocused	Whether or not the keyboard is currently focused.
+	*/
+	void onChangeKeyboardFocus(bool isFocused) ;
+
+	/**
+	* This event is fired when the target URL has changed. This is usually the result of 
+	* hovering over a link on the page.
+	*
+	* @param	url	The updated target URL (or empty if the target URL is cleared).
+	*/
+	void onChangeTargetURL(const std::string& url) ;
+
+
+public:
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    TypedReferenceCount::init_type();
+    register_type(_type_handle, "AwWebViewListener",
+                  TypedReferenceCount::get_class_type());
+  }
+  virtual TypeHandle get_type() const {
+    return get_class_type();
+  }
+  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
+
+private:
+  static TypeHandle _type_handle;
+};
+
+// #include "awWebViewListener.I"
+
+#endif

+ 1 - 1
panda/src/awesomium/awesomium_includes.h

@@ -15,8 +15,8 @@
 #ifndef _AWESOMIUM_INCLUDES_H_
 #ifndef _AWESOMIUM_INCLUDES_H_
 #define _AWESOMIUM_INCLUDES_H_
 #define _AWESOMIUM_INCLUDES_H_
 
 
-
 #include "WebCore.h"
 #include "WebCore.h"
 #include "WebView.h"
 #include "WebView.h"
+#include "WebViewListener.h"
 
 
 #endif
 #endif

+ 3 - 0
panda/src/awesomium/config_awesomium.cxx

@@ -15,8 +15,10 @@
 #include "config_awesomium.h"
 #include "config_awesomium.h"
 #include "awWebCore.h"
 #include "awWebCore.h"
 #include "awWebView.h"
 #include "awWebView.h"
+#include "awWebViewListener.h"
 #include "dconfig.h"
 #include "dconfig.h"
 
 
+
 Configure(config_awesomium);
 Configure(config_awesomium);
 NotifyCategoryDef(awesomium, "");
 NotifyCategoryDef(awesomium, "");
 
 
@@ -43,5 +45,6 @@ init_libawesomium() {
   
   
   AwWebCore::init_type();
   AwWebCore::init_type();
   AwWebView::init_type();
   AwWebView::init_type();
+  AwWebViewListener::init_type();
 
 
 }
 }

+ 1 - 0
panda/src/awesomium/pandaawesomium_composite1.cxx

@@ -1,3 +1,4 @@
 #include "config_awesomium.cxx"
 #include "config_awesomium.cxx"
 #include "awWebCore.cxx"
 #include "awWebCore.cxx"
 #include "awWebView.cxx"
 #include "awWebView.cxx"
+#include "awWebViewListener.cxx"