incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtu...@apache.org
Subject svn commit: r499297 - /incubator/xap/trunk/codebase/src/xap/widgets/dojo/Window.js
Date Wed, 24 Jan 2007 07:50:23 GMT
Author: mturyn
Date: Tue Jan 23 23:50:22 2007
New Revision: 499297

URL: http://svn.apache.org/viewvc?view=rev&rev=499297
Log:
http://issues.apache.org/jira/browse/XAP-58
Gave window minimum height/width, styled the resize bar a bit better to set it off from the
container.

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

Modified: incubator/xap/trunk/codebase/src/xap/widgets/dojo/Window.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/widgets/dojo/Window.js?view=diff&rev=499297&r1=499296&r2=499297
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/widgets/dojo/Window.js (original)
+++ incubator/xap/trunk/codebase/src/xap/widgets/dojo/Window.js Tue Jan 23 23:50:22 2007
@@ -46,18 +46,24 @@
 	postCreate: function(){
 		xap.widgets.dojo.Window.superclass.postCreate.call(this);	
 		this.aquireResizeHandleObject() ;
-		this.minHeightPx = this.titleBar.clientHeight
-								+ this.resizeBar.clientHeight ;
+		this.resizeBar.style.padding="2px" ;
+		this.resizeBar.style.borderTop="2px ridge silver" ;
+		this.resizeBar.style.borderBottom="2px ridge silver" ;	
+		this.resizeBar.style.borderLeft="1px ridge silver" ;	
+		this.resizeBar.style.borderRight="1px ridge silver" ;						
+
+		
 
 		// 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,"showTitleBarIcons");
	
+		dojo.event.connect(this.resizeBar._resizeHandle,"endSizing",this,"endResizing");		
 		
 		// Fix the title text DIV's width:
-		this.resetTitleTextBox() ;	
+		this.resetTitleTextBox() ;
+			
 	},
 	
 	minimizeWindow:function(evt) {
@@ -70,19 +76,13 @@
 		if( this.windowState != "maximized" ){
 			this.setPrevious() ;
 		}
-
-
-
-
 		
 		this.resizeBar.style.visibility="hidden" ;
 
 
+		// Show just the top bar, narrowed to (say) 8 icons' worth:
 
-
-		// Show just the top bar, narrowed to 8 icons' worth:
-
-		var newW = this.minimizedWindowWidth() ;
+		var newW = this.minimizedWindowWidthPx() ;
 
 		var newH = dojo.style.getOuterHeight(this.titleBar); // + dojo.style.getOuterHeight(this.resizeBar);
 	
@@ -112,7 +112,7 @@
 			// nowhere to minimise to:
 			return ;
 		}
-		var newW = this.minimizedWindowWidth() ;
+		var newW = this.minimizedWindowWidthPx() ;
 		// Arrange window next to previous minimised window:
 		if(!parent.minWins){
 			parent.minWins = {} ;
@@ -178,29 +178,48 @@
 		if (evt && xap.util.Event.getPreventDefault(evt)){
 			return;
 		}
-
 		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);
+		var event = evt ;
+		if(!evt){
+			event = {} ;
+		}
+
+		xap.widgets.dojo.Window.superclass.restoreWindow.call(this,event);
 		
 		this.minimizeAction.style.display=this.displayMinimizeAction ? "" : "none";
 	
 	},
