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 mt...@apache.org on 2007/01/08 23:27:10 UTC

svn commit: r494250 - in /incubator/xap/trunk/src/xap: bridges/dojo/WindowBridge.js widgets/dojo/Window.js

Author: mturyn
Date: Mon Jan  8 15:27:09 2007
New Revision: 494250

URL: http://svn.apache.org/viewvc?view=rev&rev=494250
Log:
1.) Fixed residual visibility issue.
2.) Enabled resetting the title
2.a.) Added methods to keep a new, longer, title 
from being truncated at previous length, or overflowing into the action icons.
3.) Changed initial width setting so that it will naturally go to the title text width (+icons').

Modified:
    incubator/xap/trunk/src/xap/bridges/dojo/WindowBridge.js
    incubator/xap/trunk/src/xap/widgets/dojo/Window.js

Modified: incubator/xap/trunk/src/xap/bridges/dojo/WindowBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/WindowBridge.js?view=diff&rev=494250&r1=494249&r2=494250
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/WindowBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/WindowBridge.js Mon Jan  8 15:27:09 2007
@@ -57,6 +57,7 @@
 		peer.previous = {} ;
 	}	
 
+
 	peer.resizeTo(200,200) ;
 
 
@@ -96,6 +97,13 @@
 	var w = this.getElement().getAttribute("width") ;
 
 	var defaultSize = "100px" ;
