#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
{
btn_pair p{ std::make_shared<button>(*this) , dat} ;
p.first->events().click( [&](
const arg_click& ei){_m_click( ei);} );
p.first->caption( dat.url) ;
plc_["abc"]<< *(p.first);
plc_.collocate();
ui_el_.push_back(p);
}
{
for(btn_pair &bp : ui_el_)
{
break;
}
}
}
};
}
int main()
{
ui::bar bar;
bar.show();
framework fw;
fw.set(&bar);
fw.work();
}