|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
#include <Wt/WAbstractTableModel.h>
|
|
#pragma GCC diagnostic pop
|
|
#include <Wt/WApplication.h>
|
|
#include <Wt/WBootstrap5Theme.h>
|
|
#include <Wt/WContainerWidget.h>
|
|
#include <Wt/WGridLayout.h>
|
|
#include <Wt/WHBoxLayout.h>
|
|
#include <Wt/WMenuItem.h>
|
|
#include <Wt/WPanel.h>
|
|
#include <Wt/WPopupMenu.h>
|
|
#include <Wt/WPushButton.h>
|
|
#include <Wt/WServer.h>
|
|
#include <Wt/WTable.h>
|
|
#include <Wt/WTableView.h>
|
|
#include <Wt/WTabWidget.h>
|
|
#include <Wt/WText.h>
|
|
#include <Wt/WVBoxLayout.h>
|
|
|
|
using namespace std;
|
|
using namespace Wt;
|
|
using namespace Wt::cpp17;
|
|
|
|
#define SET_BS5THEME 1
|
|
|
|
// Always apply theme before creating widgets!
|
|
class CThemedApplication : public WApplication
|
|
{
|
|
public:
|
|
CThemedApplication(const WEnvironment& rcEnv)
|
|
: WApplication{rcEnv}
|
|
{
|
|
#if SET_BS5THEME
|
|
setTheme(make_shared<WBootstrap5Theme>());
|
|
#endif
|
|
}
|
|
};
|
|
|
|
class CPanel final : public WContainerWidget
|
|
{
|
|
public:
|
|
CPanel(const WString& text)
|
|
{
|
|
WBoxLayout& lytPanel{*setLayout(make_unique<WVBoxLayout>())};
|
|
lytPanel.setContentsMargins(0, 0, 0, 0);
|
|
lytPanel.setSpacing(0);
|
|
|
|
WText& txtTop{*lytPanel.addWidget(make_unique<WText>())};
|
|
txtTop.setText(text);
|
|
txtTop.setTextAlignment(AlignmentFlag::Center);
|
|
|
|
#if 0
|
|
for (int i = 0; i < 3; ++i)
|
|
{
|
|
lytPanel.addWidget(make_unique<WTable>())
|
|
->columnAt (0)->setWidth(20);
|
|
}
|
|
#endif
|
|
|
|
WTable& tblBottom{*lytPanel.addWidget(make_unique<WTable>())};
|
|
tblBottom.columnAt (0)->setWidth(20);
|
|
tblBottom.elementAt(0, 2)->addWidget(make_unique<WText>("long label text"))->setWordWrap(false);
|
|
#if 0
|
|
tblBottom.elementAt(1, 1)->setColumnSpan(3);
|
|
tblBottom.elementAt(1, 1)->addWidget(make_unique<WTable>());
|
|
#endif
|
|
|
|
lytPanel.addStretch(100);
|
|
}
|
|
};
|
|
|
|
class CApplication final : public CThemedApplication
|
|
{
|
|
public:
|
|
CApplication(const WEnvironment& rcEnv);
|
|
|
|
private:
|
|
WContainerWidget& _cntRoot{*root()};
|
|
WBoxLayout& _lytRoot{*_cntRoot.setLayout(make_unique<WVBoxLayout>())};
|
|
|
|
WTabWidget& _tbwMain{*_lytRoot.addWidget(make_unique<WTabWidget>(), /*stretch*/ 100)};
|
|
WMenuItem& _tabA{*_tbwMain.addTab(make_unique<WContainerWidget>(), "A", ContentLoading::Eager)};
|
|
WContainerWidget& _cntA{dynamic_cast<WContainerWidget&>(*_tbwMain.widget(_tbwMain.count() - 1))};
|
|
WBoxLayout& _lytA{*_cntA.setLayout(make_unique<WHBoxLayout>())};
|
|
|
|
WContainerWidget& _cntATop{*_lytA.addWidget(make_unique<WContainerWidget>())};
|
|
WBoxLayout& _lytATop{*_cntATop.setLayout(make_unique<WHBoxLayout>())};
|
|
#if 0
|
|
WContainerWidget& _cntABottom{*_lytA.addWidget(make_unique<WContainerWidget>())};
|
|
WBoxLayout& _lytABottom{*_cntABottom.setLayout(make_unique<WHBoxLayout>())};
|
|
|
|
WMenuItem& _tabB{*_tbwMain.addTab(make_unique<WTableView>(), "B", ContentLoading::Eager)};
|
|
#endif
|
|
};
|
|
|
|
CApplication::CApplication(const WEnvironment& rcEnv)
|
|
: CThemedApplication{rcEnv}
|
|
{
|
|
setTitle("bug repro " WT_VERSION_STR);
|
|
|
|
_lytA.setContentsMargins(0, 0, 0, 0);
|
|
_lytA.addStretch(100);
|
|
_cntA.setOverflow(Overflow::Auto);
|
|
|
|
_lytATop.setContentsMargins(0, 0, 0, 0);
|
|
_lytATop.setSpacing(0);
|
|
for (int i = 0; i < 20; ++i)
|
|
{
|
|
_lytATop.addWidget(make_unique<CPanel>("panel " + std::to_string(i + 1)));
|
|
}
|
|
_lytATop.addStretch(100);
|
|
_cntATop.setOverflow(Overflow::Auto);
|
|
|
|
#if 0
|
|
_lytABottom.setContentsMargins(0, 0, 0, 0);
|
|
_lytABottom.addStretch(100);
|
|
_lytABottom.addWidget(make_unique<WPushButton>("Button"))->clicked().connect([&] { });
|
|
#endif
|
|
|
|
// final action after creating the UI
|
|
enableUpdates();
|
|
}
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
return WRun(argc, argv, [](const WEnvironment& rcEnv)
|
|
{
|
|
try
|
|
{
|
|
return make_unique<CApplication>(rcEnv);
|
|
}
|
|
catch (const std::exception& rcException)
|
|
{
|
|
cerr << "exception " << typeid(remove_cvref<decltype(rcException)>::type).name() << ": " << rcException.what() << endl;
|
|
|
|
#if DEBUG
|
|
exit(-1);
|
|
#endif
|
|
throw;
|
|
}
|
|
});
|
|
}
|