<?xml version="1.0"?>

<!-- 	
Kulula.XML

Configuration file for the Kulula language and the compiler.
Enhances the Kulula language.
For details read the manual. -->

<Kulula version="0" subversion="6" author="salam@student.ethz.ch">

	<!--
	Standard Modules that should be available in every new built component 
	(list of Module names separated with commas) -->
	
	<Import value="WMComponents, Utilities, AosFS, 
	WMWindowManager, WMRectangles, AosRandom, "/>
	
	<!-- 	
	Shorthand and first class citizens 
	
	Attributes of Type-tag:
			wrap				the type name in Kulula
			oberon				the type name in Oberon
			
	The Type-tag may contain several Property-tags (= first class citizen. If not, it is just a shorthand).
			
	Attributes of Property-tag:
		type				see description later ('Name', 'Literal', 'Numerical', 'Autosize')
		place				where should the code be emitted ('Init' = in the procedure where the window is constructed)
		object				the place holder of the object in the oberon-attribute (standard is a star *)
		value				if there is a value (literals and numericals) this is the place holder of the value in the oberon-attribute
		oberon				the Oberon code with the place holders of the object-attribute (and sometimes value-attribute)
		default				defines, if the property is emitted, even if it is not stated in the WITH-property-list
		tag					this attribute contains the key name of the property (will be stored in a tag in the components XML)
			
	Types of first class citizens:
		1. 	'Name' 		as keywords (in Oberon code BOOLEAN),
		2. 	'Literal' 		as strings between parenthesises (Utilities.String),
		3. 	'Numerical' 	as integers (LONGINT)
		And special types:
			'Autosize' 		is code emitted when there was no size indication. -->
			
	<Types>
		<!-- The basic types - shorthands -->
		<Type wrap="Boolean" oberon="BOOLEAN"/>
		<Type wrap="Integer" oberon="INTEGER"/>
		<Type wrap="Number" oberon="LONGINT"/>
		<Type wrap="Bit" oberon="BOOLEAN"/>
		<Type wrap="String" oberon="ARRAY 255 OF CHAR"/>
		<Type wrap="AoC" oberon="ARRAY 255 OF CHAR"/>
		<Type wrap="AoC5011" oberon="ARRAY 5011 OF CHAR"/>
		<Type wrap="AoC255" oberon="ARRAY 255 OF CHAR"/>
		
		<!-- Kulula Foundation Classes -->
		<Type wrap="MediaPanel" oberon="MediaPanel.MediaPanel"/>
		<Type wrap="Text" oberon="KFCText.Text"/>
		
		<!-- Common visible components -->
		<Type wrap="Panel" oberon="WMStandardComponents.Panel">
			<Property type="Autosize" place="Init" object="*" oberon="*.bounds.SetExtents( 80, 20 );"/>
			<Property type="Numeric" place="Init" object="*" value="?" oberon="*.bounds.SetWidth( ? );" />
			<Property type="Numeric" place="Init" object="*" value="?" oberon="*.bounds.SetHeight( ? );" />
		</Type>
		
		<Type wrap="Button" oberon="WMStandardComponents.Button">
			<Property type="Autosize" place="Init" object="*" oberon="*.bounds.SetExtents( 80, 20 );"/>
			<Property type="Literal" place="Init" object="*" value="?" oberon="*.caption.SetAOC(?^);" tag="caption"/>			
