Example #1
0
DialogExample::DialogExample(const WEnvironment& env)
  : WApplication(env),
    messageBox_(0)
{
  setTitle("Dialog example");

  WContainerWidget *textdiv = new WContainerWidget(root());
  textdiv->setStyleClass("text");

  new WText("<h2>Wt dialogs example</h2>", textdiv);
  new WText("You can use WMessageBox for simple modal dialog boxes. <br />",
	    textdiv);

  WContainerWidget *buttons = new WContainerWidget(root());
  buttons->setStyleClass("buttons");

  WPushButton *button;

  button = new WPushButton("One liner", buttons);
  button->clicked().connect(this, &DialogExample::messageBox1);

  button = new WPushButton("Comfortable ?", buttons);
  button->clicked().connect(this, &DialogExample::messageBox2);

  button = new WPushButton("Havoc!", buttons);
  button->clicked().connect(this, &DialogExample::messageBox3);

  button = new WPushButton("Discard", buttons);
  button->clicked().connect(this, &DialogExample::messageBox4);

  button = new WPushButton("Familiar", buttons);
  button->clicked().connect(this, &DialogExample::custom);

  textdiv = new WContainerWidget(root());
  textdiv->setStyleClass("text");

  status_ = new WText("Go ahead...", textdiv);

  styleSheet().addRule(".buttons",
		       "padding: 5px;");
  styleSheet().addRule(".buttons BUTTON",
		       "padding-left: 4px; padding-right: 4px;"
		       "margin-top: 4px; display: block");

  // avoid scrollbar problems
  styleSheet().addRule(".text", "padding: 4px 8px");
  styleSheet().addRule("body", "margin: 0px;");
}
Example #2
0
MainPage::MainPage( const WEnvironment& env)    
    : WApplication(env)
{

    setTitle("Main page");

    this->useStyleSheet(AppPaths::cssFile);

    // Remove this 2 lines???
    userList = new WContainerWidget(root());
    userList->setStyleClass("list");


    // Remove it?
    WContainerWidget *t = new WContainerWidget();
    t->setInline(false);
    t->show();
    t->setStyleClass("big");    

    // Remove it?
    WStackedWidget *main = new WStackedWidget(root());
    main->setStyleClass("");    

    root()->removeWidget(main);




    Wt::WHBoxLayout *loginLayout = new Wt::WHBoxLayout(root());
    LoginWidget *login = new LoginWidget();
    loginLayout->addWidget(login);
    login->loggedIn().connect(this,&MainPage::setMainPage);
}
Example #3
0
void WTabWidget::create(WFlags<AlignmentFlag> layoutAlignment)
{
  setImplementation(layout_ = new WContainerWidget());

  WT_DEBUG( setObjectName("WTabWidget") );

  menu_ = new WMenu(new WStackedWidget(), Horizontal);
  menu_->setRenderAsList(true);

  WContainerWidget *menuDiv = new WContainerWidget();
  menuDiv->setStyleClass("Wt-tabs");
  menuDiv->addWidget(menu_);

  layout_->addWidget(menuDiv);
  layout_->addWidget(menu_->contentsStack());

  setJavaScriptMember
    (WT_RESIZE_JS, std::string() +
     "function(self, w, h) {"
     """self.style.height= h + 'px';"
     """var c = self.firstChild;"
     """var t = self.lastChild;"
     """h -= c.offsetHeight + " WT_CLASS ".px(c, 'marginTop') "
     ""   "+ " WT_CLASS ".px(c, 'marginBottom');"
     """if (h > 0)"
     ""  "t." + WT_RESIZE_JS + "(t, w, h);"
     "};");

  menu_->itemSelected().connect(this, &WTabWidget::onItemSelected);
  menu_->itemClosed().connect(this, &WTabWidget::onItemClosed);
}
Example #4
0
  /*! \brief Setup the user interface.
   */
  void createUI() {
    WContainerWidget *w = root();
    w->setStyleClass("maindiv");

    /*
     * The main layout is a 3x2 grid layout.
     */
    WGridLayout *layout = new WGridLayout();
    layout->addWidget(createTitle("Folders"), 0, 0);
    layout->addWidget(createTitle("Files"), 0, 1);
    layout->addWidget(folderView(), 1, 0);
    layout->setColumnResizable(0);

    // select the first folder
    folderView_->select(folderModel_->index(0, 0, folderModel_->index(0, 0)));

    WVBoxLayout *vbox = new WVBoxLayout();
    vbox->addWidget(fileView(), 1);
    vbox->addWidget(pieChart(), 1);
    vbox->setResizable(0);

    layout->addLayout(vbox, 1, 1);

    layout->addWidget(aboutDisplay(), 2, 0, 1, 2);

    /*
     * Let row 1 and column 1 take the excess space.
     */
    layout->setRowStretch(1, 1);
    layout->setColumnStretch(1, 1);

    w->setLayout(layout);
  }
Example #5
0
  /*! \brief Creates the chart.
   */
  WWidget *pieChart() {
    using namespace Chart;

    WPieChart *chart = new WPieChart();
    chart->setModel(fileFilterModel_);
    chart->setTitle("File sizes");

    chart->setLabelsColumn(1); // Name
    chart->setDataColumn(3);   // Size

    chart->setPerspectiveEnabled(true, 0.2);
    chart->setDisplayLabels(Outside | TextLabel);

    if (!WApplication::instance()->environment().ajax()) {
      chart->resize(500, 200);
      chart->setMargin(WLength::Auto, Left | Right);
      WContainerWidget *w = new WContainerWidget();
      w->addWidget(chart);
      w->setStyleClass("about");
      return w;
    } else {
      chart->setStyleClass("about");
      return chart;
    }
  }
Example #6
0
WWidget *ProductMenuItem::createItemWidget()
{        
    //<div class="collection" style="background: url(productimages/QEES_Dimmer_billed_tekst_01_thumb.jpg) no-repeat;">
    WAnchor *result = new WAnchor();    
    WContainerWidget *collection = new WContainerWidget(result);
    result->mouseWentOver().connect(SLOT(this, ProductMenuItem::_mouseWentOver));
    result->mouseWentOut().connect(SLOT(this, ProductMenuItem::_mouseWentOut));

    collection->setStyleClass("collection");
    WString imageName = _product->imageThumbName("var/www/", "resources/images/productimages/");
    collection->decorationStyle().setBackgroundImage(imageName.toUTF8());

    _faderInvisible = new WContainerWidget(collection);
    _faderInvisible->setStyleClass("fader invisible");

    WContainerWidget *faderInvisible2 = new WContainerWidget(_faderInvisible);
    new WText(_description(), faderInvisible2);

    // @todo: Add this? Change picutre
    // <!--<div class="sale_label"></div>-->
    //WContainerWidget *salesLabel = new WContainerWidget(collection);
    //salesLabel->setStyleClass("sale_label");

    // @todo: Add this? Change picutre
    // <!--<div class="sale_label"></div>-->
    //WContainerWidget *offerLabel = new WContainerWidget(collection);
    //offerLabel->setStyleClass("offer_label");

  return result;
}
Example #7
0
mapboxApplication::mapboxApplication(const WEnvironment & env) : WApplication(env)
{
  if (appRoot().empty()) {
    std::cerr << "!!!!!!!!!!" << std::endl
      << "!! Warning: read the README.md file for hints on deployment,"
      << " the approot looks suspect!" << std::endl
      << "!!!!!!!!!!" << std::endl;
  }

  setTheme(new WBootstrapTheme());
  this->useStyleSheet(WLink("wtMapExample.css"));

  setTitle("Mapbox Examples");

  WContainerWidget * mainContent = new WContainerWidget(root());
  mainContent->setStyleClass("examplemap");
  map = new MapBox::Map(mainContent, true);
  map->setMapStyle(MapBox::MAPSTYLE::Streets);
  map->zoom(14).center(MapBox::Coordinate(51.515823, -0.124331));

  // add all controls
  // map->addNavigationControl();
  // map->addGeoLocateControl();
  // map->addGeoCoderControl();

  menuBar = new MenuBar(root());

}
Example #8
0
WWidget *StyleLayout::wGridLayout()
{
  WContainerWidget *result = new WContainerWidget();
  topic("WGridLayout", result);

  addText(tr("layout-WGridLayout"), result);

  WContainerWidget *container;

  container = new WContainerWidget(result);
  container->resize(WLength::Auto, 400);
  container->setStyleClass("yellow-box");
  WGridLayout *grid = new WGridLayout();
  container->setLayout(grid);

  for (int row = 0; row < 3; ++row) {
    for (int column = 0; column < 4; ++column) {
      WText *t = addText(tr("grid-item").arg(row).arg(column));
      if (row == 1 || column == 1 || column == 2)
	t->setStyleClass("blue-box");
      else
	t->setStyleClass("green-box");
      grid->addWidget(t, row, column);
    }
  }

  grid->setRowStretch(1, 1);
  grid->setColumnStretch(1, 1);
  grid->setColumnStretch(2, 1);

  return result;
}
Example #9
0
WWidget *EventsDemo::wMouseEvent()
{
  WContainerWidget *result = new WContainerWidget();

  topic("WMouseEvent", result);
  addText(tr("events-WMouseEvent"), result);
  WContainerWidget *c = new WContainerWidget(result);
  WHBoxLayout *hlayout = new WHBoxLayout;
  c->setLayout(hlayout);
  WContainerWidget *l = new WContainerWidget;
  WContainerWidget *r = new WContainerWidget;
  new WText("clicked<br/>doubleClicked<br/>mouseWentOut<br/>mouseWentOver",
	    l);
  new WText("mouseWentDown<br/>mouseWentUp<br/>mouseMoved<br/>mouseWheel", r);
  hlayout->addWidget(l);
  hlayout->addWidget(r);
  c->resize(600, 300);
  l->decorationStyle().setBackgroundColor(Wt::gray);
  r->decorationStyle().setBackgroundColor(Wt::gray);
  // prevent that firefox interprets drag as drag&drop action
  l->setStyleClass("unselectable");
  r->setStyleClass("unselectable");
  l->clicked().connect(this, &EventsDemo::showClicked);
  l->doubleClicked().connect(this, &EventsDemo::showDoubleClicked);
  l->mouseWentOut().connect(this, &EventsDemo::showMouseWentOut);
  l->mouseWentOver().connect(this, &EventsDemo::showMouseWentOver);
  r->mouseMoved().connect(this, &EventsDemo::showMouseMoved);
  r->mouseWentUp().connect(this, &EventsDemo::showMouseWentUp);
  r->mouseWentDown().connect(this, &EventsDemo::showMouseWentDown);
  r->mouseWheel().connect(this, &EventsDemo::showMouseWheel);
  r->mouseWheel().preventDefaultAction(true);

  l->setAttributeValue
    ("oncontextmenu",
     "event.cancelBubble = true; event.returnValue = false; return false;");
  r->setAttributeValue
    ("oncontextmenu",
     "event.cancelBubble = true; event.returnValue = false; return false;");

  new WBreak(result);
  new WText("Last event: ", result);
  mouseEventType_ = new WText(result);
  new WBreak(result);
  mouseEventDescription_ = new WText(result);

  return result;
}
Example #10
0
void WNavigationBar::addWrapped(WWidget *widget, AlignmentFlag alignment,
				const char *wrapClass)
{
  WContainerWidget *contents = resolve<WContainerWidget *>("contents");

  WContainerWidget *wrap = new WContainerWidget(contents);
  wrap->setStyleClass(wrapClass);
  align(wrap, alignment);
  wrap->addWidget(widget);
}
Example #11
0
WTreeTable::WTreeTable()
{
  setImplementation(std::unique_ptr<WContainerWidget>(impl_ = new WContainerWidget()));

  setStyleClass("Wt-treetable");
  setPositionScheme(PositionScheme::Relative);

  headers_ = impl_->addWidget(cpp14::make_unique<WContainerWidget>());
  headers_->setStyleClass("Wt-header header");

  /*
   * spacer for when a scroll bar is visible
   */
  WContainerWidget *spacer
    = headers_->addWidget(cpp14::make_unique<WContainerWidget>());
  spacer->setStyleClass("Wt-sbspacer");

  headerContainer_
    = headers_->addWidget(cpp14::make_unique<WContainerWidget>());
  headerContainer_->setFloatSide(Side::Right);

  headers_->addWidget(cpp14::make_unique<WText>());
  columnWidths_.push_back(WLength::Auto);

  WContainerWidget *content
    = impl_->addWidget(cpp14::make_unique<WContainerWidget>());
  content->setStyleClass("Wt-content");
  if (!wApp->environment().agentIsIE())
    content->setOverflow(Overflow::Auto);
  else
    content->setAttributeValue
      ("style", "overflow-y: auto; overflow-x: hidden; zoom: 1");

  tree_ = content->addWidget(cpp14::make_unique<WTree>());
  tree_->setMargin(3, Side::Top);
  tree_->resize(WLength(100, LengthUnit::Percentage), WLength::Auto);
}
Example #12
0
WTreeTable::WTreeTable(WContainerWidget *parent)
  : WCompositeWidget(parent)
{
  setImplementation(impl_ = new WContainerWidget());

  setStyleClass("Wt-treetable");
  setPositionScheme(Relative);

  headers_ = new WContainerWidget(impl_);
  headers_->setStyleClass("Wt-header header");

  /*
   * spacer for when a scroll bar is visible
   */
  WContainerWidget *spacer = new WContainerWidget(headers_);
  spacer->setStyleClass("Wt-sbspacer");

  headerContainer_ = new WContainerWidget(headers_);
  headerContainer_->setFloatSide(Right);

  headers_->addWidget(new WText());
  columnWidths_.push_back(WLength::Auto);

  WContainerWidget *content = new WContainerWidget(impl_);
  content->setStyleClass("Wt-content");
  if (!wApp->environment().agentIsIE())
    content->setOverflow(WContainerWidget::OverflowAuto);
  else
    content->setAttributeValue
      ("style", "overflow-y: auto; overflow-x: hidden; zoom: 1");

  content->addWidget(tree_ = new WTree());

  tree_->setMargin(3, Top);
  tree_->resize(WLength(100, WLength::Percentage), WLength::Auto);
}
Example #13
0
LoginWidget::LoginWidget(WContainerWidget *parent):
  WCompositeWidget(parent)
{

    setImplementation(_impl = new WContainerWidget());
    _impl->setStyleClass("center-block");

    WContainerWidget *container = new WContainerWidget(_impl);
    container->setStyleClass("center");

    new WText("Name",container);

    WPushButton *login = new WPushButton("GO!!!",container);
    login->setStyleClass("button white");
    login->clicked().connect(this, &LoginWidget::emitt);
    //login->clicked().emit();


}
Example #14
0
File: Home.C Project: GuLinux/wt
WWidget *Home::quoteForm()
{
  WContainerWidget *result = new WContainerWidget();
  result->setStyleClass("quote");

  WTemplate *requestTemplate = new WTemplate(tr("quote.request"), result);

  WPushButton *quoteButton = new WPushButton(tr("quote.requestbutton"));
  requestTemplate->bindWidget("button", quoteButton);

  WWidget *quoteForm = createQuoteForm();
  result->addWidget(quoteForm);

  quoteButton->clicked().connect(quoteForm, &WWidget::show);
  quoteButton->clicked().connect(requestTemplate, &WWidget::hide);

  quoteForm->hide();

  return result;
}
Example #15
0
WWidget *StyleLayout::wBorderLayout()
{
  WContainerWidget *result = new WContainerWidget();
  topic("WBorderLayout", result);

  addText(tr("layout-WBorderLayout"), result);

  WContainerWidget *container;

  container = new WContainerWidget(result);
  container->resize(WLength::Auto, 400);
  container->setStyleClass("yellow-box");
  WBorderLayout *layout = new WBorderLayout();
  container->setLayout(layout);

  WText *item;

  item = addText(tr("borderlayout-item").arg("North"));
  item->setStyleClass("green-box");
  layout->addWidget(item, WBorderLayout::North);

  item = addText(tr("borderlayout-item").arg("West"));
  item->setStyleClass("green-box");
  layout->addWidget(item, WBorderLayout::West);

  item = addText(tr("borderlayout-item").arg("East"));
  item->setStyleClass("green-box");
  layout->addWidget(item, WBorderLayout::East);

  item = addText(tr("borderlayout-item").arg("South"));
  item->setStyleClass("green-box");
  layout->addWidget(item, WBorderLayout::South);

  item = addText(tr("borderlayout-item").arg("Center"));
  item->setStyleClass("green-box");
  layout->addWidget(item, WBorderLayout::Center);

  return result;
}
Example #16
0
WPopupMenu::WPopupMenu()
  : WCompositeWidget(),
    parentItem_(0),
    result_(0),
    location_(0),
    aboutToHide_(this),
    triggered_(this),
    cancel_(this, "cancel"),
    recursiveEventLoop_(false),
    autoHideDelay_(-1)
{
  const char *TEMPLATE =
    "${shadow-x1-x2}"
    "${contents}";

  setImplementation(impl_ = new WTemplate(WString::fromUTF8(TEMPLATE)));
  impl_->setLoadLaterWhenInvisible(false);

  setPositionScheme(Absolute);
  setStyleClass("Wt-popupmenu Wt-outset");

  impl_->bindString("shadow-x1-x2", WTemplate::DropShadow_x1_x2);
  WContainerWidget *content = new WContainerWidget();
  content->setStyleClass("content");
  impl_->bindWidget("contents", content);

  const char *CSS_RULES_NAME = "Wt::WPopupMenu";

  WApplication *app = WApplication::instance();

  if (!app->styleSheet().isDefined(CSS_RULES_NAME))
    app->styleSheet().addRule
      (".Wt-notselected .Wt-popupmenu", "visibility: hidden;", CSS_RULES_NAME);

  app->domRoot()->addWidget(this);

  hide();
}
Example #17
0
void Reports::createFooter()
{
    WContainerWidget *update_div = new WContainerWidget(this);
    update_div->setId("update_info");
    update_div->setStyleClass("update_info clear_inside");
    WContainerWidget *wc = new WContainerWidget(update_div);
    wc->setStyleClass("update");
    WContainerWidget *wcp = new WContainerWidget(update_div);

    WAnchor *update_kick = new WAnchor("javascript:void(0)", tr("update"),wc);
    //update_kick->setLink(WLink(WLink::InternalPath,"/update"));
    update_kick->show();
    update_kick->setId("update_report");
    update_kick->setStyleClass("debt");
    update_kick->clicked().connect(boost::bind(&Reports::changed, this, update_kick));
    new WText(tr("reports.updatebtn.footer"),wcp);
/*
    <div id="update_info" class="update_info clear_inside">
		<p class="update"><a class="debt" href="/user?mode=debt&amp;force_updates=1">Обновить данные</a></p>
		<p>*Чтоб посмотреть свежие данные на текущий момент, <br> рекомендуется нажать кнопку "Обновить данные"</p>
	</div>
*/
}
Example #18
0
void WToolBar::setCompact(bool compact)
{
  if (compact != compact_) {
    compact_ = compact;

    if (compact) {
      if (impl_->count() > 0)
	LOG_INFO("setCompact(true): not implemented");
      setStyleClass("btn-group");
    } else {
      setStyleClass("btn-toolbar");
      WContainerWidget *group = new WContainerWidget();
      group->setStyleClass("btn-group");
      while (impl_->count() > 0) {
	WWidget *w = impl_->widget(0);
	impl_->removeWidget(w);
	group->addWidget(w);
      }
      impl_->addWidget(group);
      lastGroup_ = group;
    }
  }
}
Example #19
0
void PaintedSlider::updateState()
{
  bool rtl = WApplication::instance()->layoutDirection() == RightToLeft;

  std::string resourcesURL = WApplication::resourcesUrl();

  Orientation o = slider_->orientation();

  handle_->setStyleClass("handle");

  if (o == Horizontal) {
    handle_->resize(HANDLE_WIDTH, h());
    handle_->setOffsets(0, Top);
  } else {
    handle_->resize(w(), HANDLE_WIDTH);
    handle_->setOffsets(0, Left);
  }

  double l = o == Horizontal ? w() : h();
  double pixelsPerUnit = (l - HANDLE_WIDTH) / range();

  std::string dir;
  if (o == Horizontal)
    dir = rtl ? "right" : "left";
  else
    dir = "top";
  std::string u = (o == Horizontal ? "x" : "y");
  std::string U = (o == Horizontal ? "X" : "Y");
  std::string maxS = boost::lexical_cast<std::string>(l - HANDLE_WIDTH);
  std::string ppU = boost::lexical_cast<std::string>(pixelsPerUnit);
  std::string minimumS = boost::lexical_cast<std::string>(slider_->minimum());
  std::string maximumS = boost::lexical_cast<std::string>(slider_->maximum());

  std::string width = boost::lexical_cast<std::string>(w());
  std::string horizontal = boost::lexical_cast<std::string>(o == Horizontal);

  /*
   * Note: cancelling the mouseDown event prevents the selection behaviour
   */
  std::string mouseDownJS = 
    """obj.setAttribute('down', " WT_CLASS ".widgetCoordinates(obj, event)."
    + u + "); "
    WT_CLASS ".cancelEvent(event);";

  // = 'u' position relative to background, corrected for slider
  std::string computeD =
    ""  "var objh = " + handle_->jsRef() + ","
    ""      "objb = " + jsRef() + ","
    ""      "page_u = WT.pageCoordinates(event)." + u + ","
    ""      "widget_page_u = WT.widgetPageCoordinates(objb)." + u + ","
    ""      "pos = page_u - widget_page_u,"
    ""      "rtl = " + boost::lexical_cast<std::string>(rtl) + ","
    ""      "horizontal = " + horizontal + ";"
    ""  "if (rtl && horizontal)"
    ""  "  pos = " + width + " - pos;"
    ""  "var d = pos - down;";
  

  std::string mouseMovedJS = 
    """var down = obj.getAttribute('down');"
    """var WT = " WT_CLASS ";"
    """if (down != null && down != '') {"
    + computeD +
    ""  "d = Math.max(0, Math.min(d, " + maxS + "));"
    ""  "var v = Math.round(d/" + ppU + ");"
    ""  "var intd = v*" + ppU + ";"
    ""  "if (Math.abs(WT.pxself(objh, '" + dir + "') - intd) > 1) {"
    ""    "objh.style." + dir + " = intd + 'px';" +
    slider_->sliderMoved().createCall(o == Horizontal ? "v + " + minimumS
				      : maximumS + " - v") + 
    ""  "}"
    """}";

  std::string mouseUpJS = 
    """var down = obj.getAttribute('down');"
    """var WT = " WT_CLASS ";"
    """if (down != null && down != '') {"
    + computeD +
    """d += " + boost::lexical_cast<std::string>(HANDLE_WIDTH / 2) + ";" +
    sliderReleased_.createCall("d") + 
    ""  "obj.removeAttribute('down');"
    """}";

  bool enabled = !slider_->isDisabled();
  
  mouseDownJS_.setJavaScript(std::string("function(obj, event) {") 
			     + (enabled ? mouseDownJS : "") 
			     + "}");
  mouseMovedJS_.setJavaScript(std::string("function(obj, event) {") 
			      + (enabled ? mouseMovedJS : "") 
			      + "}");
  mouseUpJS_.setJavaScript(std::string("function(obj, event) {") 
			   + (enabled ? mouseUpJS : "") 
			   + "}");

  update();
  updateSliderPosition();
}
Example #20
0
///
//  Constructor
//
LoginPage::LoginPage(WContainerWidget *parent) :
    WContainerWidget(parent),
    mLoggedIn(false),
    mLogoutRequested(false)
{
    setStyleClass("maindiv");

    WLabel* loginText = new WLabel("Enter username and password:"******"");
    WText *userNameText = new WText("User Name:");

    mPasswordLineEdit = new WLineEdit("");
    mPasswordLineEdit->setEchoMode(WLineEdit::Password);

    WText *passwordText = new WText("Password:"******"Login");

    WGridLayout *loginLayout = new WGridLayout();
    loginLayout->addWidget(userNameText, 0, 0, AlignRight);
    loginLayout->addWidget(mUserNameLineEdit, 0, 1, AlignLeft);
    loginLayout->addWidget(passwordText, 1, 0, AlignRight);
    loginLayout->addWidget(mPasswordLineEdit, 1, 1, AlignLeft);

    WGridLayout *textLayout = new WGridLayout();
    textLayout->addWidget(loginText, 0, 0, AlignCenter);

    WGridLayout *buttonLayout = new WGridLayout();
    buttonLayout->addWidget(loginButton, 0, 0, AlignCenter | AlignMiddle);

    WImage *chbLogo = new WImage(tr("logo-image").toUTF8());
    WGridLayout *chbLogoLayout = new WGridLayout();
    chbLogoLayout->addWidget(chbLogo, 0, 0, AlignCenter);

    WLabel *titleLabel = new WLabel(tr("page-top-text"));
    titleLabel->setStyleClass("logintitlediv");
    WGridLayout *titleLayout = new WGridLayout();
    titleLayout->addWidget(titleLabel, 0, 0, AlignCenter);

    WContainerWidget *loginContainer = new WContainerWidget();
    loginContainer->setStyleClass("logindiv");

    mFailureLabel = new WLabel("Invalid username and/or password.  Try again.");
    mFailureLabel->setStyleClass("redtext");

    WVBoxLayout *layout = new WVBoxLayout();
    layout->addLayout(chbLogoLayout, AlignCenter);
    layout->addLayout(titleLayout, AlignCenter);
    layout->addLayout(textLayout, AlignCenter);
    layout->addLayout(loginLayout);
    layout->addWidget(mFailureLabel);
    layout->addLayout(buttonLayout, AlignCenter | AlignMiddle);

    mFailureLabel->hide();

    loginContainer->setLayout(layout, AlignTop);

    WVBoxLayout *pageLayout = new WVBoxLayout();
    pageLayout->addWidget(loginContainer);
    pageLayout->addWidget(new WText(tr("login-page-text")));

    setLayout(pageLayout, AlignMiddle | AlignCenter);

    loginButton->clicked().connect(SLOT(this, LoginPage::login));
    mPasswordLineEdit->enterPressed().connect(SLOT(this, LoginPage::login));

    resetAll();
}
Example #21
0
///
//  Create the user interface widgets
//
void PipelineApp::createUI()
{
    WApplication::instance()->log("debug") << "createUI: START";
    WContainerWidget *w = root();
    w->setStyleClass("maindiv");

    // Create the top tab
    WTabWidget *topTab = new WTabWidget();
    topTab->setStyleClass("toptabdiv");
    mSubjectPage = new SubjectPage();
    //mResultsPage = new ResultsPage(mSubjectPage->getMRIBrowser());
    //mMonitorPage = new MonitorPage(mSubjectPage->getMRIBrowser());
    topTab->addTab(mSubjectPage, "Subjects");
    //topTab->addTab(mResultsPage, "Results");
    //topTab->addTab(mMonitorPage, "Monitor Cluster");
    //topTab->addTab(new WText(w->tr("cluster-load-page"), XHTMLUnsafeText), "Cluster Load");
    //topTab->currentChanged().connect(this, &PipelineApp::mainTabChanged);

    WGridLayout *layout = new WGridLayout();
    layout->addWidget(topTab, 0, 0);
    layout->addWidget(new WLabel(w->tr("file-bug")), 2, 0, Wt::AlignCenter);
    layout->setRowStretch(0, 1);

    mMainSiteWidget = new WContainerWidget();
    //mProjectPage = new ProjectPage();


    // All items in the tabbed widget need to be resized to 100% to
    // fill the contents.  This trick came from the Wt WTabWidget
    // documentation and took me a good half a day to figure out.
    mSubjectPage->resize(WLength(100.0, WLength::Percentage),
                         WLength(100.0, WLength::Percentage));
    //mResultsPage->resize(WLength(100.0, WLength::Percentage),
   //                      WLength(100.0, WLength::Percentage));
    //mMonitorPage->resize(WLength(100.0, WLength::Percentage),
      //                   WLength(100.0, WLength::Percentage));

    mMainSiteWidget->setLayout(layout);

    //mLoginPage = new LoginPage();
    //mLoginPage->userLoggedIn().connect(this, &PipelineApp::userLoggedIn);
    //mProjectPage->projectChosen().connect(this, &PipelineApp::projectChosen);
    //mProjectPage->logoutUser().connect(this, &PipelineApp::logout);
    //changeProjectButton->clicked().connect(this, &PipelineApp::goHome);
    //logoutButton->clicked().connect(this, &PipelineApp::logout);

    //mStackedWidget = new WStackedWidget();
    //mStackedWidget->addWidget(mLoginPage);
    //mStackedWidget->addWidget(mainSite);
    //mStackedWidget->setCurrentIndex(0);

    WVBoxLayout *primaryLayout = new WVBoxLayout();
    primaryLayout->addWidget(mMainSiteWidget);

    w->setLayout(primaryLayout);

    requestTooLarge().connect(this, &PipelineApp::largeRequest);

    setTitle(w->tr("page-title"));

    WApplication::instance()->log("debug") << "createUI: FINISH";

    // See if the user is already logged in via a cookie
//    if (mLoginPage->getLoggedIn())
   // {
     //   userLoggedIn(mLoginPage->getCurrentUserName(), mLoginPage->getCurrentEmail());
   // }
}
Example #22
0
void WDialog::create()
{
  closeIcon_ = 0;
  footer_ = 0;
  modal_ = true;
  resizable_ = false;
  recursiveEventLoop_ = false;
  impl_ = dynamic_cast<WTemplate *>(implementation());

  const char *CSS_RULES_NAME = "Wt::WDialog";

  WApplication *app = WApplication::instance();

  if (!app->styleSheet().isDefined(CSS_RULES_NAME)) {
    /* Needed for the dialog cover */
    if (app->environment().agentIsIElt(9))
      app->styleSheet().addRule("body", "height: 100%;");

    std::string position
      = app->environment().agent() == WEnvironment::IE6 ? "absolute" : "fixed";

    // we use left: 50%, top: 50%, margin hack when JavaScript is not available
    // see below for an IE workaround
    app->styleSheet().addRule("div.Wt-dialog", std::string() +
			      (app->environment().ajax() ?
			       "visibility: hidden;" : "") 
			      //"position: " + position + ';'
			      + (!app->environment().ajax() ?
				 "left: 50%; top: 50%;"
				 "margin-left: -100px; margin-top: -50px;" :
				 "left: 0px; top: 0px;"),
			      CSS_RULES_NAME);

    if (app->environment().agent() == WEnvironment::IE6) {
      app->styleSheet().addRule
	("div.Wt-dialogcover",
	 "position: absolute;"
	 "left: expression("
	 "(ignoreMe2 = document.documentElement.scrollLeft) + 'px' );"
	 "top: expression("
	 "(ignoreMe = document.documentElement.scrollTop) + 'px' );");

      // simulate position: fixed left: 50%; top 50%
      if (!app->environment().ajax())
	app->styleSheet().addRule
	  ("div.Wt-dialog",
	   "position: absolute;"
	   "left: expression("
	   "(ignoreMe2 = document.documentElement.scrollLeft + "
	   "document.documentElement.clientWidth/2) + 'px' );"
	   "top: expression("
	   "(ignoreMe = document.documentElement.scrollTop + "
	   "document.documentElement.clientHeight/2) + 'px' );");
    }
  }

  LOAD_JAVASCRIPT(app, "js/WDialog.js", "WDialog", wtjs1);

  WContainerWidget *layoutContainer = new WContainerWidget();
  layoutContainer->setStyleClass("dialog-layout");
  WVBoxLayout *layout = new WVBoxLayout(layoutContainer);
  layout->setContentsMargins(0, 0, 0, 0);
  layout->setSpacing(0);
  impl_->bindWidget("layout", layoutContainer);

  titleBar_ = new WContainerWidget();
  app->theme()->apply(this, titleBar_, DialogTitleBarRole);

  caption_ = new WText(titleBar_);
  caption_->setInline(false);
  
  contents_ = new WContainerWidget();
  app->theme()->apply(this, contents_, DialogBodyRole);

  layout->addWidget(titleBar_);
  layout->addWidget(contents_, 1);

  saveCoverState(app, app->dialogCover());

  /*
   * Cannot be done using the CSS stylesheet in case there are
   * contained elements with setHideWithOffsets() set
   *
   * For IE, we cannot set it yet since it will confuse width measurements
   * to become minimum size instead of (unconstrained) preferred size
   */
  if (app->environment().ajax()) {
    setAttributeValue("style", "visibility: hidden");

    /*
     * This is needed for animations only, but setting absolute or
     * fixed positioning confuses layout measurement in IE browsers
     */
    if (!app->environment().agentIsIElt(9))
      setPositionScheme(Fixed);
  } else
    setPositionScheme(app->environment().agent() == WEnvironment::IE6
		      ? Absolute : Fixed);
}
FtpUserController::FtpUserController( WContainerWidget *parent)
    : WContainerWidget(parent)
{

    //this->setStyleClass("");
    //this->addStyleClass("test1");

    //Define notification area
    //notificationArea = new Wt::WText("&nbsp;",this);
    //notificationArea->setStyleClass("notificationArea");

    //Define button to add ftp users
    WContainerWidget *addFtpUSerButtonContainer = new WContainerWidget(this);
    WPushButton *addFtpUserButton = new WPushButton("Add FTP user", addFtpUSerButtonContainer);
    addFtpUSerButtonContainer->setStyleClass("add_ftpuser_button");
    addFtpUserButton->setStyleClass("button orange bigrounded");

    //Define dialog to add ftp users
    this->wDialogAddFtpUser();
    addFtpUserButton->clicked().connect(this,&FtpUserController::showDialog);



    /**
      Add user form
      */

    /*

    WContainerWidget *addFtpUser = new WContainerWidget(this);
    WContainerWidget *dropDown = new WContainerWidget(addFtpUser);
    WContainerWidget *dropDownHead = new WContainerWidget(dropDown);
    WContainerWidget *dropDownBody = new WContainerWidget(dropDown);

    addFtpUser->setStyleClass("add_ftp_user");
    dropDown->setStyleClass("right");
    dropDownHead->setStyleClass("drop_down_head");
    dropDownBody->setStyleClass("drop_down_body");

    new WText("Add user", dropDownHead);
    dropDownBody->hide();

    WContainerWidget *arrow = new WContainerWidget(dropDownHead);
    arrow->setStyleClass("arrow-down");

*/

    /* --------------------- */



    //this->setStyleClass("ftp_controller");

    logindb = new LoginDB();
    std::vector <std::string> names = logindb->getKeys();
    FtpUser::init();

    std::vector<std::string>::iterator it;
    for(it = names.begin(); it < names.end(); it++)
        {
            //if( ! it->empty()) //TO-DO delete this line

            new FtpUser(*it,this);
            //users.push_back(new FtpUser(*it,this));

            /*
            new WText(*it, userList);
            new WLineEdit(userList);
            WPushButton *btn = new WPushButton("Modify name",userList);
            btn->clicked().connect(this,&MainPage::modifyEntry);

            new WBreak(userList);*/

        }

    _autofsc = new AutofsController();

    //new WBreak(this);


}
Example #24
0
WWidget *StyleLayout::wBoxLayout()
{
  WContainerWidget *result = new WContainerWidget();
  topic("WHBoxLayout", "WVBoxLayout", result);

  addText(tr("layout-WBoxLayout"), result);

  WContainerWidget *container;
  WText *item;
  WHBoxLayout *hbox;
  WVBoxLayout *vbox;

  /*
   * first hbox
   */
  container = new WContainerWidget(result);
  container->setStyleClass("yellow-box");
  hbox = new WHBoxLayout();
  container->setLayout(hbox);

  item = addText(tr("layout-item1"));
  item->setStyleClass("green-box");
  hbox->addWidget(item);
  
  item = addText(tr("layout-item2"));
  item->setStyleClass("blue-box");
  hbox->addWidget(item);

  addText(tr("layout-WBoxLayout-stretch"), result);

  /*
   * second hbox
   */
  container = new WContainerWidget(result);
  container->setStyleClass("yellow-box");
  hbox = new WHBoxLayout();
  container->setLayout(hbox);

  item = addText(tr("layout-item1"));
  item->setStyleClass("green-box");
  hbox->addWidget(item, 1);
  
  item = addText(tr("layout-item2"));
  item->setStyleClass("blue-box");
  hbox->addWidget(item);

  addText(tr("layout-WBoxLayout-vbox"), result);

  /*
   * first vbox
   */
  container = new WContainerWidget(result);
  container->resize(150, 150);
  container->setStyleClass("yellow-box centered");
  vbox = new WVBoxLayout();
  container->setLayout(vbox);

  item = addText(tr("layout-item1"));
  item->setStyleClass("green-box");
  vbox->addWidget(item);
  
  item = addText(tr("layout-item2"));
  item->setStyleClass("blue-box");
  vbox->addWidget(item);

  /*
   * second vbox
   */
  container = new WContainerWidget(result);
  container->resize(150, 150);
  container->setStyleClass("yellow-box centered");
  vbox = new WVBoxLayout();
  container->setLayout(vbox);

  item = addText(tr("layout-item1"));
  item->setStyleClass("green-box");
  vbox->addWidget(item, 1);
  
  item = addText(tr("layout-item2"));
  item->setStyleClass("blue-box");
  vbox->addWidget(item);

  addText(tr("layout-WBoxLayout-nested"), result);

  /*
   * nested boxes
   */
  container = new WContainerWidget(result);
  container->resize(200, 200);
  container->setStyleClass("yellow-box centered");

  vbox = new WVBoxLayout();
  container->setLayout(vbox);

  item = addText(tr("layout-item1"));
  item->setStyleClass("green-box");
  vbox->addWidget(item, 1);

  hbox = new WHBoxLayout();
  vbox->addLayout(hbox);

  item = addText(tr("layout-item2"));
  item->setStyleClass("green-box");
  hbox->addWidget(item);

  item = addText(tr("layout-item3"));
  item->setStyleClass("blue-box");
  hbox->addWidget(item);

  return result;
}