Application of the most recent wxWebView patch, the only changes were so tab to space conversions. Please note this probably won't compile.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@67698 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Steve Lamerton
2011-05-04 15:40:00 +00:00
parent 1a9dfe8dcb
commit cfcf1d6ee3
23 changed files with 5130 additions and 6 deletions

View File

@@ -39,6 +39,7 @@
@echo USE_THREADS=$(USE_THREADS) >>$(BUILD_CFG_FILE)
@echo USE_GUI=$(USE_GUI) >>$(BUILD_CFG_FILE)
@echo USE_HTML=$(USE_HTML) >>$(BUILD_CFG_FILE)
@echo USE_WEB=$(USE_WEB) >>$(BUILD_CFG_FILE)
@echo USE_MEDIA=$(USE_MEDIA) >>$(BUILD_CFG_FILE)
@echo USE_OPENGL=$(USE_OPENGL) >>$(BUILD_CFG_FILE)
@echo USE_QA=$(USE_QA) >>$(BUILD_CFG_FILE)

View File

@@ -161,7 +161,9 @@
<set var="WXLIB_STC">
<if cond="MONOLITHIC=='0'">$(mk.evalExpr(wxwin.mkLibName('stc')))</if>
</set>
<set var="WXLIB_WEB">
<if cond="MONOLITHIC=='0'">$(mk.evalExpr(wxwin.mkLibName('web')))</if>
</set>
<set var="WXLIB_MONO">
<if cond="MONOLITHIC=='1'">$(mk.evalExpr(wxwin.mkLibName('mono')))</if>
</set>

View File

@@ -200,6 +200,14 @@ Default is to use debug CRT if and only if BUILD==debug.
</description>
</option>
<option name="USE_WEB">
<values>0,1</values>
<default-value>1</default-value>
<description>
Build wxWeb library (USE_GUI must be 1)?
</description>
</option>
<option name="USE_MEDIA">
<values>0,1</values>
<default-value>1</default-value>
@@ -372,6 +380,7 @@ to run the tests, include CppUnit library here.
<option name="EXTRALIBS"/>
<option name="EXTRALIBS_XML"/>
<option name="EXTRALIBS_HTML"/>
<option name="EXTRALIBS_WEB"/>
<option name="EXTRALIBS_MEDIA"/>
<option name="EXTRALIBS_GUI"/>
<option name="EXTRALIBS_OPENGL"/>
@@ -432,6 +441,7 @@ it if SHARED=1 unless you know what you are doing.
<set var="EXTRALIBS"/>
<set var="EXTRALIBS_XML"/>
<set var="EXTRALIBS_HTML"/>
<set var="EXTRALIBS_WEB"/>
<set var="EXTRALIBS_MEDIA"/>
<set var="EXTRALIBS_GUI"/>
<set var="EXTRALIBS_OPENGL">
@@ -480,6 +490,7 @@ Set the version of your Mingw installation here.
<set var="USE_RICHTEXT">1</set>
<set var="USE_STC">1</set>
<set var="USE_HTML">1</set>
<set var="USE_WEB">1</set>
<set var="USE_MEDIA">1</set>
<set var="USE_XRC">1</set>
<set var="USE_OPENGL">1</set>

View File

@@ -3309,6 +3309,21 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
<!-- wxHTML users: -->
src/generic/htmllbox.cpp
</set>
<set var="WEB_SRC_PLATFORM">
<if cond="TOOLKIT=='MSW'">
src/msw/webview.cpp
</if>
<if cond="PLATFORM_UNIX=='1'">
src/gtk/webview.cpp
</if>
<if cond="PLATFORM_MACOSX=='1'">
src/osx/webview.mm
</if>
</set>
<set var="WEB_SRC" hints="files">
$(WEB_SRC_PLATFORM)
src/common/webview.cpp
</set>
<set var="MSW_HTML_HDR" hints="files">
<if cond="TOOLKIT=='MSW'">wx/msw/helpbest.h</if>
</set>
@@ -3334,7 +3349,21 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
wx/htmllbox.h
$(MSW_HTML_HDR)
</set>
<set var="PLATFORM_WEB_HDR" hints="files">
<if cond="TOOLKIT=='MSW'">
wx/msw/webviewie.h
</if>
<if cond="PLATFORM_UNIX=='1'">
wx/gtk/webview.h
</if>
<if cond="PLATFORM_MACOSX=='1'">
wx/osx/webview.h
</if>
</set>
<set var="WEB_HDR" hints="files">
$(PLATFORM_WEB_HDR)
wx/webview.h
</set>
<!-- ====================================================================== -->

View File

@@ -4,7 +4,7 @@
<set var="MONOLIB_GUI_SRC">
<if cond="USE_GUI=='1'">
$(CORE_SRC) $(ADVANCED_SRC) $(MEDIA_SRC) $(HTML_SRC) $(QA_SRC)
$(CORE_SRC) $(ADVANCED_SRC) $(MEDIA_SRC) $(HTML_SRC) $(WEB_SRC) $(QA_SRC)
$(XRC_SRC) $(AUI_SRC) $(PROPGRID_SRC) $(RIBBON_SRC) $(RICHTEXT_SRC)
$(STC_SRC)
</if>
@@ -25,6 +25,7 @@
<define>WXMAKINGDLL</define>
<ldlibs>$(EXTRALIBS_XML)</ldlibs>
<ldlibs>$(EXTRALIBS_HTML)</ldlibs>
<ldlibs>$(EXTRALIBS_WEB)</ldlibs>
<ldlibs>$(EXTRALIBS_MEDIA)</ldlibs>
<ldlibs>$(PLUGIN_MONOLIB_EXTRALIBS)</ldlibs>
<library>$(wxscintilla_library_link)</library>

View File

@@ -173,6 +173,36 @@
<set var="MSVC6PRJ_MERGED_TARGETS_MULTILIB" append="1">html=htmllib+htmldll</set>
<!-- ================================================================ -->
<!-- wxWEB -->
<!-- ================================================================ -->
<dll id="webdll" template="wx_dll"
cond="SHARED=='1' and USE_GUI=='1' and USE_WEB=='1' and MONOLITHIC=='0'">
<define>WXUSINGDLL</define>
<define>WXMAKINGDLL_WEB</define>
<sources>$(WEB_SRC)</sources>
<library>coredll</library>
<library>basedll</library>
<ldlibs>$(EXTRALIBS_WEB)</ldlibs>
<msvc-headers>$(WEB_HDR)</msvc-headers>
</dll>
<!-- use this to conditonally link against htmldll with <library>: -->
<set var="webdll_library_link">
<if cond="SHARED=='1' and USE_GUI=='1' and USE_WEB=='1' and MONOLITHIC=='0'">webdll</if>
</set>
<lib id="weblib" template="wx_lib"
cond="SHARED=='0' and USE_GUI=='1' and USE_WEB=='1' and MONOLITHIC=='0'">
<sources>$(WEB_SRC)</sources>
<msvc-headers>$(WEB_HDR)</msvc-headers>
</lib>
<wxshortcut id="wxweb" cond="MONOLITHIC=='0' and USE_WEB=='1'"/>
<set var="MSVC6PRJ_MERGED_TARGETS_MULTILIB" append="1">web=weblib+webdll</set>
<!-- ================================================================ -->
<!-- OpenGL -->
<!-- ================================================================ -->

View File

@@ -104,6 +104,7 @@
<wx-lib>xml</wx-lib>
<wx-lib>core</wx-lib>
<wx-lib>base</wx-lib>
<wx-lib>web</wx-lib>
-->
@@ -124,7 +125,7 @@
tag definitions.
-->
<set var="WX_LIB_LIST">
base core net xml xrc html adv media gl qa aui ribbon propgrid richtext stc
base core net xml xrc html adv media gl qa aui ribbon propgrid richtext stc web
</set>
<!-- if you define this variable to 0 before including wx presets, the

View File

