Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » U++ community news and announcements » CtrlMapper
CtrlMapper [message #52030] Mon, 08 July 2019 10:40
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Sometimes CtrlRetriver is not flexible enough. For such cases I have now introduced really primitive helper class CtrlMapper, which is sort of similar, buth does the value transfer immediately. Demonstrated in reference/CtrlMapper

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

#define LAYOUTFILE <CtrlMapper/CtrlMapper.lay>
#include <CtrlCore/lay.h>

struct MyStruct {
	String text;
	bool   option;
};

struct MyDlg : WithMyDlgLayout<TopWindow> {
	typedef MyDlg CLASSNAME;
	
	void Map(CtrlMapper& m, MyStruct& s);
	
	MyDlg();
};

MyDlg::MyDlg()
{
	CtrlLayoutOK(*this, "My Dialog");
}

void MyDlg::Map(CtrlMapper& m, MyStruct& s)
{
	m
		(text, s.text)
		(option, s.option)
	;
}

GUI_APP_MAIN
{
	MyStruct data;
	data.text = "Some text";
	data.option = true;

	MyDlg dlg;
	dlg.Map(CtrlMapper().ToCtrls(), data);
	if(dlg.Run() == IDOK)
		dlg.Map(CtrlMapper().ToValues(), data);

	PromptOK(String() << "text: [* \1" << data.text << "\1]&"
	                  << "option: [* " << data.option);
}


Previous Topic: Ide: Debug/Test in Valgrind now outputs error to error console
Next Topic: ide: Now supports search in console output
Goto Forum:
  


Current Time: Fri Mar 29 02:12:46 CET 2024

Total time taken to generate the page: 0.01555 seconds