<!--			<Property type="Literal" place="Init" object="*" value="?" oberon="*.caption.SetAOC(&#x22;?&#x22;);"/>			-->
			<Property type="Numeric" place="Init" object="*" value="?" oberon="*.bounds.SetWidth( ? );" />
			<Property type="Numeric" place="Init" object="*" value="?" oberon="*.bounds.SetHeight( ? );" />
		</Type>

		<Type wrap="ToggleButton" oberon="KFCToggleButton.ToggleButton">
			<Property type="Autosize" place="Init" object="*" oberon="*.bounds.SetExtents( 80, 20 );"/>
			<Property type="Name" name="OFF" default="TRUE" place="Init" object="*" oberon="*.SetState(FALSE);"/>
			<Property type="Name" name="ON" place="Init" object="*" oberon="*.SetState(TRUE);"/>
			<Property type="Literal" place="Init" object="*" value="?" oberon="*.SetCaptionOn(?^);" tag="captionon"/>			
			<Property type="Literal" place="Init" object="*" value="?" oberon="*.SetCaptionOff(?^);" tag="captionoff"/>			
			<Property type="Numeric" place="Init" object="*" value="?" oberon="*.bounds.SetWidth( ? );" />
			<Property type="Numeric" place="Init" object="*" value="?" oberon="*.bounds.SetHeight( ? );" />
		</Type>
				
		<Type wrap="Link" oberon="WMStandardComponents.Button"/>			
		
		<Type wrap="Textfield" oberon="WMEditors.Editor">
			<Property type="Autosize" place="Init" object="*" oberon="*.bounds.SetExtents( 150, 20);"/>
			<Property type="Name" name="SINGLELINE" place="Init" object="*" oberon="*.multiLine.Set(FALSE);"/>
			<Property type="Name" name="BORDER" place="Init" object="*" oberon="*.tv.showBorder.Set(TRUE);"/>
			<Property type="Name" name="MULTILINE" place="Init" object="*" oberon="*.multiLine.Set(TRUE);"/>
			<Property type="Literal" place="Init" object="*" value="?" oberon="*.SetAsString(?^);" tag="text"/>
			<Property type="Numeric" place="Init" object="*" value="?" oberon="*.bounds.SetWidth( ? );" />
			<Property type="Numeric" place="Init" object="*" value="?" oberon="*.bounds.SetHeight( ? );" />
			<Property type="Name" name="SOMETHING" place="Init" default="TRUE" object="--" oberon="(* a default value *)"/>
		</Type>

	</Types>

	<!-- Reserved words -->
	<Reserved>
	
		<!-- Reserved since they are keywords of the language -->
		<Keyword name="THE"/>
		<Keyword name="OF"/>
		<Keyword name="AS"/>
		<Keyword name=","/>
		<Keyword name="."/>
		<Keyword name="SEE"/>
		<Keyword name="ACT"/>
		<Keyword name="OFFER"/>
		<Keyword name="DATA"/>
		<Keyword name="AT"/>
		<Keyword name="IN"/>
		<Keyword name="RAISES"/>
		<Keyword name="BUT"/>
		<Keyword name="NOT"/>
		<Keyword name="WHERE"/>
		<Keyword name="FROM"/>
		<Keyword name="-"/>
		<Keyword name="="/>
		<Keyword name="%3C"/>
		<Keyword name="AUTO"/>
		<Keyword name="ALLOVER"/>
		<Keyword name="RIGHT"/>
		<Keyword name="LEFT"/>
		<Keyword name="CENTER"/>
		<Keyword name="TOP"/>
		<Keyword name="BOTTOM"/>
		<Keyword name="("/>
		<Keyword name=")"/>
		<Keyword name="WITH"/>
		<Keyword name="MY"/>
		<Keyword name="OTHERS"/>
		
		<!-- 	Reserved for future implementations, or 
				Oberon expressions -->
		<Future name="IS"/>
		<Future name="AUTO"/>
		<Future name="MAYBE"/>
		<Future name="IF"/>
		<Future name="THEN"/>
		<Future name="ELSE"/>
		<Future name="END"/>
		<Future name="LOOP"/>
		<Future name="DO"/>
		<Future name="WHILE"/>
		<Future name="UNTIL"/>
		<Future name=";"/>
		<Future name="*"/>
		<Future name="#"/>
		<Future name="%"/>
		<Future name="!"/>
		<Future name="~"/>	

	</Reserved>
	
	<!--
		The trailer is used to specify standard commands that should be appended to the Oberon Module. -->
	<Trailer object="xyz" value="S.Free xyz ~\nxyz.Start~\nxyz.Stop~\nPC0.Compile /s xyz.Mod~ PET.Open xyz.Mod"/>
	
	<!--
	Positioning functions:
		function tag with attributes:
			name	identifier to use positioning function -->
	<Positioning>
		<Function name="Random" Type="Oberon">
			
			(* Returns a randomly chosen area for a Kulula component *)
			PROCEDURE KLLRandom( o: ANY; i : INTEGER ) : WMRectangles.Rectangle;
			VAR
				r: WMRectangles.Rectangle; z: REAL;
				KLLindex: LONGINT;
				tmp: Utilities.String;				
				RandomNumbers: AosRandom.Sequence;
			BEGIN
				NEW(RandomNumbers);
				tmp := GetAttributeValue( Kulula.aKLLindex );
				Utilities.StrToInt( tmp^, KLLindex );
				INC(KLLindex, 3);
				INC( KLLindex );
				IF o IS Kulula.VisibleComponent THEN
					RandomNumbers.InitSeed( KLLindex * (i + 1) );
					z := RandomNumbers.Uniform();
					r.l := ENTIER( RandomNumbers.Uniform() * bounds.GetWidth() );
					r.t := ENTIER( RandomNumbers.Uniform() * bounds.GetHeight() );
					r.r := r.l + ENTIER( RandomNumbers.Uniform() * ( bounds.GetWidth() - r.l) );
					r.b := r.t + ENTIER( RandomNumbers.Uniform() * ( bounds.GetHeight() - r.t) );
				ELSIF o IS WMComponents.VisualComponent THEN
					RandomNumbers.InitSeed( KLLindex * (i + 1) );
					z := RandomNumbers.Uniform();
					r.l := ENTIER( RandomNumbers.Uniform() * bounds.GetWidth() );
					r.t := ENTIER( RandomNumbers.Uniform() * bounds.GetHeight() );
					r.r := r.l + ENTIER( RandomNumbers.Uniform() * ( bounds.GetWidth() - r.l) );
					r.b := r.t + ENTIER( RandomNumbers.Uniform() * (bounds.GetHeight() - r.t) );
				END;
				RETURN r
			END KLLRandom;</Function>
		<Function name="ZicZac" Type="Oberon">
			
			(* Returns an area for a Kulula component in the shape of a big Z letter: 
			firstly, at the left top corner. Secondly, on the right of the first component.
			The third component in the center. After that at the bottom left and finally 
			at the bottom right *)
			PROCEDURE KLLZicZac( o: ANY; i : INTEGER ) : WMRectangles.Rectangle;
			VAR
				r: WMRectangles.Rectangle; z: REAL;
			BEGIN				
				(* TODO *)
				RETURN r
			END;</Function>
	</Positioning>

</Kulula>


