当前位置: 首页>>代码示例>>C++>>正文


C++ wt::WApplication类代码示例

本文整理汇总了C++中wt::WApplication的典型用法代码示例。如果您正苦于以下问题:C++ WApplication类的具体用法?C++ WApplication怎么用?C++ WApplication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了WApplication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RegionsCreator

        /*!
         * \brief Конструктор класса сайта.
         * \param[in] Класс хранения окружения сайта
         */
        CompanyesApplication(const Wt::WEnvironment& env)
            : Wt::WApplication(env)
        {
            this->messageResourceBundle().use(this->appRoot() + "rus_locale");
            this->useStyleSheet(this->appRoot() + "main.css");
            this->setTitle(Wt::WString::tr("Title"));

            Wt::WApplication *app = Wt::WApplication::instance();
            app->setLoadingIndicator(new Wt::WOverlayLoadingIndicator());
            app->styleSheet().addRule("body", "margin: 0px");

            Wt::WStackedWidget* contents = new Wt::WStackedWidget();
            contents->setOverflow(Wt::WContainerWidget::OverflowAuto);
            contents->setPositionScheme(Wt::Relative);

            Wt::WMenu* menu = new Wt::WMenu(contents, Wt::Vertical, 0);
            menu->setRenderAsList(true);
            menu->setStyleClass("menu");

            std::string absolute_path = boost::filesystem::system_complete(boost::filesystem::path(".")).string();
            new RegionsCreator(absolute_path, contents, menu);

            Wt::WHBoxLayout* hlayout = new Wt::WHBoxLayout();
            hlayout->addWidget(menu, 0);
            hlayout->addWidget(contents, 1);

            Wt::WVBoxLayout* vlayout = new Wt::WVBoxLayout(this->root());
            vlayout->addWidget(new Wt::WText(Wt::WString::tr("Header")), 0);
            vlayout->addLayout(hlayout, 1);
        }
开发者ID:runya-v,项目名称:run,代码行数:34,代码来源:Main.cpp

示例2: RssReader

Wt::WApplication *createApplication(const Wt::WEnvironment& env)
{
  Wt::WApplication *app = new Wt::WApplication(env);
  new RssReader(app->root());

  return app;
}
开发者ID:DTidd,项目名称:wt,代码行数:7,代码来源:SocketNotifier.C

示例3: handleURLChange

void Extension::handleURLChange() {
    // Find the page
    IGui* gui = IGui::instance();
    Wt::WApplication* app = Wt::WApplication::instance();
    std::string pageName = "/";
    std::string action = "view";
    if (app->internalPathMatches("/page/")) {
        pageName = app->internalPathNextPart("/page/");
        std::string pagePath = "/page/" + pageName + "/";
        if (app->internalPathMatches(pagePath))
            action = app->internalPathNextPart(pagePath);
    }
    dbo::Session& s = dbSession();
    dbo::Transaction t(s);
    dbo::ptr<Model> page = s.find<Model>().where("name=?").bind(pageName);
    // Use it
    if (page) {
        ActionMap::const_iterator found = actionMap.find(action);
        if (found != actionMap.end()) {
            ((this)->*(found->second))(*page); // Call the action .. view/edit etc..
        } else {
            Wt::WApplication::instance()->log("ERROR") <<
                    "No valid action for page " << page->getName() << " - " <<
                    "Action name " << action;
            // Default to view maybe ?
            gui->setBody("ERROR: No such action " + action );
        }
    } else {
        gui->setBody("PAGE NOT FOUND: " + pageName);
    }
    t.commit();
}
开发者ID:matiu2,项目名称:witty-plus,代码行数:32,代码来源:Extension.cpp

示例4: render

  void Popup::render(Wt::WFlags<Wt::RenderFlag> flags) {
    Wt::WApplication * app = Wt::WApplication::instance();
    Wt::WString initFunction = app->javaScriptClass() + ".init_popup_" + id();

    Wt::WStringStream stream;
    stream
      << "{" << initFunction.toUTF8() << " = function() {"
      << "  var self = " << jsRef() << ";"
      << "  if (!self) {"
      << "    setTimeout(" << initFunction.toUTF8() << ", 0);"
      << "  }";

    stream
      << "  self.popup = new mapboxgl.Popup( {"
      << "    closeButton: " << ToScript(closeButton_).toUTF8() << ", "
      << "    closeOnClick: " << ToScript(closeOnClick_).toUTF8() << ", "
      << "    anchor: " << ToScript(anchor_).toUTF8()
      << "  });";

    for (unsigned int i = 0; i < additions_.size(); i++) {
      stream << additions_[i].toUTF8();
    }
    additions_.clear();

    stream
      << "  setTimeout(function(){ delete " << initFunction.toUTF8() << ";}, 0)};\n"
      << "}\n"
      << initFunction.toUTF8() << "();\n";

    app->doJavaScript(stream.str());
  }
开发者ID:yvanvds,项目名称:wtMapbox,代码行数:31,代码来源:Popup.cpp

