Difference between revisions of "LavishGUI:User Interface XML Files"

From Lavish Software Wiki
Jump to navigation Jump to search
Line 27: Line 27:
  
 
=== Example XML File ===
 
=== Example XML File ===
<?xml version="1.0" encoding="UTF-8"?>
+
  <?xml version="1.0" encoding="UTF-8"?>
<ISUI>
+
  <ISUI>
<Window name='Test Window'>
+
  <Window name='Test Window'>
<X>150</X>
+
  <X>150</X>
<Y>100</Y>
+
  <Y>100</Y>
<Width>400</Width>
+
  <Width>400</Width>
<Height>400</Height>
+
  <Height>400</Height>
<Children>
+
  <Children>
<TabControl name='Test TabControl'>
+
  <TabControl name='Test TabControl'>
<Width>100%</Width>
+
  <X>5%</X>
<Height>100%</Height>
+
  <Width>90%</Width>
<Tabs>
+
  <Height>95%</Height>
<Tab name='Main'>
+
  <Tabs>
<button name='Test Button'>
+
  <Tab name='Main'>
<X>10%</X>
+
  <button name='Test Button'>
<Y>10%</Y>
+
  <X>10%</X>
<Width>80</Width>
+
  <Y>10%</Y>
<Height>20</Height>
+
  <Width>80</Width>
<AutoTooltip>This is a test button</AutoTooltip>
+
  <Height>20</Height>
<Text>Test Button</Text>
+
  <AutoTooltip>This is a test button</AutoTooltip>
<OnLeftClick>MessageBox -ok "You clicked the button."</OnLeftClick>
+
  <Text>Test Button</Text>
</button>
+
  <OnLeftClick>MessageBox -ok "You clicked the button."</OnLeftClick>
+
  </button>
<checkbox name='Test Checkbox'>
+
 
<X>30%</X>
+
  <checkbox name='Test Checkbox'>
<Y>10%</Y>
+
  <X>50%</X>
<Width>100</Width>
+
  <Y>10%</Y>
<Height>20</height>
+
  <Width>100</Width>
<Text>Test Checkbox</Text>
+
  <Height>20</height>
<OnLeftClick>echo Is checkbox checked? ${This.Checked}</OnLeftClick>
+
  <Text>Test Checkbox</Text>
</checkbox>
+
  <OnLeftClick>echo Is checkbox checked? ${This.Checked}</OnLeftClick>
+
  </checkbox>
<combobox name='Test Combobox'>
+
 
<X>10%</X>
+
  <combobox name='Test Combobox'>
<Y>20%</Y>
+
  <X>10%</X>
<Width>125</Width>
+
  <Y>20%</Y>
<Height>20</Height>
+
  <Width>125</Width>
<Items>
+
  <Height>20</Height>
<Item Value='1'>Cheese</Item>
+
  <Items>
<Item Value='2'>Pickles</Item>
+
  <Item Value='1'>Cheese</Item>
</Items>
+
  <Item Value='2'>Pickles</Item>
</combobox>
+
  </Items>
+
  </combobox>
<listbox name='Test Listbox'>
+
 
<X>10%</X>
+
  <commandbutton name='Test Commandbutton'>
<Y>50%</Y>
+
  <X>10%</X>
<Width>125</Width>
+
  <Y>30%</Y>
<Height>100</Height>
+
  <Width>120</Width>
<Items>
+
  <Height>20</Height>
<Item Value='1'>Spider-Man</Item>
+
  <Text>Test Commandbutton</Text>
<Item Value='2'>Batman</Item>
+
  <Command>echo Don't Press Me!</Command>
<Item Value='3'>Superman</Item>
+
  </commandbutton>
<Item Value='4'>Donkey Kong</Item>
+
 
</Items>
+
  <listbox name='Test Listbox'>
</listbox>
+
  <X>10%</X>
</Tab>
+
  <Y>50%</Y>
<Tab name='Secondary'>
+
  <Width>125</Width>
<slider name='Test Slider'>
+
  <Height>100</Height>
<X>2%</X>
+
  <Items>
<Y>2%</Y>
+
  <Item Value='1'>Spider-Man</Item>
<Width>100</Width>
+
  <Item Value='2'>Batman</Item>
<Height>20</Height>
+
  <Item Value='3'>Superman</Item>
</slider>
+
  <Item Value='4'>Donkey Kong</Item>
+
  </Items>
<gauge name='Test Gauge' ColorMask='ff33ffff'>
+
  </listbox>
<X>2%</X>
+
  </Tab>
<Y>10%</Y>
+
  <Tab name='Secondary'>
