<?xml version="1.0" encoding="utf-8"?>
<!-- 
   Copyright (c) 2009- Boreal - Information Strategies, published under the BSD license.
   See http://geoprisma.org/license for the full text of the license.
 --> 
<xsl:stylesheet version="1.0" xmlns:php="http://php.net/xsl"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:dyn="http://exslt.org/dynamic"
    xmlns:getmouseposition="http://geoprisma.org/getmouseposition"
    extension-element-prefixes="dyn">

  <xsl:output method="html" indent="yes" encoding="utf-8" omit-xml-declaration="yes"/>
  <xsl:namespace-alias stylesheet-prefix="php" result-prefix="xsl" />

<!-- 
     Function : printWidgetSource

     Print the source code for this widget
-->
  <!-- Call for each widget type-->
  <xsl:template name="getmouseposition:printWidgetSource">
    <script>
        <xsl:attribute name="src" >
             <xsl:value-of select="$g_widgets_url"/>
             <xsl:text>/getmouseposition/GetMousePosition.js</xsl:text>
        </xsl:attribute>    
    </script>
    
    <!-- Traduction (utilisation de la méthode extjs)
                http://extjs.com/learn/Tutorial:Localizing_Ext#Application_Localization
    --> 
    <script>            
        Ext.apply(OpenLayers.Control.Click.prototype, {
            i18n_popup_title : <xsl:value-of select="php:functionString('getmouseposition::getText','i18n_popup_title','JS')" />            
        });   
    </script>
    
   </xsl:template>

<!-- 
     Function : printWidgetExecution

     Print the execution code for this widget
-->
  <!-- Call for each widget name-->
  <xsl:template name="getmouseposition:printWidgetExecution">
    <xsl:param name="pWidgetName" />
    <xsl:param name="pResourceName" />
    <xsl:param name="pMapName" />

    <!-- get draw mode  -->
    <xsl:variable name="pDrawMode">
      <xsl:value-of select="$drawmode" />
    </xsl:variable>
	
	  <!-- get proxy url -->
    <xsl:variable name="pProxyURL">
      <xsl:value-of select="$proxyurl" />
    </xsl:variable>

    <!-- javascript START -->
    <script type="text/javascript">
      oMap = objGPWidget<xsl:value-of select="$pMapName" />;

      var objWidgetOptions = {};
      <xsl:for-each select="./options">
        objWidgetOptions =
        <xsl:call-template name="getObjectFromNode">
          <xsl:with-param name="pNode" select="." />
        </xsl:call-template>;
      </xsl:for-each>

      Ext.apply(objWidgetOptions, {handlerOptions: {"single": true}});

      <!-- creation of the control -->
          objGPWidget<xsl:value-of select="$pWidgetName" /> = new OpenLayers.Control.Click(objWidgetOptions);
		  
          <!-- options for the GeoExtToolbar -->
          objGPWidget<xsl:value-of select="$pWidgetName" />GeoExtToolbarOptions = new GeoExt.Action({
            iconCls: 'getmouseposition',
            control: objGPWidget<xsl:value-of select="$pWidgetName" />,
            map: oMap,
            // button options
            toggleGroup: oMap.id,
            allowDepress: false,
	    <!--todo: gettext-->
            tooltip: <xsl:value-of select="php:functionString('getmouseposition::getText','i18n_button_tooltip','JS')" />,
            // check item options
            group: oMap.id
          });		

		        
    </script>
    <!-- javascript END -->
  </xsl:template>

<!-- 
     Function : drawWidget

     Output the widget depending on the render type
-->
  <!-- Call for each widget name -->
  <xsl:template name="getmouseposition:drawWidget">
    <xsl:param name="pWidgetName" />
      objGPWidget<xsl:value-of select="$pWidgetName" />
  </xsl:template>


<!--
    Function: getWidgetDepedencies

    Return the list of dependencies for this widget
-->
  <!-- Call for each widget type-->
  <xsl:template name="getmouseposition:getWidgetDepedencies">

  </xsl:template>

</xsl:stylesheet>