Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / docs / source / Vml.html
index 7426ab9..a6142f7 100644 (file)
@@ -1,4 +1,21 @@
-<!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-draw.engine.Vml'>/**
+<!DOCTYPE html>
+<html>
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+  <title>The source code</title>
+  <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
+  <script type="text/javascript" src="../prettify/prettify.js"></script>
+  <style type="text/css">
+    .highlight { display: block; background-color: #ddd; }
+  </style>
+  <script type="text/javascript">
+    function highlight() {
+      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
+    }
+  </script>
+</head>
+<body onload="prettyPrint(); highlight();">
+  <pre class="prettyprint lang-js"><span id='Ext-draw-engine-Vml'>/**
 </span> * @class Ext.draw.engine.Vml
  * @extends Ext.draw.Surface
  * Provides specific methods to draw with VML.
@@ -593,64 +610,77 @@ Ext.define('Ext.draw.engine.Vml', {
     },
 
     setSize: function(width, height) {
-        var me = this,
-            viewBox = me.viewBox,
-            scaleX, scaleY, items, i, len;
+        var me = this;
         width = width || me.width;
         height = height || me.height;
         me.width = width;
         me.height = height;
 
-        if (!me.el) {
-            return;
-        }
+        if (me.el) {
+            // Size outer div
+            if (width != undefined) {
+                me.el.setWidth(width);
+            }
+            if (height != undefined) {
+                me.el.setHeight(height);
+            }
 
-        // Size outer div
-        if (width != undefined) {
-            me.el.setWidth(width);
-        }
-        if (height != undefined) {
-            me.el.setHeight(height);
+            // Handle viewBox sizing
+            me.applyViewBox();
+
+            me.callParent(arguments);
         }
+    },
+
+    setViewBox: function(x, y, width, height) {
+        this.callParent(arguments);
+        this.viewBox = {
+            x: x,
+            y: y,
+            width: width,
+            height: height
+        };
+        this.applyViewBox();
+    },
+
+<span id='Ext-draw-engine-Vml-method-applyViewBox'>    /**
+</span>     * @private Using the current viewBox property and the surface's width and height, calculate the
+     * appropriate viewBoxShift that will be applied as a persistent transform to all sprites.
+     */
+    applyViewBox: function() {
+        var me = this,
+            viewBox = me.viewBox,
+            width = me.width,
+            height = me.height,
+            viewBoxX, viewBoxY, viewBoxWidth, viewBoxHeight,
+            relativeHeight, relativeWidth, size;
 
-        // Handle viewBox sizing
         if (viewBox &amp;&amp; (width || height)) {
-            var viewBoxX = viewBox.x,
-                viewBoxY = viewBox.y,
-                viewBoxWidth = viewBox.width,
-                viewBoxHeight = viewBox.height,
-                relativeHeight = height / viewBoxHeight,
-                relativeWidth = width / viewBoxWidth,
-                size;
+            viewBoxX = viewBox.x;
+            viewBoxY = viewBox.y;
+            viewBoxWidth = viewBox.width;
+            viewBoxHeight = viewBox.height;
+            relativeHeight = height / viewBoxHeight;
+            relativeWidth = width / viewBoxWidth;
+
             if (viewBoxWidth * relativeHeight &lt; width) {
                 viewBoxX -= (width - viewBoxWidth * relativeHeight) / 2 / relativeHeight;
             }
             if (viewBoxHeight * relativeWidth &lt; height) {
                 viewBoxY -= (height - viewBoxHeight * relativeWidth) / 2 / relativeWidth;
             }
+
             size = 1 / Math.max(viewBoxWidth / width, viewBoxHeight / height);
-            // Scale and translate group
+
             me.viewBoxShift = {
                 dx: -viewBoxX,
                 dy: -viewBoxY,
                 scale: size
             };
-            items = me.items.items;
-            for (i = 0, len = items.length; i &lt; len; i++) {
-                me.transform(items[i]);
-            }
+            me.items.each(function(item) {
+                me.transform(item);
+            });
         }
-        this.callParent(arguments);
-    },
-
-    setViewBox: function(x, y, width, height) {
-        this.callParent(arguments);
-        this.viewBox = {
-            x: x,
-            y: y,
-            width: width,
-            height: height
-        };
     },
 
     onAdd: function(item) {
@@ -860,7 +890,7 @@ Ext.define('Ext.draw.engine.Vml', {
         }
     },
 
-<span id='Ext-draw.engine.Vml-method-addGradient'>    /**
+<span id='Ext-draw-engine-Vml-method-addGradient'>    /**
 </span>     * Adds a definition to this Surface for a linear gradient. We convert the gradient definition
      * to its corresponding VML attributes and store it for later use by individual sprites.
      * @param {Object} gradient
@@ -897,4 +927,6 @@ Ext.define('Ext.draw.engine.Vml', {
         delete me.el;
     }
 });
-</pre></pre></body></html>
\ No newline at end of file
+</pre>
+</body>
+</html>