Пример #1
0
WebUi::WebUi(WApplication *app) :
    AbstractUi(),
    m_app(app)
{
    app->setTitle("Quassel web interface");
    WVBoxLayout *layout = new WVBoxLayout;
    app->root()->setLayout(layout);
    
    /*m_loginButton = new WPushButton("Connect");
    m_loginButton->clicked().connect(this, &WebUi::connect);
    layout->addWidget(m_loginButton);*/

    _chatView = new WTableView(app->root());
    layout->addWidget(_chatView);

    _inputWidget = new WLineEdit(app->root());
    layout->addWidget(_inputWidget);
    

    QObject::connect(Client::coreConnection(), SIGNAL(userAuthenticationRequired(CoreAccount*,bool*,QString)), SLOT(userAuthenticationRequired(CoreAccount*,bool*,QString)));
    QObject::connect(Client::coreConnection(), SIGNAL(connectionMsg(QString)), SLOT(printMsg(QString)));
    QObject::connect(Client::coreConnection(), SIGNAL(progressTextChanged(QString)), SLOT(printMsg(QString)));
    QObject::connect(Client::coreConnection(), SIGNAL(connectionError(QString)), SLOT(printMsg(QString)));
    QObject::connect(Client::coreConnection(), SIGNAL(connectionErrorPopup(QString)), SLOT(printMsg(QString)));
    //QObject::connect(Client::coreConnection(), SIGNAL(userAuthenticationRequired(CoreAccount*,bool*,QString)), SLOT(userAuthenticationRequired(CoreAccount*,bool*,QString)));
    //Client::coreAccountModel()->load();
    //if (!Client::coreConnection()->connectToCore()) {
        bool ok;
        userAuthenticationRequired(0, &ok, "");
    //}
}
Пример #2
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);
  }
