#include #include #include #include #include #include #include #include #include #include using namespace std; using namespace Wt; #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()); #endif } }; template constexpr inline std::unique_ptr create(std::function&& fInitialize, TArgs&&... args) { std::unique_ptr Ptr{std::make_unique(std::forward(args)...)}; fInitialize(*Ptr); return Ptr; } class CApplication final : public CThemedApplication { public: CApplication(const WEnvironment& rcEnv); private: WServer& _Server; //!< The associated WServer instance, needed for async operations. WContainerWidget& _cntRoot{*root()}; WBoxLayout& _lytRoot{*_cntRoot.setLayout(make_unique())}; WPushButton& _btnP{*_lytRoot.addWidget(create([this](auto& btnP) { btnP.clicked().connect([this] { _pnlBottom.setDisabled(true); }); }, "Enable bottom panel"))}; WPanel& _pnlBottom{*_lytRoot.addWidget(create([this](auto&) { _lytRoot.addStretch(100); }))}; WContainerWidget& _cntBottom{*_pnlBottom.setCentralWidget(make_unique())}; WBoxLayout& _lytBottom{*_cntBottom.setLayout(make_unique())}; WPushButton& _btnDummy{*_lytBottom.addWidget(make_unique("Dummy button just in order to avoid somebody saying the final stretch would not make sense"))}; }; CApplication::CApplication(const WEnvironment& rcEnv) : CThemedApplication{rcEnv} , _Server{*environment().server()} { setTitle("bug repro"); _lytBottom.addStretch(100); _pnlBottom.setDisabled(true); // final action after creating the UI enableUpdates(); } int main(int argc, char* argv[]) { return WRun(argc, argv, [](const WEnvironment& rcEnv) { try { return make_unique(rcEnv); } catch (const std::exception& rcException) { cerr << "exception " << typeid(remove_cvref::type).name() << ": " << rcException.what() << endl; #if DEBUG exit(-1); #endif throw; } }); }