示例5: tellClient

 /// Call this to push a server side validation result to the client side (complete with message)
 static void tellClient(WFormWidget* widget, const WString& value, Result validationResult) {
     widget->setJavaScriptMember("serverValidationResult",
      "{ value:" + value.jsStringLiteral() + ","
       "valid:" + (validationResult.state() == WValidator::Valid ? "true," : "false,") +
      "message:" + validationResult.message().jsStringLiteral() + "}");
     Wt::WApplication* app = Wt::WApplication::instance();
     app->doJavaScript( app->javaScriptClass() + ".WT.validate(" + widget->jsRef() + ");" );
 }
开发者ID:lyase,项目名称:cblog,代码行数:9,代码来源:ServerSideValidator.hpp

示例6: startSurvey

void SurveySelector::startSurvey() {
	std::cout << "Hello " << user_->text() << ", please fill in " << surveys_->currentText() << std::endl;
	Wt::WApplication *app = Wt::WApplication::instance();
	std::string path("/fill/");
	path.append(user_->text().toUTF8());
	path.append("/");
	path.append(surveys_->currentText().toUTF8());
	app->setInternalPath(path, true);
}
开发者ID:mathieu-reymond,项目名称:structure-of-computer-programs-2,代码行数:9,代码来源:SurveySelector.cpp

示例7: CreateApplication

Wt::WApplication* Core::CreateApplication (const Wt::WEnvironment& e)
{
	Wt::WApplication *result = new Wt::WApplication (e);
	result->setTitle ("LeechCraft");

	Interface *interface = new Interface (result, e);

	return result;
}
开发者ID:Beliaf,项目名称:leechcraft,代码行数:9,代码来源:core.cpp

示例8: toggleTheme

void MainWindow::toggleTheme() {
    Wt::WApplication* app = Wt::WApplication::instance(); // Get the Wt::WApplication intstance for our thread
    std::string oldTheme = app->cssTheme();
    std::string newTheme = oldTheme == "default" ? "polished" : "default";
    app->setCssTheme(newTheme); // Toggle the theme between 'default' and 'polished'
    _btnToggleTheme->setText("Change to " + oldTheme);
    // Make the client reload the css
    app->doJavaScript(app->javaScriptClass() + ".updateStyles()");
}
开发者ID:GD-Krone,项目名称:witty-tutorial,代码行数:9,代码来源:MainWindow.cpp

示例9: runtime_error

YahooStockHistory::GotCSVSignal& YahooStockHistory::query(const std::string& query)
{
     std::string url = "http://ichart.yahoo.com/table.csv?";
     url += query;
     Wt::WApplication* app = Wt::WApplication::instance();
     app->log("info") << "Sending query: " << url << "\n";
     if (http->get(url)) {
          return http->done();
     }
     throw std::runtime_error("Couldn't connect to http");
};
开发者ID:lyase,项目名称:witty-tutorial,代码行数:11,代码来源:Yahoo.cpp

示例10: sendToAll

void Table::sendToAll() {
    // TODO: Mutex lock?
    std::cout << "sending " << test << " to " << clients.length() << std::endl;
    Wt::WApplication *app = Wt::WApplication::instance();

    foreach(TableView* i, clients) {
        if (app && app->sessionId() == i->sessionId())
            i->updateNumber(test);
        else
            m_server.post(i->sessionId(), boost::bind(&TableView::updateNumber, i, test));
    }
}
开发者ID:opatut,项目名称:playgrounds,代码行数:12,代码来源:Table.cpp

示例11: validateWidgetAndTellBrowser

 /// Validates the widget and passes the message on to the browser
 static Result validateWidgetAndTellBrowser(WFormWidget* widget) {
     ServerSideValidator* validator = dynamic_cast<ServerSideValidator*>(widget->validator());
     if (validator != 0) {
         WString value = getValue(widget);
         Result result = validator->validate(value);
         tellClient(widget, value, result);
         return result;
     } else {
         Wt::WApplication* app = Wt::WApplication::instance();
         app->doJavaScript( app->javaScriptClass() + ".WT.validate(" + widget->jsRef() + ");" );
         return widget->validate();
     }
 }
开发者ID:lyase,项目名称:cblog,代码行数:14,代码来源:ServerSideValidator.hpp

示例12: SetCookie

/* ****************************************************************************
 * Set Cookie
 */
void SetCookie(std::string name, std::string myValue)
{
    Wt::WApplication *app = Wt::WApplication::instance();
    try
    {
        app->setCookie(name, myValue, 150000, "", "/", false);
    }
    catch (std::exception& e)
    {
        std::cerr << e.what() << std::endl;
        std::cerr << "WittyWizard::SetCookie: Failed writting cookie: " << name;
        Wt::log("error") << "WittyWizard::SetCookie()  Failed writting cookie: " << name;
    }
} // end void WittyWizard::SetCookie
开发者ID:lyase,项目名称:install,代码行数:17,代码来源:WittyWizard.cpp

示例13: setConnectionPool

/* ****************************************************************************
 * Menu Manager Session
 * appPath:
 * useDb:
 * lang: FIXME: default|lang1|lang2|lang3
 * connectionPool:
 */
