|
#include <Wt/WApplication.h>
|
|
#include <Wt/WBreak.h>
|
|
#include <Wt/WCheckBox.h>
|
|
#include <Wt/WContainerWidget.h>
|
|
#include <Wt/WPushButton.h>
|
|
|
|
#include <iostream>
|
|
#include <memory>
|
|
|
|
class MY_APPLICATION : public Wt::WApplication
|
|
{
|
|
public:
|
|
explicit MY_APPLICATION(const Wt::WEnvironment & i_enviromment) :
|
|
WApplication(i_enviromment)
|
|
{
|
|
m_check_box = root()->addWidget(std::make_unique<Wt::WCheckBox>("An option"));
|
|
|
|
m_check_box->checked().connect(this, & MY_APPLICATION::checked);
|
|
m_check_box->unChecked().connect(this, & MY_APPLICATION::unchecked);
|
|
m_check_box->changed().connect(this, & MY_APPLICATION::changed);
|
|
|
|
root()->addWidget(std::make_unique<Wt::WBreak>());
|
|
|
|
auto toggle_button = root()->addWidget(std::make_unique<Wt::WPushButton>("Toggle option"));
|
|
toggle_button->clicked().connect(this, & MY_APPLICATION::toggle_option);
|
|
}
|
|
|
|
private:
|
|
void checked(){ std::cout << "The checkbox was checked" << std::endl; }
|
|
void unchecked(){ std::cout << "The checkbox was unchecked" << std::endl; }
|
|
void changed() { std::cout << "The checkbox was changed" << std::endl; }
|
|
|
|
void toggle_option()
|
|
{
|
|
const bool is_checked = m_check_box->isChecked();
|
|
m_check_box->setChecked(! is_checked);
|
|
}
|
|
|
|
Wt::WCheckBox * m_check_box {nullptr};
|
|
};
|
|
|
|
int main(int i_argc, char ** i_argv)
|
|
{
|
|
return Wt::WRun(i_argc, i_argv, [](const Wt::WEnvironment &env)
|
|
{
|
|
return std::make_unique<MY_APPLICATION>(env);
|
|
});
|
|
}
|