Project

General

Profile

Bug #5391 » test_20161020a_WTextEdit_Chrome_layout.C

Bruce Toll, 11/02/2016 01:03 AM

 
#include <Wt/WServer>
#include <Wt/WVBoxLayout>
#include <Wt/WAnimation>
#include <Wt/WBreak>
#include <Wt/WText>
#include <Wt/WTextEdit>
#include <Wt/WPushButton>
#include <Wt/WBootstrapTheme>

using namespace Wt;

class TestApplication : public WApplication
{
public:
TestApplication(const WEnvironment& env);

private:
WBootstrapTheme bs_theme_;
};

TestApplication::TestApplication(const WEnvironment& env) : WApplication(env)
{
setTitle("WTextEdit in layout issue (Chrome)");
setTheme(&bs_theme_);

new WText("The yellow container has a WVBoxLayout manager. "
"Pressing the button adds a WTextEdit to the container. "
"With Chrome, the WTextEdit can extend beyond its container, typically when the browser cache is cold. "
"It can also fail in FireFox with a slow internet connection.", root());
new WBreak(root());
auto pb = new WPushButton("Press to add WTextEdit", root());
pb->setStyleClass("btn-primary");

auto main_container = new WContainerWidget(root());
main_container->resize(500, 200);
main_container->decorationStyle().setBackgroundColor(WColor(yellow));
auto v_layout = new WVBoxLayout();
main_container->setLayout(v_layout);
v_layout->setContentsMargins(0, 0, 0, 0);
pb->clicked().connect(std::bind([=] {
auto te = new WTextEdit();
te->setExtraPlugins("nonbreaking,paste,preview,searchreplace,table,wordcount,charmap");
te->setConfigurationSetting("resize", boost::any(false));
v_layout->addWidget(te, 1);
pb->disable();
}));
}

int main(int argc, char **argv)
{
return WRun(argc, argv, [](const WEnvironment& env) {return new TestApplication(env);});
}
(1-1/2)