本文整理汇总了C++中WApplication::require方法的典型用法代码示例。如果您正苦于以下问题:C++ WApplication::require方法的具体用法?C++ WApplication::require怎么用?C++ WApplication::require使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WApplication
的用法示例。
在下文中一共展示了WApplication::require方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initTinyMCE
void WTextEdit::initTinyMCE()
{
const char *THIS_JS = "js/WTextEdit.js";
WApplication *app = WApplication::instance();
if (!app->javaScriptLoaded(THIS_JS)) {
if (app->environment().ajax())
app->doJavaScript("window.tinyMCE_GZ = { loaded: true };", false);
int version = getTinyMCEVersion();
std::string folder = version == 3 ? "tiny_mce/" : "tinymce/";
std::string jsFile = version == 3 ? "tiny_mce.js" : "tinymce.js";
std::string tinyMCEBaseURL = WApplication::relativeResourcesUrl() + folder;
WApplication::readConfigurationProperty("tinyMCEBaseURL", tinyMCEBaseURL);
if (!tinyMCEBaseURL.empty()
&& tinyMCEBaseURL[tinyMCEBaseURL.length()-1] != '/')
tinyMCEBaseURL += '/';
app->require(tinyMCEBaseURL + jsFile, "window['tinyMCE']");
app->styleSheet().addRule(".mceEditor",
"display: block; position: absolute;");
LOAD_JAVASCRIPT(app, THIS_JS, "WTextEdit", wtjs1);
}
}
示例2: WCompositeWidget
WMediaPlayer::WMediaPlayer(MediaType mediaType, WContainerWidget *parent)
: WCompositeWidget(parent),
mediaType_(mediaType),
videoWidth_(0),
videoHeight_(0),
gui_(this),
boundSignals_(0)
{
for (unsigned i = 0; i < 11; ++i)
control_[i] = 0;
for (unsigned i = 0; i < 3; ++i)
display_[i] = 0;
for (unsigned i = 0; i < 2; ++i)
progressBar_[i] = 0;
WTemplate *impl = new WMediaPlayerImpl(this, tr("Wt.WMediaPlayer.template"));
impl->bindString("gui", std::string());
setImplementation(impl);
WApplication *app = WApplication::instance();
LOAD_JAVASCRIPT(app, "js/WMediaPlayer.js", "WMediaPlayer", wtjs1);
std::string res = WApplication::relativeResourcesUrl() + "jPlayer/";
if (!app->environment().ajax())
app->require(res + "jquery.min.js");
if (app->require(res + "jquery.jplayer.min.js"))
app->useStyleSheet(res + "skin/jplayer.blue.monday.css");
if (mediaType_ == Video)
setVideoSize(480, 270);
#ifndef WT_TARGET_JAVA
implementJavaScript(&WMediaPlayer::play,
jsPlayerRef() + ".jPlayer('play');");
implementJavaScript(&WMediaPlayer::pause,
jsPlayerRef() + ".jPlayer('pause');");
implementJavaScript(&WMediaPlayer::stop,
jsPlayerRef() + ".jPlayer('stop');");
#endif
}
示例3: setImplementation
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8/////////9/////////A
WGoogleMapEx::WGoogleMapEx(WContainerWidget *parent)
{
setImplementation(new WContainerWidget());
WApplication *app = WApplication::instance();
std::string googlekey = localhost_key;
Wt::WApplication::readConfigurationProperty("google_api_key", googlekey);
// init the google javascript api
const std::string gmuri = "http://www.google.com/jsapi?key=" + googlekey;
app->require(gmuri, "google");
if(parent)
parent->addWidget(this);
/*
// if there is no google api key configured, use the one for
// http://localhost:8080/
static const string localhost_key
= "ABQIAAAAWqrN5o4-ISwj0Up_depYvhTwM0brOpm-"
"All5BF6PoaKBxRWWERS-S9gPtCri-B6BZeXV8KpT4F80DQ";
string googlekey = localhost_key;
Wt::WApplication::readConfigurationProperty("google_api_key", googlekey);
// init the google javascript api
const string gmuri = "http://www.google.com/jsapi?key=" + googlekey;
app->require(gmuri, "google");
*/
// app->require("/googlemaps_addons/BDCCArrow.js", "GM_Arrow");
// app->require("/googlemaps_addons/BDCCCircle.js", "GM_Circle");
// app->require("http://www.bdcc.co.uk/Gmaps/BDCCCircle.js");
// app->require("http://www.bdcc.co.uk/Gmaps/BDCCArrow.js");
/*
std::stringstream sstr;
sstr << "function onGoogleApiLoad()"
<< "{"
<< "var scriptnode1 = document.createElement('SCRIPT');"
<< "scriptnode1.type = 'text/javascript';"
<< "scriptnode1.src = '/googlemaps_addons/BDCCCircle.js';"
<< "var scriptnode2 = document.createElement('SCRIPT');"
<< "scriptnode2.type = 'text/javascript';"
<< "scriptnode2.src = '/googlemaps_addons/BDCCArrow.js';"
<< "var headnode = document.getElementsByTagName('HEAD');"
<< "if(headnode[0] != null)"
<< "{"
<< "headnode[0].appendChild(scriptnode1);"
<< "headnode[0].appendChild(scriptnode2);"
<< "}"
<< "};"
<< "google.setOnLoadCallback(onGoogleApiLoad);";
app->doJavaScript(sstr.str(), true);
*/
}
示例4: initExt
void Widget::initExt()
{
std::string extBaseURL = "ext";
WApplication::readConfigurationProperty("extBaseURL", extBaseURL);
if (!extBaseURL.empty() && extBaseURL[extBaseURL.length()-1] != '/')
extBaseURL += '/';
WApplication *app = WApplication::instance();
if (app->require(extBaseURL + "ext-base.js", "window['Ext']")) {
app->require(extBaseURL + "ext-all.js", "window.Ext['DomHelper']");
app->useStyleSheet(extBaseURL + "resources/css/ext-all.css");
// fixes for Firefox 3:
app->styleSheet().addRule(".x-date-middle", "width:130px;");
// rendering glitches on all browsers:
app->styleSheet().addRule(".ext-gecko .x-form-text", "margin-top: -1px;");
app->styleSheet().addRule(".ext-safari .x-form-text", "margin-top: -1px;");
app->styleSheet().addRule(".ext-ie .x-form-text",
"margin-top: 0px !important;"
"margin-bottom: 0px !important;");
app->doJavaScript(/*app->javaScriptClass() + '.' + */ "ExtW = new Array();"
"Ext.QuickTips.init();"
"Ext.BLANK_IMAGE_URL='" + extBaseURL
+ "resources/images/default/s.gif';", false);
app->declareJavaScriptFunction("deleteExtW",
"" "function(id){"
"" "var w=ExtW[id];"
"" "if(w){"
"" "if (w.el && w.destroy) w.destroy();"
"" "delete ExtW[id];"
"" "}"
"" "}");
if (app->environment().agentIsIE())
app->doJavaScript
("if ((typeof Range !== 'undefined')"
"" "&& !Range.prototype.createContextualFragment) {"
"""Range.prototype.createContextualFragment = function(html) {"
"" "var startNode = this.startContainer;"
"" "var doc = startNode.nodeType == 9 ? startNode :"
"" "startNode.ownerDocument;"
"" "var container = doc.createElement('div');"
"" "container.innerHTML = html;"
"" "var frag = doc.createDocumentFragment(), n;"
"" "while ( (n = container.firstChild) ) {"
"" "frag.appendChild(n);"
"" "}"
"" "return frag;"
"""};"
"}", false);
/*
* Normally, Ext does this in its onReady function, but this is not
* fired when loading ExtJS on demand.
*/
std::string bodyClass;
if (app->environment().agentIsIE()) {
bodyClass = " ext-ie ";
bodyClass += app->environment().agent() == WEnvironment::IE6
? "ext-ie6" : "ext-ie7 ";
} else if (app->environment().agentIsSafari())
bodyClass = " ext-safari";
else if (app->environment().agentIsOpera())
bodyClass = " ext-opera";
else if (app->environment().agentIsGecko())
bodyClass = " ext-gecko";
const std::string& ua = app->environment().userAgent();
if (ua.find("Linux") != std::string::npos)
bodyClass += " ext-linux";
if (ua.find("Macintosh") != std::string::npos
|| ua.find("Mac OS X") != std::string::npos)
bodyClass += " ext-mac";
app->setBodyClass(app->bodyClass() + bodyClass);
app->setHtmlClass(app->htmlClass() + " ext-strict");
}
}