@@ -39,12 +39,12 @@ def mk_wxid(id):
# All libs that are part of the main library:
MAIN_LIBS = ['mono', 'base', 'core', 'adv', 'html', 'xml', 'net',
MAIN_LIBS = ['mono', 'base', 'core', 'adv', 'html', 'xml', 'net', 'web',
'media', 'qa', 'xrc', 'aui', 'ribbon', 'propgrid', 'richtext', 'stc']
# List of library names/ids for categories with different names:
LIBS_NOGUI = ['xml', 'net']
LIBS_GUI = ['core', 'adv', 'html', 'gl', 'qa', 'xrc', 'media',
'aui', 'propgrid', 'richtext', 'stc', 'ribbon']
'aui', 'propgrid', 'richtext', 'stc', 'ribbon', 'web']
# Additional libraries that must be linked in:
EXTRALIBS = {
'gl' : '$(EXTRALIBS_OPENGL)',
@@ -52,6 +52,7 @@ EXTRALIBS = {
'html' : '$(EXTRALIBS_HTML)',
'adv' : '$(PLUGIN_ADV_EXTRALIBS)',
'media' : '$(EXTRALIBS_MEDIA)',
'web' : '$(EXTRALIBS_WEB)',
}
def mkLibName(wxid):

116
include/wx/gtk/webview.h Normal file
View File

@@ -0,0 +1,116 @@
/////////////////////////////////////////////////////////////////////////////
// Name: include/gtk/wx/webview.h
// Purpose: GTK webkit backend for web view component
// Author: Robert Roebling, Marianne Gagnon
// Id: $Id$
// Copyright: (c) 200 Marianne Gagnon, 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_WEBKITCTRL_H_
#define _WX_GTK_WEBKITCTRL_H_
#include "wx/setup.h"
#if wxHAVE_WEB_BACKEND_GTK_WEBKIT
#include "wx/webview.h"
//-----------------------------------------------------------------------------
// wxWebViewGTKWebKit
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxWebViewGTKWebKit : public wxWebView
{
public:
wxWebViewGTKWebKit() { Init(); }
wxWebViewGTKWebKit(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxString& url = wxWebViewDefaultURLStr,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxString& name = wxWebViewNameStr)
{
Init();
Create(parent, id, url, pos, size, style, name);
}
virtual bool Create(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxString& url = wxWebViewDefaultURLStr,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxString& name = wxWebViewNameStr);
virtual bool Enable( bool enable = true );
// implementation
// --------------
static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
// helper to allow access to protected member from GTK callback
void MoveWindow(int x, int y, int width, int height)
{
DoMoveWindow(x, y, width, height);
}
void ZoomIn();
void ZoomOut();
void SetWebkitZoom(float level);
float GetWebkitZoom();
virtual void Stop();
virtual void LoadUrl(const wxString& url);
virtual void GoBack();
virtual void GoForward();
virtual void Reload(wxWebViewReloadFlags flags = 0);
virtual bool CanGoBack();
virtual bool CanGoForward();
virtual wxString GetCurrentURL();
virtual wxString GetCurrentTitle();
virtual wxString GetPageSource();
virtual void SetPage(const wxString& html, const wxString& baseUrl);
virtual void Print();
virtual bool IsBusy();
void SetZoomType(wxWebViewZoomType);
wxWebViewZoomType GetZoomType() const;
bool CanSetZoomType(wxWebViewZoomType) const;
virtual wxWebViewZoom GetZoom();
virtual void SetZoom(wxWebViewZoom);
/** FIXME: hack to work around signals being received too early */
bool m_ready;
/** TODO: check if this can be made private
* The native control has a getter to check for busy state, but except in
* very recent versions of webkit this getter doesn't say everything we need
* (namely it seems to stay indefinitely busy when loading is cancelled by
* user)
*/
bool m_busy;
protected:
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
private:
// focus event handler: calls GTKUpdateBitmap()
void GTKOnFocus(wxFocusEvent& event);
GtkWidget *web_view;
// FIXME: try to get DECLARE_DYNAMIC_CLASS macros & stuff right
//DECLARE_DYNAMIC_CLASS(wxWebViewGTKWebKit)
};
#endif // if wxHAVE_WEB_BACKEND_GTK_WEBKIT

126
include/wx/msw/webviewie.h Normal file
View File

@@ -0,0 +1,126 @@
/////////////////////////////////////////////////////////////////////////////
// Name: include/wx/msw/webviewie.h
// Purpose: wxMSW IE wxWebView backend
// Author: Marianne Gagnon
// Id: $Id$
// Copyright: (c) 2010 Marianne Gagnon
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef wxWebViewIE_H
#define wxWebViewIE_H
#include "wx/setup.h"
#if wxHAVE_WEB_BACKEND_IE
#include "wx/control.h"
#include "wx/webview.h"
#include "wx/msw/ole/automtn.h"
#include "wx/msw/ole/activex.h"
// TODO: move this to wx/msw/chkconf.h
#if wxUSE_ACTIVEX != 1
#error "wxUSE_ACTIVEX must be activated for this to work"
#endif
#if wxUSE_OLE_AUTOMATION != 1
#error "wxUSE_OLE_AUTOMATION must be activated for this to work"
#endif
// FIXME: get those DLL export macros right...
class wxWebViewIE : public wxWebView
{
public:
wxWebViewIE() {}
wxWebViewIE(wxWindow* parent,
wxWindowID id,
const wxString& url = wxWebViewDefaultURLStr,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxWebViewNameStr)
{
Create(parent, id, url, pos, size, style, name);
}
bool Create(wxWindow* parent,
wxWindowID id,
const wxString& url = wxWebViewDefaultURLStr,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxWebViewNameStr);
virtual void LoadUrl(const wxString& url);
virtual bool CanGoForward() { return m_canNavigateForward; }
virtual bool CanGoBack() { return m_canNavigateBack; }
virtual void GoBack();
virtual void GoForward();
virtual void Stop();
virtual void Reload(wxWebViewReloadFlags flags=0);
virtual wxString GetPageSource();
virtual bool IsBusy();
virtual wxString GetCurrentURL();
virtual wxString GetCurrentTitle();
virtual void SetZoomType(wxWebViewZoomType);
virtual wxWebViewZoomType GetZoomType() const;
virtual bool CanSetZoomType(wxWebViewZoomType) const;
virtual void Print();
virtual void SetPage(const wxString& html, const wxString& baseUrl);
virtual wxWebViewZoom GetZoom();
virtual void SetZoom(wxWebViewZoom zoom);
// ---- IE-specific methods
// FIXME: I seem to be able to access remote webpages even in offline mode...
bool IsOfflineMode();
void SetOfflineMode(bool offline);
/**
* Get text zoom
* @return text zoom from 0 to 4
*/
int GetIETextZoom();
/**
* @param level 0 to 4
*/
void SetIETextZoom(int level);
void SetIEOpticalZoom(float zoom);
float GetIEOpticalZoom();
void onActiveXEvent(wxActiveXEvent& evt);
void onEraseBg(wxEraseEvent& evt) {}
DECLARE_EVENT_TABLE();
private:
wxActiveXContainer* m_container;
wxAutomationObject m_ie;
IWebBrowser2* m_webBrowser;
DWORD m_dwCookie;
bool m_canNavigateBack;
bool m_canNavigateForward;
/** The "Busy" property of IWebBrowser2 does not always return busy when
* we'd want it to; this variable may be set to true in cases where the
* Busy property is false but should be true.
*/
bool m_isBusy;
};
#endif // wxHAVE_WEB_BACKEND_IE
#endif // wxWebViewIE_H

142
include/wx/osx/webview.h Normal file
View File

@@ -0,0 +1,142 @@
/////////////////////////////////////////////////////////////////////////////
// Name: include/wx/osx/webkit.h
// Purpose: wxOSXWebKitCtrl - embeddable web kit control,
// OS X implementation of web view component
// Author: Jethro Grassie / Kevin Ollivier / Marianne Gagnon
// Modified by:
// Created: 2004-4-16
// RCS-ID: $Id$
// Copyright: (c) Jethro Grassie / Kevin Ollivier / Marianne Gagnon
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_WEBKIT_H
#define _WX_WEBKIT_H
#include "wx/setup.h"
#if wxUSE_WEBKIT && (defined(__WXMAC__) || defined(__WXCOCOA__))
// TODO: define this in setup.h ?
#define wxHAVE_WEB_BACKEND_OSX_WEBKIT 1
#include "wx/control.h"
#include "wx/webview.h"
// ----------------------------------------------------------------------------
// Web Kit Control
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxOSXWebKitCtrl : public wxWebView
{
public:
wxDECLARE_DYNAMIC_CLASS(wxOSXWebKitCtrl);
wxOSXWebKitCtrl() {}
wxOSXWebKitCtrl(wxWindow *parent,
wxWindowID winID = wxID_ANY,
const wxString& strURL = wxWebViewDefaultURLStr,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxString& name = wxWebViewNameStr)
{
Create(parent, winID, strURL, pos, size, style, name);
}
bool Create(wxWindow *parent,
wxWindowID winID = wxID_ANY,
const wxString& strURL = wxWebViewDefaultURLStr,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxString& name = wxWebViewNameStr);
virtual ~wxOSXWebKitCtrl();
void InternalLoadURL(const wxString &url);
virtual bool CanGoBack();
virtual bool CanGoForward();
virtual void GoBack();
virtual void GoForward();
virtual void Reload(wxWebViewReloadFlags flags = 0);
virtual void Stop();
virtual wxString GetPageSource();
virtual void SetPageTitle(const wxString& title) { m_pageTitle = title; }
virtual wxString GetPageTitle(){ return m_pageTitle; }
virtual void SetPage(const wxString& html, const wxString& baseUrl);
virtual void Print();
virtual void LoadUrl(const wxString& url);
virtual wxString GetCurrentURL();
virtual wxString GetCurrentTitle();
virtual wxWebViewZoom GetZoom();
virtual void SetZoom(wxWebViewZoom zoom);
virtual void SetZoomType(wxWebViewZoomType zoomType);
virtual wxWebViewZoomType GetZoomType() const;
virtual bool CanSetZoomType(wxWebViewZoomType type) const;
virtual bool IsBusy() { return m_busy; }
// ---- methods not from the parent (common) interface
wxString GetSelectedText();
wxString RunScript(const wxString& javascript);
bool CanGetPageSource();
void SetScrollPos(int pos);
int GetScrollPos();
void MakeEditable(bool enable = true);
bool IsEditable();
wxString GetSelection();
bool CanIncreaseTextSize();
void IncreaseTextSize();
bool CanDecreaseTextSize();
void DecreaseTextSize();
float GetWebkitZoom();
void SetWebkitZoom(float zoom);
// don't hide base class virtuals
virtual void SetScrollPos( int orient, int pos, bool refresh = true )
{ return wxControl::SetScrollPos(orient, pos, refresh); }
virtual int GetScrollPos( int orient ) const
{ return wxControl::GetScrollPos(orient); }
//we need to resize the webview when the control size changes
void OnSize(wxSizeEvent &event);
void OnMove(wxMoveEvent &event);
void OnMouseEvents(wxMouseEvent &event);
bool m_busy;
protected:
DECLARE_EVENT_TABLE()
void MacVisibilityChanged();
private:
wxWindow *m_parent;
wxWindowID m_windowID;
wxString m_pageTitle;
struct objc_object *m_webView;
// we may use this later to setup our own mouse events,
// so leave it in for now.
void* m_webKitCtrlEventHandler;
//It should be WebView*, but WebView is an Objective-C class
//TODO: look into using DECLARE_WXCOCOA_OBJC_CLASS rather than this.
};
#else
// TODO: define this in setup.h ?
#define wxHAVE_WEB_BACKEND_OSX_WEBKIT 0
#endif // wxUSE_WEBKIT
#endif // _WX_WEBKIT_H_

429
include/wx/webview.h Normal file
View File

@@ -0,0 +1,429 @@
/////////////////////////////////////////////////////////////////////////////
// Name: webview.h
// Purpose: Common interface and events for web view component
// Author: Marianne Gagnon
// Id: $Id$
// Copyright: (c) 2010 Marianne Gagnon
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_WEB_VIEW_H_
#define _WX_WEB_VIEW_H_
#include <wx/control.h>
#include <wx/event.h>
#include <wx/sstream.h>
/**
* Zoom level in web view component
*/
enum wxWebViewZoom
{
wxWEB_VIEW_ZOOM_TINY,
wxWEB_VIEW_ZOOM_SMALL,
wxWEB_VIEW_ZOOM_MEDIUM,
wxWEB_VIEW_ZOOM_LARGE,
wxWEB_VIEW_ZOOM_LARGEST
};
/**
* The type of zooming that the web view control can perform
*/
enum wxWebViewZoomType
{
/** The entire layout scales when zooming, including images */
wxWEB_VIEW_ZOOM_TYPE_LAYOUT,
/** Only the text changes in size when zooming, images and other layout
* elements retain their initial size */
wxWEB_VIEW_ZOOM_TYPE_TEXT
};
/** Types of errors that can cause navigation to fail */
enum wxWebNavigationError
{
/** Connection error (timeout, etc.) */
wxWEB_NAV_ERR_CONNECTION = 1,
/** Invalid certificate */
wxWEB_NAV_ERR_CERTIFICATE = 2,
/** Authentication required */
wxWEB_NAV_ERR_AUTH = 3,
/** Other security error */
wxWEB_NAV_ERR_SECURITY = 4,
/** Requested resource not found */
wxWEB_NAV_ERR_NOT_FOUND = 5,
/** Invalid request/parameters (e.g. bad URL, bad protocol,
* unsupported resource type) */
wxWEB_NAV_ERR_REQUEST = 6,
/** The user cancelled (e.g. in a dialog) */
wxWEB_NAV_ERR_USER_CANCELLED = 7,
/** Another (exotic) type of error that didn't fit in other categories*/
wxWEB_NAV_ERR_OTHER = 8
};
/** Type of refresh */
enum wxWebViewReloadFlags
{
/** Reload the current view without accessing the cache */
wxWEB_VIEW_RELOAD_NO_CACHE = 1
};
/**
* List of available backends for wxWebView
*/
enum wxWebViewBackend
{
/** Value that may be passed to wxWebView to let it pick an appropriate
* engine for the current platform*/
wxWEB_VIEW_BACKEND_DEFAULT,
/** The OSX-native WebKit web engine */
wxWEB_VIEW_BACKEND_OSX_WEBKIT,
/** The GTK port of the WebKit engine */
wxWEB_VIEW_BACKEND_GTK_WEBKIT,
/** Use Microsoft Internet Explorer as web engine */
wxWEB_VIEW_BACKEND_IE
};
extern WXDLLIMPEXP_DATA_CORE(const char) wxWebViewNameStr[];
extern WXDLLIMPEXP_DATA_CORE(const char) wxWebViewDefaultURLStr[];
/**
* @class wxWebView
*
* This control may be used to render web (HTML / CSS / javascript) documents.
* Capabilities of the HTML renderer will depend upon the backed.
* TODO: describe each backend and its capabilities here
*
* Note that errors are generally reported asynchronously though the
* wxEVT_COMMAND_WEB_VIEW_ERROR event described below.
*
* @beginEventEmissionTable{wxWebNavigationEvent}
* @event{EVT_BUTTON(id, func)}
*
* @event{EVT_WEB_VIEW_NAVIGATING(id, func)}
* Process a wxEVT_COMMAND_WEB_VIEW_NAVIGATING event, generated before trying
* to get a resource. This event may be vetoed to prevent navigating to this
* resource. Note that if the displayed HTML document has several frames, one
* such event will be generated per frame.
*
* @event{EVT_WEB_VIEW_NAVIGATED(id, func)}
* Process a wxEVT_COMMAND_WEB_VIEW_NAVIGATED event generated after it was
* confirmed that a resource would be requested. This event may not be vetoed.
* Note that if the displayed HTML document has several frames, one such event
* will be generated per frame.
*
* @event{EVT_WEB_VIEW_LOADED(id, func)}
* Process a wxEVT_COMMAND_WEB_VIEW_LOADED event generated when the document
* is fully loaded and displayed.
*
* @event{EVT_WEB_VIEW_ERRROR(id, func)}
* Process a wxEVT_COMMAND_WEB_VIEW_ERROR event generated when a navigation
* error occurs.
* The integer associated with this event will be a wxWebNavigationError item.
* The string associated with this event may contain a backend-specific more
* precise error message/code.
*
* @endEventTable
*/
class wxWebView : public wxControl
{
public:
/**
* Creation function for two-step creation.
*/
virtual bool Create(wxWindow* parent,
wxWindowID id,
const wxString& url,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name) = 0;
/**
* Factory function to create a new wxWebView for two-step creation
* (you need to call wxWebView::Create on the returned object)
* @param backend which web engine to use as backend for wxWebView
* @return the created wxWebView, or NULL if the requested backend is
* not available
*/
static wxWebView* New(wxWebViewBackend backend = wxWEB_VIEW_BACKEND_DEFAULT);
// TODO: clarify what styles can do, or remove this flag
/**
* Factory function to create a new wxWebView
* @param parent parent window to create this view in
* @param id ID of this control
* @param url URL to load by default in the web view
* @param pos position to create this control at
* (you may use wxDefaultPosition if you use sizers)
* @param size size to create this control with
* (you may use wxDefaultSize if you use sizers)
* @param backend which web engine to use as backend for wxWebView
* @return the created wxWebView, or NULL if the requested backend
* is not available
*/
static wxWebView* New(wxWindow* parent,
wxWindowID id,
const wxString& url = wxWebViewDefaultURLStr,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
wxWebViewBackend backend = wxWEB_VIEW_BACKEND_DEFAULT,
long style = 0,
const wxString& name = wxWebViewNameStr);
/** Get whether it is possible to navigate back in the history of
* visited pages
*/
virtual bool CanGoBack() = 0;
/** Get whether it is possible to navigate forward in the history of
* visited pages
*/
virtual bool CanGoForward() = 0;
/** Navigate back in the history of visited pages.
* Only valid if CanGoBack() returned true.
*/
virtual void GoBack() = 0;
/** Navigate forwardin the history of visited pages.
* Only valid if CanGoForward() returned true.
*/
virtual void GoForward() = 0;
/**
* Load a HTMl document (web page) from a URL
* @param url the URL where the HTML document to display can be found
* @note web engines generally report errors asynchronously, so if you wish
* to know whether loading the URL was successful, register to receive
* navigation error events
*/
virtual void LoadUrl(const wxString& url) = 0;
/**
* Stop the current page loading process, if any.
* May trigger an error event of type wxWEB_NAV_ERR_USER_CANCELLED.
* TODO: make wxWEB_NAV_ERR_USER_CANCELLED errors uniform across ports.
*/
virtual void Stop() = 0;
/**
* Reload the currently displayed URL.
* @param flags A bit array that may optionnally contain reload options
*/
virtual void Reload(wxWebViewReloadFlags flags=0) = 0;
/**
* Get the URL of the currently displayed document
*/
virtual wxString GetCurrentURL() = 0;
/**
* Get the title of the current web page, or its URL/path if title is not
* available
*/
virtual wxString GetCurrentTitle() = 0;
// TODO: handle choosing a frame when calling GetPageSource()?
/**
* Get the HTML source code of the currently displayed document
* @return the HTML source code, or an empty string if no page is currently
* shown
*/
virtual wxString GetPageSource() = 0;
/**
* Get the zoom factor of the page
* @return How much the HTML document is zoomed (scaleed)
*/
virtual wxWebViewZoom GetZoom() = 0;
/**
* Set the zoom factor of the page
* @param zoom How much to zoom (scale) the HTML document
*/
virtual void SetZoom(wxWebViewZoom zoom) = 0;
/**
* Set how to interpret the zoom factor
* @param zoomType how the zoom factor should be interpreted by the
* HTML engine
* @note invoke canSetZoomType() first, some HTML renderers may not
* support all zoom types
*/
virtual void SetZoomType(wxWebViewZoomType zoomType) = 0;
/**
* Get how the zoom factor is currently interpreted
* @return how the zoom factor is currently interpreted by the HTML engine
*/
virtual wxWebViewZoomType GetZoomType() const = 0;
/**
* Retrieve whether the current HTML engine supports a type of zoom
* @param type the type of zoom to test
* @return whether this type of zoom is supported by this HTML engine
* (and thus can be set through setZoomType())
*/
virtual bool CanSetZoomType(wxWebViewZoomType type) const = 0;
// TODO: allow 'SetPage' to find files (e.g. images) from a virtual file
// system if possible
/**
* Set the displayed page source to the contents of the given string
* @param html the string that contains the HTML data to display
* @param baseUrl URL assigned to the HTML data, to be used to resolve
* relative paths, for instance
*/
virtual void SetPage(const wxString& html, const wxString& baseUrl) = 0;
/**
* Set the displayed page source to the contents of the given stream
* @param html the stream to read HTML data from
* @param baseUrl URL assigned to the HTML data, to be used to resolve
* relative paths, for instance
*/
virtual void SetPage(wxInputStream& html, wxString baseUrl)
{
wxStringOutputStream stream;
stream.Write(html);
SetPage(stream.GetString(), baseUrl);
}
// TODO:
// wxString GetSelection(); // maybe?
// void SetSelection(...); // maybe?
// void MakeEditable(bool enable = true); // maybe?
// bool IsEditable(); // maybe?
// void EnableJavascript(bool enabled); // maybe?
// wxString RunScript(const wxString& javascript); // maybe?
// void SetScrollPos(int pos); // maybe?
// int GetScrollPos(); // maybe?
// wxString GetStatusText(); // maybe?
// void SetStatusText(wxString text); // maybe?
// * status text changed event?
// * title changed event?
// virtual bool IsOfflineMode() = 0; // maybe?
// virtual void SetOfflineMode(bool offline) = 0; // maybe?
// TODO: offer API to control the opening of new frames
// (through <a target="..."> as well as through javascript), OR
// provide a behavior consistent across ports.
// - OSX : I receive an event for new frames opened with HTML target, and
// currently block them all.
// - IE : The DISPID_NEWWINDOW2 event looks like it should work, but I
// receive way too many of them. A new IE instance opens.
// - GTK : All frame open requests are blocked. A slot exists that I could
// connect to to be notified if ever needed
/**
* Opens a print dialog so that the user may print the currently
* displayed page.
*/
virtual void Print() = 0;
/**
* Returns whether the web control is currently busy (e.g. loading a page)
*/
virtual bool IsBusy() = 0;
};
//class WXDLLIMPEXP_FWD_HTML wxWebNavigationEvent;
// FIXME: get those WXDLLIMPEXP_HTML & DECLARE_DYNAMIC_CLASS right...
//wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_HTML, wxEVT_COMMAND_WEB_VIEW_NAVIGATE,
// wxWebNavigationEvent );
// FIXME: get those WXDLLIMPEXP_HTML & DECLARE_DYNAMIC_CLASS right...
class wxWebNavigationEvent : public wxCommandEvent
{
public:
wxWebNavigationEvent() {}
wxWebNavigationEvent(wxEventType type, int id, const wxString href,
const wxString target, bool canVeto)
: wxCommandEvent(type, id)
{
m_href = href;
m_target = target;
m_vetoed = false;
m_canVeto = canVeto;
}
/**
* Get the URL being visited
*/
const wxString& GetHref() const { return m_href; }
/**
* Get the target (frame or window) in which the URL that caused this event
* is viewed, or an empty string if not available.
*/
const wxString& GetTarget() const { return m_target; }
// default copy ctor, assignment operator and dtor are ok
virtual wxEvent* Clone() const { return new wxWebNavigationEvent(*this); }
/** Get whether this event may be vetoed (stopped/prevented). Only
* meaningful for events fired before navigation takes place.
*/
bool CanVeto() const { return m_canVeto; }
/** Whether this event was vetoed (stopped/prevented). Only meaningful for
* events fired before navigation takes place.
*/
bool IsVetoed() const { return m_vetoed; }
/** Veto (prevent/stop) this event. Only meaningful for events fired
* before navigation takes place. Only valid if CanVeto() returned true.
*/
void Veto() { wxASSERT(m_canVeto); m_vetoed = true; }
private:
wxString m_href;
wxString m_target;
bool m_canVeto;
bool m_vetoed;
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWebNavigationEvent);
};
wxDECLARE_EVENT( wxEVT_COMMAND_WEB_VIEW_NAVIGATING, wxWebNavigationEvent );
wxDECLARE_EVENT( wxEVT_COMMAND_WEB_VIEW_NAVIGATED, wxWebNavigationEvent );
wxDECLARE_EVENT( wxEVT_COMMAND_WEB_VIEW_LOADED, wxWebNavigationEvent );
wxDECLARE_EVENT( wxEVT_COMMAND_WEB_VIEW_ERROR, wxWebNavigationEvent );
typedef void (wxEvtHandler::*wxWebNavigationEventFunction)
(wxWebNavigationEvent&);
#define wxWebNavigationEventHandler(func) \
wxEVENT_HANDLER_CAST(wxWebNavigationEventFunction, func)
#define EVT_WEB_VIEW_NAVIGATING(id, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_WEB_VIEW_NAVIGATING, id,
wxHtmlNavigatingEventHandler(fn))
#define EVT_WEB_VIEW_NAVIGATED(id, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_WEB_VIEW_NAVIGATED, id,
wxHtmlNavigatingEventHandler(fn))
#define EVT_WEB_VIEW_LOADED(id, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_WEB_VIEW_LOADED, id,
wxHtmlNavigatingEventHandler(fn))
#define EVT_WEB_VIEW_ERRROR(id, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_WEB_VIEW_ERROR, id,
wxHtmlNavigatingEventHandler(fn))
#endif

