Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move addons into main pyjamas library, convert Canvas2D to semi-work …
…under hulahop git-svn-id: https://pyjamas.svn.sourceforge.net/svnroot/pyjamas/trunk@771 7a2bd370-bda8-463c-979e-2900ccfb811e
- Loading branch information
lkcl
committed
Jul 3, 2009
1 parent
3b7edbf
commit 5037d8b
Showing
11 changed files
with
120 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
class Canvas(Widget): | ||
|
||
def isEmulation(self): | ||
JS(""" | ||
return (typeof $wnd.G_vmlCanvasManager != "undefined"); | ||
""") | ||
|
||
def init(self): | ||
JS(""" | ||
var el = this.getElement().firstChild; | ||
if (typeof $wnd.G_vmlCanvasManager != "undefined") { | ||
var parent = el.parent; | ||
el = $wnd.G_vmlCanvasManager.fixElement_(el); | ||
el.getContext = function () { | ||
if (this.context_) { | ||
return this.context_; | ||
} | ||
return this.context_ = new $wnd.CanvasRenderingContext2D(el); | ||
}; | ||
el.attachEvent("onpropertychange", function (e) { | ||
// we need to watch changes to width and height | ||
switch (e.propertyName) { | ||
case "width": | ||
case "height": | ||
// coord size changed? | ||
break; | ||
} | ||
}); | ||
// if style.height is set | ||
var attrs = el.attributes; | ||
if (attrs.width && attrs.width.specified) { | ||
// TODO: use runtimeStyle and coordsize | ||
// el.getContext().setWidth_(attrs.width.nodeValue); | ||
el.style.width = attrs.width.nodeValue + "px"; | ||
} | ||
if (attrs.height && attrs.height.specified) { | ||
// TODO: use runtimeStyle and coordsize | ||
// el.getContext().setHeight_(attrs.height.nodeValue); | ||
el.style.height = attrs.height.nodeValue + "px"; | ||
} | ||
} | ||
var ctx = el.getContext("2d"); | ||
ctx._createPattern = ctx.createPattern; | ||
ctx.createPattern = function(img, rep) { | ||
if (!(img instanceof Image)) img = img.getElement(); | ||
return this._createPattern(img, rep); | ||
} | ||
ctx._drawImage = ctx.drawImage; | ||
ctx.drawImage = function() { | ||
var a=arguments; | ||
if (!(a[0] instanceof Image)) a[0] = a[0].getElement(); | ||
if (a.length==9) return this._drawImage(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]); | ||
else if (a.length==5) return this._drawImage(a[0], a[1], a[2], a[3], a[4]); | ||
return this._drawImage(a[0], a[1], a[2]); | ||
} | ||
this.context = ctx; | ||
""") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters