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


C++ WText::setFloatSide方法代码示例

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


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

示例1: update

// Updates all ranks
void RecentMatchesContainer::update()
{
    this->clear();
    
    std::vector<RecentMatch> recent_matches = Spartan_->getRecentMatches();
    
    // Create halo api with an api key (get api key from 343i api site)
    //HaloAPI halo_api("05cdc66c52ca4465b0b6e3c56bb87b71");
    
    for (int i = 0; i < recent_matches.size() && i < 10; i++)
    {
        // CUSTOM CONTAINERS
        Wt::WContainerWidget *myContainer = new Wt::WContainerWidget();
        myContainer->decorationStyle().setBorder(Wt::WBorder(Wt::WBorder::Style::Solid, Wt::WBorder::Width::Thin, Wt::WColor(0, 0, 0)));
        myContainer->decorationStyle().setBackgroundColor(Wt::WColor(240, 240, 240));
        myContainer->setPadding(3);
        myContainer->setMargin(3, Wt::Bottom);
        
        std::string title_string = "<b>" + getNameFromHopper(recent_matches[i].hopper_id_) + " / </b>" + getNameFromBaseVariant(recent_matches[i].base_variant_) + "<b> / </b>" + getNameFromMap(recent_matches[i].map_id_) + "";
        Wt::WText *someText = new Wt::WText(title_string, myContainer);
        
        Wt::WPushButton *myButton = new Wt::WPushButton(" + ", myContainer);
        myButton->setFloatSide(Wt::Right);
        
        std::string game_time = time_from_double(recent_matches[i].match_length_);
        Wt::WText *someMoreText = new Wt::WText(game_time, myContainer);
        someMoreText->setFloatSide(Wt::Right);
        
        Wt::WStackedWidget *myStack = new Wt::WStackedWidget(myContainer);
        Wt::WText *text1 = new Wt::WText("text1", myStack);

        
        myButton->clicked().connect(std::bind([=]()
        {
            if (myStack->currentIndex() == 0)
            {
                myButton->setText(" - ");
                Wt::WContainerWidget *stats_table = new Wt::WContainerWidget(myStack);
                Wt::WTable *table = new Wt::WTable(stats_table);
                table->setHeaderCount(1);
                table->elementAt(0, 0)->addWidget(new Wt::WText("Gamertag"));
                HaloAPI halo_api("05cdc66c52ca4465b0b6e3c56bb87b71");
                std::vector<std::string> gamertags;
                
                std::string json_data = halo_api.getPostGameCarnageArena(recent_matches[i].match_id_);
                Json::Value root;   // will contains the root value after parsing.
                Json::Reader reader;
                bool parsingSuccessful = reader.parse( json_data, root );
                if ( !parsingSuccessful )
                {
                    // report to the user the failure and their locations in the document.
                    std::cout  << "Failed to parse configuration\n"
                    << reader.getFormattedErrorMessages();
                }
                const Json::Value plugins = root;
                
                for (int j = 0; j < plugins["PlayerStats"].size(); j++)
                {
                    std::string tag(
                                    plugins["PlayerStats"][j]["Player"]["Gamertag"].asString()
                                    );
                    gamertags.push_back(tag);
                    table->elementAt(j+1, 0)->addWidget(new Wt::WText(tag));
                }
                table->addStyleClass("table table-condensed");
                myStack->setCurrentIndex(1);
            } else
            {
                delete myStack->currentWidget();
                myStack->setCurrentIndex(0);
                myButton->setText(" + ");
            }
        }));
        this->addWidget(myContainer);
    }
}
开发者ID:cluoma,项目名称:HaloViewer,代码行数:77,代码来源:RecentMatchesContainer.cpp


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