View File

@@ -87,6 +87,7 @@
<subproject id="uiaction" template="sub"/>
<subproject id="validate" template="sub"/>
<subproject id="vscroll" template="sub"/>
<subproject id="web" template="sub"/>
<subproject id="widgets" template="sub"/>
<subproject id="wizard" template="sub"/>
<subproject id="wrapsizer" template="sub"/>

260
samples/web/forward.xpm Normal file
View File

@@ -0,0 +1,260 @@
/* XPM */
static const char * forward_xpm[] = {
"32 32 225 2",
" c None",
". c #3A7304",
"+ c #5B8B2C",
"@ c #3C7404",
"# c #CBE0B7",
"$ c #77A24E",
"% c #3B7504",
"& c #CDE2B8",
"* c #C7DEB0",
"= c #8EB469",
"- c #3C7605",
"; c #C7DFB1",
"> c #9EC776",
", c #BBD8A0",
"' c #9FC280",
") c #42790D",
"! c #C5DDAD",
"~ c #96C36A",
"{ c #92C065",
"] c #AFD18E",
"^ c #AECD91",
"/ c #4D821B",
"( c #3A7404",
"_ c #C2DCA9",
": c #92C064",
"< c #8CBD5D",
"[ c #8BBC5B",
"} c #A0C979",
"| c #B5D299",
"1 c #5D8D2E",
"2 c #3B7503",
"3 c #B8D59B",
"4 c #BDD8A2",
"5 c #BED9A3",
"6 c #BFD9A4",
"7 c #BFDAA5",
"8 c #C0DAA6",
"9 c #C0DBA6",
"0 c #C2DCAA",
"a c #8DBD5E",
"b c #88BB57",
"c c #86B954",
"d c #85B952",
"e c #92C066",
"f c #B5D498",
"g c #729E46",
"h c #B8D69A",
"i c #7DB447",
"j c #7FB54A",
"k c #81B64D",
"l c #83B750",
"m c #84B851",
"n c #86B953",
"o c #86BA53",
"p c #86BA52",
"q c #84B850",
"r c #82B74F",
"s c #80B64C",
"t c #7EB549",
"u c #85B853",
"v c #B0D18F",
"w c #85AF5D",
"x c #3C7505",
"y c #B5D597",
"z c #78B141",
"A c #7AB344",
"B c #7FB54B",
"C c #81B74C",
"D c #82B94D",
"E c #83BA4D",
"F c #84BA4D",
"G c #83BA4C",
"H c #81B94A",
"I c #7FB848",
"J c #7DB646",
"K c #7AB343",
"L c #78B140",
"M c #7AB242",
"N c #A3CB7E",
"O c #97BD70",
"P c #427A0E",
"Q c #B4D495",
"R c #74AF3B",
"S c #76B03E",
"T c #79B342",
"U c #7CB644",
"V c #7EB745",
"W c #7FB946",
"X c #80BB48",
"Y c #80BB47",
"Z c #7FBA45",
"` c #7CB841",
" . c #71B132",
".. c #68AB27",
"+. c #62A61F",
"@. c #61A41F",
"#. c #65A625",
"$. c #91C064",
"%. c #A1C67D",
"&. c #4C821A",
"*. c #B2D292",
"=. c #70AD35",
"-. c #71AD37",
";. c #73AF39",
">. c #77B23C",
",. c #79B63E",
"'. c #7CB940",
"). c #7CBA40",
"!. c #7EBC41",
"~. c #7BBB3D",
"{. c #70B52C",
"]. c #62AD18",
"^. c #58A80B",
"/. c #56A508",
"(. c #54A207",
"_. c #529F06",
":. c #509C05",
"<. c #4E9905",
"[. c #A8CB85",
"}. c #598C29",
"|. c #3B7404",
"1. c #ADD08B",
"2. c #66A727",
"3. c #69A92B",
"4. c #6EAE30",
"5. c #6FB02F",
"6. c #6EB22C",
"7. c #6DB328",
"8. c #69B221",
"9. c #62B015",
"0. c #5CAD0B",
"a. c #5BAE0B",
"b. c #5BAD0A",
"c. c #5AAC0A",
"d. c #59A909",
"e. c #57A608",
"f. c #54A308",
"g. c #4F9B05",
"h. c #A2C97E",
"i. c #578B25",
"j. c #A3CA7E",
"k. c #52A007",
"l. c #55A408",
"m. c #58A809",
"n. c #5CAF0B",
"o. c #5EB10B",
"p. c #5EB20C",
"q. c #5FB20C",
"r. c #5DB00B",
"s. c #59AA0A",
"t. c #57A709",
"u. c #529E07",
"v. c #94BE6B",
"w. c #4B8116",
"x. c #519E06",
"y. c #54A307",
"z. c #5DAF0B",
"A. c #5FB30C",
"B. c #61B50D",
"C. c #62B70D",
"D. c #61B60D",
"E. c #60B40C",
"F. c #5EB10C",
"G. c #5CAE0B",
"H. c #59AA09",
"I. c #5BA810",
"J. c #8FC25E",
"K. c #8AB65C",
"L. c #41790C",
"M. c #53A007",
"N. c #61B70D",
"O. c #63BA0E",
"P. c #65BC0F",
"Q. c #64BB0E",
"R. c #63B90E",
"S. c #60B50D",
"T. c #67B31B",
"U. c #9CCB6D",
"V. c #7AAA4A",
"W. c #3B7405",
"X. c #A4CC7E",
"Y. c #A6CF7F",
"Z. c #A8D180",
"`. c #AAD480",
" + c #ACD781",
".+ c #ADD982",
"++ c #AFDB82",
"@+ c #B0DD83",
"#+ c #B1DE83",
"$+ c #6CC317",
"%+ c #67BF10",
"&+ c #75BE2B",
"*+ c #A3D075",
"=+ c #689C37",
"-+ c #3A7204",
";+ c #AEDE7D",
">+ c #6FC818",
",+ c #6AC411",
"'+ c #68C010",
")+ c #84C93E",
"!+ c #A4D275",
"~+ c #578B23",
"{+ c #376E03",
"]+ c #AEDF7D",
"^+ c #72CB19",
"/+ c #6DC714",
"(+ c #94D455",
"_+ c #9DCD6E",
":+ c #488016",
"<+ c #336204",
"[+ c #AEE07E",
"}+ c #7AD223",
"|+ c #A2DD67",
"1+ c #91C35E",
"2+ c #41790B",
"3+ c #B2E184",
"4+ c #AFE37C",
"5+ c #7EB24A",
"6+ c #3D7506",
"7+ c #3C7504",
"8+ c #AFDC84",
"9+ c #6A9D39",
"0+ c #3A7305",
"a+ c #50851D",
"b+ c #386F03",
" ",
" ",
" ",
" ",
" . ",
" . + @ ",
" . # $ % ",
" . & * = - ",
" . ; > , ' ) ",
" . ! ~ { ] ^ / ",
" . ( ( ( ( ( ( ( ( . _ : < [ } | 1 2 ",
" . 3 , 4 5 6 7 8 8 9 0 a b c d e f g % ",
" . h i j k l m d n o o p q r s t u v w x ",
" . y z A i t B C D E F G H I J K L M N O P ",
" . Q R S L T U V W X Y Y Z ` ...+.@.#.$.%.&. ",
" . *.=.-.;.>.,.'.).!.~.{.].^./.(._.:.<.<.R [.}.|. ",
" . 1.2.3.4.5.6.7.8.9.0.a.b.c.d.e.f._.g.<.=.h.i.|. ",
" . j.<.g.k.l.m.c.n.o.p.q.p.r.b.s.t.(.u.t v.w.@ ",
" . j.<.x.y.t.c.z.A.B.C.C.D.E.F.G.H.I.J.K.L. ",
" . j.g.M./.s.n.A.N.O.P.P.Q.R.S.F.T.U.V.W. ",
" . j.X.Y.Z.`. +.+++@+#+$+%+P.R.&+*+=+-+ ",
" . . . . . . . . . . ;+>+,+'+)+!+~+{+ ",
" @ ]+^+/+(+_+:+<+ ",
" @ [+}+|+1+2+ ",
" @ 3+4+5+6+ ",
" 7+8+9+0+ ",
" . a+b+ ",
" . ",
" ",
" ",
" ",
" "};

322
samples/web/refresh.xpm Normal file
View File

@@ -0,0 +1,322 @@
/* XPM */
static const char * refresh_xpm[] = {
"32 32 287 2",
" c None",
". c #396AA9",
"+ c #3D6CA9",
"@ c #3968A8",
"# c #3565A5",
"$ c #3767A6",
"% c #3867A7",
"& c #3A6AA8",
"* c #3567A6",
"= c #3C6BA8",
"- c #4B77B0",
"; c #87A6CE",
"> c #A5BFDE",
", c #B3CAE4",
"' c #BAD0E8",
") c #B6CEE6",
"! c #AFC6E1",
"~ c #9CB8D9",
"{ c #82A3CB",
"] c #537EB5",
"^ c #3767A7",
"/ c #3869A6",
"( c #3364A4",
"_ c #3E6CA9",
": c #94B1D4",
"< c #BCD2E8",
"[ c #BBD1E8",
"} c #B9D0E7",
"| c #B8CEE6",
"1 c #B5CDE5",
"2 c #B3CBE5",
"3 c #B2CBE5",
"4 c #B4CCE5",
"5 c #AAC4E1",
"6 c #799EC9",
"7 c #3B69A9",
"8 c #3768A6",
"9 c #3F6EAA",
"0 c #AEC5E1",
"a c #BED3E9",
"b c #B8CEE7",
"c c #B6CDE6",
"d c #B1CAE4",
"e c #AFC8E3",
"f c #ADC7E3",
"g c #ABC6E3",
"h c #769AC6",
"i c #3867A6",
"j c #3868A7",
"k c #87AAD2",
"l c #A6BFDD",
"m c #C0D4E9",
"n c #BDD3E8",
"o c #B4CCE4",
"p c #A2BCDB",
"q c #9AB6D7",
"r c #9EB9DA",
"s c #ABC4E0",
"t c #BAD0E7",
"u c #B9CFE7",
"v c #AEC8E3",
"w c #AAC5E2",
"x c #A8C4E1",
"y c #A6C2E0",
"z c #A9C4E1",
"A c #B3CBE6",
"B c #9DBADB",
"C c #4574AD",
"D c #3465A4",
"E c #89AAD1",
"F c #A5C2E0",
"G c #6E94C1",
"H c #BFD4EA",
"I c #93B1D4",
"J c #4E79B2",
"K c #3969A8",
"L c #3969A7",
"M c #3868A6",
"N c #3B6AA7",
"O c #5C84B8",
"P c #8CACD2",
"Q c #B3CCE5",
"R c #9EBDDE",
"S c #8FB3D8",
"T c #81A9D3",
"U c #8CB0D7",
"V c #9FBDDD",
"W c #96B5D8",
"X c #9CBCDD",
"Y c #A2C0DF",
"Z c #A5BFDC",
"` c #5D86B8",
" . c #3B6AA8",
".. c #3768A7",
"+. c #3A6AA9",
"@. c #3464A5",
"#. c #3969A5",
"$. c #6B90C0",
"%. c #98B7D9",
"&. c #98B9DC",
"*. c #84ABD5",
"=. c #7EA7D3",
"-. c #7BA5D2",
";. c #80A9D4",
">. c #97B8DB",
",. c #79A4D1",
"'. c #A3C0DF",
"). c #3C6AA9",
"!. c #6B91C0",
"~. c #4A77B3",
"{. c #4E7BB5",
"]. c #3667A5",
"^. c #7197C5",
"/. c #A0BEDE",
"(. c #8BAFD7",
"_. c #7AA5D2",
":. c #78A3D1",
"<. c #75A1D0",
"[. c #3364A5",
"}. c #5884BB",
"|. c #5D88BE",
"1. c #517EB8",
"2. c #3666A6",
"3. c #406EAA",
"4. c #9EBBDB",
"5. c #77A2D0",
"6. c #74A0CF",
"7. c #ABC6E2",
"8. c #4172AF",
"9. c #648DC3",
"0. c #678FC5",
"a. c #4D7AB4",
"b. c #3565A3",
"c. c #4472AC",
"d. c #A2BFDF",
"e. c #87ADD6",
"f. c #76A1D0",
"g. c #739FCF",
"h. c #76A2D0",
"i. c #5783BB",
"j. c #4571AC",
"k. c #9EBCDC",
"l. c #8BB0D7",
"m. c #74A1D0",
"n. c #729FCF",
"o. c #AFC9E4",
"p. c #3F6EAB",
"q. c #A3BEDD",
"r. c #A9C4E2",
"s. c #A9C5E1",
"t. c #AFC8E4",
"u. c #B2CAE4",
"v. c #3565A4",
"w. c #3666A5",
"x. c #CADBED",
"y. c #C9DAED",
"z. c #C7D9EC",
"A. c #C2D6EA",
"B. c #C0D4EA",
"C. c #C1D5EA",
"D. c #A0BCDB",
"E. c #3769A6",
"F. c #C8DAEC",
"G. c #9BBBDD",
"H. c #3C6CA8",
"I. c #B3CBE4",
"J. c #416EAA",
"K. c #C8D9EC",
"L. c #99BADC",
"M. c #BDD2E8",
"N. c #A9C2DF",
"O. c #416EA9",
"P. c #82A9D8",
"Q. c #3869A7",
"R. c #C6D8EC",
"S. c #98B9DB",
"T. c #A7C4E1",
"U. c #B2CBE4",
"V. c #7399C5",
"W. c #3668A6",
"X. c #87ADD9",
"Y. c #C4D6E9",
"Z. c #B1CAE2",
"`. c #3F70AD",
" + c #4577B4",
".+ c #3667A6",
"++ c #C4D7EB",
"@+ c #9DBCDE",
"#+ c #B5CDE6",
"$+ c #96B8DB",
"%+ c #95B7DB",
"&+ c #95B6DA",
"*+ c #85AAD2",
"=+ c #5682B9",
"-+ c #4982C6",
";+ c #B3CDE5",
">+ c #769CCC",
",+ c #3A6CAB",
"'+ c #4476B3",
")+ c #4D81BC",
"!+ c #A9C2DE",
"~+ c #B7CEE7",
"{+ c #9FBEDE",
"]+ c #6D9BCE",
"^+ c #6A99CC",
"/+ c #719ECF",
"(+ c #82A9D4",
"_+ c #80A7D3",
":+ c #618DC1",
"<+ c #4573AF",
"[+ c #3466A5",
"}+ c #3769A9",
"|+ c #386BAD",
"1+ c #376CAE",
"2+ c #3667A9",
"3+ c #4072B0",
"4+ c #5183BE",
"5+ c #588DC7",
"6+ c #3B6EAD",
"7+ c #94B3D7",
"8+ c #5882B7",
"9+ c #A1BEDC",
"0+ c #88AED7",
"a+ c #6E9CCD",
"b+ c #6999CC",
"c+ c #6797CB",
"d+ c #6696CB",
"e+ c #729ECF",
"f+ c #76A0D0",
"g+ c #6995C8",
"h+ c #5E8DC3",
"i+ c #5A8AC2",
"j+ c #5C8CC3",
"k+ c #5E90C9",
"l+ c #5B8FC7",
"m+ c #578CC7",
"n+ c #4A7EBC",
"o+ c #3566A5",
"p+ c #9FBCDA",
"q+ c #3768A5",
"r+ c #6990C1",
"s+ c #7CA5D2",
"t+ c #6A9ACC",
"u+ c #6596CB",
"v+ c #6395CA",
"w+ c #6294CA",
"x+ c #6093C9",
"y+ c #6093CA",
"z+ c #5D91C8",
"A+ c #5B8FC8",
"B+ c #588DC6",
"C+ c #588CC7",
"D+ c #4D82BE",
"E+ c #315F98",
"F+ c #3A69A6",
"G+ c #648EC0",
"H+ c #7EA5D2",
"I+ c #7AA4D2",
"J+ c #6F9DCE",
"K+ c #6193CA",
"L+ c #5F91C8",
"M+ c #5D90C8",
"N+ c #5C90C7",
"O+ c #5C90C8",
"P+ c #588EC6",
"Q+ c #477AB7",
"R+ c #3465A5",
"S+ c #2E578E",
"T+ c #3666A2",
"U+ c #4674AD",
"V+ c #5A88BE",
"W+ c #6592C6",
"X+ c #6B98CB",
"Y+ c #6B99CC",
"Z+ c #6797CC",
"`+ c #6090C7",
" @ c #5588C1",
".@ c #4679B6",
"+@ c #32609C",
"@@ c #1B3558",
"#@ c #2B5185",
"$@ c #325E9A",
"%@ c #3464A1",
"&@ c #3463A3",
"*@ c #3464A2",
"=@ c #32609B",
"-@ c #2A4F83",
" ",
" . + @ # $ % & * ",
" = - ; > , ' ) ! ~ { ] ^ / ( ",
" _ : < [ } | 1 2 2 3 4 | 5 6 7 8 % ( ",
" 9 0 a < ' } b c 3 d e f g f 4 d h i j k ( ",
" j l m n o p q r s t u 4 v w x y z A B C D E F ( ",
" G H I J K & L L M N O P Q c g R S T U V W X Y ( ",
" = Z ` ...+.@. L #.$.%.&.*.=.-.;.>.,.'.( ",
" ).!.K ~.{.]. @ ^./.(._.:.<.<.z [. ",
" .N }.|.1.2. 8 3.4.&.5.6.<.7.# ",
" ( 8.9.0.a.b. c.d.e.f.g.h.f # ",
" ( i. j.k.l.5.m.n.h.o.# ",
" ( p.q.w r.z s.w t.u.v. ",
" ( ( ( ( ( ( ( ( ( ( ( ",
" ( w.w.w.D ( ( ( ( ( ( ",
" ( x.x.y.z.A.B.C.D.E. ( ",
" ( F.G.&.&.&.v s H. ( ",
" ( F.G.&.&.w I.J. . ( ",
" ( K.G.&.L.M.N.O.^ P. Q.D ",
" ( R.G.&.&.S.T.U.V.W. X.Y.Z.`. +.+ ",
" ( ++@+#+G.$+%+%+&+*+=+]..+ -+;+>+,+'+)+* ",
" ( A.} !+~+{+*.]+^+/+(+_+:+<+[+}+|+1+|+2+3+4+5+6+ ",
" ( C.7+( 8+9+0+a+b+c+d+b+e+5.f+g+h+i+j+k+l+m+n+o+ ",
" ( p+M q+r+l.s+t+u+v+w+x+x+x+y+z+A+B+C+D+o+ ",
" D . E+F+G+H+I+J+c+K+L+M+N+O+l+P+Q+R+ ",
" ( S+T+U+V+W+X+Y+Z+`+ @.@$ +@ ",
" @@#@$@%@&@( *@=@-@ ",
" ",
" ",
" ",
" ",
" "};