MenuManSession::MenuManSession(const std::string& appPath, const std::string& useDb, const std::string& lang, Wt::Dbo::SqlConnectionPool& connectionPool) : appPath_(appPath), useDb_(useDb), lang_(lang), connectionPool_(connectionPool)
{
    if (useDb == "1")
    {
        setConnectionPool(connectionPool_);
        mapClass<MenuMan>("menuman"); // table name menuman
        Wt::WApplication* app = Wt::WApplication::instance();
        std::string path = app->internalPath(); // /lang/menuman/
        bool doXmlUpdate = false;
        // FIXME add security for logon or certificate
        // hard code /admin/menuman/updatexml for admin work
        if (path.find("/admin/menuman/updatexml") != std::string::npos) { doXmlUpdate = true; }
        //Wt::log("start") << " *** MenuManSession::MenuManSession() useDb | path = " << path << " | doXmlUpdate = " << doXmlUpdate << " *** ";
        if (CrystalBall::InitDb || doXmlUpdate)
        {
            try
            {
                Wt::Dbo::Transaction t(*this);
                // Note: you must drop table to do update
                if (doXmlUpdate)
                {
                    Wt::log("warning") << "MenuManSession::MenuManSession() SQL Drop Table menuman";
                    dropTables();
                }
                createTables();
                Wt::log("warning") << "Created database: menuman ";
                if (!ImportXML())
                {
                    Wt::log("error") << " *** MenuManSession::MenuManSession() ImportXML failed! *** ";
                    return;
                }
                t.commit();
            }
            catch (std::exception& e)
            {
                Wt::log("warning") << " *** MenuManSession::MenuManSession()  Using existing menuman database = " << e.what();
            }
        }
    } // end if (useDb == "1")
    //Wt::log("end") << " *** MenuManSession::MenuManSession() *** ";
} // end MenuManSession
开发者ID:WittyWizard,项目名称:install,代码行数:48,代码来源:MenuManSession.cpp

示例14: GetHits

/* ****************************************************************************
 * Get Hits
 */
std::string HitCounterManImpl::GetHits()
{
    // Create an instance of app to access Internal Paths
    Wt::WApplication* app = Wt::WApplication::instance();
    try
    {
        // Start a Transaction
        Wt::Dbo::Transaction t(session_);

        hits = session_.query<int>("select count(*) from hitcounterman").where("page = ?").bind(app->internalPath());
        //Wt::log("notice") << "HitCounterManImpl::GetHits()  hits = " << hits << " | page = " << app->internalPath();

        // Commit Transaction
        t.commit();    }
    catch (std::exception& e)
    {
        std::cerr << e.what() << std::endl;
        //Wt::log("error") << "HitCounterManImpl::GetHits()  Failed reading from hitcounterman database.";
        hits = 0;
    }

    try
    {
        Wt::WLocale myString = Wt::WLocale(theLocale.c_str());
        // Note: this only works if you set the Separator, use case to set it
        myString.setGroupSeparator(",");
        std::string myReturn = myString.toString(hits).toUTF8();
        return myReturn;
        /*
         * This requires locale to be installed and configured on server
        std::stringstream ss;
        ss.imbue(std::locale(theLocale.c_str()));
        ss << std::fixed << hits;
        return ss.str();
        */
    }
    catch (std::exception& e)
    {
        std::cerr << e.what() << std::endl;
        std::cerr << "HitCounterManImpl::GetHits: Failed local not installed";
        Wt::log("error") << "HitCounterManImpl::GetHits() Failed local not installed";
    }

    return std::to_string(hits);
} // end GetHits
开发者ID:WittyWizard,项目名称:install,代码行数:48,代码来源:HitCounterManImpl.cpp

示例15: Set

/* ****************************************************************************
 * Set
 */
void HitCounterManImpl::Set()
{
    // Create an instance of app to access Internal Paths
    Wt::WApplication* app = Wt::WApplication::instance();
    try
    {
        // Start a Transaction
        Wt::Dbo::Transaction t(session_);
        HitCounterMans myHitCounterMan = session_.find<HitCounterMan>();
        //
        hits = myHitCounterMan.size();
        //
        // Commit Transaction
        t.commit();
    }
    catch (std::exception& e)
    {
        std::cerr << e.what() << std::endl;
        std::cerr << "HitCounterManImpl::Update: Failed reading from hitcounterman database";
        Wt::log("error") << "HitCounterManImpl::Update()  Failed reading from hitcounterman database";
    }

    try
    {
        // Start a Transaction
        Wt::Dbo::Transaction t(session_);
        //
        uniqueHits = session_.query<int>("select COUNT(distinct ipaddress) from hitcounterman").where("page = ?").bind(app->internalPath());;
        // Commit Transaction
        t.commit();
    }
    catch (std::exception& e)
    {
        std::cerr << e.what() << std::endl;
        std::cerr << "HitCounterManImpl::Update: Failed reading from hitcounterman database";
        Wt::log("error") << "HitCounterManImpl::Update()  Failed reading from hitcounterman database";
    }

} // end
开发者ID:WittyWizard,项目名称:install,代码行数:42,代码来源:HitCounterManImpl.cpp


注:本文中的wt::WApplication类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。