| 1 |
define(["dojo/_base/declare", "./ScaleIndicatorBase", "dojox/gfx", "dojo/_base/event", "dojo/dom-geometry"], |
| 2 |
function(declare, ScaleIndicatorBase, gfx, eventUtil, domGeom){ |
| 3 |
return declare("dojox.dgauges.RectangularValueIndicator", ScaleIndicatorBase, { |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
paddingLeft: 0, |
| 10 |
|
| 11 |
|
| 12 |
paddingTop: 0, |
| 13 |
|
| 14 |
|
| 15 |
paddingRight: 0, |
| 16 |
|
| 17 |
|
| 18 |
paddingBottom: 0, |
| 19 |
|
| 20 |
|
| 21 |
constructor: function(){ |
| 22 |
this.addInvalidatingProperties(["paddingTop", "paddingLeft", "paddingRight", "paddingBottom"]); |
| 23 |
}, |
| 24 |
|
| 25 |
indicatorShapeFunc: function(group, indicator){ |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
return group.createPolyline([0, 0, 10, 0, 0, 10, -10, 0, 0, 0]).setStroke({ |
| 36 |
color: "black", |
| 37 |
width: 1 |
| 38 |
}); |
| 39 |
}, |
| 40 |
|
| 41 |
refreshRendering: function(){ |
| 42 |
this.inherited(arguments); |
| 43 |
|
| 44 |
|
| 45 |
var v = isNaN(this._transitionValue) ? this.value : this._transitionValue; |
| 46 |
var pos = this.scale.positionForValue(v); |
| 47 |
|
| 48 |
|
| 49 |
var dx = 0, dy = 0; |
| 50 |
var angle = 0; |
| 51 |
if(this.scale._gauge.orientation == "horizontal"){ |
| 52 |
dx = pos; |
| 53 |
dy = this.paddingTop; |
| 54 |
}else{ |
| 55 |
dx = this.paddingLeft; |
| 56 |
dy = pos; |
| 57 |
angle = 90; |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
this._gfxGroup.setTransform([{ |
| 63 |
dx: dx, |
| 64 |
dy: dy |
| 65 |
}, gfx.matrix.rotateg(angle)]); |
| 66 |
}, |
| 67 |
|
| 68 |
_onMouseDown: function(event){ |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
this.inherited(arguments); |
| 74 |
var np = domGeom.position(this.scale._gauge.domNode, true); |
| 75 |
this.set("value", this.scale.valueForPosition({x: event.pageX - np.x, y: event.pageY - np.y})); |
| 76 |
|
| 77 |
|
| 78 |
eventUtil.stop(event); |
| 79 |
}, |
| 80 |
|
| 81 |
_onMouseMove: function(event){ |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
this.inherited(arguments); |
| 87 |
|
| 88 |
var np = domGeom.position(this.scale._gauge.domNode, true); |
| 89 |
this.set("value", this.scale.valueForPosition({x: event.pageX - np.x, y: event.pageY - np.y})); |
| 90 |
} |
| 91 |
}) |
| 92 |
}); |