[OpenLayers-Commits] r2051 - sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control

commits at openlayers.org commits at openlayers.org
Thu Dec 14 05:43:06 EST 2006


Author: bertil
Date: 2006-12-14 05:43:05 -0500 (Thu, 14 Dec 2006)
New Revision: 2051

Added:
   sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Container.js
Log:
container class


Added: sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Container.js
===================================================================
--- sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Container.js	                        (rev 0)
+++ sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Container.js	2006-12-14 10:43:05 UTC (rev 2051)
@@ -0,0 +1,78 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt 
+ * for the full text of the license. */
+
+/**
+ * @class
+ *
+ * @requires OpenLayers/Control.js
+ */
+OpenLayers.Control.Container = OpenLayers.Class.create();
+OpenLayers.Control.Container.prototype = OpenLayers.Class.inherit( OpenLayers.Control, {
+
+	contentDiv: null,
+
+	controls: null,
+	
+    /**
+     * @constructor
+     * 
+     * @param {Object} options
+     */
+    initialize: function() {
+        OpenLayers.Control.prototype.initialize.apply(this, arguments);
+        this.controlName = "olContainer";
+        this.controls = [];
+    },
+    
+    /**
+     * @param {OpenLayers.Pixel} px
+     *
+     * @returns A reference to the DIV DOMElement containing the control
+     * @type DOMElement
+     */
+    draw: function (px) {
+        OpenLayers.Control.prototype.draw.apply(this, arguments);
+        
+        var containerHeader = document.createElement("div");
+        containerHeader.className = this.controlName+"Header";
+        this.div.appendChild(containerHeader);
+        
+        this.contentDiv = document.createElement("div");
+        this.contentDiv.className = this.controlName+"Content";
+        this.div.appendChild(this.contentDiv);
+        
+    	for (var i = 0; i < this.controls.length; i++) {
+    		this.contentDiv.appendChild(this.controls[i].draw());
+    	}
+        
+        var containerFooter = document.createElement("div");
+        containerFooter.className = this.controlName+"Footer";
+        this.div.appendChild(containerFooter);
+        
+        return this.div;
+    }, 
+    
+    /**
+     * @param {OpenLayers.Control} control
+     */    
+    addControl: function(control) {
+		this.controls.push(control);
+    },
+
+    /** Set the map property for the control. This is done through an accessor
+     *   so that subclasses can override this and take special action once 
+     *   they have their map variable set. 
+     * 
+     * @param {OpenLayers.Map} map
+     */    
+    setMap: function(map) {
+    	this.map = map;
+    	for (var i = 0; i < this.controls.length; i++) {
+    		this.controls[i].setMap(this.map);
+    	}
+    },
+    
+    CLASS_NAME: "OpenLayers.Control.Container"
+
+});
\ No newline at end of file



More information about the Commits mailing list