<Height>12</Height>
+
  <slider name='Test Slider'>
<Width>r20</Width>
+
  <X>2%</X>
<Range>100</Range>
+
  <Y>2%</Y>
<OnLoad>echo This:SetValue[57]</OnLoad>
+
  <Width>100</Width>
<Filler ColorMask='FF0066cc' Template='gaugefiller'>
+
  <Height>20</Height>
<Height>100%</Height>
+
  <OnChange>This.Parent.FindChild[Test Gauge]:SetValue[${This.Value}]</OnChange>
<Width>100%</Width>
+
  </slider>
</Filler>
+
 
</gauge>
+
  <gauge name='Test Gauge'>
</Tab>
+
  <X>2%</X>
<Tab name='Backup'>
+
  <Y>10%</Y>
<console name='Test Console'>
+
  <Height>12</Height>
<X>0</X>
+
  <Width>r20</Width>
<Y>0</Y>
+
  <Range>100</Range>
<Width>100%</Width>
+
  </gauge>
<Height>20%</Height>
+
  </Tab>
</console>
+
  <Tab name='Backup'>
+
  <console name='Test Console'>
<text name='Test Text'>
+
  <X>5</X>
<X>0</X>
+
  <Y>5</Y>
<Y>22%</Y>
+
  <Width>r10</Width>
<Width>160</Width>
+
  <Height>20%</Height>
<Height>20</Height>
+
  </console>
<Text>This is not a test.</Text>
+
 
</text>
+
  <text name='Test Text'>
+
  <X>5</X>
<commandentry name='Test Commandentry'>
+
  <Y>23%</Y>
<X>0</X>
+
  <Width>r10</Width>
<Y>30%</Y>
+
  <Height>20</Height>
<Width>100%</Width>
+
  <Text>This is not a test.</Text>
<Height>20</Height>
+
  </text>
</commandentry>
+
 
+
  <commandentry name='Test Commandentry'>
<textedit name='Test Textedit'>
+
  <X>5</X>
<X>0</X>
+
  <Y>30%</Y>
<Y>45%</Y>
+
  <Width>r10</Width>
<Width>100%</Width>
+
  <Height>20</Height>
<Height>20%</Height>
+
  </commandentry>
</textedit>
+
 
+
  <textedit name='Test Textedit'>
<textentry name='Test Textentry'>
+
  <X>5</X>
<X>0</X>
+
  <Y>45%</Y>
<Y>70%</Y>
+
  <Width>r10</Width>
<Width>100%</Width>
+
  <Height>20%</Height>
<Height>20</Height>
+
  </textedit>
<OnKeyDown>if ${Key.Equal["enter"]}
+
 
  {
+
  <textentry name='Test Textentry'>
  echo ${This.Text.Escape}
+
  <X>5</X>
  This:SetText[""]
+
  <Y>70%</Y>
  }
+
  <Width>r10</Width>
</OnKeyDown>
+
  <Height>20</Height>
</textentry>
+
  <OnKeyDown>if ${Key.Equal["enter"]}
</Tab>
+
    {
</Tabs>
+
    echo ${This.Text.Escape}
</TabControl>
+
    This:SetText[""]
</Children>
+
    }
</Window>
+
  </OnKeyDown>
</ISUI>
+
  </textentry>
 +
  </Tab>
 +
  </Tabs>
 +
  </TabControl>
 +
  </Children>
 +
  </Window>
 +
  </ISUI>
 +
 
 
== Creating Skins ==
 
== Creating Skins ==
 
See [[LavishGUI:Skins]]
 
See [[LavishGUI:Skins]]

Revision as of 01:07, 28 October 2008

Introduction

Required Background

A basic understanding of XML or HTML is required. This quick run-down should get you going.

