root / trunk / web / dojo / dojox / drawing / manager / Canvas.js
History | View | Annotate | Download (2.93 KB)
1 | 9 | andrej.cim | /*
|
---|---|---|---|
2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||
3 | Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||
4 | see: http://dojotoolkit.org/license for details
|
||
5 | */
|
||
6 | |||
7 | |||
8 | if(!dojo._hasResource["dojox.drawing.manager.Canvas"]){ |
||
9 | dojo._hasResource["dojox.drawing.manager.Canvas"]=true; |
||
10 | dojo.provide("dojox.drawing.manager.Canvas");
|
||
11 | (function(){
|
||
12 | dojox.drawing.manager.Canvas=dojox.drawing.util.oo.declare(function(_1){
|
||
13 | dojo.mixin(this,_1);
|
||
14 | var _2=dojo.contentBox(this.srcRefNode); |
||
15 | this.height=this.parentHeight=_2.h; |
||
16 | this.width=this.parentWidth=_2.w; |
||
17 | this.domNode=dojo.create("div",{id:"canvasNode"},this.srcRefNode); |
||
18 | dojo.style(this.domNode,{width:this.width,height:"auto"}); |
||
19 | dojo.setSelectable(this.domNode,false); |
||
20 | this.id=this.id||this.util.uid("surface"); |
||
21 | this.gfxSurface=dojox.gfx.createSurface(this.domNode,this.width,this.height); |
||
22 | this.gfxSurface.whenLoaded(this,function(){ |
||
23 | setTimeout(dojo.hitch(this,function(){ |
||
24 | this.surfaceReady=true; |
||
25 | if(dojo.isIE){
|
||
26 | }else{
|
||
27 | if(dojox.gfx.renderer=="silverlight"){ |
||
28 | this.id=this.domNode.firstChild.id; |
||
29 | }else{
|
||
30 | } |
||
31 | } |
||
32 | this.underlay=this.gfxSurface.createGroup(); |
||
33 | this.surface=this.gfxSurface.createGroup(); |
||
34 | this.overlay=this.gfxSurface.createGroup(); |
||
35 | this.surface.setTransform({dx:0,dy:0,xx:1,yy:1}); |
||
36 | this.gfxSurface.getDimensions=dojo.hitch(this.gfxSurface,"getDimensions"); |
||
37 | if(_1.callback){
|
||
38 | _1.callback(this.domNode);
|
||
39 | } |
||
40 | }),500);
|
||
41 | }); |
||
42 | this._mouseHandle=this.mouse.register(this); |
||
43 | },{zoom:1,useScrollbars:true,baseClass:"drawingCanvas",resize:function(_3,_4){ |
||
44 | this.parentWidth=_3;
|
||
45 | this.parentHeight=_4;
|
||
46 | this.setDimensions(_3,_4);
|
||
47 | },setDimensions:function(_5,_6,_7,_8){ |
||
48 | var sw=this.getScrollWidth(); |
||
49 | this.width=Math.max(_5,this.parentWidth); |
||
50 | this.height=Math.max(_6,this.parentHeight); |
||
51 | if(this.height>this.parentHeight){ |
||
52 | this.width-=sw;
|
||
53 | } |
||
54 | if(this.width>this.parentWidth){ |
||
55 | this.height-=sw;
|
||
56 | } |
||
57 | this.mouse.resize(this.width,this.height); |
||
58 | this.gfxSurface.setDimensions(this.width,this.height); |
||
59 | this.domNode.parentNode.scrollTop=_8||0; |
||
60 | this.domNode.parentNode.scrollLeft=_7||0; |
||
61 | if(this.useScrollbars){ |
||
62 | dojo.style(this.domNode.parentNode,{overflowY:this.height>this.parentHeight?"scroll":"hidden",overflowX:this.width>this.parentWidth?"scroll":"hidden"}); |
||
63 | }else{
|
||
64 | dojo.style(this.domNode.parentNode,{overflowY:"hidden",overflowX:"hidden"}); |
||
65 | } |
||
66 | },setZoom:function(_9){ |
||
67 | this.zoom=_9;
|
||
68 | this.surface.setTransform({xx:_9,yy:_9}); |
||
69 | this.setDimensions(this.width*_9,this.height*_9); |
||
70 | },onScroll:function(){ |
||
71 | },getScrollOffset:function(){ |
||
72 | return {top:this.domNode.parentNode.scrollTop,left:this.domNode.parentNode.scrollLeft}; |
||
73 | },getScrollWidth:function(){ |
||
74 | var p=dojo.create("div"); |
||
75 | p.innerHTML="<div style=\"width:50px;height:50px;overflow:hidden;position:absolute;top:0;left:-1000px;\"><div style=\"height:100px;\"></div>";
|
||
76 | var _a=p.firstChild;
|
||
77 | dojo.body().appendChild(_a); |
||
78 | var _b=dojo.contentBox(_a).h;
|
||
79 | dojo.style(_a,"overflow","scroll"); |
||
80 | var _c=_b-dojo.contentBox(_a).h;
|
||
81 | dojo.destroy(_a); |
||
82 | this.getScrollWidth=function(){ |
||
83 | return _c;
|
||
84 | }; |
||
85 | return _c;
|
||
86 | }}); |
||
87 | })(); |
||
88 | } |