|
#include <Wt/WApplication.h>
|
|
#include <Wt/WEnvironment.h>
|
|
#include <Wt/WPushButton.h>
|
|
#include <Wt/WStandardItem.h>
|
|
#include <Wt/WStandardItemModel.h>
|
|
#include <Wt/WTableView.h>
|
|
#include <Wt/WText.h>
|
|
#include <Wt/WTimer.h>
|
|
#include <Wt/WVBoxLayout.h>
|
|
|
|
using namespace Wt;
|
|
using namespace std;
|
|
|
|
class TestApp : public WApplication {
|
|
public:
|
|
TestApp(const WEnvironment& env);
|
|
void testWindow();
|
|
private:
|
|
int windowInstance_ = 0;
|
|
};
|
|
|
|
class TableView : public WTableView {
|
|
public:
|
|
TableView()
|
|
{
|
|
setLayoutSizeAware(true);
|
|
}
|
|
|
|
void layoutSizeChanged(int width, int height) override
|
|
{
|
|
log("info") << "TableView::layoutSizeChanged (w = " << width << ", h = " << height << ")";
|
|
#if 1 // NOTE: fails with this enabled or disabled
|
|
WTableView::layoutSizeChanged(width, height);
|
|
#endif
|
|
}
|
|
};
|
|
|
|
void TestApp::testWindow()
|
|
{
|
|
auto topLayout = make_unique<WVBoxLayout>();
|
|
topLayout->setPreferredImplementation(LayoutImplementation::JavaScript);
|
|
|
|
auto model = make_shared<WStandardItemModel>(200, 4);
|
|
for (int r = 0; r < model->rowCount(); ++r) {
|
|
for (int c = 0; c < model->columnCount(); ++c) {
|
|
model->setData(model->index(r, c), r + c);
|
|
}
|
|
}
|
|
auto tableView = make_unique<TableView>();
|
|
tableView->setModel(model);
|
|
topLayout->addWidget(move(tableView), 1);
|
|
topLayout->addWidget(move(make_unique<WText>("<p>Some footer text...</p>")), 0);
|
|
root()->setLayout(move(topLayout));
|
|
}
|
|
|
|
TestApp::TestApp(const WEnvironment& env) : WApplication(env)
|
|
{
|
|
auto param = env.getParameter("p");
|
|
setTitle(string("Oscillation Test") + (param ? (" Window " + *param) : ""));
|
|
|
|
if (param)
|
|
testWindow();
|
|
else {
|
|
root()->addWidget(move(make_unique<WText>("<p>Push button to open window.</p>"
|
|
"<p>Watch for oscillations in Windows 7 Chrome switching to zoom levels 67%.</p>"
|
|
"<p>Debian Stretch chromium oscillates at 80% zoom, resized to around 18 rows</p>")));
|
|
auto button = root()->addWidget(make_unique<WPushButton>("Open window"));
|
|
|
|
button->clicked().connect([=] {
|
|
WString url = wApp->resolveRelativeUrl("?p=" + to_string(++windowInstance_));
|
|
button->doJavaScript("window.open(" + url.jsStringLiteral() + ", 'Test Window " +
|
|
to_string(windowInstance_) + "', 'height=387,width=360');");
|
|
});
|
|
}
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
return WRun(argc, argv, [](const WEnvironment& env) {return make_unique<TestApp>(env);});
|
|
}
|