Пример #1
0
gdWSearch::gdWSearch(WContainerWidget* parent)
  : WContainerWidget(parent), m_leSearch(0), m_pImage(0)
{
  if ( WString::tr("byObjectStyleSheet").narrow() == "true" )
    wApp->useStyleSheet(wApp->theme()->resourcesUrl() + "gdwtcore/Css/gdWSearch.css");
  addStyleClass("gdWSearch");
  m_leSearch = new WLineEdit();
  m_leSearch->setTextSize(50);
  //  m_leSearch->resize(150, WLength::Auto);
  m_leSearch->enterPressed().connect(SLOT(this, gdWSearch::doSearch));
  m_leSearch->focussed().connect(SLOT(this, gdWSearch::doFocussed));
  m_leSearch->blurred().connect(SLOT(this, gdWSearch::doBlurred));
  m_pImage = new WImage();
  m_pImage->setImageRef(wApp->theme()->resourcesUrl() + "gdwtcore/Icons/Loupe.png");
  gdImageProperties imgProp = gdImage_size(wApp->docRoot() + m_pImage->imageRef());
  m_pImage->setWidth(WLength(imgProp.width, WLength::Pixel));
  m_pImage->setHeight(WLength(imgProp.height, WLength::Pixel));
  m_pImage->clicked().connect(SLOT(this, gdWSearch::doSearch));
  if ( 0 ) {
    WHBoxLayout* hbox = new WHBoxLayout();
    hbox->addWidget(m_leSearch, 1);
    hbox->addWidget(m_pImage, 0);
    setLayout(hbox);
  } else {
    addWidget(m_leSearch);
    //     addWidget(m_pImage);
  }
}
Пример #2
0
void SimpleChatWidget::letLogin()
{
  disconnect();

  clear();

  WVBoxLayout *vLayout = new WVBoxLayout();
  setLayout(vLayout, AlignLeft | AlignTop);

  WHBoxLayout *hLayout = new WHBoxLayout();
  vLayout->addLayout(hLayout);

  hLayout->addWidget(new WLabel("User name:"), 0, AlignMiddle);
  hLayout->addWidget(userNameEdit_ = new WLineEdit(user_), 0, AlignMiddle);
  userNameEdit_->setFocus();

  WPushButton *b = new WPushButton("Login");
  hLayout->addWidget(b, 0, AlignMiddle);

  b->clicked().connect(this, &SimpleChatWidget::login);
  userNameEdit_->enterPressed().connect(this, &SimpleChatWidget::login);

  vLayout->addWidget(statusMsg_ = new WText());
  statusMsg_->setTextFormat(PlainText);
}
Пример #3
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;
}
Пример #4
0
void SimpleChatWidget::createLayout(WWidget *messages, WWidget *userList,
				    WWidget *messageEdit,
				    WWidget *sendButton, WWidget *logoutButton)
{
  /*
   * Create a vertical layout, which will hold 3 rows,
   * organized like this:
   *
   * WVBoxLayout
   * --------------------------------------------
   * | nested WHBoxLayout (vertical stretch=1)  |
   * |                              |           |
   * |  messages                    | userList  |
   * |   (horizontal stretch=1)     |           |
   * |                              |           |
   * --------------------------------------------
   * | message edit area                        |
   * --------------------------------------------
   * | WHBoxLayout                              |
   * | send | logout                            |
   * --------------------------------------------
   */
  WVBoxLayout *vLayout = new WVBoxLayout();

  // Create a horizontal layout for the messages | userslist.
  WHBoxLayout *hLayout = new WHBoxLayout();

  // Add widget to horizontal layout with stretch = 1
  hLayout->addWidget(messages, 1);
  messages->setStyleClass("chat-msgs");

    // Add another widget to horizontal layout with stretch = 0
  hLayout->addWidget(userList);
  userList->setStyleClass("chat-users");

  hLayout->setResizable(0, true);

  // Add nested layout to vertical layout with stretch = 1
  vLayout->addLayout(hLayout, 1);

  // Add widget to vertical layout with stretch = 0
  vLayout->addWidget(messageEdit);
  messageEdit->setStyleClass("chat-noedit");

  // Create a horizontal layout for the buttons.
  hLayout = new WHBoxLayout();

  // Add button to horizontal layout with stretch = 0
  hLayout->addWidget(sendButton);

  // Add button to horizontal layout with stretch = 0
  hLayout->addWidget(logoutButton);

  // Add nested layout to vertical layout with stretch = 0
  vLayout->addLayout(hLayout, 0, AlignLeft);

  setLayout(vLayout);
}
Пример #5
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;
}
Пример #6
0
///
//  Constructor
//
ResultsPage::ResultsPage(const MRIBrowser *mriBrowser, WContainerWidget *parent) :
    mMRIBrowser(mriBrowser),
    WContainerWidget(parent)
{
    setStyleClass("tabdiv");

    mResultsTable = new ResultsTable();

    WContainerWidget *browserContainer = new WContainerWidget();
    WContainerWidget *resultsContainer = new WContainerWidget;

    WText *showText = new WText("Show Results by User:"******"<user>");
    mUserComboBox->addItem("All");

    mSearchLineEdit = new WLineEdit("");
    mSearchLineEdit->setMinimumSize(150, WLength::Auto);
    mSearchLineEdit->resize(150, WLength::Auto);

    mSearchPushButton = new WPushButton("GO");
    WPushButton *clearButton = new WPushButton("Clear");
    WPushButton *refreshButton = new WPushButton("Refresh");

    userBox->addWidget(new WText("Search:"), 0, 2, AlignRight | AlignMiddle);
    userBox->addWidget(mSearchLineEdit, 0, 3, AlignLeft| AlignMiddle);
    userBox->addWidget(mSearchPushButton, 0, 4, AlignLeft | AlignMiddle);
    userBox->addWidget(clearButton, 0, 5, AlignLeft | AlignMiddle);
    userBox->addWidget(refreshButton, 0, 6, AlignRight | AlignMiddle);
    userBox->setColumnStretch(2, 1);
    userBox->setColumnStretch(6, 1);
    userBox->setColumnStretch(7, 3);

    mPipelineArgTable = new PipelineArgTable();
    mPipelineArgTable->resize(WLength::Auto, 150);
    mPipelineArgTable->setMinimumSize(WLength::Auto,
                                      WLength(150, WLength::Pixel));
    mPipelineArgTable->setMaximumSize(WLength::Auto,
                                      WLength(150, WLength::Pixel));

    mJobStatus = new JobStatus();
    WHBoxLayout *bottomLayout = new WHBoxLayout();
    bottomLayout->addWidget(mPipelineArgTable);
    bottomLayout->addWidget(mJobStatus);



    WGridLayout *browserLayout = new WGridLayout();
    browserLayout->addLayout(userBox, 0, 0);
    browserLayout->addWidget(mResultsTable, 1, 0);
    browserLayout->addLayout(bottomLayout, 2, 0);
    browserLayout->setRowStretch(0, -1);
    browserLayout->setRowStretch(1, 1);
    browserLayout->setRowStretch(2, -1);
    browserContainer->setLayout(browserLayout);


    mBackButton = new WPushButton("<- Back");

    WTabWidget *tabWidget = new WTabWidget();
    tabWidget->setStyleClass("toptabdiv");
    mMonitorLogTab = new MonitorLogTab(mriBrowser);
    mMonitorResultsTab = new MonitorResultsTab(mriBrowser);
    tabWidget->addTab(mMonitorResultsTab, "Results");
    tabWidget->addTab(mMonitorLogTab, "Logs");

    WGridLayout *resultsLayout = new WGridLayout();
    resultsLayout->addWidget(mBackButton, 0, 0, AlignLeft | AlignMiddle);
    resultsLayout->addWidget(tabWidget, 1, 0);
    resultsLayout->setRowStretch(0, -1);
    resultsLayout->setRowStretch(1, 1);
    resultsContainer->setLayout(resultsLayout);

    mStackedWidget = new WStackedWidget();
    mStackedWidget->addWidget(browserContainer);
    mStackedWidget->addWidget(resultsContainer);

    WGridLayout *layout = new WGridLayout();
    layout->addWidget(mStackedWidget, 0, 0);
    layout->setRowStretch(0, -1);
    setLayout(layout);

    mUserComboBox->activated().connect(SLOT(this, ResultsPage::userChanged));
    mSearchPushButton->clicked().connect(SLOT(this, ResultsPage::searchPushed));
    clearButton->clicked().connect(SLOT(this, ResultsPage::clearPushed));
    mResultsTable->resultSelected().connect(SLOT(this, ResultsPage::resultSelected));
    mResultsTable->resultClicked().connect(SLOT(this, ResultsPage::resultClicked));
    mBackButton->clicked().connect(SLOT(this, ResultsPage::backPushed));
    refreshButton->clicked().connect(SLOT(this, ResultsPage::refreshClicked));

    // 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.
    mMonitorLogTab->resize(WLength(100, WLength::Percentage),
                           WLength(100, WLength::Percentage));
    mMonitorResultsTab->resize(WLength(100, WLength::Percentage),
                               WLength(100, WLength::Percentage));
}
Пример #7
0
  /*! \brief Constructor.
   */
  GitViewApplication(const WEnvironment& env) 
    : WApplication(env)
  {
    useStyleSheet("gitview.css");
    setTitle("Git model example");

    const char *gitRepo = getenv("GITVIEW_REPOSITORY_PATH");

    WGridLayout *grid = new WGridLayout();
    grid->addWidget(new WText("Git repository path:"), 0, 0);
    grid->addWidget(repositoryEdit_ = new WLineEdit(gitRepo ? gitRepo : "")
		    , 0, 1, AlignLeft);
    grid->addWidget(repositoryError_ = new WText(), 0, 2);
    grid->addWidget(new WText("Revision:"), 1, 0);
    grid->addWidget(revisionEdit_ = new WLineEdit("master"), 1, 1, AlignLeft);
    grid->addWidget(revisionError_ = new WText(), 1, 2);

    repositoryEdit_->setTextSize(30);
    revisionEdit_->setTextSize(20);
    repositoryError_->setStyleClass("error-msg");
    revisionError_->setStyleClass("error-msg");

    repositoryEdit_->enterPressed()
      .connect(this, &GitViewApplication::loadGitModel);
    revisionEdit_->enterPressed()
      .connect(this, &GitViewApplication::loadGitModel);

    WPushButton *b = new WPushButton("Load");
    b->clicked().connect(this, &GitViewApplication::loadGitModel);
    grid->addWidget(b, 2, 0, AlignLeft);

    gitView_ = new WTreeView();
    gitView_->resize(300, WLength::Auto);
    gitView_->setSortingEnabled(false);
    gitView_->setModel(gitModel_ = new GitModel(this));
    gitView_->setSelectionMode(SingleSelection);
    gitView_->selectionChanged().connect(this, &GitViewApplication::showFile);

    sourceView_ = new SourceView(DisplayRole, 
				 GitModel::ContentsRole, 
				 GitModel::FilePathRole);
    sourceView_->setStyleClass("source-view");

    if (environment().javaScript()) {
      /*
       * We have JavaScript: We can use layout managers so everything will
       * always fit nicely in the window.
       */
      WVBoxLayout *topLayout = new WVBoxLayout();
      topLayout->addLayout(grid, 0, AlignTop | AlignLeft);

      WHBoxLayout *gitLayout = new WHBoxLayout();
      gitLayout->setLayoutHint("table-layout", "fixed");
      gitLayout->addWidget(gitView_, 0);
      gitLayout->addWidget(sourceView_, 1);
      topLayout->addLayout(gitLayout, 1);

      root()->setLayout(topLayout);
      root()->setStyleClass("maindiv");
    } else {
      /*
       * No JavaScript: let's make the best of the situation using regular
       * CSS-based layout
       */
      root()->setStyleClass("maindiv");
      WContainerWidget *top = new WContainerWidget();
      top->setLayout(grid, AlignTop | AlignLeft);
      root()->addWidget(top);
      root()->addWidget(gitView_);
      gitView_->setFloatSide(Left);
      gitView_->setMargin(6);
      root()->addWidget(sourceView_);
      sourceView_->setMargin(6);
    }
  }
