<?xml version="1.0" encoding="iso-8859-1"?>
<!--

	** XHPD, XML hierarchical program description **

	This is digested by either ubuildinit, or by RAPP-type things.

-->
<xhpd version="1.0">

	<propset id="cpref">
		<property name="background" value="@background" />
		<property name="foreground" value="@foreground" />
		<property name="highlight" value="@highlight" />
		<property name="shadow" value="@shadow" />
		<property name="iecolor" value="@extra" />
		<property name="tentry" value="@tentry" />
	</propset>
	<propset id="selcpref">
		<property name="sel-background" value="@selback" />
		<property name="sel-foreground" value="@selfore" />
	</propset>
	<propset id="helvfont">
		<property name="font" value="-*-helvetica-medium-r-*-*-12-*-*-*-*-*-iso8859-*" />
	</propset>

	<application>
		<property name="hint-delay" value="0, 800000" />
		<property name="hint-font" value="-adobe-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*" />
		<property name="hint-foreground" value="#000000" />
		<property name="hint-background" value="#d0f8d8" />
	</application>

	<section name="buildinit">
		<!--{{{  cpreface-->
		<cpreface>
			<![CDATA[
			#include <stdio.h>
			#include <stdlib.h>
			#include <string.h>
			#include <sys/types.h>
			#include <unistd.h>
			#include <stdarg.h>
			#include <sys/socket.h>
			#include <netinet/in.h>     
			#include <arpa/inet.h>

			#include <X11/Xlib.h>
			#include <X11/Xos.h>
			#include <X11/Xatom.h>
			#include <X11/Xutil.h>

			#include <uwg_support.h>
			#include <uwg.h>
			#include <uwg_visual.h>
			#include <uwg_nvisual.h>
			#include <uwg_textops.h>
			#include <uwg_3dops.h>
			#include <uwg_propset.h>

			/* need to add some kind of "middle" set of includes.. */
			#include <uwg_window.h>
			#include <uwg_vde.h>
			#include <uwg_label.h>

			static void do_vde_place (UWGVDE *vde, UWGVisual *parent, int x, int y, int width, int height, void *uptr);

			typedef struct {
				int x, y, width, height;
			} InitialGeom;

			static InitialGeom *new_initial_geom (int x, int y, int width, int height)
			{
				InitialGeom *ig = (InitialGeom *)smalloc (sizeof (InitialGeom));

				ig->x = x;
				ig->y = y;
				ig->width = width;
				ig->height = height;

				return ig;
			}

			static void free_initial_geom (InitialGeom *ig)
			{
				sfree (ig);
			}

			]]>
		</cpreface>
		<!--}}}-->
		<!--{{{  ctail-->
		<ctail>
			<![CDATA[

			int main (int argc, char **argv)
			{
				UWGXContext *xcxt;

				uwg_init (argc, argv);
				xcxt = uwg_new_context (NULL);
				if (!xcxt) {
					fprintf (stderr, "%s: failed to create context\n", *argv);
					exit (EXIT_FAILURE);
				}

				create_vde1 (xcxt);

				uwg_set_property (PROP_HINT_DELAY, 0, 800000);
				uwg_set_property (PROP_HINT_FONT, "-adobe-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*");
				uwg_set_property (PROP_HINT_FOREGROUND_STR, "#000000");
				uwg_set_property (PROP_HINT_BACKGROUND_STR, "#d0f8d8");

				uwg_mainloop ();

				destroy_vde1 ();
				uwg_destroy_context (xcxt);

				return 0;
			}

			static void default_label_initfunc (UWGLabel *label)
			{
				InitialGeom *ig = (InitialGeom *)label->visual->userptr;

				label->set_property (label, PROP_GEOMETRY, ig->x, ig->y, ig->width, ig->height);
				label->set_property (label, PROP_CAPTION, "a label");
				label->set_property (label, PROP_FOREGROUND, uwg_cs_get_preferable (label->visual->xcxt, CPREF_FOREGROUND));
				label->set_property (label, PROP_BACKGROUND, uwg_cs_get_preferable (label->visual->xcxt, CPREF_BACKGROUND));

				return;
			}

			static void default_panel_initfunc (UWGPanel *panel)
			{
				InitialGeom *ig = (InitialGeom *)panel->visual->userptr;

				panel->set_property (panel, PROP_GEOMETRY, ig->x, ig->y, ig->width, ig->height);
				panel->set_property (panel, PROP_CAPTION, "a panel");
				panel->set_property (panel, PROP_FOREGROUND, uwg_cs_get_preferable (panel->visual->xcxt, CPREF_FOREGROUND));
				panel->set_property (panel, PROP_BACKGROUND, uwg_cs_get_preferable (panel->visual->xcxt, CPREF_BACKGROUND));

				return;
			}

			static void do_vde_place (UWGVDE *vde, UWGVisual *parent, int x, int y, int width, int height, void *uptr)
			{
				char *gtype;
				InitialGeom *ig = new_initial_geom (x, y, width, height);

				combo1->get_property (combo1, PROP_TEXT, &gtype);
				fprintf (stderr, "do_vde_place(): [application]: placing [%s] at (%d,%d,%d,%d) inside [%s]\n", gtype, x, y, width, height, parent ? parent->id : "?");

				if (!strcmp (gtype, "UWGLabel")) {
					UWGLabelCB *labelcb = uwg_label_cbcreate ();

					labelcb->initfunc = default_label_initfunc;
					uwg_label_create (parent->xcxt, parent, labelcb, (void *)ig);
				} else if (!strcmp (gtype, "UWGPanel")) {
					UWGPanelCB *panelcb = uwg_panel_cbcreate ();

					panelcb->initfunc = default_panel_initfunc;
					uwg_panel_create (parent->xcxt, parent, panelcb, (void *)ig);
				}

				free_initial_geom (ig);
				return;
			}
			]]>
		</ctail>
		<!--}}}-->
	</section>

	<gadget type="UWGWindow" name="vde1">
		<property name="filename" value="vde1" />
		<property name="caption" value="Test application" />
		<property name="icon-name" value="testapp" />
		<property name="width" value="522" />
		<property name="height" value="426" />
		<property name="position" value="user" />
		<property name="style" value="border" />
		<property name="visible" value="true" />
		<property set="cpref" />

		<gadget type="UWGPanel">
			<property set="cpref" />
			<property name="geometry" value="0,0,522,32" />
			<property name="indent" value="1" />

			<gadget type="UWGSpeedBtn">
				<property name="geometry" value="4,4,24,24" />
				<property set="cpref" />
				<property name="img-up" value="/home/develop/wgbuilder/wgb_ide/images/fileOpen.xpm" />
				<property name="style" value="popup" />
				<property name="hint" value="open XHPD file" />
			</gadget>
			<gadget type="UWGSpeedBtn">
				<property name="geometry" value="28,4,24,24" />
				<property set="cpref" />
				<property name="img-up" value="/home/develop/wgbuilder/wgb_ide/images/viewGadgets.xpm" />
				<property name="style" value="popup" />
				<property name="hint" value="plant new gadget" />

				<action name="on_click">
					<![CDATA[
						realvde->place_gadget (realvde, do_vde_place, NULL);
					]]>
				</action>
			</gadget>
			<gadget name="combo1" type="UWGComboBox">
				<property name="geometry" value="64,6,192,20" />
				<property set="cpref" />
				<property set="helvfont" />
				<property name="text" value="UWGLabel" />
				<property name="style" value="popup" />

				<action name="on_create">
					<![CDATA[
						gadget->add_item (gadget, "UWGLabel");
						gadget->add_item (gadget, "UWGButton");
					]]>
					<command name="add_item"><arg value="UWGPanel" /></command>
				</action>
			</gadget>
		</gadget>
		<gadget type="UWGPanel">
			<property set="cpref" />
			<property name="geometry" value="0,32,522,394" />
			<property name="indent" value="1" />

			<gadget type="UWGPanel">
				<property set="cpref" />
				<property name="visible" value="1" />
				<property name="geometry" value="4,4,514,386" />
				<property name="indent" value="-1" />

				<!--{{{  realvde:UWGVDE-->
				<gadget name="realvde" type="UWGVDE">
					<property name="visible" value="1" />
					<property name="geometry" value="1,1,512,384" />
					<property name="align-to-grid" value="1" />
					<property name="background" value="white" />
					<property name="foreground" value="black" />

					<gadget type="UWGButton">
						<property set="cpref" />
						<property name="geometry" value="64,64,128,96" />
						<property name="caption" value="testing..." />
					</gadget>
					<gadget type="UWGPanel">
						<property set="cpref" />
						<property name="geometry" value="256,32,192,192" />
						<property name="indent" value="-2" />

						<gadget type="UWGButton">
							<property set="cpref" />
							<property set="helvfont" />
							<property name="geometry" value="32,32,96,32" />
							<property name="caption" value="nested gadget" />
						</gadget>
					</gadget>
				</gadget>
				<!--}}}-->
			</gadget>
		</gadget>

		<action name="on_delete">
			<command name="@termloop">
				<arg value="0" />
			</command>
		</action>
	</gadget>

</xhpd>