401
samples/web/stop.xpm Normal file
View File

@@ -0,0 +1,401 @@
/* XPM */
static const char * stop_xpm[] = {
"32 32 366 2",
" c None",
". c #860000",
"+ c #890000",
"@ c #991414",
"# c #F38989",
"$ c #F79393",
"% c #F79292",
"& c #F79090",
"* c #F78F8F",
"= c #F68C8C",
"- c #F68A8A",
"; c #F58787",
"> c #A61F1F",
", c #8A0000",
"' c #991515",
") c #F18383",
"! c #E76565",
"~ c #D94040",
"{ c #D93F3F",
"] c #D83E3E",
"^ c #D83D3D",
"/ c #D83C3C",
"( c #D83B3B",
"_ c #E15252",
": c #F17C7C",
"< c #A51C1C",
"[ c #880000",
"} c #9B1616",
"| c #F18484",
"1 c #E76666",
"2 c #D94242",
"3 c #D94141",
"4 c #E05252",
"5 c #F07878",
"6 c #A41A1A",
"7 c #F28585",
"8 c #E66565",
"9 c #D94343",
"0 c #DA4444",
"a c #E15151",
"b c #EF7474",
"c c #A21818",
"d c #9D1818",
"e c #DA4545",
"f c #D83A3A",
"g c #E05050",
"h c #EE7070",
"i c #9F1616",
"j c #9E1818",
"k c #E56363",
"l c #DA4646",
"m c #DA4747",
"n c #D73A3A",
"o c #D63939",
"p c #DF4F4F",
"q c #EE6C6C",
"r c #9E1414",
"s c #A01919",
"t c #E56262",
"u c #E54B4B",
"v c #FA4F4F",
"w c #DD4848",
"x c #EB4444",
"y c #F64545",
"z c #D63A3A",
"A c #D53939",
"B c #D43838",
"C c #EC6868",
"D c #9D1212",
"E c #A01A1A",
"F c #E45F5F",
"G c #E54A4A",
"H c #F96161",
"I c #EFA9A9",
"J c #F75454",
"K c #DC4747",
"L c #EA4646",
"M c #F56B6B",
"N c #F08E8E",
"O c #F24747",
"P c #D43939",
"Q c #D33838",
"R c #D23737",
"S c #DD4C4C",
"T c #E96363",
"U c #9A0F0F",
"V c #F68E8E",
"W c #E45D5D",
"X c #E54848",
"Y c #F85F5F",
"Z c #E6DBDB",
"` c #E5E5E5",
" . c #EEB2B2",
".. c #F75252",
"+. c #DC4545",
"@. c #EB4848",
"#. c #F66C6C",
"$. c #E5E1E1",
"%. c #E4E4E4",
"&. c #EF9292",
"*. c #F24848",
"=. c #CF3535",
"-. c #DC4B4B",
";. c #ED6666",
">. c #FC4848",
",. c #EEAAAA",
"'. c #E6E6E6",
"). c #E7E7E7",
"!. c #EFB3B3",
"~. c #DC4343",
"{. c #EB4B4B",
"]. c #F67171",
"^. c #E8E4E4",
"/. c #E6D9D9",
"(. c #FF4848",
"_. c #DB3C3C",
":. c #D13838",
"<. c #D03636",
"[. c #CE3434",
"}. c #EF6B6B",
"|. c #F85353",
"1. c #EEB6B6",
"2. c #E8E8E8",
"3. c #E9E9E9",
"4. c #EAEAEA",
"5. c #F0B7B7",
"6. c #F75858",
"7. c #EC4E4E",
"8. c #F77777",
"9. c #EBE7E7",
"0. c #E9DDDD",
"a. c #F86565",
"b. c #DF4242",
"c. c #D03737",
"d. c #CF3636",
"e. c #CE3535",
"f. c #CD3333",
"g. c #EF6969",
"h. c #DB4343",
"i. c #F85A5A",
"j. c #F0BABA",
"k. c #EBEBEB",
"l. c #ECECEC",
"m. c #F2BABA",
"n. c #F97878",
"o. c #ECE9E9",
"p. c #ECE0E0",
"q. c #F96C6C",
"r. c #DF4646",
"s. c #D13939",
"t. c #D03838",
"u. c #CF3737",
"v. c #CD3434",
"w. c #CC3333",
"x. c #EE6767",
"y. c #F79191",
"z. c #DB4141",
"A. c #F86161",
"B. c #F2BFBF",
"C. c #EDEDED",
"D. c #EEEEEE",
"E. c #EEE3E3",
"F. c #F97272",
"G. c #DF4949",
"H. c #CE3636",
"I. c #CD3535",
"J. c #CC3434",
"K. c #CB3232",
"L. c #EE6565",
"M. c #F76868",
"N. c #F4C0C0",
"O. c #EFEFEF",
"P. c #F0F0F0",
"Q. c #F0E7E7",
"R. c #FA7979",
"S. c #DF4A4A",
"T. c #CC3131",
"U. c #CA2D2D",
"V. c #C82929",
"W. c #C72828",
"X. c #ED5F5F",
"Y. c #D73939",
"Z. c #ED5A5A",
"`. c #FA8686",
" + c #F1F1F1",
".+ c #F2F2F2",
"++ c #F5CFCF",
"@+ c #FD7171",
"#+ c #D33939",
"$+ c #CB2424",
"%+ c #C71616",
"&+ c #C40B0B",
"*+ c #C00202",
"=+ c #BF0000",
"-+ c #BE0000",
";+ c #BD0000",
">+ c #BC0000",
",+ c #E93D3D",
"'+ c #D73838",
")+ c #EA5B5B",
"!+ c #F99191",
"~+ c #F2EFEF",
"{+ c #F3F3F3",
"]+ c #F4F4F4",
"^+ c #F45353",
"/+ c #C60505",
"(+ c #C10000",
"_+ c #C00000",
":+ c #BA0000",
"<+ c #E93B3B",
"[+ c #F68D8D",
"}+ c #D73737",
"|+ c #EA5E5E",
"1+ c #F99595",
"2+ c #F3F0F0",
"3+ c #F5F5F5",
"4+ c #F6EEEE",
"5+ c #F7DDDD",
"6+ c #F3BFBF",
"7+ c #F45C5C",
"8+ c #C40606",
"9+ c #BB0000",
"0+ c #B90000",
"a+ c #E83939",
"b+ c #F68B8B",
"c+ c #D73535",
"d+ c #D73636",
"e+ c #F99A9A",
"f+ c #F7EFEF",
"g+ c #FA8181",
"h+ c #FD6767",
"i+ c #F8C7C7",
"j+ c #F3C3C3",
"k+ c #F36666",
"l+ c #C20707",
"m+ c #B80000",
"n+ c #E73838",
"o+ c #F68989",
"p+ c #D63434",
"q+ c #EB6363",
"r+ c #F89D9D",
"s+ c #F1EFEF",
"t+ c #F7EEEE",
"u+ c #F97F7F",
"v+ c #D62424",
"w+ c #C80707",
"x+ c #F56C6C",
"y+ c #F9CCCC",
"z+ c #F2C6C6",
"A+ c #F47272",
"B+ c #BF0707",
"C+ c #B70000",
"D+ c #E73636",
"E+ c #F48686",
"F+ c #E14E4E",
"G+ c #D63333",
"H+ c #F78383",
"I+ c #F5BCBC",
"J+ c #F5ECEC",
"K+ c #F98484",
"L+ c #D62727",
"M+ c #C40000",
"N+ c #C30000",
"O+ c #C60808",
"P+ c #F57676",
"Q+ c #F8CFCF",
"R+ c #F0DFDF",
"S+ c #FE8A8A",
"T+ c #C41515",
"U+ c #B80202",
"V+ c #E63434",
"W+ c #A82323",
"X+ c #F07A7A",
"Y+ c #E04C4C",
"Z+ c #D63232",
"`+ c #D53333",
" @ c #D53535",
".@ c #F27E7E",
"+@ c #F5BBBB",
"@@ c #F1E9E9",
"#@ c #F98B8B",
"$@ c #D62A2A",
"%@ c #C20000",
"&@ c #C40909",
"*@ c #F48080",
"=@ c #F6D2D2",
"-@ c #F3E4E4",
";@ c #C61B1B",
">@ c #D92626",
",@ c #CD2020",
"'@ c #8B0000",
")@ c #A72222",
"!@ c #EF6E6E",
"~@ c #DE3C3C",
"{@ c #D11B1B",
"]@ c #CE1313",
"^@ c #CA0707",
"/@ c #C90303",
"(@ c #FF8F8F",
"_@ c #D62D2D",
":@ c #C10A0A",
"<@ c #F58B8B",
"[@ c #FD9898",
"}@ c #C61C1C",
"|@ c #B90303",
"1@ c #DB2828",
"2@ c #CA1F1F",
"3@ c #890101",
"4@ c #A01313",
"5@ c #EC5555",
"6@ c #D61F1F",
"7@ c #C90000",
"8@ c #C80000",
"9@ c #C70000",
"0@ c #C70303",
"a@ c #CD1616",
"b@ c #BF0909",
"c@ c #C11010",
"d@ c #B90404",
"e@ c #DC2929",
"f@ c #C71E1E",
"g@ c #A01111",
"h@ c #EA5252",
"i@ c #D51E1E",
"j@ c #C60000",
"k@ c #C50000",
"l@ c #BA0404",
"m@ c #DC2A2A",
"n@ c #C31C1C",
"o@ c #9E1010",
"p@ c #EA4E4E",
"q@ c #D51D1D",
"r@ c #BB0505",
"s@ c #DE2B2B",
"t@ c #BF1A1A",
"u@ c #840000",
"v@ c #9E0F0F",
"w@ c #E94A4A",
"x@ c #D31C1C",
"y@ c #BC0606",
"z@ c #DF2D2D",
"A@ c #BA1818",
"B@ c #870000",
"C@ c #790000",
"D@ c #9C0D0D",
"E@ c #E84646",
"F@ c #D01B1B",
"G@ c #BC0707",
"H@ c #E02E2E",
"I@ c #B61717",
"J@ c #810000",
"K@ c #730000",
"L@ c #9A0C0C",
"M@ c #EC4949",
"N@ c #EB4747",
"O@ c #EB4545",
"P@ c #E94343",
"Q@ c #E94141",
"R@ c #E93F3F",
"S@ c #E73939",
"T@ c #E73737",
"U@ c #E63535",
"V@ c #B31515",
"W@ c #7D0000",
"X@ c #720000",
"Y@ c #7C0000",
" . . . . . . . . . . . . + ",
" @ # $ $ $ $ $ % & * = - ; > , ",
" ' ) ! ~ ~ ~ ~ { { ] ^ / ( _ : < [ ",
" } | 1 2 2 2 2 3 3 ~ { ] ^ / ( 4 5 6 [ ",
" } 7 8 9 9 0 0 9 9 2 3 ~ { ] ^ / ( a b c ",
" d 7 8 0 0 e e e e 0 9 2 3 ~ { ] / ( f g h i ",
" j 7 k 0 e l m m m l e 0 9 2 3 { ] ^ / n o p q r ",
" s 7 t 9 0 e m u v w m l e 9 2 3 ~ x y / z A B p C D ",
" E 7 F 2 9 0 e G H I J K l e 9 2 3 L M N O z P Q R S T U ",
" . V W ~ 3 2 0 X Y Z ` ...+.0 9 2 @.#.$.%.&.*.P Q R =.-.;.. ",
" . % ] { 3 2 9 >.,.` '.).!...~.2 {.].^.).'./.(._.:.<.=.[.}.. ",
" . % ] { ~ 3 2 ~.|.1.2.3.4.5.6.7.8.9.3.2.0.a.b.:.c.d.e.f.g.. ",
" . % ^ ] { ~ ~ 3 h.i.j.4.k.l.m.n.o.k.k.p.q.r.s.t.u.e.v.w.x.. ",
" . y./ ^ ] ] { ~ ~ z.A.B.C.D.D.D.D.D.E.F.G.s.t.u.H.I.J.K.L.. ",
" . y.( ( / ^ ] ] { { z.M.N.O.P.P.P.Q.R.S.s.t.u.H.T.U.V.W.X.. ",
" . & Y.f ( / / ^ ^ ^ ^ Z.`. +.+.+.+++@+#+$+%+&+*+=+-+;+>+,+. ",
" . * '+Y.f f ( ( ( / )+!+~+{+{+]+]+{+N.^+/+(+_+=+-+;+>+:+<+. ",
" . [+}+}+'+Y.Y.Y.f |+1+2+{+3+4+5+]+.+ +6+7+8+=+-+;+9+:+0+a+. ",
" . b+c+d+}+}+'+'+|+e+~+{+3+f+g+h+i+3+{+ +j+k+l+;+9+:+0+m+n+. ",
" . o+p+c+c+d+d+q+r+s+.+3+t+u+v+w+x+y+3+{+P.z+A+B+:+0+m+C+D+. ",
" . E+F+G+p+p+p+H+I+ +{+J+K+L+M+N+O+P+Q+]+ +R+S+T+0+m+C+U+V+. ",
" [ W+X+Y+Z+Z+`+ @.@+@@@#@$@M+N+%@(+&@*@=@-@& ;@0+m+C+U+>@,@. ",
" '@)@!@~@{@]@^@/@!@(@_@M+N+%@(+_+-+:@<@[@}@0+m+C+|@1@2@3@ ",
" + 4@5@6@7@8@9@0@a@M+N+%@(+=+-+;+>+b@c@0+m+C+d@e@f@+ ",
" + g@h@i@9@j@k@M+N+%@(+=+-+;+>+9+:+0+m+C+l@m@n@, ",
" , o@p@q@k@M+N+%@_+=+-+;+>+9+:+0+m+C+r@s@t@+ ",
" u@v@w@x@N+%@_+=+-+;+>+9+:+0+m+C+y@z@A@B@ ",
" C@D@E@F@_+=+-+;+>+9+:+0+m+C+G@H@I@J@ ",
" K@L@{.M@N@O@P@Q@R@,+<+S@T@U@V@W@ ",
" X@. . . . . . . . . . . . Y@ ",
" ",
" "};

19
samples/web/web.bkl Normal file
View File

