From aded6eb5272ccb4f9b90ee529bdb014ffaa59031 Mon Sep 17 00:00:00 2001 From: Tommi Komulainen Date: Tue, 25 Aug 2009 15:05:32 +0000 Subject: browser-plugin: add zoom property Example: plugin.zoom = plugin.zoom * 1.5; --- diff --git a/browser-plugin/plugin.cpp b/browser-plugin/plugin.cpp index 8398db3..7d79100 100644 --- a/browser-plugin/plugin.cpp +++ b/browser-plugin/plugin.cpp @@ -80,6 +80,19 @@ Plugin::ZoomOut () } void +Plugin::SetZoom (double zoom) +{ + ev_view_set_sizing_mode (EV_VIEW (mView), EV_SIZING_FREE); + ev_view_set_zoom (EV_VIEW (mView), zoom, FALSE); +} + +double +Plugin::GetZoom (void) const +{ + return ev_view_get_zoom (EV_VIEW (mView)); +} + +void Plugin::FindNext (const char *text) { } diff --git a/browser-plugin/plugin.h b/browser-plugin/plugin.h index 95c53ef..7ea940e 100644 --- a/browser-plugin/plugin.h +++ b/browser-plugin/plugin.h @@ -35,6 +35,8 @@ class Plugin { void Load (const char *fname); void ZoomIn (); void ZoomOut (); + double GetZoom () const; + void SetZoom (double); void FindNext (const char *text); void FindPrevious (const char *text); void ShowLoadingError (); diff --git a/browser-plugin/scriptable.cpp b/browser-plugin/scriptable.cpp index 6272c7d..e8fbcb2 100644 --- a/browser-plugin/scriptable.cpp +++ b/browser-plugin/scriptable.cpp @@ -197,6 +197,7 @@ ScriptablePluginObject::ScriptablePluginObject (NPP npp) : mMagicWrapper(0) { mTitleID = NPN_GetStringIdentifier ("title"); + mZoomID = NPN_GetStringIdentifier ("zoom"); mMagicWrapperID = NPN_GetStringIdentifier ("magicWrapper"); mZoomInID = NPN_GetStringIdentifier ("zoomIn"); @@ -229,6 +230,7 @@ ScriptablePluginObject::HasProperty (NPIdentifier name) { NPIdentifier properties[] = { mTitleID, + mZoomID, mMagicWrapperID }; @@ -256,6 +258,9 @@ ScriptablePluginObject::GetProperty (NPIdentifier name, NPVariant *result) } return true; + } else if (name == mZoomID) { + DOUBLE_TO_NPVARIANT (plugin->GetZoom(), *result); + return true; } return false; @@ -292,6 +297,19 @@ ScriptablePluginObject::SetProperty (NPIdentifier name, const NPVariant *value) } return true; + } else if (name == mZoomID) { + double zoom; + if (NPVARIANT_IS_DOUBLE (*value)) { + zoom = NPVARIANT_TO_DOUBLE (*value); + } else if (NPVARIANT_IS_INT32 (*value)) { + zoom = NPVARIANT_TO_INT32 (*value); + } else { + NPN_SetException (this, "Invalid type for zoom, expected a number"); + return false; + } + + plugin->SetZoom (zoom); + return true; } return false; diff --git a/browser-plugin/scriptable.h b/browser-plugin/scriptable.h index 79a9519..cc6ac1c 100644 --- a/browser-plugin/scriptable.h +++ b/browser-plugin/scriptable.h @@ -93,6 +93,7 @@ class ScriptablePluginObject : public ScriptablePluginObjectBase private: NPIdentifier mTitleID; + NPIdentifier mZoomID; NPIdentifier mMagicWrapperID; NPIdentifier mZoomInID; -- cgit v0.9.1