mirror of https://github.com/axmolengine/axmol.git
change WebView namespace and add WebViewTest
This commit is contained in:
parent
736b83acb1
commit
2226d4b420
|
@ -1351,6 +1351,12 @@
|
|||
1AC0269C1914068200FA920D /* ConvertUTF.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC026991914068200FA920D /* ConvertUTF.h */; };
|
||||
1AC0269D1914068200FA920D /* ConvertUTF.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC026991914068200FA920D /* ConvertUTF.h */; };
|
||||
2986667F18B1B246000E39CA /* CCTweenFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2986667818B1B079000E39CA /* CCTweenFunction.cpp */; };
|
||||
298D7F6419AC2EFD00FF096D /* UIWebViewWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 298D7F5C19AC2EFD00FF096D /* UIWebViewWrapper.h */; };
|
||||
298D7F6519AC2EFD00FF096D /* UIWebViewWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 298D7F5D19AC2EFD00FF096D /* UIWebViewWrapper.mm */; };
|
||||
298D7F6819AC2EFD00FF096D /* WebView.h in Headers */ = {isa = PBXBuildFile; fileRef = 298D7F6019AC2EFD00FF096D /* WebView.h */; };
|
||||
298D7F6919AC2EFD00FF096D /* WebView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 298D7F6119AC2EFD00FF096D /* WebView.mm */; };
|
||||
298D7F6A19AC2EFD00FF096D /* WebViewImpl_iOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 298D7F6219AC2EFD00FF096D /* WebViewImpl_iOS.h */; };
|
||||
298D7F6B19AC2EFD00FF096D /* WebViewImpl_iOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 298D7F6319AC2EFD00FF096D /* WebViewImpl_iOS.mm */; };
|
||||
299754F4193EC95400A54AC3 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */; };
|
||||
299754F5193EC95400A54AC3 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */; };
|
||||
299754F6193EC95400A54AC3 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 299754F3193EC95400A54AC3 /* ObjectFactory.h */; };
|
||||
|
@ -2300,6 +2306,12 @@
|
|||
2958244A19873D8E00F9746D /* UIScale9Sprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIScale9Sprite.h; sourceTree = "<group>"; };
|
||||
2986667818B1B079000E39CA /* CCTweenFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTweenFunction.cpp; sourceTree = "<group>"; };
|
||||
2986667918B1B079000E39CA /* CCTweenFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTweenFunction.h; sourceTree = "<group>"; };
|
||||
298D7F5C19AC2EFD00FF096D /* UIWebViewWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIWebViewWrapper.h; sourceTree = "<group>"; };
|
||||
298D7F5D19AC2EFD00FF096D /* UIWebViewWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIWebViewWrapper.mm; sourceTree = "<group>"; };
|
||||
298D7F6019AC2EFD00FF096D /* WebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebView.h; sourceTree = "<group>"; };
|
||||
298D7F6119AC2EFD00FF096D /* WebView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebView.mm; sourceTree = "<group>"; };
|
||||
298D7F6219AC2EFD00FF096D /* WebViewImpl_iOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewImpl_iOS.h; sourceTree = "<group>"; };
|
||||
298D7F6319AC2EFD00FF096D /* WebViewImpl_iOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewImpl_iOS.mm; sourceTree = "<group>"; };
|
||||
299754F2193EC95400A54AC3 /* ObjectFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ObjectFactory.cpp; path = ../base/ObjectFactory.cpp; sourceTree = "<group>"; };
|
||||
299754F3193EC95400A54AC3 /* ObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjectFactory.h; path = ../base/ObjectFactory.h; sourceTree = "<group>"; };
|
||||
299CF1F919A434BC00C378C1 /* ccRandom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ccRandom.cpp; path = ../base/ccRandom.cpp; sourceTree = "<group>"; };
|
||||
|
@ -4016,6 +4028,12 @@
|
|||
29CB8F521929D65500C841D6 /* experimental */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
298D7F5C19AC2EFD00FF096D /* UIWebViewWrapper.h */,
|
||||
298D7F5D19AC2EFD00FF096D /* UIWebViewWrapper.mm */,
|
||||
298D7F6019AC2EFD00FF096D /* WebView.h */,
|
||||
298D7F6119AC2EFD00FF096D /* WebView.mm */,
|
||||
298D7F6219AC2EFD00FF096D /* WebViewImpl_iOS.h */,
|
||||
298D7F6319AC2EFD00FF096D /* WebViewImpl_iOS.mm */,
|
||||
3EA0FB69191C841D00B170C8 /* UIVideoPlayer.h */,
|
||||
3EA0FB6A191C841D00B170C8 /* UIVideoPlayerIOS.mm */,
|
||||
);
|
||||
|
@ -5454,6 +5472,7 @@
|
|||
46A171061807CECB005B8026 /* CCPhysicsWorld.h in Headers */,
|
||||
50ABBDB41925AB4100A911A9 /* ccShaders.h in Headers */,
|
||||
15AE19B319AAD39700C27E9E /* SliderReader.h in Headers */,
|
||||
298D7F6419AC2EFD00FF096D /* UIWebViewWrapper.h in Headers */,
|
||||
15AE1B7919AADA9A00C27E9E /* UIRichText.h in Headers */,
|
||||
15AE1A4A19AAD3D500C27E9E /* b2CircleShape.h in Headers */,
|
||||
50ABBE861925AB6F00A911A9 /* ccFPSImages.h in Headers */,
|
||||
|
@ -5465,6 +5484,7 @@
|
|||
15AE1A4019AAD3D500C27E9E /* b2Collision.h in Headers */,
|
||||
5034CA40191D591100CE6051 /* ccShader_Position_uColor.vert in Headers */,
|
||||
15AE184719AAD2F700C27E9E /* CCSprite3DMaterial.h in Headers */,
|
||||
298D7F6819AC2EFD00FF096D /* WebView.h in Headers */,
|
||||
15AE1BFC19AAE01E00C27E9E /* CCControlUtils.h in Headers */,
|
||||
15AE193519AAD35100C27E9E /* CCActionObject.h in Headers */,
|
||||
15AE1AA919AAD40300C27E9E /* b2TimeStep.h in Headers */,
|
||||
|
@ -5839,6 +5859,7 @@
|
|||
15AE1B0919AAD42500C27E9E /* cpPolyShape.h in Headers */,
|
||||
15AE193919AAD35100C27E9E /* CCArmatureAnimation.h in Headers */,
|
||||
15AE1AA419AAD40300C27E9E /* b2ContactManager.h in Headers */,
|
||||
298D7F6A19AC2EFD00FF096D /* WebViewImpl_iOS.h in Headers */,
|
||||
B276EF601988D1D500CD400F /* CCVertexIndexData.h in Headers */,
|
||||
50ABBD5F1925AB0000A911A9 /* Vec3.h in Headers */,
|
||||
50ABBE921925AB6F00A911A9 /* CCPlatformMacros.h in Headers */,
|
||||
|
@ -6672,6 +6693,7 @@
|
|||
15AE1A4319AAD3D500C27E9E /* b2DynamicTree.cpp in Sources */,
|
||||
15AE1BFF19AAE01E00C27E9E /* CCScale9Sprite.cpp in Sources */,
|
||||
15AE1A3A19AAD3D500C27E9E /* b2BroadPhase.cpp in Sources */,
|
||||
298D7F6519AC2EFD00FF096D /* UIWebViewWrapper.mm in Sources */,
|
||||
15AE19B619AAD39700C27E9E /* TextBMFontReader.cpp in Sources */,
|
||||
15AE1BFD19AAE01E00C27E9E /* CCInvocation.cpp in Sources */,
|
||||
B24AA98A195A675C007B4522 /* CCFastTMXTiledMap.cpp in Sources */,
|
||||
|
@ -6710,6 +6732,7 @@
|
|||
1A5702C9180BCE370088DEC7 /* CCTextFieldTTF.cpp in Sources */,
|
||||
15AE1A0519AAD3A700C27E9E /* Bone.cpp in Sources */,
|
||||
15AE1B3D19AAD43700C27E9E /* cpCollision.c in Sources */,
|
||||
298D7F6919AC2EFD00FF096D /* WebView.mm in Sources */,
|
||||
15AE1C1719AAE2C700C27E9E /* CCPhysicsSprite.cpp in Sources */,
|
||||
1A5702EB180BCE750088DEC7 /* CCTileMapAtlas.cpp in Sources */,
|
||||
1A5702EF180BCE750088DEC7 /* CCTMXLayer.cpp in Sources */,
|
||||
|
@ -6762,6 +6785,7 @@
|
|||
50ABBE5E1925AB6F00A911A9 /* CCEventListener.cpp in Sources */,
|
||||
15AE1BC719AAE00000C27E9E /* AssetsManager.cpp in Sources */,
|
||||
50ABBEA81925AB6F00A911A9 /* CCTouch.cpp in Sources */,
|
||||
298D7F6B19AC2EFD00FF096D /* WebViewImpl_iOS.mm in Sources */,
|
||||
15AE1A9619AAD40300C27E9E /* b2Draw.cpp in Sources */,
|
||||
503DD8E91926736A00CD74DD /* CCES2Renderer.m in Sources */,
|
||||
5027253D190BF1B900AAF4ED /* cocos2d.cpp in Sources */,
|
||||
|
|
|
@ -865,6 +865,7 @@
|
|||
290E94B6196FC16900694919 /* CocostudioParserTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 290E94B3196FC16900694919 /* CocostudioParserTest.cpp */; };
|
||||
295824591987415900F9746D /* UIScale9SpriteTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 295824571987415900F9746D /* UIScale9SpriteTest.cpp */; };
|
||||
2958245A1987415900F9746D /* UIScale9SpriteTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 295824571987415900F9746D /* UIScale9SpriteTest.cpp */; };
|
||||
298D7F6F19AC31F300FF096D /* UIWebViewTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 298D7F6D19AC31F300FF096D /* UIWebViewTest.cpp */; };
|
||||
29FBBBFE196A9ECD00E65826 /* CocostudioParserJsonTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29FBBBFC196A9ECD00E65826 /* CocostudioParserJsonTest.cpp */; };
|
||||
29FBBBFF196A9ECD00E65826 /* CocostudioParserJsonTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29FBBBFC196A9ECD00E65826 /* CocostudioParserJsonTest.cpp */; };
|
||||
38FA2E73194AEBE100FF2BE4 /* ActionTimelineTestScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 38FA2E71194AEBE100FF2BE4 /* ActionTimelineTestScene.cpp */; };
|
||||
|
@ -2886,6 +2887,8 @@
|
|||
290E94B4196FC16900694919 /* CocostudioParserTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CocostudioParserTest.h; path = ../CocostudioParserTest.h; sourceTree = "<group>"; };
|
||||
295824571987415900F9746D /* UIScale9SpriteTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIScale9SpriteTest.cpp; sourceTree = "<group>"; };
|
||||
295824581987415900F9746D /* UIScale9SpriteTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIScale9SpriteTest.h; sourceTree = "<group>"; };
|
||||
298D7F6D19AC31F300FF096D /* UIWebViewTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UIWebViewTest.cpp; path = UIWebViewTest/UIWebViewTest.cpp; sourceTree = "<group>"; };
|
||||
298D7F6E19AC31F300FF096D /* UIWebViewTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UIWebViewTest.h; path = UIWebViewTest/UIWebViewTest.h; sourceTree = "<group>"; };
|
||||
29FBBBFC196A9ECD00E65826 /* CocostudioParserJsonTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CocostudioParserJsonTest.cpp; sourceTree = "<group>"; };
|
||||
29FBBBFD196A9ECD00E65826 /* CocostudioParserJsonTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocostudioParserJsonTest.h; sourceTree = "<group>"; };
|
||||
38FA2E71194AEBE100FF2BE4 /* ActionTimelineTestScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ActionTimelineTestScene.cpp; sourceTree = "<group>"; };
|
||||
|
@ -6907,6 +6910,15 @@
|
|||
path = UIWidgetAddNodeTest;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
298D7F6C19AC31C000FF096D /* UIWebViewTest */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
298D7F6D19AC31F300FF096D /* UIWebViewTest.cpp */,
|
||||
298D7F6E19AC31F300FF096D /* UIWebViewTest.h */,
|
||||
);
|
||||
name = UIWebViewTest;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
@ -6988,6 +7000,7 @@
|
|||
29FBBC00196A9F0D00E65826 /* UIAndEditorTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
298D7F6C19AC31C000FF096D /* UIWebViewTest */,
|
||||
295824571987415900F9746D /* UIScale9SpriteTest.cpp */,
|
||||
295824581987415900F9746D /* UIScale9SpriteTest.h */,
|
||||
29080D1F191B595E0066F8DF /* CocosGUIScene.cpp */,
|
||||
|
@ -8316,6 +8329,7 @@
|
|||
1AC35B3E18CECF0C00F37B72 /* Bug-422.cpp in Sources */,
|
||||
29080DAC191B595E0066F8DF /* UIFocusTest.cpp in Sources */,
|
||||
1AC35BF618CECF0C00F37B72 /* HttpClientTest.cpp in Sources */,
|
||||
298D7F6F19AC31F300FF096D /* UIWebViewTest.cpp in Sources */,
|
||||
29080DA6191B595E0066F8DF /* UIButtonTest_Editor.cpp in Sources */,
|
||||
1AC35B5018CECF0C00F37B72 /* ClickAndMoveTest.cpp in Sources */,
|
||||
);
|
||||
|
|
|
@ -47,6 +47,7 @@ THE SOFTWARE.
|
|||
#include "ui/UIRelativeBox.h"
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
#include "ui/UIVideoPlayer.h"
|
||||
#include "ui/WebView.h"
|
||||
#endif
|
||||
#include "ui/UIDeprecated.h"
|
||||
#include "ui/GUIExport.h"
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#import "CCEAGLView.h"
|
||||
#import "CCDirector.h"
|
||||
|
||||
using namespace cocos2d::experimental::ui;
|
||||
|
||||
|
||||
@interface UIWebViewWrapper () <UIWebViewDelegate>
|
||||
@property(nonatomic, retain) UIWebView *uiWebView;
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
#ifndef __CC_WebView_INL_H_
|
||||
#define __CC_WebView_INL_H_
|
||||
|
||||
#include "WebView.h"
|
||||
#include "platform/CCGLView.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
|
||||
namespace cocos2d {
|
||||
namespace plugin {
|
||||
WebView::WebView() : _impl(new WebViewImpl(this)) {
|
||||
}
|
||||
|
||||
WebView::~WebView() {
|
||||
delete _impl;
|
||||
}
|
||||
|
||||
WebView *WebView::create() {
|
||||
auto pRet = new WebView();
|
||||
if (pRet->init()) {
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void WebView::setJavascriptInterfaceScheme(const std::string &scheme) {
|
||||
_impl->setJavascriptInterfaceScheme(scheme);
|
||||
}
|
||||
|
||||
void WebView::loadData(const cocos2d::Data &data, const std::string &MIMEType, const std::string &encoding, const std::string &baseURL) {
|
||||
_impl->loadData(data, MIMEType, encoding, baseURL);
|
||||
}
|
||||
|
||||
void WebView::loadHTMLString(const std::string &string, const std::string &baseURL) {
|
||||
_impl->loadHTMLString(string, baseURL);
|
||||
}
|
||||
|
||||
void WebView::loadUrl(const std::string &url) {
|
||||
_impl->loadUrl(url);
|
||||
}
|
||||
|
||||
void WebView::loadFile(const std::string &fileName) {
|
||||
_impl->loadFile(fileName);
|
||||
}
|
||||
|
||||
void WebView::stopLoading() {
|
||||
_impl->stopLoading();
|
||||
}
|
||||
|
||||
void WebView::reload() {
|
||||
_impl->reload();
|
||||
}
|
||||
|
||||
bool WebView::canGoBack() {
|
||||
return _impl->canGoBack();
|
||||
}
|
||||
|
||||
bool WebView::canGoForward() {
|
||||
return _impl->canGoForward();
|
||||
}
|
||||
|
||||
void WebView::goBack() {
|
||||
_impl->goBack();
|
||||
}
|
||||
|
||||
void WebView::goForward() {
|
||||
_impl->goForward();
|
||||
}
|
||||
|
||||
void WebView::evaluateJS(const std::string &js) {
|
||||
_impl->evaluateJS(js);
|
||||
}
|
||||
|
||||
void WebView::setScalesPageToFit(bool const scalesPageToFit) {
|
||||
_impl->setScalesPageToFit(scalesPageToFit);
|
||||
}
|
||||
|
||||
void WebView::draw(cocos2d::Renderer *renderer, cocos2d::Mat4 const &transform, uint32_t flags) {
|
||||
cocos2d::ui::Widget::draw(renderer, transform, flags);
|
||||
_impl->draw(renderer, transform, flags);
|
||||
}
|
||||
|
||||
void WebView::setVisible(bool visible) {
|
||||
Node::setVisible(visible);
|
||||
_impl->setVisible(visible);
|
||||
}
|
||||
} // namespace cocos2d
|
||||
} // namespace plugin
|
||||
|
||||
#endif
|
|
@ -2,6 +2,5 @@
|
|||
// Created by gin0606 on 2014/08/05.
|
||||
//
|
||||
|
||||
|
||||
#include "WebViewImpl_android.h"
|
||||
#include "WebViewImpl_iOS.h"
|
||||
#include "WebView-inl.h"
|
||||
|
|
|
@ -5,11 +5,16 @@
|
|||
#ifndef __Cocos2d_Plugin_WebView_H_
|
||||
#define __Cocos2d_Plugin_WebView_H_
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
|
||||
|
||||
#include "ui/UIWidget.h"
|
||||
#include "base/CCData.h"
|
||||
|
||||
namespace cocos2d {
|
||||
namespace plugin {
|
||||
NS_CC_BEGIN
|
||||
namespace experimental{
|
||||
namespace ui{
|
||||
|
||||
class WebViewImpl;
|
||||
|
||||
class WebView : public cocos2d::ui::Widget {
|
||||
|
@ -135,9 +140,13 @@ public:
|
|||
virtual void setVisible(bool visible) override;
|
||||
|
||||
private:
|
||||
cocos2d::plugin::WebViewImpl *_impl;
|
||||
WebViewImpl *_impl;
|
||||
};
|
||||
|
||||
} // namespace cocos2d
|
||||
} // namespace plugin
|
||||
} // namespace experimental
|
||||
}//namespace ui
|
||||
|
||||
#endif
|
||||
|
||||
#endif //__Cocos2d_Plugin_WebView_H_
|
||||
|
|
|
@ -4,4 +4,92 @@
|
|||
|
||||
|
||||
#include "WebViewImpl_iOS.h"
|
||||
#include "WebView-inl.h"
|
||||
#include "WebView.h"
|
||||
#include "platform/CCGLView.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
namespace experimental{
|
||||
namespace ui{
|
||||
|
||||
WebView::WebView() : _impl(new WebViewImpl(this)) {
|
||||
}
|
||||
|
||||
WebView::~WebView() {
|
||||
delete _impl;
|
||||
}
|
||||
|
||||
WebView *WebView::create() {
|
||||
auto pRet = new WebView();
|
||||
if (pRet->init()) {
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void WebView::setJavascriptInterfaceScheme(const std::string &scheme) {
|
||||
_impl->setJavascriptInterfaceScheme(scheme);
|
||||
}
|
||||
|
||||
void WebView::loadData(const cocos2d::Data &data, const std::string &MIMEType, const std::string &encoding, const std::string &baseURL) {
|
||||
_impl->loadData(data, MIMEType, encoding, baseURL);
|
||||
}
|
||||
|
||||
void WebView::loadHTMLString(const std::string &string, const std::string &baseURL) {
|
||||
_impl->loadHTMLString(string, baseURL);
|
||||
}
|
||||
|
||||
void WebView::loadUrl(const std::string &url) {
|
||||
_impl->loadUrl(url);
|
||||
}
|
||||
|
||||
void WebView::loadFile(const std::string &fileName) {
|
||||
_impl->loadFile(fileName);
|
||||
}
|
||||
|
||||
void WebView::stopLoading() {
|
||||
_impl->stopLoading();
|
||||
}
|
||||
|
||||
void WebView::reload() {
|
||||
_impl->reload();
|
||||
}
|
||||
|
||||
bool WebView::canGoBack() {
|
||||
return _impl->canGoBack();
|
||||
}
|
||||
|
||||
bool WebView::canGoForward() {
|
||||
return _impl->canGoForward();
|
||||
}
|
||||
|
||||
void WebView::goBack() {
|
||||
_impl->goBack();
|
||||
}
|
||||
|
||||
void WebView::goForward() {
|
||||
_impl->goForward();
|
||||
}
|
||||
|
||||
void WebView::evaluateJS(const std::string &js) {
|
||||
_impl->evaluateJS(js);
|
||||
}
|
||||
|
||||
void WebView::setScalesPageToFit(bool const scalesPageToFit) {
|
||||
_impl->setScalesPageToFit(scalesPageToFit);
|
||||
}
|
||||
|
||||
void WebView::draw(cocos2d::Renderer *renderer, cocos2d::Mat4 const &transform, uint32_t flags) {
|
||||
cocos2d::ui::Widget::draw(renderer, transform, flags);
|
||||
_impl->draw(renderer, transform, flags);
|
||||
}
|
||||
|
||||
void WebView::setVisible(bool visible) {
|
||||
Node::setVisible(visible);
|
||||
_impl->setVisible(visible);
|
||||
}
|
||||
} // namespace cocos2d
|
||||
} // namespace ui
|
||||
} //namespace experimental
|
|
@ -10,15 +10,19 @@
|
|||
@class UIWebViewWrapper;
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
class Data;
|
||||
class Renderer;
|
||||
class Mat4;
|
||||
namespace plugin {
|
||||
|
||||
namespace experimental {
|
||||
namespace ui{
|
||||
|
||||
class WebView;
|
||||
|
||||
class WebViewImpl {
|
||||
public:
|
||||
WebViewImpl(cocos2d::plugin::WebView *webView);
|
||||
WebViewImpl(WebView *webView);
|
||||
|
||||
virtual ~WebViewImpl();
|
||||
|
||||
|
@ -58,6 +62,7 @@ private:
|
|||
};
|
||||
|
||||
} // namespace cocos2d
|
||||
} // namespace plugin
|
||||
} // namespace experimental
|
||||
}//namespace ui
|
||||
|
||||
#endif //__cocos2d_plugin_WebViewImpl_IOS_H_
|
||||
|
|
|
@ -5,16 +5,19 @@
|
|||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
|
||||
#include "WebViewImpl_iOS.h"
|
||||
#import "UIWebViewWrapper.h"
|
||||
#include "renderer/CCRenderer.h"
|
||||
#include "WebView.h"
|
||||
#include "CCDirector.h"
|
||||
#include "CCGLView.h"
|
||||
#include "CCEAGLView.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
|
||||
#import "UIWebViewWrapper.h"
|
||||
#include "ui/WebView.h"
|
||||
|
||||
|
||||
namespace cocos2d {
|
||||
namespace plugin {
|
||||
namespace experimental {
|
||||
namespace ui{
|
||||
|
||||
WebViewImpl::WebViewImpl(WebView *webView)
|
||||
: _uiWebViewWrapper([UIWebViewWrapper webViewWrapper]), _webView(webView) {
|
||||
|
@ -128,7 +131,9 @@ void WebViewImpl::draw(cocos2d::Renderer *renderer, cocos2d::Mat4 const &transfo
|
|||
void WebViewImpl::setVisible(bool visible) {
|
||||
[_uiWebViewWrapper setVisible:visible];
|
||||
}
|
||||
|
||||
} // namespace cocos2d
|
||||
} // namespace plugin
|
||||
} // namespace experimental
|
||||
} //namespace ui
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
|
|
|
@ -29,6 +29,20 @@ g_guisTests[] =
|
|||
Director::getInstance()->replaceScene(scene);
|
||||
}
|
||||
},
|
||||
#endif
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
{
|
||||
"WebViewTest",
|
||||
[](Ref* sender)
|
||||
{
|
||||
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
||||
sceneManager->setCurrentUISceneId(KWebViewTest);
|
||||
sceneManager->setMinUISceneId(KWebViewTest);
|
||||
sceneManager->setMaxUISceneId(KWebViewTest);
|
||||
Scene* scene = sceneManager->currentUIScene();
|
||||
Director::getInstance()->replaceScene(scene);
|
||||
}
|
||||
},
|
||||
#endif
|
||||
{
|
||||
"focus test",
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "UIFocusTest/UIFocusTest.h"
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
#include "UIVideoPlayerTest/UIVideoPlayerTest.h"
|
||||
#include "UIWebViewTest/UIWebViewTest.h"
|
||||
#endif
|
||||
#include "UIScale9SpriteTest.h"
|
||||
|
||||
|
@ -94,6 +95,7 @@ static const char* s_testArray[] =
|
|||
"UIFocusTest-ListView",
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
"UIVideoPlayerTest",
|
||||
"UIWebViewTest",
|
||||
#endif
|
||||
"UIScale9SpriteTest",
|
||||
"UIScale9SpriteHierarchialTest",
|
||||
|
@ -328,6 +330,8 @@ Scene *UISceneManager::currentUIScene()
|
|||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
case kUIVideoPlayerTest:
|
||||
return VideoPlayerTest::sceneWithTitle(s_testArray[_currentUISceneId]);
|
||||
case KWebViewTest:
|
||||
return WebViewTest::sceneWithTitle(s_testArray[_currentUISceneId]);
|
||||
#endif
|
||||
case kUIScale9SpriteTest:
|
||||
return UIScale9SpriteTest::sceneWithTitle(s_testArray[_currentUISceneId]);
|
||||
|
|
|
@ -92,6 +92,7 @@ enum
|
|||
kUIFocusTest_ListView,
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
kUIVideoPlayerTest,
|
||||
KWebViewTest,
|
||||
#endif
|
||||
kUIScale9SpriteTest,
|
||||
kUIScale9SpriteHierarchialTest,
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "UIWebViewTest.h"
|
||||
|
||||
bool WebViewTest::init()
|
||||
{
|
||||
if (UIScene::init()) {
|
||||
_webView = experimental::ui::WebView::create();
|
||||
_webView->setPosition(Director::getInstance()->getVisibleSize()/2);
|
||||
_webView->setContentSize(Director::getInstance()->getVisibleSize() * 0.5);
|
||||
_webView->loadUrl("http://www.baidu.com");
|
||||
this->addChild(_webView);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __cocos2d_tests__UIWebViewTest__
|
||||
#define __cocos2d_tests__UIWebViewTest__
|
||||
|
||||
#include "../UIScene.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
class WebViewTest : public UIScene
|
||||
{
|
||||
public:
|
||||
UI_SCENE_CREATE_FUNC(WebViewTest);
|
||||
|
||||
virtual bool init();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
cocos2d::experimental::ui::WebView *_webView;
|
||||
|
||||
};
|
||||
|
||||
#endif /* defined(__cocos2d_tests__UIWebViewTest__) */
|
Loading…
Reference in New Issue