123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- /****************************************************************
- ** 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);
- }
|