incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtu...@apache.org
Subject svn commit: r547291 - in /incubator/xap/trunk/codebase: css/xapDefault.css src/xap/bridges/dojo/ColumnBridge.js src/xap/widgets/dojo/TreeTable.js
Date Thu, 14 Jun 2007 16:18:33 GMT
Author: mturyn
Date: Thu Jun 14 09:18:33 2007
New Revision: 547291

URL: http://svn.apache.org/viewvc?view=rev&rev=547291
Log:
(From M. Mikhaylov:)
Return of column sizing, still buggy under FF when cell content's width excceeds the column's.

Modified:
    incubator/xap/trunk/codebase/css/xapDefault.css
    incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js
    incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js

Modified: incubator/xap/trunk/codebase/css/xapDefault.css
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/css/xapDefault.css?view=diff&rev=547291&r1=547290&r2=547291
==============================================================================
--- incubator/xap/trunk/codebase/css/xapDefault.css (original)
+++ incubator/xap/trunk/codebase/css/xapDefault.css Thu Jun 14 09:18:33 2007
@@ -215,6 +215,10 @@
 	background-repeat: repeat-x;
 }
 
+.xapHeaderContents{
+	overflow: hidden;
+}
+
 .xapHeaderMouseOver{
 	background-image: url(./xap_header_hover.gif);
 }

Modified: incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js?view=diff&rev=547291&r1=547290&r2=547291
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js Thu Jun 14 09:18:33
2007
@@ -61,7 +61,7 @@
 	this.getPeer()._dataType = value;
 }	
 
-
+//TODO: Find out why this doesn't seem to get called.
 xap.bridges.dojo.ColumnBridge.prototype.setHorizontalAlignmentAttribute = function( value
){
 	this.getPeer()._horizontalAlignment = value;
 }	
@@ -77,7 +77,12 @@
 /**
  *	This seems the best place at which to cache the 
  *  XAL-derived width, if any:
-**/ 
+**/
+//Old way of doing it, superseded by the set[Width|HorizontalAlignment]Attribute
+// methods below; keep it around commented-out until we're sure that the newer
+// way will work, e.g. that we're not missing a peer.header when we first parse 
+// this tag.
+// 
 xap.bridges.dojo.ColumnBridge.prototype.init = function(){
 	xap.bridges.dojo.ColumnBridge.superclass.init.call(this) ;
 	var peer =  this.getPeer() ;
@@ -90,4 +95,37 @@
 	}
 }
 
+/**
+ *	Set explicit column width and resize a table
+ */
+xap.bridges.dojo.ColumnBridge.prototype.setWidthAttribute = function( value ){
+	var peer = this.getPeer();
+	if(peer) {
+			peer.setStatedWidth(value);
+	}
+	// Need this here if we resize a column after the
+	// table is built---use resizeTable<b>Later</b>
+	// because 1.) IE probably needs the delay, and
+	// 2.) the peer code keeps this from being run multiple 
+	// times in succession---if there's already a resizeTableTask
+	// job in play, this won't add another one:
+	if(peer._table) {
+		peer._table._resizeTableLater();
+	}
+}
+
+/**
+ *	Set column halignment---note that this is not sufficient to
+ *  reset the alignment all over the table, that will come later.
+ */
+xap.bridges.dojo.ColumnBridge.prototype.setHorizontalAlignmentAttribute = function( value
){
+	var peer = this.getPeer();
+	if(peer.header && peer._horizontalAlignment){
+		peer.header.setHorizontalAlignment(value) ;
+		// Code in table widget will look at this
+		// member to determing the alignment of
+		// newly-added cells:
+		peer._horizontalAlignment=value ;		
+	}
+}
 

Modified: incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js?view=diff&rev=547291&r1=547290&r2=547291
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js (original)
+++ incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js Thu Jun 14 09:18:33 2007
@@ -138,6 +138,7 @@
 	 * the widths of columns and headers match up.
 	 */
 	_resizeTable: function(){
+	
 		var tableWidth = 0;
 		
 		//don't user tbody.childNodes[0] here because in the case
@@ -199,62 +200,77 @@
 				}
 			}
 			