@@ -0,0 +1,19 @@
<?xml version="1.0" ?>
<!-- $Id: widgets.bkl 59311 2009-03-04 11:47:32Z FM $ -->
<makefile>
<include file="../../build/bakefiles/common_samples.bkl"/>
<exe id="web" template="wx_sample" template_append="wx_append">
<sources>
web.cpp
</sources>
<headers></headers>
<wx-lib>core</wx-lib>
<wx-lib>base</wx-lib>
<wx-lib>web</wx-lib>
<wx-lib>stc</wx-lib>
<win32-res>../sample.rc</win32-res>
</exe>
</makefile>

640
samples/web/web.cpp Normal file
View File

@@ -0,0 +1,640 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wxiepanel.cpp
// Purpose: wxBetterHTMLControl test
// Author: Marianne Gagnon
// Id: $Id$
// Copyright: (c) 2010 Marianne Gagnon
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include <wx/wx.h>
#include <wx/artprov.h>
#include <wx/notifmsg.h>
#include <wx/settings.h>
#if wxUSE_STC
#include <wx/stc/stc.h>
#else
#error "wxStyledTextControl is needed by this sample"
#endif
#include "wx/webview.h"
#include "wxlogo.xpm"
#include "back.xpm"
#include "forward.xpm"
#include "stop.xpm"
#include "refresh.xpm"
// --------------------------------------------------------------------------------------------------
// SOURCE VIEW FRAME
// --------------------------------------------------------------------------------------------------
enum
{
MARGIN_LINE_NUMBERS,
//MARGIN_DIVIDER,
//MARGIN_FOLDING
};
class SourceViewDialog : public wxDialog
{
public:
void onClose(wxCloseEvent& evt)
{
EndModal( GetReturnCode() );
}
SourceViewDialog(wxWindow* parent, wxString source) :
wxDialog(parent, wxID_ANY, "Source Code",
wxDefaultPosition, wxSize(700,500),
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
wxStyledTextCtrl* text = new wxStyledTextCtrl(this, wxID_ANY);
//text->SetLexer(wxSTC_LEX_HTML);
text->SetMarginWidth (MARGIN_LINE_NUMBERS, 50);
text->StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour (75, 75, 75) );
text->StyleSetBackground (wxSTC_STYLE_LINENUMBER, wxColour (220, 220, 220));
text->SetMarginType (MARGIN_LINE_NUMBERS, wxSTC_MARGIN_NUMBER);
text->SetWrapMode (wxSTC_WRAP_WORD);
text->SetText(source);
text->StyleClearAll();
text->SetLexer(wxSTC_LEX_HTML);
text->StyleSetForeground (wxSTC_H_DOUBLESTRING, wxColour(255,0,0));
text->StyleSetForeground (wxSTC_H_SINGLESTRING, wxColour(255,0,0));
text->StyleSetForeground (wxSTC_H_ENTITY, wxColour(255,0,0));
text->StyleSetForeground (wxSTC_H_TAG, wxColour(0,150,0));
text->StyleSetForeground (wxSTC_H_TAGUNKNOWN, wxColour(0,150,0));
text->StyleSetForeground (wxSTC_H_ATTRIBUTE, wxColour(0,0,150));
text->StyleSetForeground (wxSTC_H_ATTRIBUTEUNKNOWN, wxColour(0,0,150));
text->StyleSetForeground (wxSTC_H_COMMENT, wxColour(150,150,150));
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(text, 1, wxEXPAND);
SetSizer(sizer);
Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(SourceViewDialog::onClose), NULL, this);
}
};
// --------------------------------------------------------------------------------------------------
// MAIN BROWSER CLASS
// --------------------------------------------------------------------------------------------------
class wxMiniApp : public wxApp
{
wxTextCtrl* url;
wxWebView* m_browser_ctrl;
wxFrame* frame;
wxToolBarToolBase* back;
wxToolBarToolBase* forward;
wxToolBarToolBase* stop;
wxToolBarToolBase* reload;
wxToolBarToolBase* tools;
wxMenu* toolsMenu;
wxMenuItem* tinySize;
wxMenuItem* smallSize;
wxMenuItem* mediumSize;
wxMenuItem* largeSize;
wxMenuItem* largestSize;
//wxMenuItem* offlineMode;
//wxMenuItem* onlineMode;
wxLogWindow* logging;
wxToolBar* m_toolbar;
wxTimer* m_timer;
int m_animation_angle;
wxPanel* m_notification_panel;
wxStaticText* m_notification_text;
public:
// function called at the application initialization
virtual bool OnInit();
/**
* Implement timer to display the loading animation (OK, I admit this is totally irrelevant to
* the HTML control being demonstrated here, but it's fun ;)
*/
void onAnimationTimer(wxTimerEvent& evt)
{
m_animation_angle += 15;
if (m_animation_angle > 360) m_animation_angle -= 360;
wxBitmap image(32, 32);
{
wxMemoryDC dc;
dc.SelectObject(image);
dc.SetBackground(wxBrush(wxColour(255,0,255)));
dc.Clear();
if (m_animation_angle >= 0 && m_animation_angle <= 180)
{
dc.SetBrush(*wxYELLOW_BRUSH);
dc.SetPen(*wxYELLOW_PEN);
dc.DrawCircle(16 - int(sin(m_animation_angle*0.01745f /* convert to radians */)*14.0f),
16 + int(cos(m_animation_angle*0.01745f /* convert to radians */)*14.0f), 3 );
}
dc.DrawBitmap(wxBitmap(wxlogo_xpm), 0, 0, true);
if (m_animation_angle > 180)
{
dc.SetBrush(*wxYELLOW_BRUSH);
dc.SetPen(*wxYELLOW_PEN);
dc.DrawCircle(16 - int(sin(m_animation_angle*0.01745f /* convert to radians */)*14.0f),
16 + int(cos(m_animation_angle*0.01745f /* convert to radians */)*14.0f), 3 );
}
}
image.SetMask(new wxMask(image, wxColour(255,0,255)));
m_toolbar->SetToolNormalBitmap(tools->GetId(), image);
}
/**
* Method that retrieves the current state from the web control and updates the GUI
* the reflect this current state.
*/
void updateState()
{
m_toolbar->EnableTool( back->GetId(), m_browser_ctrl->CanGoBack() );
m_toolbar->EnableTool( forward->GetId(), m_browser_ctrl->CanGoForward() );
if (m_browser_ctrl->IsBusy())
{
//tools->SetLabel(_("Loading..."));
if (m_timer == NULL)
{
m_timer = new wxTimer(this);
this->Connect(wxEVT_TIMER, wxTimerEventHandler(wxMiniApp::onAnimationTimer), NULL, this);
}
m_timer->Start(100); // start animation timer
m_toolbar->EnableTool( stop->GetId(), true );
}
else
{
if (m_timer != NULL) m_timer->Stop(); // stop animation timer
//tools->SetLabel(_("Tools"));
m_toolbar->SetToolNormalBitmap(tools->GetId(), wxBitmap(wxlogo_xpm));
m_toolbar->EnableTool( stop->GetId(), false );
}
frame->SetTitle( m_browser_ctrl->GetCurrentTitle() );
url->SetValue( m_browser_ctrl->GetCurrentURL() );
}
/**
* Callback invoked when user entered an URL and pressed enter
*/
void onUrl(wxCommandEvent& evt)
{
if (m_notification_panel->IsShown())
{
m_notification_panel->Hide();
frame->Layout();
}
m_browser_ctrl->LoadUrl( url->GetValue() );
updateState();
}
/**
* Callback invoked when user pressed the "back" button
*/
void onBack(wxCommandEvent& evt)
{
// First, hide notification panel if it was shown
if (m_notification_panel->IsShown())
{
m_notification_panel->Hide();
frame->Layout();
}
m_browser_ctrl->GoBack();
updateState();
}
/**
* Callback invoked when user pressed the "forward" button
*/
void onForward(wxCommandEvent& evt)
{
// First, hide notification panel if it was shown
if (m_notification_panel->IsShown())
{
m_notification_panel->Hide();
frame->Layout();
}
m_browser_ctrl->GoForward();
updateState();
}
/**
* Callback invoked when user pressed the "stop" button
*/
void onStop(wxCommandEvent& evt)
{
m_browser_ctrl->Stop();
updateState();
}
/**
* Callback invoked when user pressed the "reload" button
*/
void onReload(wxCommandEvent& evt)
{
// First, hide notification panel if it was shown
if (m_notification_panel->IsShown())
{
m_notification_panel->Hide();
frame->Layout();
}
m_browser_ctrl->Reload();
updateState();
}
/**
* Callback invoked when there is a request to load a new page (for instance
* when the user clicks a link)
*/
void onNavigationRequest(wxWebNavigationEvent& evt)
{
// First, hide notification panel if it was shown
if (m_notification_panel->IsShown())
{
m_notification_panel->Hide();
frame->Layout();
}
wxLogMessage("Navigation request to '" + evt.GetHref() + "' (target='" +
evt.GetTarget() + "')");
wxASSERT(m_browser_ctrl->IsBusy());
// Uncomment this to see how to block navigation requests
//int answer = wxMessageBox("Proceed with navigation to '" + evt.GetHref() + "'?",
// "Proceed with navigation?", wxYES_NO );
//if (answer != wxYES)
//{
// evt.Veto();
//}
updateState();
}
/**
* Callback invoked when a navigation request was accepted
*/
void onNavigationComplete(wxWebNavigationEvent& evt)
{
wxLogMessage("Navigation complete; url='" + evt.GetHref() + "'");
updateState();
}
/**
* Callback invoked when a page is finished loading
*/
void onDocumentLoaded(wxWebNavigationEvent& evt)
{
wxLogMessage("Document loaded; url='" + evt.GetHref() + "'");
updateState();
m_browser_ctrl->GetZoom();
}
/**
* Invoked when user selects the "View Source" menu item
*/
void onViewSourceRequest(wxCommandEvent& evt)
{
SourceViewDialog dlg(frame, m_browser_ctrl->GetPageSource());
dlg.Center();
dlg.ShowModal();
}
/**
* Invoked when user selects the "Menu" item
*/
void onToolsClicked(wxCommandEvent& evt)
{
tinySize->Check(false);
smallSize->Check(false);
mediumSize->Check(false);
largeSize->Check(false);
largestSize->Check(false);
wxWebViewZoom zoom = m_browser_ctrl->GetZoom();
switch (zoom)
{
case wxWEB_VIEW_ZOOM_TINY:
tinySize->Check();
break;
case wxWEB_VIEW_ZOOM_SMALL:
smallSize->Check();
break;
case wxWEB_VIEW_ZOOM_MEDIUM:
mediumSize->Check();
break;
case wxWEB_VIEW_ZOOM_LARGE:
largeSize->Check();
break;
case wxWEB_VIEW_ZOOM_LARGEST:
largestSize->Check();
break;
}
// bool IsOfflineMode();
// void SetOfflineMode(bool offline);
//offlineMode->Check(false);
//onlineMode->Check(false);
//const bool offline = m_browser_ctrl->IsOfflineMode();
//if (offline) offlineMode->Check();
//else onlineMode->Check();
wxPoint position = frame->ScreenToClient( wxGetMousePosition() );
frame->PopupMenu(toolsMenu, position.x, position.y);
}
/**
* Invoked when user selects the zoom size in the menu
*/
void onSetZoom(wxCommandEvent& evt)
{
if (evt.GetId() == tinySize->GetId())
{
m_browser_ctrl->SetZoom(wxWEB_VIEW_ZOOM_TINY);
}
else if (evt.GetId() == smallSize->GetId())
{
m_browser_ctrl->SetZoom(wxWEB_VIEW_ZOOM_SMALL);
}
else if (evt.GetId() == mediumSize->GetId())
{
m_browser_ctrl->SetZoom(wxWEB_VIEW_ZOOM_MEDIUM);
}
else if (evt.GetId() == largeSize->GetId())
{
m_browser_ctrl->SetZoom(wxWEB_VIEW_ZOOM_LARGE);
}
else if (evt.GetId() == largestSize->GetId())
{
m_browser_ctrl->SetZoom(wxWEB_VIEW_ZOOM_LARGEST);
}
else
{
wxASSERT(false);
}
}
/*
void onChangeOnlineMode(wxCommandEvent& evt)
{
if (evt.GetId() == offlineMode->GetId())
{
m_browser_ctrl->SetOfflineMode(true);
m_browser_ctrl->SetPage("<html><body><h1>You are now in offline mode.</h1></body></html>");
}
else if (evt.GetId() == onlineMode->GetId())
{
m_browser_ctrl->SetOfflineMode(false);
}
else
{
wxASSERT(false);
}
}
*/
/**
* Callback invoked when a loading error occurs
*/
void onError(wxWebNavigationEvent& evt)
{
wxString errorCategory;
switch (evt.GetInt())
{
case wxWEB_NAV_ERR_CONNECTION:
errorCategory = "wxWEB_NAV_ERR_CONNECTION";
break;
case wxWEB_NAV_ERR_CERTIFICATE:
errorCategory = "wxWEB_NAV_ERR_CERTIFICATE";
break;
case wxWEB_NAV_ERR_AUTH:
errorCategory = "wxWEB_NAV_ERR_AUTH";
break;
case wxWEB_NAV_ERR_SECURITY:
errorCategory = "wxWEB_NAV_ERR_SECURITY";
break;
case wxWEB_NAV_ERR_NOT_FOUND:
errorCategory = "wxWEB_NAV_ERR_NOT_FOUND";
break;
case wxWEB_NAV_ERR_REQUEST:
errorCategory = "wxWEB_NAV_ERR_REQUEST";
break;
case wxWEB_NAV_ERR_USER_CANCELLED:
errorCategory = "wxWEB_NAV_ERR_USER_CANCELLED";
break;
case wxWEB_NAV_ERR_OTHER:
errorCategory = "wxWEB_NAV_ERR_OTHER";
break;
}
wxLogMessage("Error; url='" + evt.GetHref() + "', error='" + errorCategory + "' (" + evt.GetString() + ")");
// show the notification panel
m_notification_text->SetLabel(_("An error occurred loading ") + evt.GetHref() + "\n" +
"'" + errorCategory + "' (" + evt.GetString() + ")");
m_notification_panel->Layout();
m_notification_panel->GetSizer()->SetSizeHints(m_notification_panel);
m_notification_panel->Show();
frame->Layout();
updateState();
}
/**
* Invoked when user clicks "Hide" in the notification panel
*/
void onHideNotifBar(wxCommandEvent& evt)
{
m_notification_panel->Hide();
frame->Layout();
}
void onClose(wxCloseEvent& evt)
{
frame->Destroy();
}
void onQuitMenu(wxCommandEvent& evt)
{
frame->Destroy();
}
/**
* Invoked when user selects "Print" from the menu
*/
void onPrint(wxCommandEvent& evt)
{
m_browser_ctrl->Print();
}
};
IMPLEMENT_APP(wxMiniApp);
bool wxMiniApp::OnInit()
{
m_timer = NULL;
m_animation_angle = 0;
frame = new wxFrame( NULL, -1, _("wxBetterHTMLControl Browser Example"), wxDefaultPosition, wxSize(800, 600) );
// wx has a default mechanism to expand the only control of a frame; but since this mechanism
// does not involve sizers, invoking ->Layout on the frame does not udpate the layout which is
// not good.
wxBoxSizer* expandSizer = new wxBoxSizer(wxHORIZONTAL);
wxPanel* mainpane = new wxPanel(frame, wxID_ANY);
expandSizer->Add(mainpane, 1, wxEXPAND);
frame->SetSizer(expandSizer);
wxLog::SetLogLevel(wxLOG_Max);
logging = new wxLogWindow(frame, _("Logging"));
wxLog::SetLogLevel(wxLOG_Max);
// ---- Create the Tools menu
toolsMenu = new wxMenu();
wxMenuItem* print = toolsMenu->Append(wxID_ANY , _("Print"));
wxMenuItem* viewSource = toolsMenu->Append(wxID_ANY , _("View Source"));
toolsMenu->AppendSeparator();
tinySize = toolsMenu->AppendCheckItem(wxID_ANY, _("Tiny"));
smallSize = toolsMenu->AppendCheckItem(wxID_ANY, _("Small"));
mediumSize = toolsMenu->AppendCheckItem(wxID_ANY, _("Medium"));
largeSize = toolsMenu->AppendCheckItem(wxID_ANY, _("Large"));
largestSize = toolsMenu->AppendCheckItem(wxID_ANY, _("Largest"));
//toolsMenu->AppendSeparator();
//offlineMode = toolsMenu->AppendCheckItem(wxID_ANY, _("Offline Mode"));
//onlineMode = toolsMenu->AppendCheckItem(wxID_ANY, _("Online Mode"));
// ---- Create the Toolbar
m_toolbar = frame->CreateToolBar(/*wxNO_BORDER |*/ wxTB_TEXT);
m_toolbar->SetToolBitmapSize(wxSize(32, 32));
back = m_toolbar->AddTool(wxID_ANY, _("Back"), wxBitmap(back_xpm));
forward = m_toolbar->AddTool(wxID_ANY, _("Forward"), wxBitmap(forward_xpm));
stop = m_toolbar->AddTool(wxID_ANY, _("Stop"), wxBitmap(stop_xpm));
reload = m_toolbar->AddTool(wxID_ANY, _("Reload"), wxBitmap(refresh_xpm));
url = new wxTextCtrl(m_toolbar, wxID_ANY, wxT("http://www.google.com"),
wxDefaultPosition, wxSize(400, -1), wxTE_PROCESS_ENTER );
m_toolbar->AddControl(url, _("URL"));
tools = m_toolbar->AddTool(wxID_ANY, _("Menu"), wxBitmap(wxlogo_xpm));
//m_toolbar->SetDropdownMenu(tools->GetId(), toolsMenu);
m_toolbar->Realize();
m_toolbar->Connect(back->GetId(), wxEVT_COMMAND_TOOL_CLICKED,
wxCommandEventHandler(wxMiniApp::onBack), NULL, this );
m_toolbar->Connect(forward->GetId(), wxEVT_COMMAND_TOOL_CLICKED,
wxCommandEventHandler(wxMiniApp::onForward), NULL, this );
m_toolbar->Connect(stop->GetId(), wxEVT_COMMAND_TOOL_CLICKED,
wxCommandEventHandler(wxMiniApp::onStop), NULL, this );
m_toolbar->Connect(reload->GetId(), wxEVT_COMMAND_TOOL_CLICKED,
wxCommandEventHandler(wxMiniApp::onReload), NULL, this );
m_toolbar->Connect(tools->GetId(), wxEVT_COMMAND_TOOL_CLICKED,
wxCommandEventHandler(wxMiniApp::onToolsClicked), NULL, this );
url->Connect(url->GetId(), wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(wxMiniApp::onUrl), NULL, this );
frame->Connect(viewSource->GetId(), wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(wxMiniApp::onViewSourceRequest), NULL, this );
frame->Connect(print->GetId(), wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(wxMiniApp::onPrint), NULL, this );
frame->Connect(tinySize->GetId(), wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(wxMiniApp::onSetZoom), NULL, this );
frame->Connect(smallSize->GetId(), wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(wxMiniApp::onSetZoom), NULL, this );
frame->Connect(mediumSize->GetId(), wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(wxMiniApp::onSetZoom), NULL, this );
frame->Connect(largeSize->GetId(), wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(wxMiniApp::onSetZoom), NULL, this );
frame->Connect(largestSize->GetId(), wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(wxMiniApp::onSetZoom), NULL, this );
// ---- Create the web view
m_browser_ctrl = wxWebView::GetNew(mainpane, wxID_ANY);
// ---- Create the notification panel
{
wxBoxSizer* notification_sizer = new wxBoxSizer(wxHORIZONTAL);
m_notification_panel = new wxPanel(mainpane, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE);
m_notification_text = new wxStaticText(m_notification_panel, wxID_ANY, "[No message]");
notification_sizer->Add( new wxStaticBitmap(m_notification_panel, wxID_ANY,
wxArtProvider::GetBitmap(wxART_WARNING, wxART_OTHER , wxSize(48, 48))),
0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
notification_sizer->Add(m_notification_text, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 5);
wxButton* hideNotif = new wxButton(m_notification_panel, wxID_ANY, _("Hide"));
notification_sizer->Add(hideNotif, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
m_notification_panel->SetSizer(notification_sizer);
m_notification_panel->SetBackgroundColour(wxColor(255,225,110));
m_notification_panel->Hide();
hideNotif->Connect(hideNotif->GetId(), wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler(wxMiniApp::onHideNotifBar), NULL, this);
}
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(m_notification_panel, 0, wxEXPAND | wxALL, 5);
sizer->Add(m_browser_ctrl, 1, wxEXPAND | wxALL, 5);
mainpane->SetSizer(sizer);
frame->Layout();
frame->Center();
frame->Show();
m_browser_ctrl->Connect(m_browser_ctrl->GetId(), wxEVT_COMMAND_WEB_VIEW_NAVIGATING,
wxWebNavigationEventHandler(wxMiniApp::onNavigationRequest), NULL, this);
m_browser_ctrl->Connect(m_browser_ctrl->GetId(), wxEVT_COMMAND_WEB_VIEW_NAVIGATED,
wxWebNavigationEventHandler(wxMiniApp::onNavigationComplete), NULL, this);
m_browser_ctrl->Connect(m_browser_ctrl->GetId(), wxEVT_COMMAND_WEB_VIEW_LOADED,
wxWebNavigationEventHandler(wxMiniApp::onDocumentLoaded), NULL, this);
m_browser_ctrl->Connect(m_browser_ctrl->GetId(), wxEVT_COMMAND_WEB_VIEW_ERROR,
wxWebNavigationEventHandler(wxMiniApp::onError), NULL, this);
frame->Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(wxMiniApp::onClose), NULL, this);
Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(wxMiniApp::onQuitMenu), NULL, this);
// You can test different zoom types (if supported by the backend)
// if (m_browser_ctrl->CanSetZoomType(wxWEB_VIEW_ZOOM_TYPE_LAYOUT))
// m_browser_ctrl->SetZoomType(wxWEB_VIEW_ZOOM_TYPE_LAYOUT);
SetTopWindow(frame);
frame->Layout();
return true;
}

