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 » Coffee corner » Interesting....
Re: Interesting.... [message #1830 is a reply to message #1829] Tue, 21 March 2006 22:09 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
#include <CtrlLib/CtrlLib.h>

struct XmlDlg : public TopWindow {
	Array<Label>                 label;
	ArrayMap<String, EditString> edit;
	ArrayMap<String, Option>     option;

	bool Load(const char *xml);
};

bool XmlDlg::Load(const char *xml)
{
	int y = 10;
	try {
		XmlParser p(xml);
		while(!p.IsTag())
			p.Skip();
		p.PassTag("dialog");
		int linecy = Draw::GetStdFontCy() + 4;
		while(!p.End())
			if(p.TagE("option")) {
				Add(option.Add(p["id"]).SetLabel(p["label"]).TopPos(y, linecy).LeftPos(10, 100));
				y += linecy + 4;
			}
			else
			if(p.TagE("edit")) {
				Add(label.Add().SetLabel(p["label"]).TopPos(y, linecy).LeftPos(10, 30));
				Add(edit.Add(p["id"]).TopPos(y, linecy).LeftPos(40, 60));
				y += linecy + 4;
			}
			else
				p.Skip();
	}
	catch(XmlError e) {
		Exclamation("XML error: " + e);
		return false;
	}
	SetRect(0, 0, 110, y + 10);
	return true;
}

GUI_APP_MAIN
{
	XmlDlg dlg;
	if(!dlg.Load(LoadFile(GetDataFile("dialog.xml"))))
		return;
	dlg.Run();
	int q = dlg.edit.Find("E1");
	if(q >= 0)
		PromptOK("E1 value: " + DeQtf(AsString(~dlg.edit[q])));
}


<?xml version="1.0"?>
<dialog>
	<option id="O1" label="Option"/>
	<option id="O2" label="Another option"/>
	<edit id="E1" label="Text"/>
	<edit id="E2" label="Text2"/>
</dialog>

[Updated on: Tue, 21 March 2006 22:37]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: online Whiteboard
Next Topic: What Smartphone to buy for UPP?
Goto Forum:
  


Current Time: Sat May 04 18:24:21 CEST 2024

Total time taken to generate the page: 0.02877 seconds