Пример #3
0
///
//  Constructor
//
ResultsTable::ResultsTable(WContainerWidget *parent) :
    WContainerWidget(parent),
    mSortFilterProxyModel(NULL)
{
    setStyleClass("tabdiv");

    mModel = new WStandardItemModel(this);
    mModel->insertColumns(0, 11);
    mModel->setHeaderData(0, boost::any(WString::fromUTF8("Date")));
    mModel->setHeaderData(1, boost::any(WString::fromUTF8("User")));
    mModel->setHeaderData(2, boost::any(WString::fromUTF8("MRID")));
    mModel->setHeaderData(3, boost::any(WString::fromUTF8("Name")));
    mModel->setHeaderData(4, boost::any(WString::fromUTF8("Scan Name")));
    mModel->setHeaderData(5, boost::any(WString::fromUTF8("Birthday")));
    mModel->setHeaderData(6, boost::any(WString::fromUTF8("Scan Date")));
    mModel->setHeaderData(7, boost::any(WString::fromUTF8("Manufacturer")));
    mModel->setHeaderData(8, boost::any(WString::fromUTF8("Model")));
    mModel->setHeaderData(9, boost::any(WString::fromUTF8("Software Ver")));
    mModel->setHeaderData(10, boost::any(WString::fromUTF8("Pipeline")));
    mModel->invisibleRootItem()->setRowCount(0);

    mTreeView = new WTreeView();
    mTreeView->setRootIsDecorated(false);
    mTreeView->setAlternatingRowColors(true);
    mTreeView->setSelectionMode(SingleSelection);
    mTreeView->doubleClicked().connect(SLOT(this, ResultsTable::jobSelected));
    mTreeView->clicked().connect(SLOT(this, ResultsTable::jobClicked));

    WVBoxLayout *layout = new WVBoxLayout();
    layout->addWidget(mTreeView);

    setLayout(layout);

    resetAll();
}
Пример #4
0
void WsContent::doEditPage(std::string path)
{
  std::string newPath = path;
  boost::algorithm::replace_first(newPath, "/Edit", "");
  boost::algorithm::replace_first(newPath, "/SiteMap", "");
  std::string sPathWithoutPrefix = WsApp->WsModules().pathWithoutPrefix(newPath); // ex. /SiteMap
  std::string     sysPath(m_sDocumentRoot + sPathWithoutPrefix);
  WsUser*         pUser       = WsApp->wsUser();
  NodePtr         pNode       = pUser->getAccessRoot()->eatPath(sPathWithoutPrefix);
  if (!pNode.get() ) {
    addWidget(new WsErrorPage(WsErrorPage::Error, path, pUser, "Returned node is null"));
    return;
  }
  clear();
  setOverflow(WContainerWidget::OverflowAuto);
  WVBoxLayout* vbox = new WVBoxLayout();
  setLayout(vbox);
  WsFormConfig* m_formConfig = new WsFormConfig(pNode, WsApp->WsModules());
  vbox->addWidget(m_formConfig, 0);
  vbox->addWidget(WsApp->WsModules().module("WsModEditorUploader")->createContents());
  std::string     strExt(boost::filesystem::extension(sPathWithoutPrefix));
  if ( strExt == ".fhtml" ) {
    if ( !gdcore_isPathFile(sysPath) ) return;
    gdFHtmlEditor* pEditor = new gdFHtmlEditor("", false);
    pEditor->setCurrentPath(sysPath);
    pEditor->readFile();
    m_formConfig->setEditorFhtml(pEditor);
    pEditor->resize(WLength(100, WLength::Percentage), WLength(400));
    vbox->addWidget(pEditor, 1);
  }
}
Пример #5
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);
}
Пример #6
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);
}
Пример #7
0
void Example::search_presenting(WContainerWidget* cw,
                                const MapViewer::GeoNodes& nodes) {
    WContainerWidget* cw_n = new WContainerWidget();
    WVBoxLayout* vl = new WVBoxLayout();
    BOOST_FOREACH (MapViewer::GeoNode node, nodes) {
        Coordinate& pos = node.first;
        vl->addWidget(new WText(node.second + "<br />" +
                                str(boost::format("%.4f %.4f")
                                    % pos.longitude() % pos.latitude())),
                      AlignTop);
    }
Пример #8
0
void AdsEditor::renderUI() {
  AdsApplication *app = AdsApplication::adsApplication();
  cppdb::session &db = app->db_;
  
  clear();
  WPushButton *btn = new WPushButton("Criar Anuncio", this);
  btn->clicked().connect(this, &AdsEditor::novoAnuncio);
  WPushButton *update = new WPushButton("Atualiza", this);
  update->clicked().connect(this, &AdsEditor::renderUI);
  new WBreak(this);
  new WBreak(this);
  new WText("<h3>Lista de Anuncios</h3>",this);
  
  Wt::WContainerWidget *w = new Wt::WContainerWidget(this);
  w->resize(600, WLength::Auto);
  WVBoxLayout *layout = new Wt::WVBoxLayout();
  cppdb::result res = db <<
    "select id, titulo, url, imagem, texto, ativo "
    " from anuncio";
  while(res.next()) {
    WContainerWidget *cont = new WContainerWidget();
    AdsAnuncio *anuncio = new AdsAnuncio(cont);
    
    res >>  anuncio->id >> anuncio->titulo_ >> anuncio->link_ >>
      anuncio->imagem_ >> anuncio->texto_ >> anuncio->ativo_;    
    
    WPushButton *tituloBtn = new WPushButton("Titulo",cont);
    tituloBtn->clicked().connect(anuncio, &AdsAnuncio::editarTitulo);
    
    WPushButton *urlBtn = new WPushButton("URL",cont);
    urlBtn->clicked().connect(anuncio, &AdsAnuncio::editarURL);
    
    WPushButton *imagemBtn = new WPushButton("Imagem",cont);
    imagemBtn->clicked().connect(anuncio, &AdsAnuncio::editarImagem);
    
    WPushButton *textoBtn = new WPushButton("Texto",cont);
    textoBtn->clicked().connect(anuncio, &AdsAnuncio::editarTexto);
    
    WCheckBox *ativoCheck = new Wt::WCheckBox("Ativo",cont);
    if(anuncio->ativo_ == 1)
      ativoCheck->setChecked(true);
    else 
      ativoCheck->setChecked(false);
    ativoCheck->changed().connect(anuncio, &AdsAnuncio::changeAtiva);

    WPushButton *deletaBtn = new WPushButton("Deleta",cont);
    deletaBtn->clicked().connect(anuncio, &AdsAnuncio::deletaAnuncio);

    anuncio->renderUI();
    layout->addWidget(cont);
  }
  w->setLayout(layout);
}
Пример #9
0
void gdContainerBar::init()
{
  makeToolbar();
  WVBoxLayout*       vbox = new WVBoxLayout();
  if ( !m_pPanel || !m_pPanel->titleBar() )
    vbox->addWidget(m_pToolBar,  0);
  //   else
  //     m_pPanel->titleBarWidget()->addWidget(m_pToolBar);
  vbox->addWidget(m_pView, 1);
  resize(WLength(100, WLength::Percentage), WLength(100, WLength::Percentage));
  setOverflow(WContainerWidget::OverflowHidden);
  setLayout(vbox);
  view()->model()->rowsInserted().connect(SLOT(this, gdContainerBar::doModelRowCountChanged));
  view()->model()->rowsRemoved() .connect(SLOT(this, gdContainerBar::doModelRowCountChanged));
}
Пример #10
0
///
//  Constructor
//
MonitorPage::MonitorPage(const MRIBrowser *mriBrowser,
                         WContainerWidget *parent) :
    WContainerWidget(parent),
    mMRIBrowser(mriBrowser)
{
    setStyleClass("tabdiv");

    WGridLayout *layout = new WGridLayout();
    layout->addWidget(createTitle("Cluster Jobs"), 0, 0);

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

    WVBoxLayout *clusterJobsLayout = new WVBoxLayout();
    mClusterJobBrowser = new ClusterJobBrowser();
    mPatientInfoBox = new PatientInfoBox();
    mPatientInfoBox->setStyleClass("verysmallgroupdiv");

    clusterJobsLayout->addWidget(mClusterJobBrowser);
    clusterJobsLayout->addWidget(mPatientInfoBox);

    layout->addLayout(clusterJobsLayout, 1, 0);


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

    setLayout(layout);

    // Make connections
    mClusterJobBrowser->clusterJobSelected().connect(SLOT(this, MonitorPage::jobSelectedChanged));

    // 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));

}
Пример #11
0
Файл: Home.C Проект: GuLinux/wt
void Home::setup()
{
  /*
   * This function switches between the two major components of the homepage,
   * depending on the internal path:
   * /src -> source viewer
   * /... -> homepage
   *
   * FIXME: we should take into account language /cn/src ...
   */
  std::string base = internalPathNextPart("/");

  if (base == SRC_INTERNAL_PATH) {
    if (!sourceViewer_) {
      delete homePage_;
      homePage_ = 0;

      root()->clear();

      sourceViewer_ = sourceViewer("/" + SRC_INTERNAL_PATH + "/");
      WVBoxLayout *layout = new WVBoxLayout();
      layout->setContentsMargins(0, 0, 0, 0);
      layout->addWidget(sourceViewer_);
      root()->setLayout(layout);
    }
  } else {
    if (!homePage_) {
      delete sourceViewer_;
      sourceViewer_ = 0;

      root()->clear();

      createHome();
      root()->addWidget(homePage_);

      setLanguageFromPath();
    }
  }
}
HydrovoltsConnectChartView::HydrovoltsConnectChartView(
    HydrovoltsConnectModel* pModel,
    WContainerWidget* parent):
    WContainerWidget(parent),
    m_y1(HydrovoltsConnectModel::COL_POWER),
    m_y2(HydrovoltsConnectModel::COL_POWER, LineSeries, Y2Axis)
{
    m_pModel = pModel;
    resize(WLength::Auto, 600);
    //resize(WLength::Auto, WLength::Auto);

    setStyleClass("layoutdiv");
    CreateChart();
    HydrovoltsConnectChartToolbar* pToolbar = new HydrovoltsConnectChartToolbar( m_pModel, this);
    pToolbar->y1Changed().connect(this, &HydrovoltsConnectChartView::OnY1Changed);
    pToolbar->y2Changed().connect(this, &HydrovoltsConnectChartView::OnY2Changed);

    WVBoxLayout *pLayout = new WVBoxLayout();

    if (pLayout != NULL && m_pChart != NULL && pToolbar != NULL)
    {

        setWidth(WLength::Auto);

        // Toolbar
        pLayout->addWidget(pToolbar);
        pLayout->setStretchFactor(pToolbar, 0);

        // Chart
        pLayout->addWidget(m_pChart);
        pLayout->setStretchFactor(m_pChart,100);
        //pLayout->setRowStretch();
        //pLayout->setColumnStretch();

        setLayoutSizeAware(true);
        setLayout(pLayout);
    }
}
Пример #13
0
void WsContent::viewDirectory(const std::string& path)
{
  WsUser*         pUser        = WsApp->wsUser();
  NodePtr pRootNode    = pUser->getAccessRoot();
  if ( !pRootNode ) {
    wApp->log("notice") <<  "WsContent::viewDirectory() : Path = " << path << ", getAccessRoot() is null";
    return;
  }
  NodePtr pNode        = pRootNode.get()->eatPath(path);
  if ( !pNode.get() ) {
    wApp->log("notice") <<  "WsContent::viewDirectory() : Path = " << path << ", getAccessRoot() eatPath is null";
    return;
  }
  std::string     sInitPage    = pNode.get()->getProperties().get()->get("global", "initial_page", "");
  if ( sInitPage.size() > 0 ) {
    std::string newPage =  pNode.get()->getPath().string() + "/" + sInitPage;
    wApp->log("notice") <<  "WsContent::viewDirectory() : set initial page to " << newPage;
    return wApp->setInternalPath(newPage, true);
  }
  clear();
  if ( !(pUser->isAdministrator() || pUser->isEditor()) )
    if ( WsLayoutProperties::instance()->get("global", "use_content_directory_view", "false") == "false" ) return;
  WsApp->hideImages(false);
  WWidget* w = WsApp->WsModules().module("WsModDirectoryView2")->createContents();
  WsOptions* wOpt = dynamic_cast<WsOptions*>(w);
  wOpt->setOption("rootPath", path);
  if ( 0 ) {
    WVBoxLayout*  vBox = new WVBoxLayout();
    vBox->addWidget(w, 1);
    setLayout(vBox);
    setOverflow(WContainerWidget::OverflowHidden);
  } else {
    addWidget(w);
    setOverflow(WContainerWidget::OverflowAuto);
  }
}
Пример #14
0
void WsContent::selectWidget(std::string path)
{
  std::string             sysPath(m_sDocumentRoot + path);
  boost::filesystem::path p(path);
  std::string             strExt (p.extension().string());
  std::string             strName(p.stem().string());
  std::string             strFileName(strName + strExt);
  std::string             fileContent;
  if ( m_bLogContent )
    wApp->log("notice") << "WsContent::selectWidget :  path = " << path << " name = " << strName << " extension = " << strExt << " system path = " << sysPath;
  // This extension is mainly created for allowing text in a image without a link
  if ( strExt == ".nolink" ) {
    addWidget(new WsErrorPage(WsErrorPage::Error, path, 0, "Extension not allowed", true));
    return;
  }
  // .html
  if ( strExt == ".html" ) {
    if ( m_bLogContent )
      wApp->log("notice") << "WsContent::selectWidget : render a html file : " << sysPath;
    if ( !m_bAllowHtmlRendering ) {
      addWidget(new WsErrorPage(WsErrorPage::Error, path, 0, "Rendering a html file is not allowed"));
      return;
    }
    clear();
    WsApp->hideImages(false);
    WText* pIFrame = new WText();
    pIFrame->setTextFormat(XHTMLUnsafeText);
    pIFrame->setText("<iframe src='" + m_sRelativeDocumentRoot + path + "' height='98%' width='100%' frameborder='0'></iframe>");
    addWidget(pIFrame);
    return;
  }
  // .form
  if ( strExt == ".form" ) {
    if ( m_bLogContent )
      wApp->log("notice") << "WsContent::selectWidget : render a form : " << sysPath;
    clear();
    m_curWForm = new gdWForm(sysPath);
    addWidget(m_curWForm);
    return;
  }
  // .itpl, Inside template : Extension that create a template in the content.
  if ( strExt == ".itpl" ) {
    if ( m_bLogContent )
      wApp->log("notice") << "WsContent::selectWidget : render an inside template : " << sysPath;
    clear();
    WsTemplate* pTemplate = new WsTemplate(strFileName);
    addWidget(pTemplate);
    return;
  }
  // directory
  if ( gdcore_isPathDirectory(sysPath) ) {
    if ( m_bLogContent )
      wApp->log("notice") << "WsContent::selectWidget : render a directory : " << sysPath;
    viewDirectory(path);
    return;
  }
  /*
  Koen : mmm this is a tricky problem. you could do this using an internal path so that you can first let the user authenticate, if necessary, and then you redirect to a static resource with some randomly generated token in the URL so that you can serve the file
  so the permalink is clean, like /cms/folder1/folder2/file.doc
  if your app is deployed at / or /cms, you handle the internal path, authenticate, etc...
  then finally, you create a random ID, and redirect to /resource/folder1/folder2/file.doc?auth=randomid
  and this is handled by a WResource which checks the path and serves the file
  if you prefer I can create a small example ...
  ooops ! must run !
  */
  if ( strExt == ".rss" ) {
    if ( m_bLogContent )
      wApp->log("notice") << "WsContent::selectWidget : render a " << strExt << " file : " << sysPath;
    clear();
    WsApp->hideImages(false);
    addWidget(new WText("Download file : " + path + " ..."));
    return wApp->redirect(m_sRelativeDocumentRoot + path);
  }
  for (int iModule = 0; iModule < WsApp->WsModules().modules().size(); iModule++) {
    WsModule* curModule = WsApp->WsModules().modules()[iModule]->module;
    if ( curModule->isLoaded() ) continue;
    if ( (strExt.size() == 0  && strName == curModule->fileName()) || (strExt.size() > 0 && strExt == curModule->extension(strExt))  ) {
      if ( m_bLogContent )
        if ( strExt == curModule->extension(strExt) )
          wApp->log("notice") << "WsContent::selectWidget : module, render a " << strExt << " file extension : " << sysPath;
        else
          wApp->log("notice") << "WsContent::selectWidget : module, render " << strName << " file name: " << sysPath;
      clear();
      WsApp->hideImages(curModule->hideImages());
      curModule->setSysPath(sysPath);
      curModule->setDiffPath(m_sRelativeDocumentRoot);
      WWidget* w = curModule->createContents();
      if ( w ) {
        if ( asString(curModule->option("useLayout")) == "true" ) {
          WVBoxLayout* vbox = new WVBoxLayout();
          vbox->addWidget(w, 1);
          setLayout(vbox);
        } else {
          addWidget(w);
        }
      } else {
        wApp->log("notice") << "WsContent::selectWidget : module, render " << curModule->moduleName() << " CANNOT call create content: ";
      }
      return;
    }
  }

  if ( strExt == ".pdf" ) {
    if ( m_bLogContent )
      wApp->log("notice") << "WsContent::selectWidget : render a " << strExt << " file : " << sysPath;
    //     if ( !allowedPath(userUID, syspath) ) return;
    clear();
    WsApp->hideImages(false);
    addWidget(new WText("Download file : " + path + " ..."));
    return wApp->redirect(m_sRelativeDocumentRoot + path);
  }
  clear();
  addWidget(new WsErrorPage(WsErrorPage::Error, path, 0, "Unknown extension", false));
}
Пример #15
0
IdeaSubmit::IdeaSubmit(CgiRoot *cgi, Wt::WDialog *parentDialog, bool editMode, size_t editRowId) : BaseWidget(cgi),
    m_dlgParent(parentDialog),
    m_editMode(editMode),
    m_editRowId(editRowId),
    m_editCompletedHandler(this)
{
    this->clear();
    this->addWidget(Layout());

    this->setOverflow(WContainerWidget::OverflowAuto);

    Div *dvButtonWrappers = new Div();
    Div *dvButtons = new Div(dvButtonWrappers, "dvDialogButtons");
    WPushButton *submitButton;
    if (!m_editMode)
        submitButton = new WPushButton(m_lang->GetString("HOME_SUBMIT_IDEA_DLG_OK_BUTTON"), dvButtons);
    else
        submitButton = new WPushButton(m_lang->GetString("HOME_SUBMIT_IDEA_DLG_OK_EDIT_BUTTON"), dvButtons);
    WPushButton *returnButton = new WPushButton(m_lang->GetString("HOME_SUBMIT_IDEA_DLG_RETURN_BUTTON"), dvButtons);

    submitButton->setStyleClass("dialogButton");
    returnButton->setStyleClass("dialogButton");

    WVBoxLayout *layout = new WVBoxLayout();

    layout->addWidget(this);
    layout->setStretchFactor(this, 1);

    layout->addWidget(dvButtonWrappers );
    layout->setStretchFactor(dvButtonWrappers , 0);


    m_dlgParent->contents()->setLayout(layout);

    if (m_editMode) {
        string title;
        int typegamesentertainment;
        int typehygienehealth;
        int typenewsinfo;
        int typelearning;
        int typenonepresenceservices;
        int typeonlineshopping;
        int typeothers;
        string typeotherstext;
        string description;
        int audienceteens;
        int audienceparents;
        int audienceboys;
        int audiencegirls;
        int audiencewomen;
        int audiencemen;
        int audiencechilds;
        int audienceallfamilymembers;
        string usage;
        string similar;
        string difference;

        result r = m_db->Sql() << "SELECT title, "
                                  "typegamesentertainment, typehygienehealth, typenewsinfo, typelearning, "
                                  "typenonepresenceservices, typeonlineshopping, typeothers, typeotherstext, "
                                  "description, "
                                  "audienceteens, audienceparents, audienceboys, audiencegirls, audiencewomen, "
                                  "audiencemen, audiencechilds, audienceallfamilymembers, "
                                  "usage, similar, difference "
                                  "FROM [" + m_dbTables->Table("IDEAS")
                                  + "] WHERE rowid=?;" << m_editRowId << row;
        if (!r.empty()) {
            r >> title >> typegamesentertainment >> typehygienehealth
              >> typenewsinfo >> typelearning >> typenonepresenceservices >> typeonlineshopping
              >> typeothers >> typeotherstext >> description >> audienceteens >> audienceparents >> audienceboys
              >> audiencegirls >> audiencewomen >> audiencemen >> audiencechilds >> audienceallfamilymembers
              >> usage >> similar >> difference;

            title = Crypto::Decrypt(title);
            typeotherstext = Crypto::Decrypt(typeotherstext);
            description = Crypto::Decrypt(description);
            usage = Crypto::Decrypt(usage);
            similar = Crypto::Decrypt(similar);
            difference = Crypto::Decrypt(difference);

            m_typeGamesEntertainmentCheckBox->setChecked(typegamesentertainment);
            m_typeHygieneHealthCheckBox->setChecked(typehygienehealth);
            m_typeNewsInfoCheckBox->setChecked(typenewsinfo);
            m_typeLearningCheckBox->setChecked(typelearning);
            m_typeNonePresenceServicesCheckBox->setChecked(typenonepresenceservices);
            m_typeOnlineShoppingCheckBox->setChecked(typeonlineshopping);
            m_typeOthersCheckBox->setChecked(typeothers);
            if (typeothers)
                m_typeOthersTextLineEdit->setText(WString::fromUTF8(typeotherstext));
            m_titleLineEdit->setText(WString::fromUTF8(title));
            m_descriptionTextArea->setText(WString::fromUTF8(description));
            m_audienceTeensCheckBox->setChecked(audienceteens);
            m_audienceParentsCheckBox->setChecked(audienceparents);
            m_audienceBoysCheckBox->setChecked(audienceboys);
            m_audienceGirlsCheckBox->setChecked(audiencegirls);
            m_audienceWomenCheckBox->setChecked(audiencewomen);
            m_audienceMenCheckBox->setChecked(audiencemen);
            m_audienceChildsCheckBox->setChecked(audiencechilds);
            m_audienceAllFamilyMembersCheckBox->setChecked(audienceallfamilymembers);
            m_usageTextArea->setText(WString::fromUTF8(usage));
            m_similarTextArea->setText(WString::fromUTF8(similar));
            m_differenceTextArea->setText(WString::fromUTF8(difference));
        }
    }
Пример #16
0
DetailManipulation::DetailManipulation(bool enhance, WContainerWidget *parent)
	: WContainerWidget(parent), onlySmooth(!enhance)
{

	resize(WLength::Auto, WLength::Auto);

	// Image bar
	prepareInputImages();
	WContainerWidget *imageBar = new WContainerWidget;
	WVBoxLayout *imageBarLayout = new WVBoxLayout();
	for (size_t i = 0; i < inputImages.size(); ++i) {
		WImage *img = inputImages[i]->getOriginalImage();
		img->setStyleClass("image_button");
		img->resize(160, 120);
		img->setAttributeValue("onMouseOver", "this.width=192; this.height=144;");
		img->setAttributeValue("onMouseOut", "this.width=160; this.height=120;");
		img->clicked().connect(
				boost::bind(&DetailManipulation::selectImage,
							this,
							i
							)
		);
		imageBarLayout->addWidget(img);
	}
	imageBar->resize(200, WLength::Auto);
	imageBar->setLayout(imageBarLayout);
	selectedImageId = 0;

	// Main component
	imageTab = new WTabWidget();
	imageTab->addTab(inputImages[selectedImageId]->getOriginalImage(), "Original");
	if (onlySmooth) {
		imageTab->addTab(new WImage(smoothedResult[selectedImageId].second), smoothedResult[selectedImageId].first);
	}
	else {
		imageTab->addTab(new WImage(enhancedResult[selectedImageId].second), enhancedResult[selectedImageId].first);
	}
	imageTab->resize(600, WLength::Auto);


	WGridLayout *controllerLayout = new WGridLayout();
	WSlider *rSlider = new WSlider(Wt::Vertical);
	rSlider->setRange(SLIDER_MINIMUM, SLIDER_MAXIMUM);
	rSlider->setTickPosition(Wt::WSlider::TicksBothSides);
	WDoubleSpinBox *rSpinBox = new WDoubleSpinBox();
	rSpinBox->setMinimum(R_MINIMUM);
	rSpinBox->setMaximum(R_MAXIMUM);
	rSlider->sliderMoved().connect(
			boost::bind(&DetailManipulation::changeDoubleSpinBoxValue,
						this,
						rSpinBox,
						true,
						_1)
	);
	rSpinBox->valueChanged().connect(
			boost::bind(&DetailManipulation::changeSliderValue,
						this,
						rSlider,
						1.f/(R_MAXIMUM-R_MINIMUM),
						_1)
	);
	controllerLayout->addWidget(rSlider, 2, 0, 6, 1);
	controllerLayout->addWidget(rSpinBox, 9, 0);
	controllerLayout->addWidget(new WText("radius"), 10, 0);


	WSlider *epsSlider = new WSlider(Wt::Vertical);
	epsSlider->setMinimum(SLIDER_MINIMUM);
	epsSlider->setMaximum(SLIDER_MAXIMUM);
	epsSlider->setRange(SLIDER_MINIMUM, SLIDER_MAXIMUM);
	epsSlider->setTickPosition(WSlider::TicksBothSides);
	WDoubleSpinBox *epsSpinBox = new WDoubleSpinBox();
	epsSpinBox->setMinimum(EPS_MINIMUM);
	epsSpinBox->setMaximum(EPS_MAXIMUM);
	epsSlider->sliderMoved().connect(
			boost::bind(&DetailManipulation::changeDoubleSpinBoxValue,
						this,
						epsSpinBox,
						false,
						_1)
	);
	epsSpinBox->valueChanged().connect(
			boost::bind(&DetailManipulation::changeSliderValue,
						this,
						epsSlider,
						1.f/(EPS_MAXIMUM-EPS_MINIMUM),
						_1)
	);
	controllerLayout->addWidget(epsSlider, 2, 1, 6, 1);
	controllerLayout->addWidget(epsSpinBox, 9, 1);
	controllerLayout->addWidget(new WText("epsilon"), 10, 1);

	WPushButton *apply = new WPushButton("Apply");
	apply->clicked().connect(
			boost::bind(&DetailManipulation::applyEnhancement,
					this,
					rSpinBox,
					epsSpinBox
					)
	);
	controllerLayout->addWidget(apply, 1, 0, 1, 2);


	WContainerWidget *controller = new WContainerWidget();
	controller->resize(120, WLength::Auto);
	controller->setLayout(controllerLayout);


	WBorderLayout *mainLayout = new WBorderLayout(this);
	mainLayout->addWidget(imageBar, WBorderLayout::West);
	mainLayout->addWidget(imageTab, WBorderLayout::Center);
	mainLayout->addWidget(controller, WBorderLayout::East);
	//setLayout(mainLayout, Wt::AlignTop | Wt::AlignJustify);
	/*
		doJavaScript(
			    "(function () { \
						     var imageTags = document.getElementsByClassName(\"image_button\"); \
						     for (var i=0; image=imageTags[i]; ++i) { \
						         if (image.width>200 && image.height>0) { \
						             image.width = 192;  \
						         } \
						     }\
				 })();"
		);*/

}
Пример #17
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);
}
Пример #18
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();
}
Пример #19
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;
}
Пример #20
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);
    }
  }
Пример #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());
   // }
}