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 2006/10/18 01:30:57 UTC
svn commit: r465120 - in /incubator/xap/trunk:
WebContent/examples/widgets/window.xal src/xap/bridges/dojo/WindowBridge.js
src/xap/util/Event.js
Author: jmargaris
Date: Tue Oct 17 18:30:56 2006
New Revision: 465120
URL: http://svn.apache.org/viewvc?view=rev&rev=465120
Log:
window refactoring, now has it's own class
Added:
incubator/xap/trunk/src/xap/util/Event.js (with props)
Modified:
incubator/xap/trunk/WebContent/examples/widgets/window.xal
incubator/xap/trunk/src/xap/bridges/dojo/WindowBridge.js
Modified: incubator/xap/trunk/WebContent/examples/widgets/window.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/widgets/window.xal?view=diff&rev=465120&r1=465119&r2=465120
==============================================================================
--- incubator/xap/trunk/WebContent/examples/widgets/window.xal (original)
+++ incubator/xap/trunk/WebContent/examples/widgets/window.xal Tue Oct 17 18:30:56 2006
@@ -12,7 +12,19 @@
<xm:modifications xmlns:xm="http://www.openxal.org/xmodify">
<xm:append select="/xal">
- <xal:window title="A window" id="testComponent">
+
+ <xal:window title="No min,max,close or resize" x="200px" resizable="false" minimizable="false" maximizable="false" closable="false"/>
+ <xal:window title="A window" id="testComponent"
+ onClose="mco:attributeSetter.reportEvent(event)"
+ onMinimize="mco:attributeSetter.reportEvent(event)"
+ onMaximize="mco:attributeSetter.reportEvent(event)"
+ onMinimizing="mco:attributeSetter.reportEvent(event)"
+ onMaximizing="mco:attributeSetter.reportEvent(event)"
+ onClosing="mco:attributeSetter.reportEvent(event)"
+ onRestore="mco:attributeSetter.reportEvent(event)"
+ onRestoring="mco:attributeSetter.reportEvent(event)"
+
+ >
<xal:borderPanel backgroundColor="green">
<xal:menuBar borderPosition="north">
<xal:menuBarItem text="Edit">
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=465120&r1=465119&r2=465120
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/WindowBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/WindowBridge.js Tue Oct 17 18:30:56 2006
@@ -23,8 +23,9 @@
Xap.provide("xap.bridges.dojo.WindowBridge");
-Xap.require("dojo.widget.FloatingPane");
+Xap.require("xap.widgets.dojo.Window");
Xap.require("xap.session.ClientEvent");
+Xap.require("xap.util.Event");
/**
* @fileoverview
@@ -47,10 +48,19 @@
xap.bridges.dojo.WindowBridge.prototype.init = function() {
this.superclass.init.call(this);
this.getPeer().resizeTo(200,200);
+ dojo.event.connect(this.getPeer(),"maximizeWindow",this,"onMaximize");
+ dojo.event.connect(this.getPeer(),"minimizeWindow",this,"onMinimize");
+ dojo.event.connect(this.getPeer(),"closeWindow",this,"onClose");
+ dojo.event.connect(this.getPeer(),"restoreWindow",this,"onRestore");
+
+ dojo.event.connectBefore(this.getPeer(),"maximizeWindow",this,"onMaximizing");
+ dojo.event.connectBefore(this.getPeer(),"minimizeWindow",this,"onMinimizing");
+ dojo.event.connectBefore(this.getPeer(),"closeWindow",this,"onClosing");
+ dojo.event.connectBefore(this.getPeer(),"restoreWindow",this,"onRestoring");
}
xap.bridges.dojo.WindowBridge.prototype.getPeerString = function(){
- return "FloatingPane" ;
+ return "Window" ;
}
@@ -111,73 +121,64 @@
}
-//IMPORTANT DOJO change to minimize behavior which just hides
-//IMPORTANT when you minimize the restore icon doesn't appear in the
-//correct place because instead of swapping images it just shows/hides
-//the icon but the relative position is off.
-dojo.widget.html.FloatingPane.prototype.minimizeWindow = function(evt) {
- this.previous={
- width: dojo.style.getOuterWidth(this.domNode) || this.width,
- height: dojo.style.getOuterHeight(this.domNode) || this.height,
- left: this.domNode.style.left,
- top: this.domNode.style.top,
- bottom: this.domNode.style.bottom,
- right: this.domNode.style.right
- };
-
- this.resizeTo(this.previous.width,
- dojo.style.getOuterHeight(this.titleBar) + dojo.style.getOuterHeight(this.resizeBar));
- this.minimizeAction.style.display="none";
- this.restoreAction.style.display="";
- this.windowState="minimized";
-}
-
-dojo.widget.html.FloatingPane.prototype.restoreWindow = function(evt) {
- for(var attr in this.previous){
- this.domNode.style[attr] = this.previous[attr];
+
+/**
+ *
+ * EVENTS
+ *
+ *
+ */
+
+xap.bridges.dojo.WindowBridge.prototype.onMaximize = function( evt ){
+ if (!xap.util.Event.getPreventDefault(evt)){
+ this.fireEvent("onMaximize");
}
- this.resizeTo(this.previous.width, this.previous.height);
- this.previous=null;
+}
- this.restoreAction.style.display="none";
- this.maximizeAction.style.display=this.displayMaximizeAction ? "" : "none";
-
- //added this single new line
- this.minimizeAction.style.display=this.displayMinimizeAction ? "" : "none";
- this.windowState="normal";
+xap.bridges.dojo.WindowBridge.prototype.onMinimize = function( evt ){
+ if (!xap.util.Event.getPreventDefault(evt)){
+ this.fireEvent("onMinimize");
+ }
+}
+
+xap.bridges.dojo.WindowBridge.prototype.onClose = function( evt ){
+ if (!xap.util.Event.getPreventDefault(evt)){
+ this.fireEvent("onClose");
+ }
+}
+
+xap.bridges.dojo.WindowBridge.prototype.onRestore = function( evt ){
+ if (!xap.util.Event.getPreventDefault(evt)){
+ this.fireEvent("onRestore");
+ }
}
+xap.bridges.dojo.WindowBridge.prototype.onMinimizing = function( evt ){
+ var b = this.fireEvent("onMinimizing");
+ if (b==false){
+ evt.preventDefault();
+ }
+}
-dojo.require("dojo.html.shadow");
-dojo.require("dojo.lang");
-dojo.require("dojo.uri");
-
-//IMPORTANT dojo workaround for dropshadow drawing on 3 sides of object
-dojo.html.shadow.prototype.init = function(node){
- this.node=node;
-
- // make all the pieces of the shadow, and position/size them as much
- // as possible (but a lot of the coordinates are set in sizeShadow
- this.pieces={};
- var x1 = -1 * this.shadowThickness;
- var y0 = this.shadowOffset;
- var y1 = this.shadowOffset + this.shadowThickness;
- this._makePiece("tr", "top", y0, "left", 0);
- this._makePiece("r", "top", y1, "left", 0, "scale");
- this._makePiece("b", "top", 0, "left", -x1, "crop");
- this._makePiece("br", "top", 0, "left", 0);
+xap.bridges.dojo.WindowBridge.prototype.onMaximizing = function( evt ){
+ var b = this.fireEvent("onMaximizing");
+ if (b==false){
+ evt.preventDefault();
+ }
}
+xap.bridges.dojo.WindowBridge.prototype.onClosing = function( evt ){
+ var b = this.fireEvent("onClosing");
+ if (b==false){
+ evt.preventDefault();
+ }
+}
-dojo.html.shadow.prototype.size = function(width, height){
- var sideHeight = height - (this.shadowOffset+this.shadowThickness+1);
- with(this.pieces){
- r.style.height = sideHeight+"px";
- b.style.width = (width-1-this.shadowThickness)+"px";
- b.style.top = (height-1)+"px";
- br.style.top = (height-1)+"px";
- tr.style.left = (width-1)+"px";
- r.style.left = (width-1)+"px";
- br.style.left = (width-1)+"px";
+xap.bridges.dojo.WindowBridge.prototype.onRestoring = function( evt ){
+ var b = this.fireEvent("onRestoring");
+ if (b==false){
+ evt.preventDefault();
}
}
+
+
Added: incubator/xap/trunk/src/xap/util/Event.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/util/Event.js?view=auto&rev=465120
==============================================================================
--- incubator/xap/trunk/src/xap/util/Event.js (added)
+++ incubator/xap/trunk/src/xap/util/Event.js Tue Oct 17 18:30:56 2006
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+Xap.provide("xap.util.Event");
+
+/**
+ * Helper class to see if the event getPreventDefault
+ * was called, this has to work differntly
+ * based on browser.
+ */
+xap.util.Event.getPreventDefault = function(evt){
+ var consumed = false;
+ if (window.event){
+ if (window.event.returnValue==false){
+ consumed = true;
+ }
+ }
+ else if (evt.getPreventDefault){
+ consumed = evt.getPreventDefault();
+ }
+ return consumed;
+}
\ No newline at end of file
Propchange: incubator/xap/trunk/src/xap/util/Event.js
------------------------------------------------------------------------------
svn:eol-style = native