XML, simply described, is a way to arrange items. It is made up of XML tags and text. XML tags look like <Item>, and must be closed, which can look like </Item>. This sequence marks the beginning and end of an "Item". There can be any number of item types, such as <A> <B> <C> and so on. Each begin tag can have attributes. Attributes have a name, an equal sign, and a quoted value (either ' or " can be used), and are placed inside the begin tag like so: <Item Name="My Item">. Items can have text and/or more items contained between the begin tag and end tag. Items that have no text or items inside of them may be closed in the begin tag, like this: <Item Name="My Item" />. There can be multiple items of the same type within the same item.

Here is some sample XML:

<ISUI>
  <Window Name="My Window">
    <X>100</X>
    <Y>100</Y>
    <Width>300</Width>
    <Height>150</Height>
  </Window>
</ISUI>

In this example, there is ISUI,which is Inner Space specific (another application would use its own tag), which contains a Window (which has an attribute called "Name" with the value "My Window"). X, Y, Width and Height are items inside Window, each of which contain a text value. X, Y, Width and Height are also referred to as Properties of Window.

Terminology

  • Attribute: A name and value given in an XML "begin tag"
  • Child
  • Container
  • Parent
  • Property

Creating Interfaces

Example XML File

 <?xml version="1.0" encoding="UTF-8"?>
 <ISUI>
 	<Window name='Test Window'>
 	<X>150</X>
 	<Y>100</Y>
 	<Width>400</Width>
 	<Height>400</Height>
 	<Children>
 		<TabControl name='Test TabControl'>
 			<X>5%</X>
 			<Width>90%</Width>
 			<Height>95%</Height>
 			<Tabs>
 				<Tab name='Main'>
 					<button name='Test Button'>
 					<X>10%</X>
 					<Y>10%</Y>
 					<Width>80</Width>
 					<Height>20</Height>
 					<AutoTooltip>This is a test button</AutoTooltip>
 					<Text>Test Button</Text>
 					<OnLeftClick>MessageBox -ok "You clicked the button."</OnLeftClick>
 					</button>
 					
 					<checkbox name='Test Checkbox'>
 					<X>50%</X>
 					<Y>10%</Y>
 					<Width>100</Width>
 					<Height>20</height>
 					<Text>Test Checkbox</Text>
 					<OnLeftClick>echo Is checkbox checked? ${This.Checked}</OnLeftClick>
 					</checkbox>
 					
 					<combobox name='Test Combobox'>
 					<X>10%</X>
 					<Y>20%</Y>
 					<Width>125</Width>
 					<Height>20</Height>
 					<Items>
 						<Item Value='1'>Cheese</Item>
 						<Item Value='2'>Pickles</Item>
 					</Items>
 					</combobox>
 					
 					<commandbutton name='Test Commandbutton'>
 					<X>10%</X>
 					<Y>30%</Y>
 					<Width>120</Width>
 					<Height>20</Height>
 					<Text>Test Commandbutton</Text>
 					<Command>echo Don't Press Me!</Command>
 					</commandbutton>
 
 					<listbox name='Test Listbox'>
 					<X>10%</X>
 					<Y>50%</Y>
 					<Width>125</Width>
 					<Height>100</Height>
 					<Items>
 						<Item Value='1'>Spider-Man</Item>
 						<Item Value='2'>Batman</Item>
 						<Item Value='3'>Superman</Item>
 						<Item Value='4'>Donkey Kong</Item>
 					</Items>
 					</listbox>
 				</Tab>
 				<Tab name='Secondary'>
 					<slider name='Test Slider'>
 					<X>2%</X>
 					<Y>2%</Y>
 					<Width>100</Width>
 					<Height>20</Height>
 					<OnChange>This.Parent.FindChild[Test Gauge]:SetValue[${This.Value}]</OnChange>
 					</slider>
 
 					<gauge name='Test Gauge'>
 					<X>2%</X>
 					<Y>10%</Y>
 					<Height>12</Height>
 					<Width>r20</Width>
 					<Range>100</Range>
 					</gauge>
 				</Tab>
 				<Tab name='Backup'>
 					<console name='Test Console'>
 					<X>5</X>
 					<Y>5</Y>
 					<Width>r10</Width>
 					<Height>20%</Height>
 					</console>
 					
 					<text name='Test Text'>
 					<X>5</X>
 					<Y>23%</Y>
 					<Width>r10</Width>
 					<Height>20</Height>
 					<Text>This is not a test.</Text>
 					</text>
 
 					<commandentry name='Test Commandentry'>
 					<X>5</X>
 					<Y>30%</Y>
 					<Width>r10</Width>
 					<Height>20</Height>
 					</commandentry>
 					
 					<textedit name='Test Textedit'>
 					<X>5</X>
 					<Y>45%</Y>
 					<Width>r10</Width>
 					<Height>20%</Height>
 					</textedit>
 		
 					<textentry name='Test Textentry'>
 					<X>5</X>
 					<Y>70%</Y>
 					<Width>r10</Width>
 					<Height>20</Height>
 					<OnKeyDown>if ${Key.Equal["enter"]}
 						   {
 						   echo ${This.Text.Escape}
 						   This:SetText[""]
 						   }
 					</OnKeyDown>
 					</textentry>
 				</Tab>
 			</Tabs>
 		</TabControl>
 	</Children>
 	</Window>
 </ISUI>

Creating Skins

See LavishGUI:Skins

See Also

LavishGUI