-	minimizedWindowWidth:function(){
-		var wI=0 ;
-		for(var action in  this.windowActions ){
-			wI = this[action].offsetWidth ;
-			if(wI>0){
-				break ;
-			}		
+	
+	getIconWidth:function(){
+		if( !this._iconWidth ){
+			for(var action in  this.windowActions ){
+				this._iconWidth = this[action].offsetWidth ;
+				if(this._iconWidth>0){
+					break ;
+				}		
+			}	
+			// Got value from the dojo style sheet;
+			// should probably just figure out how
+			// to do that algorithmically:
+			this._iconWidth=Math.max(20,this._iconWidth);
 		}	
-		wI=Math.max(4,wI);
-		return wI*8 ;			
+		return this._iconWidth ;
+	},
+	
+	
+	minimizedWindowWidthPx:function(){
+
+		return this.getIconWidth()*8 ;			
 	},
 	
+	// resizeBar height seems to be underestimated:
+	minimizedWindowHeightPx: function(){
+		return this.getIconWidth()*4 ;
+	},	
+	
+	
+	
 	maximizeWindow:function(evt){
 		this.containerNode.style.visibility = "visible" ;
 		if (evt && xap.util.Event.getPreventDefault(evt)){
@@ -230,6 +249,13 @@
 	// copied from Floating Pane
 	// This is called when the user adjusts the size of the floating pane
 	resizeTo: function(w, h){
+		// About 5 icons' width
+		w = Math.max(5*this.getIconWidth(),Math.max(this.minimizedWindowWidthPx(),w)) ;
+		h = Math.max(2*this.getIconWidth(),Math.max(this.minimizedWindowHeightPx(),h)) ;
+		
+//		w = Math.max(100,w) ;
+//		h = Math.max(30,h) ;		
+	
 		// call the superclass resizeTo
 		xap.widgets.dojo.Window.superclass.resizeTo.call(this,w,h);
 		
@@ -264,6 +290,9 @@
 			bottom: this.domNode.style.bottom,
 			right: this.domNode.style.right
 		};	
+		
+			
+		
 	},
 	
 	enableResizeHandle: function(){
@@ -336,6 +365,11 @@
 		}
 	},
 	
+	endResizing: function(){
+		//this.resizeTo(this.domNode.clientWidth,this.domNode.clientHeight) ;
+		this.showTitleBarIcons() ;
+	},
+	
 	setVisible: function(bVisible){
 	
 		var sAttr = (bVisible)?"visible":"hidden" ;
@@ -362,11 +396,11 @@
 			// Do nothing now, but prepare for next
 			// time this window is in a "normal"
 			// state:
-			this.previous.height = val ;			
+			this.previous.height = Math.max(val,this.minimizedWindowHeightPx()+"px") ;			
 		} else {
 			// get value in pixels by resizing dom node first:
 			this.domNode.style.height = val ;
-			this.resizeTo(this.domNode.clientWidth,Math.max(this.domNode.clientHeight,this.minHeightPx))
;	
+			this.resizeTo(this.domNode.clientWidth,Math.max(this.domNode.clientHeight,this.minimizedWindowHeightPx()))
;	
 			this.resizeWindow() ;
 		}
 	},
@@ -378,7 +412,7 @@
 			// Do nothing now, but prepare for next
 			// time this window is in a "normal"
 			// state:
-			this.previous.width = val ;			
+			this.previous.width = Math.max(val,this.minimizedWindowWidthPx()+"px")  ;			
 		} else {	
 			this.domNode.style.width = val ;
 			this.resizeTo(this.domNode.clientWidth,this.domNode.clientHeight) ;		
@@ -402,9 +436,11 @@
 //For debugging:		this.titleBarText.style.backgroundColor = "black" ;
 		var titleWidthPx = this.titleBar.offsetWidth ;
 		var maxTextWidthPx = this.titleBar.offsetWidth ;
+		var iconWidth = this.getIconWidth()
+				
 		// look at the css file
 		//...but to be sure:
-		var iconWidth = 11 ;
+		//var iconWidth = 11 ;
 		for(var action in  this.windowActions ){
 			var w = this[action].offsetWidth ;		
 			if(w){
@@ -414,6 +450,8 @@
 				}
 			}
 		}
+		
+		
 		if(iconWidth){
 			// Fudge--if this is too wide, makes title bar multi-line:
 			maxTextWidthPx -= Math.round(iconWidth/2) ;



Mime
View raw message