44
samples/web/wxlogo.xpm Normal file
View File

@@ -0,0 +1,44 @@
/* XPM */
static const char *const wxlogo_xpm[] = {
/* columns rows colors chars-per-pixel */
"32 32 6 1",
" c black",
". c navy",
"X c red",
"o c yellow",
"O c gray100",
"+ c None",
/* pixels */
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++ ++++++++++",
"++++++++ ............ ++++++++++",
"++++++++ ............ ++++++++++",
"++++++++ .OO......... ++++++++++",
"++++++++ .OO......... ++++++++++",
"++++++++ .OO......... ++++++++++",
"++++++++ .OO...... ",
"++++++++ .OO...... oooooooooooo ",
" .OO...... oooooooooooo ",
" XXXXXXX .OO...... oOOooooooooo ",
" XXXXXXX .OO...... oOOooooooooo ",
" XOOXXXX ......... oOOooooooooo ",
" XOOXXXX ......... oOOooooooooo ",
" XOOXXXX oOOooooooooo ",
" XOOXXXXXXXXX ++++ oOOooooooooo ",
" XOOXXXXXXXXX ++++ oOOooooooooo ",
" XOOXXXXXXXXX ++++ oOOooooooooo ",
" XOOXXXXXXXXX ++++ oooooooooooo ",
" XOOXXXXXXXXX ++++ oooooooooooo ",
" XXXXXXXXXXXX ++++ ",
" XXXXXXXXXXXX ++++++++++++++++++",
" ++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++"
};

113
src/common/webview.cpp Normal file
View File

@@ -0,0 +1,113 @@
/////////////////////////////////////////////////////////////////////////////
// Name: webview.cpp
// Purpose: Common interface and events for web view component
// Author: Marianne Gagnon
// Id: $Id$
// Copyright: (c) 2010 Marianne Gagnon
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/webview.h"
#include "wx/osx/webkit.h"
#include "wx/gtk/webkit.h"
#include "wx/msw/webkitie.h"
extern WXDLLEXPORT_DATA(const char) wxWebViewNameStr[] = "wxWebView";
extern WXDLLEXPORT_DATA(const char) wxWebViewDefaultURLStr[] = "about:blank";
IMPLEMENT_DYNAMIC_CLASS(wxWebNavigationEvent, wxCommandEvent)
wxDEFINE_EVENT( wxEVT_COMMAND_WEB_VIEW_NAVIGATING, wxWebNavigationEvent );
wxDEFINE_EVENT( wxEVT_COMMAND_WEB_VIEW_NAVIGATED, wxWebNavigationEvent );
wxDEFINE_EVENT( wxEVT_COMMAND_WEB_VIEW_LOADED, wxWebNavigationEvent );
wxDEFINE_EVENT( wxEVT_COMMAND_WEB_VIEW_ERROR, wxWebNavigationEvent );
// static
wxWebView* wxWebView::New(wxWebViewBackend backend)
{
switch (backend)
{
#if wxHAVE_WEB_BACKEND_OSX_WEBKIT
case wxWEB_VIEW_BACKEND_OSX_WEBKIT:
return new wxOSXWebKitCtrl();
#endif
#if wxHAVE_WEB_BACKEND_GTK_WEBKIT
case wxWEB_VIEW_BACKEND_GTK_WEBKIT:
return new wxGtkWebKitCtrl();
#endif
#if wxHAVE_WEB_BACKEND_IE
case wxWEB_VIEW_BACKEND_IE:
return new wxIEPanel();
#endif
case wxWEB_VIEW_BACKEND_DEFAULT:
#if wxHAVE_WEB_BACKEND_OSX_WEBKIT
return new wxOSXWebKitCtrl();
#endif
#if wxHAVE_WEB_BACKEND_GTK_WEBKIT
return new wxGtkWebKitCtrl();
#endif
#if wxHAVE_WEB_BACKEND_IE
return new wxIEPanel();
#endif
// fall-through intended
default:
return NULL;
}
}
// static
wxWebView* wxWebView::New(wxWindow* parent,
wxWindowID id,
const wxString& url,
const wxPoint& pos,
const wxSize& size,
wxWebViewBackend backend,
long style,
const wxString& name)
{
switch (backend)
{
#if wxHAVE_WEB_BACKEND_OSX_WEBKIT
case wxWEB_VIEW_BACKEND_OSX_WEBKIT:
return new wxOSXWebKitCtrl(parent, id, url, pos, size, style,
name);
#endif
#if wxHAVE_WEB_BACKEND_GTK_WEBKIT
case wxWEB_VIEW_BACKEND_GTK_WEBKIT:
return new wxGtkWebKitCtrl(parent, id, url, pos, size, style,
name);
#endif
#if wxHAVE_WEB_BACKEND_IE
case wxWEB_VIEW_BACKEND_IE:
return new wxIEPanel(parent, id, url, pos, size, style, name);
#endif
case wxWEB_VIEW_BACKEND_DEFAULT:
#if wxHAVE_WEB_BACKEND_OSX_WEBKIT
return new wxOSXWebKitCtrl(parent, id, url, pos, size, style, name);
#endif
#if wxHAVE_WEB_BACKEND_GTK_WEBKIT
return new wxGtkWebKitCtrl(parent, id, url, pos, size, style, name);
#endif
#if wxHAVE_WEB_BACKEND_IE
return new wxIEPanel(parent, id, url, pos, size, style, name);
#endif
// fall-through intended
default:
return NULL;
}
}

560
src/gtk/webview.cpp Normal file
View File

