NAME

XMLBuilder - Build Win32::GUIs using XML

SYNOPSIS

use XMLBuilder;
&Win32::GUI::XMLBuilder::build(*DATA);
&Win32::GUI::XMLBuilder::buildfile("file.xml");
&Win32::GUI::Dialog;
...

__END__
<GUI>

..
</GUI>

DESCRIPTION

This module allows Win32::GUIs to be built using XML. For examples on usage please look in samples/ directory.

XML SYNTAX

XMLBuilder will parse an XML file or string that contains elements that describe a Win32::GUI object.

All XML documents must be enclosed in <GUI>..</GUI> elements and each separate GUI window must be enclosed in <Window>..</Window> elements. To create a N-tier window system one might use a construction similar to: -

<GUI>
	<Window name="W_1">
		...
	</Window>
	<Window name="W_2">
		...
	</Window>
		...
	<Window name="W_N">
		...
	</Window>
</GUI>

ATTRIBUTES

Elements can additionally be supplemented with attributes that describe its corresponding Win32::GUI object's properties such as top, left, height and width. These properties usually include those provided as standard in each Win32::GUI class. I.e.

<Window height="200" width="200" title="My Window"/>

Elements that require referencing in your code should be given a name attribute. An element with attribute: -

<Button name="MyButton"/>

can be called as $GUI{'name'} and event subroutines called using MyButton_Click.

Attributes can contain Perl code or variables and generally any attribute that contains a '$' symbol or begins with 'WS_' will be evaluated. This is useful when one wants to create dynamically sizing windows: -

<Window 
	name='W'
	left='0' top='0' 
	width='400' height='200' 
	style='WS_CLIPCHILDREN|WS_OVERLAPPEDWINDOW'
>
	<StatusBar 
		name='S' 
		top='$GUI{W}->ScaleHeight-$GUI{S}->Height' left='0' 
		width='$GUI{W}->ScaleWidth' height='$GUI{S}->Height'
	/>
</Window>

AUTO-RESIZING

Win32::GUI::XMLBuilder will autogenerate an _Resize subroutine by reading in values for top, left, height and width. This will work sufficiently well provided you use values that are dynamic such as $GUI{PARENT_WIDGET}->Width, $GUI{PARENT_WIDGET}->Height for width, height attributes respectively.

SUPPORTED WIDGETS

Most Win32::GUI widgets are supported and general type widgets can added without any modification being added to this module.

Win32::GUI::TabFrame

<TabFrame ... >

</TabFrame>

DEPENDENCIES

XML::Twig
Win32::GUI
Win32::GUI::TabFrame 
	(see http://perso.club-internet.fr/rocherl/Win32GUI.html)

METHODS

Win32::GUI::XMLBuilder::build($xml_string)

Parses $xml_string and constructs a Win32::GUI from its attributes.

Win32::GUI::XMLBuilder::buildfile("file.xml")

Parses "file.xml" and constructs a Win32::GUI from its attributes.

ELEMENTS

<Script>

The <Script> element is parsed before an GUI construction and is useful for defining subroutines and global variables. Variables must be declared using 'our' keyword to be accessible in <Script> elements.

<Icon>

The <Icon> element allows you to specify an Icon for your program.

<Icon file="myicon.ico" name='MyIcon' />
<Font>

Allows you to create a font for use in your program.

<Font 
	name='Bold' 
	size='8' 
	face='Arial' 
	bold='1' 
	italic='0'
/>

You might call this in a label element using something like this: -

<label 
	text='some text' 
	font='$GUI{Bold}' 
	... />.
<Class>

You can create a <Class> element,

<Class name='MyClass' icon='$GUI{MyIcon}'/> 

that can be applied to a <Window .. class='$GUI{MyClass}'>

<Menu>

Creates a menu system. The amount of '>'s prefixing a label specifies the menu items depth. A label '-' (includes '>-', '>>-', etc) creates a separator line.

<Menu name='PopupMenu'>
	<Item label='ContextMenu' sub='0'/>
	<Item label='>Cut' sub='OnEditCut'/>
	<Item label='>Copy' sub='OnEditCopy'/>
	<Item label='>Paste' sub='OnEditPaste'/>
	<item label='>-' sub='0' />
	<Item label='>Select All' sub='SelectAll'/>
</Menu>

See the menus.xml example in the samples/ directory.

<Window>

The <Window> element creates a top level widget. In addition to standard Win32::GUI::Window attributes it also has 'show'. This tells the XMLBuilder to make the Window visible on startup.

<Window show='1' ... />
<TabFrame>

Uses Laurent Rocher's Win32::GUI::TabFrame module. A Tab strip can be created using the following structure: -

<TabFrame ...>
	<Item name='P0' text='Zero'>
		<Label text='Tab 1' .... />
	</Item>
	<Item name='P1' text='One'>
		<Label text='Tab 2' .... />
		..other elements, etc...
	</Item>
</TabFrame>

See the wizard.pl example in the samples/ directory.

<TreeView>

Creates a TreeView. These can be nested deeply using the sub element <Item>. Please look at the treeview.pl example in the samples/ directory.

<TreeView ..>
	<Item .. />
	<Item ..>
		<Item .. />
		<Item .. />
			etc...
	</item>
	...
</TreeView>
<Combobox>

Generate a combobox with drop down items specified with the <Items> elements. In addition to standard attributes for Win32::GUI::Combobox there is also a 'dropdown' attribute that automatically sets the 'style' to 'WS_VISIBLE|2'. In 'dropdown' mode an <Item> element has the additional attribute 'default'.

<Rebar>

See rebar.xml example in samples/ directory.

Generic Elements

Any widget not explicitly mentioned above can be generated by using its name as an element id. For example a Button widget can be created using: -

<Button 
	name='B' 
	text='Push Me' 
	left='20' top='0' 
	width='80' height='20'
/>

3 POD Errors

The following errors were encountered while parsing the POD:

Around line 124:

You forgot a '=back' before '=head1'

Around line 263:

You forgot a '=back' before '=head1'

Around line 265:

=over without closing =back