#include <nana/gui.hpp>
#include <nana/gui/widgets/button.hpp>
#include <nana/gui/place.hpp>
#include <iostream>
class uiface
{ public:
virtual ~uiface() = 0;
virtual void create_ui_element(const data&) = 0;
};
uiface::~uiface(){}
class framework
{
uiface *uiface_{};
public:
framework()
{
dat.url = "http://nanapro.org/";
cont_.push_back(dat);
dat.url = "nanaproject.wordpress.com";
cont_.push_back(dat);
}
void set(uiface * uif) { uiface_ = uif; }
void work()
{
if(uiface_)
for(auto & ui_el : cont_ )
uiface_->create_ui_element(ui_el);
}
};
namespace ui
{
using namespace nana;
class bar :
public form,
public uiface
{
};
public:
bar() { plc_.div("<vertical abc gap=3>");}
private:
void create_ui_element(const data& dat) override
{
auto p= std::make_shared<button>(*this) ;
p->caption(dat.url) ;
plc_["abc"]<< *p;
plc_.collocate();
}
};
}
int main()
{
ui::bar bar;
bar.show();
framework fw;
fw.set(&bar);
fw.work();
}