StencilUI.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // wrapped by build app
  2. define("dojox/drawing/manager/StencilUI", ["dijit","dojo","dojox"], function(dijit,dojo,dojox){
  3. dojo.provide("dojox.drawing.manager.StencilUI");
  4. (function(){
  5. var surface, surfaceNode;
  6. dojox.drawing.manager.StencilUI = dojox.drawing.util.oo.declare(
  7. // summary:
  8. // Used for handling Stencils as UI components.
  9. // description:
  10. // Replaces manager.Stencil. Handles basic UI mouse
  11. // events like onmouseover. Does not handle selections
  12. // or support delete, etc.
  13. //
  14. function(options){
  15. //
  16. // TODO: mixin props
  17. //
  18. surface = options.surface;
  19. this.canvas = options.canvas;
  20. this.defaults = dojox.drawing.defaults.copy();
  21. this.mouse = options.mouse;
  22. this.keys = options.keys;
  23. this._mouseHandle = this.mouse.register(this);
  24. this.stencils = {};
  25. },
  26. {
  27. register: function(/*Object*/stencil){
  28. this.stencils[stencil.id] = stencil;
  29. return stencil;
  30. },
  31. onUiDown: function(/*EventObject*/obj){
  32. // summary:
  33. // Event fired on mousedown on a stencil
  34. //
  35. if(!this._isStencil(obj)){ return; }
  36. this.stencils[obj.id].onDown(obj);
  37. },
  38. onUiUp: function(/*EventObject*/obj){
  39. // summary:
  40. // Event fired on mousedown on a stencil
  41. //
  42. if(!this._isStencil(obj)){ return; }
  43. this.stencils[obj.id].onUp(obj);
  44. },
  45. onOver: function(/*EventObject*/obj){
  46. // summary:
  47. // Event fired on mousedown on a stencil
  48. //
  49. if(!this._isStencil(obj)){ return; }
  50. this.stencils[obj.id].onOver(obj);
  51. },
  52. onOut: function(/*EventObject*/obj){
  53. // summary:
  54. // Event fired on mousedown on a stencil
  55. //
  56. if(!this._isStencil(obj)){ return; }
  57. this.stencils[obj.id].onOut(obj);
  58. },
  59. _isStencil: function(/*EventObject*/obj){
  60. return !!obj.id && !!this.stencils[obj.id] && this.stencils[obj.id].type == "drawing.library.UI.Button";
  61. }
  62. }
  63. );
  64. })();
  65. });