You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by jm...@apache.org on 2007/02/23 02:18:48 UTC

svn commit: r510765 - in /incubator/xap/trunk/codebase/src/xap: bridges/dojo/BorderPanelBridge.js widgets/dojo/BorderPanel.js

Author: jmargaris
Date: Thu Feb 22 18:18:47 2007
New Revision: 510765

URL: http://svn.apache.org/viewvc?view=rev&rev=510765
Log:
new borderPane does active layout instead of passive

Modified:
    incubator/xap/trunk/codebase/src/xap/bridges/dojo/BorderPanelBridge.js
    incubator/xap/trunk/codebase/src/xap/widgets/dojo/BorderPanel.js

Modified: incubator/xap/trunk/codebase/src/xap/bridges/dojo/BorderPanelBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/dojo/BorderPanelBridge.js?view=diff&rev=510765&r1=510764&r2=510765
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/dojo/BorderPanelBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/dojo/BorderPanelBridge.js Thu Feb 22 18:18:47 2007
@@ -92,5 +92,4 @@
 
 xap.bridges.dojo.BorderPanelBridge.prototype.setBackgroundColorAttribute = function(value) {
 	this.getPeer().domNode.style.backgroundColor = value;
-	this.getPeer().showGaps();
 }

Modified: incubator/xap/trunk/codebase/src/xap/widgets/dojo/BorderPanel.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/widgets/dojo/BorderPanel.js?view=diff&rev=510765&r1=510764&r2=510765
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/widgets/dojo/BorderPanel.js (original)
+++ incubator/xap/trunk/codebase/src/xap/widgets/dojo/BorderPanel.js Thu Feb 22 18:18:47 2007
@@ -27,8 +27,9 @@
 dojo.require("dojo.html");
 dojo.require("dojo.style");
 dojo.require("dojo.event");
+dojo.require("dojo.html.layout");
 
- //IMPORTANT move this to some shared area
+ //IMPORTNT move this to some shared area
 dojo.widget.manager.registerWidgetPackage("xap.widgets.dojo");
 dojo.widget.tags.addParseTreeHandler("dojo:BorderPanel");
 
@@ -39,11 +40,7 @@
 dojo.inherits(xap.widgets.dojo.BorderPanel,dojo.widget.HtmlWidget);
 
 dojo.lang.extend(xap.widgets.dojo.BorderPanel, {
-	templateString: '<table style="overflow:hidden" cellpadding="0" cellspacing="0" border="0"><tr align="center" valign="center">'+
-	'<td colspan="3" dojoAttachPoint="north" style="height:1px"></td></tr>' +
-	'<tr align="center" valign="center" style="height:99%">'+
-	'<td dojoAttachPoint="west" style="width:1px"></td><td dojoAttachPoint="center" style="height:99%;width:99%"></td><td style="width:1px" dojoAttachPoint="east"></td></tr>' +
-	'<tr align="center" valign="center"><td colspan="3" style="height:1px" dojoAttachPoint="south"></tr></td></table>',
+	templateString: '<div></div>',
 	
 	templateCssPath: null ,
 	widgetType: "BorderPanel",
@@ -53,104 +50,60 @@
 	
 	addChild: function(child, position){
 		
-		var adjustWidth = false;
-		var adjustHeight = false;
 		if (position=="north"){
-			this.containerNode = this.north;
-			adjustWidth = true;
+			this.north = child;
 		}
 		else if (position=="south"){
-			this.containerNode = this.south;
-			adjustWidth = true;
+			this.south = child;
 		}
 		else if (position=="east"){
-			this.containerNode = this.east;
-			adjustHeight = true;
+			this.east = child;
 		}
 		else if (position=="west"){
-			this.containerNode = this.west;
-			adjustHeight = true;
+			this.west = child;
 		}
 		else{
-			this.containerNode = this.center;
-			adjustWidth = true;
-			adjustHeight = true;
+			this.center = child;
 		}
-		
-		//if we already have child nodes that's bad!
-		if (this.containerNode.childNodes.length!=0){
-			return;
-		}
-		
-		
-		//IMPORTANT should we do this in a setTimeout() after 
-		//we give the table a chance to layout first? probably
-		if (adjustWidth){
-			child.domNode.style.width="100%";
-		}
-		if (adjustHeight){
-			child.domNode.style.height="100%";
-		}
-		
 		xap.widgets.dojo.BorderPanel.superclass.addChild.call(this,child);
+		if (!this._resizePending){
+			if(this.isShowing()){
+				dojo.lang.setTimeout(this, this.onResized, 0);
+				this._resizePending = true;
+			}
+		}
 	},
 	
 	removeChild: function(child) {
 	 	var containerNode = child.domNode.parentNode;		 	
 		xap.widgets.dojo.BorderPanel.superclass.removeChild.call(this,child);
-		this.resetNode(containerNode);
+		if (!this._resizePending){
+			if(this.isShowing()){
+				dojo.lang.setTimeout(this, this.onResized, 0);
+				this._resizePending = true;
+			}
+		}
     },
     
-    resetNode : function(containerNode){
-    	var nodeStyle = containerNode.style;
-    	if (containerNode==this.north || containerNode==this.south){
-			nodeStyle.width="";
-			nodeStyle.height="1px";
-		}
-		else if (containerNode==this.east || containerNode==this.west){
-			nodeStyle.width="1px";
-			nodeStyle.height="";
+    onResized: function(){
+    	this._resizePending = false;
+		var children = [];
+		if (this.north){
+			children.push({domNode: this.north.domNode, layoutAlign: "top"});
+		}
+		if (this.south){
+			children.push({domNode: this.south.domNode, layoutAlign: "bottom"});
+		}
+		if (this.west){
+			children.push({domNode: this.west.domNode, layoutAlign: "left"});
 		}
-		else{
-			nodeStyle.width= "99%";
-			nodeStyle.height = "99%";
+		if (this.east){
+			children.push({domNode: this.east.domNode, layoutAlign: "right"});
 		}
-    },
-    
-    setGapHorizontal: function(value) { 
-		this.gapHorizontal = value;
-		this.showGaps();
-		
-    },
-    
-    setGapVertical: function(value) {
-		this.gapVertical = value;
-		this.showGaps();
-    },
-    
-    showGaps: function() {
-		this.center.style.borderStyle = "solid"; 
-    	this.center.style.borderColor = this.domNode.style.backgroundColor;    
-    	
-		this.center.style.borderLeftWidth = this.gapVertical;
-		this.center.style.borderRightWidth = this.gapVertical;
-		
- 		this.center.style.borderTopWidth = this.gapHorizontal;
-		this.center.style.borderBottomWidth = this.gapHorizontal;   
-		
-		this.west.style.borderStyle = "solid";
-		this.west.style.borderColor = this.domNode.style.backgroundColor;     
-		this.west.style.borderTopWidth = this.gapHorizontal;
-		this.west.style.borderBottomWidth = this.gapHorizontal;
-		this.west.style.borderLeftWidth = "0px";
-		this.west.style.borderRightWidth = "0px";
-
-		this.east.style.borderStyle = "solid";
-		this.east.style.borderColor = this.domNode.style.backgroundColor;
-		this.east.style.borderTopWidth = this.gapHorizontal;
-		this.east.style.borderBottomWidth = this.gapHorizontal;
-		this.east.style.borderLeftWidth = "0px";
-		this.east.style.borderRightWidth = "0px"; 
-    }    
+		if (this.center){
+			children.push({domNode: this.center.domNode, layoutAlign: "client"});
+		}
+		dojo.html.layout(this.domNode,children);
+	}
 }
 );