+	
+	// Find the "natural" width:
+	if( (!w || w=="" ||w=="null")  && peer && peer.titleBarText  ){
+		peer.titleBarText.innerHTML = peer.title ;	
+		w = peer.titleBarText.clientWidth ;
+	}
+
 
 	if( !w || w== ""){
 		// For lack of anything better---at
@@ -128,7 +136,7 @@
  
 
 xap.bridges.dojo.WindowBridge.prototype.getNewAllowedAttributes = function(){
-	return ["maximized","minimized","resizable","centered"];
+	return ["maximized","minimized","resizable","centered","title"];
 }	
 
 
@@ -375,6 +383,10 @@
 
 xap.bridges.dojo.WindowBridge.prototype.isCentered = function(){
 	return this.getElement().getAttribute("centered") == xap.xml.XmlTokens.TRUE ;
+}
+
+xap.bridges.dojo.WindowBridge.prototype.setTitleAttribute = function(txt){
+	this.getPeer().setTitle( txt ) ;
 }
 
 

Modified: incubator/xap/trunk/src/xap/widgets/dojo/Window.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/widgets/dojo/Window.js?view=diff&rev=494250&r1=494249&r2=494250
==============================================================================
--- incubator/xap/trunk/src/xap/widgets/dojo/Window.js (original)
+++ incubator/xap/trunk/src/xap/widgets/dojo/Window.js Mon Jan  8 15:27:09 2007
@@ -46,12 +46,18 @@
 	postCreate: function(){
 		xap.widgets.dojo.Window.superclass.postCreate.call(this);	
 		this.aquireResizeHandleObject() ;
+		this.minHeightPx = this.titleBar.clientHeight
+								+ this.resizeBar.clientHeight ;
+
 		// Keep icons from leaving trails over the extending title bar:
 		dojo.event.connectBefore(this,"resizeTo",this,"redisplayTitlebarIcons");
 		dojo.event.connect(this,"onResized",this,"showTitleBarIcons");	
 
 		// Paranoically sure let us be that the icons are redisplayed:		
-		dojo.event.connect(this.resizeBar._resizeHandle,"endSizing",this,"showTitleBarIconsd");		
+		dojo.event.connect(this.resizeBar._resizeHandle,"endSizing",this,"showTitleBarIcons");		
+		
+		// Fix the title text DIV's width:
+		this.resetTitleTextBox() ;	
 	},
 	
 	minimizeWindow:function(evt) {
@@ -73,15 +79,16 @@
 		this.minimizeAction.style.display="none";
 		
 		var restoreParent = this.restoreAction.parentNode;
+		var nextNode = this.restoreAction.nextSibling ;
 		restoreParent.removeChild(this.restoreAction);
-		restoreParent.appendChild(this.restoreAction);
+		restoreParent.insertBefore(this.restoreAction,nextNode);
 		
 		// Keep container node from intruding into titleBar
 		// when minimised:
 		this.containerNode.style.visibility = "hidden" ;
 		
 		this.restoreAction.style.display="";
-		this.windowState="minimized";
+		this.windowState="minimized";	
 	},
 	
 	restoreWindow:function(evt){	
@@ -92,9 +99,13 @@
 
 		this.resizeBar.style.visibility="visible" ;
 		
+		this.minHeightPx = Math.max(this.minHeightPx,
+								this.titleBar.clientHeight
+								+ this.resizeBar.clientHeight) ;		
 		xap.widgets.dojo.Window.superclass.restoreWindow.call(this,evt);
 		
 		this.minimizeAction.style.display=this.displayMinimizeAction ? "" : "none";
+	
 	},
 	
 	maximizeWindow:function(evt){
@@ -111,6 +122,7 @@
 		restoreParent.insertBefore(this.restoreAction,this.minimizeAction);
 		
 		xap.widgets.dojo.Window.superclass.maximizeWindow.call(this,evt);		
+		
 	},
 	
 	closeWindow:function(evt){
@@ -121,12 +133,16 @@
 		xap.widgets.dojo.Window.superclass.closeWindow.call(this,evt);
 	},
 	
+
 	// copied from Floating Pane
 	// This is called when the user adjusts the size of the floating pane
 	resizeTo: function(w, h){
 		// call the superclass resizeTo
 		xap.widgets.dojo.Window.superclass.resizeTo.call(this,w,h);
 		
+		// Fix the title text DIV's width:
+		this.resetTitleTextBox() ;		
+		
 		// let the child node know that we're resizing
 		if (this._childPeer && this._childPeer.onResized) {
 			this._childPeer.onResized();
@@ -198,11 +214,24 @@
 		if( !this._visible){
 			return ;
 		}
+		
+
+		var baseZ= this.titleBar.style.zIndex ;
+		if( typeof baseZ =="undefined" 
+				|| baseZ==""|| baseZ<100){
+			this.titleBar.style.zIndex = baseZ=100;
+		}		
+		// Kee the text above the bar:
+		this.titleBarText.style.zIndex = --baseZ ;
 		for(var action in  this.windowActions ){
-		// Note that we aren't touching the "display" attribute;
-		// this will override ...style.display=""
+			// Note that we aren't touching the "display" attribute;
+			// this will override ...style.display=""
 			(this[action]).style.visibility = "hidden" ;
+			// Make sure icons are visible above text:
+			(this[action]).style.zIndex = --baseZ ;			
 		}
+	
+		
 		// The hiding above and this show is basically forcing a redraw:
 		dojo.lang.setTimeout(this,"showTitleBarIcons",1) ;
 	 },
@@ -215,12 +244,20 @@
 	},
 	
 	setVisible: function(bVisible){
+	
 		var sAttr = (bVisible)?"visible":"hidden" ;
 		for(var action in  this.windowActions ){
 			(this[action]).style.visibility = sAttr ;
 		}
 		this.domNode.style.visibility=sAttr ;
-		this.resizeBar.style.visibility=sAttr ;
+		this.containerNode.style.visibility=sAttr ;		
+		if( this.windowState != "maximized" 
+			&& this.windowState != "minimized"
+		){				
+			this.resizeBar.style.visibility=sAttr ;
+		} else {
+			this.resizeBar.style.visibility="hidden" ;
+		}
 		
 		this._visible = bVisible ;
 	},
@@ -236,7 +273,7 @@
 		} else {
 			// get value in pixels by resizing dom node first:
 			this.domNode.style.height = val ;
-			this.resizeTo(this.domNode.clientWidth,this.domNode.clientHeight) ;	
+			this.resizeTo(this.domNode.clientWidth,Math.max(this.domNode.clientHeight,this.minHeightPx)) ;	
 			this.resizeWindow() ;
 		}
 	},
@@ -254,7 +291,33 @@
 			this.resizeTo(this.domNode.clientWidth,this.domNode.clientHeight) ;		
 			this.resizeWindow() ;
 		}
-	}
+	},
+	setTitle:function(val){
+		this.titleBarText.innerHTML = val ;
+		this.resetTitleTextBox() ;
+	},
+	resetTitleTextBox:function(){
+		this.titleBar.style.overflow="hidden" ;
+		this.titleBarText.style.overflow="hidden" ;
+		var titleWidthPx = this.titleBar.offsetWidth ;
+		var maxTextWidthPx = this.titleBar.offsetWidth ;
+		var iconWidth = false ;
+		for(var action in  this.windowActions ){
+			var w = this[action].offsetWidth ;		
+			if(w){
+				maxTextWidthPx -=  w ;
+				if( !iconWidth ){
+					iconWidth = w ;
+				}
+			}
+		}
+		if(iconWidth){
+			// Fudge--if this is too wide, makes title bar multi-line:
+			maxTextWidthPx -= Math.round(iconWidth/2) ;
+		}
+		maxTextWidthPx = Math.max(maxTextWidthPx,0) ;
+		this.titleBarText.style.width= maxTextWidthPx+"px";
+	}	
 });