@@ -0,0 +1,560 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/gtk/webview.cpp
// Purpose: GTK WebKit backend for web view component
// Author: Marianne Gagnon, Robert Roebling
// Id: $Id$
// Copyright: (c) 2010 Marianne Gagnon, 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#if wxHAVE_WEB_BACKEND_GTK_WEBKIT
#include "wx/stockitem.h"
#include "wx/gtk/webview.h"
#include "wx/gtk/control.h"
#include "wx/gtk/private.h"
#include "webkit/webkit.h"
// ----------------------------------------------------------------------------
// GTK callbacks
// ----------------------------------------------------------------------------
extern "C"
{
static void
wxgtk_webkitctrl_load_status_callback(GtkWidget* widget, GParamSpec* arg1,
wxWebViewGTKWebKit *webKitCtrl)
{
if (!webKitCtrl->m_ready) return;
wxString url = webKitCtrl->GetCurrentURL();
WebKitLoadStatus status;
g_object_get(G_OBJECT(widget), "load-status", &status, NULL);
wxString target; // TODO: get target (if possible)
if (status == WEBKIT_LOAD_FINISHED)
{
webKitCtrl->m_busy = false;
wxWebNavigationEvent thisEvent(wxEVT_COMMAND_WEB_VIEW_LOADED,
webKitCtrl->GetId(),
url, target, false);
if (webKitCtrl && webKitCtrl->GetEventHandler())
webKitCtrl->GetEventHandler()->ProcessEvent(thisEvent);
}
else if (status == WEBKIT_LOAD_COMMITTED)
{
webKitCtrl->m_busy = true;
wxWebNavigationEvent thisEvent(wxEVT_COMMAND_WEB_VIEW_NAVIGATED,
webKitCtrl->GetId(),
url, target, false);
if (webKitCtrl && webKitCtrl->GetEventHandler())
webKitCtrl->GetEventHandler()->ProcessEvent(thisEvent);
}
}
static WebKitNavigationResponse
wxgtk_webkitctrl_navigation_requ_callback(WebKitWebView *web_view,
WebKitWebFrame *frame,
WebKitNetworkRequest *request,
wxWebViewGTKWebKit *webKitCtrl)
{
webKitCtrl->m_busy = true;
const gchar* uri = webkit_network_request_get_uri(request);
wxString target = webkit_web_frame_get_name (frame);
wxWebNavigationEvent thisEvent(wxEVT_COMMAND_WEB_VIEW_NAVIGATING,
webKitCtrl->GetId(),
wxString( uri, wxConvUTF8 ),
target,
true);
if (webKitCtrl && webKitCtrl->GetEventHandler())
webKitCtrl->GetEventHandler()->ProcessEvent(thisEvent);
if (thisEvent.IsVetoed())
{
webKitCtrl->m_busy = false;
return WEBKIT_NAVIGATION_RESPONSE_IGNORE;
}
else
{
return WEBKIT_NAVIGATION_RESPONSE_ACCEPT;
}
}
static gboolean
wxgtk_webkitctrl_error (WebKitWebView *web_view,
WebKitWebFrame *web_frame,
gchar *uri,
gpointer web_error,
wxWebViewGTKWebKit* webKitWindow)
{
webKitWindow->m_busy = false;
wxWebNavigationError type = wxWEB_NAV_ERR_OTHER;
GError* error = (GError*)web_error;
wxString description(error->message, wxConvUTF8);
if (strcmp(g_quark_to_string(error->domain), "soup_http_error_quark") == 0)
{
switch (error->code)
{
case SOUP_STATUS_CANCELLED:
type = wxWEB_NAV_ERR_USER_CANCELLED;
break;
case SOUP_STATUS_CANT_RESOLVE:
case SOUP_STATUS_NOT_FOUND:
type = wxWEB_NAV_ERR_NOT_FOUND;
break;
case SOUP_STATUS_CANT_RESOLVE_PROXY:
case SOUP_STATUS_CANT_CONNECT:
case SOUP_STATUS_CANT_CONNECT_PROXY:
case SOUP_STATUS_SSL_FAILED:
case SOUP_STATUS_IO_ERROR:
type = wxWEB_NAV_ERR_CONNECTION;
break;
case SOUP_STATUS_MALFORMED:
//case SOUP_STATUS_TOO_MANY_REDIRECTS:
type = wxWEB_NAV_ERR_REQUEST;
break;
//case SOUP_STATUS_NO_CONTENT:
//case SOUP_STATUS_RESET_CONTENT:
case SOUP_STATUS_BAD_REQUEST:
type = wxWEB_NAV_ERR_REQUEST;
break;
case SOUP_STATUS_UNAUTHORIZED:
case SOUP_STATUS_FORBIDDEN:
type = wxWEB_NAV_ERR_AUTH;
break;
case SOUP_STATUS_METHOD_NOT_ALLOWED:
case SOUP_STATUS_NOT_ACCEPTABLE:
type = wxWEB_NAV_ERR_SECURITY;
break;
case SOUP_STATUS_PROXY_AUTHENTICATION_REQUIRED:
type = wxWEB_NAV_ERR_AUTH;
break;
case SOUP_STATUS_REQUEST_TIMEOUT:
type = wxWEB_NAV_ERR_CONNECTION;
break;
//case SOUP_STATUS_PAYMENT_REQUIRED:
case SOUP_STATUS_REQUEST_ENTITY_TOO_LARGE:
case SOUP_STATUS_REQUEST_URI_TOO_LONG:
case SOUP_STATUS_UNSUPPORTED_MEDIA_TYPE:
type = wxWEB_NAV_ERR_REQUEST;
break;
case SOUP_STATUS_BAD_GATEWAY:
case SOUP_STATUS_SERVICE_UNAVAILABLE:
case SOUP_STATUS_GATEWAY_TIMEOUT:
type = wxWEB_NAV_ERR_CONNECTION;
break;
case SOUP_STATUS_HTTP_VERSION_NOT_SUPPORTED:
type = wxWEB_NAV_ERR_REQUEST;
break;
//case SOUP_STATUS_INSUFFICIENT_STORAGE:
//case SOUP_STATUS_NOT_EXTENDED:
}
}
else if (strcmp(g_quark_to_string(error->domain),
"webkit-network-error-quark") == 0)
{
switch (error->code)
{
//WEBKIT_NETWORK_ERROR_FAILED:
//WEBKIT_NETWORK_ERROR_TRANSPORT:
case WEBKIT_NETWORK_ERROR_UNKNOWN_PROTOCOL:
type = wxWEB_NAV_ERR_REQUEST;
break;
case WEBKIT_NETWORK_ERROR_CANCELLED:
type = wxWEB_NAV_ERR_USER_CANCELLED;
break;
case WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST:
type = wxWEB_NAV_ERR_NOT_FOUND;
break;
}
}
else if (strcmp(g_quark_to_string(error->domain),
"webkit-policy-error-quark") == 0)
{
switch (error->code)
{
//case WEBKIT_POLICY_ERROR_FAILED:
//case WEBKIT_POLICY_ERROR_CANNOT_SHOW_MIME_TYPE:
//case WEBKIT_POLICY_ERROR_CANNOT_SHOW_URL:
//case WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE:
case WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT:
type = wxWEB_NAV_ERR_SECURITY;
break;
}
}
/*
webkit_plugin_error_quark
else
{
printf("Error domain %s\n", g_quark_to_string(error->domain));
}
*/
wxWebNavigationEvent thisEvent(wxEVT_COMMAND_WEB_VIEW_ERROR,
webKitWindow->GetId(),
uri,
wxEmptyString,
false);
thisEvent.SetString(description);
thisEvent.SetInt(type);
if (webKitWindow && webKitWindow->GetEventHandler())
{
webKitWindow->GetEventHandler()->ProcessEvent(thisEvent);
}
return FALSE;
}
} // extern "C"
//-----------------------------------------------------------------------------
// wxWebViewGTKWebKit
//-----------------------------------------------------------------------------
//IMPLEMENT_DYNAMIC_CLASS(wxWebViewGTKWebKit, wxControl)
bool wxWebViewGTKWebKit::Create(wxWindow *parent,
wxWindowID id,
const wxString &url,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
m_ready = false;
m_busy = false;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
{
wxFAIL_MSG( wxT("wxWebViewGTKWebKit creation failed") );
return false;
}
GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL);
web_view = webkit_web_view_new ();
g_object_ref(web_view); // TODO: check memory management
m_widget = scrolled_window;
g_object_ref(m_widget); // TODO: check memory management
/* Place the WebKitWebView in the GtkScrolledWindow */
gtk_container_add (GTK_CONTAINER (scrolled_window), web_view);
gtk_widget_show(m_widget);
gtk_widget_show(web_view);
g_signal_connect_after(web_view, "notify::load-status",
G_CALLBACK(wxgtk_webkitctrl_load_status_callback),
this);
g_signal_connect_after(web_view, "navigation-requested",
G_CALLBACK(wxgtk_webkitctrl_navigation_requ_callback),
this);
g_signal_connect_after(web_view, "load-error",
G_CALLBACK(wxgtk_webkitctrl_error),
this);
// this signal can be added if we care about new frames open requests
//g_signal_connect_after(web_view, "new-window-policy-decision-requested",
// G_CALLBACK(...), this);
m_parent->DoAddChild( this );
PostCreation(size);
/* Open a webpage */
webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), url);
m_ready = true;
return true;
}
bool wxWebViewGTKWebKit::Enable( bool enable )
{
if (!wxControl::Enable(enable))
return false;
gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable);
//if (enable)
// GTKFixSensitivity();
return true;
}
GdkWindow*
wxWebViewGTKWebKit::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{
GdkWindow* window = gtk_widget_get_parent_window(m_widget);
return window;
}
void wxWebViewGTKWebKit::ZoomIn()
{
webkit_web_view_zoom_in (WEBKIT_WEB_VIEW(web_view));
}
void wxWebViewGTKWebKit::ZoomOut()
{
webkit_web_view_zoom_out (WEBKIT_WEB_VIEW(web_view));
}
void wxWebViewGTKWebKit::SetWebkitZoom(float level)
{
webkit_web_view_set_zoom_level (WEBKIT_WEB_VIEW(web_view), level);
}
float wxWebViewGTKWebKit::GetWebkitZoom()
{
return webkit_web_view_get_zoom_level (WEBKIT_WEB_VIEW(web_view));
}
void wxWebViewGTKWebKit::Stop()
{
webkit_web_view_stop_loading (WEBKIT_WEB_VIEW(web_view));
}
void wxWebViewGTKWebKit::Reload(wxWebViewReloadFlags flags)
{
if (flags & wxWEB_VIEW_RELOAD_NO_CACHE)
{
webkit_web_view_reload_bypass_cache (WEBKIT_WEB_VIEW(web_view));
}
else
{
webkit_web_view_reload (WEBKIT_WEB_VIEW(web_view));
}
}
void wxWebViewGTKWebKit::LoadUrl(const wxString& url)
{
webkit_web_view_open(WEBKIT_WEB_VIEW(web_view), wxGTK_CONV(loc));
}
void wxWebViewGTKWebKit::GoBack()
{
webkit_web_view_go_back (WEBKIT_WEB_VIEW(web_view));
}
void wxWebViewGTKWebKit::GoForward()
{
webkit_web_view_go_forward (WEBKIT_WEB_VIEW(web_view));
}
bool wxWebViewGTKWebKit::CanGoBack()
{
return webkit_web_view_can_go_back (WEBKIT_WEB_VIEW(web_view));
}
bool wxWebViewGTKWebKit::CanGoForward()
{
return webkit_web_view_can_go_forward (WEBKIT_WEB_VIEW(web_view));
}
wxString wxWebViewGTKWebKit::GetCurrentURL()
{
// FIXME: check which encoding the web kit control uses instead of
// assuming UTF8 (here and elsewhere too)
return wxString::FromUTF8(webkit_web_view_get_uri(
WEBKIT_WEB_VIEW(web_view)));
}
wxString wxWebViewGTKWebKit::GetCurrentTitle()
{
return wxString::FromUTF8(webkit_web_view_get_title(
WEBKIT_WEB_VIEW(web_view)));
}
wxString wxWebViewGTKWebKit::GetPageSource()
{
WebKitWebFrame* frame = webkit_web_view_get_main_frame(
WEBKIT_WEB_VIEW(web_view));
WebKitWebDataSource* src = webkit_web_frame_get_data_source (frame);
// TODO: check encoding with
// const gchar*
// webkit_web_data_source_get_encoding(WebKitWebDataSource *data_source);
return wxString(webkit_web_data_source_get_data (src)->str, wxConvUTF8);
}
wxWebViewZoom wxWebViewGTKWebKit::GetZoom()
{
float zoom = GetWebkitZoom();
// arbitrary way to map float zoom to our common zoom enum
if (zoom <= 0.65)
{
return wxWEB_VIEW_ZOOM_TINY;
}
else if (zoom > 0.65 && zoom <= 0.90)
{
return wxWEB_VIEW_ZOOM_SMALL;
}
else if (zoom > 0.90 && zoom <= 1.15)
{
return wxWEB_VIEW_ZOOM_MEDIUM;
}
else if (zoom > 1.15 && zoom <= 1.45)
{
return wxWEB_VIEW_ZOOM_LARGE;
}
else if (zoom > 1.45)
{
return wxWEB_VIEW_ZOOM_LARGEST;
}
// to shut up compilers, this can never be reached logically
wxASSERT(false);
return wxWEB_VIEW_ZOOM_MEDIUM;
}
void wxWebViewGTKWebKit::SetZoom(wxWebViewZoom zoom)
{
// arbitrary way to map our common zoom enum to float zoom
switch (zoom)
{
case wxWEB_VIEW_ZOOM_TINY:
SetWebkitZoom(0.6f);
break;
case wxWEB_VIEW_ZOOM_SMALL:
SetWebkitZoom(0.8f);
break;
case wxWEB_VIEW_ZOOM_MEDIUM:
SetWebkitZoom(1.0f);
break;
case wxWEB_VIEW_ZOOM_LARGE:
SetWebkitZoom(1.3);
break;
case wxWEB_VIEW_ZOOM_LARGEST:
SetWebkitZoom(1.6);
break;
default:
wxASSERT(false);
}
}
void wxWebViewGTKWebKit::SetZoomType(wxWebViewZoomType type)
{
webkit_web_view_set_full_content_zoom(WEBKIT_WEB_VIEW(web_view),
(type == wxWEB_VIEW_ZOOM_TYPE_LAYOUT ?
TRUE : FALSE));
}
wxWebViewZoomType wxWebViewGTKWebKit::GetZoomType() const
{
gboolean fczoom = webkit_web_view_get_full_content_zoom(
WEBKIT_WEB_VIEW(web_view));
if (fczoom) return wxWEB_VIEW_ZOOM_TYPE_LAYOUT;
else return wxWEB_VIEW_ZOOM_TYPE_TEXT;
}
bool wxWebViewGTKWebKit::CanSetZoomType(wxWebViewZoomType) const
{
// this port supports all zoom types
return true;
}
void wxWebViewGTKWebKit::SetPage(const wxString& html, const wxString& baseUri)
{
webkit_web_view_load_string (WEBKIT_WEB_VIEW(web_view),
html.mb_str(wxConvUTF8),
"text/html",
"UTF-8",
baseUri.mb_str(wxConvUTF8));
}
void wxWebViewGTKWebKit::Print()
{
WebKitWebFrame* frame = webkit_web_view_get_main_frame(
WEBKIT_WEB_VIEW(web_view));
webkit_web_frame_print (frame);
// GtkPrintOperationResult webkit_web_frame_print_full
// (WebKitWebFrame *frame,
// GtkPrintOperation *operation,
// GtkPrintOperationAction action,
// GError **error);
}
bool wxWebViewGTKWebKit::IsBusy()
{
return m_busy;
// This code looks nice but returns true after a page was cancelled
/*
WebKitLoadStatus status = webkit_web_view_get_load_status
(WEBKIT_WEB_VIEW(web_view));
#if WEBKIT_CHECK_VERSION(1,1,16)
// WEBKIT_LOAD_FAILED is new in webkit 1.1.16
if (status == WEBKIT_LOAD_FAILED)
{
return false;
}
#endif
if (status == WEBKIT_LOAD_FINISHED)
{
return false;
}
return true;
*/
}
// static
wxVisualAttributes
wxWebViewGTKWebKit::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
{
return GetDefaultAttributesFromGTKWidget(webkit_web_view_new);
}
#endif // wxHAVE_WEB_BACKEND_GTK_WEBKIT

667
src/msw/webviewie.cpp Normal file
View File

