arsd.minigui_xml

A small extension module to arsd.minigui that adds functions for creating widgets and windows from short XML descriptions.

If you choose to use this, it will require arsd.dom to be compiled into your project too.

1 import arsd.minigui_xml;
2 Window window = createWindowFromXml(`
3 	<MainWindow>
4 		<Button label="Hi!" />
5 	</MainWindow>
6 `);
More...

Public Imports

arsd.minigui
public import arsd.minigui;

Members

Functions

createWindowFromXml
Window createWindowFromXml(string xml)
createWindowFromXml
Window createWindowFromXml(Document document)
makeWidgetFromString
Widget makeWidgetFromString(string xml, Widget parent)
miniguiWidgetFromXml
Widget miniguiWidgetFromXml(Element element, Widget parent)

Detailed Description

To add custom widgets to the minigui_xml factory, you need to register them with FIXME.

You can attach some events right in the XML using attributes. The attribute names are onEVENTNAME or ondirectEVENTNAME and the values are one of the following three value types:

$(LIST * If it starts with &, it is a delegate you need to register using the FIXME function.

* If it starts with (, it is a string passed to the arsd.dom.querySelector function to get an element reference

* Otherwise, it tries to call a script function (if scripting is available). )

Keep in mind For example, to make a page widget that changes based on a drop down selection, you may:

1 <DropDownSelection onchange="$(+PageWidget).setCurrentTab">
2 	<option>Foo</option>
3 	<option>Bar</option>
4 </DropDownSelection>
5 <PageWidget name="mypage">
6 	<!-- contents elided -->
7 </PageWidget>

That will create a select widget that when it changes, it will look for the next PageWidget sibling (that's the meaning of +PageWidget, see css selector syntax for more) and call its setCurrentTab method.

Since the function knows setCurrentTab takes an integer, it will automatically pull the intValue member out of the event and pass it to the method.

The given XML is the same as the following D:

1 auto select = new DropDownSelection(parent);
2 select.addOption("Foo");
3 select.addOption("Bar");
4 auto page = new PageWidget(parent);
5 page.name = "mypage";
6 
7 select.addEventListener("change", (Event event) {
8 	page.setCurrentTab(event.intValue);
9 });

Meta