-			/* if the user explicitly set, we use those */
-			if ( this._columns[i]._headerWidth ) {
-				var val = this._getSizeFromString (this._columns[i]._headerWidth);
-				if ( val ) setWidth = val;
+			/* if the user explicitly set the column width or
+			   its header's width , we use those (preferring
+			   as usual the last value parsed, that is, 
+			   the header's):
+			*/
+
+			var setWidth = this._columns[i].getBestWidth() ;
+		
+			// We want to set the column width to the explicitly-given value
+			// if it should be available from the column or its header); if
+			// a value is not available so, we'll use the greater of the 
+			// extant cell or column widths.  Note that we need to look
+			// up the explicitly-set ones in case the table is hidden when created
+			var preferredColumnWidth = setWidth ;
+			if( !setWidth ){
+				preferredColumnWidth = headerWidth>columnWidth ? headerWidth:columnWidth;	
+				preferredColumnWidth += "px" ;
 			}
-			
-			// For now, we'll settle for the greater of explicitly set, calculated column or calculated
cell; note that we need to look up
-			// the explicitly set ones in case the table is hidden when created
-			var finalWidth = headerWidth>columnWidth ? headerWidth:columnWidth;
-			finalWidth = setWidth>finalWidth?setWidth:finalWidth;			
-			this._columns[i]._calculatedWidth = finalWidth + "px";
-			tableWidth += finalWidth;
+			var preferredColumnWidthPx = parseInt(preferredColumnWidth) ;
+			this._columns[i].setStatedWidth(preferredColumnWidth) ;
+			if(this.columnsSizer 
+				&& this.columnsSizer.children
+					&& this.columnsSizer.children[i]
+				){
+				this.columnsSizer.children[i].sizeShare = preferredColumnWidthPx ;
+			}	
+			tableWidth += preferredColumnWidthPx ;
 		}
 		
 		//if we don't fix the width here then when we want the table
 		//to scroll horizontally it doesn't work very well, sizes
 		//too small
+
+		this.headerTable.style.tableLayout = "auto";
+		this.table.style.tableLayout = "auto";	
+
+
 		this.table.style.width = tableWidth + "px";
 		this.headerTable.style.width = tableWidth + "px";
 		
-		this.headerTable.style.tableLayout = "fixed";
-		this.table.style.tableLayout = "fixed";
-
+		
 		this._fixColumnWidths();
+		this.headerTable.style.tableLayout = "fixed";
+		this.table.style.tableLayout = "fixed";		
 				
 		window.clearTimeout(this._resizeTableTask);
 		this._resizeTableTask = null;
 	},
 	
-	_fixColumnWidths : function(){
+	_fixColumnWidths: function(){
 		var firstRow = this._rows.length>0?this._rows[0].domNode:null;
+var arr = new Array(0) ;		
 		for (var i=0; i<this._columns.length;i++){
-			var width = this._columns[i]._calculatedWidth;  // Note: ends with "px"
-			
-			if (dojo.render.html.ie){
-				if( this.headerRow && this.headerRow.childNodes[i]){
-					dojo.html.setMarginBox( this.headerRow.childNodes[i],
-											{width: parseInt(width)} 
-											) ;
-				}
-				if (firstRow && firstRow.childNodes[i]){
-					dojo.html.setMarginBox( firstRow.childNodes[i],
-						{width: parseInt(width)} ) ;					
-				}
+			// Note: ends with "px":
+			var width = this._columns[i].getBestWidth();
+			// These next two originally were just called under IE,
+			// and the columns set under Firefox.  The columns came
+			// out better under IE than under Firefox, so we switched 
+			// to the IE way:					
+			if( this.headerRow && this.headerRow.childNodes[i]){
+				dojo.html.setMarginBox( this.headerRow.childNodes[i],
+										{width: parseInt(width)} 
+										) ;
 			}
-			else{
-				if( this.headerTable && this.headerTable.childNodes[i] ){
-					this.headerTable.childNodes[i].style.width = width;
-				}
-				if( this.table && this.table.childNodes[i] ){
-					this.table.childNodes[i].style.width = width;
-				}				
+			if (firstRow && firstRow.childNodes[i]){
+				dojo.html.setMarginBox( firstRow.childNodes[i],
+					{width: parseInt(width)} ) ;					
 			}
 			if (this.headerRow.childNodes[i] && this.headerRow.childNodes[i].childNodes[0])
-				this.headerRow.childNodes[i].childNodes[0].style.width  = "100%";
-		}
+				this.headerRow.childNodes[i].childNodes[0].style.width  = '100%';
+		}	
 	},
 	
 	/**
@@ -771,7 +787,36 @@
 		if (this._table){
 			this._table.sortColumn(this);
 		}
+	},
+	
+	getStatedWidth: function(){
+		return this._sStatedWidth ;
+	},
+
+	setStatedWidth: function(val){
+		var res = val ;
+		// We want a string value that
+		// can be used to directly set
+		// a style object member:
+		if(!isNaN(val)){
+			res += "px" ;
+		}
+		this._sStatedWidth = res ;
+	},
+	
+	getBestWidth: function(){
+		var res = this.getStatedWidth() ;
+		if( !res ){
+			// Use column width; if not set,
+			// use header width:
+			if( res = this._explicitColumnWidth ){
+			} else if( res = this._headerWidth ){
+			}
+		}
+		return res ;
 	}
+		
+	
 });
 		
 



Mime
View raw message