Ejemplo n.º 1
0
	void createFiles()
	{
		// Create local HTML files we want to refer to by urls.
		// We read data from resources and write to files.
		// TODO: This can be removed once automatic resource
		// unpacking of file systems is supported.

		mPlatform->writeTextToFile(
			mPlatform->getLocalPath() + "PageOne.html",
			mPlatform->createTextFromHandle(PageOne_html));

		mPlatform->writeTextToFile(
			mPlatform->getLocalPath() + "PageTwo.html",
			mPlatform->createTextFromHandle(PageTwo_html));
	}
Ejemplo n.º 2
0
	MAWidgetHandle createWebView()
	{
		// Create web view.
		MAWidgetHandle webView = maWidgetCreate(MAW_WEB_VIEW);
		widgetShouldBeValid(webView, "Could not create web view");

		// Set size of the web view to fill the parent.
		maWidgetSetProperty(webView, "width", "-1");
		maWidgetSetProperty(webView, "height", "-1");

		// Method 1: Directly html property of WebView.

//		MAUtil::String html =
//			mPlatform->createTextFromHandle(ColorPage_html);
//		maWidgetSetProperty(webView, "html", html.c_str());

		// Method 2: Write html file to local file system.

		// Write HTML resource files to the local file system
		// so they can be accessed by the web view.
		// TODO: This can be removed once automatic resource
		// unpacking of file systems is supported.

		mPlatform->writeTextToFile(
			mPlatform->getLocalPath() + "ColorPage.html",
			mPlatform->createTextFromHandle(ColorPage_html));

		// As a test, create a second page (linked to from ColorPage.html).
		mPlatform->writeTextToFile(
			mPlatform->getLocalPath() + "AnotherPage.html",
			"<html><body><p><a href=\"ColorPage.html\">Hello World</a></p></body></html>");

		// Set the URL the web view displays.
		// We support both absolute file url and
		// as url that assumes a url base is set.
		maWidgetSetProperty(webView, "url", "ColorPage.html");

		// Register to receive messages from the WebView.
		WebViewMessage::getMessagesFor(webView);

		return webView;
	}