From 79b6b53d32b934c2afc224215e95f2049ef014a3 Mon Sep 17 00:00:00 2001 From: Redmond Urbino Date: Thu, 24 Dec 2009 22:37:08 +0000 Subject: [PATCH] add support for WebViewListener --- panda/src/awesomium/Sources.pp | 10 +- panda/src/awesomium/awWebViewListener.I | 13 ++ panda/src/awesomium/awWebViewListener.cxx | 81 ++++++++++++ panda/src/awesomium/awWebViewListener.h | 124 ++++++++++++++++++ panda/src/awesomium/awesomium_includes.h | 2 +- panda/src/awesomium/config_awesomium.cxx | 3 + .../awesomium/pandaawesomium_composite1.cxx | 1 + 7 files changed, 229 insertions(+), 5 deletions(-) create mode 100644 panda/src/awesomium/awWebViewListener.I create mode 100644 panda/src/awesomium/awWebViewListener.cxx create mode 100644 panda/src/awesomium/awWebViewListener.h diff --git a/panda/src/awesomium/Sources.pp b/panda/src/awesomium/Sources.pp index 493f7da1f9..0ed62aab13 100644 --- a/panda/src/awesomium/Sources.pp +++ b/panda/src/awesomium/Sources.pp @@ -17,18 +17,20 @@ #define SOURCES \ awesomium_includes.h config_awesomium.h \ awWebCore.I awWebCore.h \ - awWebView.I awWebView.h + awWebView.I awWebView.h \ + awWebViewListener.I awWebViewListener.h #define INCLUDED_SOURCES \ config_awesomium.cxx \ awWebCore.cxx \ - awWebView.cxx - + awWebView.cxx \ + awWebViewListener.cxx #define INSTALL_HEADERS \ awesomium_includes.h config_awesomium.h \ awWebCore.h awWebCore.I \ - awWebView.h awWebView.I + awWebView.h awWebView.I \ + awWebViewListener.I awWebViewListener.h #define IGATESCAN all diff --git a/panda/src/awesomium/awWebViewListener.I b/panda/src/awesomium/awWebViewListener.I new file mode 100644 index 0000000000..f342727802 --- /dev/null +++ b/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." +// +//////////////////////////////////////////////////////////////////// diff --git a/panda/src/awesomium/awWebViewListener.cxx b/panda/src/awesomium/awWebViewListener.cxx new file mode 100644 index 0000000000..0626faa6e3 --- /dev/null +++ b/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) { +} diff --git a/panda/src/awesomium/awWebViewListener.h b/panda/src/awesomium/awWebViewListener.h new file mode 100644 index 0000000000..d4174a7256 --- /dev/null +++ b/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 diff --git a/panda/src/awesomium/awesomium_includes.h b/panda/src/awesomium/awesomium_includes.h index 9a856f6d4b..f103d39566 100644 --- a/panda/src/awesomium/awesomium_includes.h +++ b/panda/src/awesomium/awesomium_includes.h @@ -15,8 +15,8 @@ #ifndef _AWESOMIUM_INCLUDES_H_ #define _AWESOMIUM_INCLUDES_H_ - #include "WebCore.h" #include "WebView.h" +#include "WebViewListener.h" #endif diff --git a/panda/src/awesomium/config_awesomium.cxx b/panda/src/awesomium/config_awesomium.cxx index 7ab192c24d..892a351327 100644 --- a/panda/src/awesomium/config_awesomium.cxx +++ b/panda/src/awesomium/config_awesomium.cxx @@ -15,8 +15,10 @@ #include "config_awesomium.h" #include "awWebCore.h" #include "awWebView.h" +#include "awWebViewListener.h" #include "dconfig.h" + Configure(config_awesomium); NotifyCategoryDef(awesomium, ""); @@ -43,5 +45,6 @@ init_libawesomium() { AwWebCore::init_type(); AwWebView::init_type(); + AwWebViewListener::init_type(); } diff --git a/panda/src/awesomium/pandaawesomium_composite1.cxx b/panda/src/awesomium/pandaawesomium_composite1.cxx index 81c8fa2590..1b0ef139ec 100644 --- a/panda/src/awesomium/pandaawesomium_composite1.cxx +++ b/panda/src/awesomium/pandaawesomium_composite1.cxx @@ -1,3 +1,4 @@ #include "config_awesomium.cxx" #include "awWebCore.cxx" #include "awWebView.cxx" +#include "awWebViewListener.cxx"