Пример #8
0
Example::Example(WContainerWidget* p):
    WContainerWidget(p) {
    WContainerWidget* cw = new WContainerWidget(this);
    WHBoxLayout* hl = new WHBoxLayout();
    mv_ = new MapViewer();
    mv_->resize(400, 300);
    mv_->set_center(Coordinate(54.8, 20.25), 9);
    mv_->clicked().connect(this, &Example::get_pos);
    hl->addWidget(mv_, 0, AlignTop);
    //
    WPushButton* to_left = new Wt::WPushButton("<");
    WPushButton* to_right = new Wt::WPushButton(">");
    to_left->clicked().connect(this, &Example::left_shift);
    to_right->clicked().connect(this, &Example::right_shift);
    WPushButton* to_top = new Wt::WPushButton("^");
    WPushButton* to_bottom = new Wt::WPushButton("v");
    to_top->clicked().connect(this, &Example::top_shift);
    to_bottom->clicked().connect(this, &Example::bottom_shift);
    //
    WPushButton* zoom_in = new Wt::WPushButton("zoom In");
    WPushButton* zoom_out = new Wt::WPushButton("zoom Out");
    zoom_in->clicked().connect(mv_, &MapViewer::zoom_in);
    zoom_out->clicked().connect(mv_, &MapViewer::zoom_out);
    //
    WContainerWidget* cw_of_zoom_to = new Wt::WContainerWidget();
    WLabel* label_of_zoom_to = new Wt::WLabel("set zoom:", cw_of_zoom_to);
    edit_of_zoom_to_ = new WLineEdit("9", cw_of_zoom_to);
    edit_of_zoom_to_->resize(30, WLength());
    label_of_zoom_to->setBuddy(edit_of_zoom_to_);
    edit_of_zoom_to_->setValidator(new WIntValidator(1, 17));
    label_of_zoom_to->setBuddy(edit_of_zoom_to_);
    WHBoxLayout* menu_hl_of_zoom_to = new WHBoxLayout();
    menu_hl_of_zoom_to->addWidget(cw_of_zoom_to, 0, AlignJustify);
    WContainerWidget* zoom_to_b_cw = new WContainerWidget();
    WPushButton* button_of_zoom_to = new Wt::WPushButton("OK", zoom_to_b_cw);
    button_of_zoom_to->clicked().connect(this, &Example::set_zoom_to);
    menu_hl_of_zoom_to->addWidget(zoom_to_b_cw, AlignJustify);
    //
    WContainerWidget* cw_of_pan_to_lng = new Wt::WContainerWidget();
    WContainerWidget* cw_of_pan_to_lat = new Wt::WContainerWidget();
    WLabel* label_of_pan_to_lng = new Wt::WLabel("set lng:", cw_of_pan_to_lng);
    WLabel* label_of_pan_to_lat = new Wt::WLabel("set lat:", cw_of_pan_to_lat);
    edit_of_pan_to_lng_ = new WLineEdit("20.4", cw_of_pan_to_lng);
    edit_of_pan_to_lng_->resize(50, WLength());
    label_of_pan_to_lng->setBuddy(edit_of_pan_to_lng_);
    edit_of_pan_to_lng_->setValidator(new WDoubleValidator(-180.0, 180.0));
    label_of_pan_to_lng->setBuddy(edit_of_pan_to_lng_);
    edit_of_pan_to_lat_ = new WLineEdit("54.7167", cw_of_pan_to_lat);
    edit_of_pan_to_lat_->resize(50, WLength());
    label_of_pan_to_lat->setBuddy(edit_of_pan_to_lat_);
    edit_of_pan_to_lat_->setValidator(new WDoubleValidator(-90.0, 90.0));
    label_of_pan_to_lat->setBuddy(edit_of_pan_to_lat_);
    WHBoxLayout* menu_hl_of_pan_to = new WHBoxLayout();
    menu_hl_of_pan_to->addWidget(cw_of_pan_to_lng, 0, AlignTop);
    menu_hl_of_pan_to->addWidget(cw_of_pan_to_lat, 0, AlignTop);
    WContainerWidget* pan_to_b_cw = new WContainerWidget();
    WPushButton* button_of_pan_to = new Wt::WPushButton("OK", pan_to_b_cw);
    button_of_pan_to->clicked().connect(this, &Example::set_pan_to);
    menu_hl_of_pan_to->addWidget(pan_to_b_cw, AlignTop);
    //
    click_pos_ = new WText();
    click_search_ = new WText();
    time_zone_ = new WText();
    //
    WVBoxLayout* vl_menu = new WVBoxLayout();
    WHBoxLayout* hl_menu_zooms = new WHBoxLayout();
    hl_menu_zooms->addWidget(zoom_in, 0, AlignTop);
    hl_menu_zooms->addWidget(zoom_out, 0, AlignTop);
    WGridLayout* shift_hl_menu = new WGridLayout();
    shift_hl_menu->addWidget(to_top, 0, 1, AlignTop);
    shift_hl_menu->addWidget(to_left, 1, 0, AlignTop);
    shift_hl_menu->addWidget(to_right, 1, 2, AlignTop);
    shift_hl_menu->addWidget(to_bottom, 2, 1, AlignTop);
    //
    WVBoxLayout* s_vl = new WVBoxLayout();
    WHBoxLayout* s_hl = new WHBoxLayout();
    WContainerWidget* s_cw = new WContainerWidget();
    s_cw->resize(220, 300);
    s_cw->setHidden(true);
    wApp->styleSheet().addRule(".mvSearchNode", "background-color:#e1d0d0;");
    wApp->styleSheet().addRule(".mvSearchText", "font-size:12px;");
    WContainerWidget* s_e_cw = new WContainerWidget();
    WLineEdit* s_edit = new WLineEdit("search", s_e_cw);
    s_edit->enterPressed().connect(boost::bind(&Example::search_pr, this,
                                   s_edit));
    WContainerWidget* s_b_cw = new WContainerWidget();
    s_b_cw->setContentAlignment(AlignLeft);
    WPushButton* s_button = new WPushButton("OK", s_b_cw);
    s_button->clicked().connect(boost::bind(&Example::search_pr, this,
                                            s_edit));
    s_hl->addWidget(s_e_cw, 0, AlignRight);
    s_hl->addWidget(s_b_cw, 0, AlignLeft);
    s_vl->addLayout(s_hl, 0, AlignTop);
    s_vl->addWidget(s_cw, 0, AlignTop);
    //
    mv_->found().connect(boost::bind(&Example::search_presenting,
                                     this, s_cw, _1));
    //
    vl_menu->addLayout(shift_hl_menu, 0, AlignTop);
    vl_menu->addLayout(hl_menu_zooms, 0, AlignTop);
    vl_menu->addLayout(menu_hl_of_zoom_to, 0, AlignJustify);
    vl_menu->addLayout(menu_hl_of_pan_to, 0, AlignTop);
    vl_menu->addWidget(click_pos_, 0, AlignTop);
    vl_menu->addWidget(click_search_, 0, AlignTop);
    vl_menu->addWidget(time_zone_, 0, AlignTop);
    hl->addLayout(vl_menu, 0, AlignTop);
    hl->addLayout(s_vl, 0, AlignTop);
    cw->setLayout(hl, AlignTop);
    mv_->set_search_panel();
    mv_->chosen().connect(this, &Example::get_search);
    MapViewer::GeoNodes marker_nodes;
    marker_nodes.push_back(std::make_pair(Coordinate(55.0151, 20.6122),
                                          ""));
    marker_nodes.push_back(std::make_pair(Coordinate(54.8, 20.25),
                                          ""));
    mv_->add_markers(marker_nodes);
}