Example #1
0
void StdGridLayoutImpl2::containerAddWidgets(WContainerWidget *container)
{
  StdLayoutImpl::containerAddWidgets(container);

  if (!container)
    return;

  WApplication *app = WApplication::instance();

  /*
   * If it is a top-level layout (as opposed to a nested layout),
   * configure overflow of the container.
   */
  if (parentLayoutImpl() == 0) {
    if (container == app->root()) {
      /*
       * Reset body,html default paddings and so on if we are doing layout
       * in the entire document.
       */
      app->setBodyClass(app->bodyClass() + " Wt-layout");
      app->setHtmlClass(app->htmlClass() + " Wt-layout");
    }
  }
}
Example #2
0
File: Widget.C Project: ReWeb3D/wt
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");
  }
}