/**************************************************************** ** Licensed Materials - Property of IBM ** ** IBM Cognos Products: mdsrv ** ** (C) Copyright IBM Corp. 2008, 2010 ** ** US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *****************************************************************/ //*********************************************************************************************** // Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved. // Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated). // // Component: Geometry support //*********************************************************************************************** function CNamespace() { var parent = this; this.sCurrentDir = '.'; } CNamespace.prototype.setCurrentDir = function ( sNewDirectory ) { if ( sNewDirectory ) this.sCurrentDir = sNewDirectory; } //------------------------------------------------------------------------------ // CUiObject class //------------------------------------------------------------------------------ function CUiObject( x, y, width, height ) { this.x = x || 0; this.y = y || 0; this.width = width || 0; this.height = height || 0; } //------------------------------------------------------------------------------ // CPoint class //------------------------------------------------------------------------------ function CPoint( x, y ) { CUiObject.call( this, x, y ); // constructor chaining } CPoint.inherits( CUiObject ); // CPoint API CPoint.prototype.Set = function ( x, y ) { this.x = x; this.y = y; } // We create this prototype object for inheritance purposes, but we // don't actually want to inherit the width and height properties, // so delete them from the prototype. delete CPoint.prototype.width; delete CPoint.prototype.height; //------------------------------------------------------------------------------ // CPosition class //------------------------------------------------------------------------------ function CPosition( x, y ) { CPoint.call( this, x, y ); // constructor chaining } CPosition.inherits( CPoint ); //------------------------------------------------------------------------------ // Rectangle class //------------------------------------------------------------------------------ function CRect( x, y, width, height ) { CUiObject.call( this, x, y, width, height ); // constructor chaining } CRect.inherits( CUiObject ); // CRect API CRect.prototype.isCoordInside = function ( x, y ) { return ( x > this.x && x < this.x + this.width && y > this.y && y < this.y + this.height ); } CRect.prototype.isPointInside = function ( pt ) { return this.isCoordInside( pt.x, pt.y ); } CRect.prototype.clone = function ( rect ) { this.x = rect.x; this.y = rect.y; this.width = rect.width; this.height = rect.height; } CRect.prototype.SetSize = function ( width, height ) { if ( width ) this.width = width; if ( height ) this.height = height; } CRect.prototype.SetPosition = function ( x, y, width, height ) { if ( x ) this.x = x; if ( y ) this.y = y; if ( width ) this.width = width; if ( height ) this.height = height; } //------------------------------------------------------------------------------ // CSize class //------------------------------------------------------------------------------ function CSize( x, y, width, height ) { CRect.call( this, x, y, width, height ); // constructor chaining } CSize.inherits( CRect ); // CSize API CSize.prototype.getCenterX = function () { return this.x + ( this.width / 2 ); } CSize.prototype.getCenterY = function () { return this.y + ( this.height / 2 ); } CSize.prototype.getCenterPoint = function () { return ( new CPoint( this.x + this.width / 2, this.y + this.height / 2 ) ); } CSize.prototype.GetSize = function () { return this; } CSize.prototype.HasIntersection = function ( size ) { var bIsIntersection = false; if ( this.isCoordInside ( size.x, size.y ) || this.isCoordInside ( size.x + size.width, size.y ) || this.isCoordInside ( size.x, size.y + size.height ) || this.isCoordInside ( size.x + size.width, size.y + size.height ) ) { bIsIntersection = true; } return bIsIntersection; } //------------------------------------------------------------------------------ // DragDrop class //------------------------------------------------------------------------------ function CDragDrop() { var dragObject = null; var originalPosition = new CPosition(0,0); var originalMousePosition = new CPosition(0,0); }