You have some control, holding a value, which actually should transfer to a Dataclass, or a layer between it.
I found now this solution for it:
Code: Select all
template<class functor, class event>
class GUI2Data : public wxEvtHandler
{
functor f;
public:
GUI2Data() {}
GUI2Data(functor f):f(f)
{
}
void Setfunctor(functor func)
{
f = func;
}
void OnSendData(event& e)
{
wxControl* control = dynamic_cast<wxControl*>(e.GetEventObject());
if(control)
f(control->GetLabel().fn_str());
}
};
Or something else.
The Event is the Event, which should trigger this operation.
f.e. OnText, or a FocusEvent.
I am not sure if control->GetLabel() works for all controls probably, but I think it should work pretty good.
The Signature of the functor needs to be some string type. f.e. std:: (w)string, or wxString, const (w)char*
Usage:
Code: Select all
// in a panelclass f.e.
GUI2Data<boost::function<void (std::string)>,wxFocusEvent> gui2data(boost::bind(&foo::SetName,classpointer,_1));
Connect(wxEVT_KILL_FOCUS,wxFocusEventHandler((GUI2Data<void (std::string),wxFocusEvent>::OnSendData)),0,gui2data);
phlox