//**************************************************************** // icMake.js (_ic304.txt) // // Copyright (c) 2006 Clifford L. Collins // All rights are Reserved // // Collins Software // 7710 Janak Drive, Houston Texas // //---------------------------------------------------------------- // No distribution/publication/use of this code is permitted //**************************************************************** var activeMake; var ESC = 27; var F2 = 113; var DEL = 46; var KEY_LEFT = 37; var KEY_RIGHT = 39; var KEY_UP = 38; var KEY_DOWN = 40; var KEY_PAGEUP = 33; var KEY_PAGEDOWN = 34; var KEY_A = 65; var KEY_C = 67; var KEY_X = 88; var KEY_V = 86; var KEY_Z = 90; //======================================================================== // icMake (Constructor) //======================================================================== function ic$Make(id,img,view,height,width) { this.id = id; this.height = height; this.width = width; this.img = img; activeMake = this; this.area = MAKE$area; this.rectangle = MAKE$rectangle; this.arc = MAKE$arc; this.symbol = MAKE$symbol; this.text = MAKE$text; this.textbox = MAKE$textbox; this.shape = MAKE$shape; this.sketch = MAKE$sketch; this.line = MAKE$line; this.pline = MAKE$pline; this.circle = MAKE$circle; this.polygon = MAKE$polygon; this.pline = MAKE$pline; this.measure = MAKE$measure; this.image = MAKE$image; this.setOn = MAKE$setOn; this.isRubberBand = false; this.isRubberDown = false; this.isDown = false; this.isClosed = false; this.ctrlDown = false; this.view = view; this.xPos = MAKE$xPos; this.yPos = MAKE$yPos; this.mouseUp = MAKE$mouseUp; this.mouseDown = MAKE$mouseDown; this.mouseMove = MAKE$mouseMove; this.keyDown = MAKE$keyDown; this.keyUp = MAKE$keyUp; this.command = MAKE$command; this.completed = MAKE$completed; this.cancel = MAKE$cancel; this.snap = MAKE$snap; this.removeEvents = MAKE$removeEvents; this.attachEvents = MAKE$attachEvents; this.erase = MAKE$erase; this.visible = MAKE$visible; this.showRange = MAKE$showRange; this.eraseRange = MAKE$eraseRange; this.makeArc = MAKE$makeArc; this.buildArea = MAKE$buildArea; this.buildAreaDone = MAKE$buildAreaDone; this.buildAdd = MAKE$buildAdd; this.buildMove = MAKE$buildMove; this.buildErase = MAKE$buildErase; this.vmlLine = MAKE$vmlLine; this.vmlPline = MAKE$vmlPline; this.vmlCircle = MAKE$vmlCircle; this.vmlRectangle = MAKE$vmlRectangle; this.vmlArc = MAKE$vmlArc; this.vmlSymbol = MAKE$vmlSymbol; this.vmlText = MAKE$vmlText; this.vmlTextbox = MAKE$vmlTextbox; this.vmlShape = MAKE$vmlShape; this.vmlImage = MAKE$vmlImage; this.onCompleted = ''; this.onMove = ''; this.onCancel = ''; this.layer = document.createElement('
'); this.layer.style.zIndex = ZSelectPlane; this.layer.style.borderWidth = 0; this.layer.style.border = ""; this.layer.style.position = "absolute"; this.layer.style.posTop = 0; this.layer.style.posLeft = 0; this.layer.style.pixelHeight = height; this.layer.style.pixelWidth = width; this.layer.oncontextmenu = null; this.isVisible = true; this.hint = ""; document.body.appendChild(this.layer); //-------------- Build Graphic ---------- this.build = document.createElement(''); this.build.style.position = "absolute" this.build.style.top = 0; this.build.style.left = 0; this.build.style.zIndex = ZSelectPlane; this.nl = 0; this.pntx = new Array(0); this.pnty = new Array(0); this.layer.appendChild(this.build); editInit(); } //======================================================================== // MAKE$buildErase //======================================================================== function MAKE$buildErase() { this.np = 0; this.build.innerHTML = ""; } //======================================================================== // MAKE$buildArea //======================================================================== function MAKE$buildArea(sx,sy) { var x,y; x = this.view.screenToX(sx); y = this.view.screenToY(sy); this.x1 = x; this.y1 = y; this.xmin = x; this.ymin = y; this.xmax = x; this.ymax = y; this.nl = 4; this.pntx[0] = this.xmin; this.pnty[0] = this.ymin; this.pntx[1] = this.xmin; this.pnty[1] = this.ymax; this.pntx[2] = this.xmax; this.pnty[2] = this.ymax; this.pntx[3] = this.xmax; this.pnty[3] = this.ymin; this.pntx[4] = this.xmin; this.pnty[4] = this.ymin; // this.build.innerHTML = this.vmlLine("Blue","",true); } //======================================================================== // MAKE$buildAreaDone //======================================================================== function MAKE$buildAreaDone(sx,sy) { var x,y; x = this.view.screenToX(sx); y = this.view.screenToY(sy); this.xmin = Math.min(x,this.xmin); this.ymin = Math.min(y,this.ymin); this.xmax = Math.max(x,this.xmax); this.ymax = Math.max(y,this.ymax); } //======================================================================== // MAKE$snap //======================================================================== function MAKE$snap(x,y) { var p; var angle,deg,dx,n; var tol; p = new Array(2); p[0] = x; p[1] = y; if (this.ctrlDown && (this.nl > 0)) { angle = angle$(this.pntx[this.nl-1],this.pnty[this.nl-1],x,y); deg = Math.round(degree$(angle)); n = Math.round(deg / 22.5); deg = n * 22.5; angle = radian$(deg); dx = length$(this.pntx[this.nl-1],this.pnty[this.nl-1],x,y); p = rotate$(dx,0,angle); p[0] = p[0] + this.pntx[this.nl-1]; p[1] = p[1] + this.pnty[this.nl-1]; return p; } try { if (! optionSnap.checked) return p; tol = parseInt(optionSnapTolerance.value); if (tol <= 0) return p; G.snap(p,tol); return p; } catch (e) { return p } } //======================================================================== // MAKE$buildAdd //======================================================================== function MAKE$buildAdd(sx,sy) { var x,y; var dx,dy; x = this.view.screenToX(sx); y = this.view.screenToY(sy); if (this.nl > 0) { dx = this.view.xToScreen(this.pntx[this.nl-1]) - sx; dy = this.view.yToScreen(this.pnty[this.nl-1]) - sy; if ((dx == 0) && (dy == 0)) return; } p = this.snap(x,y); if (this.type == 'text') this.nl = 0; this.nl = this.nl + 1; this.pntx[this.nl-1] = p[0]; this.pnty[this.nl-1] = p[1]; this.pntx[this.nl] = p[0]; this.pnty[this.nl] = p[1]; if (this.type == 'symbol') { this.angle = 0; this.build.innerHTML = this.vmlSymbol(); this.build.style.zIndex = 50; return; } if (this.type == 'text') { this.angle = 0; this.build.innerHTML = this.vmlText(); this.build.style.zIndex = 50; return; } if (this.type == 'textbox') { this.angle = 0; this.build.innerHTML = this.vmlTextbox(); this.build.style.zIndex = 50; return; } if (this.type == 'image') { this.angle = 0; this.build.innerHTML = this.vmlImage(); this.build.style.zIndex = 50; return; } if (this.type == 'shape') { this.angle = 0; this.build.innerHTML = this.vmlShape(); this.build.style.zIndex = 50; return; } if (this.type == 'rectangle') return; if (this.type == 'area') return; if (this.type == 'circle') return; if (this.type == 'arc') return; this.build.innerHTML = this.vmlLine("red","",true); this.build.style.zIndex = 50; } //======================================================================== // MAKE$buildMove //======================================================================== function MAKE$buildMove(sx,sy) { var x,y; var dx,dy; var p; var px,py; if (this.nl <= 0) return; x = this.view.screenToX(sx); y = this.view.screenToY(sy); //------------ Area ------------ if (this.type == 'area') { this.xmin = Math.min(x,this.x1); this.ymin = Math.min(y,this.y1); this.xmax = Math.max(x,this.x1); this.ymax = Math.max(y,this.y1); this.nl = 4; this.pntx[0] = this.xmin; this.pnty[0] = this.ymin; this.pntx[1] = this.xmin; this.pnty[1] = this.ymax; this.pntx[2] = this.xmax; this.pnty[2] = this.ymax; this.pntx[3] = this.xmax; this.pnty[3] = this.ymin; this.pntx[4] = this.xmin; this.pnty[4] = this.ymin; this.build.innerHTML = this.vmlLine("blue","",true); this.build.style.zIndex = 50; return; } //------------ sketch ----------- if (this.type == 'sketch') { px = this.view.xToScreen(this.pntx[this.nl]); py = this.view.yToScreen(this.pnty[this.nl]); dx = Math.abs(px - x); dy = Math.abs(py - y); if ((dx < 4) && (dy < 4)) return; this.nl = this.nl + 1; } p = this.snap(x,y) this.pntx[this.nl] = p[0]; this.pnty[this.nl] = p[1]; //------------ Area ------------ if (this.type == 'circle') { this.build.innerHTML = this.vmlCircle("red","",true); this.build.style.zIndex = 50; return; } if (this.type == 'rectangle') { this.build.innerHTML = this.vmlRectangle("red","",true); this.build.style.zIndex = 50; return; } if (this.type == 'arc') { this.build.innerHTML = this.vmlArc("red","",true); this.build.style.zIndex = 50; return; } if ((this.type == 'symbol')) { this.build.innerHTML = this.vmlSymbol(); this.build.style.zIndex = 50; return; } if ((this.type == 'text')) { this.pntx[0] = p[0]; this.pnty[0] = p[1]; this.build.innerHTML = this.vmlText(); this.build.style.zIndex = 50; return; } if ((this.type == 'textbox')) { this.build.innerHTML = this.vmlTextbox(); this.build.style.zIndex = 50; return; } if ((this.type == 'image')) { this.build.innerHTML = this.vmlImage(); this.build.style.zIndex = 50; return; } if ((this.type == 'shape')) { this.build.innerHTML = this.vmlShape(); this.build.style.zIndex = 50; return; } this.build.innerHTML = this.vmlLine("red","",true); this.build.style.zIndex = 50; } //======================================================================== // MAKE$vmlLine //======================================================================== function MAKE$vmlLine(color,href,build) { var xmin,ymin,xmax,ymax,text; var coord,i,first,filled,xhref; var lcolor; var cmd; var np; np = this.nl; if (build) np = np + 1; if (np < 2) return ""; for (i = 0; i < np; ++i) { x = Math.round(this.view.xToScreen(this.pntx[i])); y = Math.round(this.view.yToScreen(this.pnty[i])); if (i == 0) { coord = x + "," + y; first = "," + coord; } else { coord = coord + ", " + x + "," + y; } } if (this.isClosed) coord = coord + first; text = ""; return text; } //======================================================================== // MAKE$vmlPline //======================================================================== function MAKE$vmlPline(color,href,build) { var xmin,ymin,xmax,ymax,text; var coord,i,first,filled,xhref; var lcolor; var cmd; var np; np = this.nl; if (build) np = np + 1; if (np < 2) return ""; for (i = 0; i < np; ++i) { x = Math.round(this.view.xToScreen(this.pntx[i])); y = Math.round(this.view.yToScreen(this.pnty[i])); if (i == 0) { coord = x + "," + y; first = "," + coord; } else { coord = coord + ", " + x + "," + y; } } if (this.isClosed) coord = coord + first; text = ""; return text; } //======================================================================== // MAKE$vmlSymbol //======================================================================== function MAKE$vmlSymbol() { var text; var size; var np; var x,y,dx,dy; var x1,y1,x2,y2; var x,y; var rot; np = this.nl; if (np < 1) return ""; this.angle = 0 x1 = Math.round(this.view.xToScreen(this.pntx[0])); y1 = Math.round(this.view.yToScreen(this.pnty[0])); x2 = Math.round(this.view.xToScreen(this.pntx[1])); y2 = Math.round(this.view.yToScreen(this.pnty[1])); dx = Math.abs(x2 - x1); dy = Math.abs(y2 - y1); if ((dx > 8) || (dy > 8)) this.angle = angle$(x1,y1,x2,y2); window.status = 'Angle: ' + degree$(this.angle); try { size = parseInt(symbolSize.value); } catch (e) {size = 10 } if (size <= 0) return ""; dx = Math.round(size / 2); x = x1 - dx; y = y1 - dx; rot = ''; if (this.angle != 0) rot = ' Rotation=' + Math.round(degree$(this.angle)) + ';'; text = ""; toClipboard(text); return text; } //======================================================================== // MAKE$vmlArc //======================================================================== function MAKE$vmlArc(color,href,build) { var xmin,ymin,xmax,ymax,text; var coord,i,first,filled,xhref; var lcolor; var cmd; var np; np = this.nl; if (build) np = np + 1; if (np < 3) return ""; x1 = Math.round(this.view.xToScreen(this.pntx[0])); y1 = Math.round(this.view.yToScreen(this.pnty[0])); x2 = Math.round(this.view.xToScreen(this.pntx[2])); y2 = Math.round(this.view.yToScreen(this.pnty[2])); x3 = Math.round(this.view.xToScreen(this.pntx[1])); y3 = Math.round(this.view.yToScreen(this.pnty[1])); this.elementArc = makeArc$(x1,y1,x2,y2,x3,y3); if (this.elementArc.np <= 0) return; filled = "F"; if (this.isClosed) filled = "T"; for (i = 0; i < this.elementArc.np; ++i) { if (i == 0) { coord = this.elementArc.x[i] + "," + this.elementArc.y[i]; first = "," + coord; } else { coord = coord + ", " + this.elementArc.x[i] + "," + this.elementArc.y[i]; } } lcolor = "black"; if (this.isClosed) coord = coord + first; text = ''; text = ""; return text; } //======================================================================== // MAKE$vmlCircle //======================================================================== function MAKE$vmlCircle(color,href,build) { var xmin,ymin,xmax,ymax,text; var coord,i,first,filled,xhref; var lcolor; var cmd; var np; var dx,dy; var radius; var diameter; var cx,cy; var x1,y1,x2,y2; np = this.nl; if (build) np = np + 1; if (np < 2) return ""; x1 = Math.round(this.view.xToScreen(this.pntx[0])); y1 = Math.round(this.view.yToScreen(this.pnty[0])); x2 = Math.round(this.view.xToScreen(this.pntx[1])); y2 = Math.round(this.view.yToScreen(this.pnty[1])); cx = x1; cy = y1; dx = Math.abs(x2 - x1); dy = Math.abs(y2 - y1); radius = Math.round(Math.sqrt((dx*dx) + (dy*dy))); xmin = cx - radius; ymin = cy - radius; diameter = radius * 2; text = ""; return text; } //======================================================================== // MAKE$vmlRectangle //======================================================================== function MAKE$vmlRectangle(color,href,build) { var xmin,ymin,xmax,ymax,text; var coord,i,first,filled,xhref; var cmd; var np; var dx,dy; var radius; var diameter; var cx,cy; var x1,y1,x2,y2; np = this.nl; if (build) np = np + 1; if (np < 2) return ""; filled = "F"; if (this.isClosed) filled = "T"; x1 = Math.round(this.view.xToScreen(this.pntx[0])); y1 = Math.round(this.view.yToScreen(this.pnty[0])); x2 = Math.round(this.view.xToScreen(this.pntx[1])); y2 = Math.round(this.view.yToScreen(this.pnty[1])); xmin = Math.min(x1,x2); ymin = Math.min(y1,y2); xmax = Math.max(x1,x2); ymax = Math.max(y1,y2); dx = xmax - xmin; dy = ymax - ymin; text = ""; return text; } //======================================================================== // MAKE$erase //======================================================================== function MAKE$erase() { this.buildErase(); this.nl = 0; } //======================================================================== // MAKE$xPos //======================================================================== function MAKE$xPos(obj) { var p, left, dx; left = 0; p = obj; while (p != null) { left = left + p.offsetLeft; p = p.offsetParent; } dx = document.documentElement.scrollLeft + document.body.scrollLeft; return (left); } //======================================================================== // MAKE$yPos //======================================================================== function MAKE$yPos(obj) { var p, top, dy; top = 0; p = obj; while (p != null) { top = top + p.offsetTop; p = p.offsetParent; } dy = document.documentElement.scrollTop + document.body.scrollTop; return (top); } //========================================================================== // MAKE$visible //========================================================================== function MAKE$visible(status) { this.isVisible = status; this.draw(); } //========================================================================== // MAKE$drawPoint //========================================================================== function MAKE$drawPoint(sx,sy,shape,color,href,hint) { var xhref; var xhint; var re = new RegExp("://"); var id; var cmd; if (sx < -5) return; if (sx > (this.width+5)) return; if (sy < -5) return; if (sy > (this.height+5)) return; xhref = ""; if (href != "") { n = href.match(re); if (n != null) { xhref = " href=\"" + href + "\" target=\"_blank\""; } else { xhref = " onClick=\"graPicture('" + href + "')\""; } } id = ""; xhint = ""; if (hint != "") xhint = " onMouseOut=\"graHint()\" onMouseOver=\"graHint('" + edit(hint) + "')\""; cmd = " onmousedown=\"xMAKE$mouseDown(this)\"" + " onmousedown=\"xMAKE$mouseUp(this)\""; obj2 = document.createElement(''); obj2.innerHTML = ''; obj2.style.position = "absolute" obj2.style.top = sy - 5; obj2.style.left = sx - 5; obj2.style.width = 10; obj2.style.height = 10; obj2.fillcolor = color; obj2.style.zIndex = 50; this.layer.appendChild(obj2); } //========================================================================== // MAKE$vmlText //========================================================================== function MAKE$vmlText() { var txt,angle,text; var color1,color2; this.angle = 0; x = Math.round(this.view.xToScreen(this.pntx[0])); y = Math.round(this.view.yToScreen(this.pnty[0])); text = textText.value; if (text == '') text = ' '; size = parseInt(editDC.textSize); if (size <= 0) size = 1; y = y - size; //------------ Simple Text ------- txt = ''; if (editDC.textBold) text = '' + text + ''; if (editDC.textItalic) text = '' + text + ''; if (editDC.textUnderline) text = '' + text + ''; txt = txt + text + ''; return txt; } //========================================================================== // MAKE$vmlTextbox //========================================================================== function MAKE$vmlTextbox() { var txt,angle,text; var x1,y1,x2,y2; var xmin,ymin,xmax,ymax; var h,w; var s; x1 = Math.round(this.view.xToScreen(this.pntx[0])); y1 = Math.round(this.view.yToScreen(this.pnty[0])); x2 = Math.round(this.view.xToScreen(this.pntx[1])); y2 = Math.round(this.view.yToScreen(this.pnty[1])); xmin = Math.min(x1,x2); ymin = Math.min(y1,y2); xmax = Math.max(x1,x2); ymax = Math.max(y1,y2); w = xmax - xmin; h = ymax - ymin; this.textboxHeight = h; this.textboxWidth = w; text = textText.value; if (text == '') text = ' '; size = parseInt(editDC.textSize); if (size <= 0) size = 1; if (editDC.textBold) text = '' + text + ''; if (editDC.textItalic) text = '' + text + ''; if (editDC.textUnderline) text = '' + text + ''; rot = ''; if (this.angle != 0) rot = ' Rotation=' + Math.round(degree$(this.angle)) + ';'; //----------- Word Art ------------ s = editStyle(this.type); txt = ""; txt = txt + ""; txt = txt + ''; txt = txt + ''; txt = txt + text + ''; txt = txt + ''; txt = txt + ""; return txt; } //========================================================================== // MAKE$vmlImage //========================================================================== function MAKE$vmlImage() { var txt,angle,text; var x1,y1,x2,y2; var xmin,ymin,xmax,ymax; var h,w; var s; x1 = Math.round(this.view.xToScreen(this.pntx[0])); y1 = Math.round(this.view.yToScreen(this.pnty[0])); x2 = Math.round(this.view.xToScreen(this.pntx[1])); y2 = Math.round(this.view.yToScreen(this.pnty[1])); xmin = Math.min(x1,x2); ymin = Math.min(y1,y2); xmax = Math.max(x1,x2); ymax = Math.max(y1,y2); w = xmax - xmin; h = ymax - ymin; this.textboxHeight = h; this.textboxWidth = w; rot = ''; if (this.angle != 0) rot = ' Rotation=' + Math.round(degree$(this.angle)) + ';'; //----------- Word Art ------------ s = editStyle(this.type); txt = ""; txt = txt + ""; txt = txt + ""; txt = txt + ""; toClipboard(txt); return txt; } //========================================================================== // MAKE$vmlShape //========================================================================== function MAKE$vmlShape() { var txt,angle,text; var x1,y1,x2,y2; var xmin,ymin,xmax,ymax; var h,w; var s,a,c; var ss; x1 = Math.round(this.view.xToScreen(this.pntx[0])); y1 = Math.round(this.view.yToScreen(this.pnty[0])); x2 = Math.round(this.view.xToScreen(this.pntx[1])); y2 = Math.round(this.view.yToScreen(this.pnty[1])); xmin = Math.min(x1,x2); ymin = Math.min(y1,y2); xmax = Math.max(x1,x2); ymax = Math.max(y1,y2); w = xmax - xmin; h = ymax - ymin; this.shapeHeight = h; this.shapeWidth = w; text = shapeText.value; if (text == '') text = ' '; size = parseInt(editDC.textSize); if (size <= 0) size = 1; if (editDC.textBold) text = '' + text + ''; if (editDC.textItalic) text = '' + text + ''; if (editDC.textUnderline) text = '' + text + ''; rot = ''; if (this.angle != 0) rot = ' Rotation=' + Math.round(degree$(this.angle)) + ';'; //----------- Word Art ------------ s = editStyle(this.type); a = ''; if ((editDC.textBgcolor != '') && editDC.textFill) a = a + ' fillcolor=' + editDC.textBgcolor; ss = parseInt(editDC.shapeStyle); if (isNaN(ss)) ss = 63; if (ss < 0) ss = 63; txt = ""; txt = txt + ""; c = parseInt(editDC.shapeLineWidth); if (c > 0) { txt = txt + ""; } txt = txt + ''; txt = txt + ''; txt = txt + text + ''; txt = txt + ''; txt = txt + ""; return txt; } //========================================================================== // MAKE$showRange //========================================================================== function MAKE$showRange(range) { if (this.rangeObj == null) { this.rangeObj = document.createElement(''); this.layer.appendChild(this.rangeObj); } this.rangeObj.innerHTML = ''; this.rangeObj.style.position = "relative" this.rangeObj.style.top = range[1]; this.rangeObj.style.left = range[0]; this.rangeObj.style.width = range[2] - range[0]; this.rangeObj.style.height = range[3] - range[1]; this.rangeObj.style.visibility = ''; this.rangeObj.style.zIndex = 150; } //========================================================================== // MAKE$eraseRange //========================================================================== function MAKE$eraseRange(range) { if (this.rangeObj == null) return; this.rangeObj.style.visibility = 'hidden'; } //====================================================================== // replaceall //====================================================================== function edit(text) { var h; h = text.toString(); h = trim(h); while (h.indexOf("'") >= 0) { h = h.replace("'",""); } return (h); } //============================================================================ // MAKE$Line //============================================================================ function MAKE$line(onCompleted,onMove,onCancel,x,y) { this.removeEvents(); this.nl = 0; this.type = 'line'; this.setOn(onCompleted,onMove,onCancel); this.isRubberBand = true; this.isRubberDown = false; this.isDown = false; this.isClosed = false; if (x) { this.nl = 1; this.pntx[0] = x; this.pnty[0] = y; this.pntx[1] = x; this.pnty[1] = y; } this.attachEvents(); } //============================================================================ // MAKE$circle //============================================================================ function MAKE$circle(onCompleted,onMove,onCancel,x,y) { this.removeEvents(); this.nl = 0; this.type = 'circle'; this.setOn(onCompleted,onMove,onCancel); this.isRubberBand = true; this.isRubberDown = false; this.isDown = false; this.isClosed = true; if (x) { this.nl = 1; this.pntx[0] = x; this.pnty[0] = y; this.pntx[1] = x; this.pnty[1] = y; } this.attachEvents(); } //============================================================================ // MAKE$polygon //============================================================================ function MAKE$polygon(onCompleted,onMove,onCancel,x,y) { this.removeEvents(); this.nl = 0; this.type = 'polygon'; this.setOn(onCompleted,onMove,onCancel); this.isRubberBand = true; this.isRubberDown = false; this.isDown = false; this.isClosed = true; if (x) { this.nl = 1; this.pntx[0] = x; this.pnty[0] = y; this.pntx[1] = x; this.pnty[1] = y; } this.attachEvents(); } //============================================================================ // MAKE$pline //============================================================================ function MAKE$pline(onCompleted,onMove,onCancel,x,y) { this.removeEvents(); this.nl = 0; this.type = 'pline'; this.setOn(onCompleted,onMove,onCancel); this.isRubberBand = true; this.isRubberDown = false; this.isDown = false; this.isClosed = false; if (x) { this.nl = 1; this.pntx[0] = x; this.pnty[0] = y; this.pntx[1] = x; this.pnty[1] = y; } this.attachEvents(); } //============================================================================ // MAKE$area //============================================================================ function MAKE$area(onCompleted,onMove,onCancel) { var c = "htt" + "p://msdn.microsoft.com/workshop/samples/author/dhtml/refs/cursor2.ani"; var c = "images/Select.cur"; this.removeEvents(); this.type = 'area'; this.setOn(onCompleted,onMove,onCancel); this.isRubberBand = true; this.isRubberDown = true; this.isDown = false; this.isClosed = false; this.attachEvents(); // this.img.style.cursor = "url(" + c + ")"; this.img.style.cursor = "hand"; } //============================================================================ // MAKE$textbox //============================================================================ function MAKE$textbox(onCompleted,onMove,onCancel) { this.removeEvents(); this.type = 'textbox'; this.setOn(onCompleted,onMove,onCancel); this.isRubberBand = true; this.isRubberDown = true; this.isDown = false; this.isClosed = false; this.attachEvents(); } //============================================================================ // MAKE$image //============================================================================ function MAKE$image(onCompleted,onMove,onCancel) { this.removeEvents(); this.type = 'image'; this.setOn(onCompleted,onMove,onCancel); this.isRubberBand = true; this.isRubberDown = true; this.isDown = false; this.isClosed = false; this.attachEvents(); } //============================================================================ // MAKE$shape //============================================================================ function MAKE$shape(onCompleted,onMove,onCancel) { this.removeEvents(); this.type = 'shape'; this.setOn(onCompleted,onMove,onCancel); this.isRubberBand = true; this.isRubberDown = true; this.isDown = false; this.isClosed = false; this.attachEvents(); } //============================================================================ // MAKE$shape //============================================================================ function MAKE$pline(onCompleted,onMove,onCancel) { this.removeEvents(); this.type = 'pline'; this.setOn(onCompleted,onMove,onCancel); this.isRubberBand = true; this.isRubberDown = true; this.isDown = false; this.isClosed = false; this.attachEvents(); } //============================================================================ // MAKE$rectangle //============================================================================ function MAKE$rectangle(onCompleted,onMove,onCancel) { this.removeEvents(); this.type = 'rectangle'; this.setOn(onCompleted,onMove,onCancel); this.isRubberBand = true; this.isRubberDown = false; this.isDown = false; this.isClosed = true; this.attachEvents(); } //============================================================================ // MAKE$arc //============================================================================ function MAKE$arc(onCompleted,onMove,onCancel) { this.removeEvents(); this.type = 'arc'; this.setOn(onCompleted,onMove,onCancel); this.isRubberBand = false; this.isRubberDown = false; this.isDown = false; this.isClosed = false; this.attachEvents(); } //============================================================================ // MAKE$symbol //============================================================================ function MAKE$symbol(onCompleted,onMove,onCancel) { this.removeEvents(); this.type = 'symbol'; this.setOn(onCompleted,onMove,onCancel); this.isRubberBand = true; this.isRubberDown = true; this.isDown = false; this.isClosed = false; this.angle = 0; this.attachEvents(); } //============================================================================ // MAKE$text //============================================================================ function MAKE$text(onCompleted,onMove,onCancel) { this.removeEvents(); this.type = 'text'; this.setOn(onCompleted,onMove,onCancel); this.isRubberBand = true; this.isRubberDown = true; this.isDown = false; this.isClosed = false; this.angle = 0; this.attachEvents(); } //============================================================================ // MAKE$sketch //============================================================================ function MAKE$sketch(onCompleted,onMove,onCancel) { this.removeEvents(); this.type = 'sketch'; this.setOn(onCompleted,onMove,onCancel); this.isRubberBand = true; this.isRubberDown = true; this.isDown = false; this.isClosed = false; this.attachEvents(); } //============================================================================ // MAKE$measure //============================================================================ function MAKE$measure(onCompleted,onMove,onCancel,x,y) { this.removeEvents(); this.type = 'measure'; this.setOn(onCompleted,onMove,onCancel); this.isRubberBand = true; this.isRubberDown = true; this.isDown = false; if (x) { this.nl = 1; this.pntx[0] = x; this.pnty[0] = y; this.pntx[1] = x; this.pnty[1] = y; } this.attachEvents(); this.img.style.cursor = "hand"; } //======================================================================= // MAKE$setOn //======================================================================= function MAKE$setOn(onCompleted,onMove,onCancel) { this.onCreate = ''; this.onMove = ''; this.onCancel = ''; if (onCompleted) this.onCompleted = onCompleted; if (onMove) this.onMove = onMove; if (onCancel) this.onCancel = onCancel; } //======================================================================= // MAKE$attachEvents //======================================================================= function MAKE$attachEvents() { var obj; G.isSelect = false; activeMake = this; this.isSet = true; this.nl = 0; this.buildErase(); disableMainEvents(); obj = this.img; obj = window.document; obj.attachEvent("onmousedown", ie$makeMouseDown); obj.attachEvent("onmousemove", ie$makeMouseMove); obj.attachEvent("onmouseup", ie$makeMouseUp); obj.attachEvent("ondblclick", ie$makeDblClick); window.document.attachEvent("onkeydown", ie$makeKeyDown); window.document.attachEvent("onkeyup", ie$makeKeyUp); // if (browser.isNS) { // this.img.addEventListener("mousemove", nav$makeMouseMove, true); // this.img.addEventListener("mouseup", nav$makeMouseStop, true); // this.img.addEventListener("mousedown", nav$makeMouseDown, true); // this.img.addEventListener("keydown", nav$makeKeyDown, true); // event.preventDefault(); // } } //============================================================================ // MAKE$removeEvents //============================================================================ function MAKE$removeEvents() { var obj; this.img.style.cursor = ''; this.buildErase(); if (G != undefined) G.mode = ''; if (! this.isSet) return; this.isSet = false; obj = this.img; obj = window.document; obj.detachEvent("onmousemove", ie$makeMouseMove); obj.detachEvent("onmouseup", ie$makeMouseUp); obj.detachEvent("onmousedown", ie$makeMouseDown); obj.detachEvent("ondblclick", ie$makeDblClick); window.document.detachEvent("onkeydown", ie$makeKeyDown); window.document.detachEvent("onkeyup", ie$makeKeyUp); this.isRubberBand = false; this.isRubberDown = false; this.isDown = false; enableMainEvents(); // if (browser.isNS) { // document.removeEventListener("mousemove", dragMove, true); // document.removeEventListener("mouseup", dragStop, true); // } } //============================================================================ // MAKE$completed //============================================================================ function MAKE$completed() { this.removeEvents(); this.command(this.onCompleted); } //============================================================================ // MAKE$command //============================================================================ function MAKE$command(functionName) { var cmd; var xmin,ymin,xmax,ymax; var cx,cy,radius,start,sweep; var h,w; if (! functionName) return; if (functionName == '') return; if ((this.type == 'area')) { cmd = functionName + '(activeMake,' + this.xmin + ',' + this.ymin + ',' + this.xmax + ',' + this.ymax + ');'; eval(cmd); return; } if (this.type == 'textbox') { xmin = Math.min(this.pntx[0],this.pntx[1]); ymin = Math.min(this.pnty[0],this.pnty[1]); xmax = Math.max(this.pntx[0],this.pntx[1]); ymax = Math.max(this.pnty[0],this.pnty[1]); h = this.textboxHeight; w = this.textboxWidth; cmd = functionName + '(activeMake,' + xmin + ',' + ymin + ',' + xmax + ',' + ymax + ',' + h + ',' + w + ');'; eval(cmd); return; } if (this.type == 'image') { xmin = Math.min(this.pntx[0],this.pntx[1]); ymin = Math.min(this.pnty[0],this.pnty[1]); xmax = Math.max(this.pntx[0],this.pntx[1]); ymax = Math.max(this.pnty[0],this.pnty[1]); h = this.textboxHeight; w = this.textboxWidth; cmd = functionName + '(activeMake,' + xmin + ',' + ymin + ',' + xmax + ',' + ymax + ',' + h + ',' + w + ');'; eval(cmd); return; } if (this.type == 'shape') { xmin = Math.min(this.pntx[0],this.pntx[1]); ymin = Math.min(this.pnty[0],this.pnty[1]); xmax = Math.max(this.pntx[0],this.pntx[1]); ymax = Math.max(this.pnty[0],this.pnty[1]); h = this.shapeHeight; w = this.shapeWidth; cmd = functionName + '(activeMake,' + xmin + ',' + ymin + ',' + xmax + ',' + ymax + ',' + h + ',' + w + ');'; eval(cmd); return; } if ((this.type == 'line') || (this.type == 'measure') || (this.type == 'circle') || (this.type == 'rectangle')) { cmd = functionName + '(activeMake,' + this.pntx[0] + ',' + this.pnty[0] + ',' + this.pntx[1] + ',' + this.pnty[1] + ');'; eval(cmd); return; } if ((this.type == 'pline') || (this.type == 'polygon') || (this.type == 'sketch')) { cmd = functionName + '(activeMake,' + this.nl + ',this.pntx,this.pnty);'; eval(cmd); return; } if (this.type == 'arc') { if (this.elementArc.np == 0) return; cx = this.view.screenToX(this.elementArc.cx); cy = this.view.screenToY(this.elementArc.cy); radius = Math.abs(this.view.screenToX(0) - this.view.screenToX(this.elementArc.radius)); start = this.elementArc.start; // inverted Y axis sweep = this.elementArc.sweep; cmd = functionName + '(activeMake,' + cx + ',' + cy + ',' + radius + ',' + start + ',' + sweep + ');'; eval(cmd); return; } if (this.type == 'symbol') { cmd = functionName + '(activeMake,this.pntx[0],this.pnty[0],this.angle);'; eval(cmd); return; } if (this.type == 'text') { cmd = functionName + '(activeMake,this.pntx[0],this.pnty[0],this.angle);'; eval(cmd); return; } } //============================================================================ // MAKE$keyUp //============================================================================ function MAKE$keyUp(key,ctrl,alt) { if (alt) { disableMainEvents(); } } //============================================================================ // MAKE$keyDown //============================================================================ function MAKE$keyDown(key,ctrl,alt) { if (alt) { enableMainEvents(); } if (ctrl) { if (key == KEY_A) { window.event.cancelBubble = true; window.event.returnValue = false; G.selectAll(); return; } if (key == KEY_C) { window.event.cancelBubble = true; window.event.returnValue = false; G.copy(); return; } if (key == KEY_X) { window.event.cancelBubble = true; window.event.returnValue = false; G.cut(); return; } if (key == KEY_V) { window.event.cancelBubble = true; window.event.returnValue = false; G.paste(); return; } if (key == KEY_Z) { window.event.cancelBubble = true; window.event.returnValue = false; G.undelete(); return; } } if (key == ESC) { activeMake.erase(); G.clearSelected(); G.setNavigationButtons(); return; } if (key == F2) { activeMake.completed(); return; } if (key == DEL) { G.deleteSelected(); return; } if (key == KEY_PAGEUP) { G.previousFeature(); return; } if (key == KEY_PAGEDOWN) { G.nextFeature(); return; } // alert(key); //----------------- only if CTRL key down ----------------------- if (! ctrl) return if ((key == KEY_LEFT) || (key == KEY_DOWN)) { window.event.cancelBubble = true; window.event.returnValue = false; G.previousRecord(); return; } if ((key == KEY_UP) || (key == KEY_RIGHT)) { window.event.cancelBubble = true; window.event.returnValue = false; G.nextRecord(); return; } } //============================================================================ // MAKE$cancel //============================================================================ function MAKE$cancel() { this.removeEvents(); this.isDown = true; this.isRubberBand = false; this.isRubberDown = false; this.command(this.onCancel); } //============================================================================ // MAKE$mouseDown //============================================================================ function MAKE$mouseDown(x,y) { this.isDown = true; G.clearSelected(); G.mode = 'building'; if (this.type == 'area') { this.buildArea(x,y); return; } if (this.type == 'text') this.nl = 0; if (this.type == 'arc') { this.buildAdd(x,y); if (this.nl == 2) this.isRubberBand = true; return; } this.buildAdd(x,y); } //============================================================================ // MAKE$mouseMove //============================================================================ function MAKE$mouseMove(x,y) { var cmd; var rx,ry; if (this.nl == 0) return; if (this.isDown && (! this.isRubberDown)) return; if (! this.isRubberBand) return; this.buildMove(x,y); this.command(this.onMove); } //============================================================================ // MAKE$mouseUp //============================================================================ function MAKE$mouseUp(x,y) { this.isDown = false; this.img.style.cursor = ''; if (this.type == 'line') { // this.buildAdd(x,y); if (this.nl == 2) this.completed(); return; } if ((this.type == 'symbol') || (this.type == 'text')) { this.buildAdd(x,y); this.completed(); return; } if (this.type == 'arc') { if (this.nl < 3) return; this.completed(); return; } if (this.type == 'circle') { // this.buildAdd(x,y); if (this.nl == 2) this.completed(); return; } if (this.type == 'rectangle') { // this.buildAdd(x,y); if (this.nl == 2) this.completed(); return; } if ((this.type == 'polygon') || (this.type == 'pline')) { // this.buildAdd(x,y); return; } if (this.type == 'area') { this.buildAreaDone(x,y); this.completed(); return; } if (this.type == 'textbox') { this.buildAdd(x,y); if (this.nl == 2) this.completed(); return; } if (this.type == 'image') { this.buildAdd(x,y); if (this.nl == 2) this.completed(); return; } if (this.type == 'shape') { this.buildAdd(x,y); if (this.nl == 2) this.completed(); return; } if ((this.type == 'sketch')) { this.buildAdd(x,y); this.completed(); return; } if (this.type == 'measure') { // this.buildAdd(x,y); if (this.nl == 2) this.completed(); return; } } //============================================================================ // myConcern //============================================================================ function myConcern(obj,shilt,ctrl,alt) { var shift, ctrl, alt; shift = event.shiftKey; ctrl = event.ctrlKey; alt = event.altKey; if (alt) return false; if (! obj) return false; if (obj.tagName == 'INPUT') return false; if (obj.tagName == 'BODY') return false; if (obj.tagName == 'HTML') return false; if (obj == activeMake.img) return true; if (obj.id) { if (obj.id.substr(0,8) == 'icLayer_') return true; if (obj.id == 'icMake') return true; } return myConcern(obj.parentElement); } //============================================================================ // ie$makeMouseDown //============================================================================ function ie$makeMouseDown() { var x,y; var shift,ctrl,alt; activeMake.ctrlDown = event.ctrlKey; if (! myConcern(event.srcElement)) return; x = event.x; y = event.y; window.event.cancelBubble = true; window.event.returnValue = false; if (G.snapPoint) { x = G.snapX; y = G.snapY; } G.snapPoint = false; if (G.mode == 'edit') G.edit.up(x,y); activeMake.mouseDown(x,y); G.mode = ''; } //============================================================================ // ie$makeMouseMove //============================================================================ function ie$makeMouseMove() { var x,y; var rx,ry; if (! myConcern(event.srcElement)) return; x = event.x; y = event.y; activeMake.ctrlDown = event.ctrlKey; window.event.cancelBubble = true; window.event.returnValue = false; if ((G.mode != 'edit') || (G.onMove == "")) { rx = G.view.screenToX(x); ry = G.view.screenToY(y); rx = Math.round(rx * 1000) / 1000; ry = Math.round(ry * 1000) / 1000; window.status = 'x: ' + rx + ' y: ' + ry + ' sx: ' + x + ' sy: ' + y; } if (G.mode == 'edit') G.edit.move(x,y); else activeMake.mouseMove(x,y); } //============================================================================ // ie$makeMouseUp //============================================================================ function ie$makeMouseUp() { var x,y; if (! myConcern(event.srcElement)) return; x = event.x; y = event.y; activeMake.ctrlDown = event.ctrlKey; window.event.cancelBubble = true; window.event.returnValue = false; if (G.mode == 'edit') G.edit.up(x,y); else activeMake.mouseUp(x,y); G.mode = ''; } //============================================================================ // ie$makeKeyDown //============================================================================ function ie$makeKeyDown() { // window.event.cancelBubble = true; // window.event.returnValue = false; activeMake.keyDown(window.event.keyCode,window.event.ctrlKey,window.event.altKey); } //============================================================================ // ie$makeKeyUp //============================================================================ function ie$makeKeyUp() { // window.event.cancelBubble = true; // window.event.returnValue = false; activeMake.keyUp(window.event.keyCode,window.event.ctrlKey,window.event.altKey); } //============================================================================ // ie$makeDblClick //============================================================================ function ie$makeDblClick() { window.event.cancelBubble = true; window.event.returnValue = false; if (! myConcern(event.srcElement)) return; activeMake.keyDown(F2); // Completed } //============================================================================ // MAKE$makeArc //============================================================================ function MAKE$makeArc() { if (nl < 2) return false; return false; }