| 1 |
define([ |
| 2 |
"dojo/_base/kernel", |
| 3 |
"dojo/_base/lang", |
| 4 |
"dojo/_base/array", |
| 5 |
"dojo/_base/declare", |
| 6 |
"dojo/_base/connect", |
| 7 |
"dijit/form/ToggleButton" |
| 8 |
], function(dojo){ |
| 9 |
return dojo.declare("dojox.sketch._Plugin", null, { |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
constructor: function(args){ |
| 14 |
if(args){ |
| 15 |
dojo.mixin(this, args); |
| 16 |
} |
| 17 |
this._connects=[]; |
| 18 |
}, |
| 19 |
|
| 20 |
figure: null, |
| 21 |
iconClassPrefix: "dojoxSketchIcon", |
| 22 |
itemGroup: 'toolsGroup', |
| 23 |
button: null, |
| 24 |
queryCommand: null, |
| 25 |
shape: "", |
| 26 |
useDefaultCommand: true, |
| 27 |
buttonClass: dijit.form.ToggleButton, |
| 28 |
_initButton: function(){ |
| 29 |
if(this.shape.length){ |
| 30 |
|
| 31 |
|
| 32 |
var className = this.iconClassPrefix+" "+this.iconClassPrefix + this.shape.charAt(0).toUpperCase() + this.shape.substr(1); |
| 33 |
if(!this.button){ |
| 34 |
var props = { |
| 35 |
label: this.shape, |
| 36 |
showLabel: false, |
| 37 |
iconClass: className, |
| 38 |
dropDown: this.dropDown, |
| 39 |
tabIndex: "-1" |
| 40 |
}; |
| 41 |
this.button = new this.buttonClass(props); |
| 42 |
this.connect(this.button,'onClick','activate'); |
| 43 |
} |
| 44 |
} |
| 45 |
}, |
| 46 |
attr: function(name,value){ |
| 47 |
return this.button.attr(name,value); |
| 48 |
}, |
| 49 |
onActivate: function(){}, |
| 50 |
activate: function(e){ |
| 51 |
this.onActivate(); |
| 52 |
this.figure.setTool(this); |
| 53 |
this.attr('checked',true); |
| 54 |
}, |
| 55 |
onMouseDown: function(e){}, |
| 56 |
onMouseMove: function(e){}, |
| 57 |
onMouseUp: function(e){}, |
| 58 |
destroy: function(f){ |
| 59 |
dojo.forEach(this._connects,dojo.disconnect); |
| 60 |
}, |
| 61 |
connect: function(o,f,tf){ |
| 62 |
this._connects.push(dojo.connect(o,f,this,tf)); |
| 63 |
}, |
| 64 |
setFigure: function( figure){ |
| 65 |
|
| 66 |
this.figure = figure; |
| 67 |
}, |
| 68 |
setToolbar: function( toolbar){ |
| 69 |
|
| 70 |
this._initButton(); |
| 71 |
if(this.button){ |
| 72 |
toolbar.addChild(this.button); |
| 73 |
} |
| 74 |
if(this.itemGroup){ |
| 75 |
toolbar.addGroupItem(this,this.itemGroup); |
| 76 |
} |
| 77 |
} |
| 78 |
}); |
| 79 |
}); |