@@ -0,0 +1,667 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/msw/webviewie.cpp
// Purpose: wxMSW wxWebViewIE class implementation for web view component
// Author: Marianne Gagnon
// Id: $Id$
// Copyright: (c) 2010 Marianne Gagnon
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/msw/webview.h"
#if wxHAVE_WEB_BACKEND_IE
#include <olectl.h>
#include <oleidl.h>
#include <exdispid.h>
#include <exdisp.h>
#include <mshtml.h>
// FIXME: Seems like MINGW does not have these, how to handle cleanly?
#define DISPID_COMMANDSTATECHANGE 105
typedef enum CommandStateChangeConstants {
CSC_UPDATECOMMANDS = (int) 0xFFFFFFFF,
CSC_NAVIGATEFORWARD = 0x1,
CSC_NAVIGATEBACK = 0x2
} CommandStateChangeConstants;
// FIXME: Seems like MINGW does not have these, how to handle cleanly?
#define DISPID_NAVIGATECOMPLETE2 252
#define DISPID_NAVIGATEERROR 271
#define OLECMDID_OPTICAL_ZOOM 63
#define INET_E_ERROR_FIRST 0x800C0002L
#define INET_E_INVALID_URL 0x800C0002L
#define INET_E_NO_SESSION 0x800C0003L
#define INET_E_CANNOT_CONNECT 0x800C0004L
#define INET_E_RESOURCE_NOT_FOUND 0x800C0005L
#define INET_E_OBJECT_NOT_FOUND 0x800C0006L
#define INET_E_DATA_NOT_AVAILABLE 0x800C0007L
#define INET_E_DOWNLOAD_FAILURE 0x800C0008L
#define INET_E_AUTHENTICATION_REQUIRED 0x800C0009L
#define INET_E_NO_VALID_MEDIA 0x800C000AL
#define INET_E_CONNECTION_TIMEOUT 0x800C000BL
#define INET_E_INVALID_REQUEST 0x800C000CL
#define INET_E_UNKNOWN_PROTOCOL 0x800C000DL
#define INET_E_SECURITY_PROBLEM 0x800C000EL
#define INET_E_CANNOT_LOAD_DATA 0x800C000FL
#define INET_E_CANNOT_INSTANTIATE_OBJECT 0x800C0010L
#define INET_E_QUERYOPTION_UNKNOWN 0x800C0013L
#define INET_E_REDIRECT_FAILED 0x800C0014L
#define INET_E_REDIRECT_TO_DIR 0x800C0015L
#define INET_E_CANNOT_LOCK_REQUEST 0x800C0016L
#define INET_E_USE_EXTEND_BINDING 0x800C0017L
#define INET_E_TERMINATED_BIND 0x800C0018L
#define INET_E_INVALID_CERTIFICATE 0x800C0019L
#define INET_E_CODE_DOWNLOAD_DECLINED 0x800C0100L
#define INET_E_RESULT_DISPATCHED 0x800C0200L
#define INET_E_CANNOT_REPLACE_SFP_FILE 0x800C0300L
#define INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY 0x800C0500L
#define INET_E_CODE_INSTALL_SUPPRESSED 0x800C0400L
#define REFRESH_COMPLETELY 3
BEGIN_EVENT_TABLE(wxWebViewIE, wxControl)
EVT_ACTIVEX(wxID_ANY, wxWebViewIE::onActiveXEvent)
EVT_ERASE_BACKGROUND(wxWebViewIE::onEraseBg)
END_EVENT_TABLE()
bool wxWebViewIE::Create(wxWindow* parent,
wxWindowID id,
const wxString& url,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
if (!wxControl::Create(parent, id, pos, size, style,
wxDefaultValidator, name))
{
return false;
}
m_webBrowser = NULL;
m_canNavigateBack = false;
m_canNavigateForward = false;
m_isBusy = false;
if (::CoCreateInstance(CLSID_WebBrowser, NULL,
CLSCTX_INPROC_SERVER, // CLSCTX_INPROC,
IID_IWebBrowser2 , (void**)&m_webBrowser) != 0)
{
wxLogError("Failed to initialize IE, CoCreateInstance returned an error");
return false;
}
m_ie.SetDispatchPtr(m_webBrowser); // wxAutomationObject will release itself
m_webBrowser->put_RegisterAsBrowser(VARIANT_TRUE);
m_webBrowser->put_RegisterAsDropTarget(VARIANT_TRUE);
//m_webBrowser->put_Silent(VARIANT_FALSE);
m_container = new wxActiveXContainer(this, IID_IWebBrowser2, m_webBrowser);
SetBackgroundStyle(wxBG_STYLE_PAINT);
SetDoubleBuffered(true);
return true;
}
void wxWebViewIE::LoadUrl(const wxString& url)
{
wxVariant out = m_ie.CallMethod("Navigate", (BSTR) url.wc_str(),
NULL, NULL, NULL, NULL);
// FIXME: why is out value null??
//(HRESULT)(out.GetLong()) == S_OK;
}
void wxWebViewIE::SetPage(const wxString& html, const wxString& baseUrl)
{
LoadUrl("about:blank");
// Let the wx events generated for navigation events be processed, so
// that the underlying IE component completes its Document object.
// FIXME: calling wxYield is not elegant nor very reliable probably
wxYield();
wxVariant documentVariant = m_ie.GetProperty("Document");
void* documentPtr = documentVariant.GetVoidPtr();
wxASSERT (documentPtr != NULL);
// TODO: consider the "baseUrl" parameter if possible
// TODO: consider encoding
BSTR bstr = SysAllocString(html.wc_str());
// Creates a new one-dimensional array
SAFEARRAY *psaStrings = SafeArrayCreateVector(VT_VARIANT, 0, 1);
if (psaStrings != NULL)
{
VARIANT *param;
HRESULT hr = SafeArrayAccessData(psaStrings, (LPVOID*)&param);
param->vt = VT_BSTR;
param->bstrVal = bstr;
hr = SafeArrayUnaccessData(psaStrings);
IHTMLDocument2* document = (IHTMLDocument2*)documentPtr;
document->write(psaStrings);
// SafeArrayDestroy calls SysFreeString for each BSTR
SafeArrayDestroy(psaStrings);
}
else
{
wxLogError("wxWebViewIE::SetPage() : psaStrings is NULL");
}
}
wxString wxWebViewIE::GetPageSource()
{
wxVariant documentVariant = m_ie.GetProperty("Document");
void* documentPtr = documentVariant.GetVoidPtr();
if (documentPtr == NULL)
{
return wxEmptyString;
}
IHTMLDocument2* document = (IHTMLDocument2*)documentPtr;
IHTMLElement *bodyTag = NULL;
IHTMLElement *htmlTag = NULL;
document->get_body(&bodyTag);
wxASSERT(bodyTag != NULL);
document->Release();
bodyTag->get_parentElement(&htmlTag);
wxASSERT(htmlTag != NULL);
BSTR bstr;
htmlTag->get_outerHTML(&bstr);
bodyTag->Release();
htmlTag->Release();
//wxMessageBox(wxString(bstr));
// TODO: check encoding
return wxString(bstr);
}
// FIXME? retrieve OLECMDID_GETZOOMRANGE instead of hardcoding range 0-4
wxWebViewZoom wxWebViewIE::GetZoom()
{
const int zoom = GetIETextZoom();
switch (zoom)
{
case 0:
return wxWEB_VIEW_ZOOM_TINY;
break;
case 1:
return wxWEB_VIEW_ZOOM_SMALL;
break;
case 2:
return wxWEB_VIEW_ZOOM_MEDIUM;
break;
case 3:
return wxWEB_VIEW_ZOOM_LARGE;
break;
case 4:
return wxWEB_VIEW_ZOOM_LARGEST;
break;
default:
wxASSERT(false);
return wxWEB_VIEW_ZOOM_MEDIUM;
}
}
void wxWebViewIE::SetZoom(wxWebViewZoom zoom)
{
// I know I could cast from enum to int since wxWebViewZoom happens to
// match with IE's zoom levels, but I don't like doing that, what if enum
// values change...
switch (zoom)
{
case wxWEB_VIEW_ZOOM_TINY:
SetIETextZoom(0);
break;
case wxWEB_VIEW_ZOOM_SMALL:
SetIETextZoom(1);
break;
case wxWEB_VIEW_ZOOM_MEDIUM:
SetIETextZoom(2);
break;
case wxWEB_VIEW_ZOOM_LARGE:
SetIETextZoom(3);
break;
case wxWEB_VIEW_ZOOM_LARGEST:
SetIETextZoom(4);
break;
default:
wxASSERT(false);
}
}
void wxWebViewIE::SetIETextZoom(int level)
{
VARIANT zoomVariant;
VariantInit (&zoomVariant);
V_VT(&zoomVariant) = VT_I4;
V_I4(&zoomVariant) = level;
HRESULT result = m_webBrowser->ExecWB(OLECMDID_ZOOM,
OLECMDEXECOPT_DONTPROMPTUSER,
&zoomVariant, NULL);
wxASSERT (result == S_OK);
VariantClear (&zoomVariant);
}
int wxWebViewIE::GetIETextZoom()
{
VARIANT zoomVariant;
VariantInit (&zoomVariant);
V_VT(&zoomVariant) = VT_I4;
V_I4(&zoomVariant) = 4;
HRESULT result = m_webBrowser->ExecWB(OLECMDID_ZOOM,
OLECMDEXECOPT_DONTPROMPTUSER,
NULL, &zoomVariant);
wxASSERT (result == S_OK);
int zoom = V_I4(&zoomVariant);
// wxMessageBox(wxString::Format("Zoom : %i", zoom));
VariantClear (&zoomVariant);
return zoom;
}
void wxWebViewIE::SetIEOpticalZoom(float zoom)
{
// TODO: add support for optical zoom (IE7+ only)
// TODO: get range from OLECMDID_OPTICAL_GETZOOMRANGE instead of hardcoding?
wxASSERT(zoom >= 10.0f);
wxASSERT(zoom <= 1000.0f);
VARIANT zoomVariant;
VariantInit (&zoomVariant);
V_VT(&zoomVariant) = VT_I4;
V_I4(&zoomVariant) = (zoom * 100.0f);
HRESULT result = m_webBrowser->ExecWB((OLECMDID)OLECMDID_OPTICAL_ZOOM,
OLECMDEXECOPT_DODEFAULT,
&zoomVariant,
NULL);
wxASSERT (result == S_OK);
}
float wxWebViewIE::GetIEOpticalZoom()
{
// TODO: add support for optical zoom (IE7+ only)
VARIANT zoomVariant;
VariantInit (&zoomVariant);
V_VT(&zoomVariant) = VT_I4;
V_I4(&zoomVariant) = -1;
HRESULT result = m_webBrowser->ExecWB((OLECMDID)OLECMDID_OPTICAL_ZOOM,
OLECMDEXECOPT_DODEFAULT, NULL,
&zoomVariant);
wxASSERT (result == S_OK);
const int zoom = V_I4(&zoomVariant);
VariantClear (&zoomVariant);
return zoom / 100.0f;
}
void wxWebViewIE::SetZoomType(wxWebViewZoomType)
{
// TODO: add support for optical zoom (IE7+ only)
wxASSERT(false);
}
wxWebViewZoomType wxWebViewIE::GetZoomType() const
{
// TODO: add support for optical zoom (IE7+ only)
return wxWEB_VIEW_ZOOM_TYPE_TEXT;
}
bool wxWebViewIE::CanSetZoomType(wxWebViewZoomType) const
{
// both are supported
// TODO: IE6 only supports text zoom, check if it's IE6 first
return true;
}
void wxWebViewIE::Print()
{
m_webBrowser->ExecWB(OLECMDID_PRINTPREVIEW,
OLECMDEXECOPT_DODEFAULT, NULL, NULL);
}
void wxWebViewIE::GoBack()
{
wxVariant out = m_ie.CallMethod("GoBack");
// FIXME: why is out value null??
//return (HRESULT)(out.GetLong()) == S_OK;
}
void wxWebViewIE::GoForward()
{
wxVariant out = m_ie.CallMethod("GoForward");
// FIXME: why is out value null??
//return (HRESULT)(out.GetLong()) == S_OK;
}
void wxWebViewIE::Stop()
{
wxVariant out = m_ie.CallMethod("Stop");
// FIXME: why is out value null??
//return (HRESULT)(out.GetLong()) == S_OK;
}
void wxWebViewIE::Reload(wxWebViewReloadFlags flags)
{
wxVariant out;
if (flags & wxWEB_VIEW_RELOAD_NO_CACHE)
{
VARIANTARG level;
level.vt = VT_I2;
level.iVal = 3;
out = m_ie.CallMethod("Refresh2", &level);
}
else
{
out = m_ie.CallMethod("Refresh");
}
if (out.GetType() != "null")
{
wxMessageBox("Non-null return message : " + out.GetType());
}
}
bool wxWebViewIE::IsOfflineMode()
{
wxVariant out = m_ie.GetProperty("Offline");
wxASSERT(out.GetType() == "bool");
return out.GetBool();
}
void wxWebViewIE::SetOfflineMode(bool offline)
{
// FIXME: the wxWidgets docs do not really document what the return
// parameter of PutProperty is
const bool success = m_ie.PutProperty("Offline", (offline ?
VARIANT_TRUE :
VARIANT_FALSE));
wxASSERT(success);
}
bool wxWebViewIE::IsBusy()
{
if (m_isBusy) return true;
wxVariant out = m_ie.GetProperty("Busy");
wxASSERT(out.GetType() == "bool");
return out.GetBool();
}
wxString wxWebViewIE::GetCurrentURL()
{
wxVariant out = m_ie.GetProperty("LocationURL");
wxASSERT(out.GetType() == "string");
return out.GetString();
}
wxString wxWebViewIE::GetCurrentTitle()
{
wxVariant out = m_ie.GetProperty("LocationName");
wxASSERT(out.GetType() == "string");
return out.GetString();
}
void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
{
if (m_webBrowser == NULL) return;
switch (evt.GetDispatchId())
{
case DISPID_BEFORENAVIGATE2:
{
m_isBusy = true;
wxString url = evt[1].GetString();
wxString target = evt[3].GetString();
wxWebNavigationEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATING,
GetId(), url, target, true);
event.SetEventObject(this);
HandleWindowEvent(event);
if (event.IsVetoed())
{
wxActiveXEventNativeMSW* nativeParams =
evt.GetNativeParameters();
*V_BOOLREF(&nativeParams->pDispParams->rgvarg[0]) = VARIANT_TRUE;
}
// at this point, either the navigation event has been cancelled
// and we're not busy, either it was accepted and IWebBrowser2's
// Busy property will be true; so we don't need our override
// flag anymore.
m_isBusy = false;
break;
}
case DISPID_NAVIGATECOMPLETE2:
{
wxString url = evt[1].GetString();
// TODO: set target parameter if possible
wxString target = wxEmptyString;
wxWebNavigationEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATED,
GetId(), url, target, false);
event.SetEventObject(this);
HandleWindowEvent(event);
break;
}
case DISPID_PROGRESSCHANGE:
{
// download progress
break;
}
case DISPID_DOCUMENTCOMPLETE:
{
wxString url = evt[1].GetString();
// TODO: set target parameter if possible
wxString target = wxEmptyString;
wxWebNavigationEvent event(wxEVT_COMMAND_WEB_VIEW_LOADED, GetId(),
url, target, false);
event.SetEventObject(this);
HandleWindowEvent(event);
break;
}
case DISPID_STATUSTEXTCHANGE:
{
break;
}
case DISPID_TITLECHANGE:
{
break;
}
case DISPID_NAVIGATEERROR:
{
wxWebNavigationError errorType = wxWEB_NAV_ERR_OTHER;
wxString errorCode = "?";
switch (evt[3].GetLong())
{
case INET_E_INVALID_URL: // (0x800C0002L or -2146697214)
errorCode = "INET_E_INVALID_URL";
errorType = wxWEB_NAV_ERR_REQUEST;
break;
case INET_E_NO_SESSION: // (0x800C0003L or -2146697213)
errorCode = "INET_E_NO_SESSION";
errorType = wxWEB_NAV_ERR_CONNECTION;
break;
case INET_E_CANNOT_CONNECT: // (0x800C0004L or -2146697212)
errorCode = "INET_E_CANNOT_CONNECT";
errorType = wxWEB_NAV_ERR_CONNECTION;
break;
case INET_E_RESOURCE_NOT_FOUND: // (0x800C0005L or -2146697211)
errorCode = "INET_E_RESOURCE_NOT_FOUND";
errorType = wxWEB_NAV_ERR_NOT_FOUND;
break;
case INET_E_OBJECT_NOT_FOUND: // (0x800C0006L or -2146697210)
errorCode = "INET_E_OBJECT_NOT_FOUND";
errorType = wxWEB_NAV_ERR_NOT_FOUND;
break;
case INET_E_DATA_NOT_AVAILABLE: // (0x800C0007L or -2146697209)
errorCode = "INET_E_DATA_NOT_AVAILABLE";
errorType = wxWEB_NAV_ERR_NOT_FOUND;
break;
case INET_E_DOWNLOAD_FAILURE: // (0x800C0008L or -2146697208)
errorCode = "INET_E_DOWNLOAD_FAILURE";
errorType = wxWEB_NAV_ERR_CONNECTION;
break;
case INET_E_AUTHENTICATION_REQUIRED: // (0x800C0009L or -2146697207)
errorCode = "INET_E_AUTHENTICATION_REQUIRED";
errorType = wxWEB_NAV_ERR_AUTH;
break;
case INET_E_NO_VALID_MEDIA: // (0x800C000AL or -2146697206)
errorCode = "INET_E_NO_VALID_MEDIA";
errorType = wxWEB_NAV_ERR_REQUEST;
break;
case INET_E_CONNECTION_TIMEOUT: // (0x800C000BL or -2146697205)
errorCode = "INET_E_CONNECTION_TIMEOUT";
errorType = wxWEB_NAV_ERR_CONNECTION;
break;
case INET_E_INVALID_REQUEST: // (0x800C000CL or -2146697204)
errorCode = "INET_E_INVALID_REQUEST";
errorType = wxWEB_NAV_ERR_REQUEST;
break;
case INET_E_UNKNOWN_PROTOCOL: // (0x800C000DL or -2146697203)
errorCode = "INET_E_UNKNOWN_PROTOCOL";
errorType = wxWEB_NAV_ERR_REQUEST;
break;
case INET_E_SECURITY_PROBLEM: // (0x800C000EL or -2146697202)
errorCode = "INET_E_SECURITY_PROBLEM";
errorType = wxWEB_NAV_ERR_SECURITY;
break;
case INET_E_CANNOT_LOAD_DATA: // (0x800C000FL or -2146697201)
errorCode = "INET_E_CANNOT_LOAD_DATA";
errorType = wxWEB_NAV_ERR_OTHER;
break;
case INET_E_CANNOT_INSTANTIATE_OBJECT:
// CoCreateInstance will return an error code if this happens,
// we'll handle this above.
return;
break;
case INET_E_REDIRECT_FAILED: // (0x800C0014L or -2146697196)
errorCode = "INET_E_REDIRECT_FAILED";
errorType = wxWEB_NAV_ERR_OTHER;
break;
case INET_E_REDIRECT_TO_DIR: // (0x800C0015L or -2146697195)
errorCode = "INET_E_REDIRECT_TO_DIR";
errorType = wxWEB_NAV_ERR_REQUEST;
break;
case INET_E_CANNOT_LOCK_REQUEST: // (0x800C0016L or -2146697194)
errorCode = "INET_E_CANNOT_LOCK_REQUEST";
errorType = wxWEB_NAV_ERR_OTHER;
break;
case INET_E_USE_EXTEND_BINDING: // (0x800C0017L or -2146697193)
errorCode = "INET_E_USE_EXTEND_BINDING";
errorType = wxWEB_NAV_ERR_OTHER;
break;
case INET_E_TERMINATED_BIND: // (0x800C0018L or -2146697192)
errorCode = "INET_E_TERMINATED_BIND";
errorType = wxWEB_NAV_ERR_OTHER;
break;
case INET_E_INVALID_CERTIFICATE: // (0x800C0019L or -2146697191)
errorCode = "INET_E_INVALID_CERTIFICATE";
errorType = wxWEB_NAV_ERR_CERTIFICATE;
break;
case INET_E_CODE_DOWNLOAD_DECLINED: // (0x800C0100L or -2146696960)
errorCode = "INET_E_CODE_DOWNLOAD_DECLINED";
errorType = wxWEB_NAV_ERR_USER_CANCELLED;
break;
case INET_E_RESULT_DISPATCHED: // (0x800C0200L or -2146696704)
// cancel request cancelled...
errorCode = "INET_E_RESULT_DISPATCHED";
errorType = wxWEB_NAV_ERR_OTHER;
break;
case INET_E_CANNOT_REPLACE_SFP_FILE: // (0x800C0300L or -2146696448)
errorCode = "INET_E_CANNOT_REPLACE_SFP_FILE";
errorType = wxWEB_NAV_ERR_SECURITY;
break;
case INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY:
errorCode = "INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY";
errorType = wxWEB_NAV_ERR_SECURITY;
break;
case INET_E_CODE_INSTALL_SUPPRESSED:
errorCode = "INET_E_CODE_INSTALL_SUPPRESSED";
errorType = wxWEB_NAV_ERR_SECURITY;
break;
}
wxString url = evt[1].GetString();
wxString target = evt[2].GetString();
wxWebNavigationEvent event(wxEVT_COMMAND_WEB_VIEW_ERROR, GetId(),
url, target, false);
event.SetEventObject(this);
event.SetInt(errorType);
event.SetString(errorCode);
HandleWindowEvent(event);
break;
}
case DISPID_COMMANDSTATECHANGE:
{
long commandId = evt[0].GetLong();
bool enable = evt[1].GetBool();
if (commandId == CSC_NAVIGATEBACK)
{
m_canNavigateBack = enable;
}
else if (commandId == CSC_NAVIGATEFORWARD)
{
m_canNavigateForward = enable;
}
}
/*
case DISPID_NEWWINDOW2:
//case DISPID_NEWWINDOW3:
{
wxLogMessage("DISPID_NEWWINDOW2\n");
wxActiveXEventNativeMSW* nativeParams = evt.GetNativeParameters();
// Cancel the attempt to open a new window
*V_BOOLREF(&nativeParams->pDispParams->rgvarg[0]) = VARIANT_TRUE;
}*/
}
evt.Skip();
}
#endif

1208
src/osx/webview.mm Normal file

File diff suppressed because it is too large Load Diff