1 | dojo.provide("dojox.drawing.manager.StencilUI"); |
---|
2 | |
---|
3 | (function(){ |
---|
4 | var surface, surfaceNode; |
---|
5 | dojox.drawing.manager.StencilUI = dojox.drawing.util.oo.declare( |
---|
6 | // summary: |
---|
7 | // Used for handling Stencils as UI components. |
---|
8 | // description: |
---|
9 | // Replaces manager.Stencil. Handles basic UI mouse |
---|
10 | // events like onmouseover. Does not handle selections |
---|
11 | // or support delete, etc. |
---|
12 | // |
---|
13 | function(options){ |
---|
14 | // |
---|
15 | // TODO: mixin props |
---|
16 | // |
---|
17 | surface = options.surface; |
---|
18 | this.canvas = options.canvas; |
---|
19 | |
---|
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 | })(); |
---|