Permalink
Browse files

Move the IE stuff to the Canvas class

  • Loading branch information...
certik committed May 25, 2010
1 parent 67b4be0 commit 49a900a530f372d378777c368090fed2be3cc1fe
Showing with 10 additions and 8 deletions.
  1. +5 −4 examples/ui.html
  2. +5 −4 examples/ui.py
View
@@ -106,7 +106,11 @@
_Canvas.prototype.__class__ = _Canvas;
_Canvas.prototype.toString = _iter.prototype.toString;
_Canvas.prototype.__init__ = function(id) {
- this._obj = Ext.getDom(js(id)).getContext(js(str("2d")));
+ var dom = Ext.getDom(js(id));
+ if (py_builtins.bool(Ext.isIE)) {
+ G_vmlCanvasManager.initElement(dom);
+ }
+ this._obj = dom.getContext(js(str("2d")));
}
_Canvas.prototype.fillRect = function(x1, y1, w, h) {
this._obj.fillStyle = js(this.fillStyle);
@@ -286,9 +290,6 @@
tuple([str("html"), str("<canvas id='canvas' width='200' height='200'></canvas>")]),
tuple([str("collapsible"), true])
])));
- if (py_builtins.bool(Ext.isIE)) {
- G_vmlCanvasManager.initElement(Ext.getDom(str("canvas")));
- }
return p;
});
var toolbar_mesh1 = $def({}, function(b, e) {
View
@@ -80,9 +80,6 @@ def get_panel():
"html": "<canvas id='canvas' width='200' height='200'></canvas>",
"collapsible": true
})
- if Ext.isIE:
- # This is needed for IE to emulate the canvas element:
- G_vmlCanvasManager.initElement(Ext.getDom('canvas'))
return p
def toolbar_mesh1(b, e):
@@ -210,7 +207,11 @@ def info_box(title, msg):
class Canvas(object):
def __init__(self, id):
- self._obj = Ext.getDom(js(id)).getContext(js('2d'))
+ dom = Ext.getDom(js(id))
+ if Ext.isIE:
+ # This is needed for IE to emulate the canvas element:
+ G_vmlCanvasManager.initElement(dom)
+ self._obj = dom.getContext(js('2d'))
def fillRect(self, x1, y1, w, h):
self._obj.fillStyle = js(self.fillStyle)

0 comments on commit 49a900a

Please sign in to comment.