在Vent中嵌入Ventus

时间:2013-05-16 14:23:45

标签: javascript c++ html embed wt

Hello其他程序员!我的目标是在WT页面(http://www.rlamana.es/ventus/)中嵌入Ventus窗口管理器(https://github.com/rlamana/Ventus),repo here(http://www.webtoolkit.eu/wt)并运行“简单示例”。我在WT页面中嵌入了ventus窗口,但是我的窗口存在样式问题。我猜这是与Ventus和WT的CSS冲突。这让我在这里,因为CSS不是我的强项。我正在使用visual studio2010进行开发,我只有一个WT项目运行,基本上是hello world应用程序,其中所有小部件都被删除了。我已经包含了simple.html示例使用的所有CSS和JS,并且一直试图弄清楚如何使它与WT一起工作。任何帮助将不胜感激!

void HelloApplication::InitInterface()
{
//Include the CSS
wApp->useStyleSheet("Ventus/examples/simple/css/normalize.css");
wApp->useStyleSheet("Ventus/examples/simple/css/simple.css");
wApp->useStyleSheet("Ventus/build/ventus.css");
wApp->useStyleSheet("Ventus/examples/simple/css/browseralert.css");

//Include the JS
wApp->require("Ventus/vendor/modernizr.js");
wApp->require("Ventus/vendor/jquery.js");
wApp->require("Ventus/vendor/handlebars.js");
wApp->require("Ventus/build/ventus.js");

WContainerWidget* root = this->root();

WContainerWidget* ventus_widget = new WContainerWidget(root);

//Widget ref
std::string ventus_widget_ref = ventus_widget->jsRef(); // is a text string that will be the element when executed in JS


std::string command = ventus_widget_ref + ".wm = new Ventus.WindowManager();";
//Create the window manager
ventus_widget->doJavaScript(command);

command = ventus_widget_ref + ".wm.createWindow({title: 'Ventus', x: 10, y: 10, width: 500, height: 500}).open();";

//You may also create new windows by creating container widgets and fromQuery function
//WContainerWidget* app_window = new WContainerWidget(wApp->root());
//command = ventus_widget_ref + ".wm.createWindow.fromQuery(" + app_window->jsRef() + ", {title: 'Ventus', x: 10, y: 10, width: 500, height: 500}).open();";
//You can then add widgets to the ventus window like any other WT container
//app_window->addWidget(app.get());

//Create a window
ventus_widget->doJavaScript(command);
}

1 个答案:

答案 0 :(得分:1)

终于明白了。使用WT而不是使用“require”来加载CSS文件时,请使用“useStyleSheet”。