Home » Community » Coffee corner » Interesting....
Re: Interesting.... [message #1830 is a reply to message #1829] |
Tue, 21 March 2006 22:09   |
 |
mirek
Messages: 14255 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
|
|
|
 |
|
Interesting....
By: mirek on Tue, 21 March 2006 21:41
|
 |
|
Re: Interesting....
By: mirek on Tue, 21 March 2006 22:09
|
 |
|
Re: Interesting....
By: unodgs on Wed, 22 March 2006 08:45
|
 |
|
Re: Interesting....
By: mirek on Wed, 22 March 2006 10:09
|
 |
|
Re: Interesting....
By: hojtsy on Wed, 22 March 2006 13:36
|
 |
|
Re: Interesting....
By: mirek on Wed, 22 March 2006 13:51
|
 |
|
Re: Interesting....
By: mr_ped on Wed, 12 April 2006 12:44
|
 |
|
Re: Interesting....
By: mirek on Wed, 12 April 2006 13:20
|
 |
|
Re: Interesting....
By: tojocky on Tue, 27 October 2009 09:44
|
 |
|
Re: Interesting....
|
 |
|
Re: Interesting....
By: mdelfede on Wed, 28 October 2009 13:34
|
Goto Forum:
Current Time: Mon Apr 28 12:04:21 CEST 2025
Total time taken to generate the page: 0.01169 seconds
|